diff --git a/node_modules/es-toolkit/dist/compat/array/uniq.d.mts b/node_modules/es-toolkit/dist/compat/array/uniq.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..48a90711da0447032b6604c79714d9ad5e68321b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniq.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/array/uniq.d.ts +/** + * Creates a duplicate-free version of an array. + * + * This function takes an array and returns a new array containing only the unique values + * from the original array, preserving the order of first occurrence. + * + * @template T - The type of elements in the array. + * @param arr - The array to process. + * @returns A new array with only unique values from the original array. + * + * @example + * const array = [1, 2, 2, 3, 4, 4, 5]; + * const result = uniq(array); + * // result will be [1, 2, 3, 4, 5] + */ +declare function uniq(arr: ArrayLike | null | undefined): T[]; +//#endregion +export { uniq }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/uniq.d.ts b/node_modules/es-toolkit/dist/compat/array/uniq.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..48a90711da0447032b6604c79714d9ad5e68321b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniq.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/array/uniq.d.ts +/** + * Creates a duplicate-free version of an array. + * + * This function takes an array and returns a new array containing only the unique values + * from the original array, preserving the order of first occurrence. + * + * @template T - The type of elements in the array. + * @param arr - The array to process. + * @returns A new array with only unique values from the original array. + * + * @example + * const array = [1, 2, 2, 3, 4, 4, 5]; + * const result = uniq(array); + * // result will be [1, 2, 3, 4, 5] + */ +declare function uniq(arr: ArrayLike | null | undefined): T[]; +//#endregion +export { uniq }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/uniq.js b/node_modules/es-toolkit/dist/compat/array/uniq.js new file mode 100644 index 0000000000000000000000000000000000000000..07d253ef6a5458bacad263d4edb68c88e9594c9c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniq.js @@ -0,0 +1,24 @@ +const require_uniq = require("../../array/uniq.js"); +const require_isArrayLike = require("../predicate/isArrayLike.js"); +//#region src/compat/array/uniq.ts +/** +* Creates a duplicate-free version of an array. +* +* This function takes an array and returns a new array containing only the unique values +* from the original array, preserving the order of first occurrence. +* +* @template T - The type of elements in the array. +* @param arr - The array to process. +* @returns A new array with only unique values from the original array. +* +* @example +* const array = [1, 2, 2, 3, 4, 4, 5]; +* const result = uniq(array); +* // result will be [1, 2, 3, 4, 5] +*/ +function uniq(arr) { + if (!require_isArrayLike.isArrayLike(arr)) return []; + return require_uniq.uniq(Array.from(arr)); +} +//#endregion +exports.uniq = uniq; diff --git a/node_modules/es-toolkit/dist/compat/array/uniq.mjs b/node_modules/es-toolkit/dist/compat/array/uniq.mjs new file mode 100644 index 0000000000000000000000000000000000000000..99d7c591e4bf17fde70e42c64e005cfaddad379c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniq.mjs @@ -0,0 +1,24 @@ +import { uniq as uniq$1 } from "../../array/uniq.mjs"; +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +//#region src/compat/array/uniq.ts +/** +* Creates a duplicate-free version of an array. +* +* This function takes an array and returns a new array containing only the unique values +* from the original array, preserving the order of first occurrence. +* +* @template T - The type of elements in the array. +* @param arr - The array to process. +* @returns A new array with only unique values from the original array. +* +* @example +* const array = [1, 2, 2, 3, 4, 4, 5]; +* const result = uniq(array); +* // result will be [1, 2, 3, 4, 5] +*/ +function uniq(arr) { + if (!isArrayLike(arr)) return []; + return uniq$1(Array.from(arr)); +} +//#endregion +export { uniq }; diff --git a/node_modules/es-toolkit/dist/compat/array/uniqBy.d.mts b/node_modules/es-toolkit/dist/compat/array/uniqBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..236ec86097e10af59cd31c76d306d9cc8c237087 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniqBy.d.mts @@ -0,0 +1,18 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.mjs"; + +//#region src/compat/array/uniqBy.d.ts +/** + * Creates a duplicate-free version of an array, using an optional transform function. + * + * @template T + * @param array - The array to inspect. + * @param iteratee - The transform function or property name to get values from. + * @returns Returns the new duplicate-free array. + * + * @example + * uniqBy([2.1, 1.2, 2.3], Math.floor); + * // => [2.1, 1.2] + */ +declare function uniqBy(array: ArrayLike | null | undefined, iteratee: ValueIteratee): T[]; +//#endregion +export { uniqBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/uniqBy.d.ts b/node_modules/es-toolkit/dist/compat/array/uniqBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..db0bea2a309e3b0997849ea4c8a13cb1f5ab914c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniqBy.d.ts @@ -0,0 +1,18 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.js"; + +//#region src/compat/array/uniqBy.d.ts +/** + * Creates a duplicate-free version of an array, using an optional transform function. + * + * @template T + * @param array - The array to inspect. + * @param iteratee - The transform function or property name to get values from. + * @returns Returns the new duplicate-free array. + * + * @example + * uniqBy([2.1, 1.2, 2.3], Math.floor); + * // => [2.1, 1.2] + */ +declare function uniqBy(array: ArrayLike | null | undefined, iteratee: ValueIteratee): T[]; +//#endregion +export { uniqBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/uniqBy.js b/node_modules/es-toolkit/dist/compat/array/uniqBy.js new file mode 100644 index 0000000000000000000000000000000000000000..caf1d3179b6ac0432985634dc5ade202398aca1d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniqBy.js @@ -0,0 +1,12 @@ +const require_uniqBy = require("../../array/uniqBy.js"); +const require_ary = require("../../function/ary.js"); +const require_identity = require("../../function/identity.js"); +const require_iteratee = require("../util/iteratee.js"); +const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js"); +//#region src/compat/array/uniqBy.ts +function uniqBy(array, iteratee$1 = require_identity.identity) { + if (!require_isArrayLikeObject.isArrayLikeObject(array)) return []; + return require_uniqBy.uniqBy(Array.from(array), require_ary.ary(require_iteratee.iteratee(iteratee$1), 1)); +} +//#endregion +exports.uniqBy = uniqBy; diff --git a/node_modules/es-toolkit/dist/compat/array/uniqBy.mjs b/node_modules/es-toolkit/dist/compat/array/uniqBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0252c4b803c1bc1eb9bb286263850497c7882260 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniqBy.mjs @@ -0,0 +1,12 @@ +import { uniqBy as uniqBy$1 } from "../../array/uniqBy.mjs"; +import { ary } from "../../function/ary.mjs"; +import { identity } from "../../function/identity.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs"; +//#region src/compat/array/uniqBy.ts +function uniqBy(array, iteratee$1 = identity) { + if (!isArrayLikeObject(array)) return []; + return uniqBy$1(Array.from(array), ary(iteratee(iteratee$1), 1)); +} +//#endregion +export { uniqBy }; diff --git a/node_modules/es-toolkit/dist/compat/array/uniqWith.d.mts b/node_modules/es-toolkit/dist/compat/array/uniqWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..48e34e70319d1c2070db2224cc3fa874d335f4db --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniqWith.d.mts @@ -0,0 +1,28 @@ +//#region src/compat/array/uniqWith.d.ts +type Comparator = (a: T, b: T) => boolean; +/** + * This method is like `uniq`, except that it accepts a `comparator` which is used to determine the equality of elements. + * + * It creates a duplicate-free version of an array, in which only the first occurrence of each element is kept. + * If a `comparator` is provided, it will be invoked with two arguments: `(arrVal, othVal)` to compare elements. + * If no comparator is provided, shallow equality is used. + * + * The order of result values is determined by the order they appear in the input array. + * + * @template T - The type of elements in the array. + * @param arr - The array to process. + * @param [comparator] - Optional function to compare elements for equality. + * @returns A new array with only unique values based on the comparator. + * + * @example + * const array = [1, 2, 2, 3]; + * const result = uniqWith(array); + * // result will be [1, 2, 3] + * + * const array = [1, 2, 3]; + * const result = uniqWith(array, (a, b) => a % 2 === b % 2) + * // result will be [1, 2] + */ +declare function uniqWith(arr: ArrayLike | null | undefined, comparator?: Comparator): T[]; +//#endregion +export { uniqWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/uniqWith.d.ts b/node_modules/es-toolkit/dist/compat/array/uniqWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..48e34e70319d1c2070db2224cc3fa874d335f4db --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniqWith.d.ts @@ -0,0 +1,28 @@ +//#region src/compat/array/uniqWith.d.ts +type Comparator = (a: T, b: T) => boolean; +/** + * This method is like `uniq`, except that it accepts a `comparator` which is used to determine the equality of elements. + * + * It creates a duplicate-free version of an array, in which only the first occurrence of each element is kept. + * If a `comparator` is provided, it will be invoked with two arguments: `(arrVal, othVal)` to compare elements. + * If no comparator is provided, shallow equality is used. + * + * The order of result values is determined by the order they appear in the input array. + * + * @template T - The type of elements in the array. + * @param arr - The array to process. + * @param [comparator] - Optional function to compare elements for equality. + * @returns A new array with only unique values based on the comparator. + * + * @example + * const array = [1, 2, 2, 3]; + * const result = uniqWith(array); + * // result will be [1, 2, 3] + * + * const array = [1, 2, 3]; + * const result = uniqWith(array, (a, b) => a % 2 === b % 2) + * // result will be [1, 2] + */ +declare function uniqWith(arr: ArrayLike | null | undefined, comparator?: Comparator): T[]; +//#endregion +export { uniqWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/uniqWith.js b/node_modules/es-toolkit/dist/compat/array/uniqWith.js new file mode 100644 index 0000000000000000000000000000000000000000..9ec74f8681ebac25a3e24f7686528ff187d84503 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniqWith.js @@ -0,0 +1,34 @@ +const require_uniqWith = require("../../array/uniqWith.js"); +const require_isArrayLike = require("../predicate/isArrayLike.js"); +const require_uniq = require("./uniq.js"); +//#region src/compat/array/uniqWith.ts +/** +* This method is like `uniq`, except that it accepts a `comparator` which is used to determine the equality of elements. +* +* It creates a duplicate-free version of an array, in which only the first occurrence of each element is kept. +* If a `comparator` is provided, it will be invoked with two arguments: `(arrVal, othVal)` to compare elements. +* If no comparator is provided, shallow equality is used. +* +* The order of result values is determined by the order they appear in the input array. +* +* @template T - The type of elements in the array. +* @param arr - The array to process. +* @param [comparator] - Optional function to compare elements for equality. +* @returns A new array with only unique values based on the comparator. +* +* @example +* const array = [1, 2, 2, 3]; +* const result = uniqWith(array); +* // result will be [1, 2, 3] +* +* const array = [1, 2, 3]; +* const result = uniqWith(array, (a, b) => a % 2 === b % 2) +* // result will be [1, 2] +*/ +function uniqWith(arr, comparator) { + if (!require_isArrayLike.isArrayLike(arr)) return []; + if (typeof comparator !== "function") return require_uniq.uniq(Array.from(arr)); + return require_uniqWith.uniqWith(Array.from(arr), (kept, candidate) => comparator(candidate, kept)); +} +//#endregion +exports.uniqWith = uniqWith; diff --git a/node_modules/es-toolkit/dist/compat/array/uniqWith.mjs b/node_modules/es-toolkit/dist/compat/array/uniqWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8d2f305b24e6b73cbe75558d757f9d3aa7f31c09 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/uniqWith.mjs @@ -0,0 +1,34 @@ +import { uniqWith as uniqWith$1 } from "../../array/uniqWith.mjs"; +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +import { uniq } from "./uniq.mjs"; +//#region src/compat/array/uniqWith.ts +/** +* This method is like `uniq`, except that it accepts a `comparator` which is used to determine the equality of elements. +* +* It creates a duplicate-free version of an array, in which only the first occurrence of each element is kept. +* If a `comparator` is provided, it will be invoked with two arguments: `(arrVal, othVal)` to compare elements. +* If no comparator is provided, shallow equality is used. +* +* The order of result values is determined by the order they appear in the input array. +* +* @template T - The type of elements in the array. +* @param arr - The array to process. +* @param [comparator] - Optional function to compare elements for equality. +* @returns A new array with only unique values based on the comparator. +* +* @example +* const array = [1, 2, 2, 3]; +* const result = uniqWith(array); +* // result will be [1, 2, 3] +* +* const array = [1, 2, 3]; +* const result = uniqWith(array, (a, b) => a % 2 === b % 2) +* // result will be [1, 2] +*/ +function uniqWith(arr, comparator) { + if (!isArrayLike(arr)) return []; + if (typeof comparator !== "function") return uniq(Array.from(arr)); + return uniqWith$1(Array.from(arr), (kept, candidate) => comparator(candidate, kept)); +} +//#endregion +export { uniqWith }; diff --git a/node_modules/es-toolkit/dist/compat/array/unzip.d.mts b/node_modules/es-toolkit/dist/compat/array/unzip.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ea34c46f1f96088673a6826a0b221d34f25fed29 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/unzip.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/array/unzip.d.ts +/** + * Gathers elements in the same position in an internal array + * from a grouped array of elements and returns them as a new array. + * + * @template T - The type of elements in the nested array. + * @param array - The nested array to unzip. + * @returns A new array of unzipped elements. + * + * @example + * const zipped = [['a', true, 1],['b', false, 2]]; + * const result = unzip(zipped); + * // result will be [['a', 'b'], [true, false], [1, 2]] + */ +declare function unzip(array: T[][] | ArrayLike> | null | undefined): T[][]; +//#endregion +export { unzip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/unzip.d.ts b/node_modules/es-toolkit/dist/compat/array/unzip.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea34c46f1f96088673a6826a0b221d34f25fed29 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/unzip.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/array/unzip.d.ts +/** + * Gathers elements in the same position in an internal array + * from a grouped array of elements and returns them as a new array. + * + * @template T - The type of elements in the nested array. + * @param array - The nested array to unzip. + * @returns A new array of unzipped elements. + * + * @example + * const zipped = [['a', true, 1],['b', false, 2]]; + * const result = unzip(zipped); + * // result will be [['a', 'b'], [true, false], [1, 2]] + */ +declare function unzip(array: T[][] | ArrayLike> | null | undefined): T[][]; +//#endregion +export { unzip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/unzip.js b/node_modules/es-toolkit/dist/compat/array/unzip.js new file mode 100644 index 0000000000000000000000000000000000000000..706fa9c48edb5013644b4361f4f7a27360bc66d4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/unzip.js @@ -0,0 +1,25 @@ +const require_unzip = require("../../array/unzip.js"); +const require_isArray = require("../predicate/isArray.js"); +const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js"); +//#region src/compat/array/unzip.ts +/** +* Gathers elements in the same position in an internal array +* from a grouped array of elements and returns them as a new array. +* +* @template T - The type of elements in the nested array. +* @param array - The nested array to unzip. +* @returns A new array of unzipped elements. +* +* @example +* const zipped = [['a', true, 1],['b', false, 2]]; +* const result = unzip(zipped); +* // result will be [['a', 'b'], [true, false], [1, 2]] +*/ +function unzip(array) { + if (!require_isArrayLikeObject.isArrayLikeObject(array) || !array.length) return []; + array = require_isArray.isArray(array) ? array : Array.from(array); + array = array.filter((item) => require_isArrayLikeObject.isArrayLikeObject(item)); + return require_unzip.unzip(array); +} +//#endregion +exports.unzip = unzip; diff --git a/node_modules/es-toolkit/dist/compat/array/unzip.mjs b/node_modules/es-toolkit/dist/compat/array/unzip.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e183dae818b12e537136e88eb3833d439571e097 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/unzip.mjs @@ -0,0 +1,25 @@ +import { unzip as unzip$1 } from "../../array/unzip.mjs"; +import { isArray } from "../predicate/isArray.mjs"; +import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs"; +//#region src/compat/array/unzip.ts +/** +* Gathers elements in the same position in an internal array +* from a grouped array of elements and returns them as a new array. +* +* @template T - The type of elements in the nested array. +* @param array - The nested array to unzip. +* @returns A new array of unzipped elements. +* +* @example +* const zipped = [['a', true, 1],['b', false, 2]]; +* const result = unzip(zipped); +* // result will be [['a', 'b'], [true, false], [1, 2]] +*/ +function unzip(array) { + if (!isArrayLikeObject(array) || !array.length) return []; + array = isArray(array) ? array : Array.from(array); + array = array.filter((item) => isArrayLikeObject(item)); + return unzip$1(array); +} +//#endregion +export { unzip }; diff --git a/node_modules/es-toolkit/dist/compat/array/unzipWith.d.mts b/node_modules/es-toolkit/dist/compat/array/unzipWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7c5a36707f2be039e51b849f204338633a7be2e3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/unzipWith.d.mts @@ -0,0 +1,31 @@ +//#region src/compat/array/unzipWith.d.ts +/** + * This method is like `unzip` except that it accepts an iteratee to specify + * how regrouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). + * + * @template T, R + * @param array - The array of grouped elements to process. + * @param iteratee - The function to combine regrouped values. + * @returns Returns the new array of regrouped elements. + * + * @example + * unzipWith([[1, 10, 100], [2, 20, 200]], (a, b) => a + b); + * // => [3, 30, 300] + */ +declare function unzipWith(array: ArrayLike> | null | undefined, iteratee: (...values: T[]) => R): R[]; +/** + * This method is like `unzip` except that it accepts an iteratee to specify + * how regrouped values should be combined. + * + * @template T + * @param array - The array of grouped elements to process. + * @returns Returns the new array of regrouped elements. + * + * @example + * unzipWith([[1, 10, 100], [2, 20, 200]]); + * // => [[1, 2], [10, 20], [100, 200]] + */ +declare function unzipWith(array: ArrayLike> | null | undefined): T[][]; +//#endregion +export { unzipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/unzipWith.d.ts b/node_modules/es-toolkit/dist/compat/array/unzipWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c5a36707f2be039e51b849f204338633a7be2e3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/unzipWith.d.ts @@ -0,0 +1,31 @@ +//#region src/compat/array/unzipWith.d.ts +/** + * This method is like `unzip` except that it accepts an iteratee to specify + * how regrouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). + * + * @template T, R + * @param array - The array of grouped elements to process. + * @param iteratee - The function to combine regrouped values. + * @returns Returns the new array of regrouped elements. + * + * @example + * unzipWith([[1, 10, 100], [2, 20, 200]], (a, b) => a + b); + * // => [3, 30, 300] + */ +declare function unzipWith(array: ArrayLike> | null | undefined, iteratee: (...values: T[]) => R): R[]; +/** + * This method is like `unzip` except that it accepts an iteratee to specify + * how regrouped values should be combined. + * + * @template T + * @param array - The array of grouped elements to process. + * @returns Returns the new array of regrouped elements. + * + * @example + * unzipWith([[1, 10, 100], [2, 20, 200]]); + * // => [[1, 2], [10, 20], [100, 200]] + */ +declare function unzipWith(array: ArrayLike> | null | undefined): T[][]; +//#endregion +export { unzipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/unzipWith.js b/node_modules/es-toolkit/dist/compat/array/unzipWith.js new file mode 100644 index 0000000000000000000000000000000000000000..0ef97c24ec9f12988a8fd2e15cfb75d6ea72d88c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/unzipWith.js @@ -0,0 +1,33 @@ +const require_unzip = require("../../array/unzip.js"); +const require_isArray = require("../predicate/isArray.js"); +const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js"); +//#region src/compat/array/unzipWith.ts +/** +* Unzips an array of arrays, applying an `iteratee` function to regrouped elements. +* +* If the array is `null` or `undefined`, returns an empty array. +* +* @template T +* @param array - The nested array to unzip. This is an array of arrays, +* where each inner array contains elements to be unzipped. +* @param iteratee - A function to transform the unzipped elements. +* @returns A new array of unzipped and transformed elements. +* +* @example +* const nestedArray = [[1, 2], [3, 4], [5, 6]]; +* const result = unzipWith(nestedArray, (a, b) => a + b); +* console.log(result); // [9, 12] +*/ +function unzipWith(array, iteratee) { + if (!require_isArrayLikeObject.isArrayLikeObject(array) || !array.length) return []; + const unzipped = require_isArray.isArray(array) ? require_unzip.unzip(array) : require_unzip.unzip(Array.from(array, (value) => Array.from(value))); + if (!iteratee) return unzipped; + const result = new Array(unzipped.length); + for (let i = 0; i < unzipped.length; i++) { + const value = unzipped[i]; + result[i] = iteratee(...value); + } + return result; +} +//#endregion +exports.unzipWith = unzipWith; diff --git a/node_modules/es-toolkit/dist/compat/array/unzipWith.mjs b/node_modules/es-toolkit/dist/compat/array/unzipWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..233aedebad5700e12443ca11e1e3348d5ece5457 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/unzipWith.mjs @@ -0,0 +1,33 @@ +import { unzip } from "../../array/unzip.mjs"; +import { isArray } from "../predicate/isArray.mjs"; +import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs"; +//#region src/compat/array/unzipWith.ts +/** +* Unzips an array of arrays, applying an `iteratee` function to regrouped elements. +* +* If the array is `null` or `undefined`, returns an empty array. +* +* @template T +* @param array - The nested array to unzip. This is an array of arrays, +* where each inner array contains elements to be unzipped. +* @param iteratee - A function to transform the unzipped elements. +* @returns A new array of unzipped and transformed elements. +* +* @example +* const nestedArray = [[1, 2], [3, 4], [5, 6]]; +* const result = unzipWith(nestedArray, (a, b) => a + b); +* console.log(result); // [9, 12] +*/ +function unzipWith(array, iteratee) { + if (!isArrayLikeObject(array) || !array.length) return []; + const unzipped = isArray(array) ? unzip(array) : unzip(Array.from(array, (value) => Array.from(value))); + if (!iteratee) return unzipped; + const result = new Array(unzipped.length); + for (let i = 0; i < unzipped.length; i++) { + const value = unzipped[i]; + result[i] = iteratee(...value); + } + return result; +} +//#endregion +export { unzipWith }; diff --git a/node_modules/es-toolkit/dist/compat/array/without.d.mts b/node_modules/es-toolkit/dist/compat/array/without.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1ffa13ab6a208975627f50a5f326730574666ac6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/without.d.mts @@ -0,0 +1,24 @@ +//#region src/compat/array/without.d.ts +/** + * Creates an array that excludes all specified values. + * + * It correctly excludes `NaN`, as it compares values using [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero). + * + * @template T The type of elements in the array. + * @param array - The array to filter. + * @param values - The values to exclude. + * @returns A new array without the specified values. + * + * @example + * // Removes the specified values from the array + * without([1, 2, 3, 4, 5], 2, 4); + * // Returns: [1, 3, 5] + * + * @example + * // Removes specified string values from the array + * without(['a', 'b', 'c', 'a'], 'a'); + * // Returns: ['b', 'c'] + */ +declare function without(array: ArrayLike | null | undefined, ...values: T[]): T[]; +//#endregion +export { without }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/without.d.ts b/node_modules/es-toolkit/dist/compat/array/without.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ffa13ab6a208975627f50a5f326730574666ac6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/without.d.ts @@ -0,0 +1,24 @@ +//#region src/compat/array/without.d.ts +/** + * Creates an array that excludes all specified values. + * + * It correctly excludes `NaN`, as it compares values using [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero). + * + * @template T The type of elements in the array. + * @param array - The array to filter. + * @param values - The values to exclude. + * @returns A new array without the specified values. + * + * @example + * // Removes the specified values from the array + * without([1, 2, 3, 4, 5], 2, 4); + * // Returns: [1, 3, 5] + * + * @example + * // Removes specified string values from the array + * without(['a', 'b', 'c', 'a'], 'a'); + * // Returns: ['b', 'c'] + */ +declare function without(array: ArrayLike | null | undefined, ...values: T[]): T[]; +//#endregion +export { without }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/without.js b/node_modules/es-toolkit/dist/compat/array/without.js new file mode 100644 index 0000000000000000000000000000000000000000..11835f9e84631ec1060dae1814e2025fbfc70a62 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/without.js @@ -0,0 +1,29 @@ +const require_without = require("../../array/without.js"); +const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js"); +//#region src/compat/array/without.ts +/** +* Creates an array that excludes all specified values. +* +* It correctly excludes `NaN`, as it compares values using [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero). +* +* @template T The type of elements in the array. +* @param array - The array to filter. +* @param values - The values to exclude. +* @returns A new array without the specified values. +* +* @example +* // Removes the specified values from the array +* without([1, 2, 3, 4, 5], 2, 4); +* // Returns: [1, 3, 5] +* +* @example +* // Removes specified string values from the array +* without(['a', 'b', 'c', 'a'], 'a'); +* // Returns: ['b', 'c'] +*/ +function without(array, ...values) { + if (!require_isArrayLikeObject.isArrayLikeObject(array)) return []; + return require_without.without(Array.from(array), ...values); +} +//#endregion +exports.without = without; diff --git a/node_modules/es-toolkit/dist/compat/array/without.mjs b/node_modules/es-toolkit/dist/compat/array/without.mjs new file mode 100644 index 0000000000000000000000000000000000000000..44509425523e8ed2406c72f43e940ad2f6a6b189 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/without.mjs @@ -0,0 +1,29 @@ +import { without as without$1 } from "../../array/without.mjs"; +import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs"; +//#region src/compat/array/without.ts +/** +* Creates an array that excludes all specified values. +* +* It correctly excludes `NaN`, as it compares values using [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero). +* +* @template T The type of elements in the array. +* @param array - The array to filter. +* @param values - The values to exclude. +* @returns A new array without the specified values. +* +* @example +* // Removes the specified values from the array +* without([1, 2, 3, 4, 5], 2, 4); +* // Returns: [1, 3, 5] +* +* @example +* // Removes specified string values from the array +* without(['a', 'b', 'c', 'a'], 'a'); +* // Returns: ['b', 'c'] +*/ +function without(array, ...values) { + if (!isArrayLikeObject(array)) return []; + return without$1(Array.from(array), ...values); +} +//#endregion +export { without }; diff --git a/node_modules/es-toolkit/dist/compat/array/xor.d.mts b/node_modules/es-toolkit/dist/compat/array/xor.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4259e8f3519c85e6b0dd7282a15f7b46b837639a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xor.d.mts @@ -0,0 +1,24 @@ +//#region src/compat/array/xor.d.ts +/** + * Computes the symmetric difference of the provided arrays, returning an array of elements + * that exist in only one of the arrays. + * + * @template T - The type of elements in the arrays. + * @param arrays - The arrays to compare. + * @returns An array containing the elements that are present in only one of the provided `arrays`. + * + * @example + * // Returns [1, 2, 5, 6] + * xor([1, 2, 3, 4], [3, 4, 5, 6]); + * + * @example + * // Returns ['a', 'c'] + * xor(['a', 'b'], ['b', 'c']); + * + * @example + * // Returns [1, 3, 5] + * xor([1, 2], [2, 3], [4, 5]); + */ +declare function xor(...arrays: Array | null | undefined>): T[]; +//#endregion +export { xor }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/xor.d.ts b/node_modules/es-toolkit/dist/compat/array/xor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4259e8f3519c85e6b0dd7282a15f7b46b837639a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xor.d.ts @@ -0,0 +1,24 @@ +//#region src/compat/array/xor.d.ts +/** + * Computes the symmetric difference of the provided arrays, returning an array of elements + * that exist in only one of the arrays. + * + * @template T - The type of elements in the arrays. + * @param arrays - The arrays to compare. + * @returns An array containing the elements that are present in only one of the provided `arrays`. + * + * @example + * // Returns [1, 2, 5, 6] + * xor([1, 2, 3, 4], [3, 4, 5, 6]); + * + * @example + * // Returns ['a', 'c'] + * xor(['a', 'b'], ['b', 'c']); + * + * @example + * // Returns [1, 3, 5] + * xor([1, 2], [2, 3], [4, 5]); + */ +declare function xor(...arrays: Array | null | undefined>): T[]; +//#endregion +export { xor }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/xor.js b/node_modules/es-toolkit/dist/compat/array/xor.js new file mode 100644 index 0000000000000000000000000000000000000000..33d3f37c31aef99a5228a4a5613da203bbf47a7b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xor.js @@ -0,0 +1,38 @@ +const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js"); +const require_toArray = require("../util/toArray.js"); +//#region src/compat/array/xor.ts +/** +* Computes the symmetric difference of the provided arrays, returning an array of elements +* that exist in only one of the arrays. +* +* @template T - The type of elements in the arrays. +* @param arrays - The arrays to compare. +* @returns An array containing the elements that are present in only one of the provided `arrays`. +* +* @example +* // Returns [1, 2, 5, 6] +* xor([1, 2, 3, 4], [3, 4, 5, 6]); +* +* @example +* // Returns ['a', 'c'] +* xor(['a', 'b'], ['b', 'c']); +* +* @example +* // Returns [1, 3, 5] +* xor([1, 2], [2, 3], [4, 5]); +*/ +function xor(...arrays) { + const itemCounts = /* @__PURE__ */ new Map(); + for (let i = 0; i < arrays.length; i++) { + const array = arrays[i]; + if (!require_isArrayLikeObject.isArrayLikeObject(array)) continue; + const itemSet = new Set(require_toArray.toArray(array)); + for (const item of itemSet) if (!itemCounts.has(item)) itemCounts.set(item, 1); + else itemCounts.set(item, itemCounts.get(item) + 1); + } + const result = []; + for (const [item, count] of itemCounts) if (count === 1) result.push(item); + return result; +} +//#endregion +exports.xor = xor; diff --git a/node_modules/es-toolkit/dist/compat/array/xor.mjs b/node_modules/es-toolkit/dist/compat/array/xor.mjs new file mode 100644 index 0000000000000000000000000000000000000000..29b641804d71bd7841ea8e8cac4ba8d269fa1c9b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xor.mjs @@ -0,0 +1,38 @@ +import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs"; +import { toArray } from "../util/toArray.mjs"; +//#region src/compat/array/xor.ts +/** +* Computes the symmetric difference of the provided arrays, returning an array of elements +* that exist in only one of the arrays. +* +* @template T - The type of elements in the arrays. +* @param arrays - The arrays to compare. +* @returns An array containing the elements that are present in only one of the provided `arrays`. +* +* @example +* // Returns [1, 2, 5, 6] +* xor([1, 2, 3, 4], [3, 4, 5, 6]); +* +* @example +* // Returns ['a', 'c'] +* xor(['a', 'b'], ['b', 'c']); +* +* @example +* // Returns [1, 3, 5] +* xor([1, 2], [2, 3], [4, 5]); +*/ +function xor(...arrays) { + const itemCounts = /* @__PURE__ */ new Map(); + for (let i = 0; i < arrays.length; i++) { + const array = arrays[i]; + if (!isArrayLikeObject(array)) continue; + const itemSet = new Set(toArray(array)); + for (const item of itemSet) if (!itemCounts.has(item)) itemCounts.set(item, 1); + else itemCounts.set(item, itemCounts.get(item) + 1); + } + const result = []; + for (const [item, count] of itemCounts) if (count === 1) result.push(item); + return result; +} +//#endregion +export { xor }; diff --git a/node_modules/es-toolkit/dist/compat/array/xorBy.d.mts b/node_modules/es-toolkit/dist/compat/array/xorBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1caf1eb91704b9ee0016a98c727a1abfdb80a610 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xorBy.d.mts @@ -0,0 +1,57 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.mjs"; + +//#region src/compat/array/xorBy.d.ts +/** + * This method is like `xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by which + * uniqueness is computed. The iteratee is invoked with one argument: (value). + * + * @template T + * @param arrays - The arrays to inspect. + * @param [iteratee] - The iteratee invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); + * // => [1.2, 4.3] + * + * @example + * xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] + */ +declare function xorBy(arrays: ArrayLike | null | undefined, iteratee?: ValueIteratee): T[]; +/** + * This method is like `xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by which + * uniqueness is computed. The iteratee is invoked with one argument: (value). + * + * @template T + * @param arrays - The first array to inspect. + * @param arrays2 - The second array to inspect. + * @param [iteratee] - The iteratee invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); + * // => [1.2, 4.3] + */ +declare function xorBy(arrays: ArrayLike | null | undefined, arrays2: ArrayLike | null | undefined, iteratee?: ValueIteratee): T[]; +/** + * This method is like `xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by which + * uniqueness is computed. The iteratee is invoked with one argument: (value). + * + * @template T + * @param arrays - The first array to inspect. + * @param arrays2 - The second array to inspect. + * @param arrays3 - The third array to inspect. + * @param iteratee - The iteratee invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorBy([1.2, 2.3], [3.4, 4.5], [5.6, 6.7], Math.floor); + * // => [1.2, 3.4, 5.6] + */ +declare function xorBy(arrays: ArrayLike | null | undefined, arrays2: ArrayLike | null | undefined, arrays3: ArrayLike | null | undefined, ...iteratee: Array | ArrayLike | null | undefined>): T[]; +//#endregion +export { xorBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/xorBy.d.ts b/node_modules/es-toolkit/dist/compat/array/xorBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba74db80deb86109b0c1938f854661adff431dcc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xorBy.d.ts @@ -0,0 +1,57 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.js"; + +//#region src/compat/array/xorBy.d.ts +/** + * This method is like `xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by which + * uniqueness is computed. The iteratee is invoked with one argument: (value). + * + * @template T + * @param arrays - The arrays to inspect. + * @param [iteratee] - The iteratee invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); + * // => [1.2, 4.3] + * + * @example + * xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] + */ +declare function xorBy(arrays: ArrayLike | null | undefined, iteratee?: ValueIteratee): T[]; +/** + * This method is like `xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by which + * uniqueness is computed. The iteratee is invoked with one argument: (value). + * + * @template T + * @param arrays - The first array to inspect. + * @param arrays2 - The second array to inspect. + * @param [iteratee] - The iteratee invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); + * // => [1.2, 4.3] + */ +declare function xorBy(arrays: ArrayLike | null | undefined, arrays2: ArrayLike | null | undefined, iteratee?: ValueIteratee): T[]; +/** + * This method is like `xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by which + * uniqueness is computed. The iteratee is invoked with one argument: (value). + * + * @template T + * @param arrays - The first array to inspect. + * @param arrays2 - The second array to inspect. + * @param arrays3 - The third array to inspect. + * @param iteratee - The iteratee invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorBy([1.2, 2.3], [3.4, 4.5], [5.6, 6.7], Math.floor); + * // => [1.2, 3.4, 5.6] + */ +declare function xorBy(arrays: ArrayLike | null | undefined, arrays2: ArrayLike | null | undefined, arrays3: ArrayLike | null | undefined, ...iteratee: Array | ArrayLike | null | undefined>): T[]; +//#endregion +export { xorBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/xorBy.js b/node_modules/es-toolkit/dist/compat/array/xorBy.js new file mode 100644 index 0000000000000000000000000000000000000000..c690d0a318e4297026fb7f0bd20d4509f4dc856c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xorBy.js @@ -0,0 +1,40 @@ +const require_windowed = require("../../array/windowed.js"); +const require_identity = require("../../function/identity.js"); +const require_iteratee = require("../util/iteratee.js"); +const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js"); +const require_last = require("./last.js"); +const require_differenceBy = require("./differenceBy.js"); +const require_intersectionBy = require("./intersectionBy.js"); +const require_unionBy = require("./unionBy.js"); +//#region src/compat/array/xorBy.ts +/** +* Computes the symmetric difference between two arrays using a custom mapping function. +* The symmetric difference is the set of elements which are in either of the arrays, +* but not in their intersection, determined by the result of the mapping function. +* +* @template T - Type of elements in the input arrays. +* @template U - Type of the values returned by the mapping function. +* +* @param values - The arrays to inspect, or the function to map array elements to comparison values. +* @returns 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. +* +* @example +* // Custom mapping function for objects with an 'id' property +* const idMapper = obj => obj.id; +* xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper); +* // Returns [{ id: 1 }, { id: 3 }] +*/ +function xorBy(...values) { + const lastValue = require_last.last(values); + let mapper = require_identity.identity; + if (!require_isArrayLikeObject.isArrayLikeObject(lastValue) && lastValue != null) { + mapper = require_iteratee.iteratee(lastValue); + values = values.slice(0, -1); + } + const arrays = values.filter(require_isArrayLikeObject.isArrayLikeObject); + const union = require_unionBy.unionBy(...arrays, mapper); + const intersections = require_windowed.windowed(arrays, 2).map(([arr1, arr2]) => require_intersectionBy.intersectionBy(arr1, arr2, mapper)); + return require_differenceBy.differenceBy(union, require_unionBy.unionBy(...intersections, mapper), mapper); +} +//#endregion +exports.xorBy = xorBy; diff --git a/node_modules/es-toolkit/dist/compat/array/xorBy.mjs b/node_modules/es-toolkit/dist/compat/array/xorBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cd701ab181306e821fbae9b0cac9853eeb28d608 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xorBy.mjs @@ -0,0 +1,38 @@ +import { windowed } from "../../array/windowed.mjs"; +import { identity } from "../../function/identity.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs"; +import { last } from "./last.mjs"; +import { differenceBy } from "./differenceBy.mjs"; +import { intersectionBy } from "./intersectionBy.mjs"; +import { unionBy } from "./unionBy.mjs"; +//#region src/compat/array/xorBy.ts +/** +* Computes the symmetric difference between two arrays using a custom mapping function. +* The symmetric difference is the set of elements which are in either of the arrays, +* but not in their intersection, determined by the result of the mapping function. +* +* @template T - Type of elements in the input arrays. +* @template U - Type of the values returned by the mapping function. +* +* @param values - The arrays to inspect, or the function to map array elements to comparison values. +* @returns 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. +* +* @example +* // Custom mapping function for objects with an 'id' property +* const idMapper = obj => obj.id; +* xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper); +* // Returns [{ id: 1 }, { id: 3 }] +*/ +function xorBy(...values) { + const lastValue = last(values); + let mapper = identity; + if (!isArrayLikeObject(lastValue) && lastValue != null) { + mapper = iteratee(lastValue); + values = values.slice(0, -1); + } + const arrays = values.filter(isArrayLikeObject); + return differenceBy(unionBy(...arrays, mapper), unionBy(...windowed(arrays, 2).map(([arr1, arr2]) => intersectionBy(arr1, arr2, mapper)), mapper), mapper); +} +//#endregion +export { xorBy }; diff --git a/node_modules/es-toolkit/dist/compat/array/xorWith.d.mts b/node_modules/es-toolkit/dist/compat/array/xorWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b4b9007ce067d8e22bf87db8bc370d0dfd889587 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xorWith.d.mts @@ -0,0 +1,53 @@ +//#region src/compat/array/xorWith.d.ts +/** + * This method is like `xor` except that it accepts `comparator` which is + * invoked to compare elements of `arrays`. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @template T + * @param arrays - The arrays to inspect. + * @param [comparator] - The comparator invoked per element. + * @returns Returns the new array of values. + * + * @example + * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * const others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * xorWith(objects, others, isEqual); + * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + */ +declare function xorWith(arrays: ArrayLike | null | undefined, comparator?: (a: T, b: T) => boolean): T[]; +/** + * This method is like `xor` except that it accepts `comparator` which is + * invoked to compare elements of `arrays`. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @template T + * @param arrays - The first array to inspect. + * @param arrays2 - The second array to inspect. + * @param [comparator] - The comparator invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorWith([1, 2], [2, 3], (a, b) => a === b); + * // => [1, 3] + */ +declare function xorWith(arrays: ArrayLike | null | undefined, arrays2: ArrayLike | null | undefined, comparator?: (a: T, b: T) => boolean): T[]; +/** + * This method is like `xor` except that it accepts `comparator` which is + * invoked to compare elements of `arrays`. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @template T + * @param arrays - The first array to inspect. + * @param arrays2 - The second array to inspect. + * @param arrays3 - The third array to inspect. + * @param comparator - The comparator invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorWith([1], [2], [3], (a, b) => a === b); + * // => [1, 2, 3] + */ +declare function xorWith(arrays: ArrayLike | null | undefined, arrays2: ArrayLike | null | undefined, arrays3: ArrayLike | null | undefined, ...comparator: Array<((a: T, b: T) => boolean) | ArrayLike | null | undefined>): T[]; +//#endregion +export { xorWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/xorWith.d.ts b/node_modules/es-toolkit/dist/compat/array/xorWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b4b9007ce067d8e22bf87db8bc370d0dfd889587 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xorWith.d.ts @@ -0,0 +1,53 @@ +//#region src/compat/array/xorWith.d.ts +/** + * This method is like `xor` except that it accepts `comparator` which is + * invoked to compare elements of `arrays`. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @template T + * @param arrays - The arrays to inspect. + * @param [comparator] - The comparator invoked per element. + * @returns Returns the new array of values. + * + * @example + * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * const others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * xorWith(objects, others, isEqual); + * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + */ +declare function xorWith(arrays: ArrayLike | null | undefined, comparator?: (a: T, b: T) => boolean): T[]; +/** + * This method is like `xor` except that it accepts `comparator` which is + * invoked to compare elements of `arrays`. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @template T + * @param arrays - The first array to inspect. + * @param arrays2 - The second array to inspect. + * @param [comparator] - The comparator invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorWith([1, 2], [2, 3], (a, b) => a === b); + * // => [1, 3] + */ +declare function xorWith(arrays: ArrayLike | null | undefined, arrays2: ArrayLike | null | undefined, comparator?: (a: T, b: T) => boolean): T[]; +/** + * This method is like `xor` except that it accepts `comparator` which is + * invoked to compare elements of `arrays`. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @template T + * @param arrays - The first array to inspect. + * @param arrays2 - The second array to inspect. + * @param arrays3 - The third array to inspect. + * @param comparator - The comparator invoked per element. + * @returns Returns the new array of values. + * + * @example + * xorWith([1], [2], [3], (a, b) => a === b); + * // => [1, 2, 3] + */ +declare function xorWith(arrays: ArrayLike | null | undefined, arrays2: ArrayLike | null | undefined, arrays3: ArrayLike | null | undefined, ...comparator: Array<((a: T, b: T) => boolean) | ArrayLike | null | undefined>): T[]; +//#endregion +export { xorWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/xorWith.js b/node_modules/es-toolkit/dist/compat/array/xorWith.js new file mode 100644 index 0000000000000000000000000000000000000000..fa6cb1cfa4da7749cbdd355fb5db7b4150a094ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xorWith.js @@ -0,0 +1,39 @@ +const require_windowed = require("../../array/windowed.js"); +const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js"); +const require_last = require("./last.js"); +const require_differenceWith = require("./differenceWith.js"); +const require_intersectionWith = require("./intersectionWith.js"); +const require_unionWith = require("./unionWith.js"); +//#region src/compat/array/xorWith.ts +/** +* Creates an array of unique values that is the symmetric difference of the given arrays using a custom comparator function. +* +* The symmetric difference is the set of elements which are in either of the arrays, +* but not in their intersection, determined by the comparator function. +* +* @template T - Type of elements in the input arrays. +* +* @param values - The arrays to inspect, or the comparator function. +* @returns An array containing the elements that are present in exactly one of the arrays +* as determined by the comparator. +* +* @example +* // Custom comparator function for objects with an 'id' property +* const idComparator = (a, b) => a.id === b.id; +* xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idComparator); +* // Returns [{ id: 1 }, { id: 3 }] +*/ +function xorWith(...values) { + const lastValue = require_last.last(values); + let comparator = (a, b) => a === b; + if (typeof lastValue === "function") { + comparator = lastValue; + values = values.slice(0, -1); + } + const arrays = values.filter(require_isArrayLikeObject.isArrayLikeObject); + const union = require_unionWith.unionWith(...arrays, comparator); + const intersections = require_windowed.windowed(arrays, 2).map(([arr1, arr2]) => require_intersectionWith.intersectionWith(arr1, arr2, comparator)); + return require_differenceWith.differenceWith(union, require_unionWith.unionWith(...intersections, comparator), comparator); +} +//#endregion +exports.xorWith = xorWith; diff --git a/node_modules/es-toolkit/dist/compat/array/xorWith.mjs b/node_modules/es-toolkit/dist/compat/array/xorWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..387839adf17b5a6a51f8ebf0f834f540edca93cc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/xorWith.mjs @@ -0,0 +1,37 @@ +import { windowed } from "../../array/windowed.mjs"; +import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs"; +import { last } from "./last.mjs"; +import { differenceWith } from "./differenceWith.mjs"; +import { intersectionWith } from "./intersectionWith.mjs"; +import { unionWith } from "./unionWith.mjs"; +//#region src/compat/array/xorWith.ts +/** +* Creates an array of unique values that is the symmetric difference of the given arrays using a custom comparator function. +* +* The symmetric difference is the set of elements which are in either of the arrays, +* but not in their intersection, determined by the comparator function. +* +* @template T - Type of elements in the input arrays. +* +* @param values - The arrays to inspect, or the comparator function. +* @returns An array containing the elements that are present in exactly one of the arrays +* as determined by the comparator. +* +* @example +* // Custom comparator function for objects with an 'id' property +* const idComparator = (a, b) => a.id === b.id; +* xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idComparator); +* // Returns [{ id: 1 }, { id: 3 }] +*/ +function xorWith(...values) { + const lastValue = last(values); + let comparator = (a, b) => a === b; + if (typeof lastValue === "function") { + comparator = lastValue; + values = values.slice(0, -1); + } + const arrays = values.filter(isArrayLikeObject); + return differenceWith(unionWith(...arrays, comparator), unionWith(...windowed(arrays, 2).map(([arr1, arr2]) => intersectionWith(arr1, arr2, comparator)), comparator), comparator); +} +//#endregion +export { xorWith }; diff --git a/node_modules/es-toolkit/dist/compat/array/zip.d.mts b/node_modules/es-toolkit/dist/compat/array/zip.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..90007792f344c21697aac102df98575a13f87cfd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zip.d.mts @@ -0,0 +1,187 @@ +//#region src/compat/array/zip.d.ts +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T, U + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const result = zip(arr1, arr2); + * // result will be [[1, 'a'], [2, 'b'], [3, 'c']] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T, U + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1, 2], ['a', 'b']); + * // => [[1, 'a'], [2, 'b']] + */ +declare function zip(arr1: ArrayLike, arr2: ArrayLike): Array<[T | undefined, U | undefined]>; +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T, U, V + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const arr3 = [true, false]; + * const result = zip(arr1, arr2, arr3); + * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T, U, V + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1, 2], ['a', 'b'], [true, false]); + * // => [[1, 'a', true], [2, 'b', false]] + */ +declare function zip(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike): Array<[T | undefined, U | undefined, V | undefined]>; +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T, U, V, W + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const arr3 = [true, false]; + * const arr4 = [null, null, null]; + * const result = zip(arr1, arr2, arr3, arr4); + * // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T, U, V, W + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1], ['a'], [true], [null]); + * // => [[1, 'a', true, null]] + */ +declare function zip(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, arr4: ArrayLike): Array<[T | undefined, U | undefined, V | undefined, W | undefined]>; +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T, U, V, W + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param arr5 - The fifth array to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const arr3 = [true, false]; + * const arr4 = [null, null, null]; + * const arr5 = [undefined, undefined, undefined]; + * const result = zip(arr1, arr2, arr3, arr4, arr5); + * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T, U, V, W, X + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param arr5 - The fifth array to zip. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1], ['a'], [true], [null], [undefined]); + * // => [[1, 'a', true, null, undefined]] + */ +declare function zip(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, arr4: ArrayLike, arr5: ArrayLike): Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>; +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T + * @param arrays - The arrays to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const arr3 = [true, false]; + * const arr4 = [null, null, null]; + * const arr5 = [undefined, undefined, undefined]; + * const result = zip(arr1, arr2, arr3, arr4, arr5); + * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T + * @param arrays - The arrays to process. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1, 2], ['a', 'b'], [true, false]); + * // => [[1, 'a', true], [2, 'b', false]] + */ +declare function zip(...arrays: Array | null | undefined>): Array>; +//#endregion +export { zip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/zip.d.ts b/node_modules/es-toolkit/dist/compat/array/zip.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..90007792f344c21697aac102df98575a13f87cfd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zip.d.ts @@ -0,0 +1,187 @@ +//#region src/compat/array/zip.d.ts +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T, U + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const result = zip(arr1, arr2); + * // result will be [[1, 'a'], [2, 'b'], [3, 'c']] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T, U + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1, 2], ['a', 'b']); + * // => [[1, 'a'], [2, 'b']] + */ +declare function zip(arr1: ArrayLike, arr2: ArrayLike): Array<[T | undefined, U | undefined]>; +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T, U, V + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const arr3 = [true, false]; + * const result = zip(arr1, arr2, arr3); + * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T, U, V + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1, 2], ['a', 'b'], [true, false]); + * // => [[1, 'a', true], [2, 'b', false]] + */ +declare function zip(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike): Array<[T | undefined, U | undefined, V | undefined]>; +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T, U, V, W + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const arr3 = [true, false]; + * const arr4 = [null, null, null]; + * const result = zip(arr1, arr2, arr3, arr4); + * // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T, U, V, W + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1], ['a'], [true], [null]); + * // => [[1, 'a', true, null]] + */ +declare function zip(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, arr4: ArrayLike): Array<[T | undefined, U | undefined, V | undefined, W | undefined]>; +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T, U, V, W + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param arr5 - The fifth array to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const arr3 = [true, false]; + * const arr4 = [null, null, null]; + * const arr5 = [undefined, undefined, undefined]; + * const result = zip(arr1, arr2, arr3, arr4, arr5); + * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T, U, V, W, X + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param arr5 - The fifth array to zip. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1], ['a'], [true], [null], [undefined]); + * // => [[1, 'a', true, null, undefined]] + */ +declare function zip(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, arr4: ArrayLike, arr5: ArrayLike): Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>; +/** + * Combines multiple arrays into a single array of tuples. + * + * This function takes multiple arrays and returns a new array where each element is a tuple + * containing the corresponding elements from the input arrays. If the input arrays are of + * different lengths, the resulting array will have the length of the longest input array, + * with undefined values for missing elements. + * + * @template T + * @param arrays - The arrays to zip. + * @returns A new array of tuples containing the corresponding elements from the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const arr3 = [true, false]; + * const arr4 = [null, null, null]; + * const arr5 = [undefined, undefined, undefined]; + * const result = zip(arr1, arr2, arr3, arr4, arr5); + * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]] + */ +/** + * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, + * the second of which contains the second elements of the given arrays, and so on. + * + * @template T + * @param arrays - The arrays to process. + * @returns Returns the new array of grouped elements. + * + * @example + * zip([1, 2], ['a', 'b'], [true, false]); + * // => [[1, 'a', true], [2, 'b', false]] + */ +declare function zip(...arrays: Array | null | undefined>): Array>; +//#endregion +export { zip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/zip.js b/node_modules/es-toolkit/dist/compat/array/zip.js new file mode 100644 index 0000000000000000000000000000000000000000..76a2e5301423dde8bc2fed3ae7567541d740b7ba --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zip.js @@ -0,0 +1,30 @@ +const require_zip = require("../../array/zip.js"); +const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js"); +//#region src/compat/array/zip.ts +/** +* Combines multiple arrays into a single array of tuples. +* +* This function takes multiple arrays and returns a new array where each element is a tuple +* containing the corresponding elements from the input arrays. If the input arrays are of +* different lengths, the resulting array will have the length of the longest input array, +* with undefined values for missing elements. +* +* @template T +* @param arrays - The arrays to zip. +* @returns A new array of tuples containing the corresponding elements from the input arrays. +* +* @example +* const arr1 = [1, 2, 3]; +* const arr2 = ['a', 'b', 'c']; +* const arr3 = [true, false]; +* const arr4 = [null, null, null]; +* const arr5 = [undefined, undefined, undefined]; +* const result = zip(arr1, arr2, arr3, arr4, arr5); +* // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]] +*/ +function zip(...arrays) { + if (!arrays.length) return []; + return require_zip.zip(...arrays.filter((group) => require_isArrayLikeObject.isArrayLikeObject(group))); +} +//#endregion +exports.zip = zip; diff --git a/node_modules/es-toolkit/dist/compat/array/zip.mjs b/node_modules/es-toolkit/dist/compat/array/zip.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a3be7070e13e2dd3e90e056cf88c8c40b5f59e11 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zip.mjs @@ -0,0 +1,30 @@ +import { zip as zip$1 } from "../../array/zip.mjs"; +import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs"; +//#region src/compat/array/zip.ts +/** +* Combines multiple arrays into a single array of tuples. +* +* This function takes multiple arrays and returns a new array where each element is a tuple +* containing the corresponding elements from the input arrays. If the input arrays are of +* different lengths, the resulting array will have the length of the longest input array, +* with undefined values for missing elements. +* +* @template T +* @param arrays - The arrays to zip. +* @returns A new array of tuples containing the corresponding elements from the input arrays. +* +* @example +* const arr1 = [1, 2, 3]; +* const arr2 = ['a', 'b', 'c']; +* const arr3 = [true, false]; +* const arr4 = [null, null, null]; +* const arr5 = [undefined, undefined, undefined]; +* const result = zip(arr1, arr2, arr3, arr4, arr5); +* // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]] +*/ +function zip(...arrays) { + if (!arrays.length) return []; + return zip$1(...arrays.filter((group) => isArrayLikeObject(group))); +} +//#endregion +export { zip }; diff --git a/node_modules/es-toolkit/dist/compat/array/zipObject.d.mts b/node_modules/es-toolkit/dist/compat/array/zipObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0c8eaacbc171e47a422a9ac4da9914f1e5bebd3c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipObject.d.mts @@ -0,0 +1,30 @@ +//#region src/compat/array/zipObject.d.ts +/** + * Combines two arrays, one of property names and one of corresponding values, into a single object. + * + * @template T - The type of values in the values array + * @param props - An array of property names + * @param values - An array of values corresponding to the property names + * @returns A new object composed of the given property names and values + * + * @example + * const props = ['a', 'b', 'c']; + * const values = [1, 2, 3]; + * zipObject(props, values); + * // => { a: 1, b: 2, c: 3 } + */ +declare function zipObject(props: ArrayLike, values: ArrayLike): Record; +/** + * Creates an object from an array of property names, with undefined values. + * + * @param [props] - An array of property names + * @returns A new object with the given property names and undefined values + * + * @example + * const props = ['a', 'b', 'c']; + * zipObject(props); + * // => { a: undefined, b: undefined, c: undefined } + */ +declare function zipObject(props?: ArrayLike): Record; +//#endregion +export { zipObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/zipObject.d.ts b/node_modules/es-toolkit/dist/compat/array/zipObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c8eaacbc171e47a422a9ac4da9914f1e5bebd3c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipObject.d.ts @@ -0,0 +1,30 @@ +//#region src/compat/array/zipObject.d.ts +/** + * Combines two arrays, one of property names and one of corresponding values, into a single object. + * + * @template T - The type of values in the values array + * @param props - An array of property names + * @param values - An array of values corresponding to the property names + * @returns A new object composed of the given property names and values + * + * @example + * const props = ['a', 'b', 'c']; + * const values = [1, 2, 3]; + * zipObject(props, values); + * // => { a: 1, b: 2, c: 3 } + */ +declare function zipObject(props: ArrayLike, values: ArrayLike): Record; +/** + * Creates an object from an array of property names, with undefined values. + * + * @param [props] - An array of property names + * @returns A new object with the given property names and undefined values + * + * @example + * const props = ['a', 'b', 'c']; + * zipObject(props); + * // => { a: undefined, b: undefined, c: undefined } + */ +declare function zipObject(props?: ArrayLike): Record; +//#endregion +export { zipObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/zipObject.js b/node_modules/es-toolkit/dist/compat/array/zipObject.js new file mode 100644 index 0000000000000000000000000000000000000000..92e48bba12ba932aa3baa826bc1a31ddf402667d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipObject.js @@ -0,0 +1,39 @@ +const require_assignValue = require("../_internal/assignValue.js"); +//#region src/compat/array/zipObject.ts +/** +* Combines two arrays, one of property names and one of corresponding values, into a single object. +* +* This function takes two arrays: one containing property names and another containing corresponding values. +* It returns a new object where the property names from the first array are keys, and the corresponding elements +* from the second array are values. If the `keys` array is longer than the `values` array, the remaining keys will +* have `undefined` as their values. +* +* @template P - The type of elements in the array. +* @template V - The type of elements in the array. +* @param keys - An array of property names. +* @param values - An array of values corresponding to the property names. +* @returns A new object composed of the given property names and values. +* +* @example +* const keys = ['a', 'b', 'c']; +* const values = [1, 2, 3]; +* const result = zipObject(keys, values); +* // result will be { a: 1, b: 2, c: 3 } +* +* const keys2 = ['a', 'b', 'c']; +* const values2 = [1, 2]; +* const result2 = zipObject(keys2, values2); +* // result2 will be { a: 1, b: 2, c: undefined } +* +* const keys2 = ['a', 'b']; +* const values2 = [1, 2, 3]; +* const result2 = zipObject(keys2, values2); +* // result2 will be { a: 1, b: 2 } +*/ +function zipObject(keys = [], values = []) { + const result = {}; + for (let i = 0; i < keys.length; i++) require_assignValue.assignValue(result, keys[i], values[i]); + return result; +} +//#endregion +exports.zipObject = zipObject; diff --git a/node_modules/es-toolkit/dist/compat/array/zipObject.mjs b/node_modules/es-toolkit/dist/compat/array/zipObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..28c6da361b9ae21a5cac9b653ead295ac472eeb9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipObject.mjs @@ -0,0 +1,39 @@ +import { assignValue } from "../_internal/assignValue.mjs"; +//#region src/compat/array/zipObject.ts +/** +* Combines two arrays, one of property names and one of corresponding values, into a single object. +* +* This function takes two arrays: one containing property names and another containing corresponding values. +* It returns a new object where the property names from the first array are keys, and the corresponding elements +* from the second array are values. If the `keys` array is longer than the `values` array, the remaining keys will +* have `undefined` as their values. +* +* @template P - The type of elements in the array. +* @template V - The type of elements in the array. +* @param keys - An array of property names. +* @param values - An array of values corresponding to the property names. +* @returns A new object composed of the given property names and values. +* +* @example +* const keys = ['a', 'b', 'c']; +* const values = [1, 2, 3]; +* const result = zipObject(keys, values); +* // result will be { a: 1, b: 2, c: 3 } +* +* const keys2 = ['a', 'b', 'c']; +* const values2 = [1, 2]; +* const result2 = zipObject(keys2, values2); +* // result2 will be { a: 1, b: 2, c: undefined } +* +* const keys2 = ['a', 'b']; +* const values2 = [1, 2, 3]; +* const result2 = zipObject(keys2, values2); +* // result2 will be { a: 1, b: 2 } +*/ +function zipObject(keys = [], values = []) { + const result = {}; + for (let i = 0; i < keys.length; i++) assignValue(result, keys[i], values[i]); + return result; +} +//#endregion +export { zipObject }; diff --git a/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.d.mts b/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9d3a6500aee6159d336c61e25c991f984d89982e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.d.mts @@ -0,0 +1,39 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/array/zipObjectDeep.d.ts +/** + * Creates a deeply nested object given arrays of paths and values. + * + * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values. + * 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. + * Paths can be dot-separated strings or arrays of property names. + * + * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values. + * + * @template P - The type of property paths. + * @template V - The type of values corresponding to the property paths. + * @param keys - An array of property paths, each path can be a dot-separated string or an array of property names. + * @param values - An array of values corresponding to the property paths. + * @returns A new object composed of the given property paths and values. + * + * @example + * const paths = ['a.b.c', 'd.e.f']; + * const values = [1, 2]; + * const result = zipObjectDeep(paths, values); + * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } } + * + * @example + * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']]; + * const values = [1, 2]; + * const result = zipObjectDeep(paths, values); + * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } } + * + * @example + * const paths = ['a.b[0].c', 'a.b[1].d']; + * const values = [1, 2]; + * const result = zipObjectDeep(paths, values); + * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } + */ +declare function zipObjectDeep(keys?: ArrayLike, values?: ArrayLike): object; +//#endregion +export { zipObjectDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.d.ts b/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b77c20ed8604f9573d532209b4579cd6c9fb9c13 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.d.ts @@ -0,0 +1,39 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/array/zipObjectDeep.d.ts +/** + * Creates a deeply nested object given arrays of paths and values. + * + * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values. + * 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. + * Paths can be dot-separated strings or arrays of property names. + * + * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values. + * + * @template P - The type of property paths. + * @template V - The type of values corresponding to the property paths. + * @param keys - An array of property paths, each path can be a dot-separated string or an array of property names. + * @param values - An array of values corresponding to the property paths. + * @returns A new object composed of the given property paths and values. + * + * @example + * const paths = ['a.b.c', 'd.e.f']; + * const values = [1, 2]; + * const result = zipObjectDeep(paths, values); + * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } } + * + * @example + * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']]; + * const values = [1, 2]; + * const result = zipObjectDeep(paths, values); + * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } } + * + * @example + * const paths = ['a.b[0].c', 'a.b[1].d']; + * const values = [1, 2]; + * const result = zipObjectDeep(paths, values); + * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } + */ +declare function zipObjectDeep(keys?: ArrayLike, values?: ArrayLike): object; +//#endregion +export { zipObjectDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.js b/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.js new file mode 100644 index 0000000000000000000000000000000000000000..fb8eb44ea861efba6f688d013bce4af7434e7726 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.js @@ -0,0 +1,50 @@ +const require_zip = require("../../array/zip.js"); +const require_isArrayLike = require("../predicate/isArrayLike.js"); +const require_set = require("../object/set.js"); +//#region src/compat/array/zipObjectDeep.ts +/** +* Creates a deeply nested object given arrays of paths and values. +* +* This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values. +* 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. +* Paths can be dot-separated strings or arrays of property names. +* +* If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values. +* +* @template P - The type of property paths. +* @template V - The type of values corresponding to the property paths. +* @param keys - An array of property paths, each path can be a dot-separated string or an array of property names. +* @param values - An array of values corresponding to the property paths. +* @returns A new object composed of the given property paths and values. +* +* @example +* const paths = ['a.b.c', 'd.e.f']; +* const values = [1, 2]; +* const result = zipObjectDeep(paths, values); +* // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } } +* +* @example +* const paths = [['a', 'b', 'c'], ['d', 'e', 'f']]; +* const values = [1, 2]; +* const result = zipObjectDeep(paths, values); +* // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } } +* +* @example +* const paths = ['a.b[0].c', 'a.b[1].d']; +* const values = [1, 2]; +* const result = zipObjectDeep(paths, values); +* // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } +*/ +function zipObjectDeep(keys, values) { + const result = {}; + if (!require_isArrayLike.isArrayLike(keys)) return result; + if (!require_isArrayLike.isArrayLike(values)) values = []; + const zipped = require_zip.zip(Array.from(keys), Array.from(values)); + for (let i = 0; i < zipped.length; i++) { + const [key, value] = zipped[i]; + if (key != null) require_set.set(result, key, value); + } + return result; +} +//#endregion +exports.zipObjectDeep = zipObjectDeep; diff --git a/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.mjs b/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.mjs new file mode 100644 index 0000000000000000000000000000000000000000..060352cd12bddc945e9f04db123561e25ef2aa74 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipObjectDeep.mjs @@ -0,0 +1,50 @@ +import { zip } from "../../array/zip.mjs"; +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +import { set } from "../object/set.mjs"; +//#region src/compat/array/zipObjectDeep.ts +/** +* Creates a deeply nested object given arrays of paths and values. +* +* This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values. +* 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. +* Paths can be dot-separated strings or arrays of property names. +* +* If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values. +* +* @template P - The type of property paths. +* @template V - The type of values corresponding to the property paths. +* @param keys - An array of property paths, each path can be a dot-separated string or an array of property names. +* @param values - An array of values corresponding to the property paths. +* @returns A new object composed of the given property paths and values. +* +* @example +* const paths = ['a.b.c', 'd.e.f']; +* const values = [1, 2]; +* const result = zipObjectDeep(paths, values); +* // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } } +* +* @example +* const paths = [['a', 'b', 'c'], ['d', 'e', 'f']]; +* const values = [1, 2]; +* const result = zipObjectDeep(paths, values); +* // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } } +* +* @example +* const paths = ['a.b[0].c', 'a.b[1].d']; +* const values = [1, 2]; +* const result = zipObjectDeep(paths, values); +* // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } +*/ +function zipObjectDeep(keys, values) { + const result = {}; + if (!isArrayLike(keys)) return result; + if (!isArrayLike(values)) values = []; + const zipped = zip(Array.from(keys), Array.from(values)); + for (let i = 0; i < zipped.length; i++) { + const [key, value] = zipped[i]; + if (key != null) set(result, key, value); + } + return result; +} +//#endregion +export { zipObjectDeep }; diff --git a/node_modules/es-toolkit/dist/compat/array/zipWith.d.mts b/node_modules/es-toolkit/dist/compat/array/zipWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3766149cc0d043d5c978d973bb8630aa1b34a0a1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipWith.d.mts @@ -0,0 +1,93 @@ +//#region src/compat/array/zipWith.d.ts +/** + * Combines one array into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, combine: (item: T) => R): R[]; +/** + * Combines two arrays into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template U - The type of elements in the second array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, arr2: ArrayLike, combine: (item1: T, item2: U) => R): R[]; +/** + * Combines three arrays into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, combine: (item1: T, item2: U, item3: V) => R): R[]; +/** + * Combines four arrays into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @template W - The type of elements in the fourth array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, arr4: ArrayLike, combine: (item1: T, item2: U, item3: V, item4: W) => R): R[]; +/** + * Combines five arrays into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @template W - The type of elements in the fourth array. + * @template X - The type of elements in the fifth array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param arr5 - The fifth array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, arr4: ArrayLike, arr5: ArrayLike, combine: (item1: T, item2: U, item3: V, item4: W, item5: X) => R): R[]; +/** + * Combines multiple arrays into a single array using a custom combiner function. + * + * This function takes one array and a variable number of additional arrays, + * applying the provided combiner function to the corresponding elements of each array. + * If the input arrays are of different lengths, the resulting array will have the length + * of the longest input array, with undefined values for missing elements. + * + * @template T - The type of elements in the input arrays. + * @template R - The type of elements in the resulting array. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const result = zipWith(arr1, arr2, (num, char) => `${num}${char}`); + * // result will be ['1a', '2b', '3c'] + */ +declare function zipWith(...combine: Array<((...group: T[]) => R) | ArrayLike | null | undefined>): R[]; +//#endregion +export { zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/zipWith.d.ts b/node_modules/es-toolkit/dist/compat/array/zipWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3766149cc0d043d5c978d973bb8630aa1b34a0a1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipWith.d.ts @@ -0,0 +1,93 @@ +//#region src/compat/array/zipWith.d.ts +/** + * Combines one array into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, combine: (item: T) => R): R[]; +/** + * Combines two arrays into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template U - The type of elements in the second array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, arr2: ArrayLike, combine: (item1: T, item2: U) => R): R[]; +/** + * Combines three arrays into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, combine: (item1: T, item2: U, item3: V) => R): R[]; +/** + * Combines four arrays into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @template W - The type of elements in the fourth array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, arr4: ArrayLike, combine: (item1: T, item2: U, item3: V, item4: W) => R): R[]; +/** + * Combines five arrays into a single array using a custom combiner function. + * + * @template T - The type of elements in the first array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @template W - The type of elements in the fourth array. + * @template X - The type of elements in the fifth array. + * @template R - The type of elements in the resulting array. + * @param arr1 - The first array to zip. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param arr5 - The fifth array to zip. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + */ +declare function zipWith(arr1: ArrayLike, arr2: ArrayLike, arr3: ArrayLike, arr4: ArrayLike, arr5: ArrayLike, combine: (item1: T, item2: U, item3: V, item4: W, item5: X) => R): R[]; +/** + * Combines multiple arrays into a single array using a custom combiner function. + * + * This function takes one array and a variable number of additional arrays, + * applying the provided combiner function to the corresponding elements of each array. + * If the input arrays are of different lengths, the resulting array will have the length + * of the longest input array, with undefined values for missing elements. + * + * @template T - The type of elements in the input arrays. + * @template R - The type of elements in the resulting array. + * @param combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. + * + * @example + * const arr1 = [1, 2, 3]; + * const arr2 = ['a', 'b', 'c']; + * const result = zipWith(arr1, arr2, (num, char) => `${num}${char}`); + * // result will be ['1a', '2b', '3c'] + */ +declare function zipWith(...combine: Array<((...group: T[]) => R) | ArrayLike | null | undefined>): R[]; +//#endregion +export { zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/array/zipWith.js b/node_modules/es-toolkit/dist/compat/array/zipWith.js new file mode 100644 index 0000000000000000000000000000000000000000..ca9c2ceed762700a23f0b991bc5201f51333b531 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipWith.js @@ -0,0 +1,35 @@ +const require_isFunction = require("../../predicate/isFunction.js"); +const require_unzip = require("./unzip.js"); +//#region src/compat/array/zipWith.ts +/** +* Combines multiple arrays into a single array using a custom combiner function. +* +* This function takes one array and a variable number of additional arrays, +* applying the provided combiner function to the corresponding elements of each array. +* If the input arrays are of different lengths, the resulting array will have the length +* of the longest input array, with undefined values for missing elements. +* +* @template T - The type of elements in the input arrays. +* @template R - The type of elements in the resulting array. +* @param combine - The combiner function that takes corresponding elements from each array and returns a single value. +* @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. +* +* @example +* const arr1 = [1, 2, 3]; +* const arr2 = ['a', 'b', 'c']; +* const result = zipWith(arr1, arr2, (num, char) => `${num}${char}`); +* // result will be ['1a', '2b', '3c'] +*/ +function zipWith(...combine) { + let iteratee = combine.pop(); + if (!require_isFunction.isFunction(iteratee)) { + combine.push(iteratee); + iteratee = void 0; + } + if (!combine?.length) return []; + const result = require_unzip.unzip(combine); + if (iteratee == null) return result; + return result.map((group) => iteratee(...group)); +} +//#endregion +exports.zipWith = zipWith; diff --git a/node_modules/es-toolkit/dist/compat/array/zipWith.mjs b/node_modules/es-toolkit/dist/compat/array/zipWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2f0ab8bcb2e588465ccf32d4779e191cda8cf32a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/array/zipWith.mjs @@ -0,0 +1,35 @@ +import { isFunction } from "../../predicate/isFunction.mjs"; +import { unzip } from "./unzip.mjs"; +//#region src/compat/array/zipWith.ts +/** +* Combines multiple arrays into a single array using a custom combiner function. +* +* This function takes one array and a variable number of additional arrays, +* applying the provided combiner function to the corresponding elements of each array. +* If the input arrays are of different lengths, the resulting array will have the length +* of the longest input array, with undefined values for missing elements. +* +* @template T - The type of elements in the input arrays. +* @template R - The type of elements in the resulting array. +* @param combine - The combiner function that takes corresponding elements from each array and returns a single value. +* @returns A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. +* +* @example +* const arr1 = [1, 2, 3]; +* const arr2 = ['a', 'b', 'c']; +* const result = zipWith(arr1, arr2, (num, char) => `${num}${char}`); +* // result will be ['1a', '2b', '3c'] +*/ +function zipWith(...combine) { + let iteratee = combine.pop(); + if (!isFunction(iteratee)) { + combine.push(iteratee); + iteratee = void 0; + } + if (!combine?.length) return []; + const result = unzip(combine); + if (iteratee == null) return result; + return result.map((group) => iteratee(...group)); +} +//#endregion +export { zipWith }; diff --git a/node_modules/es-toolkit/dist/compat/compat.d.mts b/node_modules/es-toolkit/dist/compat/compat.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a184adc8c02a239167380c2a1735075071865072 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/compat.d.mts @@ -0,0 +1,299 @@ +import { castArray } from "./array/castArray.mjs"; +import { chunk } from "./array/chunk.mjs"; +import { compact } from "./array/compact.mjs"; +import { concat } from "./array/concat.mjs"; +import { countBy } from "./array/countBy.mjs"; +import { difference } from "./array/difference.mjs"; +import { differenceBy } from "./array/differenceBy.mjs"; +import { differenceWith } from "./array/differenceWith.mjs"; +import { drop } from "./array/drop.mjs"; +import { dropRight } from "./array/dropRight.mjs"; +import { dropRightWhile } from "./array/dropRightWhile.mjs"; +import { dropWhile } from "./array/dropWhile.mjs"; +import { forEach } from "./array/forEach.mjs"; +import { forEachRight } from "./array/forEachRight.mjs"; +import { every } from "./array/every.mjs"; +import { fill } from "./array/fill.mjs"; +import { filter } from "./array/filter.mjs"; +import { find } from "./array/find.mjs"; +import { findIndex } from "./array/findIndex.mjs"; +import { findLast } from "./array/findLast.mjs"; +import { findLastIndex } from "./array/findLastIndex.mjs"; +import { head } from "./array/head.mjs"; +import { flatMap } from "./array/flatMap.mjs"; +import { flatMapDeep } from "./array/flatMapDeep.mjs"; +import { flatMapDepth } from "./array/flatMapDepth.mjs"; +import { flatten } from "./array/flatten.mjs"; +import { flattenDeep } from "./array/flattenDeep.mjs"; +import { flattenDepth } from "./array/flattenDepth.mjs"; +import { groupBy } from "./array/groupBy.mjs"; +import { includes } from "./array/includes.mjs"; +import { indexOf } from "./array/indexOf.mjs"; +import { initial } from "./array/initial.mjs"; +import { intersection } from "./array/intersection.mjs"; +import { intersectionBy } from "./array/intersectionBy.mjs"; +import { intersectionWith } from "./array/intersectionWith.mjs"; +import { invokeMap } from "./array/invokeMap.mjs"; +import { join } from "./array/join.mjs"; +import { keyBy } from "./array/keyBy.mjs"; +import { last } from "./array/last.mjs"; +import { lastIndexOf } from "./array/lastIndexOf.mjs"; +import { map } from "./array/map.mjs"; +import { nth } from "./array/nth.mjs"; +import { orderBy } from "./array/orderBy.mjs"; +import { partition } from "./array/partition.mjs"; +import { pull } from "./array/pull.mjs"; +import { pullAll } from "./array/pullAll.mjs"; +import { pullAllBy } from "./array/pullAllBy.mjs"; +import { pullAllWith } from "./array/pullAllWith.mjs"; +import { pullAt } from "./array/pullAt.mjs"; +import { reduce } from "./array/reduce.mjs"; +import { reduceRight } from "./array/reduceRight.mjs"; +import { reject } from "./array/reject.mjs"; +import { remove } from "./array/remove.mjs"; +import { reverse } from "./array/reverse.mjs"; +import { sample } from "./array/sample.mjs"; +import { sampleSize } from "./array/sampleSize.mjs"; +import { shuffle } from "./array/shuffle.mjs"; +import { size } from "./array/size.mjs"; +import { slice } from "./array/slice.mjs"; +import { some } from "./array/some.mjs"; +import { sortBy } from "./array/sortBy.mjs"; +import { sortedIndex } from "./array/sortedIndex.mjs"; +import { sortedIndexBy } from "./array/sortedIndexBy.mjs"; +import { sortedIndexOf } from "./array/sortedIndexOf.mjs"; +import { sortedLastIndex } from "./array/sortedLastIndex.mjs"; +import { sortedLastIndexBy } from "./array/sortedLastIndexBy.mjs"; +import { sortedLastIndexOf } from "./array/sortedLastIndexOf.mjs"; +import { tail } from "./array/tail.mjs"; +import { take } from "./array/take.mjs"; +import { takeRight } from "./array/takeRight.mjs"; +import { takeRightWhile } from "./array/takeRightWhile.mjs"; +import { takeWhile } from "./array/takeWhile.mjs"; +import { union } from "./array/union.mjs"; +import { unionBy } from "./array/unionBy.mjs"; +import { unionWith } from "./array/unionWith.mjs"; +import { uniq } from "./array/uniq.mjs"; +import { uniqBy } from "./array/uniqBy.mjs"; +import { uniqWith } from "./array/uniqWith.mjs"; +import { unzip } from "./array/unzip.mjs"; +import { unzipWith } from "./array/unzipWith.mjs"; +import { without } from "./array/without.mjs"; +import { xor } from "./array/xor.mjs"; +import { xorBy } from "./array/xorBy.mjs"; +import { xorWith } from "./array/xorWith.mjs"; +import { zip } from "./array/zip.mjs"; +import { zipObject } from "./array/zipObject.mjs"; +import { zipObjectDeep } from "./array/zipObjectDeep.mjs"; +import { zipWith } from "./array/zipWith.mjs"; +import { after } from "./function/after.mjs"; +import { ary } from "./function/ary.mjs"; +import { attempt } from "./function/attempt.mjs"; +import { before } from "./function/before.mjs"; +import { bind } from "./function/bind.mjs"; +import { bindKey } from "./function/bindKey.mjs"; +import { curry } from "./function/curry.mjs"; +import { curryRight } from "./function/curryRight.mjs"; +import { DebouncedFunc, debounce } from "./function/debounce.mjs"; +import { defer } from "./function/defer.mjs"; +import { delay } from "./function/delay.mjs"; +import { flip } from "./function/flip.mjs"; +import { flow } from "./function/flow.mjs"; +import { flowRight } from "./function/flowRight.mjs"; +import { memoize } from "./function/memoize.mjs"; +import { negate } from "./function/negate.mjs"; +import { nthArg } from "./function/nthArg.mjs"; +import { once } from "./function/once.mjs"; +import { overArgs } from "./function/overArgs.mjs"; +import { partial } from "./function/partial.mjs"; +import { partialRight } from "./function/partialRight.mjs"; +import { rearg } from "./function/rearg.mjs"; +import { rest } from "./function/rest.mjs"; +import { spread } from "./function/spread.mjs"; +import { throttle } from "./function/throttle.mjs"; +import { unary } from "./function/unary.mjs"; +import { wrap } from "./function/wrap.mjs"; +import { add } from "./math/add.mjs"; +import { ceil } from "./math/ceil.mjs"; +import { clamp } from "./math/clamp.mjs"; +import { divide } from "./math/divide.mjs"; +import { floor } from "./math/floor.mjs"; +import { inRange } from "./math/inRange.mjs"; +import { max } from "./math/max.mjs"; +import { maxBy } from "./math/maxBy.mjs"; +import { mean } from "./math/mean.mjs"; +import { meanBy } from "./math/meanBy.mjs"; +import { min } from "./math/min.mjs"; +import { minBy } from "./math/minBy.mjs"; +import { multiply } from "./math/multiply.mjs"; +import { parseInt } from "./math/parseInt.mjs"; +import { random } from "./math/random.mjs"; +import { range } from "./math/range.mjs"; +import { rangeRight } from "./math/rangeRight.mjs"; +import { round } from "./math/round.mjs"; +import { subtract } from "./math/subtract.mjs"; +import { sum } from "./math/sum.mjs"; +import { sumBy } from "./math/sumBy.mjs"; +import { isEqual } from "../predicate/isEqual.mjs"; +import { identity } from "./function/identity.mjs"; +import { noop } from "./function/noop.mjs"; +import { assign } from "./object/assign.mjs"; +import { assignIn } from "./object/assignIn.mjs"; +import { assignInWith } from "./object/assignInWith.mjs"; +import { assignWith } from "./object/assignWith.mjs"; +import { at } from "./object/at.mjs"; +import { clone } from "./object/clone.mjs"; +import { cloneDeep } from "./object/cloneDeep.mjs"; +import { cloneDeepWith } from "./object/cloneDeepWith.mjs"; +import { cloneWith } from "./object/cloneWith.mjs"; +import { create } from "./object/create.mjs"; +import { defaults } from "./object/defaults.mjs"; +import { defaultsDeep } from "./object/defaultsDeep.mjs"; +import { findKey } from "./object/findKey.mjs"; +import { findLastKey } from "./object/findLastKey.mjs"; +import { forIn } from "./object/forIn.mjs"; +import { forInRight } from "./object/forInRight.mjs"; +import { forOwn } from "./object/forOwn.mjs"; +import { forOwnRight } from "./object/forOwnRight.mjs"; +import { fromPairs } from "./object/fromPairs.mjs"; +import { functions } from "./object/functions.mjs"; +import { functionsIn } from "./object/functionsIn.mjs"; +import { get } from "./object/get.mjs"; +import { has } from "./object/has.mjs"; +import { hasIn } from "./object/hasIn.mjs"; +import { invert } from "./object/invert.mjs"; +import { invertBy } from "./object/invertBy.mjs"; +import { keys } from "./object/keys.mjs"; +import { keysIn } from "./object/keysIn.mjs"; +import { mapKeys } from "./object/mapKeys.mjs"; +import { mapValues } from "./object/mapValues.mjs"; +import { merge } from "./object/merge.mjs"; +import { mergeWith } from "./object/mergeWith.mjs"; +import { omit } from "./object/omit.mjs"; +import { omitBy } from "./object/omitBy.mjs"; +import { pick } from "./object/pick.mjs"; +import { pickBy } from "./object/pickBy.mjs"; +import { property } from "./object/property.mjs"; +import { propertyOf } from "./object/propertyOf.mjs"; +import { result } from "./object/result.mjs"; +import { set } from "./object/set.mjs"; +import { setWith } from "./object/setWith.mjs"; +import { toDefaulted } from "./object/toDefaulted.mjs"; +import { toPairs } from "./object/toPairs.mjs"; +import { toPairsIn } from "./object/toPairsIn.mjs"; +import { transform } from "./object/transform.mjs"; +import { unset } from "./object/unset.mjs"; +import { update } from "./object/update.mjs"; +import { updateWith } from "./object/updateWith.mjs"; +import { values } from "./object/values.mjs"; +import { valuesIn } from "./object/valuesIn.mjs"; +import { isFunction } from "./predicate/isFunction.mjs"; +import { isLength } from "./predicate/isLength.mjs"; +import { isMatchWith } from "./predicate/isMatchWith.mjs"; +import { isNative } from "./predicate/isNative.mjs"; +import { isNull } from "./predicate/isNull.mjs"; +import { isUndefined } from "./predicate/isUndefined.mjs"; +import { conforms } from "./predicate/conforms.mjs"; +import { conformsTo } from "./predicate/conformsTo.mjs"; +import { isArguments } from "./predicate/isArguments.mjs"; +import { isArray } from "./predicate/isArray.mjs"; +import { isArrayBuffer } from "./predicate/isArrayBuffer.mjs"; +import { isArrayLike } from "./predicate/isArrayLike.mjs"; +import { isArrayLikeObject } from "./predicate/isArrayLikeObject.mjs"; +import { isBoolean } from "./predicate/isBoolean.mjs"; +import { isBuffer } from "./predicate/isBuffer.mjs"; +import { isDate } from "./predicate/isDate.mjs"; +import { isElement } from "./predicate/isElement.mjs"; +import { isEmpty } from "./predicate/isEmpty.mjs"; +import { isEqualWith } from "./predicate/isEqualWith.mjs"; +import { isError } from "./predicate/isError.mjs"; +import { isFinite } from "./predicate/isFinite.mjs"; +import { isInteger } from "./predicate/isInteger.mjs"; +import { isMap } from "./predicate/isMap.mjs"; +import { isMatch } from "./predicate/isMatch.mjs"; +import { isNaN } from "./predicate/isNaN.mjs"; +import { isNil } from "./predicate/isNil.mjs"; +import { isNumber } from "./predicate/isNumber.mjs"; +import { isObject } from "./predicate/isObject.mjs"; +import { isObjectLike } from "./predicate/isObjectLike.mjs"; +import { isPlainObject } from "./predicate/isPlainObject.mjs"; +import { isRegExp } from "./predicate/isRegExp.mjs"; +import { isSafeInteger } from "./predicate/isSafeInteger.mjs"; +import { isSet } from "./predicate/isSet.mjs"; +import { isString } from "./predicate/isString.mjs"; +import { isSymbol } from "./predicate/isSymbol.mjs"; +import { isTypedArray } from "./predicate/isTypedArray.mjs"; +import { isWeakMap } from "./predicate/isWeakMap.mjs"; +import { isWeakSet } from "./predicate/isWeakSet.mjs"; +import { matches } from "./predicate/matches.mjs"; +import { matchesProperty } from "./predicate/matchesProperty.mjs"; +import { capitalize } from "./string/capitalize.mjs"; +import { bindAll } from "./util/bindAll.mjs"; +import { camelCase } from "./string/camelCase.mjs"; +import { deburr } from "./string/deburr.mjs"; +import { endsWith } from "./string/endsWith.mjs"; +import { escape } from "./string/escape.mjs"; +import { escapeRegExp } from "./string/escapeRegExp.mjs"; +import { kebabCase } from "./string/kebabCase.mjs"; +import { lowerCase } from "./string/lowerCase.mjs"; +import { lowerFirst } from "./string/lowerFirst.mjs"; +import { pad } from "./string/pad.mjs"; +import { padEnd } from "./string/padEnd.mjs"; +import { padStart } from "./string/padStart.mjs"; +import { repeat } from "./string/repeat.mjs"; +import { replace } from "./string/replace.mjs"; +import { snakeCase } from "./string/snakeCase.mjs"; +import { split } from "./string/split.mjs"; +import { startCase } from "./string/startCase.mjs"; +import { startsWith } from "./string/startsWith.mjs"; +import { template } from "./string/template.mjs"; +import { templateSettings } from "./string/templateSettings.mjs"; +import { toLower } from "./string/toLower.mjs"; +import { toUpper } from "./string/toUpper.mjs"; +import { trim } from "./string/trim.mjs"; +import { trimEnd } from "./string/trimEnd.mjs"; +import { trimStart } from "./string/trimStart.mjs"; +import { truncate } from "./string/truncate.mjs"; +import { unescape } from "./string/unescape.mjs"; +import { upperCase } from "./string/upperCase.mjs"; +import { upperFirst } from "./string/upperFirst.mjs"; +import { words } from "./string/words.mjs"; +import { cond } from "./util/cond.mjs"; +import { constant } from "./util/constant.mjs"; +import { defaultTo } from "./util/defaultTo.mjs"; +import { eq } from "./util/eq.mjs"; +import { gt } from "./util/gt.mjs"; +import { gte } from "./util/gte.mjs"; +import { invoke } from "./util/invoke.mjs"; +import { iteratee } from "./util/iteratee.mjs"; +import { lt } from "./util/lt.mjs"; +import { lte } from "./util/lte.mjs"; +import { method } from "./util/method.mjs"; +import { methodOf } from "./util/methodOf.mjs"; +import { now } from "./util/now.mjs"; +import { over } from "./util/over.mjs"; +import { overEvery } from "./util/overEvery.mjs"; +import { overSome } from "./util/overSome.mjs"; +import { stubArray } from "./util/stubArray.mjs"; +import { stubFalse } from "./util/stubFalse.mjs"; +import { stubObject } from "./util/stubObject.mjs"; +import { stubString } from "./util/stubString.mjs"; +import { stubTrue } from "./util/stubTrue.mjs"; +import { times } from "./util/times.mjs"; +import { toArray } from "./util/toArray.mjs"; +import { toFinite } from "./util/toFinite.mjs"; +import { toInteger } from "./util/toInteger.mjs"; +import { toLength } from "./util/toLength.mjs"; +import { toNumber } from "./util/toNumber.mjs"; +import { toPath } from "./util/toPath.mjs"; +import { toPlainObject } from "./util/toPlainObject.mjs"; +import { toSafeInteger } from "./util/toSafeInteger.mjs"; +import { toString } from "./util/toString.mjs"; +import { uniqueId } from "./util/uniqueId.mjs"; + +//#region src/compat/compat.d.ts +declare namespace compat_d_exports { + export { DebouncedFunc, add, after, ary, assign, assignIn, assignInWith, assignWith, at, attempt, before, bind, bindAll, bindKey, camelCase, capitalize, castArray, ceil, chunk, clamp, clone, cloneDeep, cloneDeepWith, cloneWith, compact, concat, cond, conforms, conformsTo, constant, countBy, create, curry, curryRight, debounce, deburr, defaultTo, defaults, defaultsDeep, defer, delay, difference, differenceBy, differenceWith, divide, drop, dropRight, dropRightWhile, dropWhile, forEach as each, forEachRight as eachRight, endsWith, eq, escape, escapeRegExp, every, assignIn as extend, assignInWith as extendWith, fill, filter, find, findIndex, findKey, findLast, findLastIndex, findLastKey, head as first, flatMap, flatMapDeep, flatMapDepth, flatten, flattenDeep, flattenDepth, flip, floor, flow, flowRight, forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, fromPairs, functions, functionsIn, get, groupBy, gt, gte, has, hasIn, head, identity, inRange, includes, indexOf, initial, intersection, intersectionBy, intersectionWith, invert, invertBy, invoke, invokeMap, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, iteratee, join, kebabCase, keyBy, keys, keysIn, last, lastIndexOf, lowerCase, lowerFirst, lt, lte, map, mapKeys, mapValues, matches, matchesProperty, max, maxBy, mean, meanBy, memoize, merge, mergeWith, method, methodOf, min, minBy, multiply, negate, noop, now, nth, nthArg, omit, omitBy, once, orderBy, over, overArgs, overEvery, overSome, pad, padEnd, padStart, parseInt, partial, partialRight, partition, pick, pickBy, property, propertyOf, pull, pullAll, pullAllBy, pullAllWith, pullAt, random, range, rangeRight, rearg, reduce, reduceRight, reject, remove, repeat, replace, rest, result, reverse, round, sample, sampleSize, set, setWith, shuffle, size, slice, snakeCase, some, sortBy, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, split, spread, startCase, startsWith, stubArray, stubFalse, stubObject, stubString, stubTrue, subtract, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, template, templateSettings, throttle, times, toArray, toDefaulted, toFinite, toInteger, toLength, toLower, toNumber, toPairs, toPairsIn, toPath, toPlainObject, toSafeInteger, toString, toUpper, transform, trim, trimEnd, trimStart, truncate, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, uniqueId, unset, unzip, unzipWith, update, updateWith, upperCase, upperFirst, values, valuesIn, without, words, wrap, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith }; +} +//#endregion +export { compat_d_exports }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/compat.d.ts b/node_modules/es-toolkit/dist/compat/compat.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6226e0a70bf2783e00561d98a0d6b970e7314aff --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/compat.d.ts @@ -0,0 +1,299 @@ +import { castArray } from "./array/castArray.js"; +import { chunk } from "./array/chunk.js"; +import { compact } from "./array/compact.js"; +import { concat } from "./array/concat.js"; +import { countBy } from "./array/countBy.js"; +import { difference } from "./array/difference.js"; +import { differenceBy } from "./array/differenceBy.js"; +import { differenceWith } from "./array/differenceWith.js"; +import { drop } from "./array/drop.js"; +import { dropRight } from "./array/dropRight.js"; +import { dropRightWhile } from "./array/dropRightWhile.js"; +import { dropWhile } from "./array/dropWhile.js"; +import { forEach } from "./array/forEach.js"; +import { forEachRight } from "./array/forEachRight.js"; +import { every } from "./array/every.js"; +import { fill } from "./array/fill.js"; +import { filter } from "./array/filter.js"; +import { find } from "./array/find.js"; +import { findIndex } from "./array/findIndex.js"; +import { findLast } from "./array/findLast.js"; +import { findLastIndex } from "./array/findLastIndex.js"; +import { head } from "./array/head.js"; +import { flatMap } from "./array/flatMap.js"; +import { flatMapDeep } from "./array/flatMapDeep.js"; +import { flatMapDepth } from "./array/flatMapDepth.js"; +import { flatten } from "./array/flatten.js"; +import { flattenDeep } from "./array/flattenDeep.js"; +import { flattenDepth } from "./array/flattenDepth.js"; +import { groupBy } from "./array/groupBy.js"; +import { includes } from "./array/includes.js"; +import { indexOf } from "./array/indexOf.js"; +import { initial } from "./array/initial.js"; +import { intersection } from "./array/intersection.js"; +import { intersectionBy } from "./array/intersectionBy.js"; +import { intersectionWith } from "./array/intersectionWith.js"; +import { invokeMap } from "./array/invokeMap.js"; +import { join } from "./array/join.js"; +import { keyBy } from "./array/keyBy.js"; +import { last } from "./array/last.js"; +import { lastIndexOf } from "./array/lastIndexOf.js"; +import { map } from "./array/map.js"; +import { nth } from "./array/nth.js"; +import { orderBy } from "./array/orderBy.js"; +import { partition } from "./array/partition.js"; +import { pull } from "./array/pull.js"; +import { pullAll } from "./array/pullAll.js"; +import { pullAllBy } from "./array/pullAllBy.js"; +import { pullAllWith } from "./array/pullAllWith.js"; +import { pullAt } from "./array/pullAt.js"; +import { reduce } from "./array/reduce.js"; +import { reduceRight } from "./array/reduceRight.js"; +import { reject } from "./array/reject.js"; +import { remove } from "./array/remove.js"; +import { reverse } from "./array/reverse.js"; +import { sample } from "./array/sample.js"; +import { sampleSize } from "./array/sampleSize.js"; +import { shuffle } from "./array/shuffle.js"; +import { size } from "./array/size.js"; +import { slice } from "./array/slice.js"; +import { some } from "./array/some.js"; +import { sortBy } from "./array/sortBy.js"; +import { sortedIndex } from "./array/sortedIndex.js"; +import { sortedIndexBy } from "./array/sortedIndexBy.js"; +import { sortedIndexOf } from "./array/sortedIndexOf.js"; +import { sortedLastIndex } from "./array/sortedLastIndex.js"; +import { sortedLastIndexBy } from "./array/sortedLastIndexBy.js"; +import { sortedLastIndexOf } from "./array/sortedLastIndexOf.js"; +import { tail } from "./array/tail.js"; +import { take } from "./array/take.js"; +import { takeRight } from "./array/takeRight.js"; +import { takeRightWhile } from "./array/takeRightWhile.js"; +import { takeWhile } from "./array/takeWhile.js"; +import { union } from "./array/union.js"; +import { unionBy } from "./array/unionBy.js"; +import { unionWith } from "./array/unionWith.js"; +import { uniq } from "./array/uniq.js"; +import { uniqBy } from "./array/uniqBy.js"; +import { uniqWith } from "./array/uniqWith.js"; +import { unzip } from "./array/unzip.js"; +import { unzipWith } from "./array/unzipWith.js"; +import { without } from "./array/without.js"; +import { xor } from "./array/xor.js"; +import { xorBy } from "./array/xorBy.js"; +import { xorWith } from "./array/xorWith.js"; +import { zip } from "./array/zip.js"; +import { zipObject } from "./array/zipObject.js"; +import { zipObjectDeep } from "./array/zipObjectDeep.js"; +import { zipWith } from "./array/zipWith.js"; +import { after } from "./function/after.js"; +import { ary } from "./function/ary.js"; +import { attempt } from "./function/attempt.js"; +import { before } from "./function/before.js"; +import { bind } from "./function/bind.js"; +import { bindKey } from "./function/bindKey.js"; +import { curry } from "./function/curry.js"; +import { curryRight } from "./function/curryRight.js"; +import { DebouncedFunc, debounce } from "./function/debounce.js"; +import { defer } from "./function/defer.js"; +import { delay } from "./function/delay.js"; +import { flip } from "./function/flip.js"; +import { flow } from "./function/flow.js"; +import { flowRight } from "./function/flowRight.js"; +import { memoize } from "./function/memoize.js"; +import { negate } from "./function/negate.js"; +import { nthArg } from "./function/nthArg.js"; +import { once } from "./function/once.js"; +import { overArgs } from "./function/overArgs.js"; +import { partial } from "./function/partial.js"; +import { partialRight } from "./function/partialRight.js"; +import { rearg } from "./function/rearg.js"; +import { rest } from "./function/rest.js"; +import { spread } from "./function/spread.js"; +import { throttle } from "./function/throttle.js"; +import { unary } from "./function/unary.js"; +import { wrap } from "./function/wrap.js"; +import { add } from "./math/add.js"; +import { ceil } from "./math/ceil.js"; +import { clamp } from "./math/clamp.js"; +import { divide } from "./math/divide.js"; +import { floor } from "./math/floor.js"; +import { inRange } from "./math/inRange.js"; +import { max } from "./math/max.js"; +import { maxBy } from "./math/maxBy.js"; +import { mean } from "./math/mean.js"; +import { meanBy } from "./math/meanBy.js"; +import { min } from "./math/min.js"; +import { minBy } from "./math/minBy.js"; +import { multiply } from "./math/multiply.js"; +import { parseInt } from "./math/parseInt.js"; +import { random } from "./math/random.js"; +import { range } from "./math/range.js"; +import { rangeRight } from "./math/rangeRight.js"; +import { round } from "./math/round.js"; +import { subtract } from "./math/subtract.js"; +import { sum } from "./math/sum.js"; +import { sumBy } from "./math/sumBy.js"; +import { isEqual } from "../predicate/isEqual.js"; +import { identity } from "./function/identity.js"; +import { noop } from "./function/noop.js"; +import { assign } from "./object/assign.js"; +import { assignIn } from "./object/assignIn.js"; +import { assignInWith } from "./object/assignInWith.js"; +import { assignWith } from "./object/assignWith.js"; +import { at } from "./object/at.js"; +import { clone } from "./object/clone.js"; +import { cloneDeep } from "./object/cloneDeep.js"; +import { cloneDeepWith } from "./object/cloneDeepWith.js"; +import { cloneWith } from "./object/cloneWith.js"; +import { create } from "./object/create.js"; +import { defaults } from "./object/defaults.js"; +import { defaultsDeep } from "./object/defaultsDeep.js"; +import { findKey } from "./object/findKey.js"; +import { findLastKey } from "./object/findLastKey.js"; +import { forIn } from "./object/forIn.js"; +import { forInRight } from "./object/forInRight.js"; +import { forOwn } from "./object/forOwn.js"; +import { forOwnRight } from "./object/forOwnRight.js"; +import { fromPairs } from "./object/fromPairs.js"; +import { functions } from "./object/functions.js"; +import { functionsIn } from "./object/functionsIn.js"; +import { get } from "./object/get.js"; +import { has } from "./object/has.js"; +import { hasIn } from "./object/hasIn.js"; +import { invert } from "./object/invert.js"; +import { invertBy } from "./object/invertBy.js"; +import { keys } from "./object/keys.js"; +import { keysIn } from "./object/keysIn.js"; +import { mapKeys } from "./object/mapKeys.js"; +import { mapValues } from "./object/mapValues.js"; +import { merge } from "./object/merge.js"; +import { mergeWith } from "./object/mergeWith.js"; +import { omit } from "./object/omit.js"; +import { omitBy } from "./object/omitBy.js"; +import { pick } from "./object/pick.js"; +import { pickBy } from "./object/pickBy.js"; +import { property } from "./object/property.js"; +import { propertyOf } from "./object/propertyOf.js"; +import { result } from "./object/result.js"; +import { set } from "./object/set.js"; +import { setWith } from "./object/setWith.js"; +import { toDefaulted } from "./object/toDefaulted.js"; +import { toPairs } from "./object/toPairs.js"; +import { toPairsIn } from "./object/toPairsIn.js"; +import { transform } from "./object/transform.js"; +import { unset } from "./object/unset.js"; +import { update } from "./object/update.js"; +import { updateWith } from "./object/updateWith.js"; +import { values } from "./object/values.js"; +import { valuesIn } from "./object/valuesIn.js"; +import { isFunction } from "./predicate/isFunction.js"; +import { isLength } from "./predicate/isLength.js"; +import { isMatchWith } from "./predicate/isMatchWith.js"; +import { isNative } from "./predicate/isNative.js"; +import { isNull } from "./predicate/isNull.js"; +import { isUndefined } from "./predicate/isUndefined.js"; +import { conforms } from "./predicate/conforms.js"; +import { conformsTo } from "./predicate/conformsTo.js"; +import { isArguments } from "./predicate/isArguments.js"; +import { isArray } from "./predicate/isArray.js"; +import { isArrayBuffer } from "./predicate/isArrayBuffer.js"; +import { isArrayLike } from "./predicate/isArrayLike.js"; +import { isArrayLikeObject } from "./predicate/isArrayLikeObject.js"; +import { isBoolean } from "./predicate/isBoolean.js"; +import { isBuffer } from "./predicate/isBuffer.js"; +import { isDate } from "./predicate/isDate.js"; +import { isElement } from "./predicate/isElement.js"; +import { isEmpty } from "./predicate/isEmpty.js"; +import { isEqualWith } from "./predicate/isEqualWith.js"; +import { isError } from "./predicate/isError.js"; +import { isFinite } from "./predicate/isFinite.js"; +import { isInteger } from "./predicate/isInteger.js"; +import { isMap } from "./predicate/isMap.js"; +import { isMatch } from "./predicate/isMatch.js"; +import { isNaN } from "./predicate/isNaN.js"; +import { isNil } from "./predicate/isNil.js"; +import { isNumber } from "./predicate/isNumber.js"; +import { isObject } from "./predicate/isObject.js"; +import { isObjectLike } from "./predicate/isObjectLike.js"; +import { isPlainObject } from "./predicate/isPlainObject.js"; +import { isRegExp } from "./predicate/isRegExp.js"; +import { isSafeInteger } from "./predicate/isSafeInteger.js"; +import { isSet } from "./predicate/isSet.js"; +import { isString } from "./predicate/isString.js"; +import { isSymbol } from "./predicate/isSymbol.js"; +import { isTypedArray } from "./predicate/isTypedArray.js"; +import { isWeakMap } from "./predicate/isWeakMap.js"; +import { isWeakSet } from "./predicate/isWeakSet.js"; +import { matches } from "./predicate/matches.js"; +import { matchesProperty } from "./predicate/matchesProperty.js"; +import { capitalize } from "./string/capitalize.js"; +import { bindAll } from "./util/bindAll.js"; +import { camelCase } from "./string/camelCase.js"; +import { deburr } from "./string/deburr.js"; +import { endsWith } from "./string/endsWith.js"; +import { escape } from "./string/escape.js"; +import { escapeRegExp } from "./string/escapeRegExp.js"; +import { kebabCase } from "./string/kebabCase.js"; +import { lowerCase } from "./string/lowerCase.js"; +import { lowerFirst } from "./string/lowerFirst.js"; +import { pad } from "./string/pad.js"; +import { padEnd } from "./string/padEnd.js"; +import { padStart } from "./string/padStart.js"; +import { repeat } from "./string/repeat.js"; +import { replace } from "./string/replace.js"; +import { snakeCase } from "./string/snakeCase.js"; +import { split } from "./string/split.js"; +import { startCase } from "./string/startCase.js"; +import { startsWith } from "./string/startsWith.js"; +import { template } from "./string/template.js"; +import { templateSettings } from "./string/templateSettings.js"; +import { toLower } from "./string/toLower.js"; +import { toUpper } from "./string/toUpper.js"; +import { trim } from "./string/trim.js"; +import { trimEnd } from "./string/trimEnd.js"; +import { trimStart } from "./string/trimStart.js"; +import { truncate } from "./string/truncate.js"; +import { unescape } from "./string/unescape.js"; +import { upperCase } from "./string/upperCase.js"; +import { upperFirst } from "./string/upperFirst.js"; +import { words } from "./string/words.js"; +import { cond } from "./util/cond.js"; +import { constant } from "./util/constant.js"; +import { defaultTo } from "./util/defaultTo.js"; +import { eq } from "./util/eq.js"; +import { gt } from "./util/gt.js"; +import { gte } from "./util/gte.js"; +import { invoke } from "./util/invoke.js"; +import { iteratee } from "./util/iteratee.js"; +import { lt } from "./util/lt.js"; +import { lte } from "./util/lte.js"; +import { method } from "./util/method.js"; +import { methodOf } from "./util/methodOf.js"; +import { now } from "./util/now.js"; +import { over } from "./util/over.js"; +import { overEvery } from "./util/overEvery.js"; +import { overSome } from "./util/overSome.js"; +import { stubArray } from "./util/stubArray.js"; +import { stubFalse } from "./util/stubFalse.js"; +import { stubObject } from "./util/stubObject.js"; +import { stubString } from "./util/stubString.js"; +import { stubTrue } from "./util/stubTrue.js"; +import { times } from "./util/times.js"; +import { toArray } from "./util/toArray.js"; +import { toFinite } from "./util/toFinite.js"; +import { toInteger } from "./util/toInteger.js"; +import { toLength } from "./util/toLength.js"; +import { toNumber } from "./util/toNumber.js"; +import { toPath } from "./util/toPath.js"; +import { toPlainObject } from "./util/toPlainObject.js"; +import { toSafeInteger } from "./util/toSafeInteger.js"; +import { toString } from "./util/toString.js"; +import { uniqueId } from "./util/uniqueId.js"; + +//#region src/compat/compat.d.ts +declare namespace compat_d_exports { + export { DebouncedFunc, add, after, ary, assign, assignIn, assignInWith, assignWith, at, attempt, before, bind, bindAll, bindKey, camelCase, capitalize, castArray, ceil, chunk, clamp, clone, cloneDeep, cloneDeepWith, cloneWith, compact, concat, cond, conforms, conformsTo, constant, countBy, create, curry, curryRight, debounce, deburr, defaultTo, defaults, defaultsDeep, defer, delay, difference, differenceBy, differenceWith, divide, drop, dropRight, dropRightWhile, dropWhile, forEach as each, forEachRight as eachRight, endsWith, eq, escape, escapeRegExp, every, assignIn as extend, assignInWith as extendWith, fill, filter, find, findIndex, findKey, findLast, findLastIndex, findLastKey, head as first, flatMap, flatMapDeep, flatMapDepth, flatten, flattenDeep, flattenDepth, flip, floor, flow, flowRight, forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, fromPairs, functions, functionsIn, get, groupBy, gt, gte, has, hasIn, head, identity, inRange, includes, indexOf, initial, intersection, intersectionBy, intersectionWith, invert, invertBy, invoke, invokeMap, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, iteratee, join, kebabCase, keyBy, keys, keysIn, last, lastIndexOf, lowerCase, lowerFirst, lt, lte, map, mapKeys, mapValues, matches, matchesProperty, max, maxBy, mean, meanBy, memoize, merge, mergeWith, method, methodOf, min, minBy, multiply, negate, noop, now, nth, nthArg, omit, omitBy, once, orderBy, over, overArgs, overEvery, overSome, pad, padEnd, padStart, parseInt, partial, partialRight, partition, pick, pickBy, property, propertyOf, pull, pullAll, pullAllBy, pullAllWith, pullAt, random, range, rangeRight, rearg, reduce, reduceRight, reject, remove, repeat, replace, rest, result, reverse, round, sample, sampleSize, set, setWith, shuffle, size, slice, snakeCase, some, sortBy, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, split, spread, startCase, startsWith, stubArray, stubFalse, stubObject, stubString, stubTrue, subtract, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, template, templateSettings, throttle, times, toArray, toDefaulted, toFinite, toInteger, toLength, toLower, toNumber, toPairs, toPairsIn, toPath, toPlainObject, toSafeInteger, toString, toUpper, transform, trim, trimEnd, trimStart, truncate, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, uniqueId, unset, unzip, unzipWith, update, updateWith, upperCase, upperFirst, values, valuesIn, without, words, wrap, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith }; +} +//#endregion +export { compat_d_exports }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/compat.js b/node_modules/es-toolkit/dist/compat/compat.js new file mode 100644 index 0000000000000000000000000000000000000000..7f39135a49ef1bb7e380d1e37cb433628c268e52 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/compat.js @@ -0,0 +1,605 @@ +const require_runtime = require("../_virtual/_rolldown/runtime.js"); +const require_isArray = require("./predicate/isArray.js"); +const require_isPlainObject = require("./predicate/isPlainObject.js"); +const require_eq = require("./util/eq.js"); +const require_isEqual = require("../predicate/isEqual.js"); +const require_castArray = require("./array/castArray.js"); +const require_isArrayLike = require("./predicate/isArrayLike.js"); +const require_chunk = require("./array/chunk.js"); +const require_compact = require("./array/compact.js"); +const require_concat = require("./array/concat.js"); +const require_toString = require("./util/toString.js"); +const require_toPath = require("./util/toPath.js"); +const require_get = require("./object/get.js"); +const require_property = require("./object/property.js"); +const require_isObject = require("./predicate/isObject.js"); +const require_isMatchWith = require("./predicate/isMatchWith.js"); +const require_isMatch = require("./predicate/isMatch.js"); +const require_matches = require("./predicate/matches.js"); +const require_cloneDeepWith = require("./object/cloneDeepWith.js"); +const require_cloneDeep = require("./object/cloneDeep.js"); +const require_isArguments = require("./predicate/isArguments.js"); +const require_has = require("./object/has.js"); +const require_matchesProperty = require("./predicate/matchesProperty.js"); +const require_iteratee = require("./util/iteratee.js"); +const require_countBy = require("./array/countBy.js"); +const require_isObjectLike = require("./predicate/isObjectLike.js"); +const require_isArrayLikeObject = require("./predicate/isArrayLikeObject.js"); +const require_difference = require("./array/difference.js"); +const require_last = require("./array/last.js"); +const require_differenceBy = require("./array/differenceBy.js"); +const require_differenceWith = require("./array/differenceWith.js"); +const require_isSymbol = require("./predicate/isSymbol.js"); +const require_toNumber = require("./util/toNumber.js"); +const require_toFinite = require("./util/toFinite.js"); +const require_toInteger = require("./util/toInteger.js"); +const require_drop = require("./array/drop.js"); +const require_dropRight = require("./array/dropRight.js"); +const require_dropRightWhile = require("./array/dropRightWhile.js"); +const require_dropWhile = require("./array/dropWhile.js"); +const require_forEach = require("./array/forEach.js"); +require("./array/each.js"); +const require_forEachRight = require("./array/forEachRight.js"); +require("./array/eachRight.js"); +const require_every = require("./array/every.js"); +const require_isString = require("./predicate/isString.js"); +const require_fill = require("./array/fill.js"); +const require_filter = require("./array/filter.js"); +const require_find = require("./array/find.js"); +const require_identity = require("./function/identity.js"); +const require_findIndex = require("./array/findIndex.js"); +const require_findLast = require("./array/findLast.js"); +const require_findLastIndex = require("./array/findLastIndex.js"); +const require_head = require("./array/head.js"); +require("./array/first.js"); +const require_flattenDepth = require("./array/flattenDepth.js"); +const require_map = require("./array/map.js"); +const require_flatMap = require("./array/flatMap.js"); +const require_flatMapDepth = require("./array/flatMapDepth.js"); +const require_flatMapDeep = require("./array/flatMapDeep.js"); +const require_flatten = require("./array/flatten.js"); +const require_flattenDeep = require("./array/flattenDeep.js"); +const require_groupBy = require("./array/groupBy.js"); +const require_includes = require("./array/includes.js"); +const require_indexOf = require("./array/indexOf.js"); +const require_initial = require("./array/initial.js"); +const require_intersection = require("./array/intersection.js"); +const require_intersectionBy = require("./array/intersectionBy.js"); +const require_uniq = require("./array/uniq.js"); +const require_intersectionWith = require("./array/intersectionWith.js"); +const require_invokeMap = require("./array/invokeMap.js"); +const require_join = require("./array/join.js"); +const require_reduce = require("./array/reduce.js"); +const require_keyBy = require("./array/keyBy.js"); +const require_lastIndexOf = require("./array/lastIndexOf.js"); +const require_nth = require("./array/nth.js"); +const require_orderBy = require("./array/orderBy.js"); +const require_partition = require("./array/partition.js"); +const require_pull = require("./array/pull.js"); +const require_pullAll = require("./array/pullAll.js"); +const require_pullAllBy = require("./array/pullAllBy.js"); +const require_pullAllWith = require("./array/pullAllWith.js"); +const require_at = require("./object/at.js"); +const require_unset = require("./object/unset.js"); +const require_pullAt = require("./array/pullAt.js"); +const require_reduceRight = require("./array/reduceRight.js"); +const require_negate = require("./function/negate.js"); +const require_reject = require("./array/reject.js"); +const require_remove = require("./array/remove.js"); +const require_reverse = require("./array/reverse.js"); +const require_sample = require("./array/sample.js"); +const require_clamp = require("./math/clamp.js"); +const require_isMap = require("./predicate/isMap.js"); +const require_isSet = require("./predicate/isSet.js"); +const require_toArray = require("./util/toArray.js"); +const require_sampleSize = require("./array/sampleSize.js"); +const require_isTypedArray = require("./predicate/isTypedArray.js"); +const require_times = require("./util/times.js"); +const require_keys = require("./object/keys.js"); +const require_values = require("./object/values.js"); +const require_isNil = require("./predicate/isNil.js"); +const require_shuffle = require("./array/shuffle.js"); +const require_size = require("./array/size.js"); +const require_slice = require("./array/slice.js"); +const require_some = require("./array/some.js"); +const require_sortBy = require("./array/sortBy.js"); +const require_isNumber = require("./predicate/isNumber.js"); +const require_isNaN = require("./predicate/isNaN.js"); +const require_sortedIndexBy = require("./array/sortedIndexBy.js"); +const require_sortedIndex = require("./array/sortedIndex.js"); +const require_sortedIndexOf = require("./array/sortedIndexOf.js"); +const require_sortedLastIndexBy = require("./array/sortedLastIndexBy.js"); +const require_sortedLastIndex = require("./array/sortedLastIndex.js"); +const require_sortedLastIndexOf = require("./array/sortedLastIndexOf.js"); +const require_tail = require("./array/tail.js"); +const require_take = require("./array/take.js"); +const require_takeRight = require("./array/takeRight.js"); +const require_takeRightWhile = require("./array/takeRightWhile.js"); +const require_takeWhile = require("./array/takeWhile.js"); +const require_union = require("./array/union.js"); +const require_unionBy = require("./array/unionBy.js"); +const require_unionWith = require("./array/unionWith.js"); +const require_uniqBy = require("./array/uniqBy.js"); +const require_uniqWith = require("./array/uniqWith.js"); +const require_unzip = require("./array/unzip.js"); +const require_unzipWith = require("./array/unzipWith.js"); +const require_without = require("./array/without.js"); +const require_xor = require("./array/xor.js"); +const require_xorBy = require("./array/xorBy.js"); +const require_xorWith = require("./array/xorWith.js"); +const require_zip = require("./array/zip.js"); +const require_zipObject = require("./array/zipObject.js"); +const require_updateWith = require("./object/updateWith.js"); +const require_set = require("./object/set.js"); +const require_zipObjectDeep = require("./array/zipObjectDeep.js"); +const require_zipWith = require("./array/zipWith.js"); +const require_after = require("./function/after.js"); +const require_ary = require("./function/ary.js"); +const require_attempt = require("./function/attempt.js"); +const require_before = require("./function/before.js"); +const require_bind = require("./function/bind.js"); +const require_bindKey = require("./function/bindKey.js"); +const require_curry = require("./function/curry.js"); +const require_curryRight = require("./function/curryRight.js"); +const require_debounce = require("./function/debounce.js"); +const require_defer = require("./function/defer.js"); +const require_delay = require("./function/delay.js"); +const require_flip = require("./function/flip.js"); +const require_flow = require("./function/flow.js"); +const require_flowRight = require("./function/flowRight.js"); +const require_memoize = require("./function/memoize.js"); +const require_nthArg = require("./function/nthArg.js"); +const require_once = require("./function/once.js"); +const require_overArgs = require("./function/overArgs.js"); +const require_partial = require("./function/partial.js"); +const require_partialRight = require("./function/partialRight.js"); +const require_rearg = require("./function/rearg.js"); +const require_rest = require("./function/rest.js"); +const require_spread = require("./function/spread.js"); +const require_throttle = require("./function/throttle.js"); +const require_unary = require("./function/unary.js"); +const require_wrap = require("./function/wrap.js"); +const require_add = require("./math/add.js"); +const require_ceil = require("./math/ceil.js"); +const require_divide = require("./math/divide.js"); +const require_floor = require("./math/floor.js"); +const require_inRange = require("./math/inRange.js"); +const require_max = require("./math/max.js"); +const require_maxBy = require("./math/maxBy.js"); +const require_sumBy = require("./math/sumBy.js"); +const require_sum = require("./math/sum.js"); +const require_mean = require("./math/mean.js"); +const require_meanBy = require("./math/meanBy.js"); +const require_min = require("./math/min.js"); +const require_minBy = require("./math/minBy.js"); +const require_multiply = require("./math/multiply.js"); +const require_parseInt = require("./math/parseInt.js"); +const require_random = require("./math/random.js"); +const require_range = require("./math/range.js"); +const require_rangeRight = require("./math/rangeRight.js"); +const require_round = require("./math/round.js"); +const require_subtract = require("./math/subtract.js"); +const require_noop = require("./function/noop.js"); +const require_assign = require("./object/assign.js"); +const require_keysIn = require("./object/keysIn.js"); +const require_assignIn = require("./object/assignIn.js"); +const require_assignInWith = require("./object/assignInWith.js"); +const require_assignWith = require("./object/assignWith.js"); +const require_clone = require("./object/clone.js"); +const require_cloneWith = require("./object/cloneWith.js"); +const require_create = require("./object/create.js"); +const require_defaults = require("./object/defaults.js"); +const require_defaultsDeep = require("./object/defaultsDeep.js"); +require("./object/extend.js"); +require("./object/extendWith.js"); +const require_findKey = require("./object/findKey.js"); +const require_findLastKey = require("./object/findLastKey.js"); +const require_forIn = require("./object/forIn.js"); +const require_forInRight = require("./object/forInRight.js"); +const require_forOwn = require("./object/forOwn.js"); +const require_forOwnRight = require("./object/forOwnRight.js"); +const require_fromPairs = require("./object/fromPairs.js"); +const require_functions = require("./object/functions.js"); +const require_functionsIn = require("./object/functionsIn.js"); +const require_hasIn = require("./object/hasIn.js"); +const require_invert = require("./object/invert.js"); +const require_invertBy = require("./object/invertBy.js"); +const require_mapKeys = require("./object/mapKeys.js"); +const require_mapValues = require("./object/mapValues.js"); +const require_mergeWith = require("./object/mergeWith.js"); +const require_merge = require("./object/merge.js"); +const require_omit = require("./object/omit.js"); +const require_omitBy = require("./object/omitBy.js"); +const require_pick = require("./object/pick.js"); +const require_pickBy = require("./object/pickBy.js"); +const require_propertyOf = require("./object/propertyOf.js"); +const require_result = require("./object/result.js"); +const require_setWith = require("./object/setWith.js"); +const require_toDefaulted = require("./object/toDefaulted.js"); +const require_toPairs = require("./object/toPairs.js"); +const require_toPairsIn = require("./object/toPairsIn.js"); +const require_isBuffer = require("./predicate/isBuffer.js"); +const require_transform = require("./object/transform.js"); +const require_update = require("./object/update.js"); +const require_valuesIn = require("./object/valuesIn.js"); +const require_isFunction = require("./predicate/isFunction.js"); +const require_isLength = require("./predicate/isLength.js"); +const require_isNative = require("./predicate/isNative.js"); +const require_isNull = require("./predicate/isNull.js"); +const require_isUndefined = require("./predicate/isUndefined.js"); +const require_conformsTo = require("./predicate/conformsTo.js"); +const require_conforms = require("./predicate/conforms.js"); +const require_isArrayBuffer = require("./predicate/isArrayBuffer.js"); +const require_isBoolean = require("./predicate/isBoolean.js"); +const require_isDate = require("./predicate/isDate.js"); +const require_isElement = require("./predicate/isElement.js"); +const require_isEmpty = require("./predicate/isEmpty.js"); +const require_isEqualWith = require("./predicate/isEqualWith.js"); +const require_isError = require("./predicate/isError.js"); +const require_isFinite = require("./predicate/isFinite.js"); +const require_isInteger = require("./predicate/isInteger.js"); +const require_isRegExp = require("./predicate/isRegExp.js"); +const require_isSafeInteger = require("./predicate/isSafeInteger.js"); +const require_isWeakMap = require("./predicate/isWeakMap.js"); +const require_isWeakSet = require("./predicate/isWeakSet.js"); +const require_capitalize = require("./string/capitalize.js"); +const require_bindAll = require("./util/bindAll.js"); +const require_deburr = require("./string/deburr.js"); +const require_words = require("./string/words.js"); +const require_camelCase = require("./string/camelCase.js"); +const require_endsWith = require("./string/endsWith.js"); +const require_escape = require("./string/escape.js"); +const require_escapeRegExp = require("./string/escapeRegExp.js"); +const require_kebabCase = require("./string/kebabCase.js"); +const require_lowerCase = require("./string/lowerCase.js"); +const require_lowerFirst = require("./string/lowerFirst.js"); +const require_pad = require("./string/pad.js"); +const require_padEnd = require("./string/padEnd.js"); +const require_padStart = require("./string/padStart.js"); +const require_repeat = require("./string/repeat.js"); +const require_replace = require("./string/replace.js"); +const require_snakeCase = require("./string/snakeCase.js"); +const require_split = require("./string/split.js"); +const require_startCase = require("./string/startCase.js"); +const require_startsWith = require("./string/startsWith.js"); +const require_template = require("./string/template.js"); +const require_templateSettings = require("./string/templateSettings.js"); +const require_toLower = require("./string/toLower.js"); +const require_toUpper = require("./string/toUpper.js"); +const require_trim = require("./string/trim.js"); +const require_trimEnd = require("./string/trimEnd.js"); +const require_trimStart = require("./string/trimStart.js"); +const require_truncate = require("./string/truncate.js"); +const require_unescape = require("./string/unescape.js"); +const require_upperCase = require("./string/upperCase.js"); +const require_upperFirst = require("./string/upperFirst.js"); +const require_cond = require("./util/cond.js"); +const require_constant = require("./util/constant.js"); +const require_defaultTo = require("./util/defaultTo.js"); +const require_gt = require("./util/gt.js"); +const require_gte = require("./util/gte.js"); +const require_invoke = require("./util/invoke.js"); +const require_lt = require("./util/lt.js"); +const require_lte = require("./util/lte.js"); +const require_method = require("./util/method.js"); +const require_methodOf = require("./util/methodOf.js"); +const require_now = require("./util/now.js"); +const require_over = require("./util/over.js"); +const require_overEvery = require("./util/overEvery.js"); +const require_overSome = require("./util/overSome.js"); +const require_stubArray = require("./util/stubArray.js"); +const require_stubFalse = require("./util/stubFalse.js"); +const require_stubObject = require("./util/stubObject.js"); +const require_stubString = require("./util/stubString.js"); +const require_stubTrue = require("./util/stubTrue.js"); +const require_toLength = require("./util/toLength.js"); +const require_toPlainObject = require("./util/toPlainObject.js"); +const require_toSafeInteger = require("./util/toSafeInteger.js"); +const require_uniqueId = require("./util/uniqueId.js"); +//#region src/compat/compat.ts +var compat_exports = /* @__PURE__ */ require_runtime.__exportAll({ + add: () => require_add.add, + after: () => require_after.after, + ary: () => require_ary.ary, + assign: () => require_assign.assign, + assignIn: () => require_assignIn.assignIn, + assignInWith: () => require_assignInWith.assignInWith, + assignWith: () => require_assignWith.assignWith, + at: () => require_at.at, + attempt: () => require_attempt.attempt, + before: () => require_before.before, + bind: () => require_bind.bind, + bindAll: () => require_bindAll.bindAll, + bindKey: () => require_bindKey.bindKey, + camelCase: () => require_camelCase.camelCase, + capitalize: () => require_capitalize.capitalize, + castArray: () => require_castArray.castArray, + ceil: () => require_ceil.ceil, + chunk: () => require_chunk.chunk, + clamp: () => require_clamp.clamp, + clone: () => require_clone.clone, + cloneDeep: () => require_cloneDeep.cloneDeep, + cloneDeepWith: () => require_cloneDeepWith.cloneDeepWith, + cloneWith: () => require_cloneWith.cloneWith, + compact: () => require_compact.compact, + concat: () => require_concat.concat, + cond: () => require_cond.cond, + conforms: () => require_conforms.conforms, + conformsTo: () => require_conformsTo.conformsTo, + constant: () => require_constant.constant, + countBy: () => require_countBy.countBy, + create: () => require_create.create, + curry: () => require_curry.curry, + curryRight: () => require_curryRight.curryRight, + debounce: () => require_debounce.debounce, + deburr: () => require_deburr.deburr, + defaultTo: () => require_defaultTo.defaultTo, + defaults: () => require_defaults.defaults, + defaultsDeep: () => require_defaultsDeep.defaultsDeep, + defer: () => require_defer.defer, + delay: () => require_delay.delay, + difference: () => require_difference.difference, + differenceBy: () => require_differenceBy.differenceBy, + differenceWith: () => require_differenceWith.differenceWith, + divide: () => require_divide.divide, + drop: () => require_drop.drop, + dropRight: () => require_dropRight.dropRight, + dropRightWhile: () => require_dropRightWhile.dropRightWhile, + dropWhile: () => require_dropWhile.dropWhile, + each: () => require_forEach.forEach, + eachRight: () => require_forEachRight.forEachRight, + endsWith: () => require_endsWith.endsWith, + eq: () => require_eq.eq, + escape: () => require_escape.escape, + escapeRegExp: () => require_escapeRegExp.escapeRegExp, + every: () => require_every.every, + extend: () => require_assignIn.assignIn, + extendWith: () => require_assignInWith.assignInWith, + fill: () => require_fill.fill, + filter: () => require_filter.filter, + find: () => require_find.find, + findIndex: () => require_findIndex.findIndex, + findKey: () => require_findKey.findKey, + findLast: () => require_findLast.findLast, + findLastIndex: () => require_findLastIndex.findLastIndex, + findLastKey: () => require_findLastKey.findLastKey, + first: () => require_head.head, + flatMap: () => require_flatMap.flatMap, + flatMapDeep: () => require_flatMapDeep.flatMapDeep, + flatMapDepth: () => require_flatMapDepth.flatMapDepth, + flatten: () => require_flatten.flatten, + flattenDeep: () => require_flattenDeep.flattenDeep, + flattenDepth: () => require_flattenDepth.flattenDepth, + flip: () => require_flip.flip, + floor: () => require_floor.floor, + flow: () => require_flow.flow, + flowRight: () => require_flowRight.flowRight, + forEach: () => require_forEach.forEach, + forEachRight: () => require_forEachRight.forEachRight, + forIn: () => require_forIn.forIn, + forInRight: () => require_forInRight.forInRight, + forOwn: () => require_forOwn.forOwn, + forOwnRight: () => require_forOwnRight.forOwnRight, + fromPairs: () => require_fromPairs.fromPairs, + functions: () => require_functions.functions, + functionsIn: () => require_functionsIn.functionsIn, + get: () => require_get.get, + groupBy: () => require_groupBy.groupBy, + gt: () => require_gt.gt, + gte: () => require_gte.gte, + has: () => require_has.has, + hasIn: () => require_hasIn.hasIn, + head: () => require_head.head, + identity: () => require_identity.identity, + inRange: () => require_inRange.inRange, + includes: () => require_includes.includes, + indexOf: () => require_indexOf.indexOf, + initial: () => require_initial.initial, + intersection: () => require_intersection.intersection, + intersectionBy: () => require_intersectionBy.intersectionBy, + intersectionWith: () => require_intersectionWith.intersectionWith, + invert: () => require_invert.invert, + invertBy: () => require_invertBy.invertBy, + invoke: () => require_invoke.invoke, + invokeMap: () => require_invokeMap.invokeMap, + isArguments: () => require_isArguments.isArguments, + isArray: () => require_isArray.isArray, + isArrayBuffer: () => require_isArrayBuffer.isArrayBuffer, + isArrayLike: () => require_isArrayLike.isArrayLike, + isArrayLikeObject: () => require_isArrayLikeObject.isArrayLikeObject, + isBoolean: () => require_isBoolean.isBoolean, + isBuffer: () => require_isBuffer.isBuffer, + isDate: () => require_isDate.isDate, + isElement: () => require_isElement.isElement, + isEmpty: () => require_isEmpty.isEmpty, + isEqual: () => require_isEqual.isEqual, + isEqualWith: () => require_isEqualWith.isEqualWith, + isError: () => require_isError.isError, + isFinite: () => require_isFinite.isFinite, + isFunction: () => require_isFunction.isFunction, + isInteger: () => require_isInteger.isInteger, + isLength: () => require_isLength.isLength, + isMap: () => require_isMap.isMap, + isMatch: () => require_isMatch.isMatch, + isMatchWith: () => require_isMatchWith.isMatchWith, + isNaN: () => require_isNaN.isNaN, + isNative: () => require_isNative.isNative, + isNil: () => require_isNil.isNil, + isNull: () => require_isNull.isNull, + isNumber: () => require_isNumber.isNumber, + isObject: () => require_isObject.isObject, + isObjectLike: () => require_isObjectLike.isObjectLike, + isPlainObject: () => require_isPlainObject.isPlainObject, + isRegExp: () => require_isRegExp.isRegExp, + isSafeInteger: () => require_isSafeInteger.isSafeInteger, + isSet: () => require_isSet.isSet, + isString: () => require_isString.isString, + isSymbol: () => require_isSymbol.isSymbol, + isTypedArray: () => require_isTypedArray.isTypedArray, + isUndefined: () => require_isUndefined.isUndefined, + isWeakMap: () => require_isWeakMap.isWeakMap, + isWeakSet: () => require_isWeakSet.isWeakSet, + iteratee: () => require_iteratee.iteratee, + join: () => require_join.join, + kebabCase: () => require_kebabCase.kebabCase, + keyBy: () => require_keyBy.keyBy, + keys: () => require_keys.keys, + keysIn: () => require_keysIn.keysIn, + last: () => require_last.last, + lastIndexOf: () => require_lastIndexOf.lastIndexOf, + lowerCase: () => require_lowerCase.lowerCase, + lowerFirst: () => require_lowerFirst.lowerFirst, + lt: () => require_lt.lt, + lte: () => require_lte.lte, + map: () => require_map.map, + mapKeys: () => require_mapKeys.mapKeys, + mapValues: () => require_mapValues.mapValues, + matches: () => require_matches.matches, + matchesProperty: () => require_matchesProperty.matchesProperty, + max: () => require_max.max, + maxBy: () => require_maxBy.maxBy, + mean: () => require_mean.mean, + meanBy: () => require_meanBy.meanBy, + memoize: () => require_memoize.memoize, + merge: () => require_merge.merge, + mergeWith: () => require_mergeWith.mergeWith, + method: () => require_method.method, + methodOf: () => require_methodOf.methodOf, + min: () => require_min.min, + minBy: () => require_minBy.minBy, + multiply: () => require_multiply.multiply, + negate: () => require_negate.negate, + noop: () => require_noop.noop, + now: () => require_now.now, + nth: () => require_nth.nth, + nthArg: () => require_nthArg.nthArg, + omit: () => require_omit.omit, + omitBy: () => require_omitBy.omitBy, + once: () => require_once.once, + orderBy: () => require_orderBy.orderBy, + over: () => require_over.over, + overArgs: () => require_overArgs.overArgs, + overEvery: () => require_overEvery.overEvery, + overSome: () => require_overSome.overSome, + pad: () => require_pad.pad, + padEnd: () => require_padEnd.padEnd, + padStart: () => require_padStart.padStart, + parseInt: () => require_parseInt.parseInt, + partial: () => require_partial.partial, + partialRight: () => require_partialRight.partialRight, + partition: () => require_partition.partition, + pick: () => require_pick.pick, + pickBy: () => require_pickBy.pickBy, + property: () => require_property.property, + propertyOf: () => require_propertyOf.propertyOf, + pull: () => require_pull.pull, + pullAll: () => require_pullAll.pullAll, + pullAllBy: () => require_pullAllBy.pullAllBy, + pullAllWith: () => require_pullAllWith.pullAllWith, + pullAt: () => require_pullAt.pullAt, + random: () => require_random.random, + range: () => require_range.range, + rangeRight: () => require_rangeRight.rangeRight, + rearg: () => require_rearg.rearg, + reduce: () => require_reduce.reduce, + reduceRight: () => require_reduceRight.reduceRight, + reject: () => require_reject.reject, + remove: () => require_remove.remove, + repeat: () => require_repeat.repeat, + replace: () => require_replace.replace, + rest: () => require_rest.rest, + result: () => require_result.result, + reverse: () => require_reverse.reverse, + round: () => require_round.round, + sample: () => require_sample.sample, + sampleSize: () => require_sampleSize.sampleSize, + set: () => require_set.set, + setWith: () => require_setWith.setWith, + shuffle: () => require_shuffle.shuffle, + size: () => require_size.size, + slice: () => require_slice.slice, + snakeCase: () => require_snakeCase.snakeCase, + some: () => require_some.some, + sortBy: () => require_sortBy.sortBy, + sortedIndex: () => require_sortedIndex.sortedIndex, + sortedIndexBy: () => require_sortedIndexBy.sortedIndexBy, + sortedIndexOf: () => require_sortedIndexOf.sortedIndexOf, + sortedLastIndex: () => require_sortedLastIndex.sortedLastIndex, + sortedLastIndexBy: () => require_sortedLastIndexBy.sortedLastIndexBy, + sortedLastIndexOf: () => require_sortedLastIndexOf.sortedLastIndexOf, + split: () => require_split.split, + spread: () => require_spread.spread, + startCase: () => require_startCase.startCase, + startsWith: () => require_startsWith.startsWith, + stubArray: () => require_stubArray.stubArray, + stubFalse: () => require_stubFalse.stubFalse, + stubObject: () => require_stubObject.stubObject, + stubString: () => require_stubString.stubString, + stubTrue: () => require_stubTrue.stubTrue, + subtract: () => require_subtract.subtract, + sum: () => require_sum.sum, + sumBy: () => require_sumBy.sumBy, + tail: () => require_tail.tail, + take: () => require_take.take, + takeRight: () => require_takeRight.takeRight, + takeRightWhile: () => require_takeRightWhile.takeRightWhile, + takeWhile: () => require_takeWhile.takeWhile, + template: () => require_template.template, + templateSettings: () => require_templateSettings.templateSettings, + throttle: () => require_throttle.throttle, + times: () => require_times.times, + toArray: () => require_toArray.toArray, + toDefaulted: () => require_toDefaulted.toDefaulted, + toFinite: () => require_toFinite.toFinite, + toInteger: () => require_toInteger.toInteger, + toLength: () => require_toLength.toLength, + toLower: () => require_toLower.toLower, + toNumber: () => require_toNumber.toNumber, + toPairs: () => require_toPairs.toPairs, + toPairsIn: () => require_toPairsIn.toPairsIn, + toPath: () => require_toPath.toPath, + toPlainObject: () => require_toPlainObject.toPlainObject, + toSafeInteger: () => require_toSafeInteger.toSafeInteger, + toString: () => require_toString.toString, + toUpper: () => require_toUpper.toUpper, + transform: () => require_transform.transform, + trim: () => require_trim.trim, + trimEnd: () => require_trimEnd.trimEnd, + trimStart: () => require_trimStart.trimStart, + truncate: () => require_truncate.truncate, + unary: () => require_unary.unary, + unescape: () => require_unescape.unescape, + union: () => require_union.union, + unionBy: () => require_unionBy.unionBy, + unionWith: () => require_unionWith.unionWith, + uniq: () => require_uniq.uniq, + uniqBy: () => require_uniqBy.uniqBy, + uniqWith: () => require_uniqWith.uniqWith, + uniqueId: () => require_uniqueId.uniqueId, + unset: () => require_unset.unset, + unzip: () => require_unzip.unzip, + unzipWith: () => require_unzipWith.unzipWith, + update: () => require_update.update, + updateWith: () => require_updateWith.updateWith, + upperCase: () => require_upperCase.upperCase, + upperFirst: () => require_upperFirst.upperFirst, + values: () => require_values.values, + valuesIn: () => require_valuesIn.valuesIn, + without: () => require_without.without, + words: () => require_words.words, + wrap: () => require_wrap.wrap, + xor: () => require_xor.xor, + xorBy: () => require_xorBy.xorBy, + xorWith: () => require_xorWith.xorWith, + zip: () => require_zip.zip, + zipObject: () => require_zipObject.zipObject, + zipObjectDeep: () => require_zipObjectDeep.zipObjectDeep, + zipWith: () => require_zipWith.zipWith +}); +//#endregion +Object.defineProperty(exports, "compat_exports", { + enumerable: true, + get: function() { + return compat_exports; + } +}); diff --git a/node_modules/es-toolkit/dist/compat/compat.mjs b/node_modules/es-toolkit/dist/compat/compat.mjs new file mode 100644 index 0000000000000000000000000000000000000000..599053f6c89ecd1976ba29ea966af82c47165561 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/compat.mjs @@ -0,0 +1,600 @@ +import { __exportAll } from "../_virtual/_rolldown/runtime.mjs"; +import { isArray } from "./predicate/isArray.mjs"; +import { isPlainObject } from "./predicate/isPlainObject.mjs"; +import { eq } from "./util/eq.mjs"; +import { isEqual } from "../predicate/isEqual.mjs"; +import { castArray } from "./array/castArray.mjs"; +import { isArrayLike } from "./predicate/isArrayLike.mjs"; +import { chunk } from "./array/chunk.mjs"; +import { compact } from "./array/compact.mjs"; +import { concat } from "./array/concat.mjs"; +import { toString } from "./util/toString.mjs"; +import { toPath } from "./util/toPath.mjs"; +import { get } from "./object/get.mjs"; +import { property } from "./object/property.mjs"; +import { isObject } from "./predicate/isObject.mjs"; +import { isMatchWith } from "./predicate/isMatchWith.mjs"; +import { isMatch } from "./predicate/isMatch.mjs"; +import { matches } from "./predicate/matches.mjs"; +import { cloneDeepWith } from "./object/cloneDeepWith.mjs"; +import { cloneDeep } from "./object/cloneDeep.mjs"; +import { isArguments } from "./predicate/isArguments.mjs"; +import { has } from "./object/has.mjs"; +import { matchesProperty } from "./predicate/matchesProperty.mjs"; +import { iteratee } from "./util/iteratee.mjs"; +import { countBy } from "./array/countBy.mjs"; +import { isObjectLike } from "./predicate/isObjectLike.mjs"; +import { isArrayLikeObject } from "./predicate/isArrayLikeObject.mjs"; +import { difference } from "./array/difference.mjs"; +import { last } from "./array/last.mjs"; +import { differenceBy } from "./array/differenceBy.mjs"; +import { differenceWith } from "./array/differenceWith.mjs"; +import { isSymbol } from "./predicate/isSymbol.mjs"; +import { toNumber } from "./util/toNumber.mjs"; +import { toFinite } from "./util/toFinite.mjs"; +import { toInteger } from "./util/toInteger.mjs"; +import { drop } from "./array/drop.mjs"; +import { dropRight } from "./array/dropRight.mjs"; +import { dropRightWhile } from "./array/dropRightWhile.mjs"; +import { dropWhile } from "./array/dropWhile.mjs"; +import { forEach } from "./array/forEach.mjs"; +import "./array/each.mjs"; +import { forEachRight } from "./array/forEachRight.mjs"; +import "./array/eachRight.mjs"; +import { every } from "./array/every.mjs"; +import { isString } from "./predicate/isString.mjs"; +import { fill } from "./array/fill.mjs"; +import { filter } from "./array/filter.mjs"; +import { find } from "./array/find.mjs"; +import { identity } from "./function/identity.mjs"; +import { findIndex } from "./array/findIndex.mjs"; +import { findLast } from "./array/findLast.mjs"; +import { findLastIndex } from "./array/findLastIndex.mjs"; +import { head } from "./array/head.mjs"; +import "./array/first.mjs"; +import { flattenDepth } from "./array/flattenDepth.mjs"; +import { map } from "./array/map.mjs"; +import { flatMap } from "./array/flatMap.mjs"; +import { flatMapDepth } from "./array/flatMapDepth.mjs"; +import { flatMapDeep } from "./array/flatMapDeep.mjs"; +import { flatten } from "./array/flatten.mjs"; +import { flattenDeep } from "./array/flattenDeep.mjs"; +import { groupBy } from "./array/groupBy.mjs"; +import { includes } from "./array/includes.mjs"; +import { indexOf } from "./array/indexOf.mjs"; +import { initial } from "./array/initial.mjs"; +import { intersection } from "./array/intersection.mjs"; +import { intersectionBy } from "./array/intersectionBy.mjs"; +import { uniq } from "./array/uniq.mjs"; +import { intersectionWith } from "./array/intersectionWith.mjs"; +import { invokeMap } from "./array/invokeMap.mjs"; +import { join } from "./array/join.mjs"; +import { reduce } from "./array/reduce.mjs"; +import { keyBy } from "./array/keyBy.mjs"; +import { lastIndexOf } from "./array/lastIndexOf.mjs"; +import { nth } from "./array/nth.mjs"; +import { orderBy } from "./array/orderBy.mjs"; +import { partition } from "./array/partition.mjs"; +import { pull } from "./array/pull.mjs"; +import { pullAll } from "./array/pullAll.mjs"; +import { pullAllBy } from "./array/pullAllBy.mjs"; +import { pullAllWith } from "./array/pullAllWith.mjs"; +import { at } from "./object/at.mjs"; +import { unset } from "./object/unset.mjs"; +import { pullAt } from "./array/pullAt.mjs"; +import { reduceRight } from "./array/reduceRight.mjs"; +import { negate } from "./function/negate.mjs"; +import { reject } from "./array/reject.mjs"; +import { remove } from "./array/remove.mjs"; +import { reverse } from "./array/reverse.mjs"; +import { sample } from "./array/sample.mjs"; +import { clamp } from "./math/clamp.mjs"; +import { isMap } from "./predicate/isMap.mjs"; +import { isSet } from "./predicate/isSet.mjs"; +import { toArray } from "./util/toArray.mjs"; +import { sampleSize } from "./array/sampleSize.mjs"; +import { isTypedArray } from "./predicate/isTypedArray.mjs"; +import { times } from "./util/times.mjs"; +import { keys } from "./object/keys.mjs"; +import { values } from "./object/values.mjs"; +import { isNil } from "./predicate/isNil.mjs"; +import { shuffle } from "./array/shuffle.mjs"; +import { size } from "./array/size.mjs"; +import { slice } from "./array/slice.mjs"; +import { some } from "./array/some.mjs"; +import { sortBy } from "./array/sortBy.mjs"; +import { isNumber } from "./predicate/isNumber.mjs"; +import { isNaN } from "./predicate/isNaN.mjs"; +import { sortedIndexBy } from "./array/sortedIndexBy.mjs"; +import { sortedIndex } from "./array/sortedIndex.mjs"; +import { sortedIndexOf } from "./array/sortedIndexOf.mjs"; +import { sortedLastIndexBy } from "./array/sortedLastIndexBy.mjs"; +import { sortedLastIndex } from "./array/sortedLastIndex.mjs"; +import { sortedLastIndexOf } from "./array/sortedLastIndexOf.mjs"; +import { tail } from "./array/tail.mjs"; +import { take } from "./array/take.mjs"; +import { takeRight } from "./array/takeRight.mjs"; +import { takeRightWhile } from "./array/takeRightWhile.mjs"; +import { takeWhile } from "./array/takeWhile.mjs"; +import { union } from "./array/union.mjs"; +import { unionBy } from "./array/unionBy.mjs"; +import { unionWith } from "./array/unionWith.mjs"; +import { uniqBy } from "./array/uniqBy.mjs"; +import { uniqWith } from "./array/uniqWith.mjs"; +import { unzip } from "./array/unzip.mjs"; +import { unzipWith } from "./array/unzipWith.mjs"; +import { without } from "./array/without.mjs"; +import { xor } from "./array/xor.mjs"; +import { xorBy } from "./array/xorBy.mjs"; +import { xorWith } from "./array/xorWith.mjs"; +import { zip } from "./array/zip.mjs"; +import { zipObject } from "./array/zipObject.mjs"; +import { updateWith } from "./object/updateWith.mjs"; +import { set } from "./object/set.mjs"; +import { zipObjectDeep } from "./array/zipObjectDeep.mjs"; +import { zipWith } from "./array/zipWith.mjs"; +import { after } from "./function/after.mjs"; +import { ary } from "./function/ary.mjs"; +import { attempt } from "./function/attempt.mjs"; +import { before } from "./function/before.mjs"; +import { bind } from "./function/bind.mjs"; +import { bindKey } from "./function/bindKey.mjs"; +import { curry } from "./function/curry.mjs"; +import { curryRight } from "./function/curryRight.mjs"; +import { debounce } from "./function/debounce.mjs"; +import { defer } from "./function/defer.mjs"; +import { delay } from "./function/delay.mjs"; +import { flip } from "./function/flip.mjs"; +import { flow } from "./function/flow.mjs"; +import { flowRight } from "./function/flowRight.mjs"; +import { memoize } from "./function/memoize.mjs"; +import { nthArg } from "./function/nthArg.mjs"; +import { once } from "./function/once.mjs"; +import { overArgs } from "./function/overArgs.mjs"; +import { partial } from "./function/partial.mjs"; +import { partialRight } from "./function/partialRight.mjs"; +import { rearg } from "./function/rearg.mjs"; +import { rest } from "./function/rest.mjs"; +import { spread } from "./function/spread.mjs"; +import { throttle } from "./function/throttle.mjs"; +import { unary } from "./function/unary.mjs"; +import { wrap } from "./function/wrap.mjs"; +import { add } from "./math/add.mjs"; +import { ceil } from "./math/ceil.mjs"; +import { divide } from "./math/divide.mjs"; +import { floor } from "./math/floor.mjs"; +import { inRange } from "./math/inRange.mjs"; +import { max } from "./math/max.mjs"; +import { maxBy } from "./math/maxBy.mjs"; +import { sumBy } from "./math/sumBy.mjs"; +import { sum } from "./math/sum.mjs"; +import { mean } from "./math/mean.mjs"; +import { meanBy } from "./math/meanBy.mjs"; +import { min } from "./math/min.mjs"; +import { minBy } from "./math/minBy.mjs"; +import { multiply } from "./math/multiply.mjs"; +import { parseInt } from "./math/parseInt.mjs"; +import { random } from "./math/random.mjs"; +import { range } from "./math/range.mjs"; +import { rangeRight } from "./math/rangeRight.mjs"; +import { round } from "./math/round.mjs"; +import { subtract } from "./math/subtract.mjs"; +import { noop } from "./function/noop.mjs"; +import { assign } from "./object/assign.mjs"; +import { keysIn } from "./object/keysIn.mjs"; +import { assignIn } from "./object/assignIn.mjs"; +import { assignInWith } from "./object/assignInWith.mjs"; +import { assignWith } from "./object/assignWith.mjs"; +import { clone } from "./object/clone.mjs"; +import { cloneWith } from "./object/cloneWith.mjs"; +import { create } from "./object/create.mjs"; +import { defaults } from "./object/defaults.mjs"; +import { defaultsDeep } from "./object/defaultsDeep.mjs"; +import "./object/extend.mjs"; +import "./object/extendWith.mjs"; +import { findKey } from "./object/findKey.mjs"; +import { findLastKey } from "./object/findLastKey.mjs"; +import { forIn } from "./object/forIn.mjs"; +import { forInRight } from "./object/forInRight.mjs"; +import { forOwn } from "./object/forOwn.mjs"; +import { forOwnRight } from "./object/forOwnRight.mjs"; +import { fromPairs } from "./object/fromPairs.mjs"; +import { functions } from "./object/functions.mjs"; +import { functionsIn } from "./object/functionsIn.mjs"; +import { hasIn } from "./object/hasIn.mjs"; +import { invert } from "./object/invert.mjs"; +import { invertBy } from "./object/invertBy.mjs"; +import { mapKeys } from "./object/mapKeys.mjs"; +import { mapValues } from "./object/mapValues.mjs"; +import { mergeWith } from "./object/mergeWith.mjs"; +import { merge } from "./object/merge.mjs"; +import { omit } from "./object/omit.mjs"; +import { omitBy } from "./object/omitBy.mjs"; +import { pick } from "./object/pick.mjs"; +import { pickBy } from "./object/pickBy.mjs"; +import { propertyOf } from "./object/propertyOf.mjs"; +import { result } from "./object/result.mjs"; +import { setWith } from "./object/setWith.mjs"; +import { toDefaulted } from "./object/toDefaulted.mjs"; +import { toPairs } from "./object/toPairs.mjs"; +import { toPairsIn } from "./object/toPairsIn.mjs"; +import { isBuffer } from "./predicate/isBuffer.mjs"; +import { transform } from "./object/transform.mjs"; +import { update } from "./object/update.mjs"; +import { valuesIn } from "./object/valuesIn.mjs"; +import { isFunction } from "./predicate/isFunction.mjs"; +import { isLength } from "./predicate/isLength.mjs"; +import { isNative } from "./predicate/isNative.mjs"; +import { isNull } from "./predicate/isNull.mjs"; +import { isUndefined } from "./predicate/isUndefined.mjs"; +import { conformsTo } from "./predicate/conformsTo.mjs"; +import { conforms } from "./predicate/conforms.mjs"; +import { isArrayBuffer } from "./predicate/isArrayBuffer.mjs"; +import { isBoolean } from "./predicate/isBoolean.mjs"; +import { isDate } from "./predicate/isDate.mjs"; +import { isElement } from "./predicate/isElement.mjs"; +import { isEmpty } from "./predicate/isEmpty.mjs"; +import { isEqualWith } from "./predicate/isEqualWith.mjs"; +import { isError } from "./predicate/isError.mjs"; +import { isFinite } from "./predicate/isFinite.mjs"; +import { isInteger } from "./predicate/isInteger.mjs"; +import { isRegExp } from "./predicate/isRegExp.mjs"; +import { isSafeInteger } from "./predicate/isSafeInteger.mjs"; +import { isWeakMap } from "./predicate/isWeakMap.mjs"; +import { isWeakSet } from "./predicate/isWeakSet.mjs"; +import { capitalize } from "./string/capitalize.mjs"; +import { bindAll } from "./util/bindAll.mjs"; +import { deburr } from "./string/deburr.mjs"; +import { words } from "./string/words.mjs"; +import { camelCase } from "./string/camelCase.mjs"; +import { endsWith } from "./string/endsWith.mjs"; +import { escape } from "./string/escape.mjs"; +import { escapeRegExp } from "./string/escapeRegExp.mjs"; +import { kebabCase } from "./string/kebabCase.mjs"; +import { lowerCase } from "./string/lowerCase.mjs"; +import { lowerFirst } from "./string/lowerFirst.mjs"; +import { pad } from "./string/pad.mjs"; +import { padEnd } from "./string/padEnd.mjs"; +import { padStart } from "./string/padStart.mjs"; +import { repeat } from "./string/repeat.mjs"; +import { replace } from "./string/replace.mjs"; +import { snakeCase } from "./string/snakeCase.mjs"; +import { split } from "./string/split.mjs"; +import { startCase } from "./string/startCase.mjs"; +import { startsWith } from "./string/startsWith.mjs"; +import { template } from "./string/template.mjs"; +import { templateSettings } from "./string/templateSettings.mjs"; +import { toLower } from "./string/toLower.mjs"; +import { toUpper } from "./string/toUpper.mjs"; +import { trim } from "./string/trim.mjs"; +import { trimEnd } from "./string/trimEnd.mjs"; +import { trimStart } from "./string/trimStart.mjs"; +import { truncate } from "./string/truncate.mjs"; +import { unescape } from "./string/unescape.mjs"; +import { upperCase } from "./string/upperCase.mjs"; +import { upperFirst } from "./string/upperFirst.mjs"; +import { cond } from "./util/cond.mjs"; +import { constant } from "./util/constant.mjs"; +import { defaultTo } from "./util/defaultTo.mjs"; +import { gt } from "./util/gt.mjs"; +import { gte } from "./util/gte.mjs"; +import { invoke } from "./util/invoke.mjs"; +import { lt } from "./util/lt.mjs"; +import { lte } from "./util/lte.mjs"; +import { method } from "./util/method.mjs"; +import { methodOf } from "./util/methodOf.mjs"; +import { now } from "./util/now.mjs"; +import { over } from "./util/over.mjs"; +import { overEvery } from "./util/overEvery.mjs"; +import { overSome } from "./util/overSome.mjs"; +import { stubArray } from "./util/stubArray.mjs"; +import { stubFalse } from "./util/stubFalse.mjs"; +import { stubObject } from "./util/stubObject.mjs"; +import { stubString } from "./util/stubString.mjs"; +import { stubTrue } from "./util/stubTrue.mjs"; +import { toLength } from "./util/toLength.mjs"; +import { toPlainObject } from "./util/toPlainObject.mjs"; +import { toSafeInteger } from "./util/toSafeInteger.mjs"; +import { uniqueId } from "./util/uniqueId.mjs"; +//#region src/compat/compat.ts +var compat_exports = /* @__PURE__ */ __exportAll({ + add: () => add, + after: () => after, + ary: () => ary, + assign: () => assign, + assignIn: () => assignIn, + assignInWith: () => assignInWith, + assignWith: () => assignWith, + at: () => at, + attempt: () => attempt, + before: () => before, + bind: () => bind, + bindAll: () => bindAll, + bindKey: () => bindKey, + camelCase: () => camelCase, + capitalize: () => capitalize, + castArray: () => castArray, + ceil: () => ceil, + chunk: () => chunk, + clamp: () => clamp, + clone: () => clone, + cloneDeep: () => cloneDeep, + cloneDeepWith: () => cloneDeepWith, + cloneWith: () => cloneWith, + compact: () => compact, + concat: () => concat, + cond: () => cond, + conforms: () => conforms, + conformsTo: () => conformsTo, + constant: () => constant, + countBy: () => countBy, + create: () => create, + curry: () => curry, + curryRight: () => curryRight, + debounce: () => debounce, + deburr: () => deburr, + defaultTo: () => defaultTo, + defaults: () => defaults, + defaultsDeep: () => defaultsDeep, + defer: () => defer, + delay: () => delay, + difference: () => difference, + differenceBy: () => differenceBy, + differenceWith: () => differenceWith, + divide: () => divide, + drop: () => drop, + dropRight: () => dropRight, + dropRightWhile: () => dropRightWhile, + dropWhile: () => dropWhile, + each: () => forEach, + eachRight: () => forEachRight, + endsWith: () => endsWith, + eq: () => eq, + escape: () => escape, + escapeRegExp: () => escapeRegExp, + every: () => every, + extend: () => assignIn, + extendWith: () => assignInWith, + fill: () => fill, + filter: () => filter, + find: () => find, + findIndex: () => findIndex, + findKey: () => findKey, + findLast: () => findLast, + findLastIndex: () => findLastIndex, + findLastKey: () => findLastKey, + first: () => head, + flatMap: () => flatMap, + flatMapDeep: () => flatMapDeep, + flatMapDepth: () => flatMapDepth, + flatten: () => flatten, + flattenDeep: () => flattenDeep, + flattenDepth: () => flattenDepth, + flip: () => flip, + floor: () => floor, + flow: () => flow, + flowRight: () => flowRight, + forEach: () => forEach, + forEachRight: () => forEachRight, + forIn: () => forIn, + forInRight: () => forInRight, + forOwn: () => forOwn, + forOwnRight: () => forOwnRight, + fromPairs: () => fromPairs, + functions: () => functions, + functionsIn: () => functionsIn, + get: () => get, + groupBy: () => groupBy, + gt: () => gt, + gte: () => gte, + has: () => has, + hasIn: () => hasIn, + head: () => head, + identity: () => identity, + inRange: () => inRange, + includes: () => includes, + indexOf: () => indexOf, + initial: () => initial, + intersection: () => intersection, + intersectionBy: () => intersectionBy, + intersectionWith: () => intersectionWith, + invert: () => invert, + invertBy: () => invertBy, + invoke: () => invoke, + invokeMap: () => invokeMap, + isArguments: () => isArguments, + isArray: () => isArray, + isArrayBuffer: () => isArrayBuffer, + isArrayLike: () => isArrayLike, + isArrayLikeObject: () => isArrayLikeObject, + isBoolean: () => isBoolean, + isBuffer: () => isBuffer, + isDate: () => isDate, + isElement: () => isElement, + isEmpty: () => isEmpty, + isEqual: () => isEqual, + isEqualWith: () => isEqualWith, + isError: () => isError, + isFinite: () => isFinite, + isFunction: () => isFunction, + isInteger: () => isInteger, + isLength: () => isLength, + isMap: () => isMap, + isMatch: () => isMatch, + isMatchWith: () => isMatchWith, + isNaN: () => isNaN, + isNative: () => isNative, + isNil: () => isNil, + isNull: () => isNull, + isNumber: () => isNumber, + isObject: () => isObject, + isObjectLike: () => isObjectLike, + isPlainObject: () => isPlainObject, + isRegExp: () => isRegExp, + isSafeInteger: () => isSafeInteger, + isSet: () => isSet, + isString: () => isString, + isSymbol: () => isSymbol, + isTypedArray: () => isTypedArray, + isUndefined: () => isUndefined, + isWeakMap: () => isWeakMap, + isWeakSet: () => isWeakSet, + iteratee: () => iteratee, + join: () => join, + kebabCase: () => kebabCase, + keyBy: () => keyBy, + keys: () => keys, + keysIn: () => keysIn, + last: () => last, + lastIndexOf: () => lastIndexOf, + lowerCase: () => lowerCase, + lowerFirst: () => lowerFirst, + lt: () => lt, + lte: () => lte, + map: () => map, + mapKeys: () => mapKeys, + mapValues: () => mapValues, + matches: () => matches, + matchesProperty: () => matchesProperty, + max: () => max, + maxBy: () => maxBy, + mean: () => mean, + meanBy: () => meanBy, + memoize: () => memoize, + merge: () => merge, + mergeWith: () => mergeWith, + method: () => method, + methodOf: () => methodOf, + min: () => min, + minBy: () => minBy, + multiply: () => multiply, + negate: () => negate, + noop: () => noop, + now: () => now, + nth: () => nth, + nthArg: () => nthArg, + omit: () => omit, + omitBy: () => omitBy, + once: () => once, + orderBy: () => orderBy, + over: () => over, + overArgs: () => overArgs, + overEvery: () => overEvery, + overSome: () => overSome, + pad: () => pad, + padEnd: () => padEnd, + padStart: () => padStart, + parseInt: () => parseInt, + partial: () => partial, + partialRight: () => partialRight, + partition: () => partition, + pick: () => pick, + pickBy: () => pickBy, + property: () => property, + propertyOf: () => propertyOf, + pull: () => pull, + pullAll: () => pullAll, + pullAllBy: () => pullAllBy, + pullAllWith: () => pullAllWith, + pullAt: () => pullAt, + random: () => random, + range: () => range, + rangeRight: () => rangeRight, + rearg: () => rearg, + reduce: () => reduce, + reduceRight: () => reduceRight, + reject: () => reject, + remove: () => remove, + repeat: () => repeat, + replace: () => replace, + rest: () => rest, + result: () => result, + reverse: () => reverse, + round: () => round, + sample: () => sample, + sampleSize: () => sampleSize, + set: () => set, + setWith: () => setWith, + shuffle: () => shuffle, + size: () => size, + slice: () => slice, + snakeCase: () => snakeCase, + some: () => some, + sortBy: () => sortBy, + sortedIndex: () => sortedIndex, + sortedIndexBy: () => sortedIndexBy, + sortedIndexOf: () => sortedIndexOf, + sortedLastIndex: () => sortedLastIndex, + sortedLastIndexBy: () => sortedLastIndexBy, + sortedLastIndexOf: () => sortedLastIndexOf, + split: () => split, + spread: () => spread, + startCase: () => startCase, + startsWith: () => startsWith, + stubArray: () => stubArray, + stubFalse: () => stubFalse, + stubObject: () => stubObject, + stubString: () => stubString, + stubTrue: () => stubTrue, + subtract: () => subtract, + sum: () => sum, + sumBy: () => sumBy, + tail: () => tail, + take: () => take, + takeRight: () => takeRight, + takeRightWhile: () => takeRightWhile, + takeWhile: () => takeWhile, + template: () => template, + templateSettings: () => templateSettings, + throttle: () => throttle, + times: () => times, + toArray: () => toArray, + toDefaulted: () => toDefaulted, + toFinite: () => toFinite, + toInteger: () => toInteger, + toLength: () => toLength, + toLower: () => toLower, + toNumber: () => toNumber, + toPairs: () => toPairs, + toPairsIn: () => toPairsIn, + toPath: () => toPath, + toPlainObject: () => toPlainObject, + toSafeInteger: () => toSafeInteger, + toString: () => toString, + toUpper: () => toUpper, + transform: () => transform, + trim: () => trim, + trimEnd: () => trimEnd, + trimStart: () => trimStart, + truncate: () => truncate, + unary: () => unary, + unescape: () => unescape, + union: () => union, + unionBy: () => unionBy, + unionWith: () => unionWith, + uniq: () => uniq, + uniqBy: () => uniqBy, + uniqWith: () => uniqWith, + uniqueId: () => uniqueId, + unset: () => unset, + unzip: () => unzip, + unzipWith: () => unzipWith, + update: () => update, + updateWith: () => updateWith, + upperCase: () => upperCase, + upperFirst: () => upperFirst, + values: () => values, + valuesIn: () => valuesIn, + without: () => without, + words: () => words, + wrap: () => wrap, + xor: () => xor, + xorBy: () => xorBy, + xorWith: () => xorWith, + zip: () => zip, + zipObject: () => zipObject, + zipObjectDeep: () => zipObjectDeep, + zipWith: () => zipWith +}); +//#endregion +export { compat_exports }; diff --git a/node_modules/es-toolkit/dist/compat/function/after.d.mts b/node_modules/es-toolkit/dist/compat/function/after.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0b523f9d0aed94b00e84769f6018e8d812e150b3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/after.d.mts @@ -0,0 +1,25 @@ +//#region src/compat/function/after.d.ts +/** + * The opposite of `_.before`; this method creates a function that invokes + * `func` once it's called `n` or more times. + * + * @template TFunc - The type of the function to be invoked. + * @param n - The number of calls before `func` is invoked. + * @param func - The function to restrict. + * @returns Returns the new restricted function. + * @throws {TypeError} - If `func` is not a function. + * + * @example + * const saves = ['profile', 'settings']; + * const done = after(saves.length, () => { + * console.log('done saving!'); + * }); + * + * saves.forEach(type => { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => Logs 'done saving!' after the two async saves have completed. + */ +declare function after any>(n: number, func: TFunc): TFunc; +//#endregion +export { after }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/after.d.ts b/node_modules/es-toolkit/dist/compat/function/after.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b523f9d0aed94b00e84769f6018e8d812e150b3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/after.d.ts @@ -0,0 +1,25 @@ +//#region src/compat/function/after.d.ts +/** + * The opposite of `_.before`; this method creates a function that invokes + * `func` once it's called `n` or more times. + * + * @template TFunc - The type of the function to be invoked. + * @param n - The number of calls before `func` is invoked. + * @param func - The function to restrict. + * @returns Returns the new restricted function. + * @throws {TypeError} - If `func` is not a function. + * + * @example + * const saves = ['profile', 'settings']; + * const done = after(saves.length, () => { + * console.log('done saving!'); + * }); + * + * saves.forEach(type => { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => Logs 'done saving!' after the two async saves have completed. + */ +declare function after any>(n: number, func: TFunc): TFunc; +//#endregion +export { after }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/after.js b/node_modules/es-toolkit/dist/compat/function/after.js new file mode 100644 index 0000000000000000000000000000000000000000..c5b138dbbb1db8f73cfc057c932db4c82728a870 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/after.js @@ -0,0 +1,32 @@ +const require_toInteger = require("../util/toInteger.js"); +//#region src/compat/function/after.ts +/** +* The opposite of `_.before`; this method creates a function that invokes +* `func` once it's called `n` or more times. +* +* @template TFunc - The type of the function to be invoked. +* @param n - The number of calls before `func` is invoked. +* @param func - The function to restrict. +* @returns Returns the new restricted function. +* @throws {TypeError} - If `func` is not a function. +* +* @example +* const saves = ['profile', 'settings']; +* const done = after(saves.length, () => { +* console.log('done saving!'); +* }); +* +* saves.forEach(type => { +* asyncSave({ 'type': type, 'complete': done }); +* }); +* // => Logs 'done saving!' after the two async saves have completed. +*/ +function after(n, func) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + n = require_toInteger.toInteger(n); + return function(...args) { + if (--n < 1) return func.apply(this, args); + }; +} +//#endregion +exports.after = after; diff --git a/node_modules/es-toolkit/dist/compat/function/after.mjs b/node_modules/es-toolkit/dist/compat/function/after.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fa15523ebef46f87613723219a0bafcbf380c55d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/after.mjs @@ -0,0 +1,32 @@ +import { toInteger } from "../util/toInteger.mjs"; +//#region src/compat/function/after.ts +/** +* The opposite of `_.before`; this method creates a function that invokes +* `func` once it's called `n` or more times. +* +* @template TFunc - The type of the function to be invoked. +* @param n - The number of calls before `func` is invoked. +* @param func - The function to restrict. +* @returns Returns the new restricted function. +* @throws {TypeError} - If `func` is not a function. +* +* @example +* const saves = ['profile', 'settings']; +* const done = after(saves.length, () => { +* console.log('done saving!'); +* }); +* +* saves.forEach(type => { +* asyncSave({ 'type': type, 'complete': done }); +* }); +* // => Logs 'done saving!' after the two async saves have completed. +*/ +function after(n, func) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + n = toInteger(n); + return function(...args) { + if (--n < 1) return func.apply(this, args); + }; +} +//#endregion +export { after }; diff --git a/node_modules/es-toolkit/dist/compat/function/ary.d.mts b/node_modules/es-toolkit/dist/compat/function/ary.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a371fd16d07c3cb426e3999d307537e7d8608783 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/ary.d.mts @@ -0,0 +1,25 @@ +//#region src/compat/function/ary.d.ts +/** + * Creates a function that invokes func, with up to `n` arguments, ignoring any additional arguments. + * If `n` is not provided, it defaults to the function's length. + * + * @param func - The function to cap arguments for. + * @param [n] - The arity cap. Defaults to func.length. + * @returns Returns the new capped function. + * + * @example + * function fn(a: number, b: number, c: number) { + * return Array.from(arguments); + * } + * + * // Cap at 2 arguments + * const capped = ary(fn, 2); + * capped(1, 2, 3); // [1, 2] + * + * // Default to function length + * const defaultCap = ary(fn); + * defaultCap(1, 2, 3); // [1, 2, 3] + */ +declare function ary(func: (...args: any[]) => any, n?: number): (...args: any[]) => any; +//#endregion +export { ary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/ary.d.ts b/node_modules/es-toolkit/dist/compat/function/ary.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a371fd16d07c3cb426e3999d307537e7d8608783 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/ary.d.ts @@ -0,0 +1,25 @@ +//#region src/compat/function/ary.d.ts +/** + * Creates a function that invokes func, with up to `n` arguments, ignoring any additional arguments. + * If `n` is not provided, it defaults to the function's length. + * + * @param func - The function to cap arguments for. + * @param [n] - The arity cap. Defaults to func.length. + * @returns Returns the new capped function. + * + * @example + * function fn(a: number, b: number, c: number) { + * return Array.from(arguments); + * } + * + * // Cap at 2 arguments + * const capped = ary(fn, 2); + * capped(1, 2, 3); // [1, 2] + * + * // Default to function length + * const defaultCap = ary(fn); + * defaultCap(1, 2, 3); // [1, 2, 3] + */ +declare function ary(func: (...args: any[]) => any, n?: number): (...args: any[]) => any; +//#endregion +export { ary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/ary.js b/node_modules/es-toolkit/dist/compat/function/ary.js new file mode 100644 index 0000000000000000000000000000000000000000..214a02013897f9352f59e978240824e24469eadb --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/ary.js @@ -0,0 +1,28 @@ +const require_ary = require("../../function/ary.js"); +//#region src/compat/function/ary.ts +/** +* Creates a function that invokes func, with up to `n` arguments, ignoring any additional arguments. +* +* @template F - The type of the function. +* @param func - The function to cap arguments for. +* @param n - The arity cap. +* @param guard - The value to guard the arity cap. +* @returns Returns the new capped function. +* +* @example +* function fn(a: number, b: number, c: number) { +* return Array.from(arguments); +* } +* +* ary(fn, 0)(1, 2, 3); // [] +* ary(fn, 1)(1, 2, 3); // [1] +* ary(fn, 2)(1, 2, 3); // [1, 2] +* ary(fn, 3)(1, 2, 3); // [1, 2, 3] +*/ +function ary(func, n = func.length, guard) { + if (guard) n = func.length; + if (Number.isNaN(n) || n < 0) n = 0; + return require_ary.ary(func, n); +} +//#endregion +exports.ary = ary; diff --git a/node_modules/es-toolkit/dist/compat/function/ary.mjs b/node_modules/es-toolkit/dist/compat/function/ary.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c042ea6d46f85bbd61d5be2b39acf923d434dd10 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/ary.mjs @@ -0,0 +1,28 @@ +import { ary as ary$1 } from "../../function/ary.mjs"; +//#region src/compat/function/ary.ts +/** +* Creates a function that invokes func, with up to `n` arguments, ignoring any additional arguments. +* +* @template F - The type of the function. +* @param func - The function to cap arguments for. +* @param n - The arity cap. +* @param guard - The value to guard the arity cap. +* @returns Returns the new capped function. +* +* @example +* function fn(a: number, b: number, c: number) { +* return Array.from(arguments); +* } +* +* ary(fn, 0)(1, 2, 3); // [] +* ary(fn, 1)(1, 2, 3); // [1] +* ary(fn, 2)(1, 2, 3); // [1, 2] +* ary(fn, 3)(1, 2, 3); // [1, 2, 3] +*/ +function ary(func, n = func.length, guard) { + if (guard) n = func.length; + if (Number.isNaN(n) || n < 0) n = 0; + return ary$1(func, n); +} +//#endregion +export { ary }; diff --git a/node_modules/es-toolkit/dist/compat/function/attempt.d.mts b/node_modules/es-toolkit/dist/compat/function/attempt.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..5556306e671fc9e5711d88b2b265fafadb753dfe --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/attempt.d.mts @@ -0,0 +1,34 @@ +//#region src/compat/function/attempt.d.ts +/** + * Attempts to execute a function with the provided arguments. + * If the function throws an error, it catches the error and returns it. + * If the caught error is not an instance of Error, it wraps it in a new Error. + * + * @param func - The function to be executed. + * @param args - The arguments to pass to the function. + * @returns The return value of the function if successful, or an Error if an exception is thrown. + * + * @template R - The type of the function return value. + * + * @example + * // Example 1: Successful execution + * const result = attempt((x, y) => x + y, 2, 3); + * console.log(result); // Output: 5 + * + * @example + * // Example 2: Function throws an error + * const errorResult = attempt(() => { + * throw new Error("Something went wrong"); + * }); + * console.log(errorResult); // Output: Error: Something went wrong + * + * @example + * // Example 3: Non-Error thrown + * const nonErrorResult = attempt(() => { + * throw "This is a string error"; + * }); + * console.log(nonErrorResult); // Output: Error: This is a string error + */ +declare function attempt(func: (...args: any[]) => R, ...args: any[]): R | Error; +//#endregion +export { attempt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/attempt.d.ts b/node_modules/es-toolkit/dist/compat/function/attempt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5556306e671fc9e5711d88b2b265fafadb753dfe --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/attempt.d.ts @@ -0,0 +1,34 @@ +//#region src/compat/function/attempt.d.ts +/** + * Attempts to execute a function with the provided arguments. + * If the function throws an error, it catches the error and returns it. + * If the caught error is not an instance of Error, it wraps it in a new Error. + * + * @param func - The function to be executed. + * @param args - The arguments to pass to the function. + * @returns The return value of the function if successful, or an Error if an exception is thrown. + * + * @template R - The type of the function return value. + * + * @example + * // Example 1: Successful execution + * const result = attempt((x, y) => x + y, 2, 3); + * console.log(result); // Output: 5 + * + * @example + * // Example 2: Function throws an error + * const errorResult = attempt(() => { + * throw new Error("Something went wrong"); + * }); + * console.log(errorResult); // Output: Error: Something went wrong + * + * @example + * // Example 3: Non-Error thrown + * const nonErrorResult = attempt(() => { + * throw "This is a string error"; + * }); + * console.log(nonErrorResult); // Output: Error: This is a string error + */ +declare function attempt(func: (...args: any[]) => R, ...args: any[]): R | Error; +//#endregion +export { attempt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/attempt.js b/node_modules/es-toolkit/dist/compat/function/attempt.js new file mode 100644 index 0000000000000000000000000000000000000000..eae98581d5564a2a1dd84c16b68dd66f61012bde --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/attempt.js @@ -0,0 +1,40 @@ +//#region src/compat/function/attempt.ts +/** +* Attempts to execute a function with the provided arguments. +* If the function throws an error, it catches the error and returns it. +* If the caught error is not an instance of Error, it wraps it in a new Error. +* +* @param func - The function to be executed. +* @param args - The arguments to pass to the function. +* @returns The return value of the function if successful, or an Error if an exception is thrown. +* +* @template R - The type of the function return value. +* +* @example +* // Example 1: Successful execution +* const result = attempt((x, y) => x + y, 2, 3); +* console.log(result); // Output: 5 +* +* @example +* // Example 2: Function throws an error +* const errorResult = attempt(() => { +* throw new Error("Something went wrong"); +* }); +* console.log(errorResult); // Output: Error: Something went wrong +* +* @example +* // Example 3: Non-Error thrown +* const nonErrorResult = attempt(() => { +* throw "This is a string error"; +* }); +* console.log(nonErrorResult); // Output: Error: This is a string error +*/ +function attempt(func, ...args) { + try { + return func(...args); + } catch (e) { + return e instanceof Error ? e : new Error(e); + } +} +//#endregion +exports.attempt = attempt; diff --git a/node_modules/es-toolkit/dist/compat/function/attempt.mjs b/node_modules/es-toolkit/dist/compat/function/attempt.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bc5e57c6725cc86c1469a3e79a4a89bf5480b428 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/attempt.mjs @@ -0,0 +1,40 @@ +//#region src/compat/function/attempt.ts +/** +* Attempts to execute a function with the provided arguments. +* If the function throws an error, it catches the error and returns it. +* If the caught error is not an instance of Error, it wraps it in a new Error. +* +* @param func - The function to be executed. +* @param args - The arguments to pass to the function. +* @returns The return value of the function if successful, or an Error if an exception is thrown. +* +* @template R - The type of the function return value. +* +* @example +* // Example 1: Successful execution +* const result = attempt((x, y) => x + y, 2, 3); +* console.log(result); // Output: 5 +* +* @example +* // Example 2: Function throws an error +* const errorResult = attempt(() => { +* throw new Error("Something went wrong"); +* }); +* console.log(errorResult); // Output: Error: Something went wrong +* +* @example +* // Example 3: Non-Error thrown +* const nonErrorResult = attempt(() => { +* throw "This is a string error"; +* }); +* console.log(nonErrorResult); // Output: Error: This is a string error +*/ +function attempt(func, ...args) { + try { + return func(...args); + } catch (e) { + return e instanceof Error ? e : new Error(e); + } +} +//#endregion +export { attempt }; diff --git a/node_modules/es-toolkit/dist/compat/function/before.d.mts b/node_modules/es-toolkit/dist/compat/function/before.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..67fa4ce1d851cbcb9238694ae48593259e3d146f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/before.d.mts @@ -0,0 +1,27 @@ +//#region src/compat/function/before.d.ts +/** + * Creates a function that invokes `func`, with the `this` binding and arguments + * of the created function, while it's called less than `n` times. Subsequent + * calls to the created function return the result of the last `func` invocation. + * + * @template F - The type of the function to be invoked. + * @param n - The number of times the returned function is allowed to call `func` before stopping. + * - If `n` is 0, `func` will never be called. + * - If `n` is a positive integer, `func` will be called up to `n-1` times. + * @param func - The function to be called with the limit applied. + * @returns A new function that: + * - Tracks the number of calls. + * - Invokes `func` until the `n-1`-th call. + * - Returns last result of `func`, if `n` is reached. + * @throws {TypeError} - If `func` is not a function. + * @example + * let count = 0; + * const before3 = before(3, () => ++count); + * + * before3(); // => 1 + * before3(); // => 2 + * before3(); // => 2 + */ +declare function before any>(n: number, func: F): F; +//#endregion +export { before }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/before.d.ts b/node_modules/es-toolkit/dist/compat/function/before.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..67fa4ce1d851cbcb9238694ae48593259e3d146f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/before.d.ts @@ -0,0 +1,27 @@ +//#region src/compat/function/before.d.ts +/** + * Creates a function that invokes `func`, with the `this` binding and arguments + * of the created function, while it's called less than `n` times. Subsequent + * calls to the created function return the result of the last `func` invocation. + * + * @template F - The type of the function to be invoked. + * @param n - The number of times the returned function is allowed to call `func` before stopping. + * - If `n` is 0, `func` will never be called. + * - If `n` is a positive integer, `func` will be called up to `n-1` times. + * @param func - The function to be called with the limit applied. + * @returns A new function that: + * - Tracks the number of calls. + * - Invokes `func` until the `n-1`-th call. + * - Returns last result of `func`, if `n` is reached. + * @throws {TypeError} - If `func` is not a function. + * @example + * let count = 0; + * const before3 = before(3, () => ++count); + * + * before3(); // => 1 + * before3(); // => 2 + * before3(); // => 2 + */ +declare function before any>(n: number, func: F): F; +//#endregion +export { before }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/before.js b/node_modules/es-toolkit/dist/compat/function/before.js new file mode 100644 index 0000000000000000000000000000000000000000..26810cffb09823cd344fe870b62b62d344d234fc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/before.js @@ -0,0 +1,37 @@ +const require_toInteger = require("../util/toInteger.js"); +//#region src/compat/function/before.ts +/** +* Creates a function that invokes `func`, with the `this` binding and arguments +* of the created function, while it's called less than `n` times. Subsequent +* calls to the created function return the result of the last `func` invocation. +* +* @template F - The type of the function to be invoked. +* @param n - The number of times the returned function is allowed to call `func` before stopping. +* - If `n` is 0, `func` will never be called. +* - If `n` is a positive integer, `func` will be called up to `n-1` times. +* @param func - The function to be called with the limit applied. +* @returns A new function that: +* - Tracks the number of calls. +* - Invokes `func` until the `n-1`-th call. +* - Returns last result of `func`, if `n` is reached. +* @throws {TypeError} - If `func` is not a function. +* @example +* let count = 0; +* const before3 = before(3, () => ++count); +* +* before3(); // => 1 +* before3(); // => 2 +* before3(); // => 2 +*/ +function before(n, func) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + let result; + n = require_toInteger.toInteger(n); + return function(...args) { + if (--n > 0) result = func.apply(this, args); + if (n <= 1 && func) func = void 0; + return result; + }; +} +//#endregion +exports.before = before; diff --git a/node_modules/es-toolkit/dist/compat/function/before.mjs b/node_modules/es-toolkit/dist/compat/function/before.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0afd8d88d880dfe65b54a3fc4fa5ec73ead4a9a2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/before.mjs @@ -0,0 +1,37 @@ +import { toInteger } from "../util/toInteger.mjs"; +//#region src/compat/function/before.ts +/** +* Creates a function that invokes `func`, with the `this` binding and arguments +* of the created function, while it's called less than `n` times. Subsequent +* calls to the created function return the result of the last `func` invocation. +* +* @template F - The type of the function to be invoked. +* @param n - The number of times the returned function is allowed to call `func` before stopping. +* - If `n` is 0, `func` will never be called. +* - If `n` is a positive integer, `func` will be called up to `n-1` times. +* @param func - The function to be called with the limit applied. +* @returns A new function that: +* - Tracks the number of calls. +* - Invokes `func` until the `n-1`-th call. +* - Returns last result of `func`, if `n` is reached. +* @throws {TypeError} - If `func` is not a function. +* @example +* let count = 0; +* const before3 = before(3, () => ++count); +* +* before3(); // => 1 +* before3(); // => 2 +* before3(); // => 2 +*/ +function before(n, func) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + let result; + n = toInteger(n); + return function(...args) { + if (--n > 0) result = func.apply(this, args); + if (n <= 1 && func) func = void 0; + return result; + }; +} +//#endregion +export { before }; diff --git a/node_modules/es-toolkit/dist/compat/function/bind.d.mts b/node_modules/es-toolkit/dist/compat/function/bind.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fd264bbadaa2542f26ba4875dbf0efbb2add6a36 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/bind.d.mts @@ -0,0 +1,33 @@ +//#region src/compat/function/bind.d.ts +/** + * Creates a function that invokes `func` with the `this` binding of `thisArg` and `partials` prepended to the arguments it receives. + * + * The `bind.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. + * + * Note: Unlike native `Function#bind`, this method doesn't set the `length` property of bound functions. + * + * @param func - The function to bind. + * @param thisObj - The `this` binding of `func`. + * @param partialArgs - The arguments to be partially applied. + * @returns Returns the new bound function. + * + * @example + * function greet(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * const object = { user: 'fred' }; + * let bound = bind(greet, object, 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * bound = bind(greet, object, bind.placeholder, '!'); + * bound('hi'); + * // => 'hi fred!' + */ +declare function bind(func: (...args: any[]) => any, thisObj: any, ...partialArgs: any[]): (...args: any[]) => any; +declare namespace bind { + var placeholder: typeof bindPlaceholder; +} +declare const bindPlaceholder: unique symbol; +//#endregion +export { bind }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/bind.d.ts b/node_modules/es-toolkit/dist/compat/function/bind.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd264bbadaa2542f26ba4875dbf0efbb2add6a36 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/bind.d.ts @@ -0,0 +1,33 @@ +//#region src/compat/function/bind.d.ts +/** + * Creates a function that invokes `func` with the `this` binding of `thisArg` and `partials` prepended to the arguments it receives. + * + * The `bind.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. + * + * Note: Unlike native `Function#bind`, this method doesn't set the `length` property of bound functions. + * + * @param func - The function to bind. + * @param thisObj - The `this` binding of `func`. + * @param partialArgs - The arguments to be partially applied. + * @returns Returns the new bound function. + * + * @example + * function greet(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * const object = { user: 'fred' }; + * let bound = bind(greet, object, 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * bound = bind(greet, object, bind.placeholder, '!'); + * bound('hi'); + * // => 'hi fred!' + */ +declare function bind(func: (...args: any[]) => any, thisObj: any, ...partialArgs: any[]): (...args: any[]) => any; +declare namespace bind { + var placeholder: typeof bindPlaceholder; +} +declare const bindPlaceholder: unique symbol; +//#endregion +export { bind }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/bind.js b/node_modules/es-toolkit/dist/compat/function/bind.js new file mode 100644 index 0000000000000000000000000000000000000000..1a6809fa63ab5ca043323fe09a9dbc4adf180336 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/bind.js @@ -0,0 +1,44 @@ +//#region src/compat/function/bind.ts +/** +* Creates a function that invokes `func` with the `this` binding of `thisArg` and `partials` prepended to the arguments it receives. +* +* The `bind.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: Unlike native `Function#bind`, this method doesn't set the `length` property of bound functions. +* +* @param func - The function to bind. +* @param thisObj - The `this` binding of `func`. +* @param partialArgs - The arguments to be partially applied. +* @returns Returns the new bound function. +* +* @example +* function greet(greeting, punctuation) { +* return greeting + ' ' + this.user + punctuation; +* } +* const object = { user: 'fred' }; +* let bound = bind(greet, object, 'hi'); +* bound('!'); +* // => 'hi fred!' +* +* bound = bind(greet, object, bind.placeholder, '!'); +* bound('hi'); +* // => 'hi fred!' +*/ +function bind(func, thisObj, ...partialArgs) { + const bound = function(...providedArgs) { + const args = []; + let startIndex = 0; + for (let i = 0; i < partialArgs.length; i++) { + const arg = partialArgs[i]; + if (arg === bind.placeholder) args.push(providedArgs[startIndex++]); + else args.push(arg); + } + for (let i = startIndex; i < providedArgs.length; i++) args.push(providedArgs[i]); + if (this instanceof bound) return new func(...args); + return func.apply(thisObj, args); + }; + return bound; +} +bind.placeholder = Symbol("bind.placeholder"); +//#endregion +exports.bind = bind; diff --git a/node_modules/es-toolkit/dist/compat/function/bind.mjs b/node_modules/es-toolkit/dist/compat/function/bind.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f7f834a9be0c159edbdbf0689e6e135fcd91a4aa --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/bind.mjs @@ -0,0 +1,44 @@ +//#region src/compat/function/bind.ts +/** +* Creates a function that invokes `func` with the `this` binding of `thisArg` and `partials` prepended to the arguments it receives. +* +* The `bind.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: Unlike native `Function#bind`, this method doesn't set the `length` property of bound functions. +* +* @param func - The function to bind. +* @param thisObj - The `this` binding of `func`. +* @param partialArgs - The arguments to be partially applied. +* @returns Returns the new bound function. +* +* @example +* function greet(greeting, punctuation) { +* return greeting + ' ' + this.user + punctuation; +* } +* const object = { user: 'fred' }; +* let bound = bind(greet, object, 'hi'); +* bound('!'); +* // => 'hi fred!' +* +* bound = bind(greet, object, bind.placeholder, '!'); +* bound('hi'); +* // => 'hi fred!' +*/ +function bind(func, thisObj, ...partialArgs) { + const bound = function(...providedArgs) { + const args = []; + let startIndex = 0; + for (let i = 0; i < partialArgs.length; i++) { + const arg = partialArgs[i]; + if (arg === bind.placeholder) args.push(providedArgs[startIndex++]); + else args.push(arg); + } + for (let i = startIndex; i < providedArgs.length; i++) args.push(providedArgs[i]); + if (this instanceof bound) return new func(...args); + return func.apply(thisObj, args); + }; + return bound; +} +bind.placeholder = Symbol("bind.placeholder"); +//#endregion +export { bind }; diff --git a/node_modules/es-toolkit/dist/compat/function/bindKey.d.mts b/node_modules/es-toolkit/dist/compat/function/bindKey.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..001da08debc063adf4ada2243a32c373858565c9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/bindKey.d.mts @@ -0,0 +1,46 @@ +//#region src/compat/function/bindKey.d.ts +/** + * Creates a function that invokes the method at `object[key]` with `partialArgs` prepended to the arguments it receives. + * + * This method differs from `bind` by allowing bound functions to reference methods that may be redefined or don't yet exist. + * + * The `bindKey.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. + * + * @template T - The type of the object to bind. + * @template K - The type of the key to bind. + * @param object - The object to invoke the method on. + * @param key - The key of the method. + * @param partialArgs - The arguments to be partially applied. + * @returns Returns the new bound function. + * + * @example + * const object = { + * user: 'fred', + * greet: function (greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * }, + * }; + * + * let bound = bindKey(object, 'greet', 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * object.greet = function (greeting, punctuation) { + * return greeting + 'ya ' + this.user + punctuation; + * }; + * + * bound('!'); + * // => 'hiya fred!' + * + * // Bound with placeholders. + * bound = bindKey(object, 'greet', bindKey.placeholder, '!'); + * bound('hi'); + * // => 'hiya fred!' + */ +declare function bindKey(object: object, key: string, ...partialArgs: any[]): (...args: any[]) => any; +declare namespace bindKey { + var placeholder: typeof bindKeyPlaceholder; +} +declare const bindKeyPlaceholder: unique symbol; +//#endregion +export { bindKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/bindKey.d.ts b/node_modules/es-toolkit/dist/compat/function/bindKey.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..001da08debc063adf4ada2243a32c373858565c9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/bindKey.d.ts @@ -0,0 +1,46 @@ +//#region src/compat/function/bindKey.d.ts +/** + * Creates a function that invokes the method at `object[key]` with `partialArgs` prepended to the arguments it receives. + * + * This method differs from `bind` by allowing bound functions to reference methods that may be redefined or don't yet exist. + * + * The `bindKey.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. + * + * @template T - The type of the object to bind. + * @template K - The type of the key to bind. + * @param object - The object to invoke the method on. + * @param key - The key of the method. + * @param partialArgs - The arguments to be partially applied. + * @returns Returns the new bound function. + * + * @example + * const object = { + * user: 'fred', + * greet: function (greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * }, + * }; + * + * let bound = bindKey(object, 'greet', 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * object.greet = function (greeting, punctuation) { + * return greeting + 'ya ' + this.user + punctuation; + * }; + * + * bound('!'); + * // => 'hiya fred!' + * + * // Bound with placeholders. + * bound = bindKey(object, 'greet', bindKey.placeholder, '!'); + * bound('hi'); + * // => 'hiya fred!' + */ +declare function bindKey(object: object, key: string, ...partialArgs: any[]): (...args: any[]) => any; +declare namespace bindKey { + var placeholder: typeof bindKeyPlaceholder; +} +declare const bindKeyPlaceholder: unique symbol; +//#endregion +export { bindKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/bindKey.js b/node_modules/es-toolkit/dist/compat/function/bindKey.js new file mode 100644 index 0000000000000000000000000000000000000000..a75737362110df3a2a1bf17d957540be1dbf177b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/bindKey.js @@ -0,0 +1,57 @@ +//#region src/compat/function/bindKey.ts +/** +* Creates a function that invokes the method at `object[key]` with `partialArgs` prepended to the arguments it receives. +* +* This method differs from `bind` by allowing bound functions to reference methods that may be redefined or don't yet exist. +* +* The `bindKey.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* @template T - The type of the object to bind. +* @template K - The type of the key to bind. +* @param object - The object to invoke the method on. +* @param key - The key of the method. +* @param partialArgs - The arguments to be partially applied. +* @returns Returns the new bound function. +* +* @example +* const object = { +* user: 'fred', +* greet: function (greeting, punctuation) { +* return greeting + ' ' + this.user + punctuation; +* }, +* }; +* +* let bound = bindKey(object, 'greet', 'hi'); +* bound('!'); +* // => 'hi fred!' +* +* object.greet = function (greeting, punctuation) { +* return greeting + 'ya ' + this.user + punctuation; +* }; +* +* bound('!'); +* // => 'hiya fred!' +* +* // Bound with placeholders. +* bound = bindKey(object, 'greet', bindKey.placeholder, '!'); +* bound('hi'); +* // => 'hiya fred!' +*/ +function bindKey(object, key, ...partialArgs) { + const bound = function(...providedArgs) { + const args = []; + let startIndex = 0; + for (let i = 0; i < partialArgs.length; i++) { + const arg = partialArgs[i]; + if (arg === bindKey.placeholder) args.push(providedArgs[startIndex++]); + else args.push(arg); + } + for (let i = startIndex; i < providedArgs.length; i++) args.push(providedArgs[i]); + if (this instanceof bound) return new object[key](...args); + return object[key].apply(object, args); + }; + return bound; +} +bindKey.placeholder = Symbol("bindKey.placeholder"); +//#endregion +exports.bindKey = bindKey; diff --git a/node_modules/es-toolkit/dist/compat/function/bindKey.mjs b/node_modules/es-toolkit/dist/compat/function/bindKey.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4fe324d0eaedb3637c322ff506149348fe241cbe --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/bindKey.mjs @@ -0,0 +1,57 @@ +//#region src/compat/function/bindKey.ts +/** +* Creates a function that invokes the method at `object[key]` with `partialArgs` prepended to the arguments it receives. +* +* This method differs from `bind` by allowing bound functions to reference methods that may be redefined or don't yet exist. +* +* The `bindKey.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* @template T - The type of the object to bind. +* @template K - The type of the key to bind. +* @param object - The object to invoke the method on. +* @param key - The key of the method. +* @param partialArgs - The arguments to be partially applied. +* @returns Returns the new bound function. +* +* @example +* const object = { +* user: 'fred', +* greet: function (greeting, punctuation) { +* return greeting + ' ' + this.user + punctuation; +* }, +* }; +* +* let bound = bindKey(object, 'greet', 'hi'); +* bound('!'); +* // => 'hi fred!' +* +* object.greet = function (greeting, punctuation) { +* return greeting + 'ya ' + this.user + punctuation; +* }; +* +* bound('!'); +* // => 'hiya fred!' +* +* // Bound with placeholders. +* bound = bindKey(object, 'greet', bindKey.placeholder, '!'); +* bound('hi'); +* // => 'hiya fred!' +*/ +function bindKey(object, key, ...partialArgs) { + const bound = function(...providedArgs) { + const args = []; + let startIndex = 0; + for (let i = 0; i < partialArgs.length; i++) { + const arg = partialArgs[i]; + if (arg === bindKey.placeholder) args.push(providedArgs[startIndex++]); + else args.push(arg); + } + for (let i = startIndex; i < providedArgs.length; i++) args.push(providedArgs[i]); + if (this instanceof bound) return new object[key](...args); + return object[key].apply(object, args); + }; + return bound; +} +bindKey.placeholder = Symbol("bindKey.placeholder"); +//#endregion +export { bindKey }; diff --git a/node_modules/es-toolkit/dist/compat/function/curry.d.mts b/node_modules/es-toolkit/dist/compat/function/curry.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d8ec8fe7fb8f970a1d79c7510dfc0a7cc00639b2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/curry.d.mts @@ -0,0 +1,155 @@ +//#region src/compat/function/curry.d.ts +type __ = typeof curryPlaceholder; +interface CurriedFunction1 { + (): CurriedFunction1; + (t1: T1): R; +} +interface CurriedFunction2 { + (): CurriedFunction2; + (t1: T1): CurriedFunction1; + (t1: __, t2: T2): CurriedFunction1; + (t1: T1, t2: T2): R; +} +interface CurriedFunction3 { + (): CurriedFunction3; + (t1: T1): CurriedFunction2; + (t1: __, t2: T2): CurriedFunction2; + (t1: T1, t2: T2): CurriedFunction1; + (t1: __, t2: __, t3: T3): CurriedFunction2; + (t1: T1, t2: __, t3: T3): CurriedFunction1; + (t1: __, t2: T2, t3: T3): CurriedFunction1; + (t1: T1, t2: T2, t3: T3): R; +} +interface CurriedFunction4 { + (): CurriedFunction4; + (t1: T1): CurriedFunction3; + (t1: __, t2: T2): CurriedFunction3; + (t1: T1, t2: T2): CurriedFunction2; + (t1: __, t2: __, t3: T3): CurriedFunction3; + (t1: __, t2: __, t3: T3): CurriedFunction2; + (t1: __, t2: T2, t3: T3): CurriedFunction2; + (t1: T1, t2: T2, t3: T3): CurriedFunction1; + (t1: __, t2: __, t3: __, t4: T4): CurriedFunction3; + (t1: T1, t2: __, t3: __, t4: T4): CurriedFunction2; + (t1: __, t2: T2, t3: __, t4: T4): CurriedFunction2; + (t1: __, t2: __, t3: T3, t4: T4): CurriedFunction2; + (t1: T1, t2: T2, t3: __, t4: T4): CurriedFunction1; + (t1: T1, t2: __, t3: T3, t4: T4): CurriedFunction1; + (t1: __, t2: T2, t3: T3, t4: T4): CurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4): R; +} +interface CurriedFunction5 { + (): CurriedFunction5; + (t1: T1): CurriedFunction4; + (t1: __, t2: T2): CurriedFunction4; + (t1: T1, t2: T2): CurriedFunction3; + (t1: __, t2: __, t3: T3): CurriedFunction4; + (t1: T1, t2: __, t3: T3): CurriedFunction3; + (t1: __, t2: T2, t3: T3): CurriedFunction3; + (t1: T1, t2: T2, t3: T3): CurriedFunction2; + (t1: __, t2: __, t3: __, t4: T4): CurriedFunction4; + (t1: T1, t2: __, t3: __, t4: T4): CurriedFunction3; + (t1: __, t2: T2, t3: __, t4: T4): CurriedFunction3; + (t1: __, t2: __, t3: T3, t4: T4): CurriedFunction3; + (t1: T1, t2: T2, t3: __, t4: T4): CurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: T4): CurriedFunction2; + (t1: __, t2: T2, t3: T3, t4: T4): CurriedFunction2; + (t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction1; + (t1: __, t2: __, t3: __, t4: __, t5: T5): CurriedFunction4; + (t1: T1, t2: __, t3: __, t4: __, t5: T5): CurriedFunction3; + (t1: __, t2: T2, t3: __, t4: __, t5: T5): CurriedFunction3; + (t1: __, t2: __, t3: T3, t4: __, t5: T5): CurriedFunction3; + (t1: __, t2: __, t3: __, t4: T4, t5: T5): CurriedFunction3; + (t1: T1, t2: T2, t3: __, t4: __, t5: T5): CurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: __, t5: T5): CurriedFunction2; + (t1: T1, t2: __, t3: __, t4: T4, t5: T5): CurriedFunction2; + (t1: __, t2: T2, t3: T3, t4: __, t5: T5): CurriedFunction2; + (t1: __, t2: T2, t3: __, t4: T4, t5: T5): CurriedFunction2; + (t1: __, t2: __, t3: T3, t4: T4, t5: T5): CurriedFunction2; + (t1: T1, t2: T2, t3: T3, t4: __, t5: T5): CurriedFunction1; + (t1: T1, t2: T2, t3: __, t4: T4, t5: T5): CurriedFunction1; + (t1: T1, t2: __, t3: T3, t4: T4, t5: T5): CurriedFunction1; + (t1: __, t2: T2, t3: T3, t4: T4, t5: T5): CurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R; +} +/** + * Creates a curried function that accepts a single argument. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const greet = (name: string) => `Hello ${name}`; + * const curriedGreet = curry(greet); + * curriedGreet('John'); // => 'Hello John' + */ +declare function curry(func: (t1: T1) => R, arity?: number): CurriedFunction1; +/** + * Creates a curried function that accepts two arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const add = (a: number, b: number) => a + b; + * const curriedAdd = curry(add); + * curriedAdd(1)(2); // => 3 + * curriedAdd(1, 2); // => 3 + */ +declare function curry(func: (t1: T1, t2: T2) => R, arity?: number): CurriedFunction2; +/** + * Creates a curried function that accepts three arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const volume = (l: number, w: number, h: number) => l * w * h; + * const curriedVolume = curry(volume); + * curriedVolume(2)(3)(4); // => 24 + * curriedVolume(2, 3)(4); // => 24 + * curriedVolume(2, 3, 4); // => 24 + */ +declare function curry(func: (t1: T1, t2: T2, t3: T3) => R, arity?: number): CurriedFunction3; +/** + * Creates a curried function that accepts four arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const fn = (a: number, b: number, c: number, d: number) => a + b + c + d; + * const curriedFn = curry(fn); + * curriedFn(1)(2)(3)(4); // => 10 + * curriedFn(1, 2)(3, 4); // => 10 + * curriedFn(1, 2, 3, 4); // => 10 + */ +declare function curry(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arity?: number): CurriedFunction4; +/** + * Creates a curried function that accepts five arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const fn = (a: number, b: number, c: number, d: number, e: number) => a + b + c + d + e; + * const curriedFn = curry(fn); + * curriedFn(1)(2)(3)(4)(5); // => 15 + * curriedFn(1, 2)(3, 4)(5); // => 15 + * curriedFn(1, 2, 3, 4, 5); // => 15 + */ +declare function curry(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R, arity?: number): CurriedFunction5; +/** + * Creates a curried function that accepts any number of arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const sum = (...args: number[]) => args.reduce((a, b) => a + b, 0); + * const curriedSum = curry(sum); + * curriedSum(1, 2, 3); // => 6 + * curriedSum(1)(2, 3); // => 6 + * curriedSum(1)(2)(3); // => 6 + */ +declare function curry(func: (...args: any[]) => any, arity?: number): (...args: any[]) => any; +declare namespace curry { + var placeholder: typeof curryPlaceholder; +} +declare const curryPlaceholder: unique symbol; +//#endregion +export { curry }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/curry.d.ts b/node_modules/es-toolkit/dist/compat/function/curry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8ec8fe7fb8f970a1d79c7510dfc0a7cc00639b2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/curry.d.ts @@ -0,0 +1,155 @@ +//#region src/compat/function/curry.d.ts +type __ = typeof curryPlaceholder; +interface CurriedFunction1 { + (): CurriedFunction1; + (t1: T1): R; +} +interface CurriedFunction2 { + (): CurriedFunction2; + (t1: T1): CurriedFunction1; + (t1: __, t2: T2): CurriedFunction1; + (t1: T1, t2: T2): R; +} +interface CurriedFunction3 { + (): CurriedFunction3; + (t1: T1): CurriedFunction2; + (t1: __, t2: T2): CurriedFunction2; + (t1: T1, t2: T2): CurriedFunction1; + (t1: __, t2: __, t3: T3): CurriedFunction2; + (t1: T1, t2: __, t3: T3): CurriedFunction1; + (t1: __, t2: T2, t3: T3): CurriedFunction1; + (t1: T1, t2: T2, t3: T3): R; +} +interface CurriedFunction4 { + (): CurriedFunction4; + (t1: T1): CurriedFunction3; + (t1: __, t2: T2): CurriedFunction3; + (t1: T1, t2: T2): CurriedFunction2; + (t1: __, t2: __, t3: T3): CurriedFunction3; + (t1: __, t2: __, t3: T3): CurriedFunction2; + (t1: __, t2: T2, t3: T3): CurriedFunction2; + (t1: T1, t2: T2, t3: T3): CurriedFunction1; + (t1: __, t2: __, t3: __, t4: T4): CurriedFunction3; + (t1: T1, t2: __, t3: __, t4: T4): CurriedFunction2; + (t1: __, t2: T2, t3: __, t4: T4): CurriedFunction2; + (t1: __, t2: __, t3: T3, t4: T4): CurriedFunction2; + (t1: T1, t2: T2, t3: __, t4: T4): CurriedFunction1; + (t1: T1, t2: __, t3: T3, t4: T4): CurriedFunction1; + (t1: __, t2: T2, t3: T3, t4: T4): CurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4): R; +} +interface CurriedFunction5 { + (): CurriedFunction5; + (t1: T1): CurriedFunction4; + (t1: __, t2: T2): CurriedFunction4; + (t1: T1, t2: T2): CurriedFunction3; + (t1: __, t2: __, t3: T3): CurriedFunction4; + (t1: T1, t2: __, t3: T3): CurriedFunction3; + (t1: __, t2: T2, t3: T3): CurriedFunction3; + (t1: T1, t2: T2, t3: T3): CurriedFunction2; + (t1: __, t2: __, t3: __, t4: T4): CurriedFunction4; + (t1: T1, t2: __, t3: __, t4: T4): CurriedFunction3; + (t1: __, t2: T2, t3: __, t4: T4): CurriedFunction3; + (t1: __, t2: __, t3: T3, t4: T4): CurriedFunction3; + (t1: T1, t2: T2, t3: __, t4: T4): CurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: T4): CurriedFunction2; + (t1: __, t2: T2, t3: T3, t4: T4): CurriedFunction2; + (t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction1; + (t1: __, t2: __, t3: __, t4: __, t5: T5): CurriedFunction4; + (t1: T1, t2: __, t3: __, t4: __, t5: T5): CurriedFunction3; + (t1: __, t2: T2, t3: __, t4: __, t5: T5): CurriedFunction3; + (t1: __, t2: __, t3: T3, t4: __, t5: T5): CurriedFunction3; + (t1: __, t2: __, t3: __, t4: T4, t5: T5): CurriedFunction3; + (t1: T1, t2: T2, t3: __, t4: __, t5: T5): CurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: __, t5: T5): CurriedFunction2; + (t1: T1, t2: __, t3: __, t4: T4, t5: T5): CurriedFunction2; + (t1: __, t2: T2, t3: T3, t4: __, t5: T5): CurriedFunction2; + (t1: __, t2: T2, t3: __, t4: T4, t5: T5): CurriedFunction2; + (t1: __, t2: __, t3: T3, t4: T4, t5: T5): CurriedFunction2; + (t1: T1, t2: T2, t3: T3, t4: __, t5: T5): CurriedFunction1; + (t1: T1, t2: T2, t3: __, t4: T4, t5: T5): CurriedFunction1; + (t1: T1, t2: __, t3: T3, t4: T4, t5: T5): CurriedFunction1; + (t1: __, t2: T2, t3: T3, t4: T4, t5: T5): CurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R; +} +/** + * Creates a curried function that accepts a single argument. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const greet = (name: string) => `Hello ${name}`; + * const curriedGreet = curry(greet); + * curriedGreet('John'); // => 'Hello John' + */ +declare function curry(func: (t1: T1) => R, arity?: number): CurriedFunction1; +/** + * Creates a curried function that accepts two arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const add = (a: number, b: number) => a + b; + * const curriedAdd = curry(add); + * curriedAdd(1)(2); // => 3 + * curriedAdd(1, 2); // => 3 + */ +declare function curry(func: (t1: T1, t2: T2) => R, arity?: number): CurriedFunction2; +/** + * Creates a curried function that accepts three arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const volume = (l: number, w: number, h: number) => l * w * h; + * const curriedVolume = curry(volume); + * curriedVolume(2)(3)(4); // => 24 + * curriedVolume(2, 3)(4); // => 24 + * curriedVolume(2, 3, 4); // => 24 + */ +declare function curry(func: (t1: T1, t2: T2, t3: T3) => R, arity?: number): CurriedFunction3; +/** + * Creates a curried function that accepts four arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const fn = (a: number, b: number, c: number, d: number) => a + b + c + d; + * const curriedFn = curry(fn); + * curriedFn(1)(2)(3)(4); // => 10 + * curriedFn(1, 2)(3, 4); // => 10 + * curriedFn(1, 2, 3, 4); // => 10 + */ +declare function curry(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arity?: number): CurriedFunction4; +/** + * Creates a curried function that accepts five arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const fn = (a: number, b: number, c: number, d: number, e: number) => a + b + c + d + e; + * const curriedFn = curry(fn); + * curriedFn(1)(2)(3)(4)(5); // => 15 + * curriedFn(1, 2)(3, 4)(5); // => 15 + * curriedFn(1, 2, 3, 4, 5); // => 15 + */ +declare function curry(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R, arity?: number): CurriedFunction5; +/** + * Creates a curried function that accepts any number of arguments. + * @param func - The function to curry. + * @param arity - The arity of func. + * @returns Returns the new curried function. + * @example + * const sum = (...args: number[]) => args.reduce((a, b) => a + b, 0); + * const curriedSum = curry(sum); + * curriedSum(1, 2, 3); // => 6 + * curriedSum(1)(2, 3); // => 6 + * curriedSum(1)(2)(3); // => 6 + */ +declare function curry(func: (...args: any[]) => any, arity?: number): (...args: any[]) => any; +declare namespace curry { + var placeholder: typeof curryPlaceholder; +} +declare const curryPlaceholder: unique symbol; +//#endregion +export { curry }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/curry.js b/node_modules/es-toolkit/dist/compat/function/curry.js new file mode 100644 index 0000000000000000000000000000000000000000..6f4f69d96159ec597778f29bfea1809eada55b3b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/curry.js @@ -0,0 +1,81 @@ +//#region src/compat/function/curry.ts +/** +* 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. +* The arity of `func` may be specified if `func.length` is not sufficient. +* +* The `curry.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: This method doesn't set the `length` property of curried functions. +* +* @param func - The function to curry. +* @param arity - The arity of func. +* @param guard - Enables use as an iteratee for methods like `Array#map`. +* @returns} - Returns the new curried function. +* +* @example +* const abc = function(a, b, c) { +* return Array.from(arguments); +* }; +* +* let curried = curry(abc); +* +* curried(1)(2)(3); +* // => [1, 2, 3] +* +* curried(1, 2)(3); +* // => [1, 2, 3] +* +* curried(1, 2, 3); +* // => [1, 2, 3] +* +* // Curried with placeholders. +* curried(1)(curry.placeholder, 3)(2); +* // => [1, 2, 3] +* +* // Curried with arity. +* curried = curry(abc, 2); +* +* curried(1)(2); +* // => [1, 2] +*/ +function curry(func, arity = func.length, guard) { + arity = guard ? func.length : arity; + arity = Number.parseInt(arity, 10); + if (Number.isNaN(arity) || arity < 1) arity = 0; + const wrapper = function(...partialArgs) { + const holders = partialArgs.filter((item) => item === curry.placeholder); + const length = partialArgs.length - holders.length; + if (length < arity) return makeCurry(func, arity - length, partialArgs); + if (this instanceof wrapper) return new func(...partialArgs); + return func.apply(this, partialArgs); + }; + wrapper.placeholder = curryPlaceholder; + return wrapper; +} +function makeCurry(func, arity, partialArgs) { + function wrapper(...providedArgs) { + const holders = providedArgs.filter((item) => item === curry.placeholder); + const length = providedArgs.length - holders.length; + providedArgs = composeArgs(providedArgs, partialArgs); + if (length < arity) return makeCurry(func, arity - length, providedArgs); + if (this instanceof wrapper) return new func(...providedArgs); + return func.apply(this, providedArgs); + } + wrapper.placeholder = curryPlaceholder; + return wrapper; +} +function composeArgs(providedArgs, partialArgs) { + const args = []; + let startIndex = 0; + for (let i = 0; i < partialArgs.length; i++) { + const arg = partialArgs[i]; + if (arg === curry.placeholder && startIndex < providedArgs.length) args.push(providedArgs[startIndex++]); + else args.push(arg); + } + for (let i = startIndex; i < providedArgs.length; i++) args.push(providedArgs[i]); + return args; +} +const curryPlaceholder = Symbol("curry.placeholder"); +curry.placeholder = curryPlaceholder; +//#endregion +exports.curry = curry; diff --git a/node_modules/es-toolkit/dist/compat/function/curry.mjs b/node_modules/es-toolkit/dist/compat/function/curry.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bb3f5e1e4969853b3fddf344c288ffe52da43256 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/curry.mjs @@ -0,0 +1,81 @@ +//#region src/compat/function/curry.ts +/** +* 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. +* The arity of `func` may be specified if `func.length` is not sufficient. +* +* The `curry.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: This method doesn't set the `length` property of curried functions. +* +* @param func - The function to curry. +* @param arity - The arity of func. +* @param guard - Enables use as an iteratee for methods like `Array#map`. +* @returns} - Returns the new curried function. +* +* @example +* const abc = function(a, b, c) { +* return Array.from(arguments); +* }; +* +* let curried = curry(abc); +* +* curried(1)(2)(3); +* // => [1, 2, 3] +* +* curried(1, 2)(3); +* // => [1, 2, 3] +* +* curried(1, 2, 3); +* // => [1, 2, 3] +* +* // Curried with placeholders. +* curried(1)(curry.placeholder, 3)(2); +* // => [1, 2, 3] +* +* // Curried with arity. +* curried = curry(abc, 2); +* +* curried(1)(2); +* // => [1, 2] +*/ +function curry(func, arity = func.length, guard) { + arity = guard ? func.length : arity; + arity = Number.parseInt(arity, 10); + if (Number.isNaN(arity) || arity < 1) arity = 0; + const wrapper = function(...partialArgs) { + const holders = partialArgs.filter((item) => item === curry.placeholder); + const length = partialArgs.length - holders.length; + if (length < arity) return makeCurry(func, arity - length, partialArgs); + if (this instanceof wrapper) return new func(...partialArgs); + return func.apply(this, partialArgs); + }; + wrapper.placeholder = curryPlaceholder; + return wrapper; +} +function makeCurry(func, arity, partialArgs) { + function wrapper(...providedArgs) { + const holders = providedArgs.filter((item) => item === curry.placeholder); + const length = providedArgs.length - holders.length; + providedArgs = composeArgs(providedArgs, partialArgs); + if (length < arity) return makeCurry(func, arity - length, providedArgs); + if (this instanceof wrapper) return new func(...providedArgs); + return func.apply(this, providedArgs); + } + wrapper.placeholder = curryPlaceholder; + return wrapper; +} +function composeArgs(providedArgs, partialArgs) { + const args = []; + let startIndex = 0; + for (let i = 0; i < partialArgs.length; i++) { + const arg = partialArgs[i]; + if (arg === curry.placeholder && startIndex < providedArgs.length) args.push(providedArgs[startIndex++]); + else args.push(arg); + } + for (let i = startIndex; i < providedArgs.length; i++) args.push(providedArgs[i]); + return args; +} +const curryPlaceholder = Symbol("curry.placeholder"); +curry.placeholder = curryPlaceholder; +//#endregion +export { curry }; diff --git a/node_modules/es-toolkit/dist/compat/function/curryRight.d.mts b/node_modules/es-toolkit/dist/compat/function/curryRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6a2f4126f9646a639417a8f2c60ca03607bff3f4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/curryRight.d.mts @@ -0,0 +1,86 @@ +//#region src/compat/function/curryRight.d.ts +type __ = typeof curryRightPlaceholder; +interface RightCurriedFunction1 { + (): RightCurriedFunction1; + (t1: T1): R; +} +interface RightCurriedFunction2 { + (): RightCurriedFunction2; + (t2: T2): RightCurriedFunction1; + (t1: T1, t2: __): RightCurriedFunction1; + (t1: T1, t2: T2): R; +} +interface RightCurriedFunction3 { + (): RightCurriedFunction3; + (t3: T3): RightCurriedFunction2; + (t2: T2, t3: __): RightCurriedFunction2; + (t2: T2, t3: T3): RightCurriedFunction1; + (t1: T1, t2: __, t3: __): RightCurriedFunction2; + (t1: T1, t2: T2, t3: __): RightCurriedFunction1; + (t1: T1, t2: __, t3: T3): RightCurriedFunction1; + (t1: T1, t2: T2, t3: T3): R; +} +interface RightCurriedFunction4 { + (): RightCurriedFunction4; + (t4: T4): RightCurriedFunction3; + (t3: T3, t4: __): RightCurriedFunction3; + (t3: T3, t4: T4): RightCurriedFunction2; + (t2: T2, t3: __, t4: __): RightCurriedFunction3; + (t2: T2, t3: T3, t4: __): RightCurriedFunction2; + (t2: T2, t3: __, t4: T4): RightCurriedFunction2; + (t2: T2, t3: T3, t4: T4): RightCurriedFunction1; + (t1: T1, t2: __, t3: __, t4: __): RightCurriedFunction3; + (t1: T1, t2: T2, t3: __, t4: __): RightCurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: __): RightCurriedFunction2; + (t1: T1, t2: __, t3: __, t4: T4): RightCurriedFunction2; + (t1: T1, t2: T2, t3: T3, t4: __): RightCurriedFunction1; + (t1: T1, t2: T2, t3: __, t4: T4): RightCurriedFunction1; + (t1: T1, t2: __, t3: T3, t4: T4): RightCurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4): R; +} +interface RightCurriedFunction5 { + (): RightCurriedFunction5; + (t5: T5): RightCurriedFunction4; + (t4: T4, t5: __): RightCurriedFunction4; + (t4: T4, t5: T5): RightCurriedFunction3; + (t3: T3, t4: __, t5: __): RightCurriedFunction4; + (t3: T3, t4: T4, t5: __): RightCurriedFunction3; + (t3: T3, t4: __, t5: T5): RightCurriedFunction3; + (t3: T3, t4: T4, t5: T5): RightCurriedFunction2; + (t2: T2, t3: __, t4: __, t5: __): RightCurriedFunction4; + (t2: T2, t3: T3, t4: __, t5: __): RightCurriedFunction3; + (t2: T2, t3: __, t4: T4, t5: __): RightCurriedFunction3; + (t2: T2, t3: __, t4: __, t5: T5): RightCurriedFunction3; + (t2: T2, t3: T3, t4: T4, t5: __): RightCurriedFunction2; + (t2: T2, t3: T3, t4: __, t5: T5): RightCurriedFunction2; + (t2: T2, t3: __, t4: T4, t5: T5): RightCurriedFunction2; + (t2: T2, t3: T3, t4: T4, t5: T5): RightCurriedFunction1; + (t1: T1, t2: __, t3: __, t4: __, t5: __): RightCurriedFunction4; + (t1: T1, t2: T2, t3: __, t4: __, t5: __): RightCurriedFunction3; + (t1: T1, t2: __, t3: T3, t4: __, t5: __): RightCurriedFunction3; + (t1: T1, t2: __, t3: __, t4: T4, t5: __): RightCurriedFunction3; + (t1: T1, t2: __, t3: __, t4: __, t5: T5): RightCurriedFunction3; + (t1: T1, t2: T2, t3: T3, t4: __, t5: __): RightCurriedFunction2; + (t1: T1, t2: T2, t3: __, t4: T4, t5: __): RightCurriedFunction2; + (t1: T1, t2: T2, t3: __, t4: __, t5: T5): RightCurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: T4, t5: __): RightCurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: __, t5: T5): RightCurriedFunction2; + (t1: T1, t2: __, t3: __, t4: T4, t5: T5): RightCurriedFunction2; + (t1: T1, t2: T2, t3: T3, t4: T4, t5: __): RightCurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: __, t5: T5): RightCurriedFunction1; + (t1: T1, t2: T2, t3: __, t4: T4, t5: T5): RightCurriedFunction1; + (t1: T1, t2: __, t3: T3, t4: T4, t5: T5): RightCurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R; +} +declare function curryRight(func: (t1: T1) => R, arity?: number): RightCurriedFunction1; +declare function curryRight(func: (t1: T1, t2: T2) => R, arity?: number): RightCurriedFunction2; +declare function curryRight(func: (t1: T1, t2: T2, t3: T3) => R, arity?: number): RightCurriedFunction3; +declare function curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arity?: number): RightCurriedFunction4; +declare function curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R, arity?: number): RightCurriedFunction5; +declare function curryRight(func: (...args: any[]) => any, arity?: number): (...args: any[]) => any; +declare namespace curryRight { + var placeholder: typeof curryRightPlaceholder; +} +declare const curryRightPlaceholder: unique symbol; +//#endregion +export { curryRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/curryRight.d.ts b/node_modules/es-toolkit/dist/compat/function/curryRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6a2f4126f9646a639417a8f2c60ca03607bff3f4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/curryRight.d.ts @@ -0,0 +1,86 @@ +//#region src/compat/function/curryRight.d.ts +type __ = typeof curryRightPlaceholder; +interface RightCurriedFunction1 { + (): RightCurriedFunction1; + (t1: T1): R; +} +interface RightCurriedFunction2 { + (): RightCurriedFunction2; + (t2: T2): RightCurriedFunction1; + (t1: T1, t2: __): RightCurriedFunction1; + (t1: T1, t2: T2): R; +} +interface RightCurriedFunction3 { + (): RightCurriedFunction3; + (t3: T3): RightCurriedFunction2; + (t2: T2, t3: __): RightCurriedFunction2; + (t2: T2, t3: T3): RightCurriedFunction1; + (t1: T1, t2: __, t3: __): RightCurriedFunction2; + (t1: T1, t2: T2, t3: __): RightCurriedFunction1; + (t1: T1, t2: __, t3: T3): RightCurriedFunction1; + (t1: T1, t2: T2, t3: T3): R; +} +interface RightCurriedFunction4 { + (): RightCurriedFunction4; + (t4: T4): RightCurriedFunction3; + (t3: T3, t4: __): RightCurriedFunction3; + (t3: T3, t4: T4): RightCurriedFunction2; + (t2: T2, t3: __, t4: __): RightCurriedFunction3; + (t2: T2, t3: T3, t4: __): RightCurriedFunction2; + (t2: T2, t3: __, t4: T4): RightCurriedFunction2; + (t2: T2, t3: T3, t4: T4): RightCurriedFunction1; + (t1: T1, t2: __, t3: __, t4: __): RightCurriedFunction3; + (t1: T1, t2: T2, t3: __, t4: __): RightCurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: __): RightCurriedFunction2; + (t1: T1, t2: __, t3: __, t4: T4): RightCurriedFunction2; + (t1: T1, t2: T2, t3: T3, t4: __): RightCurriedFunction1; + (t1: T1, t2: T2, t3: __, t4: T4): RightCurriedFunction1; + (t1: T1, t2: __, t3: T3, t4: T4): RightCurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4): R; +} +interface RightCurriedFunction5 { + (): RightCurriedFunction5; + (t5: T5): RightCurriedFunction4; + (t4: T4, t5: __): RightCurriedFunction4; + (t4: T4, t5: T5): RightCurriedFunction3; + (t3: T3, t4: __, t5: __): RightCurriedFunction4; + (t3: T3, t4: T4, t5: __): RightCurriedFunction3; + (t3: T3, t4: __, t5: T5): RightCurriedFunction3; + (t3: T3, t4: T4, t5: T5): RightCurriedFunction2; + (t2: T2, t3: __, t4: __, t5: __): RightCurriedFunction4; + (t2: T2, t3: T3, t4: __, t5: __): RightCurriedFunction3; + (t2: T2, t3: __, t4: T4, t5: __): RightCurriedFunction3; + (t2: T2, t3: __, t4: __, t5: T5): RightCurriedFunction3; + (t2: T2, t3: T3, t4: T4, t5: __): RightCurriedFunction2; + (t2: T2, t3: T3, t4: __, t5: T5): RightCurriedFunction2; + (t2: T2, t3: __, t4: T4, t5: T5): RightCurriedFunction2; + (t2: T2, t3: T3, t4: T4, t5: T5): RightCurriedFunction1; + (t1: T1, t2: __, t3: __, t4: __, t5: __): RightCurriedFunction4; + (t1: T1, t2: T2, t3: __, t4: __, t5: __): RightCurriedFunction3; + (t1: T1, t2: __, t3: T3, t4: __, t5: __): RightCurriedFunction3; + (t1: T1, t2: __, t3: __, t4: T4, t5: __): RightCurriedFunction3; + (t1: T1, t2: __, t3: __, t4: __, t5: T5): RightCurriedFunction3; + (t1: T1, t2: T2, t3: T3, t4: __, t5: __): RightCurriedFunction2; + (t1: T1, t2: T2, t3: __, t4: T4, t5: __): RightCurriedFunction2; + (t1: T1, t2: T2, t3: __, t4: __, t5: T5): RightCurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: T4, t5: __): RightCurriedFunction2; + (t1: T1, t2: __, t3: T3, t4: __, t5: T5): RightCurriedFunction2; + (t1: T1, t2: __, t3: __, t4: T4, t5: T5): RightCurriedFunction2; + (t1: T1, t2: T2, t3: T3, t4: T4, t5: __): RightCurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: __, t5: T5): RightCurriedFunction1; + (t1: T1, t2: T2, t3: __, t4: T4, t5: T5): RightCurriedFunction1; + (t1: T1, t2: __, t3: T3, t4: T4, t5: T5): RightCurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R; +} +declare function curryRight(func: (t1: T1) => R, arity?: number): RightCurriedFunction1; +declare function curryRight(func: (t1: T1, t2: T2) => R, arity?: number): RightCurriedFunction2; +declare function curryRight(func: (t1: T1, t2: T2, t3: T3) => R, arity?: number): RightCurriedFunction3; +declare function curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arity?: number): RightCurriedFunction4; +declare function curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R, arity?: number): RightCurriedFunction5; +declare function curryRight(func: (...args: any[]) => any, arity?: number): (...args: any[]) => any; +declare namespace curryRight { + var placeholder: typeof curryRightPlaceholder; +} +declare const curryRightPlaceholder: unique symbol; +//#endregion +export { curryRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/curryRight.js b/node_modules/es-toolkit/dist/compat/function/curryRight.js new file mode 100644 index 0000000000000000000000000000000000000000..31f36771704e1fc1863daca8201183b58d5370e9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/curryRight.js @@ -0,0 +1,86 @@ +//#region src/compat/function/curryRight.ts +/** +* 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. +* The arity of `func` may be specified if `func.length` is not sufficient. +* +* Unlike `curry`, this function curries the function from right to left. +* +* The `curryRight.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: This method doesn't set the `length` property of curried functions. +* +* @param func - The function to curry. +* @param arity - The arity of func. +* @param guard - Enables use as an iteratee for methods like `Array#map`. +* @returns} - Returns the new curried function. +* +* @example +* const abc = function(a, b, c) { +* return Array.from(arguments); +* }; +* +* let curried = curryRight(abc); +* +* curried(3)(2)(1); +* // => [1, 2, 3] +* +* curried(2, 3)(1); +* // => [1, 2, 3] +* +* curried(1, 2, 3); +* // => [1, 2, 3] +* +* // Curried with placeholders. +* curried(3)(curryRight.placeholder, 2)(1); +* // => [1, 2, 3] +* +* // Curried with arity. +* curried = curryRight(abc, 2); +* +* curried(2)(1); +* // => [1, 2] +*/ +function curryRight(func, arity = func.length, guard) { + arity = guard ? func.length : arity; + arity = Number.parseInt(arity, 10); + if (Number.isNaN(arity) || arity < 1) arity = 0; + const wrapper = function(...partialArgs) { + const holders = partialArgs.filter((item) => item === curryRight.placeholder); + const length = partialArgs.length - holders.length; + if (length < arity) return makeCurryRight(func, arity - length, partialArgs); + if (this instanceof wrapper) return new func(...partialArgs); + return func.apply(this, partialArgs); + }; + wrapper.placeholder = curryRightPlaceholder; + return wrapper; +} +function makeCurryRight(func, arity, partialArgs) { + function wrapper(...providedArgs) { + const holders = providedArgs.filter((item) => item === curryRight.placeholder); + const length = providedArgs.length - holders.length; + providedArgs = composeArgs(providedArgs, partialArgs); + if (length < arity) return makeCurryRight(func, arity - length, providedArgs); + if (this instanceof wrapper) return new func(...providedArgs); + return func.apply(this, providedArgs); + } + wrapper.placeholder = curryRightPlaceholder; + return wrapper; +} +function composeArgs(providedArgs, partialArgs) { + const placeholderLength = partialArgs.filter((arg) => arg === curryRight.placeholder).length; + const rangeLength = Math.max(providedArgs.length - placeholderLength, 0); + const args = []; + let providedIndex = 0; + for (let i = 0; i < rangeLength; i++) args.push(providedArgs[providedIndex++]); + for (let i = 0; i < partialArgs.length; i++) { + const arg = partialArgs[i]; + if (arg === curryRight.placeholder) if (providedIndex < providedArgs.length) args.push(providedArgs[providedIndex++]); + else args.push(arg); + else args.push(arg); + } + return args; +} +const curryRightPlaceholder = Symbol("curryRight.placeholder"); +curryRight.placeholder = curryRightPlaceholder; +//#endregion +exports.curryRight = curryRight; diff --git a/node_modules/es-toolkit/dist/compat/function/curryRight.mjs b/node_modules/es-toolkit/dist/compat/function/curryRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3c91acc51f57ca787947a8dcc6c10c0fa99eedd9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/curryRight.mjs @@ -0,0 +1,86 @@ +//#region src/compat/function/curryRight.ts +/** +* 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. +* The arity of `func` may be specified if `func.length` is not sufficient. +* +* Unlike `curry`, this function curries the function from right to left. +* +* The `curryRight.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: This method doesn't set the `length` property of curried functions. +* +* @param func - The function to curry. +* @param arity - The arity of func. +* @param guard - Enables use as an iteratee for methods like `Array#map`. +* @returns} - Returns the new curried function. +* +* @example +* const abc = function(a, b, c) { +* return Array.from(arguments); +* }; +* +* let curried = curryRight(abc); +* +* curried(3)(2)(1); +* // => [1, 2, 3] +* +* curried(2, 3)(1); +* // => [1, 2, 3] +* +* curried(1, 2, 3); +* // => [1, 2, 3] +* +* // Curried with placeholders. +* curried(3)(curryRight.placeholder, 2)(1); +* // => [1, 2, 3] +* +* // Curried with arity. +* curried = curryRight(abc, 2); +* +* curried(2)(1); +* // => [1, 2] +*/ +function curryRight(func, arity = func.length, guard) { + arity = guard ? func.length : arity; + arity = Number.parseInt(arity, 10); + if (Number.isNaN(arity) || arity < 1) arity = 0; + const wrapper = function(...partialArgs) { + const holders = partialArgs.filter((item) => item === curryRight.placeholder); + const length = partialArgs.length - holders.length; + if (length < arity) return makeCurryRight(func, arity - length, partialArgs); + if (this instanceof wrapper) return new func(...partialArgs); + return func.apply(this, partialArgs); + }; + wrapper.placeholder = curryRightPlaceholder; + return wrapper; +} +function makeCurryRight(func, arity, partialArgs) { + function wrapper(...providedArgs) { + const holders = providedArgs.filter((item) => item === curryRight.placeholder); + const length = providedArgs.length - holders.length; + providedArgs = composeArgs(providedArgs, partialArgs); + if (length < arity) return makeCurryRight(func, arity - length, providedArgs); + if (this instanceof wrapper) return new func(...providedArgs); + return func.apply(this, providedArgs); + } + wrapper.placeholder = curryRightPlaceholder; + return wrapper; +} +function composeArgs(providedArgs, partialArgs) { + const placeholderLength = partialArgs.filter((arg) => arg === curryRight.placeholder).length; + const rangeLength = Math.max(providedArgs.length - placeholderLength, 0); + const args = []; + let providedIndex = 0; + for (let i = 0; i < rangeLength; i++) args.push(providedArgs[providedIndex++]); + for (let i = 0; i < partialArgs.length; i++) { + const arg = partialArgs[i]; + if (arg === curryRight.placeholder) if (providedIndex < providedArgs.length) args.push(providedArgs[providedIndex++]); + else args.push(arg); + else args.push(arg); + } + return args; +} +const curryRightPlaceholder = Symbol("curryRight.placeholder"); +curryRight.placeholder = curryRightPlaceholder; +//#endregion +export { curryRight }; diff --git a/node_modules/es-toolkit/dist/compat/function/debounce.d.mts b/node_modules/es-toolkit/dist/compat/function/debounce.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8916d735209af852ab35ccab340e797721fc950e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/debounce.d.mts @@ -0,0 +1,145 @@ +//#region src/compat/function/debounce.d.ts +interface DebounceSettings { + /** + * If `true`, the function will be invoked on the leading edge of the timeout. + * @default false + */ + leading?: boolean | undefined; + /** + * The maximum time `func` is allowed to be delayed before it's invoked. + * @default Infinity + */ + maxWait?: number | undefined; + /** + * If `true`, the function will be invoked on the trailing edge of the timeout. + * @default true + */ + trailing?: boolean | undefined; +} +interface DebounceSettingsLeading extends DebounceSettings { + leading: true; +} +interface DebouncedFunc any> { + /** + * Call the original function, but applying the debounce rules. + * + * If the debounced function can be run immediately, this calls it and returns its return + * value. + * + * Otherwise, it returns the return value of the last invocation, or undefined if the debounced + * function was not invoked yet. + */ + (...args: Parameters): ReturnType | undefined; + /** + * Throw away any pending invocation of the debounced function. + */ + cancel(): void; + /** + * If there is a pending invocation of the debounced function, invoke it immediately and return + * its return value. + * + * Otherwise, return the value from the last invocation, or undefined if the debounced function + * was never invoked. + */ + flush(): ReturnType | undefined; +} +interface DebouncedFuncLeading any> extends DebouncedFunc { + (...args: Parameters): ReturnType; + flush(): ReturnType; +} +/** + * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds + * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel` + * method to cancel any pending execution. + * + * You can set the debounced function to run at the start (`leading`) or end (`trailing`) of the delay period. + * If `leading` is true, the function runs immediately on the first call. + * If `trailing` is true, the function runs after `debounceMs` milliseconds have passed since the last call. + * 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 + * (since one debounced function call cannot trigger the function twice). + * + * You can also set a `maxWait` time, which is the maximum time the function is allowed to be delayed before it is called. + * + * @template F - The type of function. + * @param func - The function to debounce. + * @param debounceMs - The number of milliseconds to delay. + * @param options - The options object + * @param options.signal - An optional AbortSignal to cancel the debounced function. + * @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. + * @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. + * @param options.maxWait - The maximum time `func` is allowed to be delayed before it's invoked. + * @returns A new debounced function with a `cancel` method. + * + * @example + * const debouncedFunction = debounce(() => { + * console.log('Function executed'); + * }, 1000); + * + * // Will log 'Function executed' after 1 second if not called again in that time + * debouncedFunction(); + * + * // Will not log anything as the previous call is canceled + * debouncedFunction.cancel(); + * + * // With AbortSignal + * const controller = new AbortController(); + * const signal = controller.signal; + * const debouncedWithSignal = debounce(() => { + * console.log('Function executed'); + * }, 1000, { signal }); + * + * debouncedWithSignal(); + * + * // Will cancel the debounced function call + * controller.abort(); + */ +declare function debounce any>(func: T, wait: number | undefined, options: DebounceSettingsLeading): DebouncedFuncLeading; +/** + * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds + * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel` + * method to cancel any pending execution. + * + * You can set the debounced function to run at the start (`leading`) or end (`trailing`) of the delay period. + * If `leading` is true, the function runs immediately on the first call. + * If `trailing` is true, the function runs after `debounceMs` milliseconds have passed since the last call. + * 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 + * (since one debounced function call cannot trigger the function twice). + * + * You can also set a `maxWait` time, which is the maximum time the function is allowed to be delayed before it is called. + * + * @template F - The type of function. + * @param func - The function to debounce. + * @param debounceMs - The number of milliseconds to delay. + * @param options - The options object + * @param options.signal - An optional AbortSignal to cancel the debounced function. + * @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. + * @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. + * @param options.maxWait - The maximum time `func` is allowed to be delayed before it's invoked. + * @returns A new debounced function with a `cancel` method. + * + * @example + * const debouncedFunction = debounce(() => { + * console.log('Function executed'); + * }, 1000); + * + * // Will log 'Function executed' after 1 second if not called again in that time + * debouncedFunction(); + * + * // Will not log anything as the previous call is canceled + * debouncedFunction.cancel(); + * + * // With AbortSignal + * const controller = new AbortController(); + * const signal = controller.signal; + * const debouncedWithSignal = debounce(() => { + * console.log('Function executed'); + * }, 1000, { signal }); + * + * debouncedWithSignal(); + * + * // Will cancel the debounced function call + * controller.abort(); + */ +declare function debounce any>(func: T, wait?: number, options?: DebounceSettings): DebouncedFunc; +//#endregion +export { DebouncedFunc, DebouncedFuncLeading, debounce }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/debounce.d.ts b/node_modules/es-toolkit/dist/compat/function/debounce.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8916d735209af852ab35ccab340e797721fc950e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/debounce.d.ts @@ -0,0 +1,145 @@ +//#region src/compat/function/debounce.d.ts +interface DebounceSettings { + /** + * If `true`, the function will be invoked on the leading edge of the timeout. + * @default false + */ + leading?: boolean | undefined; + /** + * The maximum time `func` is allowed to be delayed before it's invoked. + * @default Infinity + */ + maxWait?: number | undefined; + /** + * If `true`, the function will be invoked on the trailing edge of the timeout. + * @default true + */ + trailing?: boolean | undefined; +} +interface DebounceSettingsLeading extends DebounceSettings { + leading: true; +} +interface DebouncedFunc any> { + /** + * Call the original function, but applying the debounce rules. + * + * If the debounced function can be run immediately, this calls it and returns its return + * value. + * + * Otherwise, it returns the return value of the last invocation, or undefined if the debounced + * function was not invoked yet. + */ + (...args: Parameters): ReturnType | undefined; + /** + * Throw away any pending invocation of the debounced function. + */ + cancel(): void; + /** + * If there is a pending invocation of the debounced function, invoke it immediately and return + * its return value. + * + * Otherwise, return the value from the last invocation, or undefined if the debounced function + * was never invoked. + */ + flush(): ReturnType | undefined; +} +interface DebouncedFuncLeading any> extends DebouncedFunc { + (...args: Parameters): ReturnType; + flush(): ReturnType; +} +/** + * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds + * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel` + * method to cancel any pending execution. + * + * You can set the debounced function to run at the start (`leading`) or end (`trailing`) of the delay period. + * If `leading` is true, the function runs immediately on the first call. + * If `trailing` is true, the function runs after `debounceMs` milliseconds have passed since the last call. + * 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 + * (since one debounced function call cannot trigger the function twice). + * + * You can also set a `maxWait` time, which is the maximum time the function is allowed to be delayed before it is called. + * + * @template F - The type of function. + * @param func - The function to debounce. + * @param debounceMs - The number of milliseconds to delay. + * @param options - The options object + * @param options.signal - An optional AbortSignal to cancel the debounced function. + * @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. + * @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. + * @param options.maxWait - The maximum time `func` is allowed to be delayed before it's invoked. + * @returns A new debounced function with a `cancel` method. + * + * @example + * const debouncedFunction = debounce(() => { + * console.log('Function executed'); + * }, 1000); + * + * // Will log 'Function executed' after 1 second if not called again in that time + * debouncedFunction(); + * + * // Will not log anything as the previous call is canceled + * debouncedFunction.cancel(); + * + * // With AbortSignal + * const controller = new AbortController(); + * const signal = controller.signal; + * const debouncedWithSignal = debounce(() => { + * console.log('Function executed'); + * }, 1000, { signal }); + * + * debouncedWithSignal(); + * + * // Will cancel the debounced function call + * controller.abort(); + */ +declare function debounce any>(func: T, wait: number | undefined, options: DebounceSettingsLeading): DebouncedFuncLeading; +/** + * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds + * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel` + * method to cancel any pending execution. + * + * You can set the debounced function to run at the start (`leading`) or end (`trailing`) of the delay period. + * If `leading` is true, the function runs immediately on the first call. + * If `trailing` is true, the function runs after `debounceMs` milliseconds have passed since the last call. + * 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 + * (since one debounced function call cannot trigger the function twice). + * + * You can also set a `maxWait` time, which is the maximum time the function is allowed to be delayed before it is called. + * + * @template F - The type of function. + * @param func - The function to debounce. + * @param debounceMs - The number of milliseconds to delay. + * @param options - The options object + * @param options.signal - An optional AbortSignal to cancel the debounced function. + * @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. + * @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. + * @param options.maxWait - The maximum time `func` is allowed to be delayed before it's invoked. + * @returns A new debounced function with a `cancel` method. + * + * @example + * const debouncedFunction = debounce(() => { + * console.log('Function executed'); + * }, 1000); + * + * // Will log 'Function executed' after 1 second if not called again in that time + * debouncedFunction(); + * + * // Will not log anything as the previous call is canceled + * debouncedFunction.cancel(); + * + * // With AbortSignal + * const controller = new AbortController(); + * const signal = controller.signal; + * const debouncedWithSignal = debounce(() => { + * console.log('Function executed'); + * }, 1000, { signal }); + * + * debouncedWithSignal(); + * + * // Will cancel the debounced function call + * controller.abort(); + */ +declare function debounce any>(func: T, wait?: number, options?: DebounceSettings): DebouncedFunc; +//#endregion +export { DebouncedFunc, DebouncedFuncLeading, debounce }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/debounce.js b/node_modules/es-toolkit/dist/compat/function/debounce.js new file mode 100644 index 0000000000000000000000000000000000000000..aaf3c8d39f7be6dd0c2fdae30f0cdef92c566b14 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/debounce.js @@ -0,0 +1,38 @@ +const require_debounce = require("../../function/debounce.js"); +//#region src/compat/function/debounce.ts +function debounce(func, debounceMs = 0, options = {}) { + if (typeof options !== "object") options = {}; + const { leading = false, trailing = true, maxWait } = options; + const edges = Array(2); + if (leading) edges[0] = "leading"; + if (trailing) edges[1] = "trailing"; + let result = void 0; + let pendingAt = null; + const _debounced = require_debounce.debounce(function(...args) { + result = func.apply(this, args); + pendingAt = null; + }, debounceMs, { edges }); + const debounced = function(...args) { + if (maxWait != null) { + if (pendingAt === null) pendingAt = Date.now(); + if (Date.now() - pendingAt >= maxWait) { + result = func.apply(this, args); + pendingAt = Date.now(); + _debounced.cancel(); + _debounced.schedule(); + return result; + } + } + _debounced.apply(this, args); + return result; + }; + const flush = () => { + _debounced.flush(); + return result; + }; + debounced.cancel = _debounced.cancel; + debounced.flush = flush; + return debounced; +} +//#endregion +exports.debounce = debounce; diff --git a/node_modules/es-toolkit/dist/compat/function/debounce.mjs b/node_modules/es-toolkit/dist/compat/function/debounce.mjs new file mode 100644 index 0000000000000000000000000000000000000000..70e431b615db45762c665a5325ee48e4a8ca914c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/debounce.mjs @@ -0,0 +1,38 @@ +import { debounce as debounce$1 } from "../../function/debounce.mjs"; +//#region src/compat/function/debounce.ts +function debounce(func, debounceMs = 0, options = {}) { + if (typeof options !== "object") options = {}; + const { leading = false, trailing = true, maxWait } = options; + const edges = Array(2); + if (leading) edges[0] = "leading"; + if (trailing) edges[1] = "trailing"; + let result = void 0; + let pendingAt = null; + const _debounced = debounce$1(function(...args) { + result = func.apply(this, args); + pendingAt = null; + }, debounceMs, { edges }); + const debounced = function(...args) { + if (maxWait != null) { + if (pendingAt === null) pendingAt = Date.now(); + if (Date.now() - pendingAt >= maxWait) { + result = func.apply(this, args); + pendingAt = Date.now(); + _debounced.cancel(); + _debounced.schedule(); + return result; + } + } + _debounced.apply(this, args); + return result; + }; + const flush = () => { + _debounced.flush(); + return result; + }; + debounced.cancel = _debounced.cancel; + debounced.flush = flush; + return debounced; +} +//#endregion +export { debounce }; diff --git a/node_modules/es-toolkit/dist/compat/function/defer.d.mts b/node_modules/es-toolkit/dist/compat/function/defer.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..00d2cfd79d32e74585db4a076f61944f459beaa6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/defer.d.mts @@ -0,0 +1,15 @@ +//#region src/compat/function/defer.d.ts +/** + * Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to func when it's invoked. + * + * @param func The function to defer. + * @param args The arguments to invoke `func` with. + * @returns Returns the timer id. + * + * @example + * defer(console.log, 'deferred'); + * // => Logs 'deferred' after the current call stack has cleared. + */ +declare function defer(func: (...args: any[]) => any, ...args: any[]): number; +//#endregion +export { defer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/defer.d.ts b/node_modules/es-toolkit/dist/compat/function/defer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..00d2cfd79d32e74585db4a076f61944f459beaa6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/defer.d.ts @@ -0,0 +1,15 @@ +//#region src/compat/function/defer.d.ts +/** + * Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to func when it's invoked. + * + * @param func The function to defer. + * @param args The arguments to invoke `func` with. + * @returns Returns the timer id. + * + * @example + * defer(console.log, 'deferred'); + * // => Logs 'deferred' after the current call stack has cleared. + */ +declare function defer(func: (...args: any[]) => any, ...args: any[]): number; +//#endregion +export { defer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/defer.js b/node_modules/es-toolkit/dist/compat/function/defer.js new file mode 100644 index 0000000000000000000000000000000000000000..739524a36d3ab6d2d587c2440b40a6593a4fbf60 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/defer.js @@ -0,0 +1,20 @@ +//#region src/compat/function/defer.ts +/** +* Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to func when it's invoked. +* +* @param func The function to defer. +* @param args The arguments to invoke `func` with. +* @returns Returns the timer id. +* +* @example +* defer((text) => { +* console.log(text); +* }, 'deferred'); +* // => Logs 'deferred' after the current call stack has cleared. +*/ +function defer(func, ...args) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + return setTimeout(func, 1, ...args); +} +//#endregion +exports.defer = defer; diff --git a/node_modules/es-toolkit/dist/compat/function/defer.mjs b/node_modules/es-toolkit/dist/compat/function/defer.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0436e43cc3c48677fdf3f9c1baa9e35da41a4652 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/defer.mjs @@ -0,0 +1,20 @@ +//#region src/compat/function/defer.ts +/** +* Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to func when it's invoked. +* +* @param func The function to defer. +* @param args The arguments to invoke `func` with. +* @returns Returns the timer id. +* +* @example +* defer((text) => { +* console.log(text); +* }, 'deferred'); +* // => Logs 'deferred' after the current call stack has cleared. +*/ +function defer(func, ...args) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + return setTimeout(func, 1, ...args); +} +//#endregion +export { defer }; diff --git a/node_modules/es-toolkit/dist/compat/function/delay.d.mts b/node_modules/es-toolkit/dist/compat/function/delay.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..211647004c0b6cd51ac76415df18486508e845f1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/delay.d.mts @@ -0,0 +1,30 @@ +//#region src/compat/function/delay.d.ts +/** + * Invokes the specified function after a delay of the given number of milliseconds. + * Any additional arguments are passed to the function when it is invoked. + * + * @param func - The function to delay. + * @param wait - The number of milliseconds to delay the invocation. + * @param args - The arguments to pass to the function when it is invoked. + * @returns Returns the timer id. + * @throws {TypeError} If the first argument is not a function. + * + * @example + * // Example 1: Delayed function execution + * const timerId = delay( + * (greeting, recipient) => { + * console.log(`${greeting}, ${recipient}!`); + * }, + * 1000, + * 'Hello', + * 'Alice' + * ); + * // => 'Hello, Alice!' will be logged after one second. + * + * // Example 2: Clearing the timeout before execution + * clearTimeout(timerId); + * // The function will not be executed because the timeout was cleared. + */ +declare function delay(func: (...args: any[]) => any, wait: number, ...args: any[]): number; +//#endregion +export { delay }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/delay.d.ts b/node_modules/es-toolkit/dist/compat/function/delay.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..211647004c0b6cd51ac76415df18486508e845f1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/delay.d.ts @@ -0,0 +1,30 @@ +//#region src/compat/function/delay.d.ts +/** + * Invokes the specified function after a delay of the given number of milliseconds. + * Any additional arguments are passed to the function when it is invoked. + * + * @param func - The function to delay. + * @param wait - The number of milliseconds to delay the invocation. + * @param args - The arguments to pass to the function when it is invoked. + * @returns Returns the timer id. + * @throws {TypeError} If the first argument is not a function. + * + * @example + * // Example 1: Delayed function execution + * const timerId = delay( + * (greeting, recipient) => { + * console.log(`${greeting}, ${recipient}!`); + * }, + * 1000, + * 'Hello', + * 'Alice' + * ); + * // => 'Hello, Alice!' will be logged after one second. + * + * // Example 2: Clearing the timeout before execution + * clearTimeout(timerId); + * // The function will not be executed because the timeout was cleared. + */ +declare function delay(func: (...args: any[]) => any, wait: number, ...args: any[]): number; +//#endregion +export { delay }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/delay.js b/node_modules/es-toolkit/dist/compat/function/delay.js new file mode 100644 index 0000000000000000000000000000000000000000..8519222d73d6ed720b4933330ea86a9bb8eb9656 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/delay.js @@ -0,0 +1,34 @@ +const require_toNumber = require("../util/toNumber.js"); +//#region src/compat/function/delay.ts +/** +* Invokes the specified function after a delay of the given number of milliseconds. +* Any additional arguments are passed to the function when it is invoked. +* +* @param func - The function to delay. +* @param wait - The number of milliseconds to delay the invocation. +* @param args - The arguments to pass to the function when it is invoked. +* @returns Returns the timer id. +* @throws {TypeError} If the first argument is not a function. +* +* @example +* // Example 1: Delayed function execution +* const timerId = delay( +* (greeting, recipient) => { +* console.log(`${greeting}, ${recipient}!`); +* }, +* 1000, +* 'Hello', +* 'Alice' +* ); +* // => 'Hello, Alice!' will be logged after one second. +* +* // Example 2: Clearing the timeout before execution +* clearTimeout(timerId); +* // The function will not be executed because the timeout was cleared. +*/ +function delay(func, wait, ...args) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + return setTimeout(func, require_toNumber.toNumber(wait) || 0, ...args); +} +//#endregion +exports.delay = delay; diff --git a/node_modules/es-toolkit/dist/compat/function/delay.mjs b/node_modules/es-toolkit/dist/compat/function/delay.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b997c217c56cd2146c0d60da4487fa76c312bfef --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/delay.mjs @@ -0,0 +1,34 @@ +import { toNumber } from "../util/toNumber.mjs"; +//#region src/compat/function/delay.ts +/** +* Invokes the specified function after a delay of the given number of milliseconds. +* Any additional arguments are passed to the function when it is invoked. +* +* @param func - The function to delay. +* @param wait - The number of milliseconds to delay the invocation. +* @param args - The arguments to pass to the function when it is invoked. +* @returns Returns the timer id. +* @throws {TypeError} If the first argument is not a function. +* +* @example +* // Example 1: Delayed function execution +* const timerId = delay( +* (greeting, recipient) => { +* console.log(`${greeting}, ${recipient}!`); +* }, +* 1000, +* 'Hello', +* 'Alice' +* ); +* // => 'Hello, Alice!' will be logged after one second. +* +* // Example 2: Clearing the timeout before execution +* clearTimeout(timerId); +* // The function will not be executed because the timeout was cleared. +*/ +function delay(func, wait, ...args) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + return setTimeout(func, toNumber(wait) || 0, ...args); +} +//#endregion +export { delay }; diff --git a/node_modules/es-toolkit/dist/compat/function/flip.d.mts b/node_modules/es-toolkit/dist/compat/function/flip.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9a48e4eb808a0c3e547cff28b19710ad91520088 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flip.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/function/flip.d.ts +/** + * Reverses the order of arguments for a given function. + * + * @template T - The type of the function being flipped. + * @param func - The function whose arguments will be reversed. + * @returns A new function that takes the reversed arguments and returns the result of calling `func`. + * + * @example + * var flipped = flip(function() { + * return Array.prototype.slice.call(arguments); + * }); + * + * flipped('a', 'b', 'c', 'd'); + * // => ['d', 'c', 'b', 'a'] + */ +declare function flip any>(func: T): T; +//#endregion +export { flip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/flip.d.ts b/node_modules/es-toolkit/dist/compat/function/flip.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a48e4eb808a0c3e547cff28b19710ad91520088 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flip.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/function/flip.d.ts +/** + * Reverses the order of arguments for a given function. + * + * @template T - The type of the function being flipped. + * @param func - The function whose arguments will be reversed. + * @returns A new function that takes the reversed arguments and returns the result of calling `func`. + * + * @example + * var flipped = flip(function() { + * return Array.prototype.slice.call(arguments); + * }); + * + * flipped('a', 'b', 'c', 'd'); + * // => ['d', 'c', 'b', 'a'] + */ +declare function flip any>(func: T): T; +//#endregion +export { flip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/flip.js b/node_modules/es-toolkit/dist/compat/function/flip.js new file mode 100644 index 0000000000000000000000000000000000000000..c6be2195adb9b463b2873bfcdf4213a63ea88141 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flip.js @@ -0,0 +1,24 @@ +//#region src/compat/function/flip.ts +/** +* Reverses the order of arguments for a given function. +* +* @template F - The type of the function being flipped. +* @param func - The function whose arguments will be reversed. +* @returns A new function that takes the +* reversed arguments and returns the result of calling `func`. +* +* @example +* function fn(a: string, b: string, c: string, d: string) { +* return [a, b, c, d]; +* } +* +* const flipped = flip(fn); +* flipped('a', 'b', 'c', 'd'); // => ['d', 'c', 'b', 'a'] +*/ +function flip(func) { + return function(...args) { + return func.apply(this, args.reverse()); + }; +} +//#endregion +exports.flip = flip; diff --git a/node_modules/es-toolkit/dist/compat/function/flip.mjs b/node_modules/es-toolkit/dist/compat/function/flip.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cca5270584e1ac7577b97771e05592c778919596 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flip.mjs @@ -0,0 +1,24 @@ +//#region src/compat/function/flip.ts +/** +* Reverses the order of arguments for a given function. +* +* @template F - The type of the function being flipped. +* @param func - The function whose arguments will be reversed. +* @returns A new function that takes the +* reversed arguments and returns the result of calling `func`. +* +* @example +* function fn(a: string, b: string, c: string, d: string) { +* return [a, b, c, d]; +* } +* +* const flipped = flip(fn); +* flipped('a', 'b', 'c', 'd'); // => ['d', 'c', 'b', 'a'] +*/ +function flip(func) { + return function(...args) { + return func.apply(this, args.reverse()); + }; +} +//#endregion +export { flip }; diff --git a/node_modules/es-toolkit/dist/compat/function/flow.d.mts b/node_modules/es-toolkit/dist/compat/function/flow.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ae5924c59e064cfb39fc745d8c0f9720db5c891c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flow.d.mts @@ -0,0 +1,120 @@ +import { Many } from "../_internal/Many.mjs"; + +//#region src/compat/function/flow.d.ts +/** + * 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. + * + * @template A - The type of the arguments. + * @template R - The type of the return values. + * @param f1 - The first function to invoke. + * @param f2 - The second function to invoke. + * @param f3 - The third function to invoke. + * @param f4 - The fourth function to invoke. + * @param f5 - The fifth function to invoke. + * @param f6 - The sixth function to invoke. + * @param f7 - The seventh function to invoke. + * @returns Returns the new composite function. + * + * @example + * function square(n) { + * return n * n; + * } + * + * var addSquare = flow([add, square]); + * addSquare(1, 2); + * // => 9 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7): (...args: A) => R7; +/** + * Creates a new function that executes up to 7 functions in sequence, with additional functions flattened. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => n.toString(); + * + * const combined = flow(add, square, double, toString); + * console.log(combined(1, 2)); // "18" + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7, ...func: Array any>>): (...args: A) => any; +/** + * Creates a new function that executes 6 functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6): (...args: A) => R6; +/** + * Creates a new function that executes 5 functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5): (...args: A) => R5; +/** + * Creates a new function that executes 4 functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4): (...args: A) => R4; +/** + * Creates a new function that executes 3 functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3): (...args: A) => R3; +/** + * Creates a new function that executes 2 functions in sequence. + * The return value of the first function is passed as an argument to the second function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * + * const addThenSquare = flow(add, square); + * console.log(addThenSquare(1, 2)); // 9 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2; +/** + * Creates a new function that executes the given functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(...func: Array any>>): (...args: any[]) => any; +//#endregion +export { flow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/flow.d.ts b/node_modules/es-toolkit/dist/compat/function/flow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f203036f718c14f885be7f70d2fa80d1c2e3d659 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flow.d.ts @@ -0,0 +1,120 @@ +import { Many } from "../_internal/Many.js"; + +//#region src/compat/function/flow.d.ts +/** + * 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. + * + * @template A - The type of the arguments. + * @template R - The type of the return values. + * @param f1 - The first function to invoke. + * @param f2 - The second function to invoke. + * @param f3 - The third function to invoke. + * @param f4 - The fourth function to invoke. + * @param f5 - The fifth function to invoke. + * @param f6 - The sixth function to invoke. + * @param f7 - The seventh function to invoke. + * @returns Returns the new composite function. + * + * @example + * function square(n) { + * return n * n; + * } + * + * var addSquare = flow([add, square]); + * addSquare(1, 2); + * // => 9 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7): (...args: A) => R7; +/** + * Creates a new function that executes up to 7 functions in sequence, with additional functions flattened. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => n.toString(); + * + * const combined = flow(add, square, double, toString); + * console.log(combined(1, 2)); // "18" + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7, ...func: Array any>>): (...args: A) => any; +/** + * Creates a new function that executes 6 functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6): (...args: A) => R6; +/** + * Creates a new function that executes 5 functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5): (...args: A) => R5; +/** + * Creates a new function that executes 4 functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4): (...args: A) => R4; +/** + * Creates a new function that executes 3 functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3): (...args: A) => R3; +/** + * Creates a new function that executes 2 functions in sequence. + * The return value of the first function is passed as an argument to the second function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * + * const addThenSquare = flow(add, square); + * console.log(addThenSquare(1, 2)); // 9 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2; +/** + * Creates a new function that executes the given functions in sequence. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flow(add, square, double); + * console.log(combined(1, 2)); // 18 + */ +declare function flow(...func: Array any>>): (...args: any[]) => any; +//#endregion +export { flow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/flow.js b/node_modules/es-toolkit/dist/compat/function/flow.js new file mode 100644 index 0000000000000000000000000000000000000000..4ff12a366b8bda5faa4f8e99735ff9a7d438eadf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flow.js @@ -0,0 +1,26 @@ +const require_flatten = require("../../array/flatten.js"); +const require_flow = require("../../function/flow.js"); +//#region src/compat/function/flow.ts +/** +* 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. +* +* The `this` context of the returned function is also passed to the functions provided as parameters. +* +* @param funcs The functions to invoke. +* @returns Returns the new composite function. +* +* @example +* const add = (x: number, y: number) => x + y; +* const square = (n: number) => n * n; +* const double = (n: number) => n * 2; +* +* const combined = flow([add, square], double); +* console.log(combined(1, 2)); // 18 +*/ +function flow(...funcs) { + const flattenFuncs = require_flatten.flatten(funcs, 1); + if (flattenFuncs.some((func) => typeof func !== "function")) throw new TypeError("Expected a function"); + return require_flow.flow(...flattenFuncs); +} +//#endregion +exports.flow = flow; diff --git a/node_modules/es-toolkit/dist/compat/function/flow.mjs b/node_modules/es-toolkit/dist/compat/function/flow.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a1e94f6be6a12b63ad5483cfe61c5865e458f293 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flow.mjs @@ -0,0 +1,26 @@ +import { flatten } from "../../array/flatten.mjs"; +import { flow as flow$1 } from "../../function/flow.mjs"; +//#region src/compat/function/flow.ts +/** +* 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. +* +* The `this` context of the returned function is also passed to the functions provided as parameters. +* +* @param funcs The functions to invoke. +* @returns Returns the new composite function. +* +* @example +* const add = (x: number, y: number) => x + y; +* const square = (n: number) => n * n; +* const double = (n: number) => n * 2; +* +* const combined = flow([add, square], double); +* console.log(combined(1, 2)); // 18 +*/ +function flow(...funcs) { + const flattenFuncs = flatten(funcs, 1); + if (flattenFuncs.some((func) => typeof func !== "function")) throw new TypeError("Expected a function"); + return flow$1(...flattenFuncs); +} +//#endregion +export { flow }; diff --git a/node_modules/es-toolkit/dist/compat/function/flowRight.d.mts b/node_modules/es-toolkit/dist/compat/function/flowRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fbc1df0d7712fc84779c97eecc7062de65c9f6d4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flowRight.d.mts @@ -0,0 +1,118 @@ +import { Many } from "../_internal/Many.mjs"; + +//#region src/compat/function/flowRight.d.ts +/** + * 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. + * + * @template A - The type of the arguments. + * @template R - The type of the return values. + * @param f7 - The seventh function to invoke. + * @param f6 - The sixth function to invoke. + * @param f5 - The fifth function to invoke. + * @param f4 - The fourth function to invoke. + * @param f3 - The third function to invoke. + * @param f2 - The second function to invoke. + * @param f1 - The first function to invoke. + * @returns Returns the new composite function. + * + * @example + * function square(n) { + * return n * n; + * } + * + * var addSquare = flowRight(square, add); + * addSquare(1, 2); + * // => 9 + */ +declare function flowRight(f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R7; +/** + * Creates a new function that executes 6 functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => String(n); + * const append = (s: string) => s + '!'; + * const length = (s: string) => s.length; + * + * const combined = flowRight(length, append, toString, double, square, add); + * console.log(combined(1, 2)); // 7 + */ +declare function flowRight(f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R6; +/** + * Creates a new function that executes 5 functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => String(n); + * const append = (s: string) => s + '!'; + * + * const combined = flowRight(append, toString, double, square, add); + * console.log(combined(1, 2)); // '18!' + */ +declare function flowRight(f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R5; +/** + * Creates a new function that executes 4 functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => String(n); + * + * const combined = flowRight(toString, double, square, add); + * console.log(combined(1, 2)); // '18' + */ +declare function flowRight(f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R4; +/** + * Creates a new function that executes 3 functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flowRight(double, square, add); + * console.log(combined(1, 2)); // 18 + */ +declare function flowRight(f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R3; +/** + * Creates a new function that executes 2 functions in sequence from right to left. + * The return value of the first function is passed as an argument to the second function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * + * const combined = flowRight(square, add); + * console.log(combined(1, 2)); // 9 + */ +declare function flowRight(f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R2; +/** + * Creates a new function that executes the given functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => String(n); + * + * // Pass functions as separate arguments + * const combined1 = flowRight(toString, double, square, add); + * console.log(combined1(1, 2)); // '18' + * + * // Pass functions as arrays + * const combined2 = flowRight([toString, double], [square, add]); + * console.log(combined2(1, 2)); // '18' + */ +declare function flowRight(...func: Array any>>): (...args: any[]) => any; +//#endregion +export { flowRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/flowRight.d.ts b/node_modules/es-toolkit/dist/compat/function/flowRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec7357248dbdc611b8a7095c140e24fb3f0d5d4b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flowRight.d.ts @@ -0,0 +1,118 @@ +import { Many } from "../_internal/Many.js"; + +//#region src/compat/function/flowRight.d.ts +/** + * 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. + * + * @template A - The type of the arguments. + * @template R - The type of the return values. + * @param f7 - The seventh function to invoke. + * @param f6 - The sixth function to invoke. + * @param f5 - The fifth function to invoke. + * @param f4 - The fourth function to invoke. + * @param f3 - The third function to invoke. + * @param f2 - The second function to invoke. + * @param f1 - The first function to invoke. + * @returns Returns the new composite function. + * + * @example + * function square(n) { + * return n * n; + * } + * + * var addSquare = flowRight(square, add); + * addSquare(1, 2); + * // => 9 + */ +declare function flowRight(f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R7; +/** + * Creates a new function that executes 6 functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => String(n); + * const append = (s: string) => s + '!'; + * const length = (s: string) => s.length; + * + * const combined = flowRight(length, append, toString, double, square, add); + * console.log(combined(1, 2)); // 7 + */ +declare function flowRight(f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R6; +/** + * Creates a new function that executes 5 functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => String(n); + * const append = (s: string) => s + '!'; + * + * const combined = flowRight(append, toString, double, square, add); + * console.log(combined(1, 2)); // '18!' + */ +declare function flowRight(f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R5; +/** + * Creates a new function that executes 4 functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => String(n); + * + * const combined = flowRight(toString, double, square, add); + * console.log(combined(1, 2)); // '18' + */ +declare function flowRight(f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R4; +/** + * Creates a new function that executes 3 functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * + * const combined = flowRight(double, square, add); + * console.log(combined(1, 2)); // 18 + */ +declare function flowRight(f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R3; +/** + * Creates a new function that executes 2 functions in sequence from right to left. + * The return value of the first function is passed as an argument to the second function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * + * const combined = flowRight(square, add); + * console.log(combined(1, 2)); // 9 + */ +declare function flowRight(f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R2; +/** + * Creates a new function that executes the given functions in sequence from right to left. + * The return value of each function is passed as an argument to the next function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * const double = (n: number) => n * 2; + * const toString = (n: number) => String(n); + * + * // Pass functions as separate arguments + * const combined1 = flowRight(toString, double, square, add); + * console.log(combined1(1, 2)); // '18' + * + * // Pass functions as arrays + * const combined2 = flowRight([toString, double], [square, add]); + * console.log(combined2(1, 2)); // '18' + */ +declare function flowRight(...func: Array any>>): (...args: any[]) => any; +//#endregion +export { flowRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/flowRight.js b/node_modules/es-toolkit/dist/compat/function/flowRight.js new file mode 100644 index 0000000000000000000000000000000000000000..13f2bb8568c693a47b6a518eae1b864ba784632c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flowRight.js @@ -0,0 +1,28 @@ +const require_flatten = require("../../array/flatten.js"); +const require_flowRight = require("../../function/flowRight.js"); +//#region src/compat/function/flowRight.ts +/** +* 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. +* +* The `this` context of the returned function is also passed to the functions provided as parameters. +* +* This method is like `flow` except that it creates a function that invokes the given functions from right to left. +* +* @param funcs The functions to invoke. +* @returns Returns the new composite function. +* +* @example +* const add = (x: number, y: number) => x + y; +* const square = (n: number) => n * n; +* const double = (n: number) => n * 2; +* +* const combined = flowRight(double, [square, add]); +* console.log(combined(1, 2)); // 18 +*/ +function flowRight(...funcs) { + const flattenFuncs = require_flatten.flatten(funcs, 1); + if (flattenFuncs.some((func) => typeof func !== "function")) throw new TypeError("Expected a function"); + return require_flowRight.flowRight(...flattenFuncs); +} +//#endregion +exports.flowRight = flowRight; diff --git a/node_modules/es-toolkit/dist/compat/function/flowRight.mjs b/node_modules/es-toolkit/dist/compat/function/flowRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..364019a9f7bfe9bff02239a7acfa66feb9cbfb52 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/flowRight.mjs @@ -0,0 +1,28 @@ +import { flatten } from "../../array/flatten.mjs"; +import { flowRight as flowRight$1 } from "../../function/flowRight.mjs"; +//#region src/compat/function/flowRight.ts +/** +* 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. +* +* The `this` context of the returned function is also passed to the functions provided as parameters. +* +* This method is like `flow` except that it creates a function that invokes the given functions from right to left. +* +* @param funcs The functions to invoke. +* @returns Returns the new composite function. +* +* @example +* const add = (x: number, y: number) => x + y; +* const square = (n: number) => n * n; +* const double = (n: number) => n * 2; +* +* const combined = flowRight(double, [square, add]); +* console.log(combined(1, 2)); // 18 +*/ +function flowRight(...funcs) { + const flattenFuncs = flatten(funcs, 1); + if (flattenFuncs.some((func) => typeof func !== "function")) throw new TypeError("Expected a function"); + return flowRight$1(...flattenFuncs); +} +//#endregion +export { flowRight }; diff --git a/node_modules/es-toolkit/dist/compat/function/identity.d.mts b/node_modules/es-toolkit/dist/compat/function/identity.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c44b35aa9ead8ce197d68973808be9626b270229 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/identity.d.mts @@ -0,0 +1,43 @@ +//#region src/compat/function/identity.d.ts +/** + * Returns the input value unchanged. + * + * @template T - The type of the input value. + * @param x - The value to be returned. + * @returns The input value. + * + * @example + * // Returns 5 + * identity(5); + * + * @example + * // Returns 'hello' + * identity('hello'); + * + * @example + * // Returns { key: 'value' } + * identity({ key: 'value' }); + */ +declare function identity(value: T): T; +/** + * Returns the input value unchanged. + * + * @template T - The type of the input value. + * @param x - The value to be returned. + * @returns The input value. + * + * @example + * // Returns 5 + * identity(5); + * + * @example + * // Returns 'hello' + * identity('hello'); + * + * @example + * // Returns { key: 'value' } + * identity({ key: 'value' }); + */ +declare function identity(): undefined; +//#endregion +export { identity }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/identity.d.ts b/node_modules/es-toolkit/dist/compat/function/identity.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c44b35aa9ead8ce197d68973808be9626b270229 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/identity.d.ts @@ -0,0 +1,43 @@ +//#region src/compat/function/identity.d.ts +/** + * Returns the input value unchanged. + * + * @template T - The type of the input value. + * @param x - The value to be returned. + * @returns The input value. + * + * @example + * // Returns 5 + * identity(5); + * + * @example + * // Returns 'hello' + * identity('hello'); + * + * @example + * // Returns { key: 'value' } + * identity({ key: 'value' }); + */ +declare function identity(value: T): T; +/** + * Returns the input value unchanged. + * + * @template T - The type of the input value. + * @param x - The value to be returned. + * @returns The input value. + * + * @example + * // Returns 5 + * identity(5); + * + * @example + * // Returns 'hello' + * identity('hello'); + * + * @example + * // Returns { key: 'value' } + * identity({ key: 'value' }); + */ +declare function identity(): undefined; +//#endregion +export { identity }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/identity.js b/node_modules/es-toolkit/dist/compat/function/identity.js new file mode 100644 index 0000000000000000000000000000000000000000..553e2007afba9a4f623034d356ccb0b81e18ddc9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/identity.js @@ -0,0 +1,6 @@ +//#region src/compat/function/identity.ts +function identity(x) { + return x; +} +//#endregion +exports.identity = identity; diff --git a/node_modules/es-toolkit/dist/compat/function/identity.mjs b/node_modules/es-toolkit/dist/compat/function/identity.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9a3d0ac039823306713f4fc5dfdc87b91eff5d48 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/identity.mjs @@ -0,0 +1,6 @@ +//#region src/compat/function/identity.ts +function identity(x) { + return x; +} +//#endregion +export { identity }; diff --git a/node_modules/es-toolkit/dist/compat/function/memoize.d.mts b/node_modules/es-toolkit/dist/compat/function/memoize.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a8523c7038844a74e7f8caaa1802ddcf43be8bb2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/memoize.d.mts @@ -0,0 +1,120 @@ +//#region src/compat/function/memoize.d.ts +interface MapCache { + /** + * Removes the value associated with the specified key from the cache. + * + * @param key - The key of the value to remove + * @returns `true` if an element was removed, `false` if the key wasn't found + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }); + * cache.delete('user'); // Returns true + * cache.delete('unknown'); // Returns false + * ``` + */ + delete(key: any): boolean; + /** + * Retrieves the value associated with the specified key from the cache. + * + * @param key - The key of the value to retrieve + * @returns The cached value or undefined if not found + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }); + * cache.get('user'); // Returns { id: 123, name: 'John' } + * cache.get('unknown'); // Returns undefined + * ``` + */ + get(key: any): any; + /** + * Checks if the cache contains a value for the specified key. + * + * @param key - The key to check for existence + * @returns `true` if the key exists in the cache, otherwise `false` + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }); + * cache.has('user'); // Returns true + * cache.has('unknown'); // Returns false + * ``` + */ + has(key: any): boolean; + /** + * Stores a value in the cache with the specified key. + * If the key already exists, its value is updated. + * + * @param key - The key to associate with the value + * @param value - The value to store in the cache + * @returns The cache instance for method chaining + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }) + * .set('settings', { theme: 'dark' }); + * ``` + */ + set(key: any, value: any): this; + /** + * Removes all key-value pairs from the cache. + * This method is optional as some cache implementations may be immutable. + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }); + * cache.set('settings', { theme: 'dark' }); + * cache.clear(); // Cache is now empty + * ``` + */ + clear?(): void; +} +/** + * Constructor interface for creating a new MapCache instance. + * This defines the shape of a constructor that can create cache objects + * conforming to the MapCache interface. + * + * @example + * ```typescript + * class CustomCache implements MapCache { + * // Cache implementation + * } + * + * const CacheConstructor: MapCacheConstructor = CustomCache; + * const cache = new CacheConstructor(); + * ``` + */ +interface MapCacheConstructor { + new (): MapCache; +} +/** + * Represents a function that has been memoized. + * A memoized function maintains the same signature as the original function + * but adds a cache property to store previously computed results. + * + * @template T - The type of the original function being memoized + */ +interface MemoizedFunction { + /** + * The cache storing previously computed results + */ + cache: MapCache; +} +/** + * Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for + * storing the result based on the arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with + * the this binding of the memoized function. + * + * @template T - The type of the original function being memoized + * @param func The function to have its output memoized. + * @param [resolver] The function to resolve the cache key. + * @return {MemoizedFunction} Returns the new memoizing function. + */ +declare function memoize any>(func: T, resolver?: (...args: Parameters) => any): T & MemoizedFunction; +declare namespace memoize { + var Cache: MapCacheConstructor; +} +//#endregion +export { memoize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/memoize.d.ts b/node_modules/es-toolkit/dist/compat/function/memoize.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8523c7038844a74e7f8caaa1802ddcf43be8bb2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/memoize.d.ts @@ -0,0 +1,120 @@ +//#region src/compat/function/memoize.d.ts +interface MapCache { + /** + * Removes the value associated with the specified key from the cache. + * + * @param key - The key of the value to remove + * @returns `true` if an element was removed, `false` if the key wasn't found + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }); + * cache.delete('user'); // Returns true + * cache.delete('unknown'); // Returns false + * ``` + */ + delete(key: any): boolean; + /** + * Retrieves the value associated with the specified key from the cache. + * + * @param key - The key of the value to retrieve + * @returns The cached value or undefined if not found + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }); + * cache.get('user'); // Returns { id: 123, name: 'John' } + * cache.get('unknown'); // Returns undefined + * ``` + */ + get(key: any): any; + /** + * Checks if the cache contains a value for the specified key. + * + * @param key - The key to check for existence + * @returns `true` if the key exists in the cache, otherwise `false` + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }); + * cache.has('user'); // Returns true + * cache.has('unknown'); // Returns false + * ``` + */ + has(key: any): boolean; + /** + * Stores a value in the cache with the specified key. + * If the key already exists, its value is updated. + * + * @param key - The key to associate with the value + * @param value - The value to store in the cache + * @returns The cache instance for method chaining + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }) + * .set('settings', { theme: 'dark' }); + * ``` + */ + set(key: any, value: any): this; + /** + * Removes all key-value pairs from the cache. + * This method is optional as some cache implementations may be immutable. + * + * @example + * ```typescript + * cache.set('user', { id: 123, name: 'John' }); + * cache.set('settings', { theme: 'dark' }); + * cache.clear(); // Cache is now empty + * ``` + */ + clear?(): void; +} +/** + * Constructor interface for creating a new MapCache instance. + * This defines the shape of a constructor that can create cache objects + * conforming to the MapCache interface. + * + * @example + * ```typescript + * class CustomCache implements MapCache { + * // Cache implementation + * } + * + * const CacheConstructor: MapCacheConstructor = CustomCache; + * const cache = new CacheConstructor(); + * ``` + */ +interface MapCacheConstructor { + new (): MapCache; +} +/** + * Represents a function that has been memoized. + * A memoized function maintains the same signature as the original function + * but adds a cache property to store previously computed results. + * + * @template T - The type of the original function being memoized + */ +interface MemoizedFunction { + /** + * The cache storing previously computed results + */ + cache: MapCache; +} +/** + * Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for + * storing the result based on the arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with + * the this binding of the memoized function. + * + * @template T - The type of the original function being memoized + * @param func The function to have its output memoized. + * @param [resolver] The function to resolve the cache key. + * @return {MemoizedFunction} Returns the new memoizing function. + */ +declare function memoize any>(func: T, resolver?: (...args: Parameters) => any): T & MemoizedFunction; +declare namespace memoize { + var Cache: MapCacheConstructor; +} +//#endregion +export { memoize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/memoize.js b/node_modules/es-toolkit/dist/compat/function/memoize.js new file mode 100644 index 0000000000000000000000000000000000000000..89bc08e0d641c191f0951f527d04c58bd9970489 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/memoize.js @@ -0,0 +1,28 @@ +//#region src/compat/function/memoize.ts +/** +* Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for +* storing the result based on the arguments provided to the memoized function. By default, the first argument +* provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with +* the this binding of the memoized function. +* +* @template T - The type of the original function being memoized +* @param func The function to have its output memoized. +* @param [resolver] The function to resolve the cache key. +* @return {MemoizedFunction} Returns the new memoizing function. +*/ +function memoize(func, resolver) { + if (typeof func !== "function" || resolver != null && typeof resolver !== "function") throw new TypeError("Expected a function"); + const memoized = function(...args) { + const key = resolver ? resolver.apply(this, args) : args[0]; + const cache = memoized.cache; + if (cache.has(key)) return cache.get(key); + const result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || Map)(); + return memoized; +} +memoize.Cache = Map; +//#endregion +exports.memoize = memoize; diff --git a/node_modules/es-toolkit/dist/compat/function/memoize.mjs b/node_modules/es-toolkit/dist/compat/function/memoize.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2f06ba81110e9683e033e56e5364f063e3a11b93 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/memoize.mjs @@ -0,0 +1,28 @@ +//#region src/compat/function/memoize.ts +/** +* Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for +* storing the result based on the arguments provided to the memoized function. By default, the first argument +* provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with +* the this binding of the memoized function. +* +* @template T - The type of the original function being memoized +* @param func The function to have its output memoized. +* @param [resolver] The function to resolve the cache key. +* @return {MemoizedFunction} Returns the new memoizing function. +*/ +function memoize(func, resolver) { + if (typeof func !== "function" || resolver != null && typeof resolver !== "function") throw new TypeError("Expected a function"); + const memoized = function(...args) { + const key = resolver ? resolver.apply(this, args) : args[0]; + const cache = memoized.cache; + if (cache.has(key)) return cache.get(key); + const result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || Map)(); + return memoized; +} +memoize.Cache = Map; +//#endregion +export { memoize }; diff --git a/node_modules/es-toolkit/dist/compat/function/negate.d.mts b/node_modules/es-toolkit/dist/compat/function/negate.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f65e03cea3ba86d78b858c931b0693d8a0c1cfcd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/negate.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/function/negate.d.ts +/** + * Creates a function that negates the result of the predicate function. + * + * @template T - The type of the arguments array. + * @param predicate - The predicate to negate. + * @returns The new negated function. + * + * @example + * function isEven(n) { + * return n % 2 == 0; + * } + * + * filter([1, 2, 3, 4, 5, 6], negate(isEven)); + * // => [1, 3, 5] + */ +declare function negate(predicate: (...args: T) => boolean): (...args: T) => boolean; +//#endregion +export { negate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/negate.d.ts b/node_modules/es-toolkit/dist/compat/function/negate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f65e03cea3ba86d78b858c931b0693d8a0c1cfcd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/negate.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/function/negate.d.ts +/** + * Creates a function that negates the result of the predicate function. + * + * @template T - The type of the arguments array. + * @param predicate - The predicate to negate. + * @returns The new negated function. + * + * @example + * function isEven(n) { + * return n % 2 == 0; + * } + * + * filter([1, 2, 3, 4, 5, 6], negate(isEven)); + * // => [1, 3, 5] + */ +declare function negate(predicate: (...args: T) => boolean): (...args: T) => boolean; +//#endregion +export { negate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/negate.js b/node_modules/es-toolkit/dist/compat/function/negate.js new file mode 100644 index 0000000000000000000000000000000000000000..e4c72820c4007932344b84ce142f86d9f6611992 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/negate.js @@ -0,0 +1,22 @@ +//#region src/compat/function/negate.ts +/** +* Creates a function that negates the result of the predicate function. +* +* @template F - The type of the function to negate. +* @param func - The function to negate. +* @returns The new negated function, which negates the boolean result of `func`. +* +* @example +* const array = [1, 2, 3, 4, 5, 6]; +* const isEven = (n: number) => n % 2 === 0; +* const result = array.filter(negate(isEven)); +* // result will be [1, 3, 5] +*/ +function negate(func) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + return function(...args) { + return !func.apply(this, args); + }; +} +//#endregion +exports.negate = negate; diff --git a/node_modules/es-toolkit/dist/compat/function/negate.mjs b/node_modules/es-toolkit/dist/compat/function/negate.mjs new file mode 100644 index 0000000000000000000000000000000000000000..637dc84ba2a6a86afd9bf459f0a298364fb93c14 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/negate.mjs @@ -0,0 +1,22 @@ +//#region src/compat/function/negate.ts +/** +* Creates a function that negates the result of the predicate function. +* +* @template F - The type of the function to negate. +* @param func - The function to negate. +* @returns The new negated function, which negates the boolean result of `func`. +* +* @example +* const array = [1, 2, 3, 4, 5, 6]; +* const isEven = (n: number) => n % 2 === 0; +* const result = array.filter(negate(isEven)); +* // result will be [1, 3, 5] +*/ +function negate(func) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + return function(...args) { + return !func.apply(this, args); + }; +} +//#endregion +export { negate }; diff --git a/node_modules/es-toolkit/dist/compat/function/noop.d.mts b/node_modules/es-toolkit/dist/compat/function/noop.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..03e2b232028b670a825d3bf6fe4f73f436a62fd9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/noop.d.mts @@ -0,0 +1,13 @@ +//#region src/compat/function/noop.d.ts +/** + * A no-operation function that does nothing. + * This can be used as a placeholder or default function. + * + * @example + * noop(); // Does nothing + * + * @returns This function does not return anything. + */ +declare function noop(..._: any[]): void; +//#endregion +export { noop }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/noop.d.ts b/node_modules/es-toolkit/dist/compat/function/noop.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..03e2b232028b670a825d3bf6fe4f73f436a62fd9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/noop.d.ts @@ -0,0 +1,13 @@ +//#region src/compat/function/noop.d.ts +/** + * A no-operation function that does nothing. + * This can be used as a placeholder or default function. + * + * @example + * noop(); // Does nothing + * + * @returns This function does not return anything. + */ +declare function noop(..._: any[]): void; +//#endregion +export { noop }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/noop.js b/node_modules/es-toolkit/dist/compat/function/noop.js new file mode 100644 index 0000000000000000000000000000000000000000..b05041d375c708be24237f9662c97e8579952a97 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/noop.js @@ -0,0 +1,13 @@ +//#region src/compat/function/noop.ts +/** +* A no-operation function that does nothing. +* This can be used as a placeholder or default function. +* +* @example +* noop(); // Does nothing +* +* @returns This function does not return anything. +*/ +function noop(..._) {} +//#endregion +exports.noop = noop; diff --git a/node_modules/es-toolkit/dist/compat/function/noop.mjs b/node_modules/es-toolkit/dist/compat/function/noop.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c5bd04309c2c9c8c15a41af7e32cfb5ab56e7508 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/noop.mjs @@ -0,0 +1,13 @@ +//#region src/compat/function/noop.ts +/** +* A no-operation function that does nothing. +* This can be used as a placeholder or default function. +* +* @example +* noop(); // Does nothing +* +* @returns This function does not return anything. +*/ +function noop(..._) {} +//#endregion +export { noop }; diff --git a/node_modules/es-toolkit/dist/compat/function/nthArg.d.mts b/node_modules/es-toolkit/dist/compat/function/nthArg.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..5be167f0c96ede4b096c40ea0d21d89c788ba817 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/nthArg.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/function/nthArg.d.ts +/** + * Creates a function that gets the argument at index `n`. If `n` is negative, the nth argument from the end is returned. + * + * @param [n=0] - The index of the argument to return. + * @returns Returns the new function. + * + * @example + * var func = nthArg(1); + * func('a', 'b', 'c', 'd'); + * // => 'b' + * + * var func = nthArg(-2); + * func('a', 'b', 'c', 'd'); + * // => 'c' + */ +declare function nthArg(n?: number): (...args: any[]) => any; +//#endregion +export { nthArg }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/nthArg.d.ts b/node_modules/es-toolkit/dist/compat/function/nthArg.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5be167f0c96ede4b096c40ea0d21d89c788ba817 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/nthArg.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/function/nthArg.d.ts +/** + * Creates a function that gets the argument at index `n`. If `n` is negative, the nth argument from the end is returned. + * + * @param [n=0] - The index of the argument to return. + * @returns Returns the new function. + * + * @example + * var func = nthArg(1); + * func('a', 'b', 'c', 'd'); + * // => 'b' + * + * var func = nthArg(-2); + * func('a', 'b', 'c', 'd'); + * // => 'c' + */ +declare function nthArg(n?: number): (...args: any[]) => any; +//#endregion +export { nthArg }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/nthArg.js b/node_modules/es-toolkit/dist/compat/function/nthArg.js new file mode 100644 index 0000000000000000000000000000000000000000..43422c25f1caa554b060ebef529faeba3a3a21b9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/nthArg.js @@ -0,0 +1,28 @@ +const require_toInteger = require("../util/toInteger.js"); +//#region src/compat/function/nthArg.ts +/** +* Creates a function that retrieves the argument at the specified index `n`. +* +* If `n` is negative, the nth argument from the end is returned. +* +* @param [n=0] - The index of the argument to retrieve. +* If negative, counts from the end of the arguments list. +* @returns A new function that returns the argument at the specified index. +* +* @example +* const getSecondArg = nthArg(1); +* const result = getSecondArg('a', 'b', 'c'); +* console.log(result); // => 'b' +* +* @example +* const getLastArg = nthArg(-1); +* const result = getLastArg('a', 'b', 'c'); +* console.log(result); // => 'c' +*/ +function nthArg(n = 0) { + return function(...args) { + return args.at(require_toInteger.toInteger(n)); + }; +} +//#endregion +exports.nthArg = nthArg; diff --git a/node_modules/es-toolkit/dist/compat/function/nthArg.mjs b/node_modules/es-toolkit/dist/compat/function/nthArg.mjs new file mode 100644 index 0000000000000000000000000000000000000000..525e729790e2e1c104a873d9f2d9aa058b7aa095 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/nthArg.mjs @@ -0,0 +1,28 @@ +import { toInteger } from "../util/toInteger.mjs"; +//#region src/compat/function/nthArg.ts +/** +* Creates a function that retrieves the argument at the specified index `n`. +* +* If `n` is negative, the nth argument from the end is returned. +* +* @param [n=0] - The index of the argument to retrieve. +* If negative, counts from the end of the arguments list. +* @returns A new function that returns the argument at the specified index. +* +* @example +* const getSecondArg = nthArg(1); +* const result = getSecondArg('a', 'b', 'c'); +* console.log(result); // => 'b' +* +* @example +* const getLastArg = nthArg(-1); +* const result = getLastArg('a', 'b', 'c'); +* console.log(result); // => 'c' +*/ +function nthArg(n = 0) { + return function(...args) { + return args.at(toInteger(n)); + }; +} +//#endregion +export { nthArg }; diff --git a/node_modules/es-toolkit/dist/compat/function/once.d.mts b/node_modules/es-toolkit/dist/compat/function/once.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9a1438b14231d8f4b81fa493a057fca086e0bd8d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/once.d.mts @@ -0,0 +1,4 @@ +//#region src/compat/function/once.d.ts +declare function once any>(func: T): T; +//#endregion +export { once }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/once.d.ts b/node_modules/es-toolkit/dist/compat/function/once.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a1438b14231d8f4b81fa493a057fca086e0bd8d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/once.d.ts @@ -0,0 +1,4 @@ +//#region src/compat/function/once.d.ts +declare function once any>(func: T): T; +//#endregion +export { once }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/once.js b/node_modules/es-toolkit/dist/compat/function/once.js new file mode 100644 index 0000000000000000000000000000000000000000..123c819f08393571dbf7af7d36914dce0121bdeb --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/once.js @@ -0,0 +1,7 @@ +const require_once = require("../../function/once.js"); +//#region src/compat/function/once.ts +function once(func) { + return require_once.once(func); +} +//#endregion +exports.once = once; diff --git a/node_modules/es-toolkit/dist/compat/function/once.mjs b/node_modules/es-toolkit/dist/compat/function/once.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c7d5d0c0acaba5383f85dc147214b81a4442fce4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/once.mjs @@ -0,0 +1,7 @@ +import { once as once$1 } from "../../function/once.mjs"; +//#region src/compat/function/once.ts +function once(func) { + return once$1(func); +} +//#endregion +export { once }; diff --git a/node_modules/es-toolkit/dist/compat/function/overArgs.d.mts b/node_modules/es-toolkit/dist/compat/function/overArgs.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..455791c0df42272e6f8ae64b75e357c3e50cbc22 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/overArgs.d.mts @@ -0,0 +1,51 @@ +import { Many } from "../_internal/Many.mjs"; + +//#region src/compat/function/overArgs.d.ts +/** + * Creates a function that invokes `func` with its arguments transformed by corresponding transform functions. + * + * Transform functions can be: + * - Functions that accept and return a value + * - Property names (strings) to get a property value from each argument + * - Objects to check if arguments match the object properties + * - Arrays of [property, value] to check if argument properties match values + * + * If a transform is nullish, the identity function is used instead. + * Only transforms arguments up to the number of transform functions provided. + * + * @param func - The function to wrap + * @param transforms - The functions to transform arguments. Each transform can be: + * - A function that accepts and returns a value + * - A string to get a property value (e.g. 'name' gets the name property) + * - An object to check if arguments match its properties + * - An array of [property, value] to check property matches + * @returns A new function that transforms arguments before passing them to func + * @throws {TypeError} If func is not a function. + * @example + * ```ts + * function doubled(n: number) { + * return n * 2; + * } + * + * function square(n: number) { + * return n * n; + * } + * + * const func = overArgs((x, y) => [x, y], [doubled, square]); + * + * func(5, 3); + * // => [10, 9] + * + * // With property shorthand + * const user = { name: 'John', age: 30 }; + * const getUserInfo = overArgs( + * (name, age) => `${name} is ${age} years old`, + * ['name', 'age'] + * ); + * getUserInfo(user, user); + * // => "John is 30 years old" + * ``` + */ +declare function overArgs(func: (...args: any[]) => any, ..._transforms: Array any>>): (...args: any[]) => any; +//#endregion +export { overArgs }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/overArgs.d.ts b/node_modules/es-toolkit/dist/compat/function/overArgs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dd1ee87993d4ae2b2ba50aa1e824b45f588fa605 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/overArgs.d.ts @@ -0,0 +1,51 @@ +import { Many } from "../_internal/Many.js"; + +//#region src/compat/function/overArgs.d.ts +/** + * Creates a function that invokes `func` with its arguments transformed by corresponding transform functions. + * + * Transform functions can be: + * - Functions that accept and return a value + * - Property names (strings) to get a property value from each argument + * - Objects to check if arguments match the object properties + * - Arrays of [property, value] to check if argument properties match values + * + * If a transform is nullish, the identity function is used instead. + * Only transforms arguments up to the number of transform functions provided. + * + * @param func - The function to wrap + * @param transforms - The functions to transform arguments. Each transform can be: + * - A function that accepts and returns a value + * - A string to get a property value (e.g. 'name' gets the name property) + * - An object to check if arguments match its properties + * - An array of [property, value] to check property matches + * @returns A new function that transforms arguments before passing them to func + * @throws {TypeError} If func is not a function. + * @example + * ```ts + * function doubled(n: number) { + * return n * 2; + * } + * + * function square(n: number) { + * return n * n; + * } + * + * const func = overArgs((x, y) => [x, y], [doubled, square]); + * + * func(5, 3); + * // => [10, 9] + * + * // With property shorthand + * const user = { name: 'John', age: 30 }; + * const getUserInfo = overArgs( + * (name, age) => `${name} is ${age} years old`, + * ['name', 'age'] + * ); + * getUserInfo(user, user); + * // => "John is 30 years old" + * ``` + */ +declare function overArgs(func: (...args: any[]) => any, ..._transforms: Array any>>): (...args: any[]) => any; +//#endregion +export { overArgs }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/overArgs.js b/node_modules/es-toolkit/dist/compat/function/overArgs.js new file mode 100644 index 0000000000000000000000000000000000000000..4eaadb8cb57e727eb7defb4304ddc15b00ccc139 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/overArgs.js @@ -0,0 +1,60 @@ +const require_identity = require("../../function/identity.js"); +const require_iteratee = require("../util/iteratee.js"); +//#region src/compat/function/overArgs.ts +/** +* Creates a function that invokes `func` with its arguments transformed by corresponding transform functions. +* +* Transform functions can be: +* - Functions that accept and return a value +* - Property names (strings) to get a property value from each argument +* - Objects to check if arguments match the object properties +* - Arrays of [property, value] to check if argument properties match values +* +* If a transform is nullish, the identity function is used instead. +* Only transforms arguments up to the number of transform functions provided. +* +* @param func - The function to wrap +* @param transforms - The functions to transform arguments. Each transform can be: +* - A function that accepts and returns a value +* - A string to get a property value (e.g. 'name' gets the name property) +* - An object to check if arguments match its properties +* - An array of [property, value] to check property matches +* @returns A new function that transforms arguments before passing them to func +* @throws {TypeError} If func is not a function. +* @example +* ```ts +* function doubled(n: number) { +* return n * 2; +* } +* +* function square(n: number) { +* return n * n; +* } +* +* const func = overArgs((x, y) => [x, y], [doubled, square]); +* +* func(5, 3); +* // => [10, 9] +* +* // With property shorthand +* const user = { name: 'John', age: 30 }; +* const getUserInfo = overArgs( +* (name, age) => `${name} is ${age} years old`, +* ['name', 'age'] +* ); +* getUserInfo(user, user); +* // => "John is 30 years old" +* ``` +*/ +function overArgs(func, ..._transforms) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + const transforms = _transforms.flat(); + return function(...args) { + const length = Math.min(args.length, transforms.length); + const transformedArgs = [...args]; + for (let i = 0; i < length; i++) transformedArgs[i] = require_iteratee.iteratee(transforms[i] ?? require_identity.identity).call(this, args[i]); + return func.apply(this, transformedArgs); + }; +} +//#endregion +exports.overArgs = overArgs; diff --git a/node_modules/es-toolkit/dist/compat/function/overArgs.mjs b/node_modules/es-toolkit/dist/compat/function/overArgs.mjs new file mode 100644 index 0000000000000000000000000000000000000000..632236ee771fcf5291a86e1f717932a3416ddf2b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/overArgs.mjs @@ -0,0 +1,60 @@ +import { identity } from "../../function/identity.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +//#region src/compat/function/overArgs.ts +/** +* Creates a function that invokes `func` with its arguments transformed by corresponding transform functions. +* +* Transform functions can be: +* - Functions that accept and return a value +* - Property names (strings) to get a property value from each argument +* - Objects to check if arguments match the object properties +* - Arrays of [property, value] to check if argument properties match values +* +* If a transform is nullish, the identity function is used instead. +* Only transforms arguments up to the number of transform functions provided. +* +* @param func - The function to wrap +* @param transforms - The functions to transform arguments. Each transform can be: +* - A function that accepts and returns a value +* - A string to get a property value (e.g. 'name' gets the name property) +* - An object to check if arguments match its properties +* - An array of [property, value] to check property matches +* @returns A new function that transforms arguments before passing them to func +* @throws {TypeError} If func is not a function. +* @example +* ```ts +* function doubled(n: number) { +* return n * 2; +* } +* +* function square(n: number) { +* return n * n; +* } +* +* const func = overArgs((x, y) => [x, y], [doubled, square]); +* +* func(5, 3); +* // => [10, 9] +* +* // With property shorthand +* const user = { name: 'John', age: 30 }; +* const getUserInfo = overArgs( +* (name, age) => `${name} is ${age} years old`, +* ['name', 'age'] +* ); +* getUserInfo(user, user); +* // => "John is 30 years old" +* ``` +*/ +function overArgs(func, ..._transforms) { + if (typeof func !== "function") throw new TypeError("Expected a function"); + const transforms = _transforms.flat(); + return function(...args) { + const length = Math.min(args.length, transforms.length); + const transformedArgs = [...args]; + for (let i = 0; i < length; i++) transformedArgs[i] = iteratee(transforms[i] ?? identity).call(this, args[i]); + return func.apply(this, transformedArgs); + }; +} +//#endregion +export { overArgs }; diff --git a/node_modules/es-toolkit/dist/compat/function/partial.d.mts b/node_modules/es-toolkit/dist/compat/function/partial.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..dc1fa695413d7031bb149fbc7503bb1ec91b7518 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/partial.d.mts @@ -0,0 +1,205 @@ +import { Toolkit } from "../toolkit.mjs"; + +//#region src/compat/function/partial.d.ts +type __ = Placeholder | Toolkit; +/** + * 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. + * + * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}`; + * const sayHello = partial(greet, _, 'world'); + * console.log(sayHello('Hello')); // => 'Hello world' + */ +declare function partial(func: (t1: T1, t2: T2) => R, plc1: __, arg2: T2): (t1: T1) => R; +/** + * 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. + * + * @example + * const calculate = (x: number, y: number, z: number) => x + y + z; + * const addToY = partial(calculate, _, 2); + * console.log(addToY(1, 3)); // => 6 + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3) => R, plc1: __, arg2: T2): (t1: T1, t3: T3) => R; +/** + * 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. + * + * @example + * const calculate = (x: number, y: number, z: number) => x + y + z; + * const addZ = partial(calculate, _, _, 3); + * console.log(addZ(1, 2)); // => 6 + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3) => R, plc1: __, plc2: __, arg3: T3): (t1: T1, t2: T2) => R; +/** + * 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. + * + * @example + * const calculate = (x: number, y: number, z: number) => x + y + z; + * const withXandZ = partial(calculate, 1, _, 3); + * console.log(withXandZ(2)); // => 6 + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, plc2: __, arg3: T3): (t2: T2) => R; +/** + * 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. + * + * @example + * const calculate = (x: number, y: number, z: number) => x + y + z; + * const withYandZ = partial(calculate, _, 2, 3); + * console.log(withYandZ(1)); // => 6 + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3) => R, plc1: __, arg2: T2, arg3: T3): (t1: T1) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withB = partial(format, _, 'b'); + * console.log(withB('a', 'c', 'd')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, arg2: T2): (t1: T1, t3: T3, t4: T4) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withC = partial(format, _, _, 'c'); + * console.log(withC('a', 'b', 'd')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, plc2: __, arg3: T3): (t1: T1, t2: T2, t4: T4) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withAandC = partial(format, 'a', _, 'c'); + * console.log(withAandC('b', 'd')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3): (t2: T2, t4: T4) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withBandC = partial(format, _, 'b', 'c'); + * console.log(withBandC('a', 'd')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, arg2: T2, arg3: T3): (t1: T1, t4: T4) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withD = partial(format, _, _, _, 'd'); + * console.log(withD('a', 'b', 'c')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, plc2: __, plc3: __, arg4: T4): (t1: T1, t2: T2, t3: T3) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withAandD = partial(format, 'a', _, _, 'd'); + * console.log(withAandD('b', 'c')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, plc3: __, arg4: T4): (t2: T2, t3: T3) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withBandD = partial(format, _, 'b', _, 'd'); + * console.log(withBandD('a', 'c')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, arg2: T2, plc3: __, arg4: T4): (t1: T1, t3: T3) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withABandD = partial(format, 'a', 'b', _, 'd'); + * console.log(withABandD('c')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, plc3: __, arg4: T4): (t3: T3) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withCandD = partial(format, _, _, 'c', 'd'); + * console.log(withCandD('a', 'b')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, plc2: __, arg3: T3, arg4: T4): (t1: T1, t2: T2) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withACandD = partial(format, 'a', _, 'c', 'd'); + * console.log(withACandD('b')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3, arg4: T4): (t2: T2) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withBCandD = partial(format, _, 'b', 'c', 'd'); + * console.log(withBCandD('a')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, arg2: T2, arg3: T3, arg4: T4): (t1: T1) => R; +/** + * 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. + * + * @example + * const sum = (...numbers: number[]) => numbers.reduce((a, b) => a + b, 0); + * const partialSum = partial(sum); + * console.log(partialSum(1, 2, 3)); // => 6 + */ +declare function partial(func: (...ts: TS) => R): (...ts: TS) => R; +/** + * 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. + * + * @example + * const log = (prefix: string, ...messages: string[]) => console.log(prefix, ...messages); + * const debugLog = partial(log, '[DEBUG]'); + * debugLog('message 1', 'message 2'); // => '[DEBUG] message 1 message 2' + */ +declare function partial(func: (t1: T1, ...ts: TS) => R, arg1: T1): (...ts: TS) => R; +/** + * 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. + * + * @example + * const format = (prefix: string, separator: string, ...messages: string[]) => `${prefix}${messages.join(separator)}`; + * const logWithPrefix = partial(format, '[LOG]', ' - '); + * console.log(logWithPrefix('msg1', 'msg2')); // => '[LOG]msg1 - msg2' + */ +declare function partial(func: (t1: T1, t2: T2, ...ts: TS) => R, t1: T1, t2: T2): (...ts: TS) => R; +/** + * 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. + * + * @example + * const format = (type: string, level: string, message: string, ...tags: string[]) => + * `[${type}][${level}] ${message} ${tags.join(',')}`; + * const errorLog = partial(format, 'ERROR', 'HIGH', 'Something went wrong'); + * console.log(errorLog('critical', 'urgent')); // => '[ERROR][HIGH] Something went wrong critical,urgent' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, ...ts: TS) => R, t1: T1, t2: T2, t3: T3): (...ts: TS) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string, ...rest: string[]) => + * `${a}-${b}-${c}-${d}:${rest.join(',')}`; + * const prefixedFormat = partial(format, 'a', 'b', 'c', 'd'); + * console.log(prefixedFormat('e', 'f')); // => 'a-b-c-d:e,f' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4, ...ts: TS) => R, t1: T1, t2: T2, t3: T3, t4: T4): (...ts: TS) => R; +declare namespace partial { + var placeholder: Placeholder; +} +type Placeholder = symbol | (((value: any) => any) & { + partial: typeof partial; +}); +//#endregion +export { partial }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/partial.d.ts b/node_modules/es-toolkit/dist/compat/function/partial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d3b444a8b1620ae59937e5d8677ff9c0c451cd8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/partial.d.ts @@ -0,0 +1,205 @@ +import { Toolkit } from "../toolkit.js"; + +//#region src/compat/function/partial.d.ts +type __ = Placeholder | Toolkit; +/** + * 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. + * + * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}`; + * const sayHello = partial(greet, _, 'world'); + * console.log(sayHello('Hello')); // => 'Hello world' + */ +declare function partial(func: (t1: T1, t2: T2) => R, plc1: __, arg2: T2): (t1: T1) => R; +/** + * 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. + * + * @example + * const calculate = (x: number, y: number, z: number) => x + y + z; + * const addToY = partial(calculate, _, 2); + * console.log(addToY(1, 3)); // => 6 + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3) => R, plc1: __, arg2: T2): (t1: T1, t3: T3) => R; +/** + * 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. + * + * @example + * const calculate = (x: number, y: number, z: number) => x + y + z; + * const addZ = partial(calculate, _, _, 3); + * console.log(addZ(1, 2)); // => 6 + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3) => R, plc1: __, plc2: __, arg3: T3): (t1: T1, t2: T2) => R; +/** + * 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. + * + * @example + * const calculate = (x: number, y: number, z: number) => x + y + z; + * const withXandZ = partial(calculate, 1, _, 3); + * console.log(withXandZ(2)); // => 6 + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, plc2: __, arg3: T3): (t2: T2) => R; +/** + * 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. + * + * @example + * const calculate = (x: number, y: number, z: number) => x + y + z; + * const withYandZ = partial(calculate, _, 2, 3); + * console.log(withYandZ(1)); // => 6 + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3) => R, plc1: __, arg2: T2, arg3: T3): (t1: T1) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withB = partial(format, _, 'b'); + * console.log(withB('a', 'c', 'd')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, arg2: T2): (t1: T1, t3: T3, t4: T4) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withC = partial(format, _, _, 'c'); + * console.log(withC('a', 'b', 'd')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, plc2: __, arg3: T3): (t1: T1, t2: T2, t4: T4) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withAandC = partial(format, 'a', _, 'c'); + * console.log(withAandC('b', 'd')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3): (t2: T2, t4: T4) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withBandC = partial(format, _, 'b', 'c'); + * console.log(withBandC('a', 'd')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, arg2: T2, arg3: T3): (t1: T1, t4: T4) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withD = partial(format, _, _, _, 'd'); + * console.log(withD('a', 'b', 'c')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, plc2: __, plc3: __, arg4: T4): (t1: T1, t2: T2, t3: T3) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withAandD = partial(format, 'a', _, _, 'd'); + * console.log(withAandD('b', 'c')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, plc3: __, arg4: T4): (t2: T2, t3: T3) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withBandD = partial(format, _, 'b', _, 'd'); + * console.log(withBandD('a', 'c')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, arg2: T2, plc3: __, arg4: T4): (t1: T1, t3: T3) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withABandD = partial(format, 'a', 'b', _, 'd'); + * console.log(withABandD('c')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, plc3: __, arg4: T4): (t3: T3) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withCandD = partial(format, _, _, 'c', 'd'); + * console.log(withCandD('a', 'b')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, plc2: __, arg3: T3, arg4: T4): (t1: T1, t2: T2) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withACandD = partial(format, 'a', _, 'c', 'd'); + * console.log(withACandD('b')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3, arg4: T4): (t2: T2) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string) => `${a}-${b}-${c}-${d}`; + * const withBCandD = partial(format, _, 'b', 'c', 'd'); + * console.log(withBCandD('a')); // => 'a-b-c-d' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, plc1: __, arg2: T2, arg3: T3, arg4: T4): (t1: T1) => R; +/** + * 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. + * + * @example + * const sum = (...numbers: number[]) => numbers.reduce((a, b) => a + b, 0); + * const partialSum = partial(sum); + * console.log(partialSum(1, 2, 3)); // => 6 + */ +declare function partial(func: (...ts: TS) => R): (...ts: TS) => R; +/** + * 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. + * + * @example + * const log = (prefix: string, ...messages: string[]) => console.log(prefix, ...messages); + * const debugLog = partial(log, '[DEBUG]'); + * debugLog('message 1', 'message 2'); // => '[DEBUG] message 1 message 2' + */ +declare function partial(func: (t1: T1, ...ts: TS) => R, arg1: T1): (...ts: TS) => R; +/** + * 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. + * + * @example + * const format = (prefix: string, separator: string, ...messages: string[]) => `${prefix}${messages.join(separator)}`; + * const logWithPrefix = partial(format, '[LOG]', ' - '); + * console.log(logWithPrefix('msg1', 'msg2')); // => '[LOG]msg1 - msg2' + */ +declare function partial(func: (t1: T1, t2: T2, ...ts: TS) => R, t1: T1, t2: T2): (...ts: TS) => R; +/** + * 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. + * + * @example + * const format = (type: string, level: string, message: string, ...tags: string[]) => + * `[${type}][${level}] ${message} ${tags.join(',')}`; + * const errorLog = partial(format, 'ERROR', 'HIGH', 'Something went wrong'); + * console.log(errorLog('critical', 'urgent')); // => '[ERROR][HIGH] Something went wrong critical,urgent' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, ...ts: TS) => R, t1: T1, t2: T2, t3: T3): (...ts: TS) => R; +/** + * 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. + * + * @example + * const format = (a: string, b: string, c: string, d: string, ...rest: string[]) => + * `${a}-${b}-${c}-${d}:${rest.join(',')}`; + * const prefixedFormat = partial(format, 'a', 'b', 'c', 'd'); + * console.log(prefixedFormat('e', 'f')); // => 'a-b-c-d:e,f' + */ +declare function partial(func: (t1: T1, t2: T2, t3: T3, t4: T4, ...ts: TS) => R, t1: T1, t2: T2, t3: T3, t4: T4): (...ts: TS) => R; +declare namespace partial { + var placeholder: Placeholder; +} +type Placeholder = symbol | (((value: any) => any) & { + partial: typeof partial; +}); +//#endregion +export { partial }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/partial.js b/node_modules/es-toolkit/dist/compat/function/partial.js new file mode 100644 index 0000000000000000000000000000000000000000..ca43a570c794ab541e07654f4d84176c2f3d9256 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/partial.js @@ -0,0 +1,34 @@ +const require_partial = require("../../function/partial.js"); +//#region src/compat/function/partial.ts +/** +* 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. +* +* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: This method doesn't set the `length` property of partially applied functions. +* +* @template F The type of the function to partially apply. +* @param func The function to partially apply arguments to. +* @param partialArgs The arguments to be partially applied. +* @returns Returns the new partially applied function. +* +* @example +* function greet(greeting, name) { +* return greeting + ' ' + name; +* } +* +* const sayHelloTo = partial(greet, 'hello'); +* sayHelloTo('fred'); +* // => 'hello fred' +* +* // Partially applied with placeholders. +* const greetFred = partial(greet, partial.placeholder, 'fred'); +* greetFred('hi'); +* // => 'hi fred' +*/ +function partial(func, ...partialArgs) { + return require_partial.partialImpl(func, partial.placeholder, ...partialArgs); +} +partial.placeholder = Symbol("compat.partial.placeholder"); +//#endregion +exports.partial = partial; diff --git a/node_modules/es-toolkit/dist/compat/function/partial.mjs b/node_modules/es-toolkit/dist/compat/function/partial.mjs new file mode 100644 index 0000000000000000000000000000000000000000..442e8d12d1dd5098781958952186fb7e712ea711 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/partial.mjs @@ -0,0 +1,34 @@ +import { partialImpl } from "../../function/partial.mjs"; +//#region src/compat/function/partial.ts +/** +* 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. +* +* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: This method doesn't set the `length` property of partially applied functions. +* +* @template F The type of the function to partially apply. +* @param func The function to partially apply arguments to. +* @param partialArgs The arguments to be partially applied. +* @returns Returns the new partially applied function. +* +* @example +* function greet(greeting, name) { +* return greeting + ' ' + name; +* } +* +* const sayHelloTo = partial(greet, 'hello'); +* sayHelloTo('fred'); +* // => 'hello fred' +* +* // Partially applied with placeholders. +* const greetFred = partial(greet, partial.placeholder, 'fred'); +* greetFred('hi'); +* // => 'hi fred' +*/ +function partial(func, ...partialArgs) { + return partialImpl(func, partial.placeholder, ...partialArgs); +} +partial.placeholder = Symbol("compat.partial.placeholder"); +//#endregion +export { partial }; diff --git a/node_modules/es-toolkit/dist/compat/function/partialRight.d.mts b/node_modules/es-toolkit/dist/compat/function/partialRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..388b58926bfa9e5272ee7f771afa7d2925586fe0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/partialRight.d.mts @@ -0,0 +1,623 @@ +import { Toolkit } from "../toolkit.mjs"; + +//#region src/compat/function/partialRight.d.ts +type __ = Placeholder | Toolkit; +/** + * Creates a function that invokes the provided function with no arguments. + * + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const greet = () => 'Hello!'; + * const sayHello = partialRight(greet); + * sayHello(); // => 'Hello!' + */ +declare function partialRight(func: () => R): () => R; +/** + * Creates a function that invokes the provided function with one argument. + * + * @template T The type of the argument + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const greet = (name: string) => `Hello ${name}!`; + * const greetPerson = partialRight(greet); + * greetPerson('Fred'); // => 'Hello Fred!' + */ +declare function partialRight(func: (t1: T) => R): (t1: T) => R; +/** + * Creates a function that invokes the provided function with one argument pre-filled. + * + * @template T The type of the argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (name: string) => `Hello ${name}!`; + * const greetFred = partialRight(greet, 'Fred'); + * greetFred(); // => 'Hello Fred!' + */ +declare function partialRight(func: (t1: T) => R, arg1: T): () => R; +/** + * Creates a function that invokes the provided function with two arguments. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}!`; + * const greetWithParams = partialRight(greet); + * greetWithParams('Hi', 'Fred'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2) => R): (t1: T1, t2: T2) => R; +/** + * Creates a function that invokes the provided function with one argument pre-filled and a placeholder. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The argument to pre-fill + * @param plc2 The placeholder for the second argument + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}!`; + * const hiWithName = partialRight(greet, 'Hi', partialRight.placeholder); + * hiWithName('Fred'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2) => R, arg1: T1, plc2: __): (t2: T2) => R; +/** + * Creates a function that invokes the provided function with the second argument pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}!`; + * const greetFred = partialRight(greet, 'Fred'); + * greetFred('Hi'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2) => R, arg2: T2): (t1: T1) => R; +/** + * Creates a function that invokes the provided function with both arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}!`; + * const sayHiToFred = partialRight(greet, 'Hi', 'Fred'); + * sayHiToFred(); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2) => R, arg1: T1, arg2: T2): () => R; +/** + * Creates a function that invokes the provided function with no pre-filled arguments. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const greetWithArgs = partialRight(greet); + * greetWithArgs('Hi', 'Fred', '!'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R): (t1: T1, t2: T2, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the first argument pre-filled and placeholders for the rest. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param plc3 The placeholder for the third argument + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const hiWithNameAndPunc = partialRight(greet, 'Hi', partialRight.placeholder, partialRight.placeholder); + * hiWithNameAndPunc('Fred', '!'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, plc2: __, plc3: __): (t2: T2, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the second argument pre-filled and a placeholder for the third. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const greetFredWithPunc = partialRight(greet, 'Fred', partialRight.placeholder); + * greetFredWithPunc('Hi', '!'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg2: T2, plc3: __): (t1: T1, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the first two arguments pre-filled and a placeholder for the third. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const hiToFredWithPunc = partialRight(greet, 'Hi', 'Fred', partialRight.placeholder); + * hiToFredWithPunc('!'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, arg2: T2, plc3: __): (t3: T3) => R; +/** + * Creates a function that invokes the provided function with the third argument pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg3 The third argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const greetWithExclamation = partialRight(greet, '!'); + * greetWithExclamation('Hi', 'Fred'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg3: T3): (t1: T1, t2: T2) => R; +/** + * Creates a function that invokes the provided function with the first and third arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param arg3 The third argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const hiWithNameAndExclamation = partialRight(greet, 'Hi', partialRight.placeholder, '!'); + * hiWithNameAndExclamation('Fred'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, plc2: __, arg3: T3): (t2: T2) => R; +/** + * Creates a function that invokes the provided function with the second and third arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const greetFredWithExclamation = partialRight(greet, 'Fred', '!'); + * greetFredWithExclamation('Hi'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg2: T2, arg3: T3): (t1: T1) => R; +/** + * Creates a function that invokes the provided function with all three arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const sayHiToFredWithExclamation = partialRight(greet, 'Hi', 'Fred', '!'); + * sayHiToFredWithExclamation(); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, arg2: T2, arg3: T3): () => R; +/** + * Creates a function that invokes the provided function with no pre-filled arguments. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const formatWithArgs = partialRight(format); + * formatWithArgs('Hi', 'Fred', 'morning', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R): (t1: T1, t2: T2, t3: T3, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the first argument pre-filled and placeholders for the rest. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param plc3 The placeholder for the third argument + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiWithRest = partialRight(format, 'Hi', partialRight.placeholder, partialRight.placeholder, partialRight.placeholder); + * hiWithRest('Fred', 'morning', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, plc3: __, plc4: __): (t2: T2, t3: T3, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the second argument pre-filled and placeholders for the rest. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const greetFredWithRest = partialRight(format, 'Fred', partialRight.placeholder, partialRight.placeholder); + * greetFredWithRest('Hi', 'morning', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, plc3: __, plc4: __): (t1: T1, t3: T3, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the first two arguments pre-filled and placeholders for the rest. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiToFredWithRest = partialRight(format, 'Hi', 'Fred', partialRight.placeholder, partialRight.placeholder); + * hiToFredWithRest('morning', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, plc3: __, plc4: __): (t3: T3, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the third argument pre-filled and a placeholder for the fourth. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg3 The third argument to pre-fill + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const atMorningWithPunc = partialRight(format, 'morning', partialRight.placeholder); + * atMorningWithPunc('Hi', 'Fred', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg3: T3, plc4: __): (t1: T1, t2: T2, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the first and third arguments pre-filled and a placeholder for the fourth. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param arg3 The third argument to pre-fill + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiAtMorningWithNameAndPunc = partialRight(format, 'Hi', partialRight.placeholder, 'morning', partialRight.placeholder); + * hiAtMorningWithNameAndPunc('Fred', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3, plc4: __): (t2: T2, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the second and third arguments pre-filled and a placeholder for the fourth. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const greetFredAtMorningWithPunc = partialRight(format, 'Fred', 'morning', partialRight.placeholder); + * greetFredAtMorningWithPunc('Hi', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, arg3: T3, plc4: __): (t1: T1, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the first three arguments pre-filled and a placeholder for the fourth. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiToFredAtMorningWithPunc = partialRight(format, 'Hi', 'Fred', 'morning', partialRight.placeholder); + * hiToFredAtMorningWithPunc('!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, arg3: T3, plc4: __): (t4: T4) => R; +/** + * Creates a function that invokes the provided function with the fourth argument pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const withExclamation = partialRight(format, '!'); + * withExclamation('Hi', 'Fred', 'morning'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg4: T4): (t1: T1, t2: T2, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the first and fourth arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param plc3 The placeholder for the third argument + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiWithExclamation = partialRight(format, 'Hi', partialRight.placeholder, partialRight.placeholder, '!'); + * hiWithExclamation('Fred', 'morning'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, plc3: __, arg4: T4): (t2: T2, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the second and fourth arguments pre-filled and a placeholder for the third. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const greetFredWithTime = partialRight(format, 'Fred', partialRight.placeholder, '!'); + * greetFredWithTime('Hi', 'morning'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, plc3: __, arg4: T4): (t1: T1, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the first, second and fourth arguments pre-filled and a placeholder for the third. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiToFredWithTime = partialRight(format, 'Hi', 'Fred', partialRight.placeholder, '!'); + * hiToFredWithTime('morning'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, plc3: __, arg4: T4): (t3: T3) => R; +/** + * Creates a function that invokes the provided function with the third and fourth arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg3 The third argument to pre-fill + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const inMorningWithExclamation = partialRight(format, 'morning', '!'); + * inMorningWithExclamation('Hi', 'Fred'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg3: T3, arg4: T4): (t1: T1, t2: T2) => R; +/** + * Creates a function that invokes the provided function with the first, third and fourth arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param arg3 The third argument to pre-fill + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiInMorningWithExclamation = partialRight(format, 'Hi', partialRight.placeholder, 'morning', '!'); + * hiInMorningWithExclamation('Fred'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3, arg4: T4): (t2: T2) => R; +/** + * Creates a function that invokes the provided function with the second, third and fourth arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const greetFredInMorningWithExclamation = partialRight(format, 'Fred', 'morning', '!'); + * greetFredInMorningWithExclamation('Hi'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, arg3: T3, arg4: T4): (t1: T1) => R; +/** + * Creates a function that invokes the provided function with all arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const sayHiToFredInMorningWithExclamation = partialRight(format, 'Hi', 'Fred', 'morning', '!'); + * sayHiToFredInMorningWithExclamation(); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, arg3: T3, arg4: T4): () => R; +/** + * Creates a function that invokes the provided function with partially applied arguments appended to the arguments it receives. + * The partialRight.placeholder value can be used as a placeholder for partially applied arguments. + * + * @template F The type of the function to partially apply + * @param func The function to partially apply arguments to + * @param args The arguments to be partially applied + * @returns Returns the new partially applied function + * + * @example + * function greet(greeting: string, name: string) { + * return greeting + ' ' + name; + * } + * + * const greetFred = partialRight(greet, 'Fred'); + * greetFred('Hi'); // => 'Hi Fred' + * + * // Using placeholders + * const sayHelloTo = partialRight(greet, 'Hello', partialRight.placeholder); + * sayHelloTo('Fred'); // => 'Hello Fred' + */ +declare function partialRight(func: (...args: any[]) => any, ...args: any[]): (...args: any[]) => any; +declare namespace partialRight { + var placeholder: Placeholder; +} +type Placeholder = symbol | (((value: any) => any) & { + partialRight: typeof partialRight; +}); +//#endregion +export { partialRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/partialRight.d.ts b/node_modules/es-toolkit/dist/compat/function/partialRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..574981b4f645eed674180838a4be51fb63494688 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/partialRight.d.ts @@ -0,0 +1,623 @@ +import { Toolkit } from "../toolkit.js"; + +//#region src/compat/function/partialRight.d.ts +type __ = Placeholder | Toolkit; +/** + * Creates a function that invokes the provided function with no arguments. + * + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const greet = () => 'Hello!'; + * const sayHello = partialRight(greet); + * sayHello(); // => 'Hello!' + */ +declare function partialRight(func: () => R): () => R; +/** + * Creates a function that invokes the provided function with one argument. + * + * @template T The type of the argument + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const greet = (name: string) => `Hello ${name}!`; + * const greetPerson = partialRight(greet); + * greetPerson('Fred'); // => 'Hello Fred!' + */ +declare function partialRight(func: (t1: T) => R): (t1: T) => R; +/** + * Creates a function that invokes the provided function with one argument pre-filled. + * + * @template T The type of the argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (name: string) => `Hello ${name}!`; + * const greetFred = partialRight(greet, 'Fred'); + * greetFred(); // => 'Hello Fred!' + */ +declare function partialRight(func: (t1: T) => R, arg1: T): () => R; +/** + * Creates a function that invokes the provided function with two arguments. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}!`; + * const greetWithParams = partialRight(greet); + * greetWithParams('Hi', 'Fred'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2) => R): (t1: T1, t2: T2) => R; +/** + * Creates a function that invokes the provided function with one argument pre-filled and a placeholder. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The argument to pre-fill + * @param plc2 The placeholder for the second argument + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}!`; + * const hiWithName = partialRight(greet, 'Hi', partialRight.placeholder); + * hiWithName('Fred'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2) => R, arg1: T1, plc2: __): (t2: T2) => R; +/** + * Creates a function that invokes the provided function with the second argument pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}!`; + * const greetFred = partialRight(greet, 'Fred'); + * greetFred('Hi'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2) => R, arg2: T2): (t1: T1) => R; +/** + * Creates a function that invokes the provided function with both arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string) => `${greeting} ${name}!`; + * const sayHiToFred = partialRight(greet, 'Hi', 'Fred'); + * sayHiToFred(); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2) => R, arg1: T1, arg2: T2): () => R; +/** + * Creates a function that invokes the provided function with no pre-filled arguments. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const greetWithArgs = partialRight(greet); + * greetWithArgs('Hi', 'Fred', '!'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R): (t1: T1, t2: T2, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the first argument pre-filled and placeholders for the rest. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param plc3 The placeholder for the third argument + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const hiWithNameAndPunc = partialRight(greet, 'Hi', partialRight.placeholder, partialRight.placeholder); + * hiWithNameAndPunc('Fred', '!'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, plc2: __, plc3: __): (t2: T2, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the second argument pre-filled and a placeholder for the third. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const greetFredWithPunc = partialRight(greet, 'Fred', partialRight.placeholder); + * greetFredWithPunc('Hi', '!'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg2: T2, plc3: __): (t1: T1, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the first two arguments pre-filled and a placeholder for the third. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const hiToFredWithPunc = partialRight(greet, 'Hi', 'Fred', partialRight.placeholder); + * hiToFredWithPunc('!'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, arg2: T2, plc3: __): (t3: T3) => R; +/** + * Creates a function that invokes the provided function with the third argument pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg3 The third argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const greetWithExclamation = partialRight(greet, '!'); + * greetWithExclamation('Hi', 'Fred'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg3: T3): (t1: T1, t2: T2) => R; +/** + * Creates a function that invokes the provided function with the first and third arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param arg3 The third argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const hiWithNameAndExclamation = partialRight(greet, 'Hi', partialRight.placeholder, '!'); + * hiWithNameAndExclamation('Fred'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, plc2: __, arg3: T3): (t2: T2) => R; +/** + * Creates a function that invokes the provided function with the second and third arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const greetFredWithExclamation = partialRight(greet, 'Fred', '!'); + * greetFredWithExclamation('Hi'); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg2: T2, arg3: T3): (t1: T1) => R; +/** + * Creates a function that invokes the provided function with all three arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`; + * const sayHiToFredWithExclamation = partialRight(greet, 'Hi', 'Fred', '!'); + * sayHiToFredWithExclamation(); // => 'Hi Fred!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, arg2: T2, arg3: T3): () => R; +/** + * Creates a function that invokes the provided function with no pre-filled arguments. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const formatWithArgs = partialRight(format); + * formatWithArgs('Hi', 'Fred', 'morning', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R): (t1: T1, t2: T2, t3: T3, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the first argument pre-filled and placeholders for the rest. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param plc3 The placeholder for the third argument + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiWithRest = partialRight(format, 'Hi', partialRight.placeholder, partialRight.placeholder, partialRight.placeholder); + * hiWithRest('Fred', 'morning', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, plc3: __, plc4: __): (t2: T2, t3: T3, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the second argument pre-filled and placeholders for the rest. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const greetFredWithRest = partialRight(format, 'Fred', partialRight.placeholder, partialRight.placeholder); + * greetFredWithRest('Hi', 'morning', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, plc3: __, plc4: __): (t1: T1, t3: T3, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the first two arguments pre-filled and placeholders for the rest. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiToFredWithRest = partialRight(format, 'Hi', 'Fred', partialRight.placeholder, partialRight.placeholder); + * hiToFredWithRest('morning', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, plc3: __, plc4: __): (t3: T3, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the third argument pre-filled and a placeholder for the fourth. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg3 The third argument to pre-fill + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const atMorningWithPunc = partialRight(format, 'morning', partialRight.placeholder); + * atMorningWithPunc('Hi', 'Fred', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg3: T3, plc4: __): (t1: T1, t2: T2, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the first and third arguments pre-filled and a placeholder for the fourth. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param arg3 The third argument to pre-fill + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiAtMorningWithNameAndPunc = partialRight(format, 'Hi', partialRight.placeholder, 'morning', partialRight.placeholder); + * hiAtMorningWithNameAndPunc('Fred', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3, plc4: __): (t2: T2, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the second and third arguments pre-filled and a placeholder for the fourth. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const greetFredAtMorningWithPunc = partialRight(format, 'Fred', 'morning', partialRight.placeholder); + * greetFredAtMorningWithPunc('Hi', '!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, arg3: T3, plc4: __): (t1: T1, t4: T4) => R; +/** + * Creates a function that invokes the provided function with the first three arguments pre-filled and a placeholder for the fourth. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @param plc4 The placeholder for the fourth argument + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiToFredAtMorningWithPunc = partialRight(format, 'Hi', 'Fred', 'morning', partialRight.placeholder); + * hiToFredAtMorningWithPunc('!'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, arg3: T3, plc4: __): (t4: T4) => R; +/** + * Creates a function that invokes the provided function with the fourth argument pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const withExclamation = partialRight(format, '!'); + * withExclamation('Hi', 'Fred', 'morning'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg4: T4): (t1: T1, t2: T2, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the first and fourth arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param plc3 The placeholder for the third argument + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiWithExclamation = partialRight(format, 'Hi', partialRight.placeholder, partialRight.placeholder, '!'); + * hiWithExclamation('Fred', 'morning'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, plc3: __, arg4: T4): (t2: T2, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the second and fourth arguments pre-filled and a placeholder for the third. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const greetFredWithTime = partialRight(format, 'Fred', partialRight.placeholder, '!'); + * greetFredWithTime('Hi', 'morning'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, plc3: __, arg4: T4): (t1: T1, t3: T3) => R; +/** + * Creates a function that invokes the provided function with the first, second and fourth arguments pre-filled and a placeholder for the third. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param plc3 The placeholder for the third argument + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiToFredWithTime = partialRight(format, 'Hi', 'Fred', partialRight.placeholder, '!'); + * hiToFredWithTime('morning'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, plc3: __, arg4: T4): (t3: T3) => R; +/** + * Creates a function that invokes the provided function with the third and fourth arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg3 The third argument to pre-fill + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const inMorningWithExclamation = partialRight(format, 'morning', '!'); + * inMorningWithExclamation('Hi', 'Fred'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg3: T3, arg4: T4): (t1: T1, t2: T2) => R; +/** + * Creates a function that invokes the provided function with the first, third and fourth arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param plc2 The placeholder for the second argument + * @param arg3 The third argument to pre-fill + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const hiInMorningWithExclamation = partialRight(format, 'Hi', partialRight.placeholder, 'morning', '!'); + * hiInMorningWithExclamation('Fred'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3, arg4: T4): (t2: T2) => R; +/** + * Creates a function that invokes the provided function with the second, third and fourth arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const greetFredInMorningWithExclamation = partialRight(format, 'Fred', 'morning', '!'); + * greetFredInMorningWithExclamation('Hi'); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, arg3: T3, arg4: T4): (t1: T1) => R; +/** + * Creates a function that invokes the provided function with all arguments pre-filled. + * + * @template T1 The type of the first argument + * @template T2 The type of the second argument + * @template T3 The type of the third argument + * @template T4 The type of the fourth argument + * @template R The return type of the function + * @param func The function to partially apply + * @param arg1 The first argument to pre-fill + * @param arg2 The second argument to pre-fill + * @param arg3 The third argument to pre-fill + * @param arg4 The fourth argument to pre-fill + * @returns Returns the new partially applied function + * + * @example + * const format = (greeting: string, name: string, time: string, punctuation: string) => + * `${greeting} ${name}, it's ${time}${punctuation}`; + * const sayHiToFredInMorningWithExclamation = partialRight(format, 'Hi', 'Fred', 'morning', '!'); + * sayHiToFredInMorningWithExclamation(); // => 'Hi Fred, it's morning!' + */ +declare function partialRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, arg3: T3, arg4: T4): () => R; +/** + * Creates a function that invokes the provided function with partially applied arguments appended to the arguments it receives. + * The partialRight.placeholder value can be used as a placeholder for partially applied arguments. + * + * @template F The type of the function to partially apply + * @param func The function to partially apply arguments to + * @param args The arguments to be partially applied + * @returns Returns the new partially applied function + * + * @example + * function greet(greeting: string, name: string) { + * return greeting + ' ' + name; + * } + * + * const greetFred = partialRight(greet, 'Fred'); + * greetFred('Hi'); // => 'Hi Fred' + * + * // Using placeholders + * const sayHelloTo = partialRight(greet, 'Hello', partialRight.placeholder); + * sayHelloTo('Fred'); // => 'Hello Fred' + */ +declare function partialRight(func: (...args: any[]) => any, ...args: any[]): (...args: any[]) => any; +declare namespace partialRight { + var placeholder: Placeholder; +} +type Placeholder = symbol | (((value: any) => any) & { + partialRight: typeof partialRight; +}); +//#endregion +export { partialRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/partialRight.js b/node_modules/es-toolkit/dist/compat/function/partialRight.js new file mode 100644 index 0000000000000000000000000000000000000000..f3bbdbe3afcfa1d7a53e8a91dcb967ba0497d531 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/partialRight.js @@ -0,0 +1,34 @@ +const require_partialRight = require("../../function/partialRight.js"); +//#region src/compat/function/partialRight.ts +/** +* This method is like `partial` except that partially applied arguments are appended to the arguments it receives. +* +* The partialRight.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: This method doesn't set the `length` property of partially applied functions. +* +* @template F The type of the function to partially apply. +* @param func The function to partially apply arguments to. +* @param partialArgs The arguments to be partially applied. +* @returns Returns the new partially applied function. +* +* @example +* function greet(greeting, name) { +* return greeting + ' ' + name; +* } +* +* const greetFred = partialRight(greet, 'fred'); +* greetFred('hi'); +* // => 'hi fred' +* +* // Partially applied with placeholders. +* const sayHelloTo = partialRight(greet, 'hello', partialRight.placeholder); +* sayHelloTo('fred'); +* // => 'hello fred' +*/ +function partialRight(func, ...partialArgs) { + return require_partialRight.partialRightImpl(func, partialRight.placeholder, ...partialArgs); +} +partialRight.placeholder = Symbol("compat.partialRight.placeholder"); +//#endregion +exports.partialRight = partialRight; diff --git a/node_modules/es-toolkit/dist/compat/function/partialRight.mjs b/node_modules/es-toolkit/dist/compat/function/partialRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e5097f0568e2d2c58315f21d6e241393751b5045 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/partialRight.mjs @@ -0,0 +1,34 @@ +import { partialRightImpl } from "../../function/partialRight.mjs"; +//#region src/compat/function/partialRight.ts +/** +* This method is like `partial` except that partially applied arguments are appended to the arguments it receives. +* +* The partialRight.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments. +* +* Note: This method doesn't set the `length` property of partially applied functions. +* +* @template F The type of the function to partially apply. +* @param func The function to partially apply arguments to. +* @param partialArgs The arguments to be partially applied. +* @returns Returns the new partially applied function. +* +* @example +* function greet(greeting, name) { +* return greeting + ' ' + name; +* } +* +* const greetFred = partialRight(greet, 'fred'); +* greetFred('hi'); +* // => 'hi fred' +* +* // Partially applied with placeholders. +* const sayHelloTo = partialRight(greet, 'hello', partialRight.placeholder); +* sayHelloTo('fred'); +* // => 'hello fred' +*/ +function partialRight(func, ...partialArgs) { + return partialRightImpl(func, partialRight.placeholder, ...partialArgs); +} +partialRight.placeholder = Symbol("compat.partialRight.placeholder"); +//#endregion +export { partialRight }; diff --git a/node_modules/es-toolkit/dist/compat/function/rearg.d.mts b/node_modules/es-toolkit/dist/compat/function/rearg.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0a92a3ab96734d60d630a024e7cbe063bc759a6a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/rearg.d.mts @@ -0,0 +1,20 @@ +import { Many } from "../_internal/Many.mjs"; + +//#region src/compat/function/rearg.d.ts +/** + * Creates a function that invokes `func` with arguments arranged according to the specified `indices` + * where the argument value at the first index is provided as the first argument, + * the argument value at the second index is provided as the second argument, and so on. + * + * @param func The function to rearrange arguments for. + * @param indices The arranged argument indices. + * @returns Returns the new function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const rearrangedGreet = rearg(greet, 1, 0); + * console.log(rearrangedGreet('World', 'Hello')); // Output: "Hello, World!" + */ +declare function rearg(func: (...args: any[]) => any, ...indices: Array>): (...args: any[]) => any; +//#endregion +export { rearg }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/rearg.d.ts b/node_modules/es-toolkit/dist/compat/function/rearg.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc3165c61ca9446f1f63785d88a9c89ebad49400 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/rearg.d.ts @@ -0,0 +1,20 @@ +import { Many } from "../_internal/Many.js"; + +//#region src/compat/function/rearg.d.ts +/** + * Creates a function that invokes `func` with arguments arranged according to the specified `indices` + * where the argument value at the first index is provided as the first argument, + * the argument value at the second index is provided as the second argument, and so on. + * + * @param func The function to rearrange arguments for. + * @param indices The arranged argument indices. + * @returns Returns the new function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const rearrangedGreet = rearg(greet, 1, 0); + * console.log(rearrangedGreet('World', 'Hello')); // Output: "Hello, World!" + */ +declare function rearg(func: (...args: any[]) => any, ...indices: Array>): (...args: any[]) => any; +//#endregion +export { rearg }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/rearg.js b/node_modules/es-toolkit/dist/compat/function/rearg.js new file mode 100644 index 0000000000000000000000000000000000000000..53b9693c712b1bde0383c2fe0a085448fddb4102 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/rearg.js @@ -0,0 +1,26 @@ +const require_flatten = require("../array/flatten.js"); +//#region src/compat/function/rearg.ts +/** +* Creates a function that invokes `func` with arguments arranged according to the specified `indices` +* where the argument value at the first index is provided as the first argument, +* the argument value at the second index is provided as the second argument, and so on. +* +* @param func The function to rearrange arguments for. +* @param indices The arranged argument indices. +* @returns Returns the new function. +* +* @example +* const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; +* const rearrangedGreet = rearg(greet, 1, 0); +* console.log(rearrangedGreet('World', 'Hello')); // Output: "Hello, World!" +*/ +function rearg(func, ...indices) { + const flattenIndices = require_flatten.flatten(indices); + return function(...args) { + const reorderedArgs = flattenIndices.map((i) => args[i]).slice(0, args.length); + for (let i = reorderedArgs.length; i < args.length; i++) reorderedArgs.push(args[i]); + return func.apply(this, reorderedArgs); + }; +} +//#endregion +exports.rearg = rearg; diff --git a/node_modules/es-toolkit/dist/compat/function/rearg.mjs b/node_modules/es-toolkit/dist/compat/function/rearg.mjs new file mode 100644 index 0000000000000000000000000000000000000000..79aa04a3af656618707876e7a0c496d19c9e2780 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/rearg.mjs @@ -0,0 +1,26 @@ +import { flatten } from "../array/flatten.mjs"; +//#region src/compat/function/rearg.ts +/** +* Creates a function that invokes `func` with arguments arranged according to the specified `indices` +* where the argument value at the first index is provided as the first argument, +* the argument value at the second index is provided as the second argument, and so on. +* +* @param func The function to rearrange arguments for. +* @param indices The arranged argument indices. +* @returns Returns the new function. +* +* @example +* const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; +* const rearrangedGreet = rearg(greet, 1, 0); +* console.log(rearrangedGreet('World', 'Hello')); // Output: "Hello, World!" +*/ +function rearg(func, ...indices) { + const flattenIndices = flatten(indices); + return function(...args) { + const reorderedArgs = flattenIndices.map((i) => args[i]).slice(0, args.length); + for (let i = reorderedArgs.length; i < args.length; i++) reorderedArgs.push(args[i]); + return func.apply(this, reorderedArgs); + }; +} +//#endregion +export { rearg }; diff --git a/node_modules/es-toolkit/dist/compat/function/rest.d.mts b/node_modules/es-toolkit/dist/compat/function/rest.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..46af937474d99aeba7a24c72a90e18760110040b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/rest.d.mts @@ -0,0 +1,33 @@ +//#region src/compat/function/rest.d.ts +/** + * Creates a function that transforms the arguments of the provided function `func`. + * The transformed arguments are passed to `func` such that the arguments starting from a specified index + * are grouped into an array, while the previous arguments are passed as individual elements. + * + * @param func - The function whose arguments are to be transformed. + * @param [start=func.length - 1] - The index from which to start grouping the remaining arguments into an array. + * Defaults to `func.length - 1`, grouping all arguments after the last parameter. + * @returns A new function that, when called, returns the result of calling `func` with the transformed arguments. + * + * The transformed arguments are: + * - The first `start` arguments as individual elements. + * - The remaining arguments from index `start` onward grouped into an array. + * @example + * function fn(a, b, c) { + * return [a, b, c]; + * } + * + * // Using default start index (func.length - 1, which is 2 in this case) + * const transformedFn = rest(fn); + * console.log(transformedFn(1, 2, 3, 4)); // [1, 2, [3, 4]] + * + * // Using start index 1 + * const transformedFnWithStart = rest(fn, 1); + * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]] + * + * // With fewer arguments than the start index + * console.log(transformedFn(1)); // [1, undefined, []] + */ +declare function rest(func: (...args: any[]) => any, start?: number): (...args: any[]) => any; +//#endregion +export { rest }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/rest.d.ts b/node_modules/es-toolkit/dist/compat/function/rest.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..46af937474d99aeba7a24c72a90e18760110040b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/rest.d.ts @@ -0,0 +1,33 @@ +//#region src/compat/function/rest.d.ts +/** + * Creates a function that transforms the arguments of the provided function `func`. + * The transformed arguments are passed to `func` such that the arguments starting from a specified index + * are grouped into an array, while the previous arguments are passed as individual elements. + * + * @param func - The function whose arguments are to be transformed. + * @param [start=func.length - 1] - The index from which to start grouping the remaining arguments into an array. + * Defaults to `func.length - 1`, grouping all arguments after the last parameter. + * @returns A new function that, when called, returns the result of calling `func` with the transformed arguments. + * + * The transformed arguments are: + * - The first `start` arguments as individual elements. + * - The remaining arguments from index `start` onward grouped into an array. + * @example + * function fn(a, b, c) { + * return [a, b, c]; + * } + * + * // Using default start index (func.length - 1, which is 2 in this case) + * const transformedFn = rest(fn); + * console.log(transformedFn(1, 2, 3, 4)); // [1, 2, [3, 4]] + * + * // Using start index 1 + * const transformedFnWithStart = rest(fn, 1); + * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]] + * + * // With fewer arguments than the start index + * console.log(transformedFn(1)); // [1, undefined, []] + */ +declare function rest(func: (...args: any[]) => any, start?: number): (...args: any[]) => any; +//#endregion +export { rest }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/rest.js b/node_modules/es-toolkit/dist/compat/function/rest.js new file mode 100644 index 0000000000000000000000000000000000000000..8bee6fb1733d85869f31136e5375cff469312c99 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/rest.js @@ -0,0 +1,38 @@ +const require_rest = require("../../function/rest.js"); +//#region src/compat/function/rest.ts +/** +* Creates a function that transforms the arguments of the provided function `func`. +* The transformed arguments are passed to `func` such that the arguments starting from a specified index +* are grouped into an array, while the previous arguments are passed as individual elements. +* +* @param func - The function whose arguments are to be transformed. +* @param [start=func.length - 1] - The index from which to start grouping the remaining arguments into an array. +* Defaults to `func.length - 1`, grouping all arguments after the last parameter. +* @returns A new function that, when called, returns the result of calling `func` with the transformed arguments. +* +* The transformed arguments are: +* - The first `start` arguments as individual elements. +* - The remaining arguments from index `start` onward grouped into an array. +* @example +* function fn(a, b, c) { +* return [a, b, c]; +* } +* +* // Using default start index (func.length - 1, which is 2 in this case) +* const transformedFn = rest(fn); +* console.log(transformedFn(1, 2, 3, 4)); // [1, 2, [3, 4]] +* +* // Using start index 1 +* const transformedFnWithStart = rest(fn, 1); +* console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]] +* +* // With fewer arguments than the start index +* console.log(transformedFn(1)); // [1, undefined, []] +*/ +function rest(func, start = func.length - 1) { + start = Number.parseInt(start, 10); + if (Number.isNaN(start) || start < 0) start = func.length - 1; + return require_rest.rest(func, start); +} +//#endregion +exports.rest = rest; diff --git a/node_modules/es-toolkit/dist/compat/function/rest.mjs b/node_modules/es-toolkit/dist/compat/function/rest.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c453e9d724f26198e9d5cdfe17a6c1cf358b405c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/rest.mjs @@ -0,0 +1,38 @@ +import { rest as rest$1 } from "../../function/rest.mjs"; +//#region src/compat/function/rest.ts +/** +* Creates a function that transforms the arguments of the provided function `func`. +* The transformed arguments are passed to `func` such that the arguments starting from a specified index +* are grouped into an array, while the previous arguments are passed as individual elements. +* +* @param func - The function whose arguments are to be transformed. +* @param [start=func.length - 1] - The index from which to start grouping the remaining arguments into an array. +* Defaults to `func.length - 1`, grouping all arguments after the last parameter. +* @returns A new function that, when called, returns the result of calling `func` with the transformed arguments. +* +* The transformed arguments are: +* - The first `start` arguments as individual elements. +* - The remaining arguments from index `start` onward grouped into an array. +* @example +* function fn(a, b, c) { +* return [a, b, c]; +* } +* +* // Using default start index (func.length - 1, which is 2 in this case) +* const transformedFn = rest(fn); +* console.log(transformedFn(1, 2, 3, 4)); // [1, 2, [3, 4]] +* +* // Using start index 1 +* const transformedFnWithStart = rest(fn, 1); +* console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]] +* +* // With fewer arguments than the start index +* console.log(transformedFn(1)); // [1, undefined, []] +*/ +function rest(func, start = func.length - 1) { + start = Number.parseInt(start, 10); + if (Number.isNaN(start) || start < 0) start = func.length - 1; + return rest$1(func, start); +} +//#endregion +export { rest }; diff --git a/node_modules/es-toolkit/dist/compat/function/spread.d.mts b/node_modules/es-toolkit/dist/compat/function/spread.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..49109dec842a2910536e22002b0dc57e3a7f6cdf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/spread.d.mts @@ -0,0 +1,48 @@ +//#region src/compat/function/spread.d.ts +/** + * Creates a new function that spreads elements of an array argument into individual arguments + * for the original function. The array argument is positioned based on the `argsIndex` parameter. + * + * @template F - A function type with any number of parameters and any return type. + * @param func - The function to be transformed. It can be any function with any number of arguments. + * @param [argsIndex=0] - The index where the array argument is positioned among the other arguments. + * If `argsIndex` is negative or `NaN`, it defaults to `0`. If it's a fractional number, it is rounded to the nearest integer. + * @returns A new function that takes multiple arguments, including an array of arguments at the specified `argsIndex`, + * and returns the result of calling the original function with those arguments. + * + * @example + * function add(a, b) { + * return a + b; + * } + * + * const spreadAdd = spread(add); + * console.log(spreadAdd([1, 2])); // Output: 3 + * + * @example + * // Example function to spread arguments over + * function add(a, b) { + * return a + b; + * } + * + * // Create a new function that uses `spread` to combine arguments + * const spreadAdd = spread(add, 1); + * + * // Calling `spreadAdd` with an array as the second argument + * console.log(spreadAdd(1, [2])); // Output: 3 + * + * @example + * // Function with default arguments + * function greet(name, greeting = 'Hello') { + * return `${greeting}, ${name}!`; + * } + * + * // Create a new function that uses `spread` to position the argument array at index 0 + * const spreadGreet = spread(greet, 0); + * + * // Calling `spreadGreet` with an array of arguments + * console.log(spreadGreet(['Alice'])); // Output: Hello, Alice! + * console.log(spreadGreet(['Bob', 'Hi'])); // Output: Hi, Bob! + */ +declare function spread(func: (...args: any[]) => R, argsIndex?: number): (...args: any[]) => R; +//#endregion +export { spread }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/spread.d.ts b/node_modules/es-toolkit/dist/compat/function/spread.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..49109dec842a2910536e22002b0dc57e3a7f6cdf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/spread.d.ts @@ -0,0 +1,48 @@ +//#region src/compat/function/spread.d.ts +/** + * Creates a new function that spreads elements of an array argument into individual arguments + * for the original function. The array argument is positioned based on the `argsIndex` parameter. + * + * @template F - A function type with any number of parameters and any return type. + * @param func - The function to be transformed. It can be any function with any number of arguments. + * @param [argsIndex=0] - The index where the array argument is positioned among the other arguments. + * If `argsIndex` is negative or `NaN`, it defaults to `0`. If it's a fractional number, it is rounded to the nearest integer. + * @returns A new function that takes multiple arguments, including an array of arguments at the specified `argsIndex`, + * and returns the result of calling the original function with those arguments. + * + * @example + * function add(a, b) { + * return a + b; + * } + * + * const spreadAdd = spread(add); + * console.log(spreadAdd([1, 2])); // Output: 3 + * + * @example + * // Example function to spread arguments over + * function add(a, b) { + * return a + b; + * } + * + * // Create a new function that uses `spread` to combine arguments + * const spreadAdd = spread(add, 1); + * + * // Calling `spreadAdd` with an array as the second argument + * console.log(spreadAdd(1, [2])); // Output: 3 + * + * @example + * // Function with default arguments + * function greet(name, greeting = 'Hello') { + * return `${greeting}, ${name}!`; + * } + * + * // Create a new function that uses `spread` to position the argument array at index 0 + * const spreadGreet = spread(greet, 0); + * + * // Calling `spreadGreet` with an array of arguments + * console.log(spreadGreet(['Alice'])); // Output: Hello, Alice! + * console.log(spreadGreet(['Bob', 'Hi'])); // Output: Hi, Bob! + */ +declare function spread(func: (...args: any[]) => R, argsIndex?: number): (...args: any[]) => R; +//#endregion +export { spread }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/spread.js b/node_modules/es-toolkit/dist/compat/function/spread.js new file mode 100644 index 0000000000000000000000000000000000000000..02d489742447d378391dd93763b06f62f0730dc1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/spread.js @@ -0,0 +1,57 @@ +//#region src/compat/function/spread.ts +/** +* Creates a new function that spreads elements of an array argument into individual arguments +* for the original function. The array argument is positioned based on the `argsIndex` parameter. +* +* @template F - A function type with any number of parameters and any return type. +* @param func - The function to be transformed. It can be any function with any number of arguments. +* @param [argsIndex=0] - The index where the array argument is positioned among the other arguments. +* If `argsIndex` is negative or `NaN`, it defaults to `0`. If it's a fractional number, it is rounded to the nearest integer. +* @returns A new function that takes multiple arguments, including an array of arguments at the specified `argsIndex`, +* and returns the result of calling the original function with those arguments. +* +* @example +* function add(a, b) { +* return a + b; +* } +* +* const spreadAdd = spread(add); +* console.log(spreadAdd([1, 2])); // Output: 3 +* +* @example +* // Example function to spread arguments over +* function add(a, b) { +* return a + b; +* } +* +* // Create a new function that uses `spread` to combine arguments +* const spreadAdd = spread(add, 1); +* +* // Calling `spreadAdd` with an array as the second argument +* console.log(spreadAdd(1, [2])); // Output: 3 +* +* @example +* // Function with default arguments +* function greet(name, greeting = 'Hello') { +* return `${greeting}, ${name}!`; +* } +* +* // Create a new function that uses `spread` to position the argument array at index 0 +* const spreadGreet = spread(greet, 0); +* +* // Calling `spreadGreet` with an array of arguments +* console.log(spreadGreet(['Alice'])); // Output: Hello, Alice! +* console.log(spreadGreet(['Bob', 'Hi'])); // Output: Hi, Bob! +*/ +function spread(func, argsIndex = 0) { + argsIndex = Number.parseInt(argsIndex, 10); + if (Number.isNaN(argsIndex) || argsIndex < 0) argsIndex = 0; + return function(...args) { + const array = args[argsIndex]; + const params = args.slice(0, argsIndex); + if (array) params.push(...array); + return func.apply(this, params); + }; +} +//#endregion +exports.spread = spread; diff --git a/node_modules/es-toolkit/dist/compat/function/spread.mjs b/node_modules/es-toolkit/dist/compat/function/spread.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8128cdc3689a31bfdeb62c08f86415ddd42f65d0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/spread.mjs @@ -0,0 +1,57 @@ +//#region src/compat/function/spread.ts +/** +* Creates a new function that spreads elements of an array argument into individual arguments +* for the original function. The array argument is positioned based on the `argsIndex` parameter. +* +* @template F - A function type with any number of parameters and any return type. +* @param func - The function to be transformed. It can be any function with any number of arguments. +* @param [argsIndex=0] - The index where the array argument is positioned among the other arguments. +* If `argsIndex` is negative or `NaN`, it defaults to `0`. If it's a fractional number, it is rounded to the nearest integer. +* @returns A new function that takes multiple arguments, including an array of arguments at the specified `argsIndex`, +* and returns the result of calling the original function with those arguments. +* +* @example +* function add(a, b) { +* return a + b; +* } +* +* const spreadAdd = spread(add); +* console.log(spreadAdd([1, 2])); // Output: 3 +* +* @example +* // Example function to spread arguments over +* function add(a, b) { +* return a + b; +* } +* +* // Create a new function that uses `spread` to combine arguments +* const spreadAdd = spread(add, 1); +* +* // Calling `spreadAdd` with an array as the second argument +* console.log(spreadAdd(1, [2])); // Output: 3 +* +* @example +* // Function with default arguments +* function greet(name, greeting = 'Hello') { +* return `${greeting}, ${name}!`; +* } +* +* // Create a new function that uses `spread` to position the argument array at index 0 +* const spreadGreet = spread(greet, 0); +* +* // Calling `spreadGreet` with an array of arguments +* console.log(spreadGreet(['Alice'])); // Output: Hello, Alice! +* console.log(spreadGreet(['Bob', 'Hi'])); // Output: Hi, Bob! +*/ +function spread(func, argsIndex = 0) { + argsIndex = Number.parseInt(argsIndex, 10); + if (Number.isNaN(argsIndex) || argsIndex < 0) argsIndex = 0; + return function(...args) { + const array = args[argsIndex]; + const params = args.slice(0, argsIndex); + if (array) params.push(...array); + return func.apply(this, params); + }; +} +//#endregion +export { spread }; diff --git a/node_modules/es-toolkit/dist/compat/function/throttle.d.mts b/node_modules/es-toolkit/dist/compat/function/throttle.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..eed412a6219524a4d98d6d089d716ca760eb22af --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/throttle.d.mts @@ -0,0 +1,82 @@ +import { DebouncedFunc, DebouncedFuncLeading } from "./debounce.mjs"; + +//#region src/compat/function/throttle.d.ts +interface ThrottleSettings { + /** + * If `true`, the function will be invoked on the leading edge of the timeout. + * @default true + */ + leading?: boolean | undefined; + /** + * If `true`, the function will be invoked on the trailing edge of the timeout. + * @default true + */ + trailing?: boolean | undefined; +} +type ThrottleSettingsLeading = (ThrottleSettings & { + leading: true; +}) | Omit; +/** + * Creates a throttled function that only invokes the provided function at most once + * per every `throttleMs` milliseconds. Subsequent calls to the throttled function + * within the wait time will not trigger the execution of the original function. + * + * @template F - The type of function. + * @param func - The function to throttle. + * @param throttleMs - The number of milliseconds to throttle executions to. + * @param options - The options object + * @param options.signal - An optional AbortSignal to cancel the throttled function. + * @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. + * @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. + * @returns A new throttled function that accepts the same parameters as the original function. + * + * @example + * const throttledFunction = throttle(() => { + * console.log('Function executed'); + * }, 1000); + * + * // Will log 'Function executed' immediately + * throttledFunction(); + * + * // Will not log anything as it is within the throttle time + * throttledFunction(); + * + * // After 1 second + * setTimeout(() => { + * throttledFunction(); // Will log 'Function executed' + * }, 1000); + */ +declare function throttle any>(func: T, throttleMs?: number, options?: ThrottleSettingsLeading): DebouncedFuncLeading; +/** + * Creates a throttled function that only invokes the provided function at most once + * per every `throttleMs` milliseconds. Subsequent calls to the throttled function + * within the wait time will not trigger the execution of the original function. + * + * @template F - The type of function. + * @param func - The function to throttle. + * @param throttleMs - The number of milliseconds to throttle executions to. + * @param options - The options object + * @param options.signal - An optional AbortSignal to cancel the throttled function. + * @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. + * @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. + * @returns A new throttled function that accepts the same parameters as the original function. + * + * @example + * const throttledFunction = throttle(() => { + * console.log('Function executed'); + * }, 1000); + * + * // Will log 'Function executed' immediately + * throttledFunction(); + * + * // Will not log anything as it is within the throttle time + * throttledFunction(); + * + * // After 1 second + * setTimeout(() => { + * throttledFunction(); // Will log 'Function executed' + * }, 1000); + */ +declare function throttle any>(func: T, throttleMs?: number, options?: ThrottleSettings): DebouncedFunc; +//#endregion +export { throttle }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/throttle.d.ts b/node_modules/es-toolkit/dist/compat/function/throttle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9791bc674e84e62e975aa9118a928e68b97ecdde --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/throttle.d.ts @@ -0,0 +1,82 @@ +import { DebouncedFunc, DebouncedFuncLeading } from "./debounce.js"; + +//#region src/compat/function/throttle.d.ts +interface ThrottleSettings { + /** + * If `true`, the function will be invoked on the leading edge of the timeout. + * @default true + */ + leading?: boolean | undefined; + /** + * If `true`, the function will be invoked on the trailing edge of the timeout. + * @default true + */ + trailing?: boolean | undefined; +} +type ThrottleSettingsLeading = (ThrottleSettings & { + leading: true; +}) | Omit; +/** + * Creates a throttled function that only invokes the provided function at most once + * per every `throttleMs` milliseconds. Subsequent calls to the throttled function + * within the wait time will not trigger the execution of the original function. + * + * @template F - The type of function. + * @param func - The function to throttle. + * @param throttleMs - The number of milliseconds to throttle executions to. + * @param options - The options object + * @param options.signal - An optional AbortSignal to cancel the throttled function. + * @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. + * @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. + * @returns A new throttled function that accepts the same parameters as the original function. + * + * @example + * const throttledFunction = throttle(() => { + * console.log('Function executed'); + * }, 1000); + * + * // Will log 'Function executed' immediately + * throttledFunction(); + * + * // Will not log anything as it is within the throttle time + * throttledFunction(); + * + * // After 1 second + * setTimeout(() => { + * throttledFunction(); // Will log 'Function executed' + * }, 1000); + */ +declare function throttle any>(func: T, throttleMs?: number, options?: ThrottleSettingsLeading): DebouncedFuncLeading; +/** + * Creates a throttled function that only invokes the provided function at most once + * per every `throttleMs` milliseconds. Subsequent calls to the throttled function + * within the wait time will not trigger the execution of the original function. + * + * @template F - The type of function. + * @param func - The function to throttle. + * @param throttleMs - The number of milliseconds to throttle executions to. + * @param options - The options object + * @param options.signal - An optional AbortSignal to cancel the throttled function. + * @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. + * @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. + * @returns A new throttled function that accepts the same parameters as the original function. + * + * @example + * const throttledFunction = throttle(() => { + * console.log('Function executed'); + * }, 1000); + * + * // Will log 'Function executed' immediately + * throttledFunction(); + * + * // Will not log anything as it is within the throttle time + * throttledFunction(); + * + * // After 1 second + * setTimeout(() => { + * throttledFunction(); // Will log 'Function executed' + * }, 1000); + */ +declare function throttle any>(func: T, throttleMs?: number, options?: ThrottleSettings): DebouncedFunc; +//#endregion +export { throttle }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/throttle.js b/node_modules/es-toolkit/dist/compat/function/throttle.js new file mode 100644 index 0000000000000000000000000000000000000000..a6c7f6359f4d99bf409da4fe20673c4429564123 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/throttle.js @@ -0,0 +1,42 @@ +const require_debounce = require("./debounce.js"); +//#region src/compat/function/throttle.ts +/** +* Creates a throttled function that only invokes the provided function at most once +* per every `throttleMs` milliseconds. Subsequent calls to the throttled function +* within the wait time will not trigger the execution of the original function. +* +* @template F - The type of function. +* @param func - The function to throttle. +* @param throttleMs - The number of milliseconds to throttle executions to. +* @param options - The options object +* @param options.signal - An optional AbortSignal to cancel the throttled function. +* @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. +* @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. +* @returns A new throttled function that accepts the same parameters as the original function. +* +* @example +* const throttledFunction = throttle(() => { +* console.log('Function executed'); +* }, 1000); +* +* // Will log 'Function executed' immediately +* throttledFunction(); +* +* // Will not log anything as it is within the throttle time +* throttledFunction(); +* +* // After 1 second +* setTimeout(() => { +* throttledFunction(); // Will log 'Function executed' +* }, 1000); +*/ +function throttle(func, throttleMs = 0, options = {}) { + const { leading = true, trailing = true } = options; + return require_debounce.debounce(func, throttleMs, { + leading, + maxWait: throttleMs, + trailing + }); +} +//#endregion +exports.throttle = throttle; diff --git a/node_modules/es-toolkit/dist/compat/function/throttle.mjs b/node_modules/es-toolkit/dist/compat/function/throttle.mjs new file mode 100644 index 0000000000000000000000000000000000000000..deb881f0ca1a912497ef469cbd6d1c3f8c077697 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/throttle.mjs @@ -0,0 +1,42 @@ +import { debounce } from "./debounce.mjs"; +//#region src/compat/function/throttle.ts +/** +* Creates a throttled function that only invokes the provided function at most once +* per every `throttleMs` milliseconds. Subsequent calls to the throttled function +* within the wait time will not trigger the execution of the original function. +* +* @template F - The type of function. +* @param func - The function to throttle. +* @param throttleMs - The number of milliseconds to throttle executions to. +* @param options - The options object +* @param options.signal - An optional AbortSignal to cancel the throttled function. +* @param options.leading - If `true`, the function will be invoked on the leading edge of the timeout. +* @param options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout. +* @returns A new throttled function that accepts the same parameters as the original function. +* +* @example +* const throttledFunction = throttle(() => { +* console.log('Function executed'); +* }, 1000); +* +* // Will log 'Function executed' immediately +* throttledFunction(); +* +* // Will not log anything as it is within the throttle time +* throttledFunction(); +* +* // After 1 second +* setTimeout(() => { +* throttledFunction(); // Will log 'Function executed' +* }, 1000); +*/ +function throttle(func, throttleMs = 0, options = {}) { + const { leading = true, trailing = true } = options; + return debounce(func, throttleMs, { + leading, + maxWait: throttleMs, + trailing + }); +} +//#endregion +export { throttle }; diff --git a/node_modules/es-toolkit/dist/compat/function/unary.d.mts b/node_modules/es-toolkit/dist/compat/function/unary.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c95ecb79960c49147f5c6e54a02b477417e04a9c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/unary.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/function/unary.d.ts +/** + * Creates a function that accepts up to one argument, ignoring any additional arguments. + * + * @template F - The type of the function. + * @param func - The function to cap arguments for. + * @returns Returns the new capped function. + * + * @example + * function fn(a, b, c) { + * console.log(arguments); + * } + * + * unary(fn)(1, 2, 3); // [Arguments] { '0': 1 } + */ +declare function unary(func: (arg1: T, ...args: any[]) => U): (arg1: T) => U; +//#endregion +export { unary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/unary.d.ts b/node_modules/es-toolkit/dist/compat/function/unary.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c95ecb79960c49147f5c6e54a02b477417e04a9c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/unary.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/function/unary.d.ts +/** + * Creates a function that accepts up to one argument, ignoring any additional arguments. + * + * @template F - The type of the function. + * @param func - The function to cap arguments for. + * @returns Returns the new capped function. + * + * @example + * function fn(a, b, c) { + * console.log(arguments); + * } + * + * unary(fn)(1, 2, 3); // [Arguments] { '0': 1 } + */ +declare function unary(func: (arg1: T, ...args: any[]) => U): (arg1: T) => U; +//#endregion +export { unary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/unary.js b/node_modules/es-toolkit/dist/compat/function/unary.js new file mode 100644 index 0000000000000000000000000000000000000000..e5e0b91cba1af654b35621709922a95b50aa785c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/unary.js @@ -0,0 +1,21 @@ +const require_ary = require("./ary.js"); +//#region src/compat/function/unary.ts +/** +* Creates a function that accepts up to one argument, ignoring any additional arguments. +* +* @template F - The type of the function. +* @param func - The function to cap arguments for. +* @returns Returns the new capped function. +* +* @example +* function fn(a, b, c) { +* console.log(arguments); +* } +* +* unary(fn)(1, 2, 3); // [Arguments] { '0': 1 } +*/ +function unary(func) { + return require_ary.ary(func, 1); +} +//#endregion +exports.unary = unary; diff --git a/node_modules/es-toolkit/dist/compat/function/unary.mjs b/node_modules/es-toolkit/dist/compat/function/unary.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8a031bd2388c829f85a6623c05b67b466b413e47 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/unary.mjs @@ -0,0 +1,21 @@ +import { ary } from "./ary.mjs"; +//#region src/compat/function/unary.ts +/** +* Creates a function that accepts up to one argument, ignoring any additional arguments. +* +* @template F - The type of the function. +* @param func - The function to cap arguments for. +* @returns Returns the new capped function. +* +* @example +* function fn(a, b, c) { +* console.log(arguments); +* } +* +* unary(fn)(1, 2, 3); // [Arguments] { '0': 1 } +*/ +function unary(func) { + return ary(func, 1); +} +//#endregion +export { unary }; diff --git a/node_modules/es-toolkit/dist/compat/function/wrap.d.mts b/node_modules/es-toolkit/dist/compat/function/wrap.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2597a0c7c64afddf15d8037334b17204e0095657 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/wrap.d.mts @@ -0,0 +1,28 @@ +//#region src/compat/function/wrap.d.ts +/** + * Creates a new function that wraps the given function `func`. + * In this process, you can apply additional logic defined in the `wrapper` function before and after the execution of the original function. + * + * If a `value` is provided instead of a function, this value is passed as the first argument to the `wrapper` function. + * + * @template T - The type of the value being wrapped. + * @template U - The type of the arguments being passed to the `wrapper` function. + * @template V - The type of the return value of the `wrapper` function. + * @param value - The value to be wrapped. + * @param wrapper - The function to wrap the value with. + * @returns A new function that wraps the value with the `wrapper` function. + * + * @example + * // Wrap a function + * const greet = (name: string) => `Hi, ${name}`; + * const wrapped = wrap(greet, (value, name) => `[LOG] ${value(name)}`); + * wrapped('Bob'); // => "[LOG] Hi, Bob" + * + * @example + * // Wrap a primitive value + * const wrapped = wrap('value', v => `

${v}

`); + * wrapped(); // => "

value

" + */ +declare function wrap(value: T, wrapper: (value: T, ...args: U[]) => V): (...args: U[]) => V; +//#endregion +export { wrap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/wrap.d.ts b/node_modules/es-toolkit/dist/compat/function/wrap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2597a0c7c64afddf15d8037334b17204e0095657 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/wrap.d.ts @@ -0,0 +1,28 @@ +//#region src/compat/function/wrap.d.ts +/** + * Creates a new function that wraps the given function `func`. + * In this process, you can apply additional logic defined in the `wrapper` function before and after the execution of the original function. + * + * If a `value` is provided instead of a function, this value is passed as the first argument to the `wrapper` function. + * + * @template T - The type of the value being wrapped. + * @template U - The type of the arguments being passed to the `wrapper` function. + * @template V - The type of the return value of the `wrapper` function. + * @param value - The value to be wrapped. + * @param wrapper - The function to wrap the value with. + * @returns A new function that wraps the value with the `wrapper` function. + * + * @example + * // Wrap a function + * const greet = (name: string) => `Hi, ${name}`; + * const wrapped = wrap(greet, (value, name) => `[LOG] ${value(name)}`); + * wrapped('Bob'); // => "[LOG] Hi, Bob" + * + * @example + * // Wrap a primitive value + * const wrapped = wrap('value', v => `

${v}

`); + * wrapped(); // => "

value

" + */ +declare function wrap(value: T, wrapper: (value: T, ...args: U[]) => V): (...args: U[]) => V; +//#endregion +export { wrap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/function/wrap.js b/node_modules/es-toolkit/dist/compat/function/wrap.js new file mode 100644 index 0000000000000000000000000000000000000000..ed20cc8c2d0905a2da52e7542d6b092d997d5e03 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/wrap.js @@ -0,0 +1,34 @@ +const require_identity = require("../../function/identity.js"); +const require_isFunction = require("../../predicate/isFunction.js"); +//#region src/compat/function/wrap.ts +/** +* Creates a new function that wraps the given function `func`. +* In this process, you can apply additional logic defined in the `wrapper` function before and after the execution of the original function. +* +* If a `value` is provided instead of a function, this value is passed as the first argument to the `wrapper` function. +* +* @template T - The type of the value being wrapped. +* @template U - The type of the arguments being passed to the `wrapper` function. +* @template V - The type of the return value of the `wrapper` function. +* @param value - The value to be wrapped. +* @param wrapper - The function to wrap the value with. +* @returns A new function that wraps the value with the `wrapper` function. +* +* @example +* // Wrap a function +* const greet = (name: string) => `Hi, ${name}`; +* const wrapped = wrap(greet, (value, name) => `[LOG] ${value(name)}`); +* wrapped('Bob'); // => "[LOG] Hi, Bob" +* +* @example +* // Wrap a primitive value +* const wrapped = wrap('value', v => `

${v}

`); +* wrapped(); // => "

value

" +*/ +function wrap(value, wrapper) { + return function(...args) { + return (require_isFunction.isFunction(wrapper) ? wrapper : require_identity.identity).apply(this, [value, ...args]); + }; +} +//#endregion +exports.wrap = wrap; diff --git a/node_modules/es-toolkit/dist/compat/function/wrap.mjs b/node_modules/es-toolkit/dist/compat/function/wrap.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0f7e662e17dcd280ebc5fc2b999ad1cad3faca08 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/function/wrap.mjs @@ -0,0 +1,34 @@ +import { identity } from "../../function/identity.mjs"; +import { isFunction } from "../../predicate/isFunction.mjs"; +//#region src/compat/function/wrap.ts +/** +* Creates a new function that wraps the given function `func`. +* In this process, you can apply additional logic defined in the `wrapper` function before and after the execution of the original function. +* +* If a `value` is provided instead of a function, this value is passed as the first argument to the `wrapper` function. +* +* @template T - The type of the value being wrapped. +* @template U - The type of the arguments being passed to the `wrapper` function. +* @template V - The type of the return value of the `wrapper` function. +* @param value - The value to be wrapped. +* @param wrapper - The function to wrap the value with. +* @returns A new function that wraps the value with the `wrapper` function. +* +* @example +* // Wrap a function +* const greet = (name: string) => `Hi, ${name}`; +* const wrapped = wrap(greet, (value, name) => `[LOG] ${value(name)}`); +* wrapped('Bob'); // => "[LOG] Hi, Bob" +* +* @example +* // Wrap a primitive value +* const wrapped = wrap('value', v => `

${v}

`); +* wrapped(); // => "

value

" +*/ +function wrap(value, wrapper) { + return function(...args) { + return (isFunction(wrapper) ? wrapper : identity).apply(this, [value, ...args]); + }; +} +//#endregion +export { wrap }; diff --git a/node_modules/es-toolkit/dist/compat/index.d.mts b/node_modules/es-toolkit/dist/compat/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0f04237d8ed55db839e5ed1f9398d2b1eb873e18 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/index.d.mts @@ -0,0 +1,294 @@ +import { castArray } from "./array/castArray.mjs"; +import { chunk } from "./array/chunk.mjs"; +import { compact } from "./array/compact.mjs"; +import { concat } from "./array/concat.mjs"; +import { countBy } from "./array/countBy.mjs"; +import { difference } from "./array/difference.mjs"; +import { differenceBy } from "./array/differenceBy.mjs"; +import { differenceWith } from "./array/differenceWith.mjs"; +import { drop } from "./array/drop.mjs"; +import { dropRight } from "./array/dropRight.mjs"; +import { dropRightWhile } from "./array/dropRightWhile.mjs"; +import { dropWhile } from "./array/dropWhile.mjs"; +import { forEach } from "./array/forEach.mjs"; +import { forEachRight } from "./array/forEachRight.mjs"; +import { every } from "./array/every.mjs"; +import { fill } from "./array/fill.mjs"; +import { filter } from "./array/filter.mjs"; +import { find } from "./array/find.mjs"; +import { findIndex } from "./array/findIndex.mjs"; +import { findLast } from "./array/findLast.mjs"; +import { findLastIndex } from "./array/findLastIndex.mjs"; +import { head } from "./array/head.mjs"; +import { flatMap } from "./array/flatMap.mjs"; +import { flatMapDeep } from "./array/flatMapDeep.mjs"; +import { flatMapDepth } from "./array/flatMapDepth.mjs"; +import { flatten } from "./array/flatten.mjs"; +import { flattenDeep } from "./array/flattenDeep.mjs"; +import { flattenDepth } from "./array/flattenDepth.mjs"; +import { groupBy } from "./array/groupBy.mjs"; +import { includes } from "./array/includes.mjs"; +import { indexOf } from "./array/indexOf.mjs"; +import { initial } from "./array/initial.mjs"; +import { intersection } from "./array/intersection.mjs"; +import { intersectionBy } from "./array/intersectionBy.mjs"; +import { intersectionWith } from "./array/intersectionWith.mjs"; +import { invokeMap } from "./array/invokeMap.mjs"; +import { join } from "./array/join.mjs"; +import { keyBy } from "./array/keyBy.mjs"; +import { last } from "./array/last.mjs"; +import { lastIndexOf } from "./array/lastIndexOf.mjs"; +import { map } from "./array/map.mjs"; +import { nth } from "./array/nth.mjs"; +import { orderBy } from "./array/orderBy.mjs"; +import { partition } from "./array/partition.mjs"; +import { pull } from "./array/pull.mjs"; +import { pullAll } from "./array/pullAll.mjs"; +import { pullAllBy } from "./array/pullAllBy.mjs"; +import { pullAllWith } from "./array/pullAllWith.mjs"; +import { pullAt } from "./array/pullAt.mjs"; +import { reduce } from "./array/reduce.mjs"; +import { reduceRight } from "./array/reduceRight.mjs"; +import { reject } from "./array/reject.mjs"; +import { remove } from "./array/remove.mjs"; +import { reverse } from "./array/reverse.mjs"; +import { sample } from "./array/sample.mjs"; +import { sampleSize } from "./array/sampleSize.mjs"; +import { shuffle } from "./array/shuffle.mjs"; +import { size } from "./array/size.mjs"; +import { slice } from "./array/slice.mjs"; +import { some } from "./array/some.mjs"; +import { sortBy } from "./array/sortBy.mjs"; +import { sortedIndex } from "./array/sortedIndex.mjs"; +import { sortedIndexBy } from "./array/sortedIndexBy.mjs"; +import { sortedIndexOf } from "./array/sortedIndexOf.mjs"; +import { sortedLastIndex } from "./array/sortedLastIndex.mjs"; +import { sortedLastIndexBy } from "./array/sortedLastIndexBy.mjs"; +import { sortedLastIndexOf } from "./array/sortedLastIndexOf.mjs"; +import { tail } from "./array/tail.mjs"; +import { take } from "./array/take.mjs"; +import { takeRight } from "./array/takeRight.mjs"; +import { takeRightWhile } from "./array/takeRightWhile.mjs"; +import { takeWhile } from "./array/takeWhile.mjs"; +import { union } from "./array/union.mjs"; +import { unionBy } from "./array/unionBy.mjs"; +import { unionWith } from "./array/unionWith.mjs"; +import { uniq } from "./array/uniq.mjs"; +import { uniqBy } from "./array/uniqBy.mjs"; +import { uniqWith } from "./array/uniqWith.mjs"; +import { unzip } from "./array/unzip.mjs"; +import { unzipWith } from "./array/unzipWith.mjs"; +import { without } from "./array/without.mjs"; +import { xor } from "./array/xor.mjs"; +import { xorBy } from "./array/xorBy.mjs"; +import { xorWith } from "./array/xorWith.mjs"; +import { zip } from "./array/zip.mjs"; +import { zipObject } from "./array/zipObject.mjs"; +import { zipObjectDeep } from "./array/zipObjectDeep.mjs"; +import { zipWith } from "./array/zipWith.mjs"; +import { after } from "./function/after.mjs"; +import { ary } from "./function/ary.mjs"; +import { attempt } from "./function/attempt.mjs"; +import { before } from "./function/before.mjs"; +import { bind } from "./function/bind.mjs"; +import { bindKey } from "./function/bindKey.mjs"; +import { curry } from "./function/curry.mjs"; +import { curryRight } from "./function/curryRight.mjs"; +import { DebouncedFunc, debounce } from "./function/debounce.mjs"; +import { defer } from "./function/defer.mjs"; +import { delay } from "./function/delay.mjs"; +import { flip } from "./function/flip.mjs"; +import { flow } from "./function/flow.mjs"; +import { flowRight } from "./function/flowRight.mjs"; +import { memoize } from "./function/memoize.mjs"; +import { negate } from "./function/negate.mjs"; +import { nthArg } from "./function/nthArg.mjs"; +import { once } from "./function/once.mjs"; +import { overArgs } from "./function/overArgs.mjs"; +import { toolkit } from "./toolkit.mjs"; +import { partial } from "./function/partial.mjs"; +import { partialRight } from "./function/partialRight.mjs"; +import { rearg } from "./function/rearg.mjs"; +import { rest } from "./function/rest.mjs"; +import { spread } from "./function/spread.mjs"; +import { throttle } from "./function/throttle.mjs"; +import { unary } from "./function/unary.mjs"; +import { wrap } from "./function/wrap.mjs"; +import { add } from "./math/add.mjs"; +import { ceil } from "./math/ceil.mjs"; +import { clamp } from "./math/clamp.mjs"; +import { divide } from "./math/divide.mjs"; +import { floor } from "./math/floor.mjs"; +import { inRange } from "./math/inRange.mjs"; +import { max } from "./math/max.mjs"; +import { maxBy } from "./math/maxBy.mjs"; +import { mean } from "./math/mean.mjs"; +import { meanBy } from "./math/meanBy.mjs"; +import { min } from "./math/min.mjs"; +import { minBy } from "./math/minBy.mjs"; +import { multiply } from "./math/multiply.mjs"; +import { parseInt } from "./math/parseInt.mjs"; +import { random } from "./math/random.mjs"; +import { range } from "./math/range.mjs"; +import { rangeRight } from "./math/rangeRight.mjs"; +import { round } from "./math/round.mjs"; +import { subtract } from "./math/subtract.mjs"; +import { sum } from "./math/sum.mjs"; +import { sumBy } from "./math/sumBy.mjs"; +import { isEqual } from "../predicate/isEqual.mjs"; +import { identity } from "./function/identity.mjs"; +import { noop } from "./function/noop.mjs"; +import { assign } from "./object/assign.mjs"; +import { assignIn } from "./object/assignIn.mjs"; +import { assignInWith } from "./object/assignInWith.mjs"; +import { assignWith } from "./object/assignWith.mjs"; +import { at } from "./object/at.mjs"; +import { clone } from "./object/clone.mjs"; +import { cloneDeep } from "./object/cloneDeep.mjs"; +import { cloneDeepWith } from "./object/cloneDeepWith.mjs"; +import { cloneWith } from "./object/cloneWith.mjs"; +import { create } from "./object/create.mjs"; +import { defaults } from "./object/defaults.mjs"; +import { defaultsDeep } from "./object/defaultsDeep.mjs"; +import { findKey } from "./object/findKey.mjs"; +import { findLastKey } from "./object/findLastKey.mjs"; +import { forIn } from "./object/forIn.mjs"; +import { forInRight } from "./object/forInRight.mjs"; +import { forOwn } from "./object/forOwn.mjs"; +import { forOwnRight } from "./object/forOwnRight.mjs"; +import { fromPairs } from "./object/fromPairs.mjs"; +import { functions } from "./object/functions.mjs"; +import { functionsIn } from "./object/functionsIn.mjs"; +import { get } from "./object/get.mjs"; +import { has } from "./object/has.mjs"; +import { hasIn } from "./object/hasIn.mjs"; +import { invert } from "./object/invert.mjs"; +import { invertBy } from "./object/invertBy.mjs"; +import { keys } from "./object/keys.mjs"; +import { keysIn } from "./object/keysIn.mjs"; +import { mapKeys } from "./object/mapKeys.mjs"; +import { mapValues } from "./object/mapValues.mjs"; +import { merge } from "./object/merge.mjs"; +import { mergeWith } from "./object/mergeWith.mjs"; +import { omit } from "./object/omit.mjs"; +import { omitBy } from "./object/omitBy.mjs"; +import { pick } from "./object/pick.mjs"; +import { pickBy } from "./object/pickBy.mjs"; +import { property } from "./object/property.mjs"; +import { propertyOf } from "./object/propertyOf.mjs"; +import { result } from "./object/result.mjs"; +import { set } from "./object/set.mjs"; +import { setWith } from "./object/setWith.mjs"; +import { toDefaulted } from "./object/toDefaulted.mjs"; +import { toPairs } from "./object/toPairs.mjs"; +import { toPairsIn } from "./object/toPairsIn.mjs"; +import { transform } from "./object/transform.mjs"; +import { unset } from "./object/unset.mjs"; +import { update } from "./object/update.mjs"; +import { updateWith } from "./object/updateWith.mjs"; +import { values } from "./object/values.mjs"; +import { valuesIn } from "./object/valuesIn.mjs"; +import { isFunction } from "./predicate/isFunction.mjs"; +import { isLength } from "./predicate/isLength.mjs"; +import { isMatchWith } from "./predicate/isMatchWith.mjs"; +import { isNative } from "./predicate/isNative.mjs"; +import { isNull } from "./predicate/isNull.mjs"; +import { isUndefined } from "./predicate/isUndefined.mjs"; +import { conforms } from "./predicate/conforms.mjs"; +import { conformsTo } from "./predicate/conformsTo.mjs"; +import { isArguments } from "./predicate/isArguments.mjs"; +import { isArray } from "./predicate/isArray.mjs"; +import { isArrayBuffer } from "./predicate/isArrayBuffer.mjs"; +import { isArrayLike } from "./predicate/isArrayLike.mjs"; +import { isArrayLikeObject } from "./predicate/isArrayLikeObject.mjs"; +import { isBoolean } from "./predicate/isBoolean.mjs"; +import { isBuffer } from "./predicate/isBuffer.mjs"; +import { isDate } from "./predicate/isDate.mjs"; +import { isElement } from "./predicate/isElement.mjs"; +import { isEmpty } from "./predicate/isEmpty.mjs"; +import { isEqualWith } from "./predicate/isEqualWith.mjs"; +import { isError } from "./predicate/isError.mjs"; +import { isFinite } from "./predicate/isFinite.mjs"; +import { isInteger } from "./predicate/isInteger.mjs"; +import { isMap } from "./predicate/isMap.mjs"; +import { isMatch } from "./predicate/isMatch.mjs"; +import { isNaN } from "./predicate/isNaN.mjs"; +import { isNil } from "./predicate/isNil.mjs"; +import { isNumber } from "./predicate/isNumber.mjs"; +import { isObject } from "./predicate/isObject.mjs"; +import { isObjectLike } from "./predicate/isObjectLike.mjs"; +import { isPlainObject } from "./predicate/isPlainObject.mjs"; +import { isRegExp } from "./predicate/isRegExp.mjs"; +import { isSafeInteger } from "./predicate/isSafeInteger.mjs"; +import { isSet } from "./predicate/isSet.mjs"; +import { isString } from "./predicate/isString.mjs"; +import { isSymbol } from "./predicate/isSymbol.mjs"; +import { isTypedArray } from "./predicate/isTypedArray.mjs"; +import { isWeakMap } from "./predicate/isWeakMap.mjs"; +import { isWeakSet } from "./predicate/isWeakSet.mjs"; +import { matches } from "./predicate/matches.mjs"; +import { matchesProperty } from "./predicate/matchesProperty.mjs"; +import { capitalize } from "./string/capitalize.mjs"; +import { bindAll } from "./util/bindAll.mjs"; +import { camelCase } from "./string/camelCase.mjs"; +import { deburr } from "./string/deburr.mjs"; +import { endsWith } from "./string/endsWith.mjs"; +import { escape } from "./string/escape.mjs"; +import { escapeRegExp } from "./string/escapeRegExp.mjs"; +import { kebabCase } from "./string/kebabCase.mjs"; +import { lowerCase } from "./string/lowerCase.mjs"; +import { lowerFirst } from "./string/lowerFirst.mjs"; +import { pad } from "./string/pad.mjs"; +import { padEnd } from "./string/padEnd.mjs"; +import { padStart } from "./string/padStart.mjs"; +import { repeat } from "./string/repeat.mjs"; +import { replace } from "./string/replace.mjs"; +import { snakeCase } from "./string/snakeCase.mjs"; +import { split } from "./string/split.mjs"; +import { startCase } from "./string/startCase.mjs"; +import { startsWith } from "./string/startsWith.mjs"; +import { template } from "./string/template.mjs"; +import { templateSettings } from "./string/templateSettings.mjs"; +import { toLower } from "./string/toLower.mjs"; +import { toUpper } from "./string/toUpper.mjs"; +import { trim } from "./string/trim.mjs"; +import { trimEnd } from "./string/trimEnd.mjs"; +import { trimStart } from "./string/trimStart.mjs"; +import { truncate } from "./string/truncate.mjs"; +import { unescape } from "./string/unescape.mjs"; +import { upperCase } from "./string/upperCase.mjs"; +import { upperFirst } from "./string/upperFirst.mjs"; +import { words } from "./string/words.mjs"; +import { cond } from "./util/cond.mjs"; +import { constant } from "./util/constant.mjs"; +import { defaultTo } from "./util/defaultTo.mjs"; +import { eq } from "./util/eq.mjs"; +import { gt } from "./util/gt.mjs"; +import { gte } from "./util/gte.mjs"; +import { invoke } from "./util/invoke.mjs"; +import { iteratee } from "./util/iteratee.mjs"; +import { lt } from "./util/lt.mjs"; +import { lte } from "./util/lte.mjs"; +import { method } from "./util/method.mjs"; +import { methodOf } from "./util/methodOf.mjs"; +import { now } from "./util/now.mjs"; +import { over } from "./util/over.mjs"; +import { overEvery } from "./util/overEvery.mjs"; +import { overSome } from "./util/overSome.mjs"; +import { stubArray } from "./util/stubArray.mjs"; +import { stubFalse } from "./util/stubFalse.mjs"; +import { stubObject } from "./util/stubObject.mjs"; +import { stubString } from "./util/stubString.mjs"; +import { stubTrue } from "./util/stubTrue.mjs"; +import { times } from "./util/times.mjs"; +import { toArray } from "./util/toArray.mjs"; +import { toFinite } from "./util/toFinite.mjs"; +import { toInteger } from "./util/toInteger.mjs"; +import { toLength } from "./util/toLength.mjs"; +import { toNumber } from "./util/toNumber.mjs"; +import { toPath } from "./util/toPath.mjs"; +import { toPlainObject } from "./util/toPlainObject.mjs"; +import { toSafeInteger } from "./util/toSafeInteger.mjs"; +import { toString } from "./util/toString.mjs"; +import { uniqueId } from "./util/uniqueId.mjs"; +export { DebouncedFunc, add, after, ary, assign, assignIn, assignInWith, assignWith, at, attempt, before, bind, bindAll, bindKey, camelCase, capitalize, castArray, ceil, chunk, clamp, clone, cloneDeep, cloneDeepWith, cloneWith, compact, concat, cond, conforms, conformsTo, constant, countBy, create, curry, curryRight, debounce, deburr, toolkit as default, defaultTo, defaults, defaultsDeep, defer, delay, difference, differenceBy, differenceWith, divide, drop, dropRight, dropRightWhile, dropWhile, forEach as each, forEachRight as eachRight, endsWith, eq, escape, escapeRegExp, every, assignIn as extend, assignInWith as extendWith, fill, filter, find, findIndex, findKey, findLast, findLastIndex, findLastKey, head as first, flatMap, flatMapDeep, flatMapDepth, flatten, flattenDeep, flattenDepth, flip, floor, flow, flowRight, forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, fromPairs, functions, functionsIn, get, groupBy, gt, gte, has, hasIn, head, identity, inRange, includes, indexOf, initial, intersection, intersectionBy, intersectionWith, invert, invertBy, invoke, invokeMap, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, iteratee, join, kebabCase, keyBy, keys, keysIn, last, lastIndexOf, lowerCase, lowerFirst, lt, lte, map, mapKeys, mapValues, matches, matchesProperty, max, maxBy, mean, meanBy, memoize, merge, mergeWith, method, methodOf, min, minBy, multiply, negate, noop, now, nth, nthArg, omit, omitBy, once, orderBy, over, overArgs, overEvery, overSome, pad, padEnd, padStart, parseInt, partial, partialRight, partition, pick, pickBy, property, propertyOf, pull, pullAll, pullAllBy, pullAllWith, pullAt, random, range, rangeRight, rearg, reduce, reduceRight, reject, remove, repeat, replace, rest, result, reverse, round, sample, sampleSize, set, setWith, shuffle, size, slice, snakeCase, some, sortBy, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, split, spread, startCase, startsWith, stubArray, stubFalse, stubObject, stubString, stubTrue, subtract, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, template, templateSettings, throttle, times, toArray, toDefaulted, toFinite, toInteger, toLength, toLower, toNumber, toPairs, toPairsIn, toPath, toPlainObject, toSafeInteger, toString, toUpper, transform, trim, trimEnd, trimStart, truncate, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, uniqueId, unset, unzip, unzipWith, update, updateWith, upperCase, upperFirst, values, valuesIn, without, words, wrap, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/index.d.ts b/node_modules/es-toolkit/dist/compat/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b24aedcc38524156dae47d57b3e8928f72d6f130 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/index.d.ts @@ -0,0 +1,294 @@ +import { castArray } from "./array/castArray.js"; +import { chunk } from "./array/chunk.js"; +import { compact } from "./array/compact.js"; +import { concat } from "./array/concat.js"; +import { countBy } from "./array/countBy.js"; +import { difference } from "./array/difference.js"; +import { differenceBy } from "./array/differenceBy.js"; +import { differenceWith } from "./array/differenceWith.js"; +import { drop } from "./array/drop.js"; +import { dropRight } from "./array/dropRight.js"; +import { dropRightWhile } from "./array/dropRightWhile.js"; +import { dropWhile } from "./array/dropWhile.js"; +import { forEach } from "./array/forEach.js"; +import { forEachRight } from "./array/forEachRight.js"; +import { every } from "./array/every.js"; +import { fill } from "./array/fill.js"; +import { filter } from "./array/filter.js"; +import { find } from "./array/find.js"; +import { findIndex } from "./array/findIndex.js"; +import { findLast } from "./array/findLast.js"; +import { findLastIndex } from "./array/findLastIndex.js"; +import { head } from "./array/head.js"; +import { flatMap } from "./array/flatMap.js"; +import { flatMapDeep } from "./array/flatMapDeep.js"; +import { flatMapDepth } from "./array/flatMapDepth.js"; +import { flatten } from "./array/flatten.js"; +import { flattenDeep } from "./array/flattenDeep.js"; +import { flattenDepth } from "./array/flattenDepth.js"; +import { groupBy } from "./array/groupBy.js"; +import { includes } from "./array/includes.js"; +import { indexOf } from "./array/indexOf.js"; +import { initial } from "./array/initial.js"; +import { intersection } from "./array/intersection.js"; +import { intersectionBy } from "./array/intersectionBy.js"; +import { intersectionWith } from "./array/intersectionWith.js"; +import { invokeMap } from "./array/invokeMap.js"; +import { join } from "./array/join.js"; +import { keyBy } from "./array/keyBy.js"; +import { last } from "./array/last.js"; +import { lastIndexOf } from "./array/lastIndexOf.js"; +import { map } from "./array/map.js"; +import { nth } from "./array/nth.js"; +import { orderBy } from "./array/orderBy.js"; +import { partition } from "./array/partition.js"; +import { pull } from "./array/pull.js"; +import { pullAll } from "./array/pullAll.js"; +import { pullAllBy } from "./array/pullAllBy.js"; +import { pullAllWith } from "./array/pullAllWith.js"; +import { pullAt } from "./array/pullAt.js"; +import { reduce } from "./array/reduce.js"; +import { reduceRight } from "./array/reduceRight.js"; +import { reject } from "./array/reject.js"; +import { remove } from "./array/remove.js"; +import { reverse } from "./array/reverse.js"; +import { sample } from "./array/sample.js"; +import { sampleSize } from "./array/sampleSize.js"; +import { shuffle } from "./array/shuffle.js"; +import { size } from "./array/size.js"; +import { slice } from "./array/slice.js"; +import { some } from "./array/some.js"; +import { sortBy } from "./array/sortBy.js"; +import { sortedIndex } from "./array/sortedIndex.js"; +import { sortedIndexBy } from "./array/sortedIndexBy.js"; +import { sortedIndexOf } from "./array/sortedIndexOf.js"; +import { sortedLastIndex } from "./array/sortedLastIndex.js"; +import { sortedLastIndexBy } from "./array/sortedLastIndexBy.js"; +import { sortedLastIndexOf } from "./array/sortedLastIndexOf.js"; +import { tail } from "./array/tail.js"; +import { take } from "./array/take.js"; +import { takeRight } from "./array/takeRight.js"; +import { takeRightWhile } from "./array/takeRightWhile.js"; +import { takeWhile } from "./array/takeWhile.js"; +import { union } from "./array/union.js"; +import { unionBy } from "./array/unionBy.js"; +import { unionWith } from "./array/unionWith.js"; +import { uniq } from "./array/uniq.js"; +import { uniqBy } from "./array/uniqBy.js"; +import { uniqWith } from "./array/uniqWith.js"; +import { unzip } from "./array/unzip.js"; +import { unzipWith } from "./array/unzipWith.js"; +import { without } from "./array/without.js"; +import { xor } from "./array/xor.js"; +import { xorBy } from "./array/xorBy.js"; +import { xorWith } from "./array/xorWith.js"; +import { zip } from "./array/zip.js"; +import { zipObject } from "./array/zipObject.js"; +import { zipObjectDeep } from "./array/zipObjectDeep.js"; +import { zipWith } from "./array/zipWith.js"; +import { after } from "./function/after.js"; +import { ary } from "./function/ary.js"; +import { attempt } from "./function/attempt.js"; +import { before } from "./function/before.js"; +import { bind } from "./function/bind.js"; +import { bindKey } from "./function/bindKey.js"; +import { curry } from "./function/curry.js"; +import { curryRight } from "./function/curryRight.js"; +import { DebouncedFunc, debounce } from "./function/debounce.js"; +import { defer } from "./function/defer.js"; +import { delay } from "./function/delay.js"; +import { flip } from "./function/flip.js"; +import { flow } from "./function/flow.js"; +import { flowRight } from "./function/flowRight.js"; +import { memoize } from "./function/memoize.js"; +import { negate } from "./function/negate.js"; +import { nthArg } from "./function/nthArg.js"; +import { once } from "./function/once.js"; +import { overArgs } from "./function/overArgs.js"; +import { toolkit } from "./toolkit.js"; +import { partial } from "./function/partial.js"; +import { partialRight } from "./function/partialRight.js"; +import { rearg } from "./function/rearg.js"; +import { rest } from "./function/rest.js"; +import { spread } from "./function/spread.js"; +import { throttle } from "./function/throttle.js"; +import { unary } from "./function/unary.js"; +import { wrap } from "./function/wrap.js"; +import { add } from "./math/add.js"; +import { ceil } from "./math/ceil.js"; +import { clamp } from "./math/clamp.js"; +import { divide } from "./math/divide.js"; +import { floor } from "./math/floor.js"; +import { inRange } from "./math/inRange.js"; +import { max } from "./math/max.js"; +import { maxBy } from "./math/maxBy.js"; +import { mean } from "./math/mean.js"; +import { meanBy } from "./math/meanBy.js"; +import { min } from "./math/min.js"; +import { minBy } from "./math/minBy.js"; +import { multiply } from "./math/multiply.js"; +import { parseInt } from "./math/parseInt.js"; +import { random } from "./math/random.js"; +import { range } from "./math/range.js"; +import { rangeRight } from "./math/rangeRight.js"; +import { round } from "./math/round.js"; +import { subtract } from "./math/subtract.js"; +import { sum } from "./math/sum.js"; +import { sumBy } from "./math/sumBy.js"; +import { isEqual } from "../predicate/isEqual.js"; +import { identity } from "./function/identity.js"; +import { noop } from "./function/noop.js"; +import { assign } from "./object/assign.js"; +import { assignIn } from "./object/assignIn.js"; +import { assignInWith } from "./object/assignInWith.js"; +import { assignWith } from "./object/assignWith.js"; +import { at } from "./object/at.js"; +import { clone } from "./object/clone.js"; +import { cloneDeep } from "./object/cloneDeep.js"; +import { cloneDeepWith } from "./object/cloneDeepWith.js"; +import { cloneWith } from "./object/cloneWith.js"; +import { create } from "./object/create.js"; +import { defaults } from "./object/defaults.js"; +import { defaultsDeep } from "./object/defaultsDeep.js"; +import { findKey } from "./object/findKey.js"; +import { findLastKey } from "./object/findLastKey.js"; +import { forIn } from "./object/forIn.js"; +import { forInRight } from "./object/forInRight.js"; +import { forOwn } from "./object/forOwn.js"; +import { forOwnRight } from "./object/forOwnRight.js"; +import { fromPairs } from "./object/fromPairs.js"; +import { functions } from "./object/functions.js"; +import { functionsIn } from "./object/functionsIn.js"; +import { get } from "./object/get.js"; +import { has } from "./object/has.js"; +import { hasIn } from "./object/hasIn.js"; +import { invert } from "./object/invert.js"; +import { invertBy } from "./object/invertBy.js"; +import { keys } from "./object/keys.js"; +import { keysIn } from "./object/keysIn.js"; +import { mapKeys } from "./object/mapKeys.js"; +import { mapValues } from "./object/mapValues.js"; +import { merge } from "./object/merge.js"; +import { mergeWith } from "./object/mergeWith.js"; +import { omit } from "./object/omit.js"; +import { omitBy } from "./object/omitBy.js"; +import { pick } from "./object/pick.js"; +import { pickBy } from "./object/pickBy.js"; +import { property } from "./object/property.js"; +import { propertyOf } from "./object/propertyOf.js"; +import { result } from "./object/result.js"; +import { set } from "./object/set.js"; +import { setWith } from "./object/setWith.js"; +import { toDefaulted } from "./object/toDefaulted.js"; +import { toPairs } from "./object/toPairs.js"; +import { toPairsIn } from "./object/toPairsIn.js"; +import { transform } from "./object/transform.js"; +import { unset } from "./object/unset.js"; +import { update } from "./object/update.js"; +import { updateWith } from "./object/updateWith.js"; +import { values } from "./object/values.js"; +import { valuesIn } from "./object/valuesIn.js"; +import { isFunction } from "./predicate/isFunction.js"; +import { isLength } from "./predicate/isLength.js"; +import { isMatchWith } from "./predicate/isMatchWith.js"; +import { isNative } from "./predicate/isNative.js"; +import { isNull } from "./predicate/isNull.js"; +import { isUndefined } from "./predicate/isUndefined.js"; +import { conforms } from "./predicate/conforms.js"; +import { conformsTo } from "./predicate/conformsTo.js"; +import { isArguments } from "./predicate/isArguments.js"; +import { isArray } from "./predicate/isArray.js"; +import { isArrayBuffer } from "./predicate/isArrayBuffer.js"; +import { isArrayLike } from "./predicate/isArrayLike.js"; +import { isArrayLikeObject } from "./predicate/isArrayLikeObject.js"; +import { isBoolean } from "./predicate/isBoolean.js"; +import { isBuffer } from "./predicate/isBuffer.js"; +import { isDate } from "./predicate/isDate.js"; +import { isElement } from "./predicate/isElement.js"; +import { isEmpty } from "./predicate/isEmpty.js"; +import { isEqualWith } from "./predicate/isEqualWith.js"; +import { isError } from "./predicate/isError.js"; +import { isFinite } from "./predicate/isFinite.js"; +import { isInteger } from "./predicate/isInteger.js"; +import { isMap } from "./predicate/isMap.js"; +import { isMatch } from "./predicate/isMatch.js"; +import { isNaN } from "./predicate/isNaN.js"; +import { isNil } from "./predicate/isNil.js"; +import { isNumber } from "./predicate/isNumber.js"; +import { isObject } from "./predicate/isObject.js"; +import { isObjectLike } from "./predicate/isObjectLike.js"; +import { isPlainObject } from "./predicate/isPlainObject.js"; +import { isRegExp } from "./predicate/isRegExp.js"; +import { isSafeInteger } from "./predicate/isSafeInteger.js"; +import { isSet } from "./predicate/isSet.js"; +import { isString } from "./predicate/isString.js"; +import { isSymbol } from "./predicate/isSymbol.js"; +import { isTypedArray } from "./predicate/isTypedArray.js"; +import { isWeakMap } from "./predicate/isWeakMap.js"; +import { isWeakSet } from "./predicate/isWeakSet.js"; +import { matches } from "./predicate/matches.js"; +import { matchesProperty } from "./predicate/matchesProperty.js"; +import { capitalize } from "./string/capitalize.js"; +import { bindAll } from "./util/bindAll.js"; +import { camelCase } from "./string/camelCase.js"; +import { deburr } from "./string/deburr.js"; +import { endsWith } from "./string/endsWith.js"; +import { escape } from "./string/escape.js"; +import { escapeRegExp } from "./string/escapeRegExp.js"; +import { kebabCase } from "./string/kebabCase.js"; +import { lowerCase } from "./string/lowerCase.js"; +import { lowerFirst } from "./string/lowerFirst.js"; +import { pad } from "./string/pad.js"; +import { padEnd } from "./string/padEnd.js"; +import { padStart } from "./string/padStart.js"; +import { repeat } from "./string/repeat.js"; +import { replace } from "./string/replace.js"; +import { snakeCase } from "./string/snakeCase.js"; +import { split } from "./string/split.js"; +import { startCase } from "./string/startCase.js"; +import { startsWith } from "./string/startsWith.js"; +import { template } from "./string/template.js"; +import { templateSettings } from "./string/templateSettings.js"; +import { toLower } from "./string/toLower.js"; +import { toUpper } from "./string/toUpper.js"; +import { trim } from "./string/trim.js"; +import { trimEnd } from "./string/trimEnd.js"; +import { trimStart } from "./string/trimStart.js"; +import { truncate } from "./string/truncate.js"; +import { unescape } from "./string/unescape.js"; +import { upperCase } from "./string/upperCase.js"; +import { upperFirst } from "./string/upperFirst.js"; +import { words } from "./string/words.js"; +import { cond } from "./util/cond.js"; +import { constant } from "./util/constant.js"; +import { defaultTo } from "./util/defaultTo.js"; +import { eq } from "./util/eq.js"; +import { gt } from "./util/gt.js"; +import { gte } from "./util/gte.js"; +import { invoke } from "./util/invoke.js"; +import { iteratee } from "./util/iteratee.js"; +import { lt } from "./util/lt.js"; +import { lte } from "./util/lte.js"; +import { method } from "./util/method.js"; +import { methodOf } from "./util/methodOf.js"; +import { now } from "./util/now.js"; +import { over } from "./util/over.js"; +import { overEvery } from "./util/overEvery.js"; +import { overSome } from "./util/overSome.js"; +import { stubArray } from "./util/stubArray.js"; +import { stubFalse } from "./util/stubFalse.js"; +import { stubObject } from "./util/stubObject.js"; +import { stubString } from "./util/stubString.js"; +import { stubTrue } from "./util/stubTrue.js"; +import { times } from "./util/times.js"; +import { toArray } from "./util/toArray.js"; +import { toFinite } from "./util/toFinite.js"; +import { toInteger } from "./util/toInteger.js"; +import { toLength } from "./util/toLength.js"; +import { toNumber } from "./util/toNumber.js"; +import { toPath } from "./util/toPath.js"; +import { toPlainObject } from "./util/toPlainObject.js"; +import { toSafeInteger } from "./util/toSafeInteger.js"; +import { toString } from "./util/toString.js"; +import { uniqueId } from "./util/uniqueId.js"; +export { DebouncedFunc, add, after, ary, assign, assignIn, assignInWith, assignWith, at, attempt, before, bind, bindAll, bindKey, camelCase, capitalize, castArray, ceil, chunk, clamp, clone, cloneDeep, cloneDeepWith, cloneWith, compact, concat, cond, conforms, conformsTo, constant, countBy, create, curry, curryRight, debounce, deburr, toolkit as default, defaultTo, defaults, defaultsDeep, defer, delay, difference, differenceBy, differenceWith, divide, drop, dropRight, dropRightWhile, dropWhile, forEach as each, forEachRight as eachRight, endsWith, eq, escape, escapeRegExp, every, assignIn as extend, assignInWith as extendWith, fill, filter, find, findIndex, findKey, findLast, findLastIndex, findLastKey, head as first, flatMap, flatMapDeep, flatMapDepth, flatten, flattenDeep, flattenDepth, flip, floor, flow, flowRight, forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, fromPairs, functions, functionsIn, get, groupBy, gt, gte, has, hasIn, head, identity, inRange, includes, indexOf, initial, intersection, intersectionBy, intersectionWith, invert, invertBy, invoke, invokeMap, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, iteratee, join, kebabCase, keyBy, keys, keysIn, last, lastIndexOf, lowerCase, lowerFirst, lt, lte, map, mapKeys, mapValues, matches, matchesProperty, max, maxBy, mean, meanBy, memoize, merge, mergeWith, method, methodOf, min, minBy, multiply, negate, noop, now, nth, nthArg, omit, omitBy, once, orderBy, over, overArgs, overEvery, overSome, pad, padEnd, padStart, parseInt, partial, partialRight, partition, pick, pickBy, property, propertyOf, pull, pullAll, pullAllBy, pullAllWith, pullAt, random, range, rangeRight, rearg, reduce, reduceRight, reject, remove, repeat, replace, rest, result, reverse, round, sample, sampleSize, set, setWith, shuffle, size, slice, snakeCase, some, sortBy, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, split, spread, startCase, startsWith, stubArray, stubFalse, stubObject, stubString, stubTrue, subtract, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, template, templateSettings, throttle, times, toArray, toDefaulted, toFinite, toInteger, toLength, toLower, toNumber, toPairs, toPairsIn, toPath, toPlainObject, toSafeInteger, toString, toUpper, transform, trim, trimEnd, trimStart, truncate, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, uniqueId, unset, unzip, unzipWith, update, updateWith, upperCase, upperFirst, values, valuesIn, without, words, wrap, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/index.js b/node_modules/es-toolkit/dist/compat/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1fd502008b5d0d637775655615a1017b19c39ae2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/index.js @@ -0,0 +1,596 @@ +Object.defineProperties(exports, { + __esModule: { value: true }, + [Symbol.toStringTag]: { value: "Module" } +}); +const require_isArray = require("./predicate/isArray.js"); +const require_isPlainObject = require("./predicate/isPlainObject.js"); +const require_eq = require("./util/eq.js"); +const require_isEqual = require("../predicate/isEqual.js"); +const require_castArray = require("./array/castArray.js"); +const require_isArrayLike = require("./predicate/isArrayLike.js"); +const require_chunk = require("./array/chunk.js"); +const require_compact = require("./array/compact.js"); +const require_concat = require("./array/concat.js"); +const require_toString = require("./util/toString.js"); +const require_toPath = require("./util/toPath.js"); +const require_get = require("./object/get.js"); +const require_property = require("./object/property.js"); +const require_isObject = require("./predicate/isObject.js"); +const require_isMatchWith = require("./predicate/isMatchWith.js"); +const require_isMatch = require("./predicate/isMatch.js"); +const require_matches = require("./predicate/matches.js"); +const require_cloneDeepWith = require("./object/cloneDeepWith.js"); +const require_cloneDeep = require("./object/cloneDeep.js"); +const require_isArguments = require("./predicate/isArguments.js"); +const require_has = require("./object/has.js"); +const require_matchesProperty = require("./predicate/matchesProperty.js"); +const require_iteratee = require("./util/iteratee.js"); +const require_countBy = require("./array/countBy.js"); +const require_isObjectLike = require("./predicate/isObjectLike.js"); +const require_isArrayLikeObject = require("./predicate/isArrayLikeObject.js"); +const require_difference = require("./array/difference.js"); +const require_last = require("./array/last.js"); +const require_differenceBy = require("./array/differenceBy.js"); +const require_differenceWith = require("./array/differenceWith.js"); +const require_isSymbol = require("./predicate/isSymbol.js"); +const require_toNumber = require("./util/toNumber.js"); +const require_toFinite = require("./util/toFinite.js"); +const require_toInteger = require("./util/toInteger.js"); +const require_drop = require("./array/drop.js"); +const require_dropRight = require("./array/dropRight.js"); +const require_dropRightWhile = require("./array/dropRightWhile.js"); +const require_dropWhile = require("./array/dropWhile.js"); +const require_forEach = require("./array/forEach.js"); +const require_forEachRight = require("./array/forEachRight.js"); +const require_every = require("./array/every.js"); +const require_isString = require("./predicate/isString.js"); +const require_fill = require("./array/fill.js"); +const require_filter = require("./array/filter.js"); +const require_find = require("./array/find.js"); +const require_identity = require("./function/identity.js"); +const require_findIndex = require("./array/findIndex.js"); +const require_findLast = require("./array/findLast.js"); +const require_findLastIndex = require("./array/findLastIndex.js"); +const require_head = require("./array/head.js"); +const require_flattenDepth = require("./array/flattenDepth.js"); +const require_map = require("./array/map.js"); +const require_flatMap = require("./array/flatMap.js"); +const require_flatMapDepth = require("./array/flatMapDepth.js"); +const require_flatMapDeep = require("./array/flatMapDeep.js"); +const require_flatten = require("./array/flatten.js"); +const require_flattenDeep = require("./array/flattenDeep.js"); +const require_groupBy = require("./array/groupBy.js"); +const require_includes = require("./array/includes.js"); +const require_indexOf = require("./array/indexOf.js"); +const require_initial = require("./array/initial.js"); +const require_intersection = require("./array/intersection.js"); +const require_intersectionBy = require("./array/intersectionBy.js"); +const require_uniq = require("./array/uniq.js"); +const require_intersectionWith = require("./array/intersectionWith.js"); +const require_invokeMap = require("./array/invokeMap.js"); +const require_join = require("./array/join.js"); +const require_reduce = require("./array/reduce.js"); +const require_keyBy = require("./array/keyBy.js"); +const require_lastIndexOf = require("./array/lastIndexOf.js"); +const require_nth = require("./array/nth.js"); +const require_orderBy = require("./array/orderBy.js"); +const require_partition = require("./array/partition.js"); +const require_pull = require("./array/pull.js"); +const require_pullAll = require("./array/pullAll.js"); +const require_pullAllBy = require("./array/pullAllBy.js"); +const require_pullAllWith = require("./array/pullAllWith.js"); +const require_at = require("./object/at.js"); +const require_unset = require("./object/unset.js"); +const require_pullAt = require("./array/pullAt.js"); +const require_reduceRight = require("./array/reduceRight.js"); +const require_negate = require("./function/negate.js"); +const require_reject = require("./array/reject.js"); +const require_remove = require("./array/remove.js"); +const require_reverse = require("./array/reverse.js"); +const require_sample = require("./array/sample.js"); +const require_clamp = require("./math/clamp.js"); +const require_isMap = require("./predicate/isMap.js"); +const require_isSet = require("./predicate/isSet.js"); +const require_toArray = require("./util/toArray.js"); +const require_sampleSize = require("./array/sampleSize.js"); +const require_isTypedArray = require("./predicate/isTypedArray.js"); +const require_times = require("./util/times.js"); +const require_keys = require("./object/keys.js"); +const require_values = require("./object/values.js"); +const require_isNil = require("./predicate/isNil.js"); +const require_shuffle = require("./array/shuffle.js"); +const require_size = require("./array/size.js"); +const require_slice = require("./array/slice.js"); +const require_some = require("./array/some.js"); +const require_sortBy = require("./array/sortBy.js"); +const require_isNumber = require("./predicate/isNumber.js"); +const require_isNaN = require("./predicate/isNaN.js"); +const require_sortedIndexBy = require("./array/sortedIndexBy.js"); +const require_sortedIndex = require("./array/sortedIndex.js"); +const require_sortedIndexOf = require("./array/sortedIndexOf.js"); +const require_sortedLastIndexBy = require("./array/sortedLastIndexBy.js"); +const require_sortedLastIndex = require("./array/sortedLastIndex.js"); +const require_sortedLastIndexOf = require("./array/sortedLastIndexOf.js"); +const require_tail = require("./array/tail.js"); +const require_take = require("./array/take.js"); +const require_takeRight = require("./array/takeRight.js"); +const require_takeRightWhile = require("./array/takeRightWhile.js"); +const require_takeWhile = require("./array/takeWhile.js"); +const require_union = require("./array/union.js"); +const require_unionBy = require("./array/unionBy.js"); +const require_unionWith = require("./array/unionWith.js"); +const require_uniqBy = require("./array/uniqBy.js"); +const require_uniqWith = require("./array/uniqWith.js"); +const require_unzip = require("./array/unzip.js"); +const require_unzipWith = require("./array/unzipWith.js"); +const require_without = require("./array/without.js"); +const require_xor = require("./array/xor.js"); +const require_xorBy = require("./array/xorBy.js"); +const require_xorWith = require("./array/xorWith.js"); +const require_zip = require("./array/zip.js"); +const require_zipObject = require("./array/zipObject.js"); +const require_updateWith = require("./object/updateWith.js"); +const require_set = require("./object/set.js"); +const require_zipObjectDeep = require("./array/zipObjectDeep.js"); +const require_zipWith = require("./array/zipWith.js"); +const require_after = require("./function/after.js"); +const require_ary = require("./function/ary.js"); +const require_attempt = require("./function/attempt.js"); +const require_before = require("./function/before.js"); +const require_bind = require("./function/bind.js"); +const require_bindKey = require("./function/bindKey.js"); +const require_curry = require("./function/curry.js"); +const require_curryRight = require("./function/curryRight.js"); +const require_debounce = require("./function/debounce.js"); +const require_defer = require("./function/defer.js"); +const require_delay = require("./function/delay.js"); +const require_flip = require("./function/flip.js"); +const require_flow = require("./function/flow.js"); +const require_flowRight = require("./function/flowRight.js"); +const require_memoize = require("./function/memoize.js"); +const require_nthArg = require("./function/nthArg.js"); +const require_once = require("./function/once.js"); +const require_overArgs = require("./function/overArgs.js"); +const require_partial = require("./function/partial.js"); +const require_partialRight = require("./function/partialRight.js"); +const require_rearg = require("./function/rearg.js"); +const require_rest = require("./function/rest.js"); +const require_spread = require("./function/spread.js"); +const require_throttle = require("./function/throttle.js"); +const require_unary = require("./function/unary.js"); +const require_wrap = require("./function/wrap.js"); +const require_add = require("./math/add.js"); +const require_ceil = require("./math/ceil.js"); +const require_divide = require("./math/divide.js"); +const require_floor = require("./math/floor.js"); +const require_inRange = require("./math/inRange.js"); +const require_max = require("./math/max.js"); +const require_maxBy = require("./math/maxBy.js"); +const require_sumBy = require("./math/sumBy.js"); +const require_sum = require("./math/sum.js"); +const require_mean = require("./math/mean.js"); +const require_meanBy = require("./math/meanBy.js"); +const require_min = require("./math/min.js"); +const require_minBy = require("./math/minBy.js"); +const require_multiply = require("./math/multiply.js"); +const require_parseInt = require("./math/parseInt.js"); +const require_random = require("./math/random.js"); +const require_range = require("./math/range.js"); +const require_rangeRight = require("./math/rangeRight.js"); +const require_round = require("./math/round.js"); +const require_subtract = require("./math/subtract.js"); +const require_noop = require("./function/noop.js"); +const require_assign = require("./object/assign.js"); +const require_keysIn = require("./object/keysIn.js"); +const require_assignIn = require("./object/assignIn.js"); +const require_assignInWith = require("./object/assignInWith.js"); +const require_assignWith = require("./object/assignWith.js"); +const require_clone = require("./object/clone.js"); +const require_cloneWith = require("./object/cloneWith.js"); +const require_create = require("./object/create.js"); +const require_defaults = require("./object/defaults.js"); +const require_defaultsDeep = require("./object/defaultsDeep.js"); +const require_findKey = require("./object/findKey.js"); +const require_findLastKey = require("./object/findLastKey.js"); +const require_forIn = require("./object/forIn.js"); +const require_forInRight = require("./object/forInRight.js"); +const require_forOwn = require("./object/forOwn.js"); +const require_forOwnRight = require("./object/forOwnRight.js"); +const require_fromPairs = require("./object/fromPairs.js"); +const require_functions = require("./object/functions.js"); +const require_functionsIn = require("./object/functionsIn.js"); +const require_hasIn = require("./object/hasIn.js"); +const require_invert = require("./object/invert.js"); +const require_invertBy = require("./object/invertBy.js"); +const require_mapKeys = require("./object/mapKeys.js"); +const require_mapValues = require("./object/mapValues.js"); +const require_mergeWith = require("./object/mergeWith.js"); +const require_merge = require("./object/merge.js"); +const require_omit = require("./object/omit.js"); +const require_omitBy = require("./object/omitBy.js"); +const require_pick = require("./object/pick.js"); +const require_pickBy = require("./object/pickBy.js"); +const require_propertyOf = require("./object/propertyOf.js"); +const require_result = require("./object/result.js"); +const require_setWith = require("./object/setWith.js"); +const require_toDefaulted = require("./object/toDefaulted.js"); +const require_toPairs = require("./object/toPairs.js"); +const require_toPairsIn = require("./object/toPairsIn.js"); +const require_isBuffer = require("./predicate/isBuffer.js"); +const require_transform = require("./object/transform.js"); +const require_update = require("./object/update.js"); +const require_valuesIn = require("./object/valuesIn.js"); +const require_isFunction = require("./predicate/isFunction.js"); +const require_isLength = require("./predicate/isLength.js"); +const require_isNative = require("./predicate/isNative.js"); +const require_isNull = require("./predicate/isNull.js"); +const require_isUndefined = require("./predicate/isUndefined.js"); +const require_conformsTo = require("./predicate/conformsTo.js"); +const require_conforms = require("./predicate/conforms.js"); +const require_isArrayBuffer = require("./predicate/isArrayBuffer.js"); +const require_isBoolean = require("./predicate/isBoolean.js"); +const require_isDate = require("./predicate/isDate.js"); +const require_isElement = require("./predicate/isElement.js"); +const require_isEmpty = require("./predicate/isEmpty.js"); +const require_isEqualWith = require("./predicate/isEqualWith.js"); +const require_isError = require("./predicate/isError.js"); +const require_isFinite = require("./predicate/isFinite.js"); +const require_isInteger = require("./predicate/isInteger.js"); +const require_isRegExp = require("./predicate/isRegExp.js"); +const require_isSafeInteger = require("./predicate/isSafeInteger.js"); +const require_isWeakMap = require("./predicate/isWeakMap.js"); +const require_isWeakSet = require("./predicate/isWeakSet.js"); +const require_capitalize = require("./string/capitalize.js"); +const require_bindAll = require("./util/bindAll.js"); +const require_deburr = require("./string/deburr.js"); +const require_words = require("./string/words.js"); +const require_camelCase = require("./string/camelCase.js"); +const require_endsWith = require("./string/endsWith.js"); +const require_escape = require("./string/escape.js"); +const require_escapeRegExp = require("./string/escapeRegExp.js"); +const require_kebabCase = require("./string/kebabCase.js"); +const require_lowerCase = require("./string/lowerCase.js"); +const require_lowerFirst = require("./string/lowerFirst.js"); +const require_pad = require("./string/pad.js"); +const require_padEnd = require("./string/padEnd.js"); +const require_padStart = require("./string/padStart.js"); +const require_repeat = require("./string/repeat.js"); +const require_replace = require("./string/replace.js"); +const require_snakeCase = require("./string/snakeCase.js"); +const require_split = require("./string/split.js"); +const require_startCase = require("./string/startCase.js"); +const require_startsWith = require("./string/startsWith.js"); +const require_template = require("./string/template.js"); +const require_templateSettings = require("./string/templateSettings.js"); +const require_toLower = require("./string/toLower.js"); +const require_toUpper = require("./string/toUpper.js"); +const require_trim = require("./string/trim.js"); +const require_trimEnd = require("./string/trimEnd.js"); +const require_trimStart = require("./string/trimStart.js"); +const require_truncate = require("./string/truncate.js"); +const require_unescape = require("./string/unescape.js"); +const require_upperCase = require("./string/upperCase.js"); +const require_upperFirst = require("./string/upperFirst.js"); +const require_cond = require("./util/cond.js"); +const require_constant = require("./util/constant.js"); +const require_defaultTo = require("./util/defaultTo.js"); +const require_gt = require("./util/gt.js"); +const require_gte = require("./util/gte.js"); +const require_invoke = require("./util/invoke.js"); +const require_lt = require("./util/lt.js"); +const require_lte = require("./util/lte.js"); +const require_method = require("./util/method.js"); +const require_methodOf = require("./util/methodOf.js"); +const require_now = require("./util/now.js"); +const require_over = require("./util/over.js"); +const require_overEvery = require("./util/overEvery.js"); +const require_overSome = require("./util/overSome.js"); +const require_stubArray = require("./util/stubArray.js"); +const require_stubFalse = require("./util/stubFalse.js"); +const require_stubObject = require("./util/stubObject.js"); +const require_stubString = require("./util/stubString.js"); +const require_stubTrue = require("./util/stubTrue.js"); +const require_toLength = require("./util/toLength.js"); +const require_toPlainObject = require("./util/toPlainObject.js"); +const require_toSafeInteger = require("./util/toSafeInteger.js"); +const require_uniqueId = require("./util/uniqueId.js"); +require("./compat.js"); +const require_toolkit = require("./toolkit.js"); +exports.add = require_add.add; +exports.after = require_after.after; +exports.ary = require_ary.ary; +exports.assign = require_assign.assign; +exports.assignIn = require_assignIn.assignIn; +exports.assignInWith = require_assignInWith.assignInWith; +exports.assignWith = require_assignWith.assignWith; +exports.at = require_at.at; +exports.attempt = require_attempt.attempt; +exports.before = require_before.before; +exports.bind = require_bind.bind; +exports.bindAll = require_bindAll.bindAll; +exports.bindKey = require_bindKey.bindKey; +exports.camelCase = require_camelCase.camelCase; +exports.capitalize = require_capitalize.capitalize; +exports.castArray = require_castArray.castArray; +exports.ceil = require_ceil.ceil; +exports.chunk = require_chunk.chunk; +exports.clamp = require_clamp.clamp; +exports.clone = require_clone.clone; +exports.cloneDeep = require_cloneDeep.cloneDeep; +exports.cloneDeepWith = require_cloneDeepWith.cloneDeepWith; +exports.cloneWith = require_cloneWith.cloneWith; +exports.compact = require_compact.compact; +exports.concat = require_concat.concat; +exports.cond = require_cond.cond; +exports.conforms = require_conforms.conforms; +exports.conformsTo = require_conformsTo.conformsTo; +exports.constant = require_constant.constant; +exports.countBy = require_countBy.countBy; +exports.create = require_create.create; +exports.curry = require_curry.curry; +exports.curryRight = require_curryRight.curryRight; +exports.debounce = require_debounce.debounce; +exports.deburr = require_deburr.deburr; +exports.default = require_toolkit.toolkit; +exports.defaultTo = require_defaultTo.defaultTo; +exports.defaults = require_defaults.defaults; +exports.defaultsDeep = require_defaultsDeep.defaultsDeep; +exports.defer = require_defer.defer; +exports.delay = require_delay.delay; +exports.difference = require_difference.difference; +exports.differenceBy = require_differenceBy.differenceBy; +exports.differenceWith = require_differenceWith.differenceWith; +exports.divide = require_divide.divide; +exports.drop = require_drop.drop; +exports.dropRight = require_dropRight.dropRight; +exports.dropRightWhile = require_dropRightWhile.dropRightWhile; +exports.dropWhile = require_dropWhile.dropWhile; +exports.each = require_forEach.forEach; +exports.eachRight = require_forEachRight.forEachRight; +exports.endsWith = require_endsWith.endsWith; +exports.eq = require_eq.eq; +exports.escape = require_escape.escape; +exports.escapeRegExp = require_escapeRegExp.escapeRegExp; +exports.every = require_every.every; +exports.extend = require_assignIn.assignIn; +exports.extendWith = require_assignInWith.assignInWith; +exports.fill = require_fill.fill; +exports.filter = require_filter.filter; +exports.find = require_find.find; +exports.findIndex = require_findIndex.findIndex; +exports.findKey = require_findKey.findKey; +exports.findLast = require_findLast.findLast; +exports.findLastIndex = require_findLastIndex.findLastIndex; +exports.findLastKey = require_findLastKey.findLastKey; +exports.first = require_head.head; +exports.flatMap = require_flatMap.flatMap; +exports.flatMapDeep = require_flatMapDeep.flatMapDeep; +exports.flatMapDepth = require_flatMapDepth.flatMapDepth; +exports.flatten = require_flatten.flatten; +exports.flattenDeep = require_flattenDeep.flattenDeep; +exports.flattenDepth = require_flattenDepth.flattenDepth; +exports.flip = require_flip.flip; +exports.floor = require_floor.floor; +exports.flow = require_flow.flow; +exports.flowRight = require_flowRight.flowRight; +exports.forEach = require_forEach.forEach; +exports.forEachRight = require_forEachRight.forEachRight; +exports.forIn = require_forIn.forIn; +exports.forInRight = require_forInRight.forInRight; +exports.forOwn = require_forOwn.forOwn; +exports.forOwnRight = require_forOwnRight.forOwnRight; +exports.fromPairs = require_fromPairs.fromPairs; +exports.functions = require_functions.functions; +exports.functionsIn = require_functionsIn.functionsIn; +exports.get = require_get.get; +exports.groupBy = require_groupBy.groupBy; +exports.gt = require_gt.gt; +exports.gte = require_gte.gte; +exports.has = require_has.has; +exports.hasIn = require_hasIn.hasIn; +exports.head = require_head.head; +exports.identity = require_identity.identity; +exports.inRange = require_inRange.inRange; +exports.includes = require_includes.includes; +exports.indexOf = require_indexOf.indexOf; +exports.initial = require_initial.initial; +exports.intersection = require_intersection.intersection; +exports.intersectionBy = require_intersectionBy.intersectionBy; +exports.intersectionWith = require_intersectionWith.intersectionWith; +exports.invert = require_invert.invert; +exports.invertBy = require_invertBy.invertBy; +exports.invoke = require_invoke.invoke; +exports.invokeMap = require_invokeMap.invokeMap; +exports.isArguments = require_isArguments.isArguments; +exports.isArray = require_isArray.isArray; +exports.isArrayBuffer = require_isArrayBuffer.isArrayBuffer; +exports.isArrayLike = require_isArrayLike.isArrayLike; +exports.isArrayLikeObject = require_isArrayLikeObject.isArrayLikeObject; +exports.isBoolean = require_isBoolean.isBoolean; +exports.isBuffer = require_isBuffer.isBuffer; +exports.isDate = require_isDate.isDate; +exports.isElement = require_isElement.isElement; +exports.isEmpty = require_isEmpty.isEmpty; +exports.isEqual = require_isEqual.isEqual; +exports.isEqualWith = require_isEqualWith.isEqualWith; +exports.isError = require_isError.isError; +exports.isFinite = require_isFinite.isFinite; +exports.isFunction = require_isFunction.isFunction; +exports.isInteger = require_isInteger.isInteger; +exports.isLength = require_isLength.isLength; +exports.isMap = require_isMap.isMap; +exports.isMatch = require_isMatch.isMatch; +exports.isMatchWith = require_isMatchWith.isMatchWith; +exports.isNaN = require_isNaN.isNaN; +exports.isNative = require_isNative.isNative; +exports.isNil = require_isNil.isNil; +exports.isNull = require_isNull.isNull; +exports.isNumber = require_isNumber.isNumber; +exports.isObject = require_isObject.isObject; +exports.isObjectLike = require_isObjectLike.isObjectLike; +exports.isPlainObject = require_isPlainObject.isPlainObject; +exports.isRegExp = require_isRegExp.isRegExp; +exports.isSafeInteger = require_isSafeInteger.isSafeInteger; +exports.isSet = require_isSet.isSet; +exports.isString = require_isString.isString; +exports.isSymbol = require_isSymbol.isSymbol; +exports.isTypedArray = require_isTypedArray.isTypedArray; +exports.isUndefined = require_isUndefined.isUndefined; +exports.isWeakMap = require_isWeakMap.isWeakMap; +exports.isWeakSet = require_isWeakSet.isWeakSet; +exports.iteratee = require_iteratee.iteratee; +exports.join = require_join.join; +exports.kebabCase = require_kebabCase.kebabCase; +exports.keyBy = require_keyBy.keyBy; +exports.keys = require_keys.keys; +exports.keysIn = require_keysIn.keysIn; +exports.last = require_last.last; +exports.lastIndexOf = require_lastIndexOf.lastIndexOf; +exports.lowerCase = require_lowerCase.lowerCase; +exports.lowerFirst = require_lowerFirst.lowerFirst; +exports.lt = require_lt.lt; +exports.lte = require_lte.lte; +exports.map = require_map.map; +exports.mapKeys = require_mapKeys.mapKeys; +exports.mapValues = require_mapValues.mapValues; +exports.matches = require_matches.matches; +exports.matchesProperty = require_matchesProperty.matchesProperty; +exports.max = require_max.max; +exports.maxBy = require_maxBy.maxBy; +exports.mean = require_mean.mean; +exports.meanBy = require_meanBy.meanBy; +exports.memoize = require_memoize.memoize; +exports.merge = require_merge.merge; +exports.mergeWith = require_mergeWith.mergeWith; +exports.method = require_method.method; +exports.methodOf = require_methodOf.methodOf; +exports.min = require_min.min; +exports.minBy = require_minBy.minBy; +exports.multiply = require_multiply.multiply; +exports.negate = require_negate.negate; +exports.noop = require_noop.noop; +exports.now = require_now.now; +exports.nth = require_nth.nth; +exports.nthArg = require_nthArg.nthArg; +exports.omit = require_omit.omit; +exports.omitBy = require_omitBy.omitBy; +exports.once = require_once.once; +exports.orderBy = require_orderBy.orderBy; +exports.over = require_over.over; +exports.overArgs = require_overArgs.overArgs; +exports.overEvery = require_overEvery.overEvery; +exports.overSome = require_overSome.overSome; +exports.pad = require_pad.pad; +exports.padEnd = require_padEnd.padEnd; +exports.padStart = require_padStart.padStart; +exports.parseInt = require_parseInt.parseInt; +exports.partial = require_partial.partial; +exports.partialRight = require_partialRight.partialRight; +exports.partition = require_partition.partition; +exports.pick = require_pick.pick; +exports.pickBy = require_pickBy.pickBy; +exports.property = require_property.property; +exports.propertyOf = require_propertyOf.propertyOf; +exports.pull = require_pull.pull; +exports.pullAll = require_pullAll.pullAll; +exports.pullAllBy = require_pullAllBy.pullAllBy; +exports.pullAllWith = require_pullAllWith.pullAllWith; +exports.pullAt = require_pullAt.pullAt; +exports.random = require_random.random; +exports.range = require_range.range; +exports.rangeRight = require_rangeRight.rangeRight; +exports.rearg = require_rearg.rearg; +exports.reduce = require_reduce.reduce; +exports.reduceRight = require_reduceRight.reduceRight; +exports.reject = require_reject.reject; +exports.remove = require_remove.remove; +exports.repeat = require_repeat.repeat; +exports.replace = require_replace.replace; +exports.rest = require_rest.rest; +exports.result = require_result.result; +exports.reverse = require_reverse.reverse; +exports.round = require_round.round; +exports.sample = require_sample.sample; +exports.sampleSize = require_sampleSize.sampleSize; +exports.set = require_set.set; +exports.setWith = require_setWith.setWith; +exports.shuffle = require_shuffle.shuffle; +exports.size = require_size.size; +exports.slice = require_slice.slice; +exports.snakeCase = require_snakeCase.snakeCase; +exports.some = require_some.some; +exports.sortBy = require_sortBy.sortBy; +exports.sortedIndex = require_sortedIndex.sortedIndex; +exports.sortedIndexBy = require_sortedIndexBy.sortedIndexBy; +exports.sortedIndexOf = require_sortedIndexOf.sortedIndexOf; +exports.sortedLastIndex = require_sortedLastIndex.sortedLastIndex; +exports.sortedLastIndexBy = require_sortedLastIndexBy.sortedLastIndexBy; +exports.sortedLastIndexOf = require_sortedLastIndexOf.sortedLastIndexOf; +exports.split = require_split.split; +exports.spread = require_spread.spread; +exports.startCase = require_startCase.startCase; +exports.startsWith = require_startsWith.startsWith; +exports.stubArray = require_stubArray.stubArray; +exports.stubFalse = require_stubFalse.stubFalse; +exports.stubObject = require_stubObject.stubObject; +exports.stubString = require_stubString.stubString; +exports.stubTrue = require_stubTrue.stubTrue; +exports.subtract = require_subtract.subtract; +exports.sum = require_sum.sum; +exports.sumBy = require_sumBy.sumBy; +exports.tail = require_tail.tail; +exports.take = require_take.take; +exports.takeRight = require_takeRight.takeRight; +exports.takeRightWhile = require_takeRightWhile.takeRightWhile; +exports.takeWhile = require_takeWhile.takeWhile; +exports.template = require_template.template; +exports.templateSettings = require_templateSettings.templateSettings; +exports.throttle = require_throttle.throttle; +exports.times = require_times.times; +exports.toArray = require_toArray.toArray; +exports.toDefaulted = require_toDefaulted.toDefaulted; +exports.toFinite = require_toFinite.toFinite; +exports.toInteger = require_toInteger.toInteger; +exports.toLength = require_toLength.toLength; +exports.toLower = require_toLower.toLower; +exports.toNumber = require_toNumber.toNumber; +exports.toPairs = require_toPairs.toPairs; +exports.toPairsIn = require_toPairsIn.toPairsIn; +exports.toPath = require_toPath.toPath; +exports.toPlainObject = require_toPlainObject.toPlainObject; +exports.toSafeInteger = require_toSafeInteger.toSafeInteger; +exports.toString = require_toString.toString; +exports.toUpper = require_toUpper.toUpper; +exports.transform = require_transform.transform; +exports.trim = require_trim.trim; +exports.trimEnd = require_trimEnd.trimEnd; +exports.trimStart = require_trimStart.trimStart; +exports.truncate = require_truncate.truncate; +exports.unary = require_unary.unary; +exports.unescape = require_unescape.unescape; +exports.union = require_union.union; +exports.unionBy = require_unionBy.unionBy; +exports.unionWith = require_unionWith.unionWith; +exports.uniq = require_uniq.uniq; +exports.uniqBy = require_uniqBy.uniqBy; +exports.uniqWith = require_uniqWith.uniqWith; +exports.uniqueId = require_uniqueId.uniqueId; +exports.unset = require_unset.unset; +exports.unzip = require_unzip.unzip; +exports.unzipWith = require_unzipWith.unzipWith; +exports.update = require_update.update; +exports.updateWith = require_updateWith.updateWith; +exports.upperCase = require_upperCase.upperCase; +exports.upperFirst = require_upperFirst.upperFirst; +exports.values = require_values.values; +exports.valuesIn = require_valuesIn.valuesIn; +exports.without = require_without.without; +exports.words = require_words.words; +exports.wrap = require_wrap.wrap; +exports.xor = require_xor.xor; +exports.xorBy = require_xorBy.xorBy; +exports.xorWith = require_xorWith.xorWith; +exports.zip = require_zip.zip; +exports.zipObject = require_zipObject.zipObject; +exports.zipObjectDeep = require_zipObjectDeep.zipObjectDeep; +exports.zipWith = require_zipWith.zipWith; diff --git a/node_modules/es-toolkit/dist/compat/index.mjs b/node_modules/es-toolkit/dist/compat/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..eb9b923074ab22020b327c8d67a102f0d49860bc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/index.mjs @@ -0,0 +1,295 @@ +import { isArray } from "./predicate/isArray.mjs"; +import { isPlainObject } from "./predicate/isPlainObject.mjs"; +import { eq } from "./util/eq.mjs"; +import { isEqual } from "../predicate/isEqual.mjs"; +import { castArray } from "./array/castArray.mjs"; +import { isArrayLike } from "./predicate/isArrayLike.mjs"; +import { chunk } from "./array/chunk.mjs"; +import { compact } from "./array/compact.mjs"; +import { concat } from "./array/concat.mjs"; +import { toString } from "./util/toString.mjs"; +import { toPath } from "./util/toPath.mjs"; +import { get } from "./object/get.mjs"; +import { property } from "./object/property.mjs"; +import { isObject } from "./predicate/isObject.mjs"; +import { isMatchWith } from "./predicate/isMatchWith.mjs"; +import { isMatch } from "./predicate/isMatch.mjs"; +import { matches } from "./predicate/matches.mjs"; +import { cloneDeepWith } from "./object/cloneDeepWith.mjs"; +import { cloneDeep } from "./object/cloneDeep.mjs"; +import { isArguments } from "./predicate/isArguments.mjs"; +import { has } from "./object/has.mjs"; +import { matchesProperty } from "./predicate/matchesProperty.mjs"; +import { iteratee } from "./util/iteratee.mjs"; +import { countBy } from "./array/countBy.mjs"; +import { isObjectLike } from "./predicate/isObjectLike.mjs"; +import { isArrayLikeObject } from "./predicate/isArrayLikeObject.mjs"; +import { difference } from "./array/difference.mjs"; +import { last } from "./array/last.mjs"; +import { differenceBy } from "./array/differenceBy.mjs"; +import { differenceWith } from "./array/differenceWith.mjs"; +import { isSymbol } from "./predicate/isSymbol.mjs"; +import { toNumber } from "./util/toNumber.mjs"; +import { toFinite } from "./util/toFinite.mjs"; +import { toInteger } from "./util/toInteger.mjs"; +import { drop } from "./array/drop.mjs"; +import { dropRight } from "./array/dropRight.mjs"; +import { dropRightWhile } from "./array/dropRightWhile.mjs"; +import { dropWhile } from "./array/dropWhile.mjs"; +import { forEach } from "./array/forEach.mjs"; +import { forEachRight } from "./array/forEachRight.mjs"; +import { every } from "./array/every.mjs"; +import { isString } from "./predicate/isString.mjs"; +import { fill } from "./array/fill.mjs"; +import { filter } from "./array/filter.mjs"; +import { find } from "./array/find.mjs"; +import { identity } from "./function/identity.mjs"; +import { findIndex } from "./array/findIndex.mjs"; +import { findLast } from "./array/findLast.mjs"; +import { findLastIndex } from "./array/findLastIndex.mjs"; +import { head } from "./array/head.mjs"; +import { flattenDepth } from "./array/flattenDepth.mjs"; +import { map } from "./array/map.mjs"; +import { flatMap } from "./array/flatMap.mjs"; +import { flatMapDepth } from "./array/flatMapDepth.mjs"; +import { flatMapDeep } from "./array/flatMapDeep.mjs"; +import { flatten } from "./array/flatten.mjs"; +import { flattenDeep } from "./array/flattenDeep.mjs"; +import { groupBy } from "./array/groupBy.mjs"; +import { includes } from "./array/includes.mjs"; +import { indexOf } from "./array/indexOf.mjs"; +import { initial } from "./array/initial.mjs"; +import { intersection } from "./array/intersection.mjs"; +import { intersectionBy } from "./array/intersectionBy.mjs"; +import { uniq } from "./array/uniq.mjs"; +import { intersectionWith } from "./array/intersectionWith.mjs"; +import { invokeMap } from "./array/invokeMap.mjs"; +import { join } from "./array/join.mjs"; +import { reduce } from "./array/reduce.mjs"; +import { keyBy } from "./array/keyBy.mjs"; +import { lastIndexOf } from "./array/lastIndexOf.mjs"; +import { nth } from "./array/nth.mjs"; +import { orderBy } from "./array/orderBy.mjs"; +import { partition } from "./array/partition.mjs"; +import { pull } from "./array/pull.mjs"; +import { pullAll } from "./array/pullAll.mjs"; +import { pullAllBy } from "./array/pullAllBy.mjs"; +import { pullAllWith } from "./array/pullAllWith.mjs"; +import { at } from "./object/at.mjs"; +import { unset } from "./object/unset.mjs"; +import { pullAt } from "./array/pullAt.mjs"; +import { reduceRight } from "./array/reduceRight.mjs"; +import { negate } from "./function/negate.mjs"; +import { reject } from "./array/reject.mjs"; +import { remove } from "./array/remove.mjs"; +import { reverse } from "./array/reverse.mjs"; +import { sample } from "./array/sample.mjs"; +import { clamp } from "./math/clamp.mjs"; +import { isMap } from "./predicate/isMap.mjs"; +import { isSet } from "./predicate/isSet.mjs"; +import { toArray } from "./util/toArray.mjs"; +import { sampleSize } from "./array/sampleSize.mjs"; +import { isTypedArray } from "./predicate/isTypedArray.mjs"; +import { times } from "./util/times.mjs"; +import { keys } from "./object/keys.mjs"; +import { values } from "./object/values.mjs"; +import { isNil } from "./predicate/isNil.mjs"; +import { shuffle } from "./array/shuffle.mjs"; +import { size } from "./array/size.mjs"; +import { slice } from "./array/slice.mjs"; +import { some } from "./array/some.mjs"; +import { sortBy } from "./array/sortBy.mjs"; +import { isNumber } from "./predicate/isNumber.mjs"; +import { isNaN } from "./predicate/isNaN.mjs"; +import { sortedIndexBy } from "./array/sortedIndexBy.mjs"; +import { sortedIndex } from "./array/sortedIndex.mjs"; +import { sortedIndexOf } from "./array/sortedIndexOf.mjs"; +import { sortedLastIndexBy } from "./array/sortedLastIndexBy.mjs"; +import { sortedLastIndex } from "./array/sortedLastIndex.mjs"; +import { sortedLastIndexOf } from "./array/sortedLastIndexOf.mjs"; +import { tail } from "./array/tail.mjs"; +import { take } from "./array/take.mjs"; +import { takeRight } from "./array/takeRight.mjs"; +import { takeRightWhile } from "./array/takeRightWhile.mjs"; +import { takeWhile } from "./array/takeWhile.mjs"; +import { union } from "./array/union.mjs"; +import { unionBy } from "./array/unionBy.mjs"; +import { unionWith } from "./array/unionWith.mjs"; +import { uniqBy } from "./array/uniqBy.mjs"; +import { uniqWith } from "./array/uniqWith.mjs"; +import { unzip } from "./array/unzip.mjs"; +import { unzipWith } from "./array/unzipWith.mjs"; +import { without } from "./array/without.mjs"; +import { xor } from "./array/xor.mjs"; +import { xorBy } from "./array/xorBy.mjs"; +import { xorWith } from "./array/xorWith.mjs"; +import { zip } from "./array/zip.mjs"; +import { zipObject } from "./array/zipObject.mjs"; +import { updateWith } from "./object/updateWith.mjs"; +import { set } from "./object/set.mjs"; +import { zipObjectDeep } from "./array/zipObjectDeep.mjs"; +import { zipWith } from "./array/zipWith.mjs"; +import { after } from "./function/after.mjs"; +import { ary } from "./function/ary.mjs"; +import { attempt } from "./function/attempt.mjs"; +import { before } from "./function/before.mjs"; +import { bind } from "./function/bind.mjs"; +import { bindKey } from "./function/bindKey.mjs"; +import { curry } from "./function/curry.mjs"; +import { curryRight } from "./function/curryRight.mjs"; +import { debounce } from "./function/debounce.mjs"; +import { defer } from "./function/defer.mjs"; +import { delay } from "./function/delay.mjs"; +import { flip } from "./function/flip.mjs"; +import { flow } from "./function/flow.mjs"; +import { flowRight } from "./function/flowRight.mjs"; +import { memoize } from "./function/memoize.mjs"; +import { nthArg } from "./function/nthArg.mjs"; +import { once } from "./function/once.mjs"; +import { overArgs } from "./function/overArgs.mjs"; +import { partial } from "./function/partial.mjs"; +import { partialRight } from "./function/partialRight.mjs"; +import { rearg } from "./function/rearg.mjs"; +import { rest } from "./function/rest.mjs"; +import { spread } from "./function/spread.mjs"; +import { throttle } from "./function/throttle.mjs"; +import { unary } from "./function/unary.mjs"; +import { wrap } from "./function/wrap.mjs"; +import { add } from "./math/add.mjs"; +import { ceil } from "./math/ceil.mjs"; +import { divide } from "./math/divide.mjs"; +import { floor } from "./math/floor.mjs"; +import { inRange } from "./math/inRange.mjs"; +import { max } from "./math/max.mjs"; +import { maxBy } from "./math/maxBy.mjs"; +import { sumBy } from "./math/sumBy.mjs"; +import { sum } from "./math/sum.mjs"; +import { mean } from "./math/mean.mjs"; +import { meanBy } from "./math/meanBy.mjs"; +import { min } from "./math/min.mjs"; +import { minBy } from "./math/minBy.mjs"; +import { multiply } from "./math/multiply.mjs"; +import { parseInt } from "./math/parseInt.mjs"; +import { random } from "./math/random.mjs"; +import { range } from "./math/range.mjs"; +import { rangeRight } from "./math/rangeRight.mjs"; +import { round } from "./math/round.mjs"; +import { subtract } from "./math/subtract.mjs"; +import { noop } from "./function/noop.mjs"; +import { assign } from "./object/assign.mjs"; +import { keysIn } from "./object/keysIn.mjs"; +import { assignIn } from "./object/assignIn.mjs"; +import { assignInWith } from "./object/assignInWith.mjs"; +import { assignWith } from "./object/assignWith.mjs"; +import { clone } from "./object/clone.mjs"; +import { cloneWith } from "./object/cloneWith.mjs"; +import { create } from "./object/create.mjs"; +import { defaults } from "./object/defaults.mjs"; +import { defaultsDeep } from "./object/defaultsDeep.mjs"; +import { findKey } from "./object/findKey.mjs"; +import { findLastKey } from "./object/findLastKey.mjs"; +import { forIn } from "./object/forIn.mjs"; +import { forInRight } from "./object/forInRight.mjs"; +import { forOwn } from "./object/forOwn.mjs"; +import { forOwnRight } from "./object/forOwnRight.mjs"; +import { fromPairs } from "./object/fromPairs.mjs"; +import { functions } from "./object/functions.mjs"; +import { functionsIn } from "./object/functionsIn.mjs"; +import { hasIn } from "./object/hasIn.mjs"; +import { invert } from "./object/invert.mjs"; +import { invertBy } from "./object/invertBy.mjs"; +import { mapKeys } from "./object/mapKeys.mjs"; +import { mapValues } from "./object/mapValues.mjs"; +import { mergeWith } from "./object/mergeWith.mjs"; +import { merge } from "./object/merge.mjs"; +import { omit } from "./object/omit.mjs"; +import { omitBy } from "./object/omitBy.mjs"; +import { pick } from "./object/pick.mjs"; +import { pickBy } from "./object/pickBy.mjs"; +import { propertyOf } from "./object/propertyOf.mjs"; +import { result } from "./object/result.mjs"; +import { setWith } from "./object/setWith.mjs"; +import { toDefaulted } from "./object/toDefaulted.mjs"; +import { toPairs } from "./object/toPairs.mjs"; +import { toPairsIn } from "./object/toPairsIn.mjs"; +import { isBuffer } from "./predicate/isBuffer.mjs"; +import { transform } from "./object/transform.mjs"; +import { update } from "./object/update.mjs"; +import { valuesIn } from "./object/valuesIn.mjs"; +import { isFunction } from "./predicate/isFunction.mjs"; +import { isLength } from "./predicate/isLength.mjs"; +import { isNative } from "./predicate/isNative.mjs"; +import { isNull } from "./predicate/isNull.mjs"; +import { isUndefined } from "./predicate/isUndefined.mjs"; +import { conformsTo } from "./predicate/conformsTo.mjs"; +import { conforms } from "./predicate/conforms.mjs"; +import { isArrayBuffer } from "./predicate/isArrayBuffer.mjs"; +import { isBoolean } from "./predicate/isBoolean.mjs"; +import { isDate } from "./predicate/isDate.mjs"; +import { isElement } from "./predicate/isElement.mjs"; +import { isEmpty } from "./predicate/isEmpty.mjs"; +import { isEqualWith } from "./predicate/isEqualWith.mjs"; +import { isError } from "./predicate/isError.mjs"; +import { isFinite } from "./predicate/isFinite.mjs"; +import { isInteger } from "./predicate/isInteger.mjs"; +import { isRegExp } from "./predicate/isRegExp.mjs"; +import { isSafeInteger } from "./predicate/isSafeInteger.mjs"; +import { isWeakMap } from "./predicate/isWeakMap.mjs"; +import { isWeakSet } from "./predicate/isWeakSet.mjs"; +import { capitalize } from "./string/capitalize.mjs"; +import { bindAll } from "./util/bindAll.mjs"; +import { deburr } from "./string/deburr.mjs"; +import { words } from "./string/words.mjs"; +import { camelCase } from "./string/camelCase.mjs"; +import { endsWith } from "./string/endsWith.mjs"; +import { escape } from "./string/escape.mjs"; +import { escapeRegExp } from "./string/escapeRegExp.mjs"; +import { kebabCase } from "./string/kebabCase.mjs"; +import { lowerCase } from "./string/lowerCase.mjs"; +import { lowerFirst } from "./string/lowerFirst.mjs"; +import { pad } from "./string/pad.mjs"; +import { padEnd } from "./string/padEnd.mjs"; +import { padStart } from "./string/padStart.mjs"; +import { repeat } from "./string/repeat.mjs"; +import { replace } from "./string/replace.mjs"; +import { snakeCase } from "./string/snakeCase.mjs"; +import { split } from "./string/split.mjs"; +import { startCase } from "./string/startCase.mjs"; +import { startsWith } from "./string/startsWith.mjs"; +import { template } from "./string/template.mjs"; +import { templateSettings } from "./string/templateSettings.mjs"; +import { toLower } from "./string/toLower.mjs"; +import { toUpper } from "./string/toUpper.mjs"; +import { trim } from "./string/trim.mjs"; +import { trimEnd } from "./string/trimEnd.mjs"; +import { trimStart } from "./string/trimStart.mjs"; +import { truncate } from "./string/truncate.mjs"; +import { unescape } from "./string/unescape.mjs"; +import { upperCase } from "./string/upperCase.mjs"; +import { upperFirst } from "./string/upperFirst.mjs"; +import { cond } from "./util/cond.mjs"; +import { constant } from "./util/constant.mjs"; +import { defaultTo } from "./util/defaultTo.mjs"; +import { gt } from "./util/gt.mjs"; +import { gte } from "./util/gte.mjs"; +import { invoke } from "./util/invoke.mjs"; +import { lt } from "./util/lt.mjs"; +import { lte } from "./util/lte.mjs"; +import { method } from "./util/method.mjs"; +import { methodOf } from "./util/methodOf.mjs"; +import { now } from "./util/now.mjs"; +import { over } from "./util/over.mjs"; +import { overEvery } from "./util/overEvery.mjs"; +import { overSome } from "./util/overSome.mjs"; +import { stubArray } from "./util/stubArray.mjs"; +import { stubFalse } from "./util/stubFalse.mjs"; +import { stubObject } from "./util/stubObject.mjs"; +import { stubString } from "./util/stubString.mjs"; +import { stubTrue } from "./util/stubTrue.mjs"; +import { toLength } from "./util/toLength.mjs"; +import { toPlainObject } from "./util/toPlainObject.mjs"; +import { toSafeInteger } from "./util/toSafeInteger.mjs"; +import { uniqueId } from "./util/uniqueId.mjs"; +import "./compat.mjs"; +import { toolkit } from "./toolkit.mjs"; +export { add, after, ary, assign, assignIn, assignInWith, assignWith, at, attempt, before, bind, bindAll, bindKey, camelCase, capitalize, castArray, ceil, chunk, clamp, clone, cloneDeep, cloneDeepWith, cloneWith, compact, concat, cond, conforms, conformsTo, constant, countBy, create, curry, curryRight, debounce, deburr, toolkit as default, defaultTo, defaults, defaultsDeep, defer, delay, difference, differenceBy, differenceWith, divide, drop, dropRight, dropRightWhile, dropWhile, forEach as each, forEachRight as eachRight, endsWith, eq, escape, escapeRegExp, every, assignIn as extend, assignInWith as extendWith, fill, filter, find, findIndex, findKey, findLast, findLastIndex, findLastKey, head as first, flatMap, flatMapDeep, flatMapDepth, flatten, flattenDeep, flattenDepth, flip, floor, flow, flowRight, forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, fromPairs, functions, functionsIn, get, groupBy, gt, gte, has, hasIn, head, identity, inRange, includes, indexOf, initial, intersection, intersectionBy, intersectionWith, invert, invertBy, invoke, invokeMap, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, iteratee, join, kebabCase, keyBy, keys, keysIn, last, lastIndexOf, lowerCase, lowerFirst, lt, lte, map, mapKeys, mapValues, matches, matchesProperty, max, maxBy, mean, meanBy, memoize, merge, mergeWith, method, methodOf, min, minBy, multiply, negate, noop, now, nth, nthArg, omit, omitBy, once, orderBy, over, overArgs, overEvery, overSome, pad, padEnd, padStart, parseInt, partial, partialRight, partition, pick, pickBy, property, propertyOf, pull, pullAll, pullAllBy, pullAllWith, pullAt, random, range, rangeRight, rearg, reduce, reduceRight, reject, remove, repeat, replace, rest, result, reverse, round, sample, sampleSize, set, setWith, shuffle, size, slice, snakeCase, some, sortBy, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, split, spread, startCase, startsWith, stubArray, stubFalse, stubObject, stubString, stubTrue, subtract, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, template, templateSettings, throttle, times, toArray, toDefaulted, toFinite, toInteger, toLength, toLower, toNumber, toPairs, toPairsIn, toPath, toPlainObject, toSafeInteger, toString, toUpper, transform, trim, trimEnd, trimStart, truncate, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, uniqueId, unset, unzip, unzipWith, update, updateWith, upperCase, upperFirst, values, valuesIn, without, words, wrap, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith }; diff --git a/node_modules/es-toolkit/dist/compat/math/add.d.mts b/node_modules/es-toolkit/dist/compat/math/add.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..57c97ce67163c953c7ef8f4ca484177cba93b0d1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/add.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/math/add.d.ts +/** + * Adds two numbers while safely handling `NaN` values. + * + * This function takes two numbers and returns their sum. If either of the numbers is `NaN`, + * the function returns `NaN`. + * + * @param value - The first number to add. + * @param other - The second number to add. + * @returns The sum of the two numbers, or `NaN` if any input is `NaN`. + * + * @example + * const result1 = add(2, 3); // result1 will be 5 + * const result2 = add(5, NaN); // result2 will be NaN + * const result3 = add(NaN, 10); // result3 will be NaN + */ +declare function add(value: number, other: number): number; +//#endregion +export { add }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/add.d.ts b/node_modules/es-toolkit/dist/compat/math/add.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..57c97ce67163c953c7ef8f4ca484177cba93b0d1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/add.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/math/add.d.ts +/** + * Adds two numbers while safely handling `NaN` values. + * + * This function takes two numbers and returns their sum. If either of the numbers is `NaN`, + * the function returns `NaN`. + * + * @param value - The first number to add. + * @param other - The second number to add. + * @returns The sum of the two numbers, or `NaN` if any input is `NaN`. + * + * @example + * const result1 = add(2, 3); // result1 will be 5 + * const result2 = add(5, NaN); // result2 will be NaN + * const result3 = add(NaN, 10); // result3 will be NaN + */ +declare function add(value: number, other: number): number; +//#endregion +export { add }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/add.js b/node_modules/es-toolkit/dist/compat/math/add.js new file mode 100644 index 0000000000000000000000000000000000000000..aeab5ab05fe1da31c7b3e061e35e4c4fd8efe9a8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/add.js @@ -0,0 +1,32 @@ +const require_toString = require("../util/toString.js"); +const require_toNumber = require("../util/toNumber.js"); +//#region src/compat/math/add.ts +/** +* Adds two numbers while safely handling `NaN` values. +* +* This function takes two numbers and returns their sum. If either of the numbers is `NaN`, +* the function returns `NaN`. +* +* @param value - The first number to add. +* @param other - The second number to add. +* @returns The sum of the two numbers, or `NaN` if any input is `NaN`. +* +* @example +* const result1 = add(2, 3); // result1 will be 5 +* const result2 = add(5, NaN); // result2 will be NaN +* const result3 = add(NaN, 10); // result3 will be NaN +*/ +function add(value, other) { + if (value === void 0 && other === void 0) return 0; + if (value === void 0 || other === void 0) return value ?? other; + if (typeof value === "string" || typeof other === "string") { + value = require_toString.toString(value); + other = require_toString.toString(other); + } else { + value = require_toNumber.toNumber(value); + other = require_toNumber.toNumber(other); + } + return value + other; +} +//#endregion +exports.add = add; diff --git a/node_modules/es-toolkit/dist/compat/math/add.mjs b/node_modules/es-toolkit/dist/compat/math/add.mjs new file mode 100644 index 0000000000000000000000000000000000000000..54f5e167a2c28be00d8aca80adefcbb14321909a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/add.mjs @@ -0,0 +1,32 @@ +import { toString } from "../util/toString.mjs"; +import { toNumber } from "../util/toNumber.mjs"; +//#region src/compat/math/add.ts +/** +* Adds two numbers while safely handling `NaN` values. +* +* This function takes two numbers and returns their sum. If either of the numbers is `NaN`, +* the function returns `NaN`. +* +* @param value - The first number to add. +* @param other - The second number to add. +* @returns The sum of the two numbers, or `NaN` if any input is `NaN`. +* +* @example +* const result1 = add(2, 3); // result1 will be 5 +* const result2 = add(5, NaN); // result2 will be NaN +* const result3 = add(NaN, 10); // result3 will be NaN +*/ +function add(value, other) { + if (value === void 0 && other === void 0) return 0; + if (value === void 0 || other === void 0) return value ?? other; + if (typeof value === "string" || typeof other === "string") { + value = toString(value); + other = toString(other); + } else { + value = toNumber(value); + other = toNumber(other); + } + return value + other; +} +//#endregion +export { add }; diff --git a/node_modules/es-toolkit/dist/compat/math/ceil.d.mts b/node_modules/es-toolkit/dist/compat/math/ceil.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a1f14ab4cb9545f83a3f9856c47d5b244b6cdd22 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/ceil.d.mts @@ -0,0 +1,16 @@ +//#region src/compat/math/ceil.d.ts +/** + * Computes number rounded up to precision. + * + * @param number The number to round up. + * @param precision The precision to round up to. + * @returns Returns the rounded up number. + * + * @example + * ceil(4.006); // => 5 + * ceil(6.004, 2); // => 6.01 + * ceil(6040, -2); // => 6100 + */ +declare function ceil(number: number, precision?: number): number; +//#endregion +export { ceil }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/ceil.d.ts b/node_modules/es-toolkit/dist/compat/math/ceil.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a1f14ab4cb9545f83a3f9856c47d5b244b6cdd22 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/ceil.d.ts @@ -0,0 +1,16 @@ +//#region src/compat/math/ceil.d.ts +/** + * Computes number rounded up to precision. + * + * @param number The number to round up. + * @param precision The precision to round up to. + * @returns Returns the rounded up number. + * + * @example + * ceil(4.006); // => 5 + * ceil(6.004, 2); // => 6.01 + * ceil(6040, -2); // => 6100 + */ +declare function ceil(number: number, precision?: number): number; +//#endregion +export { ceil }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/ceil.js b/node_modules/es-toolkit/dist/compat/math/ceil.js new file mode 100644 index 0000000000000000000000000000000000000000..c086ee6df0bb92886ba43f48ca5649fecbb5d2fa --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/ceil.js @@ -0,0 +1,19 @@ +const require_decimalAdjust = require("../_internal/decimalAdjust.js"); +//#region src/compat/math/ceil.ts +/** +* Computes number rounded up to precision. +* +* @param number The number to round up. +* @param precision The precision to round up to. +* @returns Returns the rounded up number. +* +* @example +* ceil(4.006); // => 5 +* ceil(6.004, 2); // => 6.01 +* ceil(6040, -2); // => 6100 +*/ +function ceil(number, precision = 0) { + return require_decimalAdjust.decimalAdjust("ceil", number, precision); +} +//#endregion +exports.ceil = ceil; diff --git a/node_modules/es-toolkit/dist/compat/math/ceil.mjs b/node_modules/es-toolkit/dist/compat/math/ceil.mjs new file mode 100644 index 0000000000000000000000000000000000000000..57cb4aba4ecbeeed21dfc2959ef214ed78ac3574 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/ceil.mjs @@ -0,0 +1,19 @@ +import { decimalAdjust } from "../_internal/decimalAdjust.mjs"; +//#region src/compat/math/ceil.ts +/** +* Computes number rounded up to precision. +* +* @param number The number to round up. +* @param precision The precision to round up to. +* @returns Returns the rounded up number. +* +* @example +* ceil(4.006); // => 5 +* ceil(6.004, 2); // => 6.01 +* ceil(6040, -2); // => 6100 +*/ +function ceil(number, precision = 0) { + return decimalAdjust("ceil", number, precision); +} +//#endregion +export { ceil }; diff --git a/node_modules/es-toolkit/dist/compat/math/clamp.d.mts b/node_modules/es-toolkit/dist/compat/math/clamp.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..28e37727df3578a837a278395d2c7ed38285bced --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/clamp.d.mts @@ -0,0 +1,27 @@ +//#region src/compat/math/clamp.d.ts +/** + * Clamps a number within the specified bounds. + * + * @param number The number to clamp + * @param lower The lower bound + * @param upper The upper bound + * @returns Returns the clamped number + * @example + * clamp(3, 2, 4) // => 3 + * clamp(0, 5, 10) // => 5 + * clamp(15, 5, 10) // => 10 + */ +declare function clamp(number: number, lower: number, upper: number): number; +/** + * Clamps a number to an upper bound. + * + * @param number The number to clamp + * @param upper The upper bound + * @returns Returns the clamped number + * @example + * clamp(5, 3) // => 3 + * clamp(2, 3) // => 2 + */ +declare function clamp(number: number, upper: number): number; +//#endregion +export { clamp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/clamp.d.ts b/node_modules/es-toolkit/dist/compat/math/clamp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..28e37727df3578a837a278395d2c7ed38285bced --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/clamp.d.ts @@ -0,0 +1,27 @@ +//#region src/compat/math/clamp.d.ts +/** + * Clamps a number within the specified bounds. + * + * @param number The number to clamp + * @param lower The lower bound + * @param upper The upper bound + * @returns Returns the clamped number + * @example + * clamp(3, 2, 4) // => 3 + * clamp(0, 5, 10) // => 5 + * clamp(15, 5, 10) // => 10 + */ +declare function clamp(number: number, lower: number, upper: number): number; +/** + * Clamps a number to an upper bound. + * + * @param number The number to clamp + * @param upper The upper bound + * @returns Returns the clamped number + * @example + * clamp(5, 3) // => 3 + * clamp(2, 3) // => 2 + */ +declare function clamp(number: number, upper: number): number; +//#endregion +export { clamp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/clamp.js b/node_modules/es-toolkit/dist/compat/math/clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..7d8205e106519913de327a549290ea57cc986908 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/clamp.js @@ -0,0 +1,36 @@ +const require_toNumber = require("../util/toNumber.js"); +//#region src/compat/math/clamp.ts +/** +* Clamps a number within the specified bounds. +* +* This function takes a number and one or two bounds, and returns the number clamped within the specified bounds. +* If only one bound is provided, it returns the minimum of the value and the bound. +* +* @param value - The number to clamp. +* @param bound1 - The minimum bound to clamp the number, or the maximum bound if bound2 is not provided. +* @param [bound2] - The maximum bound to clamp the number. If not provided, the function will only consider bound1 as the upper limit. +* @returns The clamped number within the specified bounds. +* +* @example +* const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5 +* const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15 +* const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5 +* const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15 +*/ +function clamp(value, bound1, bound2) { + if (bound2 === void 0) { + bound2 = bound1; + bound1 = void 0; + } + if (bound2 !== void 0) { + bound2 = require_toNumber.toNumber(bound2); + value = Math.min(value, Number.isNaN(bound2) ? 0 : bound2); + } + if (bound1 !== void 0) { + bound1 = require_toNumber.toNumber(bound1); + value = Math.max(value, Number.isNaN(bound1) ? 0 : bound1); + } + return value; +} +//#endregion +exports.clamp = clamp; diff --git a/node_modules/es-toolkit/dist/compat/math/clamp.mjs b/node_modules/es-toolkit/dist/compat/math/clamp.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4066ce0e7112b7be7ff1daa0827e085e40b5f89b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/clamp.mjs @@ -0,0 +1,36 @@ +import { toNumber } from "../util/toNumber.mjs"; +//#region src/compat/math/clamp.ts +/** +* Clamps a number within the specified bounds. +* +* This function takes a number and one or two bounds, and returns the number clamped within the specified bounds. +* If only one bound is provided, it returns the minimum of the value and the bound. +* +* @param value - The number to clamp. +* @param bound1 - The minimum bound to clamp the number, or the maximum bound if bound2 is not provided. +* @param [bound2] - The maximum bound to clamp the number. If not provided, the function will only consider bound1 as the upper limit. +* @returns The clamped number within the specified bounds. +* +* @example +* const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5 +* const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15 +* const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5 +* const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15 +*/ +function clamp(value, bound1, bound2) { + if (bound2 === void 0) { + bound2 = bound1; + bound1 = void 0; + } + if (bound2 !== void 0) { + bound2 = toNumber(bound2); + value = Math.min(value, Number.isNaN(bound2) ? 0 : bound2); + } + if (bound1 !== void 0) { + bound1 = toNumber(bound1); + value = Math.max(value, Number.isNaN(bound1) ? 0 : bound1); + } + return value; +} +//#endregion +export { clamp }; diff --git a/node_modules/es-toolkit/dist/compat/math/divide.d.mts b/node_modules/es-toolkit/dist/compat/math/divide.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..cf8c9602b0dddd8cde2b215df5399e4165ea6b4b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/divide.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/math/divide.d.ts +/** + * Divide two numbers. + * + * If either of the numbers is `NaN`, the function returns `NaN`. + * + * @param value The first number in a division. + * @param other The second number in a division. + * @returns The quotient of value and other. + * + * @example + * divide(6, 3); // => 2 + * divide(2, NaN); // => NaN + * divide(NaN, 3); // => NaN + * divide(NaN, NaN); // => NaN + */ +declare function divide(value: number, other: number): number; +//#endregion +export { divide }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/divide.d.ts b/node_modules/es-toolkit/dist/compat/math/divide.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf8c9602b0dddd8cde2b215df5399e4165ea6b4b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/divide.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/math/divide.d.ts +/** + * Divide two numbers. + * + * If either of the numbers is `NaN`, the function returns `NaN`. + * + * @param value The first number in a division. + * @param other The second number in a division. + * @returns The quotient of value and other. + * + * @example + * divide(6, 3); // => 2 + * divide(2, NaN); // => NaN + * divide(NaN, 3); // => NaN + * divide(NaN, NaN); // => NaN + */ +declare function divide(value: number, other: number): number; +//#endregion +export { divide }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/divide.js b/node_modules/es-toolkit/dist/compat/math/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..81fb8f3c851fde8fb0b38ac2397b4d1a077dfd31 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/divide.js @@ -0,0 +1,32 @@ +const require_toString = require("../util/toString.js"); +const require_toNumber = require("../util/toNumber.js"); +//#region src/compat/math/divide.ts +/** +* Divide two numbers. +* +* If either of the numbers is `NaN`, the function returns `NaN`. +* +* @param value The first number in a division. +* @param other The second number in a division. +* @returns The quotient of value and other. +* +* @example +* divide(6, 3); // => 2 +* divide(2, NaN); // => NaN +* divide(NaN, 3); // => NaN +* divide(NaN, NaN); // => NaN +*/ +function divide(value, other) { + if (value === void 0 && other === void 0) return 1; + if (value === void 0 || other === void 0) return value ?? other; + if (typeof value === "string" || typeof other === "string") { + value = require_toString.toString(value); + other = require_toString.toString(other); + } else { + value = require_toNumber.toNumber(value); + other = require_toNumber.toNumber(other); + } + return value / other; +} +//#endregion +exports.divide = divide; diff --git a/node_modules/es-toolkit/dist/compat/math/divide.mjs b/node_modules/es-toolkit/dist/compat/math/divide.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1f357a43e8ac7d0be09692b11743aa5849151164 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/divide.mjs @@ -0,0 +1,32 @@ +import { toString } from "../util/toString.mjs"; +import { toNumber } from "../util/toNumber.mjs"; +//#region src/compat/math/divide.ts +/** +* Divide two numbers. +* +* If either of the numbers is `NaN`, the function returns `NaN`. +* +* @param value The first number in a division. +* @param other The second number in a division. +* @returns The quotient of value and other. +* +* @example +* divide(6, 3); // => 2 +* divide(2, NaN); // => NaN +* divide(NaN, 3); // => NaN +* divide(NaN, NaN); // => NaN +*/ +function divide(value, other) { + if (value === void 0 && other === void 0) return 1; + if (value === void 0 || other === void 0) return value ?? other; + if (typeof value === "string" || typeof other === "string") { + value = toString(value); + other = toString(other); + } else { + value = toNumber(value); + other = toNumber(other); + } + return value / other; +} +//#endregion +export { divide }; diff --git a/node_modules/es-toolkit/dist/compat/math/floor.d.mts b/node_modules/es-toolkit/dist/compat/math/floor.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6e7142a14b82a5fb2cc9851d41bfb79614f2100d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/floor.d.mts @@ -0,0 +1,16 @@ +//#region src/compat/math/floor.d.ts +/** + * Computes number rounded down to precision. + * + * @param number The number to round down. + * @param precision The precision to round down to. + * @returns Returns the rounded down number. + * + * @example + * floor(4.006); // => 4 + * floor(0.046, 2); // => 0.04 + * floor(4060, -2); // => 4000 + */ +declare function floor(number: number, precision?: number): number; +//#endregion +export { floor }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/floor.d.ts b/node_modules/es-toolkit/dist/compat/math/floor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6e7142a14b82a5fb2cc9851d41bfb79614f2100d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/floor.d.ts @@ -0,0 +1,16 @@ +//#region src/compat/math/floor.d.ts +/** + * Computes number rounded down to precision. + * + * @param number The number to round down. + * @param precision The precision to round down to. + * @returns Returns the rounded down number. + * + * @example + * floor(4.006); // => 4 + * floor(0.046, 2); // => 0.04 + * floor(4060, -2); // => 4000 + */ +declare function floor(number: number, precision?: number): number; +//#endregion +export { floor }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/floor.js b/node_modules/es-toolkit/dist/compat/math/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..15caf62d30d1d23f253f80c1cfeba44636fb52ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/floor.js @@ -0,0 +1,19 @@ +const require_decimalAdjust = require("../_internal/decimalAdjust.js"); +//#region src/compat/math/floor.ts +/** +* Computes number rounded down to precision. +* +* @param number The number to round down. +* @param precision The precision to round down to. +* @returns Returns the rounded down number. +* +* @example +* floor(4.006); // => 4 +* floor(0.046, 2); // => 0.04 +* floor(4060, -2); // => 4000 +*/ +function floor(number, precision = 0) { + return require_decimalAdjust.decimalAdjust("floor", number, precision); +} +//#endregion +exports.floor = floor; diff --git a/node_modules/es-toolkit/dist/compat/math/floor.mjs b/node_modules/es-toolkit/dist/compat/math/floor.mjs new file mode 100644 index 0000000000000000000000000000000000000000..182cad16f103bfaec9649ae5ef55b693bd206a33 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/floor.mjs @@ -0,0 +1,19 @@ +import { decimalAdjust } from "../_internal/decimalAdjust.mjs"; +//#region src/compat/math/floor.ts +/** +* Computes number rounded down to precision. +* +* @param number The number to round down. +* @param precision The precision to round down to. +* @returns Returns the rounded down number. +* +* @example +* floor(4.006); // => 4 +* floor(0.046, 2); // => 0.04 +* floor(4060, -2); // => 4000 +*/ +function floor(number, precision = 0) { + return decimalAdjust("floor", number, precision); +} +//#endregion +export { floor }; diff --git a/node_modules/es-toolkit/dist/compat/math/inRange.d.mts b/node_modules/es-toolkit/dist/compat/math/inRange.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0da4042037d15a1a2f2a7937e625efb7bce86a18 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/inRange.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/math/inRange.d.ts +/** + * Checks if the value is within a specified range. + * + * If only `minimum` is provided, it is treated as the exclusive upper bound and the range starts at `0`. + * When the resolved bounds are out of order they are swapped, so the lower one is always inclusive + * and the higher one exclusive. + * + * @param value The value to check. + * @param minimum The lower bound of the range (inclusive). + * @param maximum The upper bound of the range (exclusive). + * @returns `true` if the value is within the specified range, otherwise `false`. + * + * @example + * const result1 = inRange(3, 5); // result1 will be true. + * const result2 = inRange(1, 2, 5); // result2 will be false. + * const result3 = inRange(-2, -4); // result3 will be true, the range is [-4, 0). + */ +declare function inRange(value: number, minimum: number, maximum?: number): boolean; +//#endregion +export { inRange }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/inRange.d.ts b/node_modules/es-toolkit/dist/compat/math/inRange.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0da4042037d15a1a2f2a7937e625efb7bce86a18 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/inRange.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/math/inRange.d.ts +/** + * Checks if the value is within a specified range. + * + * If only `minimum` is provided, it is treated as the exclusive upper bound and the range starts at `0`. + * When the resolved bounds are out of order they are swapped, so the lower one is always inclusive + * and the higher one exclusive. + * + * @param value The value to check. + * @param minimum The lower bound of the range (inclusive). + * @param maximum The upper bound of the range (exclusive). + * @returns `true` if the value is within the specified range, otherwise `false`. + * + * @example + * const result1 = inRange(3, 5); // result1 will be true. + * const result2 = inRange(1, 2, 5); // result2 will be false. + * const result3 = inRange(-2, -4); // result3 will be true, the range is [-4, 0). + */ +declare function inRange(value: number, minimum: number, maximum?: number): boolean; +//#endregion +export { inRange }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/inRange.js b/node_modules/es-toolkit/dist/compat/math/inRange.js new file mode 100644 index 0000000000000000000000000000000000000000..1780c15fba7c0a230dc9839e75f11d9c7f5ffd63 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/inRange.js @@ -0,0 +1,31 @@ +const require_toNumber = require("../util/toNumber.js"); +const require_toFinite = require("../util/toFinite.js"); +//#region src/compat/math/inRange.ts +/** +* Checks if the value is within a specified range. +* +* If only `minimum` is provided, it is treated as the exclusive upper bound and the range starts at `0`. +* When the resolved bounds are out of order they are swapped, so the lower one is always inclusive +* and the higher one exclusive. +* +* @param value The value to check. +* @param minimum The lower bound of the range (inclusive). +* @param maximum The upper bound of the range (exclusive). +* @returns `true` if the value is within the specified range, otherwise `false`. +* +* @example +* const result1 = inRange(3, 5); // result1 will be true. +* const result2 = inRange(1, 2, 5); // result2 will be false. +* const result3 = inRange(-2, -4); // result3 will be true, the range is [-4, 0). +*/ +function inRange(value, minimum, maximum) { + minimum = require_toFinite.toFinite(minimum); + if (maximum === void 0) { + maximum = minimum; + minimum = 0; + } else maximum = require_toFinite.toFinite(maximum); + value = require_toNumber.toNumber(value); + return value >= Math.min(minimum, maximum) && value < Math.max(minimum, maximum); +} +//#endregion +exports.inRange = inRange; diff --git a/node_modules/es-toolkit/dist/compat/math/inRange.mjs b/node_modules/es-toolkit/dist/compat/math/inRange.mjs new file mode 100644 index 0000000000000000000000000000000000000000..469b56ba004eb64cd4f9a28cbe90bac349296b2d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/inRange.mjs @@ -0,0 +1,31 @@ +import { toNumber } from "../util/toNumber.mjs"; +import { toFinite } from "../util/toFinite.mjs"; +//#region src/compat/math/inRange.ts +/** +* Checks if the value is within a specified range. +* +* If only `minimum` is provided, it is treated as the exclusive upper bound and the range starts at `0`. +* When the resolved bounds are out of order they are swapped, so the lower one is always inclusive +* and the higher one exclusive. +* +* @param value The value to check. +* @param minimum The lower bound of the range (inclusive). +* @param maximum The upper bound of the range (exclusive). +* @returns `true` if the value is within the specified range, otherwise `false`. +* +* @example +* const result1 = inRange(3, 5); // result1 will be true. +* const result2 = inRange(1, 2, 5); // result2 will be false. +* const result3 = inRange(-2, -4); // result3 will be true, the range is [-4, 0). +*/ +function inRange(value, minimum, maximum) { + minimum = toFinite(minimum); + if (maximum === void 0) { + maximum = minimum; + minimum = 0; + } else maximum = toFinite(maximum); + value = toNumber(value); + return value >= Math.min(minimum, maximum) && value < Math.max(minimum, maximum); +} +//#endregion +export { inRange }; diff --git a/node_modules/es-toolkit/dist/compat/math/max.d.mts b/node_modules/es-toolkit/dist/compat/math/max.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..750bcd24efd978f5cd933189b29b89e87d5ad55b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/max.d.mts @@ -0,0 +1,11 @@ +//#region src/compat/math/max.d.ts +/** + * Finds the element in an array that has the maximum value. + * + * @template T - The type of elements in the array. + * @param [items] - The array of elements to search. Defaults to an empty array. + * @returns The element with the maximum value, or undefined if the array is empty. + */ +declare function max(items: ArrayLike | null | undefined): T | undefined; +//#endregion +export { max }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/max.d.ts b/node_modules/es-toolkit/dist/compat/math/max.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..750bcd24efd978f5cd933189b29b89e87d5ad55b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/max.d.ts @@ -0,0 +1,11 @@ +//#region src/compat/math/max.d.ts +/** + * Finds the element in an array that has the maximum value. + * + * @template T - The type of elements in the array. + * @param [items] - The array of elements to search. Defaults to an empty array. + * @returns The element with the maximum value, or undefined if the array is empty. + */ +declare function max(items: ArrayLike | null | undefined): T | undefined; +//#endregion +export { max }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/max.js b/node_modules/es-toolkit/dist/compat/math/max.js new file mode 100644 index 0000000000000000000000000000000000000000..bd042ee49e6fc239057340d338d75d6e7c26c497 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/max.js @@ -0,0 +1,20 @@ +//#region src/compat/math/max.ts +/** +* Finds the element in an array that has the maximum value. +* +* @template T - The type of elements in the array. +* @param [items] - The array of elements to search. Defaults to an empty array. +* @returns The element with the maximum value, or undefined if the array is empty. +*/ +function max(items) { + if (!items || items.length === 0) return; + let maxResult = void 0; + for (let i = 0; i < items.length; i++) { + const current = items[i]; + if (current == null || Number.isNaN(current) || typeof current === "symbol") continue; + if (maxResult === void 0 || current > maxResult) maxResult = current; + } + return maxResult; +} +//#endregion +exports.max = max; diff --git a/node_modules/es-toolkit/dist/compat/math/max.mjs b/node_modules/es-toolkit/dist/compat/math/max.mjs new file mode 100644 index 0000000000000000000000000000000000000000..16c497dcec52b015bf01640b9e8df8db12a485ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/max.mjs @@ -0,0 +1,20 @@ +//#region src/compat/math/max.ts +/** +* Finds the element in an array that has the maximum value. +* +* @template T - The type of elements in the array. +* @param [items] - The array of elements to search. Defaults to an empty array. +* @returns The element with the maximum value, or undefined if the array is empty. +*/ +function max(items) { + if (!items || items.length === 0) return; + let maxResult = void 0; + for (let i = 0; i < items.length; i++) { + const current = items[i]; + if (current == null || Number.isNaN(current) || typeof current === "symbol") continue; + if (maxResult === void 0 || current > maxResult) maxResult = current; + } + return maxResult; +} +//#endregion +export { max }; diff --git a/node_modules/es-toolkit/dist/compat/math/maxBy.d.mts b/node_modules/es-toolkit/dist/compat/math/maxBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..924eb0dcaed8aacd6500a5f342d026588af96362 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/maxBy.d.mts @@ -0,0 +1,34 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.mjs"; + +//#region src/compat/math/maxBy.d.ts +/** + * Finds the element in an array that has the maximum value when applying + * the `iteratee` to each element. + * + * @template T - The type of elements in the array. + * @param items The array of elements to search. + * @param [iteratee=identity] + * The criteria used to determine the maximum value. + * - If a **function** is provided, it extracts a numeric value from each element. + * - If a **string** is provided, it is treated as a key to extract values from the objects. + * - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. + * - If an **object** is provided, it matches elements that contain the specified properties. + * @returns The element with the maximum value as determined by the `iteratee`. + * @example + * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 } + * maxBy([], x => x.a); // Returns: undefined + * maxBy( + * [ + * { name: 'john', age: 30 }, + * { name: 'jane', age: 28 }, + * { name: 'joe', age: 26 }, + * ], + * x => x.age + * ); // Returns: { name: 'john', age: 30 } + * maxBy([{ a: 1 }, { a: 2 }], 'a'); // Returns: { a: 2 } + * maxBy([{ a: 1 }, { a: 2 }], ['a', 1]); // Returns: { a: 1 } + * maxBy([{ a: 1 }, { a: 2 }], { a: 1 }); // Returns: { a: 1 } + */ +declare function maxBy(items: ArrayLike | null | undefined, iteratee?: ValueIteratee): T | undefined; +//#endregion +export { maxBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/maxBy.d.ts b/node_modules/es-toolkit/dist/compat/math/maxBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bfe0869a4adf47ef12183a6a5eb38ab76fcad46b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/maxBy.d.ts @@ -0,0 +1,34 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.js"; + +//#region src/compat/math/maxBy.d.ts +/** + * Finds the element in an array that has the maximum value when applying + * the `iteratee` to each element. + * + * @template T - The type of elements in the array. + * @param items The array of elements to search. + * @param [iteratee=identity] + * The criteria used to determine the maximum value. + * - If a **function** is provided, it extracts a numeric value from each element. + * - If a **string** is provided, it is treated as a key to extract values from the objects. + * - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. + * - If an **object** is provided, it matches elements that contain the specified properties. + * @returns The element with the maximum value as determined by the `iteratee`. + * @example + * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 } + * maxBy([], x => x.a); // Returns: undefined + * maxBy( + * [ + * { name: 'john', age: 30 }, + * { name: 'jane', age: 28 }, + * { name: 'joe', age: 26 }, + * ], + * x => x.age + * ); // Returns: { name: 'john', age: 30 } + * maxBy([{ a: 1 }, { a: 2 }], 'a'); // Returns: { a: 2 } + * maxBy([{ a: 1 }, { a: 2 }], ['a', 1]); // Returns: { a: 1 } + * maxBy([{ a: 1 }, { a: 2 }], { a: 1 }); // Returns: { a: 1 } + */ +declare function maxBy(items: ArrayLike | null | undefined, iteratee?: ValueIteratee): T | undefined; +//#endregion +export { maxBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/maxBy.js b/node_modules/es-toolkit/dist/compat/math/maxBy.js new file mode 100644 index 0000000000000000000000000000000000000000..c6495801f4470ebf72729e06c6462e7ffda4c47d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/maxBy.js @@ -0,0 +1,52 @@ +const require_identity = require("../../function/identity.js"); +const require_toArray = require("../_internal/toArray.js"); +const require_iteratee = require("../util/iteratee.js"); +//#region src/compat/math/maxBy.ts +/** +* Finds the element in an array that has the maximum value when applying +* the `iteratee` to each element. +* +* @template T - The type of elements in the array. +* @param items The array of elements to search. +* @param [iteratee=identity] +* The criteria used to determine the maximum value. +* - If a **function** is provided, it extracts a numeric value from each element. +* - If a **string** is provided, it is treated as a key to extract values from the objects. +* - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. +* - If an **object** is provided, it matches elements that contain the specified properties. +* @returns The element with the maximum value as determined by the `iteratee`. +* @example +* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 } +* maxBy([], x => x.a); // Returns: undefined +* maxBy( +* [ +* { name: 'john', age: 30 }, +* { name: 'jane', age: 28 }, +* { name: 'joe', age: 26 }, +* ], +* x => x.age +* ); // Returns: { name: 'john', age: 30 } +* maxBy([{ a: 1 }, { a: 2 }], 'a'); // Returns: { a: 2 } +* maxBy([{ a: 1 }, { a: 2 }], ['a', 1]); // Returns: { a: 1 } +* maxBy([{ a: 1 }, { a: 2 }], { a: 1 }); // Returns: { a: 1 } +*/ +function maxBy(items, iteratee$1 = require_identity.identity) { + if (items == null) return; + const array = require_toArray.toArray(items); + if (array.length === 0) return; + const getValue = require_iteratee.iteratee(iteratee$1); + let maxElement; + let max; + for (let i = 0; i < array.length; i++) { + const element = array[i]; + const current = getValue(element, i, array); + if (Number.isNaN(current)) continue; + if (max === void 0 || current > max) { + max = current; + maxElement = element; + } + } + return maxElement; +} +//#endregion +exports.maxBy = maxBy; diff --git a/node_modules/es-toolkit/dist/compat/math/maxBy.mjs b/node_modules/es-toolkit/dist/compat/math/maxBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9a06645af7ecd3d92f74899b71d7e17d6e06de0b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/maxBy.mjs @@ -0,0 +1,52 @@ +import { identity } from "../../function/identity.mjs"; +import { toArray } from "../_internal/toArray.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +//#region src/compat/math/maxBy.ts +/** +* Finds the element in an array that has the maximum value when applying +* the `iteratee` to each element. +* +* @template T - The type of elements in the array. +* @param items The array of elements to search. +* @param [iteratee=identity] +* The criteria used to determine the maximum value. +* - If a **function** is provided, it extracts a numeric value from each element. +* - If a **string** is provided, it is treated as a key to extract values from the objects. +* - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. +* - If an **object** is provided, it matches elements that contain the specified properties. +* @returns The element with the maximum value as determined by the `iteratee`. +* @example +* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 } +* maxBy([], x => x.a); // Returns: undefined +* maxBy( +* [ +* { name: 'john', age: 30 }, +* { name: 'jane', age: 28 }, +* { name: 'joe', age: 26 }, +* ], +* x => x.age +* ); // Returns: { name: 'john', age: 30 } +* maxBy([{ a: 1 }, { a: 2 }], 'a'); // Returns: { a: 2 } +* maxBy([{ a: 1 }, { a: 2 }], ['a', 1]); // Returns: { a: 1 } +* maxBy([{ a: 1 }, { a: 2 }], { a: 1 }); // Returns: { a: 1 } +*/ +function maxBy(items, iteratee$1 = identity) { + if (items == null) return; + const array = toArray(items); + if (array.length === 0) return; + const getValue = iteratee(iteratee$1); + let maxElement; + let max; + for (let i = 0; i < array.length; i++) { + const element = array[i]; + const current = getValue(element, i, array); + if (Number.isNaN(current)) continue; + if (max === void 0 || current > max) { + max = current; + maxElement = element; + } + } + return maxElement; +} +//#endregion +export { maxBy }; diff --git a/node_modules/es-toolkit/dist/compat/math/mean.d.mts b/node_modules/es-toolkit/dist/compat/math/mean.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..18f2882da4a2373cd0e3e93aabb92df6cc318c8b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/mean.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/math/mean.d.ts +/** + * Calculates the average of an array of numbers. + * + * If the array is empty, this function returns `NaN`. + * + * @param nums - An array of numbers to calculate the average. + * @returns The average of all the numbers in the array. + * + * @example + * const numbers = [1, 2, 3, 4, 5]; + * const result = mean(numbers); + * // result will be 3 + */ +declare function mean(nums: ArrayLike | null | undefined): number; +//#endregion +export { mean }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/mean.d.ts b/node_modules/es-toolkit/dist/compat/math/mean.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..18f2882da4a2373cd0e3e93aabb92df6cc318c8b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/mean.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/math/mean.d.ts +/** + * Calculates the average of an array of numbers. + * + * If the array is empty, this function returns `NaN`. + * + * @param nums - An array of numbers to calculate the average. + * @returns The average of all the numbers in the array. + * + * @example + * const numbers = [1, 2, 3, 4, 5]; + * const result = mean(numbers); + * // result will be 3 + */ +declare function mean(nums: ArrayLike | null | undefined): number; +//#endregion +export { mean }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/mean.js b/node_modules/es-toolkit/dist/compat/math/mean.js new file mode 100644 index 0000000000000000000000000000000000000000..436d9181e7867130f4c70f43a999b0f5f93382df --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/mean.js @@ -0,0 +1,21 @@ +const require_sum = require("./sum.js"); +//#region src/compat/math/mean.ts +/** +* Calculates the average of an array of numbers. +* +* If the array is empty, this function returns `NaN`. +* +* @param nums - An array of numbers to calculate the average. +* @returns The average of all the numbers in the array. +* +* @example +* const numbers = [1, 2, 3, 4, 5]; +* const result = mean(numbers); +* // result will be 3 +*/ +function mean(nums) { + const length = nums ? nums.length : 0; + return length === 0 ? NaN : require_sum.sum(nums) / length; +} +//#endregion +exports.mean = mean; diff --git a/node_modules/es-toolkit/dist/compat/math/mean.mjs b/node_modules/es-toolkit/dist/compat/math/mean.mjs new file mode 100644 index 0000000000000000000000000000000000000000..53defb1059030cba64b8eb15414803f837d8f81f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/mean.mjs @@ -0,0 +1,21 @@ +import { sum } from "./sum.mjs"; +//#region src/compat/math/mean.ts +/** +* Calculates the average of an array of numbers. +* +* If the array is empty, this function returns `NaN`. +* +* @param nums - An array of numbers to calculate the average. +* @returns The average of all the numbers in the array. +* +* @example +* const numbers = [1, 2, 3, 4, 5]; +* const result = mean(numbers); +* // result will be 3 +*/ +function mean(nums) { + const length = nums ? nums.length : 0; + return length === 0 ? NaN : sum(nums) / length; +} +//#endregion +export { mean }; diff --git a/node_modules/es-toolkit/dist/compat/math/meanBy.d.mts b/node_modules/es-toolkit/dist/compat/math/meanBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..33b5eeb6c67ac344178f647eda081a2d1ddf5da1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/meanBy.d.mts @@ -0,0 +1,28 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.mjs"; + +//#region src/compat/math/meanBy.d.ts +/** + * Calculates the average of an array of numbers when applying + * the `iteratee` function to each element. + * + * If the array is empty, this function returns `NaN`. + * + * @template T - The type of elements in the array. + * @param items An array to calculate the average. + * @param iteratee + * The criteria used to determine the maximum value. + * - If a **function** is provided, it extracts a numeric value from each element. + * - If a **string** is provided, it is treated as a key to extract values from the objects. + * - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. + * - If an **object** is provided, it matches elements that contain the specified properties. + * @returns The average of all the numbers as determined by the `iteratee` function. + * + * @example + * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2 + * meanBy([], x => x.a); // Returns: NaN + * meanBy([[2], [3], [1]], 0); // Returns: 2 + * meanBy([{ a: 2 }, { a: 3 }, { a: 1 }], 'a'); // Returns: 2 + */ +declare function meanBy(items: ArrayLike | null | undefined, iteratee?: ValueIteratee): number; +//#endregion +export { meanBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/meanBy.d.ts b/node_modules/es-toolkit/dist/compat/math/meanBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..17fbf7b081ec0d433fd9608fc07ebbd019206e0c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/meanBy.d.ts @@ -0,0 +1,28 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.js"; + +//#region src/compat/math/meanBy.d.ts +/** + * Calculates the average of an array of numbers when applying + * the `iteratee` function to each element. + * + * If the array is empty, this function returns `NaN`. + * + * @template T - The type of elements in the array. + * @param items An array to calculate the average. + * @param iteratee + * The criteria used to determine the maximum value. + * - If a **function** is provided, it extracts a numeric value from each element. + * - If a **string** is provided, it is treated as a key to extract values from the objects. + * - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. + * - If an **object** is provided, it matches elements that contain the specified properties. + * @returns The average of all the numbers as determined by the `iteratee` function. + * + * @example + * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2 + * meanBy([], x => x.a); // Returns: NaN + * meanBy([[2], [3], [1]], 0); // Returns: 2 + * meanBy([{ a: 2 }, { a: 3 }, { a: 1 }], 'a'); // Returns: 2 + */ +declare function meanBy(items: ArrayLike | null | undefined, iteratee?: ValueIteratee): number; +//#endregion +export { meanBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/meanBy.js b/node_modules/es-toolkit/dist/compat/math/meanBy.js new file mode 100644 index 0000000000000000000000000000000000000000..ad6fee104adb460562654f16344246e97b459fcd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/meanBy.js @@ -0,0 +1,32 @@ +const require_identity = require("../../function/identity.js"); +const require_meanBy = require("../../math/meanBy.js"); +const require_iteratee = require("../util/iteratee.js"); +//#region src/compat/math/meanBy.ts +/** +* Calculates the average of an array of numbers when applying +* the `iteratee` function to each element. +* +* If the array is empty, this function returns `NaN`. +* +* @template T - The type of elements in the array. +* @param items An array to calculate the average. +* @param iteratee +* The criteria used to determine the maximum value. +* - If a **function** is provided, it extracts a numeric value from each element. +* - If a **string** is provided, it is treated as a key to extract values from the objects. +* - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. +* - If an **object** is provided, it matches elements that contain the specified properties. +* @returns The average of all the numbers as determined by the `iteratee` function. +* +* @example +* meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2 +* meanBy([], x => x.a); // Returns: NaN +* meanBy([[2], [3], [1]], 0); // Returns: 2 +* meanBy([{ a: 2 }, { a: 3 }, { a: 1 }], 'a'); // Returns: 2 +*/ +function meanBy(items, iteratee$1) { + if (items == null) return NaN; + return require_meanBy.meanBy(Array.from(items), require_iteratee.iteratee(iteratee$1 ?? require_identity.identity)); +} +//#endregion +exports.meanBy = meanBy; diff --git a/node_modules/es-toolkit/dist/compat/math/meanBy.mjs b/node_modules/es-toolkit/dist/compat/math/meanBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..03f81aa80b76ef19cc6dfb72fbf77cb2b6cd63a2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/meanBy.mjs @@ -0,0 +1,32 @@ +import { identity } from "../../function/identity.mjs"; +import { meanBy as meanBy$1 } from "../../math/meanBy.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +//#region src/compat/math/meanBy.ts +/** +* Calculates the average of an array of numbers when applying +* the `iteratee` function to each element. +* +* If the array is empty, this function returns `NaN`. +* +* @template T - The type of elements in the array. +* @param items An array to calculate the average. +* @param iteratee +* The criteria used to determine the maximum value. +* - If a **function** is provided, it extracts a numeric value from each element. +* - If a **string** is provided, it is treated as a key to extract values from the objects. +* - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. +* - If an **object** is provided, it matches elements that contain the specified properties. +* @returns The average of all the numbers as determined by the `iteratee` function. +* +* @example +* meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2 +* meanBy([], x => x.a); // Returns: NaN +* meanBy([[2], [3], [1]], 0); // Returns: 2 +* meanBy([{ a: 2 }, { a: 3 }, { a: 1 }], 'a'); // Returns: 2 +*/ +function meanBy(items, iteratee$1) { + if (items == null) return NaN; + return meanBy$1(Array.from(items), iteratee(iteratee$1 ?? identity)); +} +//#endregion +export { meanBy }; diff --git a/node_modules/es-toolkit/dist/compat/math/min.d.mts b/node_modules/es-toolkit/dist/compat/math/min.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2415df033a8478db3fb93e7a6dd066af4effb0d3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/min.d.mts @@ -0,0 +1,11 @@ +//#region src/compat/math/min.d.ts +/** + * Finds the element in an array that has the minimum value. + * + * @template T - The type of elements in the array. + * @param [items] - The array of elements to search. Defaults to an empty array. + * @returns The element with the minimum value, or undefined if the array is empty. + */ +declare function min(items: ArrayLike | null | undefined): T | undefined; +//#endregion +export { min }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/min.d.ts b/node_modules/es-toolkit/dist/compat/math/min.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2415df033a8478db3fb93e7a6dd066af4effb0d3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/min.d.ts @@ -0,0 +1,11 @@ +//#region src/compat/math/min.d.ts +/** + * Finds the element in an array that has the minimum value. + * + * @template T - The type of elements in the array. + * @param [items] - The array of elements to search. Defaults to an empty array. + * @returns The element with the minimum value, or undefined if the array is empty. + */ +declare function min(items: ArrayLike | null | undefined): T | undefined; +//#endregion +export { min }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/min.js b/node_modules/es-toolkit/dist/compat/math/min.js new file mode 100644 index 0000000000000000000000000000000000000000..d3ce147d29963f46d4329d57523104cc53d3858f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/min.js @@ -0,0 +1,20 @@ +//#region src/compat/math/min.ts +/** +* Finds the element in an array that has the minimum value. +* +* @template T - The type of elements in the array. +* @param [items] - The array of elements to search. Defaults to an empty array. +* @returns The element with the minimum value, or undefined if the array is empty. +*/ +function min(items) { + if (!items || items.length === 0) return; + let minResult = void 0; + for (let i = 0; i < items.length; i++) { + const current = items[i]; + if (current == null || Number.isNaN(current) || typeof current === "symbol") continue; + if (minResult === void 0 || current < minResult) minResult = current; + } + return minResult; +} +//#endregion +exports.min = min; diff --git a/node_modules/es-toolkit/dist/compat/math/min.mjs b/node_modules/es-toolkit/dist/compat/math/min.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ab74bf9c08c0e91042ee51647d6fc4af3b7d69b8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/min.mjs @@ -0,0 +1,20 @@ +//#region src/compat/math/min.ts +/** +* Finds the element in an array that has the minimum value. +* +* @template T - The type of elements in the array. +* @param [items] - The array of elements to search. Defaults to an empty array. +* @returns The element with the minimum value, or undefined if the array is empty. +*/ +function min(items) { + if (!items || items.length === 0) return; + let minResult = void 0; + for (let i = 0; i < items.length; i++) { + const current = items[i]; + if (current == null || Number.isNaN(current) || typeof current === "symbol") continue; + if (minResult === void 0 || current < minResult) minResult = current; + } + return minResult; +} +//#endregion +export { min }; diff --git a/node_modules/es-toolkit/dist/compat/math/minBy.d.mts b/node_modules/es-toolkit/dist/compat/math/minBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2a45fd461c87c1d6f109d02583730a3546e8d10e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/minBy.d.mts @@ -0,0 +1,34 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.mjs"; + +//#region src/compat/math/minBy.d.ts +/** + * Finds the element in an array that has the minimum value when applying + * the `iteratee` to each element. + * + * @template T - The type of elements in the array. + * @param items The array of elements to search. + * @param [iteratee=identity] + * The criteria used to determine the minimum value. + * - If a **function** is provided, it extracts a numeric value from each element. + * - If a **string** is provided, it is treated as a key to extract values from the objects. + * - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. + * - If an **object** is provided, it matches elements that contain the specified properties. + * @returns The element with the minimum value as determined by the `iteratee`. + * @example + * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 } + * minBy([], x => x.a); // Returns: undefined + * minBy( + * [ + * { name: 'john', age: 30 }, + * { name: 'jane', age: 28 }, + * { name: 'joe', age: 26 }, + * ], + * x => x.age + * ); // Returns: { name: 'joe', age: 26 } + * minBy([{ a: 1 }, { a: 2 }], 'a'); // Returns: { a: 1 } + * minBy([{ a: 1 }, { a: 2 }], ['a', 1]); // Returns: { a: 2 } + * minBy([{ a: 1 }, { a: 2 }], { a: 1 }); // Returns: { a: 2 } + */ +declare function minBy(items: ArrayLike | null | undefined, iteratee?: ValueIteratee): T | undefined; +//#endregion +export { minBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/minBy.d.ts b/node_modules/es-toolkit/dist/compat/math/minBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..34b34975265114633436288182089214b0d9c310 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/minBy.d.ts @@ -0,0 +1,34 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.js"; + +//#region src/compat/math/minBy.d.ts +/** + * Finds the element in an array that has the minimum value when applying + * the `iteratee` to each element. + * + * @template T - The type of elements in the array. + * @param items The array of elements to search. + * @param [iteratee=identity] + * The criteria used to determine the minimum value. + * - If a **function** is provided, it extracts a numeric value from each element. + * - If a **string** is provided, it is treated as a key to extract values from the objects. + * - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. + * - If an **object** is provided, it matches elements that contain the specified properties. + * @returns The element with the minimum value as determined by the `iteratee`. + * @example + * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 } + * minBy([], x => x.a); // Returns: undefined + * minBy( + * [ + * { name: 'john', age: 30 }, + * { name: 'jane', age: 28 }, + * { name: 'joe', age: 26 }, + * ], + * x => x.age + * ); // Returns: { name: 'joe', age: 26 } + * minBy([{ a: 1 }, { a: 2 }], 'a'); // Returns: { a: 1 } + * minBy([{ a: 1 }, { a: 2 }], ['a', 1]); // Returns: { a: 2 } + * minBy([{ a: 1 }, { a: 2 }], { a: 1 }); // Returns: { a: 2 } + */ +declare function minBy(items: ArrayLike | null | undefined, iteratee?: ValueIteratee): T | undefined; +//#endregion +export { minBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/minBy.js b/node_modules/es-toolkit/dist/compat/math/minBy.js new file mode 100644 index 0000000000000000000000000000000000000000..d6ae6ee3e8899328271fc2f957da816f228eb4e3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/minBy.js @@ -0,0 +1,52 @@ +const require_identity = require("../../function/identity.js"); +const require_toArray = require("../_internal/toArray.js"); +const require_iteratee = require("../util/iteratee.js"); +//#region src/compat/math/minBy.ts +/** +* Finds the element in an array that has the minimum value when applying +* the `iteratee` to each element. +* +* @template T - The type of elements in the array. +* @param items The array of elements to search. +* @param [iteratee=identity] +* The criteria used to determine the minimum value. +* - If a **function** is provided, it extracts a numeric value from each element. +* - If a **string** is provided, it is treated as a key to extract values from the objects. +* - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. +* - If an **object** is provided, it matches elements that contain the specified properties. +* @returns The element with the minimum value as determined by the `iteratee`. +* @example +* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 } +* minBy([], x => x.a); // Returns: undefined +* minBy( +* [ +* { name: 'john', age: 30 }, +* { name: 'jane', age: 28 }, +* { name: 'joe', age: 26 }, +* ], +* x => x.age +* ); // Returns: { name: 'joe', age: 26 } +* minBy([{ a: 1 }, { a: 2 }], 'a'); // Returns: { a: 1 } +* minBy([{ a: 1 }, { a: 2 }], ['a', 1]); // Returns: { a: 2 } +* minBy([{ a: 1 }, { a: 2 }], { a: 1 }); // Returns: { a: 2 } +*/ +function minBy(items, iteratee$1 = require_identity.identity) { + if (items == null) return; + const array = require_toArray.toArray(items); + if (array.length === 0) return; + const getValue = require_iteratee.iteratee(iteratee$1); + let minElement; + let min; + for (let i = 0; i < array.length; i++) { + const element = array[i]; + const current = getValue(element, i, array); + if (Number.isNaN(current)) continue; + if (min === void 0 || current < min) { + min = current; + minElement = element; + } + } + return minElement; +} +//#endregion +exports.minBy = minBy; diff --git a/node_modules/es-toolkit/dist/compat/math/minBy.mjs b/node_modules/es-toolkit/dist/compat/math/minBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c043eb9f078f31e9e576640271ee464653f54224 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/minBy.mjs @@ -0,0 +1,52 @@ +import { identity } from "../../function/identity.mjs"; +import { toArray } from "../_internal/toArray.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +//#region src/compat/math/minBy.ts +/** +* Finds the element in an array that has the minimum value when applying +* the `iteratee` to each element. +* +* @template T - The type of elements in the array. +* @param items The array of elements to search. +* @param [iteratee=identity] +* The criteria used to determine the minimum value. +* - If a **function** is provided, it extracts a numeric value from each element. +* - If a **string** is provided, it is treated as a key to extract values from the objects. +* - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair. +* - If an **object** is provided, it matches elements that contain the specified properties. +* @returns The element with the minimum value as determined by the `iteratee`. +* @example +* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 } +* minBy([], x => x.a); // Returns: undefined +* minBy( +* [ +* { name: 'john', age: 30 }, +* { name: 'jane', age: 28 }, +* { name: 'joe', age: 26 }, +* ], +* x => x.age +* ); // Returns: { name: 'joe', age: 26 } +* minBy([{ a: 1 }, { a: 2 }], 'a'); // Returns: { a: 1 } +* minBy([{ a: 1 }, { a: 2 }], ['a', 1]); // Returns: { a: 2 } +* minBy([{ a: 1 }, { a: 2 }], { a: 1 }); // Returns: { a: 2 } +*/ +function minBy(items, iteratee$1 = identity) { + if (items == null) return; + const array = toArray(items); + if (array.length === 0) return; + const getValue = iteratee(iteratee$1); + let minElement; + let min; + for (let i = 0; i < array.length; i++) { + const element = array[i]; + const current = getValue(element, i, array); + if (Number.isNaN(current)) continue; + if (min === void 0 || current < min) { + min = current; + minElement = element; + } + } + return minElement; +} +//#endregion +export { minBy }; diff --git a/node_modules/es-toolkit/dist/compat/math/multiply.d.mts b/node_modules/es-toolkit/dist/compat/math/multiply.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e9ced3969fe38451e237f2a4aa5ae3a093eeaf39 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/multiply.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/math/multiply.d.ts +/** + * Multiply two numbers. + * + * If either of the numbers is `NaN`, the function returns `NaN`. + * + * @param value The first number in a multiplication + * @param other The second number in a multiplication + * @returns The product of value and other + * + * @example + * multiply(2, 3); // => 6 + * multiply(2, NaN); // => NaN + * multiply(NaN, 3); // => NaN + * multiply(NaN, NaN); // => NaN + */ +declare function multiply(value: number, other: number): number; +//#endregion +export { multiply }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/multiply.d.ts b/node_modules/es-toolkit/dist/compat/math/multiply.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9ced3969fe38451e237f2a4aa5ae3a093eeaf39 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/multiply.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/math/multiply.d.ts +/** + * Multiply two numbers. + * + * If either of the numbers is `NaN`, the function returns `NaN`. + * + * @param value The first number in a multiplication + * @param other The second number in a multiplication + * @returns The product of value and other + * + * @example + * multiply(2, 3); // => 6 + * multiply(2, NaN); // => NaN + * multiply(NaN, 3); // => NaN + * multiply(NaN, NaN); // => NaN + */ +declare function multiply(value: number, other: number): number; +//#endregion +export { multiply }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/multiply.js b/node_modules/es-toolkit/dist/compat/math/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..12bf92dea9020930bade60969b5bb3ea8fbe32ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/multiply.js @@ -0,0 +1,32 @@ +const require_toString = require("../util/toString.js"); +const require_toNumber = require("../util/toNumber.js"); +//#region src/compat/math/multiply.ts +/** +* Multiply two numbers. +* +* If either of the numbers is `NaN`, the function returns `NaN`. +* +* @param value The first number in a multiplication +* @param other The second number in a multiplication +* @returns The product of value and other +* +* @example +* multiply(2, 3); // => 6 +* multiply(2, NaN); // => NaN +* multiply(NaN, 3); // => NaN +* multiply(NaN, NaN); // => NaN +*/ +function multiply(value, other) { + if (value === void 0 && other === void 0) return 1; + if (value === void 0 || other === void 0) return value ?? other; + if (typeof value === "string" || typeof other === "string") { + value = require_toString.toString(value); + other = require_toString.toString(other); + } else { + value = require_toNumber.toNumber(value); + other = require_toNumber.toNumber(other); + } + return value * other; +} +//#endregion +exports.multiply = multiply; diff --git a/node_modules/es-toolkit/dist/compat/math/multiply.mjs b/node_modules/es-toolkit/dist/compat/math/multiply.mjs new file mode 100644 index 0000000000000000000000000000000000000000..aca1f967325112226fb502f885b475f904ec4d9a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/multiply.mjs @@ -0,0 +1,32 @@ +import { toString } from "../util/toString.mjs"; +import { toNumber } from "../util/toNumber.mjs"; +//#region src/compat/math/multiply.ts +/** +* Multiply two numbers. +* +* If either of the numbers is `NaN`, the function returns `NaN`. +* +* @param value The first number in a multiplication +* @param other The second number in a multiplication +* @returns The product of value and other +* +* @example +* multiply(2, 3); // => 6 +* multiply(2, NaN); // => NaN +* multiply(NaN, 3); // => NaN +* multiply(NaN, NaN); // => NaN +*/ +function multiply(value, other) { + if (value === void 0 && other === void 0) return 1; + if (value === void 0 || other === void 0) return value ?? other; + if (typeof value === "string" || typeof other === "string") { + value = toString(value); + other = toString(other); + } else { + value = toNumber(value); + other = toNumber(other); + } + return value * other; +} +//#endregion +export { multiply }; diff --git a/node_modules/es-toolkit/dist/compat/math/parseInt.d.mts b/node_modules/es-toolkit/dist/compat/math/parseInt.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..265658a76684fb73c9bfe44540eacadad7a09fe3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/parseInt.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/math/parseInt.d.ts +/** + * 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. + * + * @param string The string to convert to an integer. + * @param radix The radix to use when converting the string to an integer. Defaults to `0`. + * @param guard Enables use as an iteratee for methods like `Array#map`. + * @returns Returns the converted integer. + * + * @example + * parseInt('08'); // => 8 + * parseInt('0x20'); // => 32 + * + * parseInt('08', 10); // => 8 + * parseInt('0x20', 16); // => 32 + * + * ['6', '08', '10'].map(parseInt); // => [6, 8, 10] + */ +declare function parseInt(string: string, radix?: number): number; +//#endregion +export { parseInt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/parseInt.d.ts b/node_modules/es-toolkit/dist/compat/math/parseInt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..265658a76684fb73c9bfe44540eacadad7a09fe3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/parseInt.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/math/parseInt.d.ts +/** + * 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. + * + * @param string The string to convert to an integer. + * @param radix The radix to use when converting the string to an integer. Defaults to `0`. + * @param guard Enables use as an iteratee for methods like `Array#map`. + * @returns Returns the converted integer. + * + * @example + * parseInt('08'); // => 8 + * parseInt('0x20'); // => 32 + * + * parseInt('08', 10); // => 8 + * parseInt('0x20', 16); // => 32 + * + * ['6', '08', '10'].map(parseInt); // => [6, 8, 10] + */ +declare function parseInt(string: string, radix?: number): number; +//#endregion +export { parseInt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/parseInt.js b/node_modules/es-toolkit/dist/compat/math/parseInt.js new file mode 100644 index 0000000000000000000000000000000000000000..5f093d8954a6b8675cf8ff9d1ae22702438172b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/parseInt.js @@ -0,0 +1,25 @@ +const require_toString = require("../util/toString.js"); +//#region src/compat/math/parseInt.ts +/** +* 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. +* +* @param string The string to convert to an integer. +* @param radix The radix to use when converting the string to an integer. Defaults to `0`. +* @param guard Enables use as an iteratee for methods like `Array#map`. +* @returns Returns the converted integer. +* +* @example +* parseInt('08'); // => 8 +* parseInt('0x20'); // => 32 +* +* parseInt('08', 10); // => 8 +* parseInt('0x20', 16); // => 32 +* +* ['6', '08', '10'].map(parseInt); // => [6, 8, 10] +*/ +function parseInt(string, radix = 0, guard) { + if (guard) radix = 0; + return Number.parseInt(require_toString.toString(string), radix); +} +//#endregion +exports.parseInt = parseInt; diff --git a/node_modules/es-toolkit/dist/compat/math/parseInt.mjs b/node_modules/es-toolkit/dist/compat/math/parseInt.mjs new file mode 100644 index 0000000000000000000000000000000000000000..769938a0b1ed956a3d83a0eccf9c232bb757ab9c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/parseInt.mjs @@ -0,0 +1,25 @@ +import { toString } from "../util/toString.mjs"; +//#region src/compat/math/parseInt.ts +/** +* 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. +* +* @param string The string to convert to an integer. +* @param radix The radix to use when converting the string to an integer. Defaults to `0`. +* @param guard Enables use as an iteratee for methods like `Array#map`. +* @returns Returns the converted integer. +* +* @example +* parseInt('08'); // => 8 +* parseInt('0x20'); // => 32 +* +* parseInt('08', 10); // => 8 +* parseInt('0x20', 16); // => 32 +* +* ['6', '08', '10'].map(parseInt); // => [6, 8, 10] +*/ +function parseInt(string, radix = 0, guard) { + if (guard) radix = 0; + return Number.parseInt(toString(string), radix); +} +//#endregion +export { parseInt }; diff --git a/node_modules/es-toolkit/dist/compat/math/random.d.mts b/node_modules/es-toolkit/dist/compat/math/random.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fbf71f1d284a4ef6649349fb0c5918f0a3253ad8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/random.d.mts @@ -0,0 +1,47 @@ +//#region src/compat/math/random.d.ts +/** + * Generate a random number between 0 and 1. + * @param [floating] - Whether to return a floating point number. Defaults to false. + * @returns A random number between 0 and 1. + * @example + * random(); // Returns a random number between 0 and 1 + * random(true); // Returns a random floating point number between 0 and 1 + * random(false); // Returns a random integer between 0 and 1 + */ +declare function random(floating?: boolean): number; +/** + * Generate a random number between 0 and max. + * @param max - The upper bound (exclusive). + * @param [floating] - Whether to return a floating point number. Defaults to false. + * @returns A random number between 0 and max. + * @example + * random(5); // Returns a random number between 0 and 5 + * random(10, true); // Returns a random floating point number between 0 and 10 + * random(3, false); // Returns a random integer between 0 and 3 + */ +declare function random(max: number, floating?: boolean): number; +/** + * Generate a random number between min and max. + * @param min - The lower bound (inclusive). + * @param max - The upper bound (exclusive). + * @param [floating] - Whether to return a floating point number. Defaults to false. + * @returns A random number between min and max. + * @example + * random(1, 5); // Returns a random number between 1 and 5 + * random(0, 10, true); // Returns a random floating point number between 0 and 10 + * random(1, 6, false); // Returns a random integer between 1 and 6 + */ +declare function random(min: number, max: number, floating?: boolean): number; +/** + * Generate a random number between 0 and min, using guard object for special cases. + * @param min - The upper bound (exclusive). + * @param index - The index or key to check in the guard object. + * @param guard - The guard object to validate the parameters. + * @returns A random number between 0 and min. + * @example + * const guard = { 5: 5 }; + * random(5, 5, guard); // Returns a random number between 0 and 5 + */ +declare function random(min: number, index: string | number, guard: object): number; +//#endregion +export { random }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/random.d.ts b/node_modules/es-toolkit/dist/compat/math/random.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fbf71f1d284a4ef6649349fb0c5918f0a3253ad8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/random.d.ts @@ -0,0 +1,47 @@ +//#region src/compat/math/random.d.ts +/** + * Generate a random number between 0 and 1. + * @param [floating] - Whether to return a floating point number. Defaults to false. + * @returns A random number between 0 and 1. + * @example + * random(); // Returns a random number between 0 and 1 + * random(true); // Returns a random floating point number between 0 and 1 + * random(false); // Returns a random integer between 0 and 1 + */ +declare function random(floating?: boolean): number; +/** + * Generate a random number between 0 and max. + * @param max - The upper bound (exclusive). + * @param [floating] - Whether to return a floating point number. Defaults to false. + * @returns A random number between 0 and max. + * @example + * random(5); // Returns a random number between 0 and 5 + * random(10, true); // Returns a random floating point number between 0 and 10 + * random(3, false); // Returns a random integer between 0 and 3 + */ +declare function random(max: number, floating?: boolean): number; +/** + * Generate a random number between min and max. + * @param min - The lower bound (inclusive). + * @param max - The upper bound (exclusive). + * @param [floating] - Whether to return a floating point number. Defaults to false. + * @returns A random number between min and max. + * @example + * random(1, 5); // Returns a random number between 1 and 5 + * random(0, 10, true); // Returns a random floating point number between 0 and 10 + * random(1, 6, false); // Returns a random integer between 1 and 6 + */ +declare function random(min: number, max: number, floating?: boolean): number; +/** + * Generate a random number between 0 and min, using guard object for special cases. + * @param min - The upper bound (exclusive). + * @param index - The index or key to check in the guard object. + * @param guard - The guard object to validate the parameters. + * @returns A random number between 0 and min. + * @example + * const guard = { 5: 5 }; + * random(5, 5, guard); // Returns a random number between 0 and 5 + */ +declare function random(min: number, index: string | number, guard: object): number; +//#endregion +export { random }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/random.js b/node_modules/es-toolkit/dist/compat/math/random.js new file mode 100644 index 0000000000000000000000000000000000000000..4276e092042de3b8b0ad9494342cb1e47d8a17ad --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/random.js @@ -0,0 +1,58 @@ +const require_random = require("../../math/random.js"); +const require_randomInt = require("../../math/randomInt.js"); +const require_clamp = require("./clamp.js"); +//#region src/compat/math/random.ts +/** +* Generate a random number within the given range. +* +* @param minimum - The lower bound (inclusive). +* @param maximum - The upper bound (exclusive). +* @returns A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal. +* @throws {Error} Throws an error if `maximum` is not greater than `minimum`. +* +* @example +* const result1 = random(0, 5); // Returns a random number between 0 and 5. +* const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown. +* const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown. +*/ +function random(...args) { + let minimum = 0; + let maximum = 1; + let floating = false; + switch (args.length) { + case 1: + if (typeof args[0] === "boolean") floating = args[0]; + else maximum = args[0]; + break; + case 2: if (typeof args[1] === "boolean") { + maximum = args[0]; + floating = args[1]; + break; + } else { + minimum = args[0]; + maximum = args[1]; + } + case 3: if (typeof args[2] === "object" && args[2] != null && args[2][args[1]] === args[0]) { + minimum = 0; + maximum = args[0]; + floating = false; + } else { + minimum = args[0]; + maximum = args[1]; + floating = args[2]; + } + } + if (typeof minimum !== "number") minimum = Number(minimum); + if (typeof maximum !== "number") maximum = Number(maximum); + if (!minimum) minimum = 0; + if (!maximum) maximum = 0; + if (minimum > maximum) [minimum, maximum] = [maximum, minimum]; + if (!floating && (!Number.isInteger(minimum) || !Number.isInteger(maximum))) floating = true; + minimum = require_clamp.clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER); + maximum = require_clamp.clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER); + if (minimum === maximum) return minimum; + if (floating) return require_random.random(minimum, maximum); + else return require_randomInt.randomInt(minimum, maximum + 1); +} +//#endregion +exports.random = random; diff --git a/node_modules/es-toolkit/dist/compat/math/random.mjs b/node_modules/es-toolkit/dist/compat/math/random.mjs new file mode 100644 index 0000000000000000000000000000000000000000..58448d53561aa76ff13992d80ab0767a1ee5fe9b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/random.mjs @@ -0,0 +1,58 @@ +import { random as random$1 } from "../../math/random.mjs"; +import { randomInt } from "../../math/randomInt.mjs"; +import { clamp } from "./clamp.mjs"; +//#region src/compat/math/random.ts +/** +* Generate a random number within the given range. +* +* @param minimum - The lower bound (inclusive). +* @param maximum - The upper bound (exclusive). +* @returns A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal. +* @throws {Error} Throws an error if `maximum` is not greater than `minimum`. +* +* @example +* const result1 = random(0, 5); // Returns a random number between 0 and 5. +* const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown. +* const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown. +*/ +function random(...args) { + let minimum = 0; + let maximum = 1; + let floating = false; + switch (args.length) { + case 1: + if (typeof args[0] === "boolean") floating = args[0]; + else maximum = args[0]; + break; + case 2: if (typeof args[1] === "boolean") { + maximum = args[0]; + floating = args[1]; + break; + } else { + minimum = args[0]; + maximum = args[1]; + } + case 3: if (typeof args[2] === "object" && args[2] != null && args[2][args[1]] === args[0]) { + minimum = 0; + maximum = args[0]; + floating = false; + } else { + minimum = args[0]; + maximum = args[1]; + floating = args[2]; + } + } + if (typeof minimum !== "number") minimum = Number(minimum); + if (typeof maximum !== "number") maximum = Number(maximum); + if (!minimum) minimum = 0; + if (!maximum) maximum = 0; + if (minimum > maximum) [minimum, maximum] = [maximum, minimum]; + if (!floating && (!Number.isInteger(minimum) || !Number.isInteger(maximum))) floating = true; + minimum = clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER); + maximum = clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER); + if (minimum === maximum) return minimum; + if (floating) return random$1(minimum, maximum); + else return randomInt(minimum, maximum + 1); +} +//#endregion +export { random }; diff --git a/node_modules/es-toolkit/dist/compat/math/range.d.mts b/node_modules/es-toolkit/dist/compat/math/range.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..49d37a4a178167c91d81306108557ea30f97c8ab --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/range.d.mts @@ -0,0 +1,34 @@ +//#region src/compat/math/range.d.ts +/** + * Creates an array of numbers progressing from `start` up to, but not including, `end`. + * + * @param start - The starting number of the range (inclusive) + * @param end - The end number of the range (exclusive) + * @param step - The value to increment or decrement by + * @returns An array of numbers from start to end + * @example + * range(4) + * // => [0, 1, 2, 3] + * + * range(1, 5) + * // => [1, 2, 3, 4] + * + * range(0, 20, 5) + * // => [0, 5, 10, 15] + */ +declare function range(start: number, end?: number, step?: number): number[]; +/** + * Creates an array of numbers progressing from 0 up to, but not including, `end`. + * Used internally when range is called as an iteratee. + * + * @param end - The end of the range (exclusive) + * @param index - The index argument passed to the iteratee + * @param guard - The guard object passed to the iteratee + * @returns An array of numbers from 0 to end + * @example + * [1, 2, 3].map(range) + * // => [[0], [0, 1], [0, 1, 2]] + */ +declare function range(end: number, index: string | number, guard: object): number[]; +//#endregion +export { range }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/range.d.ts b/node_modules/es-toolkit/dist/compat/math/range.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..49d37a4a178167c91d81306108557ea30f97c8ab --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/range.d.ts @@ -0,0 +1,34 @@ +//#region src/compat/math/range.d.ts +/** + * Creates an array of numbers progressing from `start` up to, but not including, `end`. + * + * @param start - The starting number of the range (inclusive) + * @param end - The end number of the range (exclusive) + * @param step - The value to increment or decrement by + * @returns An array of numbers from start to end + * @example + * range(4) + * // => [0, 1, 2, 3] + * + * range(1, 5) + * // => [1, 2, 3, 4] + * + * range(0, 20, 5) + * // => [0, 5, 10, 15] + */ +declare function range(start: number, end?: number, step?: number): number[]; +/** + * Creates an array of numbers progressing from 0 up to, but not including, `end`. + * Used internally when range is called as an iteratee. + * + * @param end - The end of the range (exclusive) + * @param index - The index argument passed to the iteratee + * @param guard - The guard object passed to the iteratee + * @returns An array of numbers from 0 to end + * @example + * [1, 2, 3].map(range) + * // => [[0], [0, 1], [0, 1, 2]] + */ +declare function range(end: number, index: string | number, guard: object): number[]; +//#endregion +export { range }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/range.js b/node_modules/es-toolkit/dist/compat/math/range.js new file mode 100644 index 0000000000000000000000000000000000000000..7bbe6dee98871d6b8237f1646226750328bb4dd6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/range.js @@ -0,0 +1,37 @@ +const require_toFinite = require("../util/toFinite.js"); +const require_isIterateeCall = require("../_internal/isIterateeCall.js"); +//#region src/compat/math/range.ts +/** +* Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `step`. +* +* @param start - The starting number of the range (inclusive). +* @param end - The end number of the range (exclusive). +* @param step - The step value for the range. +* @returns An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`. +* +* @example +* // Returns [0, 1, 2, 3] +* range(4); +* +* @example +* // Returns [0, -1, -2, -3] +* range(0, -4, -1); +*/ +function range(start, end, step) { + if (step && typeof step !== "number" && require_isIterateeCall.isIterateeCall(start, end, step)) end = step = void 0; + start = require_toFinite.toFinite(start); + if (end === void 0) { + end = start; + start = 0; + } else end = require_toFinite.toFinite(end); + step = step === void 0 ? start < end ? 1 : -1 : require_toFinite.toFinite(step); + const length = Math.max(Math.ceil((end - start) / (step || 1)), 0); + const result = new Array(length); + for (let index = 0; index < length; index++) { + result[index] = start; + start += step; + } + return result; +} +//#endregion +exports.range = range; diff --git a/node_modules/es-toolkit/dist/compat/math/range.mjs b/node_modules/es-toolkit/dist/compat/math/range.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f0e39ef2eb26739f61f03993f42c707507c5fed5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/range.mjs @@ -0,0 +1,37 @@ +import { toFinite } from "../util/toFinite.mjs"; +import { isIterateeCall } from "../_internal/isIterateeCall.mjs"; +//#region src/compat/math/range.ts +/** +* Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `step`. +* +* @param start - The starting number of the range (inclusive). +* @param end - The end number of the range (exclusive). +* @param step - The step value for the range. +* @returns An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`. +* +* @example +* // Returns [0, 1, 2, 3] +* range(4); +* +* @example +* // Returns [0, -1, -2, -3] +* range(0, -4, -1); +*/ +function range(start, end, step) { + if (step && typeof step !== "number" && isIterateeCall(start, end, step)) end = step = void 0; + start = toFinite(start); + if (end === void 0) { + end = start; + start = 0; + } else end = toFinite(end); + step = step === void 0 ? start < end ? 1 : -1 : toFinite(step); + const length = Math.max(Math.ceil((end - start) / (step || 1)), 0); + const result = new Array(length); + for (let index = 0; index < length; index++) { + result[index] = start; + start += step; + } + return result; +} +//#endregion +export { range }; diff --git a/node_modules/es-toolkit/dist/compat/math/rangeRight.d.mts b/node_modules/es-toolkit/dist/compat/math/rangeRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..960adbfb7b76a362246620e7528a8f237bb10ce4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/rangeRight.d.mts @@ -0,0 +1,32 @@ +//#region src/compat/math/rangeRight.d.ts +/** + * Creates an array of numbers from `start` to `end` with optional `step`. + * @param start - The starting number of the range (inclusive). + * @param [end] - The end number of the range (exclusive). + * @param [step] - The step value for the range. + * @returns An array of numbers from `start` to `end` with the specified `step`. + * @example + * // Returns [0, 1, 2, 3] + * rangeRight(4); + * @example + * // Returns [0, 2, 4, 6] + * rangeRight(0, 8, 2); + * @example + * // Returns [5, 4, 3, 2, 1] + * rangeRight(1, 6); + */ +declare function rangeRight(start: number, end?: number, step?: number): number[]; +/** + * Creates an array of numbers from 0 to `end` with step 1. + * Used when called as an iteratee for methods like `_.map`. + * @param end - The end number of the range (exclusive). + * @param index - The index parameter (used for iteratee calls). + * @param guard - The guard parameter (used for iteratee calls). + * @returns An array of numbers from 0 to `end` with step 1. + * @example + * // Returns [0, 1, 2, 3] + * rangeRight(4, 'index', {}); + */ +declare function rangeRight(end: number, index: string | number, guard: object): number[]; +//#endregion +export { rangeRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/rangeRight.d.ts b/node_modules/es-toolkit/dist/compat/math/rangeRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..960adbfb7b76a362246620e7528a8f237bb10ce4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/rangeRight.d.ts @@ -0,0 +1,32 @@ +//#region src/compat/math/rangeRight.d.ts +/** + * Creates an array of numbers from `start` to `end` with optional `step`. + * @param start - The starting number of the range (inclusive). + * @param [end] - The end number of the range (exclusive). + * @param [step] - The step value for the range. + * @returns An array of numbers from `start` to `end` with the specified `step`. + * @example + * // Returns [0, 1, 2, 3] + * rangeRight(4); + * @example + * // Returns [0, 2, 4, 6] + * rangeRight(0, 8, 2); + * @example + * // Returns [5, 4, 3, 2, 1] + * rangeRight(1, 6); + */ +declare function rangeRight(start: number, end?: number, step?: number): number[]; +/** + * Creates an array of numbers from 0 to `end` with step 1. + * Used when called as an iteratee for methods like `_.map`. + * @param end - The end number of the range (exclusive). + * @param index - The index parameter (used for iteratee calls). + * @param guard - The guard parameter (used for iteratee calls). + * @returns An array of numbers from 0 to `end` with step 1. + * @example + * // Returns [0, 1, 2, 3] + * rangeRight(4, 'index', {}); + */ +declare function rangeRight(end: number, index: string | number, guard: object): number[]; +//#endregion +export { rangeRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/rangeRight.js b/node_modules/es-toolkit/dist/compat/math/rangeRight.js new file mode 100644 index 0000000000000000000000000000000000000000..2e1e2853dd282e0dee3a5addff62c259b791d310 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/rangeRight.js @@ -0,0 +1,38 @@ +const require_toFinite = require("../util/toFinite.js"); +const require_isIterateeCall = require("../_internal/isIterateeCall.js"); +//#region src/compat/math/rangeRight.ts +/** +* Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `step`. +* +* @param start - The starting number of the range (inclusive). +* @param end - The end number of the range (exclusive). +* @param step - The step value for the range. +* @returns An array of numbers from `end` (exclusive) to `start` (inclusive) with the specified `step`. +* @throws {Error} Throws an error if the step value is not a non-zero integer. +* +* @example +* // Returns [3, 2, 1, 0] +* rangeRight(4); +* +* @example +* // Returns [-3, -2, -1, 0] +* rangeRight(0, -4, -1); +*/ +function rangeRight(start, end, step) { + if (step && typeof step !== "number" && require_isIterateeCall.isIterateeCall(start, end, step)) end = step = void 0; + start = require_toFinite.toFinite(start); + if (end === void 0) { + end = start; + start = 0; + } else end = require_toFinite.toFinite(end); + step = step === void 0 ? start < end ? 1 : -1 : require_toFinite.toFinite(step); + const length = Math.max(Math.ceil((end - start) / (step || 1)), 0); + const result = new Array(length); + for (let index = length - 1; index >= 0; index--) { + result[index] = start; + start += step; + } + return result; +} +//#endregion +exports.rangeRight = rangeRight; diff --git a/node_modules/es-toolkit/dist/compat/math/rangeRight.mjs b/node_modules/es-toolkit/dist/compat/math/rangeRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d4c2765f79bf719a1e75c0d51b3fe23909d13361 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/rangeRight.mjs @@ -0,0 +1,38 @@ +import { toFinite } from "../util/toFinite.mjs"; +import { isIterateeCall } from "../_internal/isIterateeCall.mjs"; +//#region src/compat/math/rangeRight.ts +/** +* Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `step`. +* +* @param start - The starting number of the range (inclusive). +* @param end - The end number of the range (exclusive). +* @param step - The step value for the range. +* @returns An array of numbers from `end` (exclusive) to `start` (inclusive) with the specified `step`. +* @throws {Error} Throws an error if the step value is not a non-zero integer. +* +* @example +* // Returns [3, 2, 1, 0] +* rangeRight(4); +* +* @example +* // Returns [-3, -2, -1, 0] +* rangeRight(0, -4, -1); +*/ +function rangeRight(start, end, step) { + if (step && typeof step !== "number" && isIterateeCall(start, end, step)) end = step = void 0; + start = toFinite(start); + if (end === void 0) { + end = start; + start = 0; + } else end = toFinite(end); + step = step === void 0 ? start < end ? 1 : -1 : toFinite(step); + const length = Math.max(Math.ceil((end - start) / (step || 1)), 0); + const result = new Array(length); + for (let index = length - 1; index >= 0; index--) { + result[index] = start; + start += step; + } + return result; +} +//#endregion +export { rangeRight }; diff --git a/node_modules/es-toolkit/dist/compat/math/round.d.mts b/node_modules/es-toolkit/dist/compat/math/round.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8fbac75daef03ff5eea8c35b70be319da43666d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/round.d.mts @@ -0,0 +1,16 @@ +//#region src/compat/math/round.d.ts +/** + * Computes number rounded to precision. + * + * @param number The number to round. + * @param precision The precision to round to. + * @returns Returns the rounded number. + * + * @example + * round(4.006); // => 4 + * round(4.006, 2); // => 4.01 + * round(4060, -2); // => 4100 + */ +declare function round(number: number, precision?: number): number; +//#endregion +export { round }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/round.d.ts b/node_modules/es-toolkit/dist/compat/math/round.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8fbac75daef03ff5eea8c35b70be319da43666d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/round.d.ts @@ -0,0 +1,16 @@ +//#region src/compat/math/round.d.ts +/** + * Computes number rounded to precision. + * + * @param number The number to round. + * @param precision The precision to round to. + * @returns Returns the rounded number. + * + * @example + * round(4.006); // => 4 + * round(4.006, 2); // => 4.01 + * round(4060, -2); // => 4100 + */ +declare function round(number: number, precision?: number): number; +//#endregion +export { round }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/round.js b/node_modules/es-toolkit/dist/compat/math/round.js new file mode 100644 index 0000000000000000000000000000000000000000..a35d6db66832c277006f2215abfc4f0e95bc7c20 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/round.js @@ -0,0 +1,19 @@ +const require_decimalAdjust = require("../_internal/decimalAdjust.js"); +//#region src/compat/math/round.ts +/** +* Computes number rounded to precision. +* +* @param number The number to round. +* @param precision The precision to round to. +* @returns Returns the rounded number. +* +* @example +* round(4.006); // => 4 +* round(4.006, 2); // => 4.01 +* round(4060, -2); // => 4100 +*/ +function round(number, precision = 0) { + return require_decimalAdjust.decimalAdjust("round", number, precision); +} +//#endregion +exports.round = round; diff --git a/node_modules/es-toolkit/dist/compat/math/round.mjs b/node_modules/es-toolkit/dist/compat/math/round.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d81cb554018a87691c8859a6b0e2435808b7ffab --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/round.mjs @@ -0,0 +1,19 @@ +import { decimalAdjust } from "../_internal/decimalAdjust.mjs"; +//#region src/compat/math/round.ts +/** +* Computes number rounded to precision. +* +* @param number The number to round. +* @param precision The precision to round to. +* @returns Returns the rounded number. +* +* @example +* round(4.006); // => 4 +* round(4.006, 2); // => 4.01 +* round(4060, -2); // => 4100 +*/ +function round(number, precision = 0) { + return decimalAdjust("round", number, precision); +} +//#endregion +export { round }; diff --git a/node_modules/es-toolkit/dist/compat/math/subtract.d.mts b/node_modules/es-toolkit/dist/compat/math/subtract.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3c6a0e4184e19e96a4abeca4f2cc830eea64f5c7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/subtract.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/math/subtract.d.ts +/** + * Subtracts one number from another. + * + * If either of the numbers is `NaN`, the function returns `NaN`. + * + * @param value The first number. (minuend) + * @param other The second number.(subtrahend) + * @returns The difference of the two numbers, or `NaN` if any input is `NaN`. + * + * @example + * subtract(6, 3); // => 3 + * subtract(6, NaN); // => NaN + * subtract(NaN, 3); // => NaN + */ +declare function subtract(value: number, other: number): number; +//#endregion +export { subtract }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/subtract.d.ts b/node_modules/es-toolkit/dist/compat/math/subtract.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c6a0e4184e19e96a4abeca4f2cc830eea64f5c7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/subtract.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/math/subtract.d.ts +/** + * Subtracts one number from another. + * + * If either of the numbers is `NaN`, the function returns `NaN`. + * + * @param value The first number. (minuend) + * @param other The second number.(subtrahend) + * @returns The difference of the two numbers, or `NaN` if any input is `NaN`. + * + * @example + * subtract(6, 3); // => 3 + * subtract(6, NaN); // => NaN + * subtract(NaN, 3); // => NaN + */ +declare function subtract(value: number, other: number): number; +//#endregion +export { subtract }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/subtract.js b/node_modules/es-toolkit/dist/compat/math/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..fe8156aa65bf02485785245034885d857f4888f8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/subtract.js @@ -0,0 +1,31 @@ +const require_toString = require("../util/toString.js"); +const require_toNumber = require("../util/toNumber.js"); +//#region src/compat/math/subtract.ts +/** +* Subtracts one number from another. +* +* If either of the numbers is `NaN`, the function returns `NaN`. +* +* @param value The first number. (minuend) +* @param other The second number.(subtrahend) +* @returns The difference of the two numbers, or `NaN` if any input is `NaN`. +* +* @example +* subtract(6, 3); // => 3 +* subtract(6, NaN); // => NaN +* subtract(NaN, 3); // => NaN +*/ +function subtract(value, other) { + if (value === void 0 && other === void 0) return 0; + if (value === void 0 || other === void 0) return value ?? other; + if (typeof value === "string" || typeof other === "string") { + value = require_toString.toString(value); + other = require_toString.toString(other); + } else { + value = require_toNumber.toNumber(value); + other = require_toNumber.toNumber(other); + } + return value - other; +} +//#endregion +exports.subtract = subtract; diff --git a/node_modules/es-toolkit/dist/compat/math/subtract.mjs b/node_modules/es-toolkit/dist/compat/math/subtract.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b1b1d5ac36ee3d624afc8f1de471482c0fe6ea34 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/subtract.mjs @@ -0,0 +1,31 @@ +import { toString } from "../util/toString.mjs"; +import { toNumber } from "../util/toNumber.mjs"; +//#region src/compat/math/subtract.ts +/** +* Subtracts one number from another. +* +* If either of the numbers is `NaN`, the function returns `NaN`. +* +* @param value The first number. (minuend) +* @param other The second number.(subtrahend) +* @returns The difference of the two numbers, or `NaN` if any input is `NaN`. +* +* @example +* subtract(6, 3); // => 3 +* subtract(6, NaN); // => NaN +* subtract(NaN, 3); // => NaN +*/ +function subtract(value, other) { + if (value === void 0 && other === void 0) return 0; + if (value === void 0 || other === void 0) return value ?? other; + if (typeof value === "string" || typeof other === "string") { + value = toString(value); + other = toString(other); + } else { + value = toNumber(value); + other = toNumber(other); + } + return value - other; +} +//#endregion +export { subtract }; diff --git a/node_modules/es-toolkit/dist/compat/math/sum.d.mts b/node_modules/es-toolkit/dist/compat/math/sum.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6e4ddd372f72fdb7ceed2b791bbc39a78bfafc13 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/sum.d.mts @@ -0,0 +1,20 @@ +//#region src/compat/math/sum.d.ts +/** + * Computes the sum of the values that are returned by the `iteratee` function. + * + * It does not coerce values to `number`. + * + * @param array - The array to iterate over. + * @returns Returns the sum. + * + * @example + * sum([1, 2, 3]); // => 6 + * sum([1n, 2n, 3n]); // => 6n + * sum(["1", "2"]); // => "12" + * sum([1, undefined, 2]); // => 3 + * sum(null); // => 0 + * sum(undefined); // => 0 + */ +declare function sum(array: ArrayLike | null | undefined): number; +//#endregion +export { sum }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/sum.d.ts b/node_modules/es-toolkit/dist/compat/math/sum.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6e4ddd372f72fdb7ceed2b791bbc39a78bfafc13 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/sum.d.ts @@ -0,0 +1,20 @@ +//#region src/compat/math/sum.d.ts +/** + * Computes the sum of the values that are returned by the `iteratee` function. + * + * It does not coerce values to `number`. + * + * @param array - The array to iterate over. + * @returns Returns the sum. + * + * @example + * sum([1, 2, 3]); // => 6 + * sum([1n, 2n, 3n]); // => 6n + * sum(["1", "2"]); // => "12" + * sum([1, undefined, 2]); // => 3 + * sum(null); // => 0 + * sum(undefined); // => 0 + */ +declare function sum(array: ArrayLike | null | undefined): number; +//#endregion +export { sum }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/sum.js b/node_modules/es-toolkit/dist/compat/math/sum.js new file mode 100644 index 0000000000000000000000000000000000000000..996c6dfb999101bb08f03b25a14a19c90892d0f6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/sum.js @@ -0,0 +1,23 @@ +const require_sumBy = require("./sumBy.js"); +//#region src/compat/math/sum.ts +/** +* Computes the sum of the values that are returned by the `iteratee` function. +* +* It does not coerce values to `number`. +* +* @param array - The array to iterate over. +* @returns Returns the sum. +* +* @example +* sum([1, 2, 3]); // => 6 +* sum([1n, 2n, 3n]); // => 6n +* sum(["1", "2"]); // => "12" +* sum([1, undefined, 2]); // => 3 +* sum(null); // => 0 +* sum(undefined); // => 0 +*/ +function sum(array) { + return require_sumBy.sumBy(array); +} +//#endregion +exports.sum = sum; diff --git a/node_modules/es-toolkit/dist/compat/math/sum.mjs b/node_modules/es-toolkit/dist/compat/math/sum.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e449eea60e6913478caa543cc37d0c576027fe6f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/sum.mjs @@ -0,0 +1,23 @@ +import { sumBy } from "./sumBy.mjs"; +//#region src/compat/math/sum.ts +/** +* Computes the sum of the values that are returned by the `iteratee` function. +* +* It does not coerce values to `number`. +* +* @param array - The array to iterate over. +* @returns Returns the sum. +* +* @example +* sum([1, 2, 3]); // => 6 +* sum([1n, 2n, 3n]); // => 6n +* sum(["1", "2"]); // => "12" +* sum([1, undefined, 2]); // => 3 +* sum(null); // => 0 +* sum(undefined); // => 0 +*/ +function sum(array) { + return sumBy(array); +} +//#endregion +export { sum }; diff --git a/node_modules/es-toolkit/dist/compat/math/sumBy.d.mts b/node_modules/es-toolkit/dist/compat/math/sumBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..34ad48c867ef0dd601e109c993d23aab9aeca50e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/sumBy.d.mts @@ -0,0 +1,22 @@ +//#region src/compat/math/sumBy.d.ts +/** + * Computes the sum of the values that are returned by the `iteratee` function. + * + * It does not coerce values to `number`. + * + * @template T - The type of the array elements. + * @param array - The array to iterate over. + * @param iteratee - The function invoked per iteration. + * @returns Returns the sum. + * + * @example + * sumBy([1, undefined, 2], value => value); // => 3 + * sumBy(null); // => 0 + * sumBy(undefined); // => 0 + * sumBy([1, 2, 3]); // => 6 + * sumBy([1n, 2n, 3n]); // => 6n + * sumBy([{ a: "1" }, { a: "2" }], object => object.a); // => "12" + */ +declare function sumBy(array: ArrayLike | null | undefined, iteratee?: ((value: T) => number) | string): number; +//#endregion +export { sumBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/sumBy.d.ts b/node_modules/es-toolkit/dist/compat/math/sumBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..34ad48c867ef0dd601e109c993d23aab9aeca50e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/sumBy.d.ts @@ -0,0 +1,22 @@ +//#region src/compat/math/sumBy.d.ts +/** + * Computes the sum of the values that are returned by the `iteratee` function. + * + * It does not coerce values to `number`. + * + * @template T - The type of the array elements. + * @param array - The array to iterate over. + * @param iteratee - The function invoked per iteration. + * @returns Returns the sum. + * + * @example + * sumBy([1, undefined, 2], value => value); // => 3 + * sumBy(null); // => 0 + * sumBy(undefined); // => 0 + * sumBy([1, 2, 3]); // => 6 + * sumBy([1n, 2n, 3n]); // => 6n + * sumBy([{ a: "1" }, { a: "2" }], object => object.a); // => "12" + */ +declare function sumBy(array: ArrayLike | null | undefined, iteratee?: ((value: T) => number) | string): number; +//#endregion +export { sumBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/math/sumBy.js b/node_modules/es-toolkit/dist/compat/math/sumBy.js new file mode 100644 index 0000000000000000000000000000000000000000..5753961b173578278810f598e66337ca006748b0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/sumBy.js @@ -0,0 +1,33 @@ +const require_iteratee = require("../util/iteratee.js"); +//#region src/compat/math/sumBy.ts +/** +* Computes the sum of the values that are returned by the `iteratee` function. +* +* It does not coerce values to `number`. +* +* @template T - The type of the array elements. +* @param array - The array to iterate over. +* @param iteratee - The function invoked per iteration. +* @returns Returns the sum. +* +* @example +* sumBy([1, undefined, 2], value => value); // => 3 +* sumBy(null); // => 0 +* sumBy(undefined); // => 0 +* sumBy([1, 2, 3]); // => 6 +* sumBy([1n, 2n, 3n]); // => 6n +* sumBy([{ a: "1" }, { a: "2" }], object => object.a); // => "12" +*/ +function sumBy(array, iteratee$1) { + if (!array || !array.length) return 0; + if (iteratee$1 != null) iteratee$1 = require_iteratee.iteratee(iteratee$1); + let result = void 0; + for (let i = 0; i < array.length; i++) { + const current = iteratee$1 ? iteratee$1(array[i]) : array[i]; + if (current !== void 0) if (result === void 0) result = current; + else result += current; + } + return result; +} +//#endregion +exports.sumBy = sumBy; diff --git a/node_modules/es-toolkit/dist/compat/math/sumBy.mjs b/node_modules/es-toolkit/dist/compat/math/sumBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9255675641848d623819f7e513ede4cb96e02691 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/math/sumBy.mjs @@ -0,0 +1,33 @@ +import { iteratee } from "../util/iteratee.mjs"; +//#region src/compat/math/sumBy.ts +/** +* Computes the sum of the values that are returned by the `iteratee` function. +* +* It does not coerce values to `number`. +* +* @template T - The type of the array elements. +* @param array - The array to iterate over. +* @param iteratee - The function invoked per iteration. +* @returns Returns the sum. +* +* @example +* sumBy([1, undefined, 2], value => value); // => 3 +* sumBy(null); // => 0 +* sumBy(undefined); // => 0 +* sumBy([1, 2, 3]); // => 6 +* sumBy([1n, 2n, 3n]); // => 6n +* sumBy([{ a: "1" }, { a: "2" }], object => object.a); // => "12" +*/ +function sumBy(array, iteratee$1) { + if (!array || !array.length) return 0; + if (iteratee$1 != null) iteratee$1 = iteratee(iteratee$1); + let result = void 0; + for (let i = 0; i < array.length; i++) { + const current = iteratee$1 ? iteratee$1(array[i]) : array[i]; + if (current !== void 0) if (result === void 0) result = current; + else result += current; + } + return result; +} +//#endregion +export { sumBy }; diff --git a/node_modules/es-toolkit/dist/compat/object/assign.d.mts b/node_modules/es-toolkit/dist/compat/object/assign.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fe6acc45335c2cff623044d3cbb0044221a197b0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assign.d.mts @@ -0,0 +1,111 @@ +//#region src/compat/object/assign.d.ts +/** + * Assigns properties from one source object to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the source object. + * @param object - The target object to which properties will be assigned. + * @param source - The source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source object assigned. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * const result = assign(target, source); + * // => { a: 1, b: 3, c: 4 } + */ +declare function assign(object: T, source: U): T & U; +/** + * Assigns properties from two source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const result = assign(target, source1, source2); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assign(object: T, source1: U, source2: V): T & U & V; +/** + * Assigns properties from three source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const result = assign(target, source1, source2, source3); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assign(object: T, source1: U, source2: V, source3: W): T & U & V & W; +/** + * Assigns properties from four source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @template X - The type of the fourth source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param source4 - The fourth source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * const result = assign(target, source1, source2, source3, source4); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function assign(object: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X; +/** + * Assigns properties from a target object to itself. + * + * @template T - The type of the target object. + * @param object - The target object. + * @returns The target object. + * + * @example + * const target = { a: 1, b: 2 }; + * const result = assign(target); + * // => { a: 1, b: 2 } + */ +declare function assign(object: T): T; +/** + * Assigns properties from multiple source objects to a target object. + * + * @param object - The target object to which properties will be assigned. + * @param otherArgs - The source objects whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const result = assign(target, { b: 2 }, { c: 3 }, { d: 4 }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assign(object: any, ...otherArgs: any[]): any; +//#endregion +export { assign }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/assign.d.ts b/node_modules/es-toolkit/dist/compat/object/assign.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fe6acc45335c2cff623044d3cbb0044221a197b0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assign.d.ts @@ -0,0 +1,111 @@ +//#region src/compat/object/assign.d.ts +/** + * Assigns properties from one source object to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the source object. + * @param object - The target object to which properties will be assigned. + * @param source - The source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source object assigned. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * const result = assign(target, source); + * // => { a: 1, b: 3, c: 4 } + */ +declare function assign(object: T, source: U): T & U; +/** + * Assigns properties from two source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const result = assign(target, source1, source2); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assign(object: T, source1: U, source2: V): T & U & V; +/** + * Assigns properties from three source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const result = assign(target, source1, source2, source3); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assign(object: T, source1: U, source2: V, source3: W): T & U & V & W; +/** + * Assigns properties from four source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @template X - The type of the fourth source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param source4 - The fourth source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * const result = assign(target, source1, source2, source3, source4); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function assign(object: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X; +/** + * Assigns properties from a target object to itself. + * + * @template T - The type of the target object. + * @param object - The target object. + * @returns The target object. + * + * @example + * const target = { a: 1, b: 2 }; + * const result = assign(target); + * // => { a: 1, b: 2 } + */ +declare function assign(object: T): T; +/** + * Assigns properties from multiple source objects to a target object. + * + * @param object - The target object to which properties will be assigned. + * @param otherArgs - The source objects whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const result = assign(target, { b: 2 }, { c: 3 }, { d: 4 }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assign(object: any, ...otherArgs: any[]): any; +//#endregion +export { assign }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/assign.js b/node_modules/es-toolkit/dist/compat/object/assign.js new file mode 100644 index 0000000000000000000000000000000000000000..0aa5f3263aa7b86785358186d617c04254da85bf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assign.js @@ -0,0 +1,32 @@ +const require_eq = require("../util/eq.js"); +const require_keys = require("./keys.js"); +//#region src/compat/object/assign.ts +/** +* Assigns properties from multiple source objects to a target object. +* +* This function merges the properties of the source objects into the target object. +* If a property in the source objects is equal to the corresponding property in the target object, +* it will not be overwritten. +* +* @param object - The target object to which properties will be assigned. +* @param sources - The source objects whose properties will be assigned to the target object. +* @returns The updated target object with properties from the source objects assigned. +* +* @example +* const target = { a: 1 }; +* const result = assign(target, { b: 2 }, { c: 3 }); +* console.log(result); // Output: { a: 1, b: 2, c: 3 } +*/ +function assign(object, ...sources) { + for (let i = 0; i < sources.length; i++) assignImpl(object, sources[i]); + return object; +} +function assignImpl(object, source) { + const keys$1 = require_keys.keys(source); + for (let i = 0; i < keys$1.length; i++) { + const key = keys$1[i]; + if (!(key in object) || !require_eq.eq(object[key], source[key])) object[key] = source[key]; + } +} +//#endregion +exports.assign = assign; diff --git a/node_modules/es-toolkit/dist/compat/object/assign.mjs b/node_modules/es-toolkit/dist/compat/object/assign.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f482a8c786f241e73d922b33627679d6727830c6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assign.mjs @@ -0,0 +1,32 @@ +import { eq } from "../util/eq.mjs"; +import { keys } from "./keys.mjs"; +//#region src/compat/object/assign.ts +/** +* Assigns properties from multiple source objects to a target object. +* +* This function merges the properties of the source objects into the target object. +* If a property in the source objects is equal to the corresponding property in the target object, +* it will not be overwritten. +* +* @param object - The target object to which properties will be assigned. +* @param sources - The source objects whose properties will be assigned to the target object. +* @returns The updated target object with properties from the source objects assigned. +* +* @example +* const target = { a: 1 }; +* const result = assign(target, { b: 2 }, { c: 3 }); +* console.log(result); // Output: { a: 1, b: 2, c: 3 } +*/ +function assign(object, ...sources) { + for (let i = 0; i < sources.length; i++) assignImpl(object, sources[i]); + return object; +} +function assignImpl(object, source) { + const keys$1 = keys(source); + for (let i = 0; i < keys$1.length; i++) { + const key = keys$1[i]; + if (!(key in object) || !eq(object[key], source[key])) object[key] = source[key]; + } +} +//#endregion +export { assign }; diff --git a/node_modules/es-toolkit/dist/compat/object/assignIn.d.mts b/node_modules/es-toolkit/dist/compat/object/assignIn.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4420a024783d4b51ec5b897b30d46c18a5b20ed4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignIn.d.mts @@ -0,0 +1,112 @@ +//#region src/compat/object/assignIn.d.ts +/** + * Assigns own and inherited properties from one source object to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the source object. + * @param object - The target object to which properties will be assigned. + * @param source - The source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source object assigned. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * const result = assignIn(target, source); + * // => { a: 1, b: 3, c: 4 } + */ +declare function assignIn(object: T, source: U): T & U; +/** + * Assigns own and inherited properties from two source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const result = assignIn(target, source1, source2); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignIn(object: T, source1: U, source2: V): T & U & V; +/** + * Assigns own and inherited properties from three source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const result = assignIn(target, source1, source2, source3); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assignIn(object: T, source1: U, source2: V, source3: W): T & U & V & W; +/** + * Assigns own and inherited properties from four source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @template X - The type of the fourth source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param source4 - The fourth source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * const result = assignIn(target, source1, source2, source3, source4); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function assignIn(object: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X; +/** + * Returns the target object as-is. + * + * @template T - The type of the target object. + * @param object - The target object. + * @returns The target object. + * + * @example + * const target = { a: 1, b: 2 }; + * const result = assignIn(target); + * // => { a: 1, b: 2 } + */ +declare function assignIn(object: T): T; +/** + * Assigns own and inherited properties from multiple source objects to a target object. + * + * @template R - The type of the result. + * @param object - The target object to which properties will be assigned. + * @param otherArgs - The source objects whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const result = assignIn(target, { b: 2 }, { c: 3 }, { d: 4 }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assignIn(object: any, ...otherArgs: any[]): R; +//#endregion +export { assignIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/assignIn.d.ts b/node_modules/es-toolkit/dist/compat/object/assignIn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4420a024783d4b51ec5b897b30d46c18a5b20ed4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignIn.d.ts @@ -0,0 +1,112 @@ +//#region src/compat/object/assignIn.d.ts +/** + * Assigns own and inherited properties from one source object to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the source object. + * @param object - The target object to which properties will be assigned. + * @param source - The source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source object assigned. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * const result = assignIn(target, source); + * // => { a: 1, b: 3, c: 4 } + */ +declare function assignIn(object: T, source: U): T & U; +/** + * Assigns own and inherited properties from two source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const result = assignIn(target, source1, source2); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignIn(object: T, source1: U, source2: V): T & U & V; +/** + * Assigns own and inherited properties from three source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const result = assignIn(target, source1, source2, source3); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assignIn(object: T, source1: U, source2: V, source3: W): T & U & V & W; +/** + * Assigns own and inherited properties from four source objects to a target object. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @template X - The type of the fourth source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param source4 - The fourth source object whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * const result = assignIn(target, source1, source2, source3, source4); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function assignIn(object: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X; +/** + * Returns the target object as-is. + * + * @template T - The type of the target object. + * @param object - The target object. + * @returns The target object. + * + * @example + * const target = { a: 1, b: 2 }; + * const result = assignIn(target); + * // => { a: 1, b: 2 } + */ +declare function assignIn(object: T): T; +/** + * Assigns own and inherited properties from multiple source objects to a target object. + * + * @template R - The type of the result. + * @param object - The target object to which properties will be assigned. + * @param otherArgs - The source objects whose properties will be assigned to the target object. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const result = assignIn(target, { b: 2 }, { c: 3 }, { d: 4 }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assignIn(object: any, ...otherArgs: any[]): R; +//#endregion +export { assignIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/assignIn.js b/node_modules/es-toolkit/dist/compat/object/assignIn.js new file mode 100644 index 0000000000000000000000000000000000000000..4ace90ea6fe7175b97a76b615bbb477b63bc3fa0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignIn.js @@ -0,0 +1,32 @@ +const require_eq = require("../util/eq.js"); +const require_keysIn = require("./keysIn.js"); +//#region src/compat/object/assignIn.ts +/** +* Assigns properties from multiple source objects to a target object. +* +* This function merges the properties of the source objects into the target object, +* including properties from the prototype chain. If a property in the source objects +* is equal to the corresponding property in the target object, it will not be overwritten. +* +* @param object - The target object to which properties will be assigned. +* @param sources - The source objects whose properties will be assigned to the target object. +* @returns The updated target object with properties from the source objects assigned. +* +* @example +* const target = { a: 1 }; +* const result = assignIn(target, { b: 2 }, { c: 3 }); +* console.log(result); // Output: { a: 1, b: 2, c: 3 } +*/ +function assignIn(object, ...sources) { + for (let i = 0; i < sources.length; i++) assignInImpl(object, sources[i]); + return object; +} +function assignInImpl(object, source) { + const keys = require_keysIn.keysIn(source); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (!(key in object) || !require_eq.eq(object[key], source[key])) object[key] = source[key]; + } +} +//#endregion +exports.assignIn = assignIn; diff --git a/node_modules/es-toolkit/dist/compat/object/assignIn.mjs b/node_modules/es-toolkit/dist/compat/object/assignIn.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2a8087bdf47c47953e3f47f6f64054f96d583149 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignIn.mjs @@ -0,0 +1,32 @@ +import { eq } from "../util/eq.mjs"; +import { keysIn } from "./keysIn.mjs"; +//#region src/compat/object/assignIn.ts +/** +* Assigns properties from multiple source objects to a target object. +* +* This function merges the properties of the source objects into the target object, +* including properties from the prototype chain. If a property in the source objects +* is equal to the corresponding property in the target object, it will not be overwritten. +* +* @param object - The target object to which properties will be assigned. +* @param sources - The source objects whose properties will be assigned to the target object. +* @returns The updated target object with properties from the source objects assigned. +* +* @example +* const target = { a: 1 }; +* const result = assignIn(target, { b: 2 }, { c: 3 }); +* console.log(result); // Output: { a: 1, b: 2, c: 3 } +*/ +function assignIn(object, ...sources) { + for (let i = 0; i < sources.length; i++) assignInImpl(object, sources[i]); + return object; +} +function assignInImpl(object, source) { + const keys = keysIn(source); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (!(key in object) || !eq(object[key], source[key])) object[key] = source[key]; + } +} +//#endregion +export { assignIn }; diff --git a/node_modules/es-toolkit/dist/compat/object/assignInWith.d.mts b/node_modules/es-toolkit/dist/compat/object/assignInWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..34889b964d79d1c1dce856f1eb59f925c8d0890f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignInWith.d.mts @@ -0,0 +1,127 @@ +//#region src/compat/object/assignInWith.d.ts +type AssignCustomizer = (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; +/** + * Assigns own and inherited properties from one source object to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the source object. + * @param object - The target object to which properties will be assigned. + * @param source - The source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source object assigned. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * const result = assignInWith(target, source, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 4 } + */ +declare function assignInWith(object: T, source: U, customizer: AssignCustomizer): T & U; +/** + * Assigns own and inherited properties from two source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const result = assignInWith(target, source1, source2, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignInWith(object: T, source1: U, source2: V, customizer: AssignCustomizer): T & U & V; +/** + * Assigns own and inherited properties from three source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const result = assignInWith(target, source1, source2, source3, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assignInWith(object: T, source1: U, source2: V, source3: W, customizer: AssignCustomizer): T & U & V & W; +/** + * Assigns own and inherited properties from four source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @template X - The type of the fourth source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param source4 - The fourth source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * const result = assignInWith(target, source1, source2, source3, source4, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function assignInWith(object: T, source1: U, source2: V, source3: W, source4: X, customizer: AssignCustomizer): T & U & V & W & X; +/** + * Returns the target object as-is. + * + * @template T - The type of the target object. + * @param object - The target object. + * @returns The target object. + * + * @example + * const target = { a: 1, b: 2 }; + * const result = assignInWith(target); + * // => { a: 1, b: 2 } + */ +declare function assignInWith(object: T): T; +/** + * Assigns own and inherited properties from multiple source objects to a target object using a customizer function. + * + * @template R - The type of the result. + * @param object - The target object to which properties will be assigned. + * @param otherArgs - The source objects and customizer function. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const result = assignInWith(target, { b: 2 }, { c: 3 }, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignInWith(object: any, ...otherArgs: any[]): R; +//#endregion +export { assignInWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/assignInWith.d.ts b/node_modules/es-toolkit/dist/compat/object/assignInWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..34889b964d79d1c1dce856f1eb59f925c8d0890f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignInWith.d.ts @@ -0,0 +1,127 @@ +//#region src/compat/object/assignInWith.d.ts +type AssignCustomizer = (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; +/** + * Assigns own and inherited properties from one source object to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the source object. + * @param object - The target object to which properties will be assigned. + * @param source - The source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source object assigned. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * const result = assignInWith(target, source, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 4 } + */ +declare function assignInWith(object: T, source: U, customizer: AssignCustomizer): T & U; +/** + * Assigns own and inherited properties from two source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const result = assignInWith(target, source1, source2, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignInWith(object: T, source1: U, source2: V, customizer: AssignCustomizer): T & U & V; +/** + * Assigns own and inherited properties from three source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const result = assignInWith(target, source1, source2, source3, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assignInWith(object: T, source1: U, source2: V, source3: W, customizer: AssignCustomizer): T & U & V & W; +/** + * Assigns own and inherited properties from four source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @template X - The type of the fourth source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param source4 - The fourth source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * const result = assignInWith(target, source1, source2, source3, source4, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function assignInWith(object: T, source1: U, source2: V, source3: W, source4: X, customizer: AssignCustomizer): T & U & V & W & X; +/** + * Returns the target object as-is. + * + * @template T - The type of the target object. + * @param object - The target object. + * @returns The target object. + * + * @example + * const target = { a: 1, b: 2 }; + * const result = assignInWith(target); + * // => { a: 1, b: 2 } + */ +declare function assignInWith(object: T): T; +/** + * Assigns own and inherited properties from multiple source objects to a target object using a customizer function. + * + * @template R - The type of the result. + * @param object - The target object to which properties will be assigned. + * @param otherArgs - The source objects and customizer function. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const result = assignInWith(target, { b: 2 }, { c: 3 }, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignInWith(object: any, ...otherArgs: any[]): R; +//#endregion +export { assignInWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/assignInWith.js b/node_modules/es-toolkit/dist/compat/object/assignInWith.js new file mode 100644 index 0000000000000000000000000000000000000000..a58ca1828b822646e57682f62e867592d940f1f7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignInWith.js @@ -0,0 +1,47 @@ +const require_eq = require("../util/eq.js"); +const require_keysIn = require("./keysIn.js"); +//#region src/compat/object/assignInWith.ts +/** +* Assigns properties from multiple source objects to a target object. +* You can provide a `getValueToAssign` function to determine what value will be assigned for each property. +* +* This function merges the properties of the source objects into the target object, +* including properties from the prototype chain. If a property in the source objects +* is equal to the corresponding property in the target object, it will not be overwritten. +* +* Unlike `assignIn`, this method accepts a `getValueToAssign` function that determines +* the final value to be assigned to each property in the target object. The return value +* of this function will be directly assigned to the corresponding property. This allows for +* more precise control over how properties are merged between objects. If not provided, +* the default behavior is equivalent to using the identity function (returning the source value). +* +* @param object - The target object to which properties will be assigned. +* @param sources - The source objects whose properties will be assigned to the target object. +* @returns The updated target object with properties from the source objects assigned. +* +* @example +* const target = { a: 1 }; +* const result = assignInWith(target, { b: 2 }, { c: 3 }, function(objValue, srcValue) { +* return objValue === undefined ? srcValue : objValue; +* }); +* console.log(result); // Output: { a: 1, b: 2, c: 3 } +*/ +function assignInWith(object, ...sources) { + let getValueToAssign = sources[sources.length - 1]; + if (typeof getValueToAssign === "function") sources.pop(); + else getValueToAssign = void 0; + for (let i = 0; i < sources.length; i++) assignInWithImpl(object, sources[i], getValueToAssign); + return object; +} +function assignInWithImpl(object, source, getValueToAssign) { + const keys = require_keysIn.keysIn(source); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const objValue = object[key]; + const srcValue = source[key]; + const newValue = getValueToAssign?.(objValue, srcValue, key, object, source) ?? srcValue; + if (!(key in object) || !require_eq.eq(objValue, newValue)) object[key] = newValue; + } +} +//#endregion +exports.assignInWith = assignInWith; diff --git a/node_modules/es-toolkit/dist/compat/object/assignInWith.mjs b/node_modules/es-toolkit/dist/compat/object/assignInWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f55c5c39279f4f4d03543bc96db9b0d5cb477afc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignInWith.mjs @@ -0,0 +1,47 @@ +import { eq } from "../util/eq.mjs"; +import { keysIn } from "./keysIn.mjs"; +//#region src/compat/object/assignInWith.ts +/** +* Assigns properties from multiple source objects to a target object. +* You can provide a `getValueToAssign` function to determine what value will be assigned for each property. +* +* This function merges the properties of the source objects into the target object, +* including properties from the prototype chain. If a property in the source objects +* is equal to the corresponding property in the target object, it will not be overwritten. +* +* Unlike `assignIn`, this method accepts a `getValueToAssign` function that determines +* the final value to be assigned to each property in the target object. The return value +* of this function will be directly assigned to the corresponding property. This allows for +* more precise control over how properties are merged between objects. If not provided, +* the default behavior is equivalent to using the identity function (returning the source value). +* +* @param object - The target object to which properties will be assigned. +* @param sources - The source objects whose properties will be assigned to the target object. +* @returns The updated target object with properties from the source objects assigned. +* +* @example +* const target = { a: 1 }; +* const result = assignInWith(target, { b: 2 }, { c: 3 }, function(objValue, srcValue) { +* return objValue === undefined ? srcValue : objValue; +* }); +* console.log(result); // Output: { a: 1, b: 2, c: 3 } +*/ +function assignInWith(object, ...sources) { + let getValueToAssign = sources[sources.length - 1]; + if (typeof getValueToAssign === "function") sources.pop(); + else getValueToAssign = void 0; + for (let i = 0; i < sources.length; i++) assignInWithImpl(object, sources[i], getValueToAssign); + return object; +} +function assignInWithImpl(object, source, getValueToAssign) { + const keys = keysIn(source); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const objValue = object[key]; + const srcValue = source[key]; + const newValue = getValueToAssign?.(objValue, srcValue, key, object, source) ?? srcValue; + if (!(key in object) || !eq(objValue, newValue)) object[key] = newValue; + } +} +//#endregion +export { assignInWith }; diff --git a/node_modules/es-toolkit/dist/compat/object/assignWith.d.mts b/node_modules/es-toolkit/dist/compat/object/assignWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9749f787c17706c537f16d5e8465aaf28ab86dc1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignWith.d.mts @@ -0,0 +1,127 @@ +//#region src/compat/object/assignWith.d.ts +type AssignCustomizer = (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; +/** + * Assigns own properties from one source object to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the source object. + * @param object - The target object to which properties will be assigned. + * @param source - The source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source object assigned. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * const result = assignWith(target, source, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 4 } + */ +declare function assignWith(object: T, source: U, customizer: AssignCustomizer): T & U; +/** + * Assigns own properties from two source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const result = assignWith(target, source1, source2, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignWith(object: T, source1: U, source2: V, customizer: AssignCustomizer): T & U & V; +/** + * Assigns own properties from three source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const result = assignWith(target, source1, source2, source3, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assignWith(object: T, source1: U, source2: V, source3: W, customizer: AssignCustomizer): T & U & V & W; +/** + * Assigns own properties from four source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @template X - The type of the fourth source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param source4 - The fourth source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * const result = assignWith(target, source1, source2, source3, source4, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function assignWith(object: T, source1: U, source2: V, source3: W, source4: X, customizer: AssignCustomizer): T & U & V & W & X; +/** + * Returns the target object as-is. + * + * @template T - The type of the target object. + * @param object - The target object. + * @returns The target object. + * + * @example + * const target = { a: 1, b: 2 }; + * const result = assignWith(target); + * // => { a: 1, b: 2 } + */ +declare function assignWith(object: T): T; +/** + * Assigns own properties from multiple source objects to a target object using a customizer function. + * + * @template R - The type of the result. + * @param object - The target object to which properties will be assigned. + * @param otherArgs - The source objects and customizer function. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const result = assignWith(target, { b: 2 }, { c: 3 }, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignWith(object: any, ...otherArgs: any[]): R; +//#endregion +export { assignWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/assignWith.d.ts b/node_modules/es-toolkit/dist/compat/object/assignWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9749f787c17706c537f16d5e8465aaf28ab86dc1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignWith.d.ts @@ -0,0 +1,127 @@ +//#region src/compat/object/assignWith.d.ts +type AssignCustomizer = (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; +/** + * Assigns own properties from one source object to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the source object. + * @param object - The target object to which properties will be assigned. + * @param source - The source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source object assigned. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * const result = assignWith(target, source, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 4 } + */ +declare function assignWith(object: T, source: U, customizer: AssignCustomizer): T & U; +/** + * Assigns own properties from two source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const result = assignWith(target, source1, source2, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignWith(object: T, source1: U, source2: V, customizer: AssignCustomizer): T & U & V; +/** + * Assigns own properties from three source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const result = assignWith(target, source1, source2, source3, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function assignWith(object: T, source1: U, source2: V, source3: W, customizer: AssignCustomizer): T & U & V & W; +/** + * Assigns own properties from four source objects to a target object using a customizer function. + * + * @template T - The type of the target object. + * @template U - The type of the first source object. + * @template V - The type of the second source object. + * @template W - The type of the third source object. + * @template X - The type of the fourth source object. + * @param object - The target object to which properties will be assigned. + * @param source1 - The first source object whose properties will be assigned to the target object. + * @param source2 - The second source object whose properties will be assigned to the target object. + * @param source3 - The third source object whose properties will be assigned to the target object. + * @param source4 - The fourth source object whose properties will be assigned to the target object. + * @param customizer - The function to customize assigned values. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * const result = assignWith(target, source1, source2, source3, source4, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function assignWith(object: T, source1: U, source2: V, source3: W, source4: X, customizer: AssignCustomizer): T & U & V & W & X; +/** + * Returns the target object as-is. + * + * @template T - The type of the target object. + * @param object - The target object. + * @returns The target object. + * + * @example + * const target = { a: 1, b: 2 }; + * const result = assignWith(target); + * // => { a: 1, b: 2 } + */ +declare function assignWith(object: T): T; +/** + * Assigns own properties from multiple source objects to a target object using a customizer function. + * + * @template R - The type of the result. + * @param object - The target object to which properties will be assigned. + * @param otherArgs - The source objects and customizer function. + * @returns The updated target object with properties from the source objects assigned. + * + * @example + * const target = { a: 1 }; + * const result = assignWith(target, { b: 2 }, { c: 3 }, (objValue, srcValue) => { + * return objValue === undefined ? srcValue : objValue; + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function assignWith(object: any, ...otherArgs: any[]): R; +//#endregion +export { assignWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/assignWith.js b/node_modules/es-toolkit/dist/compat/object/assignWith.js new file mode 100644 index 0000000000000000000000000000000000000000..f488f8de67078e2b7c979b0dc7ca82ed464d0e25 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignWith.js @@ -0,0 +1,47 @@ +const require_eq = require("../util/eq.js"); +const require_keys = require("./keys.js"); +//#region src/compat/object/assignWith.ts +/** +* Assigns properties from multiple source objects to a target object. +* You can provide a `getValueToAssign` function to determine what value will be assigned for each property. +* +* This function merges the properties of the source objects into the target object. +* If a property in the source objects is equal to the corresponding property in the target object, +* it will not be overwritten. +* +* Unlike `assign`, this method accepts a `getValueToAssign` function that determines +* the final value to be assigned to each property in the target object. The return value +* of this function will be directly assigned to the corresponding property. This allows for +* more precise control over how properties are merged between objects. If not provided, +* the default behavior is equivalent to using the identity function (returning the source value). +* +* @param object - The target object to which properties will be assigned. +* @param sources - The source objects whose properties will be assigned to the target object. +* @returns The updated target object with properties from the source objects assigned. +* +* @example +* const target = { a: 1 }; +* const result = assignWith(target, { b: 2 }, { c: 3 }, function(objValue, srcValue) { +* return objValue === undefined ? srcValue : objValue; +* }); +* console.log(result); // Output: { a: 1, b: 2, c: 3 } +*/ +function assignWith(object, ...sources) { + let getValueToAssign = sources[sources.length - 1]; + if (typeof getValueToAssign === "function") sources.pop(); + else getValueToAssign = void 0; + for (let i = 0; i < sources.length; i++) assignWithImpl(object, sources[i], getValueToAssign); + return object; +} +function assignWithImpl(object, source, getValueToAssign) { + const keys$1 = require_keys.keys(source); + for (let i = 0; i < keys$1.length; i++) { + const key = keys$1[i]; + const objValue = object[key]; + const srcValue = source[key]; + const newValue = getValueToAssign?.(objValue, srcValue, key, object, source) ?? srcValue; + if (!(key in object) || !require_eq.eq(objValue, newValue)) object[key] = newValue; + } +} +//#endregion +exports.assignWith = assignWith; diff --git a/node_modules/es-toolkit/dist/compat/object/assignWith.mjs b/node_modules/es-toolkit/dist/compat/object/assignWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..da6bbf17c141619ad14c9c6e1940cf32b0546ee5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/assignWith.mjs @@ -0,0 +1,47 @@ +import { eq } from "../util/eq.mjs"; +import { keys } from "./keys.mjs"; +//#region src/compat/object/assignWith.ts +/** +* Assigns properties from multiple source objects to a target object. +* You can provide a `getValueToAssign` function to determine what value will be assigned for each property. +* +* This function merges the properties of the source objects into the target object. +* If a property in the source objects is equal to the corresponding property in the target object, +* it will not be overwritten. +* +* Unlike `assign`, this method accepts a `getValueToAssign` function that determines +* the final value to be assigned to each property in the target object. The return value +* of this function will be directly assigned to the corresponding property. This allows for +* more precise control over how properties are merged between objects. If not provided, +* the default behavior is equivalent to using the identity function (returning the source value). +* +* @param object - The target object to which properties will be assigned. +* @param sources - The source objects whose properties will be assigned to the target object. +* @returns The updated target object with properties from the source objects assigned. +* +* @example +* const target = { a: 1 }; +* const result = assignWith(target, { b: 2 }, { c: 3 }, function(objValue, srcValue) { +* return objValue === undefined ? srcValue : objValue; +* }); +* console.log(result); // Output: { a: 1, b: 2, c: 3 } +*/ +function assignWith(object, ...sources) { + let getValueToAssign = sources[sources.length - 1]; + if (typeof getValueToAssign === "function") sources.pop(); + else getValueToAssign = void 0; + for (let i = 0; i < sources.length; i++) assignWithImpl(object, sources[i], getValueToAssign); + return object; +} +function assignWithImpl(object, source, getValueToAssign) { + const keys$1 = keys(source); + for (let i = 0; i < keys$1.length; i++) { + const key = keys$1[i]; + const objValue = object[key]; + const srcValue = source[key]; + const newValue = getValueToAssign?.(objValue, srcValue, key, object, source) ?? srcValue; + if (!(key in object) || !eq(objValue, newValue)) object[key] = newValue; + } +} +//#endregion +export { assignWith }; diff --git a/node_modules/es-toolkit/dist/compat/object/at.d.mts b/node_modules/es-toolkit/dist/compat/object/at.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..278d8c92301c88def49cdc78219d62428d6557f0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/at.d.mts @@ -0,0 +1,34 @@ +//#region src/compat/object/at.d.ts +type PropertyName = string | number | symbol; +type Many = T | readonly T[]; +type PropertyPath = Many; +/** + * Gets values at given paths from a dictionary or numeric dictionary. + * + * @template T - The type of the values in the dictionary. + * @param object - The dictionary to query. + * @param props - The property paths to get values for. + * @returns Returns an array of the picked values. + * + * @example + * const object = { 'a': 1, 'b': 2, 'c': 3 }; + * at(object, 'a', 'c'); + * // => [1, 3] + */ +declare function at(object: Record | Record | null | undefined, ...props: PropertyPath[]): T[]; +/** + * Gets values at given keys from an object. + * + * @template T - The type of the object. + * @param object - The object to query. + * @param props - The property keys to get values for. + * @returns Returns an array of the picked values. + * + * @example + * const object = { 'a': 1, 'b': 2, 'c': 3 }; + * at(object, 'a', 'c'); + * // => [1, 3] + */ +declare function at(object: T | null | undefined, ...props: Array>): Array; +//#endregion +export { at }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/at.d.ts b/node_modules/es-toolkit/dist/compat/object/at.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..278d8c92301c88def49cdc78219d62428d6557f0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/at.d.ts @@ -0,0 +1,34 @@ +//#region src/compat/object/at.d.ts +type PropertyName = string | number | symbol; +type Many = T | readonly T[]; +type PropertyPath = Many; +/** + * Gets values at given paths from a dictionary or numeric dictionary. + * + * @template T - The type of the values in the dictionary. + * @param object - The dictionary to query. + * @param props - The property paths to get values for. + * @returns Returns an array of the picked values. + * + * @example + * const object = { 'a': 1, 'b': 2, 'c': 3 }; + * at(object, 'a', 'c'); + * // => [1, 3] + */ +declare function at(object: Record | Record | null | undefined, ...props: PropertyPath[]): T[]; +/** + * Gets values at given keys from an object. + * + * @template T - The type of the object. + * @param object - The object to query. + * @param props - The property keys to get values for. + * @returns Returns an array of the picked values. + * + * @example + * const object = { 'a': 1, 'b': 2, 'c': 3 }; + * at(object, 'a', 'c'); + * // => [1, 3] + */ +declare function at(object: T | null | undefined, ...props: Array>): Array; +//#endregion +export { at }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/at.js b/node_modules/es-toolkit/dist/compat/object/at.js new file mode 100644 index 0000000000000000000000000000000000000000..90dc6239a614b5e81f1de48271862ab308589365 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/at.js @@ -0,0 +1,37 @@ +const require_isArrayLike = require("../predicate/isArrayLike.js"); +const require_get = require("./get.js"); +const require_isString = require("../predicate/isString.js"); +//#region src/compat/object/at.ts +/** +* Returns an array of values corresponding to `paths` of `object`. +* +* @template T - The type of the object. +* @param object - The object to iterate over. +* @param [paths] - The property paths to pick. +* @returns Returns the picked values. +* +* @example +* ```js +* const object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; +* +* at(object, ['a[0].b.c', 'a[1]']); +* // => [3, 4] +* ``` +*/ +function at(object, ...paths) { + if (paths.length === 0) return []; + const allPaths = []; + for (let i = 0; i < paths.length; i++) { + const path = paths[i]; + if (!require_isArrayLike.isArrayLike(path) || require_isString.isString(path)) { + allPaths.push(path); + continue; + } + for (let j = 0; j < path.length; j++) allPaths.push(path[j]); + } + const result = []; + for (let i = 0; i < allPaths.length; i++) result.push(require_get.get(object, allPaths[i])); + return result; +} +//#endregion +exports.at = at; diff --git a/node_modules/es-toolkit/dist/compat/object/at.mjs b/node_modules/es-toolkit/dist/compat/object/at.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0e987f10d990dcd0b6508d5f864958bad4f1309e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/at.mjs @@ -0,0 +1,37 @@ +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +import { get } from "./get.mjs"; +import { isString } from "../predicate/isString.mjs"; +//#region src/compat/object/at.ts +/** +* Returns an array of values corresponding to `paths` of `object`. +* +* @template T - The type of the object. +* @param object - The object to iterate over. +* @param [paths] - The property paths to pick. +* @returns Returns the picked values. +* +* @example +* ```js +* const object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; +* +* at(object, ['a[0].b.c', 'a[1]']); +* // => [3, 4] +* ``` +*/ +function at(object, ...paths) { + if (paths.length === 0) return []; + const allPaths = []; + for (let i = 0; i < paths.length; i++) { + const path = paths[i]; + if (!isArrayLike(path) || isString(path)) { + allPaths.push(path); + continue; + } + for (let j = 0; j < path.length; j++) allPaths.push(path[j]); + } + const result = []; + for (let i = 0; i < allPaths.length; i++) result.push(get(object, allPaths[i])); + return result; +} +//#endregion +export { at }; diff --git a/node_modules/es-toolkit/dist/compat/object/clone.d.mts b/node_modules/es-toolkit/dist/compat/object/clone.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c35ba23b47a3f47a04179307067784579b1ed056 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/clone.d.mts @@ -0,0 +1,32 @@ +//#region src/compat/object/clone.d.ts +/** + * Creates a shallow clone of the given object. + * + * @template T - The type of the object. + * @param obj - The object to clone. + * @returns A shallow clone of the given object. + * + * @example + * // Clone a primitive object + * const num = 29; + * const clonedNum = clone(num); + * console.log(clonedNum); // 29 + * console.log(clonedNum === num); // true + * + * @example + * // Clone an array + * const arr = [1, 2, 3]; + * const clonedArr = clone(arr); + * console.log(clonedArr); // [1, 2, 3] + * console.log(clonedArr === arr); // false + * + * @example + * // Clone an object + * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; + * const clonedObj = clone(obj); + * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } + * console.log(clonedObj === obj); // false + */ +declare function clone(obj: T): T; +//#endregion +export { clone }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/clone.d.ts b/node_modules/es-toolkit/dist/compat/object/clone.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c35ba23b47a3f47a04179307067784579b1ed056 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/clone.d.ts @@ -0,0 +1,32 @@ +//#region src/compat/object/clone.d.ts +/** + * Creates a shallow clone of the given object. + * + * @template T - The type of the object. + * @param obj - The object to clone. + * @returns A shallow clone of the given object. + * + * @example + * // Clone a primitive object + * const num = 29; + * const clonedNum = clone(num); + * console.log(clonedNum); // 29 + * console.log(clonedNum === num); // true + * + * @example + * // Clone an array + * const arr = [1, 2, 3]; + * const clonedArr = clone(arr); + * console.log(clonedArr); // [1, 2, 3] + * console.log(clonedArr === arr); // false + * + * @example + * // Clone an object + * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; + * const clonedObj = clone(obj); + * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } + * console.log(clonedObj === obj); // false + */ +declare function clone(obj: T): T; +//#endregion +export { clone }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/clone.js b/node_modules/es-toolkit/dist/compat/object/clone.js new file mode 100644 index 0000000000000000000000000000000000000000..39927f5983fc252ab1cfecd38ebd78df171e4675 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/clone.js @@ -0,0 +1,156 @@ +const require_isPrimitive = require("../../predicate/isPrimitive.js"); +const require_getTag = require("../_internal/getTag.js"); +const require_tags = require("../_internal/tags.js"); +const require_isArray = require("../predicate/isArray.js"); +const require_isTypedArray = require("../predicate/isTypedArray.js"); +//#region src/compat/object/clone.ts +/** +* Creates a shallow clone of the given object. +* +* @template T - The type of the object. +* @param obj - The object to clone. +* @returns A shallow clone of the given object. +* +* @example +* // Clone a primitive object +* const num = 29; +* const clonedNum = clone(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an array +* const arr = [1, 2, 3]; +* const clonedArr = clone(arr); +* console.log(clonedArr); // [1, 2, 3] +* console.log(clonedArr === arr); // false +* +* @example +* // Clone an object +* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; +* const clonedObj = clone(obj); +* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } +* console.log(clonedObj === obj); // false +*/ +function clone(obj) { + if (require_isPrimitive.isPrimitive(obj)) return obj; + const tag = require_getTag.getTag(obj); + if (!isCloneableObject(obj)) return {}; + if (require_isArray.isArray(obj)) { + const result = Array.from(obj); + if (obj.length > 0 && typeof obj[0] === "string" && Object.hasOwn(obj, "index")) { + result.index = obj.index; + result.input = obj.input; + } + return result; + } + if (require_isTypedArray.isTypedArray(obj)) { + const typedArray = obj; + const Ctor = typedArray.constructor; + return new Ctor(typedArray.buffer, typedArray.byteOffset, typedArray.length); + } + if (tag === "[object ArrayBuffer]") return new ArrayBuffer(obj.byteLength); + if (tag === "[object DataView]") { + const dataView = obj; + const buffer = dataView.buffer; + const byteOffset = dataView.byteOffset; + const byteLength = dataView.byteLength; + const clonedBuffer = new ArrayBuffer(byteLength); + const srcView = new Uint8Array(buffer, byteOffset, byteLength); + new Uint8Array(clonedBuffer).set(srcView); + return new DataView(clonedBuffer); + } + if (tag === "[object Boolean]" || tag === "[object Number]" || tag === "[object String]") { + const Ctor = obj.constructor; + const clone = new Ctor(obj.valueOf()); + if (tag === "[object String]") cloneStringObjectProperties(clone, obj); + else copyOwnProperties(clone, obj); + return clone; + } + if (tag === "[object Date]") return new Date(Number(obj)); + if (tag === "[object RegExp]") { + const regExp = obj; + const clone = new RegExp(regExp.source, regExp.flags); + clone.lastIndex = regExp.lastIndex; + return clone; + } + if (tag === "[object Symbol]") return Object(Symbol.prototype.valueOf.call(obj)); + if (tag === "[object Map]") { + const map = obj; + const result = /* @__PURE__ */ new Map(); + map.forEach((obj, key) => { + result.set(key, obj); + }); + return result; + } + if (tag === "[object Set]") { + const set = obj; + const result = /* @__PURE__ */ new Set(); + set.forEach((obj) => { + result.add(obj); + }); + return result; + } + if (tag === "[object Arguments]") { + const args = obj; + const result = {}; + copyOwnProperties(result, args); + result.length = args.length; + result[Symbol.iterator] = args[Symbol.iterator]; + return result; + } + const result = {}; + copyPrototype(result, obj); + copyOwnProperties(result, obj); + copySymbolProperties(result, obj); + return result; +} +function isCloneableObject(object) { + switch (require_getTag.getTag(object)) { + case require_tags.argumentsTag: + case require_tags.arrayTag: + case require_tags.arrayBufferTag: + case require_tags.dataViewTag: + case require_tags.booleanTag: + case require_tags.dateTag: + case require_tags.float32ArrayTag: + case require_tags.float64ArrayTag: + case require_tags.int8ArrayTag: + case require_tags.int16ArrayTag: + case require_tags.int32ArrayTag: + case require_tags.mapTag: + case require_tags.numberTag: + case require_tags.objectTag: + case require_tags.regexpTag: + case require_tags.setTag: + case require_tags.stringTag: + case require_tags.symbolTag: + case require_tags.uint8ArrayTag: + case require_tags.uint8ClampedArrayTag: + case require_tags.uint16ArrayTag: + case require_tags.uint32ArrayTag: return true; + default: return false; + } +} +function copyOwnProperties(target, source) { + for (const key in source) if (Object.hasOwn(source, key)) target[key] = source[key]; +} +function copySymbolProperties(target, source) { + const symbols = Object.getOwnPropertySymbols(source); + for (let i = 0; i < symbols.length; i++) { + const symbol = symbols[i]; + if (Object.prototype.propertyIsEnumerable.call(source, symbol)) target[symbol] = source[symbol]; + } +} +function cloneStringObjectProperties(target, source) { + const stringLength = source.valueOf().length; + for (const key in source) if (Object.hasOwn(source, key) && (Number.isNaN(Number(key)) || Number(key) >= stringLength)) target[key] = source[key]; +} +function copyPrototype(target, source) { + const proto = Object.getPrototypeOf(source); + if (proto !== null) { + if (typeof source.constructor === "function") Object.setPrototypeOf(target, proto); + } +} +//#endregion +exports.clone = clone; diff --git a/node_modules/es-toolkit/dist/compat/object/clone.mjs b/node_modules/es-toolkit/dist/compat/object/clone.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0d13a65fd451df2d8f8ab411005ce52c8a660b8f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/clone.mjs @@ -0,0 +1,156 @@ +import { isPrimitive } from "../../predicate/isPrimitive.mjs"; +import { getTag } from "../_internal/getTag.mjs"; +import { argumentsTag, arrayBufferTag, arrayTag, booleanTag, dataViewTag, dateTag, float32ArrayTag, float64ArrayTag, int16ArrayTag, int32ArrayTag, int8ArrayTag, mapTag, numberTag, objectTag, regexpTag, setTag, stringTag, symbolTag, uint16ArrayTag, uint32ArrayTag, uint8ArrayTag, uint8ClampedArrayTag } from "../_internal/tags.mjs"; +import { isArray } from "../predicate/isArray.mjs"; +import { isTypedArray } from "../predicate/isTypedArray.mjs"; +//#region src/compat/object/clone.ts +/** +* Creates a shallow clone of the given object. +* +* @template T - The type of the object. +* @param obj - The object to clone. +* @returns A shallow clone of the given object. +* +* @example +* // Clone a primitive object +* const num = 29; +* const clonedNum = clone(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an array +* const arr = [1, 2, 3]; +* const clonedArr = clone(arr); +* console.log(clonedArr); // [1, 2, 3] +* console.log(clonedArr === arr); // false +* +* @example +* // Clone an object +* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; +* const clonedObj = clone(obj); +* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } +* console.log(clonedObj === obj); // false +*/ +function clone(obj) { + if (isPrimitive(obj)) return obj; + const tag = getTag(obj); + if (!isCloneableObject(obj)) return {}; + if (isArray(obj)) { + const result = Array.from(obj); + if (obj.length > 0 && typeof obj[0] === "string" && Object.hasOwn(obj, "index")) { + result.index = obj.index; + result.input = obj.input; + } + return result; + } + if (isTypedArray(obj)) { + const typedArray = obj; + const Ctor = typedArray.constructor; + return new Ctor(typedArray.buffer, typedArray.byteOffset, typedArray.length); + } + if (tag === "[object ArrayBuffer]") return new ArrayBuffer(obj.byteLength); + if (tag === "[object DataView]") { + const dataView = obj; + const buffer = dataView.buffer; + const byteOffset = dataView.byteOffset; + const byteLength = dataView.byteLength; + const clonedBuffer = new ArrayBuffer(byteLength); + const srcView = new Uint8Array(buffer, byteOffset, byteLength); + new Uint8Array(clonedBuffer).set(srcView); + return new DataView(clonedBuffer); + } + if (tag === "[object Boolean]" || tag === "[object Number]" || tag === "[object String]") { + const Ctor = obj.constructor; + const clone = new Ctor(obj.valueOf()); + if (tag === "[object String]") cloneStringObjectProperties(clone, obj); + else copyOwnProperties(clone, obj); + return clone; + } + if (tag === "[object Date]") return new Date(Number(obj)); + if (tag === "[object RegExp]") { + const regExp = obj; + const clone = new RegExp(regExp.source, regExp.flags); + clone.lastIndex = regExp.lastIndex; + return clone; + } + if (tag === "[object Symbol]") return Object(Symbol.prototype.valueOf.call(obj)); + if (tag === "[object Map]") { + const map = obj; + const result = /* @__PURE__ */ new Map(); + map.forEach((obj, key) => { + result.set(key, obj); + }); + return result; + } + if (tag === "[object Set]") { + const set = obj; + const result = /* @__PURE__ */ new Set(); + set.forEach((obj) => { + result.add(obj); + }); + return result; + } + if (tag === "[object Arguments]") { + const args = obj; + const result = {}; + copyOwnProperties(result, args); + result.length = args.length; + result[Symbol.iterator] = args[Symbol.iterator]; + return result; + } + const result = {}; + copyPrototype(result, obj); + copyOwnProperties(result, obj); + copySymbolProperties(result, obj); + return result; +} +function isCloneableObject(object) { + switch (getTag(object)) { + case argumentsTag: + case arrayTag: + case arrayBufferTag: + case dataViewTag: + case booleanTag: + case dateTag: + case float32ArrayTag: + case float64ArrayTag: + case int8ArrayTag: + case int16ArrayTag: + case int32ArrayTag: + case mapTag: + case numberTag: + case objectTag: + case regexpTag: + case setTag: + case stringTag: + case symbolTag: + case uint8ArrayTag: + case uint8ClampedArrayTag: + case uint16ArrayTag: + case uint32ArrayTag: return true; + default: return false; + } +} +function copyOwnProperties(target, source) { + for (const key in source) if (Object.hasOwn(source, key)) target[key] = source[key]; +} +function copySymbolProperties(target, source) { + const symbols = Object.getOwnPropertySymbols(source); + for (let i = 0; i < symbols.length; i++) { + const symbol = symbols[i]; + if (Object.prototype.propertyIsEnumerable.call(source, symbol)) target[symbol] = source[symbol]; + } +} +function cloneStringObjectProperties(target, source) { + const stringLength = source.valueOf().length; + for (const key in source) if (Object.hasOwn(source, key) && (Number.isNaN(Number(key)) || Number(key) >= stringLength)) target[key] = source[key]; +} +function copyPrototype(target, source) { + const proto = Object.getPrototypeOf(source); + if (proto !== null) { + if (typeof source.constructor === "function") Object.setPrototypeOf(target, proto); + } +} +//#endregion +export { clone }; diff --git a/node_modules/es-toolkit/dist/compat/object/cloneDeep.d.mts b/node_modules/es-toolkit/dist/compat/object/cloneDeep.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8a6772485f6436e8df45ae36e53c1232ea96f383 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneDeep.d.mts @@ -0,0 +1,50 @@ +//#region src/compat/object/cloneDeep.d.ts +/** + * Creates a deep clone of the given object. + * + * @template T - The type of the object. + * @param obj - The object to clone. + * @returns A deep clone of the given object. + * + * @example + * // Clone a primitive value + * const num = 29; + * const clonedNum = clone(num); + * console.log(clonedNum); // 29 + * console.log(clonedNum === num); // true + * + * @example + * // Clone an array + * const arr = [1, 2, 3]; + * const clonedArr = clone(arr); + * console.log(clonedArr); // [1, 2, 3] + * console.log(clonedArr === arr); // false + * + * @example + * // Clone an array with nested objects + * const arr = [1, { a: 1 }, [1, 2, 3]]; + * const clonedArr = clone(arr); + * arr[1].a = 2; + * console.log(arr); // [2, { a: 2 }, [1, 2, 3]] + * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]] + * console.log(clonedArr === arr); // false + * + * @example + * // Clone an object + * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; + * const clonedObj = clone(obj); + * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } + * console.log(clonedObj === obj); // false + * + * @example + * // Clone an object with nested objects + * const obj = { a: 1, b: { c: 1 } }; + * const clonedObj = clone(obj); + * obj.b.c = 2; + * console.log(obj); // { a: 1, b: { c: 2 } } + * console.log(clonedObj); // { a: 1, b: { c: 1 } } + * console.log(clonedObj === obj); // false + */ +declare function cloneDeep(obj: T): T; +//#endregion +export { cloneDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/cloneDeep.d.ts b/node_modules/es-toolkit/dist/compat/object/cloneDeep.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a6772485f6436e8df45ae36e53c1232ea96f383 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneDeep.d.ts @@ -0,0 +1,50 @@ +//#region src/compat/object/cloneDeep.d.ts +/** + * Creates a deep clone of the given object. + * + * @template T - The type of the object. + * @param obj - The object to clone. + * @returns A deep clone of the given object. + * + * @example + * // Clone a primitive value + * const num = 29; + * const clonedNum = clone(num); + * console.log(clonedNum); // 29 + * console.log(clonedNum === num); // true + * + * @example + * // Clone an array + * const arr = [1, 2, 3]; + * const clonedArr = clone(arr); + * console.log(clonedArr); // [1, 2, 3] + * console.log(clonedArr === arr); // false + * + * @example + * // Clone an array with nested objects + * const arr = [1, { a: 1 }, [1, 2, 3]]; + * const clonedArr = clone(arr); + * arr[1].a = 2; + * console.log(arr); // [2, { a: 2 }, [1, 2, 3]] + * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]] + * console.log(clonedArr === arr); // false + * + * @example + * // Clone an object + * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; + * const clonedObj = clone(obj); + * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } + * console.log(clonedObj === obj); // false + * + * @example + * // Clone an object with nested objects + * const obj = { a: 1, b: { c: 1 } }; + * const clonedObj = clone(obj); + * obj.b.c = 2; + * console.log(obj); // { a: 1, b: { c: 2 } } + * console.log(clonedObj); // { a: 1, b: { c: 1 } } + * console.log(clonedObj === obj); // false + */ +declare function cloneDeep(obj: T): T; +//#endregion +export { cloneDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/cloneDeep.js b/node_modules/es-toolkit/dist/compat/object/cloneDeep.js new file mode 100644 index 0000000000000000000000000000000000000000..73e98ffa5583fa64242e0f442251f1d2c04665ce --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneDeep.js @@ -0,0 +1,53 @@ +const require_cloneDeepWith = require("./cloneDeepWith.js"); +//#region src/compat/object/cloneDeep.ts +/** +* Creates a deep clone of the given object. +* +* @template T - The type of the object. +* @param obj - The object to clone. +* @returns A deep clone of the given object. +* +* @example +* // Clone a primitive value +* const num = 29; +* const clonedNum = clone(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an array +* const arr = [1, 2, 3]; +* const clonedArr = clone(arr); +* console.log(clonedArr); // [1, 2, 3] +* console.log(clonedArr === arr); // false +* +* @example +* // Clone an array with nested objects +* const arr = [1, { a: 1 }, [1, 2, 3]]; +* const clonedArr = clone(arr); +* arr[1].a = 2; +* console.log(arr); // [2, { a: 2 }, [1, 2, 3]] +* console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]] +* console.log(clonedArr === arr); // false +* +* @example +* // Clone an object +* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; +* const clonedObj = clone(obj); +* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } +* console.log(clonedObj === obj); // false +* +* @example +* // Clone an object with nested objects +* const obj = { a: 1, b: { c: 1 } }; +* const clonedObj = clone(obj); +* obj.b.c = 2; +* console.log(obj); // { a: 1, b: { c: 2 } } +* console.log(clonedObj); // { a: 1, b: { c: 1 } } +* console.log(clonedObj === obj); // false +*/ +function cloneDeep(obj) { + return require_cloneDeepWith.cloneDeepWith(obj); +} +//#endregion +exports.cloneDeep = cloneDeep; diff --git a/node_modules/es-toolkit/dist/compat/object/cloneDeep.mjs b/node_modules/es-toolkit/dist/compat/object/cloneDeep.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8094b426a0d4a6ca1e076fe219aaed80436cac4c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneDeep.mjs @@ -0,0 +1,53 @@ +import { cloneDeepWith } from "./cloneDeepWith.mjs"; +//#region src/compat/object/cloneDeep.ts +/** +* Creates a deep clone of the given object. +* +* @template T - The type of the object. +* @param obj - The object to clone. +* @returns A deep clone of the given object. +* +* @example +* // Clone a primitive value +* const num = 29; +* const clonedNum = clone(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an array +* const arr = [1, 2, 3]; +* const clonedArr = clone(arr); +* console.log(clonedArr); // [1, 2, 3] +* console.log(clonedArr === arr); // false +* +* @example +* // Clone an array with nested objects +* const arr = [1, { a: 1 }, [1, 2, 3]]; +* const clonedArr = clone(arr); +* arr[1].a = 2; +* console.log(arr); // [2, { a: 2 }, [1, 2, 3]] +* console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]] +* console.log(clonedArr === arr); // false +* +* @example +* // Clone an object +* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; +* const clonedObj = clone(obj); +* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } +* console.log(clonedObj === obj); // false +* +* @example +* // Clone an object with nested objects +* const obj = { a: 1, b: { c: 1 } }; +* const clonedObj = clone(obj); +* obj.b.c = 2; +* console.log(obj); // { a: 1, b: { c: 2 } } +* console.log(clonedObj); // { a: 1, b: { c: 1 } } +* console.log(clonedObj === obj); // false +*/ +function cloneDeep(obj) { + return cloneDeepWith(obj); +} +//#endregion +export { cloneDeep }; diff --git a/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.d.mts b/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fce9234bcc079b6b208eae3c4e934626fb6fc67a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.d.mts @@ -0,0 +1,35 @@ +//#region src/compat/object/cloneDeepWith.d.ts +type CloneDeepWithCustomizer = (value: any, key: number | string | undefined, object: TObject | undefined, stack: any) => any; +/** + * Creates a deep clone of the given value using a customizer function. + * + * @template T - The type of the value. + * @param value - The value to clone. + * @param customizer - A function to customize the cloning process. + * @returns A deep clone of the given value. + * + * @example + * const obj = { a: 1, b: 2 }; + * const clonedObj = cloneDeepWith(obj, (value) => { + * if (typeof value === 'number') { + * return value * 2; + * } + * }); + * // => { a: 2, b: 4 } + */ +declare function cloneDeepWith(value: T, customizer: CloneDeepWithCustomizer): any; +/** + * Creates a deep clone of the given value. + * + * @template T - The type of the value. + * @param value - The value to clone. + * @returns A deep clone of the given value. + * + * @example + * const obj = { a: 1, b: { c: 2 } }; + * const clonedObj = cloneDeepWith(obj); + * // => { a: 1, b: { c: 2 } } + */ +declare function cloneDeepWith(value: T): T; +//#endregion +export { cloneDeepWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.d.ts b/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fce9234bcc079b6b208eae3c4e934626fb6fc67a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.d.ts @@ -0,0 +1,35 @@ +//#region src/compat/object/cloneDeepWith.d.ts +type CloneDeepWithCustomizer = (value: any, key: number | string | undefined, object: TObject | undefined, stack: any) => any; +/** + * Creates a deep clone of the given value using a customizer function. + * + * @template T - The type of the value. + * @param value - The value to clone. + * @param customizer - A function to customize the cloning process. + * @returns A deep clone of the given value. + * + * @example + * const obj = { a: 1, b: 2 }; + * const clonedObj = cloneDeepWith(obj, (value) => { + * if (typeof value === 'number') { + * return value * 2; + * } + * }); + * // => { a: 2, b: 4 } + */ +declare function cloneDeepWith(value: T, customizer: CloneDeepWithCustomizer): any; +/** + * Creates a deep clone of the given value. + * + * @template T - The type of the value. + * @param value - The value to clone. + * @returns A deep clone of the given value. + * + * @example + * const obj = { a: 1, b: { c: 2 } }; + * const clonedObj = cloneDeepWith(obj); + * // => { a: 1, b: { c: 2 } } + */ +declare function cloneDeepWith(value: T): T; +//#endregion +export { cloneDeepWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js b/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js new file mode 100644 index 0000000000000000000000000000000000000000..3c505d868a5599b836ad87b62af336d4779fdbc5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js @@ -0,0 +1,71 @@ +const require_getTag = require("../_internal/getTag.js"); +const require_tags = require("../_internal/tags.js"); +const require_cloneDeepWith = require("../../object/cloneDeepWith.js"); +//#region src/compat/object/cloneDeepWith.ts +/** +* Creates a deep clone of the given object using a customizer function. +* +* @template T - The type of the object. +* @param obj - The object to clone. +* @param [cloneValue] - A function to customize the cloning process. +* @returns A deep clone of the given object. +* +* @example +* // Clone a primitive value +* const num = 29; +* const clonedNum = cloneDeepWith(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an object with a customizer +* const obj = { a: 1, b: 2 }; +* const clonedObj = cloneDeepWith(obj, (value) => { +* if (typeof value === 'number') { +* return value * 2; // Double the number +* } +* }); +* console.log(clonedObj); // { a: 2, b: 4 } +* console.log(clonedObj === obj); // false +* +* @example +* // Clone an array with a customizer +* const arr = [1, 2, 3]; +* const clonedArr = cloneDeepWith(arr, (value) => { +* return value + 1; // Increment each value +* }); +* console.log(clonedArr); // [2, 3, 4] +* console.log(clonedArr === arr); // false +*/ +function cloneDeepWith(obj, customizer) { + return require_cloneDeepWith.cloneDeepWith(obj, (value, key, object, stack) => { + const cloned = customizer?.(value, key, object, stack); + if (cloned !== void 0) return cloned; + if (typeof obj !== "object") return; + if (require_getTag.getTag(obj) === "[object Object]" && typeof obj.constructor !== "function") { + const result = {}; + stack.set(obj, result); + require_cloneDeepWith.copyProperties(result, obj, object, stack); + return result; + } + switch (Object.prototype.toString.call(obj)) { + case require_tags.numberTag: + case require_tags.stringTag: + case require_tags.booleanTag: { + const result = new obj.constructor(obj?.valueOf()); + require_cloneDeepWith.copyProperties(result, obj); + return result; + } + case require_tags.argumentsTag: { + const result = {}; + require_cloneDeepWith.copyProperties(result, obj); + result.length = obj.length; + result[Symbol.iterator] = obj[Symbol.iterator]; + return result; + } + default: return; + } + }); +} +//#endregion +exports.cloneDeepWith = cloneDeepWith; diff --git a/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.mjs b/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..89bc392c1365370720935d13e9c6a9591cca81f5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.mjs @@ -0,0 +1,71 @@ +import { getTag } from "../_internal/getTag.mjs"; +import { argumentsTag, booleanTag, numberTag, stringTag } from "../_internal/tags.mjs"; +import { cloneDeepWith as cloneDeepWith$1, copyProperties } from "../../object/cloneDeepWith.mjs"; +//#region src/compat/object/cloneDeepWith.ts +/** +* Creates a deep clone of the given object using a customizer function. +* +* @template T - The type of the object. +* @param obj - The object to clone. +* @param [cloneValue] - A function to customize the cloning process. +* @returns A deep clone of the given object. +* +* @example +* // Clone a primitive value +* const num = 29; +* const clonedNum = cloneDeepWith(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an object with a customizer +* const obj = { a: 1, b: 2 }; +* const clonedObj = cloneDeepWith(obj, (value) => { +* if (typeof value === 'number') { +* return value * 2; // Double the number +* } +* }); +* console.log(clonedObj); // { a: 2, b: 4 } +* console.log(clonedObj === obj); // false +* +* @example +* // Clone an array with a customizer +* const arr = [1, 2, 3]; +* const clonedArr = cloneDeepWith(arr, (value) => { +* return value + 1; // Increment each value +* }); +* console.log(clonedArr); // [2, 3, 4] +* console.log(clonedArr === arr); // false +*/ +function cloneDeepWith(obj, customizer) { + return cloneDeepWith$1(obj, (value, key, object, stack) => { + const cloned = customizer?.(value, key, object, stack); + if (cloned !== void 0) return cloned; + if (typeof obj !== "object") return; + if (getTag(obj) === "[object Object]" && typeof obj.constructor !== "function") { + const result = {}; + stack.set(obj, result); + copyProperties(result, obj, object, stack); + return result; + } + switch (Object.prototype.toString.call(obj)) { + case numberTag: + case stringTag: + case booleanTag: { + const result = new obj.constructor(obj?.valueOf()); + copyProperties(result, obj); + return result; + } + case argumentsTag: { + const result = {}; + copyProperties(result, obj); + result.length = obj.length; + result[Symbol.iterator] = obj[Symbol.iterator]; + return result; + } + default: return; + } + }); +} +//#endregion +export { cloneDeepWith }; diff --git a/node_modules/es-toolkit/dist/compat/object/cloneWith.d.mts b/node_modules/es-toolkit/dist/compat/object/cloneWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..007831d585758165df38560fcdd278079e2cccd9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneWith.d.mts @@ -0,0 +1,55 @@ +//#region src/compat/object/cloneWith.d.ts +type CloneWithCustomizer = (value: T, key: number | string | undefined, object: any, stack: any) => R; +/** + * Creates a shallow clone of a value with customizer that returns a specific result type. + * + * @template T - The type of the value to clone. + * @template R - The result type extending primitive types or objects. + * @param value - The value to clone. + * @param customizer - The function to customize cloning. + * @returns Returns the cloned value. + * + * @example + * const obj = { a: 1, b: 2 }; + * const cloned = cloneWith(obj, (value) => { + * if (typeof value === 'object') { + * return JSON.parse(JSON.stringify(value)); + * } + * }); + * // => { a: 1, b: 2 } + */ +declare function cloneWith(value: T, customizer: CloneWithCustomizer): R; +/** + * Creates a shallow clone of a value with optional customizer. + * + * @template T - The type of the value to clone. + * @template R - The result type. + * @param value - The value to clone. + * @param customizer - The function to customize cloning. + * @returns Returns the cloned value or the customized result. + * + * @example + * const obj = { a: 1, b: 2 }; + * const cloned = cloneWith(obj, (value) => { + * if (typeof value === 'number') { + * return value * 2; + * } + * }); + * // => { a: 2, b: 4 } + */ +declare function cloneWith(value: T, customizer: CloneWithCustomizer): R | T; +/** + * Creates a shallow clone of a value. + * + * @template T - The type of the value to clone. + * @param value - The value to clone. + * @returns Returns the cloned value. + * + * @example + * const obj = { a: 1, b: 2 }; + * const cloned = cloneWith(obj); + * // => { a: 1, b: 2 } + */ +declare function cloneWith(value: T): T; +//#endregion +export { cloneWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/cloneWith.d.ts b/node_modules/es-toolkit/dist/compat/object/cloneWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..007831d585758165df38560fcdd278079e2cccd9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneWith.d.ts @@ -0,0 +1,55 @@ +//#region src/compat/object/cloneWith.d.ts +type CloneWithCustomizer = (value: T, key: number | string | undefined, object: any, stack: any) => R; +/** + * Creates a shallow clone of a value with customizer that returns a specific result type. + * + * @template T - The type of the value to clone. + * @template R - The result type extending primitive types or objects. + * @param value - The value to clone. + * @param customizer - The function to customize cloning. + * @returns Returns the cloned value. + * + * @example + * const obj = { a: 1, b: 2 }; + * const cloned = cloneWith(obj, (value) => { + * if (typeof value === 'object') { + * return JSON.parse(JSON.stringify(value)); + * } + * }); + * // => { a: 1, b: 2 } + */ +declare function cloneWith(value: T, customizer: CloneWithCustomizer): R; +/** + * Creates a shallow clone of a value with optional customizer. + * + * @template T - The type of the value to clone. + * @template R - The result type. + * @param value - The value to clone. + * @param customizer - The function to customize cloning. + * @returns Returns the cloned value or the customized result. + * + * @example + * const obj = { a: 1, b: 2 }; + * const cloned = cloneWith(obj, (value) => { + * if (typeof value === 'number') { + * return value * 2; + * } + * }); + * // => { a: 2, b: 4 } + */ +declare function cloneWith(value: T, customizer: CloneWithCustomizer): R | T; +/** + * Creates a shallow clone of a value. + * + * @template T - The type of the value to clone. + * @param value - The value to clone. + * @returns Returns the cloned value. + * + * @example + * const obj = { a: 1, b: 2 }; + * const cloned = cloneWith(obj); + * // => { a: 1, b: 2 } + */ +declare function cloneWith(value: T): T; +//#endregion +export { cloneWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/cloneWith.js b/node_modules/es-toolkit/dist/compat/object/cloneWith.js new file mode 100644 index 0000000000000000000000000000000000000000..2ce30341c7b824e9fc4b72a7f3c7b409be4cc4fd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneWith.js @@ -0,0 +1,55 @@ +const require_clone = require("./clone.js"); +//#region src/compat/object/cloneWith.ts +/** +* Creates a shallow clone of the given object with customization. +* This method is like `_.clone` except that it accepts a customizer which +* is invoked to produce the cloned value. If customizer returns undefined, +* cloning is handled by the method instead. +* +* If no customizer is provided, it behaves like `clone`. +* +* @template T - The type of the object. +* @param value - The value to clone. +* @param [customizer] - The function to customize cloning. +* @returns A shallow clone of the given object. +* +* @example +* // Clone a primitive value +* const num = 29; +* const clonedNum = cloneWith(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an array +* const arr = [1, 2, 3]; +* const clonedArr = cloneWith(arr); +* console.log(clonedArr); // [1, 2, 3] +* console.log(clonedArr === arr); // false +* +* @example +* // Clone an object +* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; +* const clonedObj = cloneWith(obj); +* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } +* console.log(clonedObj === obj); // false +* +* @example +* // Clone an object with a customizer +* const obj = { a: 1, b: 2 }; +* const clonedObj = cloneWith(obj, (value) => { +* if (typeof value === 'number') { +* return value * 2; // Double the number +* } +* // Returning undefined uses the default cloning +* }); +* console.log(clonedObj); // { a: 2, b: 4 } +*/ +function cloneWith(value, customizer) { + if (!customizer) return require_clone.clone(value); + const result = customizer(value); + if (result !== void 0) return result; + return require_clone.clone(value); +} +//#endregion +exports.cloneWith = cloneWith; diff --git a/node_modules/es-toolkit/dist/compat/object/cloneWith.mjs b/node_modules/es-toolkit/dist/compat/object/cloneWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9ceb815c1ae657ca1f525c0422e3406fff86907b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/cloneWith.mjs @@ -0,0 +1,55 @@ +import { clone } from "./clone.mjs"; +//#region src/compat/object/cloneWith.ts +/** +* Creates a shallow clone of the given object with customization. +* This method is like `_.clone` except that it accepts a customizer which +* is invoked to produce the cloned value. If customizer returns undefined, +* cloning is handled by the method instead. +* +* If no customizer is provided, it behaves like `clone`. +* +* @template T - The type of the object. +* @param value - The value to clone. +* @param [customizer] - The function to customize cloning. +* @returns A shallow clone of the given object. +* +* @example +* // Clone a primitive value +* const num = 29; +* const clonedNum = cloneWith(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an array +* const arr = [1, 2, 3]; +* const clonedArr = cloneWith(arr); +* console.log(clonedArr); // [1, 2, 3] +* console.log(clonedArr === arr); // false +* +* @example +* // Clone an object +* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] }; +* const clonedObj = cloneWith(obj); +* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] } +* console.log(clonedObj === obj); // false +* +* @example +* // Clone an object with a customizer +* const obj = { a: 1, b: 2 }; +* const clonedObj = cloneWith(obj, (value) => { +* if (typeof value === 'number') { +* return value * 2; // Double the number +* } +* // Returning undefined uses the default cloning +* }); +* console.log(clonedObj); // { a: 2, b: 4 } +*/ +function cloneWith(value, customizer) { + if (!customizer) return clone(value); + const result = customizer(value); + if (result !== void 0) return result; + return clone(value); +} +//#endregion +export { cloneWith }; diff --git a/node_modules/es-toolkit/dist/compat/object/create.d.mts b/node_modules/es-toolkit/dist/compat/object/create.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6ca986e7b8e4a8d17e0196a0743119671925b329 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/create.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/object/create.d.ts +/** + * Creates an object that inherits from the prototype object. + * + * If `properties` are provided, they will be added to the new object. + * Only string-keyed enumerable properties directly owned by the `properties` object are copied. + * Inherited properties or those with `Symbol` keys are not copied. + * + * @template T - The prototype object type. + * @template U - The properties object type. + * @param prototype - The object to inherit from. + * @param properties - The properties to assign to the created object. + * @returns The new object. + */ +declare function create(prototype: T, properties?: U): T & U; +//#endregion +export { create }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/create.d.ts b/node_modules/es-toolkit/dist/compat/object/create.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ca986e7b8e4a8d17e0196a0743119671925b329 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/create.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/object/create.d.ts +/** + * Creates an object that inherits from the prototype object. + * + * If `properties` are provided, they will be added to the new object. + * Only string-keyed enumerable properties directly owned by the `properties` object are copied. + * Inherited properties or those with `Symbol` keys are not copied. + * + * @template T - The prototype object type. + * @template U - The properties object type. + * @param prototype - The object to inherit from. + * @param properties - The properties to assign to the created object. + * @returns The new object. + */ +declare function create(prototype: T, properties?: U): T & U; +//#endregion +export { create }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/create.js b/node_modules/es-toolkit/dist/compat/object/create.js new file mode 100644 index 0000000000000000000000000000000000000000..eb34f1e50ce44793329a8beeb33abe407af8b46d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/create.js @@ -0,0 +1,31 @@ +const require_isObject = require("../predicate/isObject.js"); +const require_keys = require("./keys.js"); +const require_assignValue = require("../_internal/assignValue.js"); +//#region src/compat/object/create.ts +/** +* Creates an object that inherits from the prototype object. +* +* If `properties` are provided, they will be added to the new object. +* Only string-keyed enumerable properties directly owned by the `properties` object are copied. +* Inherited properties or those with `Symbol` keys are not copied. +* +* @template T - The prototype object type. +* @template U - The properties object type. +* @param prototype - The object to inherit from. +* @param properties - The properties to assign to the created object. +* @returns The new object. +*/ +function create(prototype, properties) { + const proto = require_isObject.isObject(prototype) ? Object.create(prototype) : {}; + if (properties != null) { + const propsKeys = require_keys.keys(properties); + for (let i = 0; i < propsKeys.length; i++) { + const key = propsKeys[i]; + const propsValue = properties[key]; + require_assignValue.assignValue(proto, key, propsValue); + } + } + return proto; +} +//#endregion +exports.create = create; diff --git a/node_modules/es-toolkit/dist/compat/object/create.mjs b/node_modules/es-toolkit/dist/compat/object/create.mjs new file mode 100644 index 0000000000000000000000000000000000000000..436f8537cd7afd576a5082b5d6759a27692290ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/create.mjs @@ -0,0 +1,31 @@ +import { isObject } from "../predicate/isObject.mjs"; +import { keys } from "./keys.mjs"; +import { assignValue } from "../_internal/assignValue.mjs"; +//#region src/compat/object/create.ts +/** +* Creates an object that inherits from the prototype object. +* +* If `properties` are provided, they will be added to the new object. +* Only string-keyed enumerable properties directly owned by the `properties` object are copied. +* Inherited properties or those with `Symbol` keys are not copied. +* +* @template T - The prototype object type. +* @template U - The properties object type. +* @param prototype - The object to inherit from. +* @param properties - The properties to assign to the created object. +* @returns The new object. +*/ +function create(prototype, properties) { + const proto = isObject(prototype) ? Object.create(prototype) : {}; + if (properties != null) { + const propsKeys = keys(properties); + for (let i = 0; i < propsKeys.length; i++) { + const key = propsKeys[i]; + const propsValue = properties[key]; + assignValue(proto, key, propsValue); + } + } + return proto; +} +//#endregion +export { create }; diff --git a/node_modules/es-toolkit/dist/compat/object/defaults.d.mts b/node_modules/es-toolkit/dist/compat/object/defaults.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e2ba1d408bf497aa278d2feb717623000653bb81 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/defaults.d.mts @@ -0,0 +1,101 @@ +//#region src/compat/object/defaults.d.ts +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @template S - The type of the object that provides default values. + * @param object - The target object that will receive default values. + * @param source - The object that specifies the default values to apply. + * @returns The `object` that has been updated with default values from `source`. + * + * @example + * defaults({ a: 1 }, { b: 2 }); // { a: 1, b: 2 } + * defaults({ a: undefined }, { a: 1 }); // { a: 1 } + */ +declare function defaults(object: T, source: S): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @returns The `object` that has been updated with default values from `source1` and `source2`. + * + * @example + * defaults({ a: 1 }, { b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } + * defaults({ a: undefined }, { a: 1 }, { b: 2 }); // { a: 1, b: 2 } + */ +declare function defaults(object: T, source1: S1, source2: S2): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @template S3 - The type of the third object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @param source3 - The third object that specifies the default values to apply. + * @returns The `object` that has been updated with default values from `source1`, `source2`, and `source3`. + * + * @example + * defaults({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }); // { a: 1, b: 2, c: 3, d: 4 } + * defaults({ a: undefined }, { a: 1 }, { b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } + */ +declare function defaults(object: T, source1: S1, source2: S2, source3: S3): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @template S3 - The type of the third object that provides default values. + * @template S4 - The type of the fourth object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @param source3 - The third object that specifies the default values to apply. + * @param source4 - The fourth object that specifies the default values to apply. + * @returns The `object` that has been updated with default values from `source1`, `source2`, `source3`, and `source4`. + * + * @example + * defaults({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }, { e: 5 }); // { a: 1, b: 2, c: 3, d: 4, e: 5 } + * defaults({ a: undefined }, { a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }); // { a: 1, b: 2, c: 3, d: 4 } + */ +declare function defaults(object: T, source1: S1, source2: S2, source3: S3, source4: S4): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @param object - The target object that will receive default values. + * @returns The `object` that has been updated with default values. + * + * @example + * defaults({ a: 1 }); // { a: 1 } + * defaults({ a: undefined }); // { a: undefined } + */ +declare function defaults(object: T): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @param object - The target object that will receive default values. + * @param sources - The objects that specify the default values to apply. + * @returns The `object` that has been updated with default values from `sources`. + * + * @example + * defaults({}, { a: 1 }, { b: 2 }); // { a: 1, b: 2 } + * defaults({ a: undefined }, { a: 1 }); // { a: 1 } + */ +declare function defaults(object: any, ...sources: any[]): any; +//#endregion +export { defaults }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/defaults.d.ts b/node_modules/es-toolkit/dist/compat/object/defaults.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e2ba1d408bf497aa278d2feb717623000653bb81 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/defaults.d.ts @@ -0,0 +1,101 @@ +//#region src/compat/object/defaults.d.ts +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @template S - The type of the object that provides default values. + * @param object - The target object that will receive default values. + * @param source - The object that specifies the default values to apply. + * @returns The `object` that has been updated with default values from `source`. + * + * @example + * defaults({ a: 1 }, { b: 2 }); // { a: 1, b: 2 } + * defaults({ a: undefined }, { a: 1 }); // { a: 1 } + */ +declare function defaults(object: T, source: S): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @returns The `object` that has been updated with default values from `source1` and `source2`. + * + * @example + * defaults({ a: 1 }, { b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } + * defaults({ a: undefined }, { a: 1 }, { b: 2 }); // { a: 1, b: 2 } + */ +declare function defaults(object: T, source1: S1, source2: S2): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @template S3 - The type of the third object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @param source3 - The third object that specifies the default values to apply. + * @returns The `object` that has been updated with default values from `source1`, `source2`, and `source3`. + * + * @example + * defaults({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }); // { a: 1, b: 2, c: 3, d: 4 } + * defaults({ a: undefined }, { a: 1 }, { b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } + */ +declare function defaults(object: T, source1: S1, source2: S2, source3: S3): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @template S3 - The type of the third object that provides default values. + * @template S4 - The type of the fourth object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @param source3 - The third object that specifies the default values to apply. + * @param source4 - The fourth object that specifies the default values to apply. + * @returns The `object` that has been updated with default values from `source1`, `source2`, `source3`, and `source4`. + * + * @example + * defaults({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }, { e: 5 }); // { a: 1, b: 2, c: 3, d: 4, e: 5 } + * defaults({ a: undefined }, { a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }); // { a: 1, b: 2, c: 3, d: 4 } + */ +declare function defaults(object: T, source1: S1, source2: S2, source3: S3, source4: S4): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @template T - The type of the object being processed. + * @param object - The target object that will receive default values. + * @returns The `object` that has been updated with default values. + * + * @example + * defaults({ a: 1 }); // { a: 1 } + * defaults({ a: undefined }); // { a: undefined } + */ +declare function defaults(object: T): NonNullable; +/** + * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * @param object - The target object that will receive default values. + * @param sources - The objects that specify the default values to apply. + * @returns The `object` that has been updated with default values from `sources`. + * + * @example + * defaults({}, { a: 1 }, { b: 2 }); // { a: 1, b: 2 } + * defaults({ a: undefined }, { a: 1 }); // { a: 1 } + */ +declare function defaults(object: any, ...sources: any[]): any; +//#endregion +export { defaults }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/defaults.js b/node_modules/es-toolkit/dist/compat/object/defaults.js new file mode 100644 index 0000000000000000000000000000000000000000..87b74a4278e838b05063f7113f5b26d8ddd6d34d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/defaults.js @@ -0,0 +1,46 @@ +const require_eq = require("../util/eq.js"); +const require_isNil = require("../../predicate/isNil.js"); +const require_isIterateeCall = require("../_internal/isIterateeCall.js"); +//#region src/compat/object/defaults.ts +/** +* Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. +* It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. +* +* You can pass in multiple objects to define these default values, +* and they will be applied in order from left to right. +* Once a property has been assigned a value, any subsequent values for that property will be ignored. +* +* Note: This function modifies the first argument, `object`. If you want to keep `object` unchanged, consider using `toDefaulted` instead. +* +* @template T - The type of the object being processed. +* @template S - The type of the objects that provides default values. +* @param object - The target object that will receive default values. +* @param source - The objects that specifies the default values to apply. +* @returns The `object` that has been updated with default values from `sources`, ensuring that all properties are defined and none are left as `undefined`. +* +* @example +* defaults({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } +* defaults({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 } +* defaults({ a: null }, { a: 1 }); // { a: null } +* defaults({ a: undefined }, { a: 1 }); // { a: 1 } +*/ +function defaults(object, ...sources) { + object = Object(object); + const objectProto = Object.prototype; + let length = sources.length; + const guard = length > 2 ? sources[2] : void 0; + if (guard && require_isIterateeCall.isIterateeCall(sources[0], sources[1], guard)) length = 1; + for (let i = 0; i < length; i++) { + if (require_isNil.isNil(sources[i])) continue; + const source = sources[i]; + const keys = Object.keys(source); + for (let j = 0; j < keys.length; j++) { + const key = keys[j]; + const value = object[key]; + if (value === void 0 || !Object.hasOwn(object, key) && require_eq.eq(value, objectProto[key])) object[key] = source[key]; + } + } + return object; +} +//#endregion +exports.defaults = defaults; diff --git a/node_modules/es-toolkit/dist/compat/object/defaults.mjs b/node_modules/es-toolkit/dist/compat/object/defaults.mjs new file mode 100644 index 0000000000000000000000000000000000000000..341fc626e413d0609b184b9bee063065e8e10d75 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/defaults.mjs @@ -0,0 +1,46 @@ +import { eq } from "../util/eq.mjs"; +import { isNil } from "../../predicate/isNil.mjs"; +import { isIterateeCall } from "../_internal/isIterateeCall.mjs"; +//#region src/compat/object/defaults.ts +/** +* Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. +* It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. +* +* You can pass in multiple objects to define these default values, +* and they will be applied in order from left to right. +* Once a property has been assigned a value, any subsequent values for that property will be ignored. +* +* Note: This function modifies the first argument, `object`. If you want to keep `object` unchanged, consider using `toDefaulted` instead. +* +* @template T - The type of the object being processed. +* @template S - The type of the objects that provides default values. +* @param object - The target object that will receive default values. +* @param source - The objects that specifies the default values to apply. +* @returns The `object` that has been updated with default values from `sources`, ensuring that all properties are defined and none are left as `undefined`. +* +* @example +* defaults({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } +* defaults({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 } +* defaults({ a: null }, { a: 1 }); // { a: null } +* defaults({ a: undefined }, { a: 1 }); // { a: 1 } +*/ +function defaults(object, ...sources) { + object = Object(object); + const objectProto = Object.prototype; + let length = sources.length; + const guard = length > 2 ? sources[2] : void 0; + if (guard && isIterateeCall(sources[0], sources[1], guard)) length = 1; + for (let i = 0; i < length; i++) { + if (isNil(sources[i])) continue; + const source = sources[i]; + const keys = Object.keys(source); + for (let j = 0; j < keys.length; j++) { + const key = keys[j]; + const value = object[key]; + if (value === void 0 || !Object.hasOwn(object, key) && eq(value, objectProto[key])) object[key] = source[key]; + } + } + return object; +} +//#endregion +export { defaults }; diff --git a/node_modules/es-toolkit/dist/compat/object/defaultsDeep.d.mts b/node_modules/es-toolkit/dist/compat/object/defaultsDeep.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c5c268f4490c1710d49301e5918ee761f4c7e31e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/defaultsDeep.d.mts @@ -0,0 +1,24 @@ +//#region src/compat/object/defaultsDeep.d.ts +/** + * Recursively assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * Similar to `defaults` but recursively applies default values to nested objects. + * Source objects are applied in order from left to right, and once a property has been assigned a value, + * any subsequent values for that property will be ignored. + * + * Note: This function modifies the first argument, `object`. + * + * @template T - The type of the object being processed. + * @param target - The target object that will receive default values. + * @param sources - One or more source objects that specify default values to apply. + * @returns The `object` that has been updated with default values from all sources, recursively merging nested objects. + * + * @example + * defaultsDeep({ a: { b: 2 } }, { a: { b: 3, c: 3 }, d: 4 }); // { a: { b: 2, c: 3 }, d: 4 } + * defaultsDeep({ a: { b: undefined } }, { a: { b: 1 } }); // { a: { b: 1 } } + * defaultsDeep({ a: null }, { a: { b: 1 } }); // { a: null } + */ +declare function defaultsDeep(target: any, ...sources: any[]): any; +//#endregion +export { defaultsDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/defaultsDeep.d.ts b/node_modules/es-toolkit/dist/compat/object/defaultsDeep.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5c268f4490c1710d49301e5918ee761f4c7e31e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/defaultsDeep.d.ts @@ -0,0 +1,24 @@ +//#region src/compat/object/defaultsDeep.d.ts +/** + * Recursively assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. + * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. + * + * Similar to `defaults` but recursively applies default values to nested objects. + * Source objects are applied in order from left to right, and once a property has been assigned a value, + * any subsequent values for that property will be ignored. + * + * Note: This function modifies the first argument, `object`. + * + * @template T - The type of the object being processed. + * @param target - The target object that will receive default values. + * @param sources - One or more source objects that specify default values to apply. + * @returns The `object` that has been updated with default values from all sources, recursively merging nested objects. + * + * @example + * defaultsDeep({ a: { b: 2 } }, { a: { b: 3, c: 3 }, d: 4 }); // { a: { b: 2, c: 3 }, d: 4 } + * defaultsDeep({ a: { b: undefined } }, { a: { b: 1 } }); // { a: { b: 1 } } + * defaultsDeep({ a: null }, { a: { b: 1 } }); // { a: null } + */ +declare function defaultsDeep(target: any, ...sources: any[]): any; +//#endregion +export { defaultsDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/defaultsDeep.js b/node_modules/es-toolkit/dist/compat/object/defaultsDeep.js new file mode 100644 index 0000000000000000000000000000000000000000..1894dcc9e970307d7c1c66fdaff4446a45be1ae9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/defaultsDeep.js @@ -0,0 +1,70 @@ +const require_isPlainObject = require("../predicate/isPlainObject.js"); +//#region src/compat/object/defaultsDeep.ts +/** +* Recursively assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. +* It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. +* +* Similar to `defaults` but recursively applies default values to nested objects. +* Source objects are applied in order from left to right, and once a property has been assigned a value, +* any subsequent values for that property will be ignored. +* +* Note: This function modifies the first argument, `object`. +* +* @template T - The type of the object being processed. +* @param target - The target object that will receive default values. +* @param sources - One or more source objects that specify default values to apply. +* @returns The `object` that has been updated with default values from all sources, recursively merging nested objects. +* +* @example +* defaultsDeep({ a: { b: 2 } }, { a: { b: 3, c: 3 }, d: 4 }); // { a: { b: 2, c: 3 }, d: 4 } +* defaultsDeep({ a: { b: undefined } }, { a: { b: 1 } }); // { a: { b: 1 } } +* defaultsDeep({ a: null }, { a: { b: 1 } }); // { a: null } +*/ +function defaultsDeep(target, ...sources) { + target = Object(target); + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + if (source != null) defaultsDeepRecursive(target, source, /* @__PURE__ */ new WeakMap()); + } + return target; +} +function defaultsDeepRecursive(target, source, stack) { + for (const key in source) { + const sourceValue = source[key]; + const targetValue = target[key]; + if (targetValue === void 0 || !Object.hasOwn(target, key)) { + target[key] = handleMissingProperty(sourceValue, stack); + continue; + } + if (stack.get(sourceValue) === targetValue) continue; + handleExistingProperty(targetValue, sourceValue, stack); + } +} +function handleMissingProperty(sourceValue, stack) { + if (stack.has(sourceValue)) return stack.get(sourceValue); + if (require_isPlainObject.isPlainObject(sourceValue)) { + const newObj = {}; + stack.set(sourceValue, newObj); + defaultsDeepRecursive(newObj, sourceValue, stack); + return newObj; + } + return sourceValue; +} +function handleExistingProperty(targetValue, sourceValue, stack) { + if (require_isPlainObject.isPlainObject(targetValue) && require_isPlainObject.isPlainObject(sourceValue)) { + stack.set(sourceValue, targetValue); + defaultsDeepRecursive(targetValue, sourceValue, stack); + return; + } + if (Array.isArray(targetValue) && Array.isArray(sourceValue)) { + stack.set(sourceValue, targetValue); + mergeArrays(targetValue, sourceValue, stack); + } +} +function mergeArrays(targetArray, sourceArray, stack) { + const minLength = Math.min(sourceArray.length, targetArray.length); + for (let i = 0; i < minLength; i++) if (require_isPlainObject.isPlainObject(targetArray[i]) && require_isPlainObject.isPlainObject(sourceArray[i])) defaultsDeepRecursive(targetArray[i], sourceArray[i], stack); + for (let i = minLength; i < sourceArray.length; i++) targetArray.push(sourceArray[i]); +} +//#endregion +exports.defaultsDeep = defaultsDeep; diff --git a/node_modules/es-toolkit/dist/compat/object/defaultsDeep.mjs b/node_modules/es-toolkit/dist/compat/object/defaultsDeep.mjs new file mode 100644 index 0000000000000000000000000000000000000000..755ec2e64c148d2ae82b35c289d6787030c2e4cd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/defaultsDeep.mjs @@ -0,0 +1,70 @@ +import { isPlainObject } from "../predicate/isPlainObject.mjs"; +//#region src/compat/object/defaultsDeep.ts +/** +* Recursively assigns default values to an `object`, ensuring that certain properties do not remain `undefined`. +* It sets default values for properties that are either `undefined` or inherited from `Object.prototype`. +* +* Similar to `defaults` but recursively applies default values to nested objects. +* Source objects are applied in order from left to right, and once a property has been assigned a value, +* any subsequent values for that property will be ignored. +* +* Note: This function modifies the first argument, `object`. +* +* @template T - The type of the object being processed. +* @param target - The target object that will receive default values. +* @param sources - One or more source objects that specify default values to apply. +* @returns The `object` that has been updated with default values from all sources, recursively merging nested objects. +* +* @example +* defaultsDeep({ a: { b: 2 } }, { a: { b: 3, c: 3 }, d: 4 }); // { a: { b: 2, c: 3 }, d: 4 } +* defaultsDeep({ a: { b: undefined } }, { a: { b: 1 } }); // { a: { b: 1 } } +* defaultsDeep({ a: null }, { a: { b: 1 } }); // { a: null } +*/ +function defaultsDeep(target, ...sources) { + target = Object(target); + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + if (source != null) defaultsDeepRecursive(target, source, /* @__PURE__ */ new WeakMap()); + } + return target; +} +function defaultsDeepRecursive(target, source, stack) { + for (const key in source) { + const sourceValue = source[key]; + const targetValue = target[key]; + if (targetValue === void 0 || !Object.hasOwn(target, key)) { + target[key] = handleMissingProperty(sourceValue, stack); + continue; + } + if (stack.get(sourceValue) === targetValue) continue; + handleExistingProperty(targetValue, sourceValue, stack); + } +} +function handleMissingProperty(sourceValue, stack) { + if (stack.has(sourceValue)) return stack.get(sourceValue); + if (isPlainObject(sourceValue)) { + const newObj = {}; + stack.set(sourceValue, newObj); + defaultsDeepRecursive(newObj, sourceValue, stack); + return newObj; + } + return sourceValue; +} +function handleExistingProperty(targetValue, sourceValue, stack) { + if (isPlainObject(targetValue) && isPlainObject(sourceValue)) { + stack.set(sourceValue, targetValue); + defaultsDeepRecursive(targetValue, sourceValue, stack); + return; + } + if (Array.isArray(targetValue) && Array.isArray(sourceValue)) { + stack.set(sourceValue, targetValue); + mergeArrays(targetValue, sourceValue, stack); + } +} +function mergeArrays(targetArray, sourceArray, stack) { + const minLength = Math.min(sourceArray.length, targetArray.length); + for (let i = 0; i < minLength; i++) if (isPlainObject(targetArray[i]) && isPlainObject(sourceArray[i])) defaultsDeepRecursive(targetArray[i], sourceArray[i], stack); + for (let i = minLength; i < sourceArray.length; i++) targetArray.push(sourceArray[i]); +} +//#endregion +export { defaultsDeep }; diff --git a/node_modules/es-toolkit/dist/compat/object/extend.d.mts b/node_modules/es-toolkit/dist/compat/object/extend.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4bf314a8d840e931023bf4f495e40e9cd96bb286 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/extend.d.mts @@ -0,0 +1 @@ +import { assignIn } from "./assignIn.mjs"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/extend.d.ts b/node_modules/es-toolkit/dist/compat/object/extend.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..698dbf5426150d7c00b1732dba176ff740cc2deb --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/extend.d.ts @@ -0,0 +1 @@ +import { assignIn } from "./assignIn.js"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/extend.js b/node_modules/es-toolkit/dist/compat/object/extend.js new file mode 100644 index 0000000000000000000000000000000000000000..3255a35b7a5fc3ce42e17eaba591a90e667327ba --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/extend.js @@ -0,0 +1 @@ +require("./assignIn.js"); diff --git a/node_modules/es-toolkit/dist/compat/object/extend.mjs b/node_modules/es-toolkit/dist/compat/object/extend.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4615ce68d4f231478be8b783e567035119f9f0c1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/extend.mjs @@ -0,0 +1 @@ +import "./assignIn.mjs"; diff --git a/node_modules/es-toolkit/dist/compat/object/extendWith.d.mts b/node_modules/es-toolkit/dist/compat/object/extendWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..837df9828061bae5dba30c0f01c261fa120ed0d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/extendWith.d.mts @@ -0,0 +1 @@ +import { assignInWith } from "./assignInWith.mjs"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/extendWith.d.ts b/node_modules/es-toolkit/dist/compat/object/extendWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e2647c04444a0afeb09449ea79fd7316a759f7ee --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/extendWith.d.ts @@ -0,0 +1 @@ +import { assignInWith } from "./assignInWith.js"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/extendWith.js b/node_modules/es-toolkit/dist/compat/object/extendWith.js new file mode 100644 index 0000000000000000000000000000000000000000..a46f616df6b445b853f62109932f445d961ddda4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/extendWith.js @@ -0,0 +1 @@ +require("./assignInWith.js"); diff --git a/node_modules/es-toolkit/dist/compat/object/extendWith.mjs b/node_modules/es-toolkit/dist/compat/object/extendWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2a0163158fb1d993137c68eac3c39b7cb7c10ed9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/extendWith.mjs @@ -0,0 +1 @@ +import "./assignInWith.mjs"; diff --git a/node_modules/es-toolkit/dist/compat/object/findKey.d.mts b/node_modules/es-toolkit/dist/compat/object/findKey.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4fb6e975a14fce8022f0f78223f9a4b32ce2e53a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/findKey.d.mts @@ -0,0 +1,18 @@ +import { ObjectIteratee } from "../_internal/ObjectIteratee.mjs"; + +//#region src/compat/object/findKey.d.ts +/** + * Finds the key of the first element that matches the given predicate. + * + * This function determines the type of the predicate and delegates the search + * to the appropriate helper function. It supports predicates as functions, objects, + * arrays, or strings. + * + * @template T - The type of the object. + * @param obj - The object to inspect. + * @param predicate - The predicate to match. + * @returns Returns the key of the matched element, else `undefined`. + */ +declare function findKey(obj: T | null | undefined, predicate?: ObjectIteratee): string | undefined; +//#endregion +export { findKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/findKey.d.ts b/node_modules/es-toolkit/dist/compat/object/findKey.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c2a69773dc4b31277932f88837ff05ac3ca9c093 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/findKey.d.ts @@ -0,0 +1,18 @@ +import { ObjectIteratee } from "../_internal/ObjectIteratee.js"; + +//#region src/compat/object/findKey.d.ts +/** + * Finds the key of the first element that matches the given predicate. + * + * This function determines the type of the predicate and delegates the search + * to the appropriate helper function. It supports predicates as functions, objects, + * arrays, or strings. + * + * @template T - The type of the object. + * @param obj - The object to inspect. + * @param predicate - The predicate to match. + * @returns Returns the key of the matched element, else `undefined`. + */ +declare function findKey(obj: T | null | undefined, predicate?: ObjectIteratee): string | undefined; +//#endregion +export { findKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/findKey.js b/node_modules/es-toolkit/dist/compat/object/findKey.js new file mode 100644 index 0000000000000000000000000000000000000000..4d6db05fd3467bfa71c09286d96218fe19db29c0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/findKey.js @@ -0,0 +1,24 @@ +const require_findKey = require("../../object/findKey.js"); +const require_isObject = require("../predicate/isObject.js"); +const require_iteratee = require("../util/iteratee.js"); +const require_identity = require("../function/identity.js"); +//#region src/compat/object/findKey.ts +/** +* Finds the key of the first element that matches the given predicate. +* +* This function determines the type of the predicate and delegates the search +* to the appropriate helper function. It supports predicates as functions, objects, +* arrays, or strings. +* +* @template T - The type of the object. +* @param obj - The object to inspect. +* @param predicate - The predicate to match. +* @returns Returns the key of the matched element, else `undefined`. +*/ +function findKey(obj, predicate) { + if (!require_isObject.isObject(obj)) return; + const iteratee$1 = require_iteratee.iteratee(predicate ?? require_identity.identity); + return require_findKey.findKey(obj, iteratee$1); +} +//#endregion +exports.findKey = findKey; diff --git a/node_modules/es-toolkit/dist/compat/object/findKey.mjs b/node_modules/es-toolkit/dist/compat/object/findKey.mjs new file mode 100644 index 0000000000000000000000000000000000000000..305fcb2ea48c9445d865af0f99120396a1df467a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/findKey.mjs @@ -0,0 +1,23 @@ +import { findKey as findKey$1 } from "../../object/findKey.mjs"; +import { isObject } from "../predicate/isObject.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +import { identity } from "../function/identity.mjs"; +//#region src/compat/object/findKey.ts +/** +* Finds the key of the first element that matches the given predicate. +* +* This function determines the type of the predicate and delegates the search +* to the appropriate helper function. It supports predicates as functions, objects, +* arrays, or strings. +* +* @template T - The type of the object. +* @param obj - The object to inspect. +* @param predicate - The predicate to match. +* @returns Returns the key of the matched element, else `undefined`. +*/ +function findKey(obj, predicate) { + if (!isObject(obj)) return; + return findKey$1(obj, iteratee(predicate ?? identity)); +} +//#endregion +export { findKey }; diff --git a/node_modules/es-toolkit/dist/compat/object/findLastKey.d.mts b/node_modules/es-toolkit/dist/compat/object/findLastKey.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..21cfd4ffa95d9e00374fc990a747e2fdc8505684 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/findLastKey.d.mts @@ -0,0 +1,18 @@ +import { ObjectIteratee } from "../_internal/ObjectIteratee.mjs"; + +//#region src/compat/object/findLastKey.d.ts +/** + * Finds the key of the last element that matches the given predicate. + * + * This function determines the type of the predicate and delegates the search + * to the appropriate helper function. It supports predicates as functions, objects, + * arrays, or strings. + * + * @template T - The type of the object. + * @param obj - The object to inspect. + * @param predicate - The predicate to match. + * @returns Returns the key of the matched element, else `undefined`. + */ +declare function findLastKey(obj: T | null | undefined, predicate?: ObjectIteratee): string | undefined; +//#endregion +export { findLastKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/findLastKey.d.ts b/node_modules/es-toolkit/dist/compat/object/findLastKey.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b74a55aab71aa8966ca7a1c6c229f0c075cf8080 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/findLastKey.d.ts @@ -0,0 +1,18 @@ +import { ObjectIteratee } from "../_internal/ObjectIteratee.js"; + +//#region src/compat/object/findLastKey.d.ts +/** + * Finds the key of the last element that matches the given predicate. + * + * This function determines the type of the predicate and delegates the search + * to the appropriate helper function. It supports predicates as functions, objects, + * arrays, or strings. + * + * @template T - The type of the object. + * @param obj - The object to inspect. + * @param predicate - The predicate to match. + * @returns Returns the key of the matched element, else `undefined`. + */ +declare function findLastKey(obj: T | null | undefined, predicate?: ObjectIteratee): string | undefined; +//#endregion +export { findLastKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/findLastKey.js b/node_modules/es-toolkit/dist/compat/object/findLastKey.js new file mode 100644 index 0000000000000000000000000000000000000000..4268d1ee5b3d6558216938b3590816df9ede9daf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/findLastKey.js @@ -0,0 +1,23 @@ +const require_isObject = require("../predicate/isObject.js"); +const require_iteratee = require("../util/iteratee.js"); +const require_identity = require("../function/identity.js"); +//#region src/compat/object/findLastKey.ts +/** +* Finds the key of the last element that matches the given predicate. +* +* This function determines the type of the predicate and delegates the search +* to the appropriate helper function. It supports predicates as functions, objects, +* arrays, or strings. +* +* @template T - The type of the object. +* @param obj - The object to inspect. +* @param predicate - The predicate to match. +* @returns Returns the key of the matched element, else `undefined`. +*/ +function findLastKey(obj, predicate) { + if (!require_isObject.isObject(obj)) return; + const iteratee$1 = require_iteratee.iteratee(predicate ?? require_identity.identity); + return Object.keys(obj).findLast((key) => iteratee$1(obj[key], key, obj)); +} +//#endregion +exports.findLastKey = findLastKey; diff --git a/node_modules/es-toolkit/dist/compat/object/findLastKey.mjs b/node_modules/es-toolkit/dist/compat/object/findLastKey.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c78c266677d484f386548d58ed1bed70eadec290 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/findLastKey.mjs @@ -0,0 +1,23 @@ +import { isObject } from "../predicate/isObject.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +import { identity } from "../function/identity.mjs"; +//#region src/compat/object/findLastKey.ts +/** +* Finds the key of the last element that matches the given predicate. +* +* This function determines the type of the predicate and delegates the search +* to the appropriate helper function. It supports predicates as functions, objects, +* arrays, or strings. +* +* @template T - The type of the object. +* @param obj - The object to inspect. +* @param predicate - The predicate to match. +* @returns Returns the key of the matched element, else `undefined`. +*/ +function findLastKey(obj, predicate) { + if (!isObject(obj)) return; + const iteratee$1 = iteratee(predicate ?? identity); + return Object.keys(obj).findLast((key) => iteratee$1(obj[key], key, obj)); +} +//#endregion +export { findLastKey }; diff --git a/node_modules/es-toolkit/dist/compat/object/forIn.d.mts b/node_modules/es-toolkit/dist/compat/object/forIn.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..769e37c740ac313a0a8c0dc9329f40ce54c79e0a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forIn.d.mts @@ -0,0 +1,59 @@ +//#region src/compat/object/forIn.d.ts +/** + * Iterates over an object and invokes the `iteratee` function for each property. + * + * Iterates over string keyed properties including inherited properties. + * + * The iteration is terminated early if the `iteratee` function returns `false`. + * + * @template T - The type of the object + * @param object - The object to iterate over + * @param iteratee - The function invoked per iteration + * @returns Returns the object + * + * @example + * // Iterate over all properties including inherited ones + * const obj = { a: 1, b: 2 }; + * forIn(obj, (value, key) => { + * console.log(key, value); + * }); + * // Output: 'a' 1, 'b' 2 + * + * // Early termination + * forIn(obj, (value, key) => { + * console.log(key, value); + * return key !== 'a'; // stop after 'a' + * }); + * // Output: 'a' 1 + */ +declare function forIn(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T; +/** + * Iterates over an object and invokes the `iteratee` function for each property. + * + * Iterates over string keyed properties including inherited properties. + * + * The iteration is terminated early if the `iteratee` function returns `false`. + * + * @template T - The type of the object + * @param object - The object to iterate over + * @param iteratee - The function invoked per iteration + * @returns Returns the object + * + * @example + * // Iterate over all properties including inherited ones + * const obj = { a: 1, b: 2 }; + * forIn(obj, (value, key) => { + * console.log(key, value); + * }); + * // Output: 'a' 1, 'b' 2 + * + * // Early termination + * forIn(obj, (value, key) => { + * console.log(key, value); + * return key !== 'a'; // stop after 'a' + * }); + * // Output: 'a' 1 + */ +declare function forIn(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined; +//#endregion +export { forIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/forIn.d.ts b/node_modules/es-toolkit/dist/compat/object/forIn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..769e37c740ac313a0a8c0dc9329f40ce54c79e0a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forIn.d.ts @@ -0,0 +1,59 @@ +//#region src/compat/object/forIn.d.ts +/** + * Iterates over an object and invokes the `iteratee` function for each property. + * + * Iterates over string keyed properties including inherited properties. + * + * The iteration is terminated early if the `iteratee` function returns `false`. + * + * @template T - The type of the object + * @param object - The object to iterate over + * @param iteratee - The function invoked per iteration + * @returns Returns the object + * + * @example + * // Iterate over all properties including inherited ones + * const obj = { a: 1, b: 2 }; + * forIn(obj, (value, key) => { + * console.log(key, value); + * }); + * // Output: 'a' 1, 'b' 2 + * + * // Early termination + * forIn(obj, (value, key) => { + * console.log(key, value); + * return key !== 'a'; // stop after 'a' + * }); + * // Output: 'a' 1 + */ +declare function forIn(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T; +/** + * Iterates over an object and invokes the `iteratee` function for each property. + * + * Iterates over string keyed properties including inherited properties. + * + * The iteration is terminated early if the `iteratee` function returns `false`. + * + * @template T - The type of the object + * @param object - The object to iterate over + * @param iteratee - The function invoked per iteration + * @returns Returns the object + * + * @example + * // Iterate over all properties including inherited ones + * const obj = { a: 1, b: 2 }; + * forIn(obj, (value, key) => { + * console.log(key, value); + * }); + * // Output: 'a' 1, 'b' 2 + * + * // Early termination + * forIn(obj, (value, key) => { + * console.log(key, value); + * return key !== 'a'; // stop after 'a' + * }); + * // Output: 'a' 1 + */ +declare function forIn(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined; +//#endregion +export { forIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/forIn.js b/node_modules/es-toolkit/dist/compat/object/forIn.js new file mode 100644 index 0000000000000000000000000000000000000000..caced35e0d86470fcc017d4ab3613b904894b758 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forIn.js @@ -0,0 +1,36 @@ +const require_identity = require("../../function/identity.js"); +//#region src/compat/object/forIn.ts +/** +* Iterates over an object and invokes the `iteratee` function for each property. +* +* Iterates over string keyed properties including inherited properties. +* +* The iteration is terminated early if the `iteratee` function returns `false`. +* +* @template T - The type of the object +* @param object - The object to iterate over +* @param iteratee - The function invoked per iteration +* @returns Returns the object +* +* @example +* // Iterate over all properties including inherited ones +* const obj = { a: 1, b: 2 }; +* forIn(obj, (value, key) => { +* console.log(key, value); +* }); +* // Output: 'a' 1, 'b' 2 +* +* // Early termination +* forIn(obj, (value, key) => { +* console.log(key, value); +* return key !== 'a'; // stop after 'a' +* }); +* // Output: 'a' 1 +*/ +function forIn(object, iteratee = require_identity.identity) { + if (object == null) return object; + for (const key in object) if (iteratee(object[key], key, object) === false) break; + return object; +} +//#endregion +exports.forIn = forIn; diff --git a/node_modules/es-toolkit/dist/compat/object/forIn.mjs b/node_modules/es-toolkit/dist/compat/object/forIn.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e7f92b9c9d312a79cb4d6b060bc246c64a182ce3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forIn.mjs @@ -0,0 +1,36 @@ +import { identity } from "../../function/identity.mjs"; +//#region src/compat/object/forIn.ts +/** +* Iterates over an object and invokes the `iteratee` function for each property. +* +* Iterates over string keyed properties including inherited properties. +* +* The iteration is terminated early if the `iteratee` function returns `false`. +* +* @template T - The type of the object +* @param object - The object to iterate over +* @param iteratee - The function invoked per iteration +* @returns Returns the object +* +* @example +* // Iterate over all properties including inherited ones +* const obj = { a: 1, b: 2 }; +* forIn(obj, (value, key) => { +* console.log(key, value); +* }); +* // Output: 'a' 1, 'b' 2 +* +* // Early termination +* forIn(obj, (value, key) => { +* console.log(key, value); +* return key !== 'a'; // stop after 'a' +* }); +* // Output: 'a' 1 +*/ +function forIn(object, iteratee = identity) { + if (object == null) return object; + for (const key in object) if (iteratee(object[key], key, object) === false) break; + return object; +} +//#endregion +export { forIn }; diff --git a/node_modules/es-toolkit/dist/compat/object/forInRight.d.mts b/node_modules/es-toolkit/dist/compat/object/forInRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..43c401cf1cba7706329a39dbe1e80701e2e3155c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forInRight.d.mts @@ -0,0 +1,59 @@ +//#region src/compat/object/forInRight.d.ts +/** + * Iterates over an object in reverse order and invokes the `iteratee` function for each property. + * + * Iterates over string keyed properties including inherited properties in reverse order. + * + * The iteration is terminated early if the `iteratee` function returns `false`. + * + * @template T - The type of the object + * @param object - The object to iterate over + * @param iteratee - The function invoked per iteration + * @returns Returns the object + * + * @example + * // Iterate over all properties including inherited ones + * const obj = { a: 1, b: 2 }; + * forInRight(obj, (value, key) => { + * console.log(key, value); + * }); + * // Output: 'b' 2, 'a' 1 + * + * // Early termination + * forInRight(obj, (value, key) => { + * console.log(key, value); + * return key !== 'a'; // stop after 'a' + * }); + * // Output: 'b' 2 + */ +declare function forInRight(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T; +/** + * Iterates over an object in reverse order and invokes the `iteratee` function for each property. + * + * Iterates over string keyed properties including inherited properties in reverse order. + * + * The iteration is terminated early if the `iteratee` function returns `false`. + * + * @template T - The type of the object + * @param object - The object to iterate over + * @param iteratee - The function invoked per iteration + * @returns Returns the object + * + * @example + * // Iterate over all properties including inherited ones + * const obj = { a: 1, b: 2 }; + * forInRight(obj, (value, key) => { + * console.log(key, value); + * }); + * // Output: 'b' 2, 'a' 1 + * + * // Early termination + * forInRight(obj, (value, key) => { + * console.log(key, value); + * return key !== 'a'; // stop after 'a' + * }); + * // Output: 'b' 2 + */ +declare function forInRight(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined; +//#endregion +export { forInRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/forInRight.d.ts b/node_modules/es-toolkit/dist/compat/object/forInRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..43c401cf1cba7706329a39dbe1e80701e2e3155c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forInRight.d.ts @@ -0,0 +1,59 @@ +//#region src/compat/object/forInRight.d.ts +/** + * Iterates over an object in reverse order and invokes the `iteratee` function for each property. + * + * Iterates over string keyed properties including inherited properties in reverse order. + * + * The iteration is terminated early if the `iteratee` function returns `false`. + * + * @template T - The type of the object + * @param object - The object to iterate over + * @param iteratee - The function invoked per iteration + * @returns Returns the object + * + * @example + * // Iterate over all properties including inherited ones + * const obj = { a: 1, b: 2 }; + * forInRight(obj, (value, key) => { + * console.log(key, value); + * }); + * // Output: 'b' 2, 'a' 1 + * + * // Early termination + * forInRight(obj, (value, key) => { + * console.log(key, value); + * return key !== 'a'; // stop after 'a' + * }); + * // Output: 'b' 2 + */ +declare function forInRight(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T; +/** + * Iterates over an object in reverse order and invokes the `iteratee` function for each property. + * + * Iterates over string keyed properties including inherited properties in reverse order. + * + * The iteration is terminated early if the `iteratee` function returns `false`. + * + * @template T - The type of the object + * @param object - The object to iterate over + * @param iteratee - The function invoked per iteration + * @returns Returns the object + * + * @example + * // Iterate over all properties including inherited ones + * const obj = { a: 1, b: 2 }; + * forInRight(obj, (value, key) => { + * console.log(key, value); + * }); + * // Output: 'b' 2, 'a' 1 + * + * // Early termination + * forInRight(obj, (value, key) => { + * console.log(key, value); + * return key !== 'a'; // stop after 'a' + * }); + * // Output: 'b' 2 + */ +declare function forInRight(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined; +//#endregion +export { forInRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/forInRight.js b/node_modules/es-toolkit/dist/compat/object/forInRight.js new file mode 100644 index 0000000000000000000000000000000000000000..dbeb757f9e58624e80882095a219d528973188a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forInRight.js @@ -0,0 +1,41 @@ +const require_identity = require("../../function/identity.js"); +//#region src/compat/object/forInRight.ts +/** +* Iterates over an object in reverse order and invokes the `iteratee` function for each property. +* +* Iterates over string keyed properties including inherited properties in reverse order. +* +* The iteration is terminated early if the `iteratee` function returns `false`. +* +* @template T - The type of the object +* @param object - The object to iterate over +* @param iteratee - The function invoked per iteration +* @returns Returns the object +* +* @example +* // Iterate over all properties including inherited ones +* const obj = { a: 1, b: 2 }; +* forInRight(obj, (value, key) => { +* console.log(key, value); +* }); +* // Output: 'b' 2, 'a' 1 +* +* // Early termination +* forInRight(obj, (value, key) => { +* console.log(key, value); +* return key !== 'a'; // stop after 'a' +* }); +* // Output: 'b' 2 +*/ +function forInRight(object, iteratee = require_identity.identity) { + if (object == null) return object; + const keys = []; + for (const key in object) keys.push(key); + for (let i = keys.length - 1; i >= 0; i--) { + const key = keys[i]; + if (iteratee(object[key], key, object) === false) break; + } + return object; +} +//#endregion +exports.forInRight = forInRight; diff --git a/node_modules/es-toolkit/dist/compat/object/forInRight.mjs b/node_modules/es-toolkit/dist/compat/object/forInRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..430888da04bd63dda60141f91e9e2d9249a011dc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forInRight.mjs @@ -0,0 +1,41 @@ +import { identity } from "../../function/identity.mjs"; +//#region src/compat/object/forInRight.ts +/** +* Iterates over an object in reverse order and invokes the `iteratee` function for each property. +* +* Iterates over string keyed properties including inherited properties in reverse order. +* +* The iteration is terminated early if the `iteratee` function returns `false`. +* +* @template T - The type of the object +* @param object - The object to iterate over +* @param iteratee - The function invoked per iteration +* @returns Returns the object +* +* @example +* // Iterate over all properties including inherited ones +* const obj = { a: 1, b: 2 }; +* forInRight(obj, (value, key) => { +* console.log(key, value); +* }); +* // Output: 'b' 2, 'a' 1 +* +* // Early termination +* forInRight(obj, (value, key) => { +* console.log(key, value); +* return key !== 'a'; // stop after 'a' +* }); +* // Output: 'b' 2 +*/ +function forInRight(object, iteratee = identity) { + if (object == null) return object; + const keys = []; + for (const key in object) keys.push(key); + for (let i = keys.length - 1; i >= 0; i--) { + const key = keys[i]; + if (iteratee(object[key], key, object) === false) break; + } + return object; +} +//#endregion +export { forInRight }; diff --git a/node_modules/es-toolkit/dist/compat/object/forOwn.d.mts b/node_modules/es-toolkit/dist/compat/object/forOwn.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7d1c88d4f7943af9ba3d3ed44731cdbd0c828b45 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forOwn.d.mts @@ -0,0 +1,55 @@ +//#region src/compat/object/forOwn.d.ts +/** + * Iterates over an object's properties and calls the `iteratee` function for each property. + * + * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. + * + * The `iteratee` function can terminate the iteration early by returning `false`. + * + * @template T - The type of the object. + * @param object The object to iterate over. + * @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. + * @return {T} Returns object. + * + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * forOwn(new Foo(), function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +declare function forOwn(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T; +/** + * Iterates over an object's properties and calls the `iteratee` function for each property. + * + * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. + * + * The `iteratee` function can terminate the iteration early by returning `false`. + * + * @template T - The type of the object. + * @param object The object to iterate over. + * @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. + * @return {T | null | undefined} Returns object. + * + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * forOwn(new Foo(), function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +declare function forOwn(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined; +//#endregion +export { forOwn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/forOwn.d.ts b/node_modules/es-toolkit/dist/compat/object/forOwn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d1c88d4f7943af9ba3d3ed44731cdbd0c828b45 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forOwn.d.ts @@ -0,0 +1,55 @@ +//#region src/compat/object/forOwn.d.ts +/** + * Iterates over an object's properties and calls the `iteratee` function for each property. + * + * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. + * + * The `iteratee` function can terminate the iteration early by returning `false`. + * + * @template T - The type of the object. + * @param object The object to iterate over. + * @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. + * @return {T} Returns object. + * + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * forOwn(new Foo(), function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +declare function forOwn(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T; +/** + * Iterates over an object's properties and calls the `iteratee` function for each property. + * + * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. + * + * The `iteratee` function can terminate the iteration early by returning `false`. + * + * @template T - The type of the object. + * @param object The object to iterate over. + * @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. + * @return {T | null | undefined} Returns object. + * + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * forOwn(new Foo(), function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +declare function forOwn(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined; +//#endregion +export { forOwn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/forOwn.js b/node_modules/es-toolkit/dist/compat/object/forOwn.js new file mode 100644 index 0000000000000000000000000000000000000000..f32407e7c108a764061fb719bf98bfbc0cbb14c5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forOwn.js @@ -0,0 +1,40 @@ +const require_identity = require("../../function/identity.js"); +const require_keys = require("./keys.js"); +//#region src/compat/object/forOwn.ts +/** +* Iterates over an object's properties and calls the `iteratee` function for each property. +* +* It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. +* +* The `iteratee` function can terminate the iteration early by returning `false`. +* +* @template T - The type of the object. +* @param object The object to iterate over. +* @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. +* @return {T | null | undefined} Returns object. +* +* @example +* function Foo() { +* this.a = 1; +* this.b = 2; +* } +* +* Foo.prototype.c = 3; +* +* forOwn(new Foo(), function(value, key) { +* console.log(key); +* }); +* // => Logs 'a' then 'b' (iteration order is not guaranteed). +*/ +function forOwn(object, iteratee = require_identity.identity) { + if (object == null) return object; + const iterable = Object(object); + const keys$1 = require_keys.keys(object); + for (let i = 0; i < keys$1.length; ++i) { + const key = keys$1[i]; + if (iteratee(iterable[key], key, iterable) === false) break; + } + return object; +} +//#endregion +exports.forOwn = forOwn; diff --git a/node_modules/es-toolkit/dist/compat/object/forOwn.mjs b/node_modules/es-toolkit/dist/compat/object/forOwn.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e3b0e88247cc4b573f8e38cdf649e6c255e88b7c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forOwn.mjs @@ -0,0 +1,40 @@ +import { identity } from "../../function/identity.mjs"; +import { keys } from "./keys.mjs"; +//#region src/compat/object/forOwn.ts +/** +* Iterates over an object's properties and calls the `iteratee` function for each property. +* +* It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. +* +* The `iteratee` function can terminate the iteration early by returning `false`. +* +* @template T - The type of the object. +* @param object The object to iterate over. +* @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. +* @return {T | null | undefined} Returns object. +* +* @example +* function Foo() { +* this.a = 1; +* this.b = 2; +* } +* +* Foo.prototype.c = 3; +* +* forOwn(new Foo(), function(value, key) { +* console.log(key); +* }); +* // => Logs 'a' then 'b' (iteration order is not guaranteed). +*/ +function forOwn(object, iteratee = identity) { + if (object == null) return object; + const iterable = Object(object); + const keys$1 = keys(object); + for (let i = 0; i < keys$1.length; ++i) { + const key = keys$1[i]; + if (iteratee(iterable[key], key, iterable) === false) break; + } + return object; +} +//#endregion +export { forOwn }; diff --git a/node_modules/es-toolkit/dist/compat/object/forOwnRight.d.mts b/node_modules/es-toolkit/dist/compat/object/forOwnRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..dd98d247b5cd7c05c1d61e7e13eefe5ae42fb35e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forOwnRight.d.mts @@ -0,0 +1,55 @@ +//#region src/compat/object/forOwnRight.d.ts +/** + * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property. + * + * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. + * + * The `iteratee` function can terminate the iteration early by returning `false`. + * + * @template T - The type of the object. + * @param object The object to iterate over. + * @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. + * @return {T} Returns object. + * + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * forOwnRight(new Foo(), function(value, key) { + * console.log(key); + * }); + * // => Logs 'b' then 'a' (iteration order is not guaranteed). + */ +declare function forOwnRight(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T; +/** + * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property. + * + * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. + * + * The `iteratee` function can terminate the iteration early by returning `false`. + * + * @template T - The type of the object. + * @param object The object to iterate over. + * @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. + * @return {T | null | undefined} Returns object. + * + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * forOwnRight(new Foo(), function(value, key) { + * console.log(key); + * }); + * // => Logs 'b' then 'a' (iteration order is not guaranteed). + */ +declare function forOwnRight(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined; +//#endregion +export { forOwnRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/forOwnRight.d.ts b/node_modules/es-toolkit/dist/compat/object/forOwnRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dd98d247b5cd7c05c1d61e7e13eefe5ae42fb35e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forOwnRight.d.ts @@ -0,0 +1,55 @@ +//#region src/compat/object/forOwnRight.d.ts +/** + * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property. + * + * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. + * + * The `iteratee` function can terminate the iteration early by returning `false`. + * + * @template T - The type of the object. + * @param object The object to iterate over. + * @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. + * @return {T} Returns object. + * + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * forOwnRight(new Foo(), function(value, key) { + * console.log(key); + * }); + * // => Logs 'b' then 'a' (iteration order is not guaranteed). + */ +declare function forOwnRight(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T; +/** + * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property. + * + * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. + * + * The `iteratee` function can terminate the iteration early by returning `false`. + * + * @template T - The type of the object. + * @param object The object to iterate over. + * @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. + * @return {T | null | undefined} Returns object. + * + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * forOwnRight(new Foo(), function(value, key) { + * console.log(key); + * }); + * // => Logs 'b' then 'a' (iteration order is not guaranteed). + */ +declare function forOwnRight(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined; +//#endregion +export { forOwnRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/forOwnRight.js b/node_modules/es-toolkit/dist/compat/object/forOwnRight.js new file mode 100644 index 0000000000000000000000000000000000000000..2af4418f68b66925b3a90313b5c65a8ee26eb248 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forOwnRight.js @@ -0,0 +1,40 @@ +const require_identity = require("../../function/identity.js"); +const require_keys = require("./keys.js"); +//#region src/compat/object/forOwnRight.ts +/** +* Iterates over an object's properties in reverse order and calls the `iteratee` function for each property. +* +* It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. +* +* The `iteratee` function can terminate the iteration early by returning `false`. +* +* @template T - The type of the object. +* @param object The object to iterate over. +* @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. +* @return {T | null | undefined} Returns object. +* +* @example +* function Foo() { +* this.a = 1; +* this.b = 2; +* } +* +* Foo.prototype.c = 3; +* +* forOwnRight(new Foo(), function(value, key) { +* console.log(key); +* }); +* // => Logs 'b' then 'a' (iteration order is not guaranteed). +*/ +function forOwnRight(object, iteratee = require_identity.identity) { + if (object == null) return object; + const iterable = Object(object); + const keys$1 = require_keys.keys(object); + for (let i = keys$1.length - 1; i >= 0; --i) { + const key = keys$1[i]; + if (iteratee(iterable[key], key, iterable) === false) break; + } + return object; +} +//#endregion +exports.forOwnRight = forOwnRight; diff --git a/node_modules/es-toolkit/dist/compat/object/forOwnRight.mjs b/node_modules/es-toolkit/dist/compat/object/forOwnRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9944aeff38522556d09029099e4f84173a686e68 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/forOwnRight.mjs @@ -0,0 +1,40 @@ +import { identity } from "../../function/identity.mjs"; +import { keys } from "./keys.mjs"; +//#region src/compat/object/forOwnRight.ts +/** +* Iterates over an object's properties in reverse order and calls the `iteratee` function for each property. +* +* It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys. +* +* The `iteratee` function can terminate the iteration early by returning `false`. +* +* @template T - The type of the object. +* @param object The object to iterate over. +* @param [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used. +* @return {T | null | undefined} Returns object. +* +* @example +* function Foo() { +* this.a = 1; +* this.b = 2; +* } +* +* Foo.prototype.c = 3; +* +* forOwnRight(new Foo(), function(value, key) { +* console.log(key); +* }); +* // => Logs 'b' then 'a' (iteration order is not guaranteed). +*/ +function forOwnRight(object, iteratee = identity) { + if (object == null) return object; + const iterable = Object(object); + const keys$1 = keys(object); + for (let i = keys$1.length - 1; i >= 0; --i) { + const key = keys$1[i]; + if (iteratee(iterable[key], key, iterable) === false) break; + } + return object; +} +//#endregion +export { forOwnRight }; diff --git a/node_modules/es-toolkit/dist/compat/object/fromPairs.d.mts b/node_modules/es-toolkit/dist/compat/object/fromPairs.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4f499cef3021353ebc2017ea01044d59d483a714 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/fromPairs.d.mts @@ -0,0 +1,29 @@ +//#region src/compat/object/fromPairs.d.ts +type PropertyName = string | number | symbol; +/** + * Converts an array of key-value pairs into an object. + * + * @template T - The type of the values. + * @param pairs - An array of key-value pairs. + * @returns An object where keys are strings and values are of type T. + * + * @example + * const pairs = [['a', 1], ['b', 2]]; + * const result = fromPairs(pairs); + * // => { a: 1, b: 2 } + */ +declare function fromPairs(pairs: ArrayLike<[PropertyName, T]> | null | undefined): Record; +/** + * Converts an array of key-value pairs into an object. + * + * @param pairs - An array of key-value pairs. + * @returns An object where keys are strings and values can be any type. + * + * @example + * const pairs = [['a', 1], ['b', 'hello']]; + * const result = fromPairs(pairs); + * // => { a: 1, b: 'hello' } + */ +declare function fromPairs(pairs: ArrayLike | null | undefined): Record; +//#endregion +export { fromPairs }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/fromPairs.d.ts b/node_modules/es-toolkit/dist/compat/object/fromPairs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f499cef3021353ebc2017ea01044d59d483a714 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/fromPairs.d.ts @@ -0,0 +1,29 @@ +//#region src/compat/object/fromPairs.d.ts +type PropertyName = string | number | symbol; +/** + * Converts an array of key-value pairs into an object. + * + * @template T - The type of the values. + * @param pairs - An array of key-value pairs. + * @returns An object where keys are strings and values are of type T. + * + * @example + * const pairs = [['a', 1], ['b', 2]]; + * const result = fromPairs(pairs); + * // => { a: 1, b: 2 } + */ +declare function fromPairs(pairs: ArrayLike<[PropertyName, T]> | null | undefined): Record; +/** + * Converts an array of key-value pairs into an object. + * + * @param pairs - An array of key-value pairs. + * @returns An object where keys are strings and values can be any type. + * + * @example + * const pairs = [['a', 1], ['b', 'hello']]; + * const result = fromPairs(pairs); + * // => { a: 1, b: 'hello' } + */ +declare function fromPairs(pairs: ArrayLike | null | undefined): Record; +//#endregion +export { fromPairs }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/fromPairs.js b/node_modules/es-toolkit/dist/compat/object/fromPairs.js new file mode 100644 index 0000000000000000000000000000000000000000..e6a8af4182c66013e9b4db974ed7270b93cbba0d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/fromPairs.js @@ -0,0 +1,27 @@ +const require_isArrayLike = require("../predicate/isArrayLike.js"); +//#region src/compat/object/fromPairs.ts +/** +* Converts an array of key-value pairs into an object. +* +* @template T - The type of the keys in the resulting object. It must extend `PropertyKey`. +* @template U - The type of the values in the resulting object. +* +* @param pairs - An array of key-value pairs where each key is a `PropertyKey` and each value is of type `U`. +* @returns An object where the keys are of type `T` and the values are of type `U`. +* +* @example +* const pairs = [['a', 1], ['b', 2]]; +* const result = fromPairs(pairs); +* // result will be: { a: 1, b: 2 } +*/ +function fromPairs(pairs) { + if (!require_isArrayLike.isArrayLike(pairs)) return {}; + const result = {}; + for (let i = 0; i < pairs.length; i++) { + const [key, value] = pairs[i]; + result[key] = value; + } + return result; +} +//#endregion +exports.fromPairs = fromPairs; diff --git a/node_modules/es-toolkit/dist/compat/object/fromPairs.mjs b/node_modules/es-toolkit/dist/compat/object/fromPairs.mjs new file mode 100644 index 0000000000000000000000000000000000000000..43ff150ff2c4f23bebdaf8434639473e83c5bf3d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/fromPairs.mjs @@ -0,0 +1,27 @@ +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +//#region src/compat/object/fromPairs.ts +/** +* Converts an array of key-value pairs into an object. +* +* @template T - The type of the keys in the resulting object. It must extend `PropertyKey`. +* @template U - The type of the values in the resulting object. +* +* @param pairs - An array of key-value pairs where each key is a `PropertyKey` and each value is of type `U`. +* @returns An object where the keys are of type `T` and the values are of type `U`. +* +* @example +* const pairs = [['a', 1], ['b', 2]]; +* const result = fromPairs(pairs); +* // result will be: { a: 1, b: 2 } +*/ +function fromPairs(pairs) { + if (!isArrayLike(pairs)) return {}; + const result = {}; + for (let i = 0; i < pairs.length; i++) { + const [key, value] = pairs[i]; + result[key] = value; + } + return result; +} +//#endregion +export { fromPairs }; diff --git a/node_modules/es-toolkit/dist/compat/object/functions.d.mts b/node_modules/es-toolkit/dist/compat/object/functions.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9267e237fc5b765e19a315aff840d990a67c65ca --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/functions.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/object/functions.d.ts +/** + * Creates an array of property names from an object where the property values are functions. + * + * @param object - The object to inspect. + * @returns An array of function property names. + * + * @example + * function Foo() { + * this.a = () => 'a'; + * this.b = () => 'b'; + * } + * + * Foo.prototype.c = () => 'c'; + * + * functions(new Foo); + * // => ['a', 'b'] + */ +declare function functions(object: any): string[]; +//#endregion +export { functions }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/functions.d.ts b/node_modules/es-toolkit/dist/compat/object/functions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9267e237fc5b765e19a315aff840d990a67c65ca --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/functions.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/object/functions.d.ts +/** + * Creates an array of property names from an object where the property values are functions. + * + * @param object - The object to inspect. + * @returns An array of function property names. + * + * @example + * function Foo() { + * this.a = () => 'a'; + * this.b = () => 'b'; + * } + * + * Foo.prototype.c = () => 'c'; + * + * functions(new Foo); + * // => ['a', 'b'] + */ +declare function functions(object: any): string[]; +//#endregion +export { functions }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/functions.js b/node_modules/es-toolkit/dist/compat/object/functions.js new file mode 100644 index 0000000000000000000000000000000000000000..974cf52cf232662242640d9c7718aa15dd43b834 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/functions.js @@ -0,0 +1,29 @@ +const require_keys = require("./keys.js"); +//#region src/compat/object/functions.ts +/** +* Creates an array of property names from an object where the property values are functions. +* +* Only checks for own properties with string keys. Inherited properties or +* properties with Symbol keys are not included. +* +* @param object The object to inspect. +* @returns An array of function property names. +* +* @example +* +* function Foo() { +* this.a = () => 'a' +* this.b = () => 'b' +* } +* +* Foo.prototype.c = () => 'c' +* +* functions(new Foo) +* // => ['a', 'b'] +*/ +function functions(object) { + if (object == null) return []; + return require_keys.keys(object).filter((key) => typeof object[key] === "function"); +} +//#endregion +exports.functions = functions; diff --git a/node_modules/es-toolkit/dist/compat/object/functions.mjs b/node_modules/es-toolkit/dist/compat/object/functions.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d6ab61daf892db144939b52ce3409dee38ec7ce5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/functions.mjs @@ -0,0 +1,29 @@ +import { keys } from "./keys.mjs"; +//#region src/compat/object/functions.ts +/** +* Creates an array of property names from an object where the property values are functions. +* +* Only checks for own properties with string keys. Inherited properties or +* properties with Symbol keys are not included. +* +* @param object The object to inspect. +* @returns An array of function property names. +* +* @example +* +* function Foo() { +* this.a = () => 'a' +* this.b = () => 'b' +* } +* +* Foo.prototype.c = () => 'c' +* +* functions(new Foo) +* // => ['a', 'b'] +*/ +function functions(object) { + if (object == null) return []; + return keys(object).filter((key) => typeof object[key] === "function"); +} +//#endregion +export { functions }; diff --git a/node_modules/es-toolkit/dist/compat/object/functionsIn.d.mts b/node_modules/es-toolkit/dist/compat/object/functionsIn.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ea7da91da0f09ae4eca71b01c6551e0f885e6186 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/functionsIn.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/object/functionsIn.d.ts +/** + * Returns an array of property names whose values are functions, including inherited properties. + * + * @param object The object to inspect. + * @returns Returns the function names. + * @example + * + * function Foo() { + * this.a = function() { return 'a'; }; + * this.b = function() { return 'b'; }; + * } + * + * Foo.prototype.c = function() { return 'c'; }; + * + * functionsIn(new Foo); + * // => ['a', 'b', 'c'] + */ +declare function functionsIn(object: any): string[]; +//#endregion +export { functionsIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/functionsIn.d.ts b/node_modules/es-toolkit/dist/compat/object/functionsIn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea7da91da0f09ae4eca71b01c6551e0f885e6186 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/functionsIn.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/object/functionsIn.d.ts +/** + * Returns an array of property names whose values are functions, including inherited properties. + * + * @param object The object to inspect. + * @returns Returns the function names. + * @example + * + * function Foo() { + * this.a = function() { return 'a'; }; + * this.b = function() { return 'b'; }; + * } + * + * Foo.prototype.c = function() { return 'c'; }; + * + * functionsIn(new Foo); + * // => ['a', 'b', 'c'] + */ +declare function functionsIn(object: any): string[]; +//#endregion +export { functionsIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/functionsIn.js b/node_modules/es-toolkit/dist/compat/object/functionsIn.js new file mode 100644 index 0000000000000000000000000000000000000000..e6a94b2310366802079780b5791df2f9bddd409d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/functionsIn.js @@ -0,0 +1,27 @@ +const require_isFunction = require("../../predicate/isFunction.js"); +//#region src/compat/object/functionsIn.ts +/** +* Returns an array of property names whose values are functions, including inherited properties. +* +* @param object The object to inspect. +* @returns Returns the function names. +* @example +* +* function Foo() { +* this.a = function() { return 'a'; }; +* this.b = function() { return 'b'; }; +* } +* +* Foo.prototype.c = function() { return 'c'; }; +* +* functionsIn(new Foo); +* // => ['a', 'b', 'c'] +*/ +function functionsIn(object) { + if (object == null) return []; + const result = []; + for (const key in object) if (require_isFunction.isFunction(object[key])) result.push(key); + return result; +} +//#endregion +exports.functionsIn = functionsIn; diff --git a/node_modules/es-toolkit/dist/compat/object/functionsIn.mjs b/node_modules/es-toolkit/dist/compat/object/functionsIn.mjs new file mode 100644 index 0000000000000000000000000000000000000000..70d3f6434b3b9424121397ed44ba4c8009c33b4c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/functionsIn.mjs @@ -0,0 +1,27 @@ +import { isFunction } from "../../predicate/isFunction.mjs"; +//#region src/compat/object/functionsIn.ts +/** +* Returns an array of property names whose values are functions, including inherited properties. +* +* @param object The object to inspect. +* @returns Returns the function names. +* @example +* +* function Foo() { +* this.a = function() { return 'a'; }; +* this.b = function() { return 'b'; }; +* } +* +* Foo.prototype.c = function() { return 'c'; }; +* +* functionsIn(new Foo); +* // => ['a', 'b', 'c'] +*/ +function functionsIn(object) { + if (object == null) return []; + const result = []; + for (const key in object) if (isFunction(object[key])) result.push(key); + return result; +} +//#endregion +export { functionsIn }; diff --git a/node_modules/es-toolkit/dist/compat/object/get.d.mts b/node_modules/es-toolkit/dist/compat/object/get.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..24e67d37b21830c0e9b241bfb7c2c54fae174c5a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/get.d.mts @@ -0,0 +1,328 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; +import { GetFieldType } from "../_internal/GetFieldType.mjs"; + +//#region src/compat/object/get.d.ts +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * get(object, 'a[0].b.c'); + * // => 3 + */ +declare function get(object: TObject, path: TKey | [TKey]): TObject[TKey]; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * get(object, 'a[0].b.c'); + * // => 3 + */ +declare function get(object: TObject | null | undefined, path: TKey | [TKey]): TObject[TKey] | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * get(object, 'a[0].b.c', 'default'); + * // => 3 + */ +declare function get(object: TObject | null | undefined, path: TKey | [TKey], defaultValue: TDefault): Exclude | TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': 2 } }; + * get(object, ['a', 'b']); + * // => 2 + */ +declare function get(object: TObject, path: [TKey1, TKey2]): TObject[TKey1][TKey2]; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': 2 } }; + * get(object, ['a', 'b']); + * // => 2 + */ +declare function get>(object: TObject | null | undefined, path: [TKey1, TKey2]): NonNullable[TKey2] | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': 2 } }; + * get(object, ['a', 'b'], 'default'); + * // => 2 + */ +declare function get, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2], defaultValue: TDefault): Exclude[TKey2], undefined> | TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': 3 } } }; + * get(object, ['a', 'b', 'c']); + * // => 3 + */ +declare function get(object: TObject, path: [TKey1, TKey2, TKey3]): TObject[TKey1][TKey2][TKey3]; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': 3 } } }; + * get(object, ['a', 'b', 'c']); + * // => 3 + */ +declare function get, TKey3 extends keyof NonNullable[TKey2]>>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3]): NonNullable[TKey2]>[TKey3] | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': 3 } } }; + * get(object, ['a', 'b', 'c'], 'default'); + * // => 3 + */ +declare function get, TKey3 extends keyof NonNullable[TKey2]>, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3], defaultValue: TDefault): Exclude[TKey2]>[TKey3], undefined> | TDefault; +/** + * Gets the value at path of object. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @template TKey4 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': { 'd': 4 } } } }; + * get(object, ['a', 'b', 'c', 'd']); + * // => 4 + */ +declare function get(object: TObject, path: [TKey1, TKey2, TKey3, TKey4]): TObject[TKey1][TKey2][TKey3][TKey4]; +/** + * Gets the value at path of object. If the resolved value is undefined, undefined is returned. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @template TKey4 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': { 'd': 4 } } } }; + * get(object, ['a', 'b', 'c', 'd']); + * // => 4 + */ +declare function get, TKey3 extends keyof NonNullable[TKey2]>, TKey4 extends keyof NonNullable[TKey2]>[TKey3]>>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3, TKey4]): NonNullable[TKey2]>[TKey3]>[TKey4] | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @template TKey4 + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': { 'd': 4 } } } }; + * get(object, ['a', 'b', 'c', 'd'], 'default'); + * // => 4 + */ +declare function get, TKey3 extends keyof NonNullable[TKey2]>, TKey4 extends keyof NonNullable[TKey2]>[TKey3]>, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3, TKey4], defaultValue: TDefault): Exclude[TKey2]>[TKey3]>[TKey4], undefined> | TDefault; +/** + * Gets the value at path of object. + * + * @template T + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 0: 'a', 1: 'b', 2: 'c' }; + * get(object, 1); + * // => 'b' + */ +declare function get(object: Record, path: number): T; +/** + * Gets the value at path of object. If the resolved value is undefined, undefined is returned. + * + * @template T + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 0: 'a', 1: 'b', 2: 'c' }; + * get(object, 1); + * // => 'b' + */ +declare function get(object: Record | null | undefined, path: number): T | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template T + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 0: 'a', 1: 'b', 2: 'c' }; + * get(object, 1, 'default'); + * // => 'b' + */ +declare function get(object: Record | null | undefined, path: number, defaultValue: TDefault): T | TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the default value. + * + * @example + * get(null, 'a.b.c', 'default'); + * // => 'default' + */ +declare function get(object: null | undefined, path: PropertyPath, defaultValue: TDefault): TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, undefined is returned. + * + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns undefined. + * + * @example + * get(null, 'a.b.c'); + * // => undefined + */ +declare function get(object: null | undefined, path: PropertyPath): undefined; +/** + * Gets the value at path of object using type-safe path. + * + * @template TObject + * @template TPath + * @param data - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { a: { b: { c: 1 } } }; + * get(object, 'a.b.c'); + * // => 1 + */ +declare function get(data: TObject, path: TPath): string extends TPath ? any : GetFieldType; +/** + * Gets the value at path of object using type-safe path. If the resolved value is undefined, the defaultValue is returned. + * + * @template TObject + * @template TPath + * @template TDefault + * @param data - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { a: { b: { c: 1 } } }; + * get(object, 'a.b.d', 'default'); + * // => 'default' + */ +declare function get>(data: TObject, path: TPath, defaultValue: TDefault): Exclude, null | undefined> | TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned. + * + * @param object - The object to query. + * @param path - The path of the property to get. + * @param [defaultValue] - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { a: { b: { c: 1 } } }; + * get(object, 'a.b.c', 'default'); + * // => 1 + */ +declare function get(object: any, path: PropertyPath, defaultValue?: any): any; +//#endregion +export { get }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/get.d.ts b/node_modules/es-toolkit/dist/compat/object/get.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0826829e2154d794daff3e0beefb2c4b82b056c5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/get.d.ts @@ -0,0 +1,328 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; +import { GetFieldType } from "../_internal/GetFieldType.js"; + +//#region src/compat/object/get.d.ts +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * get(object, 'a[0].b.c'); + * // => 3 + */ +declare function get(object: TObject, path: TKey | [TKey]): TObject[TKey]; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * get(object, 'a[0].b.c'); + * // => 3 + */ +declare function get(object: TObject | null | undefined, path: TKey | [TKey]): TObject[TKey] | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * get(object, 'a[0].b.c', 'default'); + * // => 3 + */ +declare function get(object: TObject | null | undefined, path: TKey | [TKey], defaultValue: TDefault): Exclude | TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': 2 } }; + * get(object, ['a', 'b']); + * // => 2 + */ +declare function get(object: TObject, path: [TKey1, TKey2]): TObject[TKey1][TKey2]; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': 2 } }; + * get(object, ['a', 'b']); + * // => 2 + */ +declare function get>(object: TObject | null | undefined, path: [TKey1, TKey2]): NonNullable[TKey2] | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': 2 } }; + * get(object, ['a', 'b'], 'default'); + * // => 2 + */ +declare function get, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2], defaultValue: TDefault): Exclude[TKey2], undefined> | TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': 3 } } }; + * get(object, ['a', 'b', 'c']); + * // => 3 + */ +declare function get(object: TObject, path: [TKey1, TKey2, TKey3]): TObject[TKey1][TKey2][TKey3]; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': 3 } } }; + * get(object, ['a', 'b', 'c']); + * // => 3 + */ +declare function get, TKey3 extends keyof NonNullable[TKey2]>>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3]): NonNullable[TKey2]>[TKey3] | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': 3 } } }; + * get(object, ['a', 'b', 'c'], 'default'); + * // => 3 + */ +declare function get, TKey3 extends keyof NonNullable[TKey2]>, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3], defaultValue: TDefault): Exclude[TKey2]>[TKey3], undefined> | TDefault; +/** + * Gets the value at path of object. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @template TKey4 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': { 'd': 4 } } } }; + * get(object, ['a', 'b', 'c', 'd']); + * // => 4 + */ +declare function get(object: TObject, path: [TKey1, TKey2, TKey3, TKey4]): TObject[TKey1][TKey2][TKey3][TKey4]; +/** + * Gets the value at path of object. If the resolved value is undefined, undefined is returned. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @template TKey4 + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': { 'd': 4 } } } }; + * get(object, ['a', 'b', 'c', 'd']); + * // => 4 + */ +declare function get, TKey3 extends keyof NonNullable[TKey2]>, TKey4 extends keyof NonNullable[TKey2]>[TKey3]>>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3, TKey4]): NonNullable[TKey2]>[TKey3]>[TKey4] | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TObject + * @template TKey1 + * @template TKey2 + * @template TKey3 + * @template TKey4 + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 'a': { 'b': { 'c': { 'd': 4 } } } }; + * get(object, ['a', 'b', 'c', 'd'], 'default'); + * // => 4 + */ +declare function get, TKey3 extends keyof NonNullable[TKey2]>, TKey4 extends keyof NonNullable[TKey2]>[TKey3]>, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3, TKey4], defaultValue: TDefault): Exclude[TKey2]>[TKey3]>[TKey4], undefined> | TDefault; +/** + * Gets the value at path of object. + * + * @template T + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 0: 'a', 1: 'b', 2: 'c' }; + * get(object, 1); + * // => 'b' + */ +declare function get(object: Record, path: number): T; +/** + * Gets the value at path of object. If the resolved value is undefined, undefined is returned. + * + * @template T + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { 0: 'a', 1: 'b', 2: 'c' }; + * get(object, 1); + * // => 'b' + */ +declare function get(object: Record | null | undefined, path: number): T | undefined; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template T + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { 0: 'a', 1: 'b', 2: 'c' }; + * get(object, 1, 'default'); + * // => 'b' + */ +declare function get(object: Record | null | undefined, path: number, defaultValue: TDefault): T | TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. + * + * @template TDefault + * @param object - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the default value. + * + * @example + * get(null, 'a.b.c', 'default'); + * // => 'default' + */ +declare function get(object: null | undefined, path: PropertyPath, defaultValue: TDefault): TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, undefined is returned. + * + * @param object - The object to query. + * @param path - The path of the property to get. + * @returns Returns undefined. + * + * @example + * get(null, 'a.b.c'); + * // => undefined + */ +declare function get(object: null | undefined, path: PropertyPath): undefined; +/** + * Gets the value at path of object using type-safe path. + * + * @template TObject + * @template TPath + * @param data - The object to query. + * @param path - The path of the property to get. + * @returns Returns the resolved value. + * + * @example + * const object = { a: { b: { c: 1 } } }; + * get(object, 'a.b.c'); + * // => 1 + */ +declare function get(data: TObject, path: TPath): string extends TPath ? any : GetFieldType; +/** + * Gets the value at path of object using type-safe path. If the resolved value is undefined, the defaultValue is returned. + * + * @template TObject + * @template TPath + * @template TDefault + * @param data - The object to query. + * @param path - The path of the property to get. + * @param defaultValue - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { a: { b: { c: 1 } } }; + * get(object, 'a.b.d', 'default'); + * // => 'default' + */ +declare function get>(data: TObject, path: TPath, defaultValue: TDefault): Exclude, null | undefined> | TDefault; +/** + * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned. + * + * @param object - The object to query. + * @param path - The path of the property to get. + * @param [defaultValue] - The value returned if the resolved value is undefined. + * @returns Returns the resolved value. + * + * @example + * const object = { a: { b: { c: 1 } } }; + * get(object, 'a.b.c', 'default'); + * // => 1 + */ +declare function get(object: any, path: PropertyPath, defaultValue?: any): any; +//#endregion +export { get }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/get.js b/node_modules/es-toolkit/dist/compat/object/get.js new file mode 100644 index 0000000000000000000000000000000000000000..989bee8db5c315b5e35548d2bcc3ccd9fd73b6e2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/get.js @@ -0,0 +1,65 @@ +const require_isUnsafeProperty = require("../../_internal/isUnsafeProperty.js"); +const require_isDeepKey = require("../_internal/isDeepKey.js"); +const require_toKey = require("../_internal/toKey.js"); +const require_toPath = require("../util/toPath.js"); +//#region src/compat/object/get.ts +/** +* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. +* +* @param object - The object to query. +* @param path - The path of the property to get. +* @param [defaultValue] - The value returned if the resolved value is undefined. +* @returns Returns the resolved value. +* +* @example +* const object = { a: { b: { c: 1 } } }; +* get(object, 'a.b.c'); +* // => 1 +* +* get(object, ['a', 'b', 'c']); +* // => 1 +* +* get(object, 'a.b.d', 'default'); +* // => 'default' +*/ +function get(object, path, defaultValue) { + if (object == null) return defaultValue; + switch (typeof path) { + case "string": { + if (require_isUnsafeProperty.isUnsafeProperty(path)) return defaultValue; + const result = object[path]; + if (result === void 0) if (require_isDeepKey.isDeepKey(path) && !Object.hasOwn(object, path)) return get(object, require_toPath.toPath(path), defaultValue); + else return defaultValue; + return result; + } + case "number": + case "symbol": { + if (typeof path === "number") path = require_toKey.toKey(path); + const result = object[path]; + if (result === void 0) return defaultValue; + return result; + } + default: { + if (Array.isArray(path)) return getWithPath(object, path, defaultValue); + if (Object.is(path?.valueOf(), -0)) path = "-0"; + else path = String(path); + if (require_isUnsafeProperty.isUnsafeProperty(path)) return defaultValue; + const result = object[path]; + if (result === void 0) return defaultValue; + return result; + } + } +} +function getWithPath(object, path, defaultValue) { + if (path.length === 0) return defaultValue; + let current = object; + for (let index = 0; index < path.length; index++) { + if (current == null) return defaultValue; + if (require_isUnsafeProperty.isUnsafeProperty(path[index])) return defaultValue; + current = current[path[index]]; + } + if (current === void 0) return defaultValue; + return current; +} +//#endregion +exports.get = get; diff --git a/node_modules/es-toolkit/dist/compat/object/get.mjs b/node_modules/es-toolkit/dist/compat/object/get.mjs new file mode 100644 index 0000000000000000000000000000000000000000..32f9febfada0a42c12cfbc55ba96bbb7a29adb17 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/get.mjs @@ -0,0 +1,65 @@ +import { isUnsafeProperty } from "../../_internal/isUnsafeProperty.mjs"; +import { isDeepKey } from "../_internal/isDeepKey.mjs"; +import { toKey } from "../_internal/toKey.mjs"; +import { toPath } from "../util/toPath.mjs"; +//#region src/compat/object/get.ts +/** +* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. +* +* @param object - The object to query. +* @param path - The path of the property to get. +* @param [defaultValue] - The value returned if the resolved value is undefined. +* @returns Returns the resolved value. +* +* @example +* const object = { a: { b: { c: 1 } } }; +* get(object, 'a.b.c'); +* // => 1 +* +* get(object, ['a', 'b', 'c']); +* // => 1 +* +* get(object, 'a.b.d', 'default'); +* // => 'default' +*/ +function get(object, path, defaultValue) { + if (object == null) return defaultValue; + switch (typeof path) { + case "string": { + if (isUnsafeProperty(path)) return defaultValue; + const result = object[path]; + if (result === void 0) if (isDeepKey(path) && !Object.hasOwn(object, path)) return get(object, toPath(path), defaultValue); + else return defaultValue; + return result; + } + case "number": + case "symbol": { + if (typeof path === "number") path = toKey(path); + const result = object[path]; + if (result === void 0) return defaultValue; + return result; + } + default: { + if (Array.isArray(path)) return getWithPath(object, path, defaultValue); + if (Object.is(path?.valueOf(), -0)) path = "-0"; + else path = String(path); + if (isUnsafeProperty(path)) return defaultValue; + const result = object[path]; + if (result === void 0) return defaultValue; + return result; + } + } +} +function getWithPath(object, path, defaultValue) { + if (path.length === 0) return defaultValue; + let current = object; + for (let index = 0; index < path.length; index++) { + if (current == null) return defaultValue; + if (isUnsafeProperty(path[index])) return defaultValue; + current = current[path[index]]; + } + if (current === void 0) return defaultValue; + return current; +} +//#endregion +export { get }; diff --git a/node_modules/es-toolkit/dist/compat/object/has.d.mts b/node_modules/es-toolkit/dist/compat/object/has.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3d16078cb39af9298ccceefe9cab49188b908c11 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/has.d.mts @@ -0,0 +1,51 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/has.d.ts +/** + * Checks if a given path exists within an object. + * + * @template T + * @template K + * @param object - The object to query. + * @param path - The path to check. + * @returns & { [key: symbol]: unknown }} Returns a type guard indicating if the path exists in the object. + * + * @example + * const obj = { a: 1, b: { c: 2 } }; + * + * if (has(obj, 'a')) { + * console.log(obj.a); // TypeScript knows obj.a exists + * } + * + * if (has(obj, 'b')) { + * console.log(obj.b.c); // TypeScript knows obj.b exists + * } + */ +declare function has(object: T, path: K): object is T & { [P in K]: P extends keyof T ? T[P] : Record extends T ? T[keyof T] : unknown } & { + [key: symbol]: unknown; +}; +/** + * Checks if a given path exists within an object. + * + * @template T + * @param object - The object to query. + * @param path - The path to check. This can be a single property key, + * an array of property keys, or a string representing a deep path. + * @returns Returns `true` if the path exists in the object, `false` otherwise. + * + * @example + * const obj = { a: { b: { c: 3 } } }; + * + * has(obj, 'a'); // true + * has(obj, ['a', 'b']); // true + * has(obj, ['a', 'b', 'c']); // true + * has(obj, 'a.b.c'); // true + * has(obj, 'a.b.d'); // false + * has(obj, ['a', 'b', 'c', 'd']); // false + * has([], 0); // false + * has([1, 2, 3], 2); // true + * has([1, 2, 3], 5); // false + */ +declare function has(object: T, path: PropertyPath): boolean; +//#endregion +export { has }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/has.d.ts b/node_modules/es-toolkit/dist/compat/object/has.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..405556f3d5b38a7706453b801434d558b7a8f4fc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/has.d.ts @@ -0,0 +1,51 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/has.d.ts +/** + * Checks if a given path exists within an object. + * + * @template T + * @template K + * @param object - The object to query. + * @param path - The path to check. + * @returns & { [key: symbol]: unknown }} Returns a type guard indicating if the path exists in the object. + * + * @example + * const obj = { a: 1, b: { c: 2 } }; + * + * if (has(obj, 'a')) { + * console.log(obj.a); // TypeScript knows obj.a exists + * } + * + * if (has(obj, 'b')) { + * console.log(obj.b.c); // TypeScript knows obj.b exists + * } + */ +declare function has(object: T, path: K): object is T & { [P in K]: P extends keyof T ? T[P] : Record extends T ? T[keyof T] : unknown } & { + [key: symbol]: unknown; +}; +/** + * Checks if a given path exists within an object. + * + * @template T + * @param object - The object to query. + * @param path - The path to check. This can be a single property key, + * an array of property keys, or a string representing a deep path. + * @returns Returns `true` if the path exists in the object, `false` otherwise. + * + * @example + * const obj = { a: { b: { c: 3 } } }; + * + * has(obj, 'a'); // true + * has(obj, ['a', 'b']); // true + * has(obj, ['a', 'b', 'c']); // true + * has(obj, 'a.b.c'); // true + * has(obj, 'a.b.d'); // false + * has(obj, ['a', 'b', 'c', 'd']); // false + * has([], 0); // false + * has([1, 2, 3], 2); // true + * has([1, 2, 3], 5); // false + */ +declare function has(object: T, path: PropertyPath): boolean; +//#endregion +export { has }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/has.js b/node_modules/es-toolkit/dist/compat/object/has.js new file mode 100644 index 0000000000000000000000000000000000000000..176dd4eb6d997d996e15f2fd3063f83f73397acc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/has.js @@ -0,0 +1,52 @@ +const require_isDeepKey = require("../_internal/isDeepKey.js"); +const require_toPath = require("../util/toPath.js"); +const require_isIndex = require("../_internal/isIndex.js"); +const require_isArguments = require("../predicate/isArguments.js"); +//#region src/compat/object/has.ts +/** +* Checks if a given path exists within an object. +* +* You can provide the path as a single property key, an array of property keys, +* or a string representing a deep path. +* +* If the path is an index and the object is an array or an arguments object, the function will verify +* if the index is valid and within the bounds of the array or arguments object, even if the array or +* arguments object is sparse (i.e., not all indexes are defined). +* +* @param object - The object to query. +* @param path - The path to check. This can be a single property key, +* an array of property keys, or a string representing a deep path. +* @returns Returns `true` if the path exists in the object, `false` otherwise. +* +* @example +* +* const obj = { a: { b: { c: 3 } } }; +* +* has(obj, 'a'); // true +* has(obj, ['a', 'b']); // true +* has(obj, ['a', 'b', 'c']); // true +* has(obj, 'a.b.c'); // true +* has(obj, 'a.b.d'); // false +* has(obj, ['a', 'b', 'c', 'd']); // false +* has([], 0); // false +* has([1, 2, 3], 2); // true +* has([1, 2, 3], 5); // false +*/ +function has(object, path) { + let resolvedPath; + if (Array.isArray(path)) resolvedPath = path; + else if (typeof path === "string" && require_isDeepKey.isDeepKey(path) && !(path in Object(object))) resolvedPath = require_toPath.toPath(path); + else resolvedPath = [path]; + if (resolvedPath.length === 0) return false; + let current = object; + for (let i = 0; i < resolvedPath.length; i++) { + const key = resolvedPath[i]; + if (current == null || !Object.hasOwn(current, key)) { + if (!((Array.isArray(current) || require_isArguments.isArguments(current)) && require_isIndex.isIndex(key) && key < current.length)) return false; + } + current = current[key]; + } + return true; +} +//#endregion +exports.has = has; diff --git a/node_modules/es-toolkit/dist/compat/object/has.mjs b/node_modules/es-toolkit/dist/compat/object/has.mjs new file mode 100644 index 0000000000000000000000000000000000000000..76f92dbf6cfb2ba6083ed7b0dfeb85c2ae50b7d8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/has.mjs @@ -0,0 +1,52 @@ +import { isDeepKey } from "../_internal/isDeepKey.mjs"; +import { toPath } from "../util/toPath.mjs"; +import { isIndex } from "../_internal/isIndex.mjs"; +import { isArguments } from "../predicate/isArguments.mjs"; +//#region src/compat/object/has.ts +/** +* Checks if a given path exists within an object. +* +* You can provide the path as a single property key, an array of property keys, +* or a string representing a deep path. +* +* If the path is an index and the object is an array or an arguments object, the function will verify +* if the index is valid and within the bounds of the array or arguments object, even if the array or +* arguments object is sparse (i.e., not all indexes are defined). +* +* @param object - The object to query. +* @param path - The path to check. This can be a single property key, +* an array of property keys, or a string representing a deep path. +* @returns Returns `true` if the path exists in the object, `false` otherwise. +* +* @example +* +* const obj = { a: { b: { c: 3 } } }; +* +* has(obj, 'a'); // true +* has(obj, ['a', 'b']); // true +* has(obj, ['a', 'b', 'c']); // true +* has(obj, 'a.b.c'); // true +* has(obj, 'a.b.d'); // false +* has(obj, ['a', 'b', 'c', 'd']); // false +* has([], 0); // false +* has([1, 2, 3], 2); // true +* has([1, 2, 3], 5); // false +*/ +function has(object, path) { + let resolvedPath; + if (Array.isArray(path)) resolvedPath = path; + else if (typeof path === "string" && isDeepKey(path) && !(path in Object(object))) resolvedPath = toPath(path); + else resolvedPath = [path]; + if (resolvedPath.length === 0) return false; + let current = object; + for (let i = 0; i < resolvedPath.length; i++) { + const key = resolvedPath[i]; + if (current == null || !Object.hasOwn(current, key)) { + if (!((Array.isArray(current) || isArguments(current)) && isIndex(key) && key < current.length)) return false; + } + current = current[key]; + } + return true; +} +//#endregion +export { has }; diff --git a/node_modules/es-toolkit/dist/compat/object/hasIn.d.mts b/node_modules/es-toolkit/dist/compat/object/hasIn.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..93aa9d6d2870add67c643053a0326acfa8c4ecd2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/hasIn.d.mts @@ -0,0 +1,44 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/hasIn.d.ts +/** + * Checks if a given path exists in an object, **including inherited properties**. + * + * You can provide the path as a single property key, an array of property keys, + * or a string representing a deep path. + * + * Unlike `has`, which only checks for own properties, `hasIn` also checks for properties + * in the prototype chain. + * + * If the path is an index and the object is an array or an arguments object, the function will verify + * if the index is valid and within the bounds of the array or arguments object, even if the array or + * arguments object is sparse (i.e., not all indexes are defined). + * + * @template T + * @param object - The object to query. + * @param path - The path to check. This can be a single property key, + * an array of property keys, or a string representing a deep path. + * @returns Returns `true` if the path exists (own or inherited), `false` otherwise. + * + * @example + * + * const obj = { a: { b: { c: 3 } } }; + * + * hasIn(obj, 'a'); // true + * hasIn(obj, ['a', 'b']); // true + * hasIn(obj, ['a', 'b', 'c']); // true + * hasIn(obj, 'a.b.c'); // true + * hasIn(obj, 'a.b.d'); // false + * hasIn(obj, ['a', 'b', 'c', 'd']); // false + * + * // Example with inherited properties: + * function Rectangle() {} + * Rectangle.prototype.area = function() {}; + * + * const rect = new Rectangle(); + * hasIn(rect, 'area'); // true + * has(rect, 'area'); // false - has only checks own properties + */ +declare function hasIn(object: T, path: PropertyPath): boolean; +//#endregion +export { hasIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/hasIn.d.ts b/node_modules/es-toolkit/dist/compat/object/hasIn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a2a9dc23beff5146db192b2cdce044f081cb599 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/hasIn.d.ts @@ -0,0 +1,44 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/hasIn.d.ts +/** + * Checks if a given path exists in an object, **including inherited properties**. + * + * You can provide the path as a single property key, an array of property keys, + * or a string representing a deep path. + * + * Unlike `has`, which only checks for own properties, `hasIn` also checks for properties + * in the prototype chain. + * + * If the path is an index and the object is an array or an arguments object, the function will verify + * if the index is valid and within the bounds of the array or arguments object, even if the array or + * arguments object is sparse (i.e., not all indexes are defined). + * + * @template T + * @param object - The object to query. + * @param path - The path to check. This can be a single property key, + * an array of property keys, or a string representing a deep path. + * @returns Returns `true` if the path exists (own or inherited), `false` otherwise. + * + * @example + * + * const obj = { a: { b: { c: 3 } } }; + * + * hasIn(obj, 'a'); // true + * hasIn(obj, ['a', 'b']); // true + * hasIn(obj, ['a', 'b', 'c']); // true + * hasIn(obj, 'a.b.c'); // true + * hasIn(obj, 'a.b.d'); // false + * hasIn(obj, ['a', 'b', 'c', 'd']); // false + * + * // Example with inherited properties: + * function Rectangle() {} + * Rectangle.prototype.area = function() {}; + * + * const rect = new Rectangle(); + * hasIn(rect, 'area'); // true + * has(rect, 'area'); // false - has only checks own properties + */ +declare function hasIn(object: T, path: PropertyPath): boolean; +//#endregion +export { hasIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/hasIn.js b/node_modules/es-toolkit/dist/compat/object/hasIn.js new file mode 100644 index 0000000000000000000000000000000000000000..68de223885c5a91fbcf5400882b20b8368e5b416 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/hasIn.js @@ -0,0 +1,62 @@ +const require_isDeepKey = require("../_internal/isDeepKey.js"); +const require_toPath = require("../util/toPath.js"); +const require_isIndex = require("../_internal/isIndex.js"); +const require_isArguments = require("../predicate/isArguments.js"); +//#region src/compat/object/hasIn.ts +/** +* Checks if a given path exists in an object, **including inherited properties**. +* +* You can provide the path as a single property key, an array of property keys, +* or a string representing a deep path. +* +* Unlike `has`, which only checks for own properties, `hasIn` also checks for properties +* in the prototype chain. +* +* If the path is an index and the object is an array or an arguments object, the function will verify +* if the index is valid and within the bounds of the array or arguments object, even if the array or +* arguments object is sparse (i.e., not all indexes are defined). +* +* @template T +* @param object - The object to query. +* @param path - The path to check. This can be a single property key, +* an array of property keys, or a string representing a deep path. +* @returns Returns `true` if the path exists (own or inherited), `false` otherwise. +* +* @example +* +* const obj = { a: { b: { c: 3 } } }; +* +* hasIn(obj, 'a'); // true +* hasIn(obj, ['a', 'b']); // true +* hasIn(obj, ['a', 'b', 'c']); // true +* hasIn(obj, 'a.b.c'); // true +* hasIn(obj, 'a.b.d'); // false +* hasIn(obj, ['a', 'b', 'c', 'd']); // false +* +* // Example with inherited properties: +* function Rectangle() {} +* Rectangle.prototype.area = function() {}; +* +* const rect = new Rectangle(); +* hasIn(rect, 'area'); // true +* has(rect, 'area'); // false - has only checks own properties +*/ +function hasIn(object, path) { + if (object == null) return false; + let resolvedPath; + if (Array.isArray(path)) resolvedPath = path; + else if (typeof path === "string" && require_isDeepKey.isDeepKey(path) && !(path in Object(object))) resolvedPath = require_toPath.toPath(path); + else resolvedPath = [path]; + if (resolvedPath.length === 0) return false; + let current = object; + for (let i = 0; i < resolvedPath.length; i++) { + const key = resolvedPath[i]; + if (current == null || !(key in Object(current))) { + if (!((Array.isArray(current) || require_isArguments.isArguments(current)) && require_isIndex.isIndex(key) && key < current.length)) return false; + } + current = current[key]; + } + return true; +} +//#endregion +exports.hasIn = hasIn; diff --git a/node_modules/es-toolkit/dist/compat/object/hasIn.mjs b/node_modules/es-toolkit/dist/compat/object/hasIn.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c1b102eaec757fe2f5ff3d9549d6a46ff68f6d13 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/hasIn.mjs @@ -0,0 +1,62 @@ +import { isDeepKey } from "../_internal/isDeepKey.mjs"; +import { toPath } from "../util/toPath.mjs"; +import { isIndex } from "../_internal/isIndex.mjs"; +import { isArguments } from "../predicate/isArguments.mjs"; +//#region src/compat/object/hasIn.ts +/** +* Checks if a given path exists in an object, **including inherited properties**. +* +* You can provide the path as a single property key, an array of property keys, +* or a string representing a deep path. +* +* Unlike `has`, which only checks for own properties, `hasIn` also checks for properties +* in the prototype chain. +* +* If the path is an index and the object is an array or an arguments object, the function will verify +* if the index is valid and within the bounds of the array or arguments object, even if the array or +* arguments object is sparse (i.e., not all indexes are defined). +* +* @template T +* @param object - The object to query. +* @param path - The path to check. This can be a single property key, +* an array of property keys, or a string representing a deep path. +* @returns Returns `true` if the path exists (own or inherited), `false` otherwise. +* +* @example +* +* const obj = { a: { b: { c: 3 } } }; +* +* hasIn(obj, 'a'); // true +* hasIn(obj, ['a', 'b']); // true +* hasIn(obj, ['a', 'b', 'c']); // true +* hasIn(obj, 'a.b.c'); // true +* hasIn(obj, 'a.b.d'); // false +* hasIn(obj, ['a', 'b', 'c', 'd']); // false +* +* // Example with inherited properties: +* function Rectangle() {} +* Rectangle.prototype.area = function() {}; +* +* const rect = new Rectangle(); +* hasIn(rect, 'area'); // true +* has(rect, 'area'); // false - has only checks own properties +*/ +function hasIn(object, path) { + if (object == null) return false; + let resolvedPath; + if (Array.isArray(path)) resolvedPath = path; + else if (typeof path === "string" && isDeepKey(path) && !(path in Object(object))) resolvedPath = toPath(path); + else resolvedPath = [path]; + if (resolvedPath.length === 0) return false; + let current = object; + for (let i = 0; i < resolvedPath.length; i++) { + const key = resolvedPath[i]; + if (current == null || !(key in Object(current))) { + if (!((Array.isArray(current) || isArguments(current)) && isIndex(key) && key < current.length)) return false; + } + current = current[key]; + } + return true; +} +//#endregion +export { hasIn }; diff --git a/node_modules/es-toolkit/dist/compat/object/invert.d.mts b/node_modules/es-toolkit/dist/compat/object/invert.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e3d9b1970a65509da3a1e2505e1beca3a65abe02 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/invert.d.mts @@ -0,0 +1,14 @@ +//#region src/compat/object/invert.d.ts +/** + * Inverts the keys and values of an object. + * + * @param object - The object to invert. + * @returns Returns the new inverted object. + * + * @example + * invert({ a: 1, b: 2, c: 3 }); + * // => { '1': 'a', '2': 'b', '3': 'c' } + */ +declare function invert(object: object): Record; +//#endregion +export { invert }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/invert.d.ts b/node_modules/es-toolkit/dist/compat/object/invert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3d9b1970a65509da3a1e2505e1beca3a65abe02 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/invert.d.ts @@ -0,0 +1,14 @@ +//#region src/compat/object/invert.d.ts +/** + * Inverts the keys and values of an object. + * + * @param object - The object to invert. + * @returns Returns the new inverted object. + * + * @example + * invert({ a: 1, b: 2, c: 3 }); + * // => { '1': 'a', '2': 'b', '3': 'c' } + */ +declare function invert(object: object): Record; +//#endregion +export { invert }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/invert.js b/node_modules/es-toolkit/dist/compat/object/invert.js new file mode 100644 index 0000000000000000000000000000000000000000..c2cb49392497e248b68f8905fbd403041fdb0d63 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/invert.js @@ -0,0 +1,25 @@ +const require_invert = require("../../object/invert.js"); +//#region src/compat/object/invert.ts +/** +* Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa. +* +* This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values, +* 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 +* of the input object's key-value pairs. +* +* @template K - Type of the keys in the input object (string, number, symbol) +* @template V - Type of the values in the input object (string, number, symbol) +* @param obj - The input object whose keys and values are to be inverted +* @returns A new object with keys and values inverted +* +* @example +* invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' } +* invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' } +* invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' } +* invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' } +*/ +function invert(obj) { + return require_invert.invert(obj); +} +//#endregion +exports.invert = invert; diff --git a/node_modules/es-toolkit/dist/compat/object/invert.mjs b/node_modules/es-toolkit/dist/compat/object/invert.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a9dfa2c5d5a71d37947fcf3e62dcd802c0154313 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/invert.mjs @@ -0,0 +1,25 @@ +import { invert as invert$1 } from "../../object/invert.mjs"; +//#region src/compat/object/invert.ts +/** +* Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa. +* +* This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values, +* 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 +* of the input object's key-value pairs. +* +* @template K - Type of the keys in the input object (string, number, symbol) +* @template V - Type of the values in the input object (string, number, symbol) +* @param obj - The input object whose keys and values are to be inverted +* @returns A new object with keys and values inverted +* +* @example +* invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' } +* invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' } +* invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' } +* invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' } +*/ +function invert(obj) { + return invert$1(obj); +} +//#endregion +export { invert }; diff --git a/node_modules/es-toolkit/dist/compat/object/invertBy.d.mts b/node_modules/es-toolkit/dist/compat/object/invertBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d5867c33222a80b91626c987bdc7c2562ad4069c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/invertBy.d.mts @@ -0,0 +1,35 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.mjs"; + +//#region src/compat/object/invertBy.d.ts +/** + * Creates a new object that reverses the keys and values of the given object, similar to the invert. + * The values of the new object are arrays of keys that correspond to the value returned by the `iteratee` function. + * + * @param object - The object to iterate over + * @param [iteratee] - Optional function to transform values into keys + * @returns An object with transformed values as keys and arrays of original keys as values + * + * @example + * const obj = { a: 1, b: 2, c: 1 }; + * invertBy(obj); // => { '1': ['a', 'c'], '2': ['b'] } + * + * @example + * const obj = { a: 1, b: 2, c: 1 }; + * invertBy(obj, value => `group${value}`); // => { 'group1': ['a', 'c'], 'group2': ['b'] } + */ +declare function invertBy(object: Record | Record | null | undefined, interatee?: ValueIteratee): Record; +/** + * Creates a new object that reverses the keys and values of the given object, similar to the invert. + * The values of the new object are arrays of keys that correspond to the value returned by the `iteratee` function. + * + * @param object - The object to iterate over + * @param [iteratee] - Optional function to transform values into keys + * @returns An object with transformed values as keys and arrays of original keys as values + * + * @example + * const obj = { foo: { id: 1 }, bar: { id: 2 }, baz: { id: 1 } }; + * invertBy(obj, value => String(value.id)); // => { '1': ['foo', 'baz'], '2': ['bar'] } + */ +declare function invertBy(object: T | null | undefined, interatee?: ValueIteratee): Record; +//#endregion +export { invertBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/invertBy.d.ts b/node_modules/es-toolkit/dist/compat/object/invertBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..75c8ddead45e6443d27babfd2916bbdb84e044eb --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/invertBy.d.ts @@ -0,0 +1,35 @@ +import { ValueIteratee } from "../_internal/ValueIteratee.js"; + +//#region src/compat/object/invertBy.d.ts +/** + * Creates a new object that reverses the keys and values of the given object, similar to the invert. + * The values of the new object are arrays of keys that correspond to the value returned by the `iteratee` function. + * + * @param object - The object to iterate over + * @param [iteratee] - Optional function to transform values into keys + * @returns An object with transformed values as keys and arrays of original keys as values + * + * @example + * const obj = { a: 1, b: 2, c: 1 }; + * invertBy(obj); // => { '1': ['a', 'c'], '2': ['b'] } + * + * @example + * const obj = { a: 1, b: 2, c: 1 }; + * invertBy(obj, value => `group${value}`); // => { 'group1': ['a', 'c'], 'group2': ['b'] } + */ +declare function invertBy(object: Record | Record | null | undefined, interatee?: ValueIteratee): Record; +/** + * Creates a new object that reverses the keys and values of the given object, similar to the invert. + * The values of the new object are arrays of keys that correspond to the value returned by the `iteratee` function. + * + * @param object - The object to iterate over + * @param [iteratee] - Optional function to transform values into keys + * @returns An object with transformed values as keys and arrays of original keys as values + * + * @example + * const obj = { foo: { id: 1 }, bar: { id: 2 }, baz: { id: 1 } }; + * invertBy(obj, value => String(value.id)); // => { '1': ['foo', 'baz'], '2': ['bar'] } + */ +declare function invertBy(object: T | null | undefined, interatee?: ValueIteratee): Record; +//#endregion +export { invertBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/invertBy.js b/node_modules/es-toolkit/dist/compat/object/invertBy.js new file mode 100644 index 0000000000000000000000000000000000000000..87db76d0a318dac926836319d96936657fe07954 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/invertBy.js @@ -0,0 +1,45 @@ +const require_identity = require("../../function/identity.js"); +const require_isNil = require("../../predicate/isNil.js"); +const require_iteratee = require("../util/iteratee.js"); +//#region src/compat/object/invertBy.ts +/** +* Creates a new object that reverses the keys and values of the given object, similar to the invert. +* +* 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. +* +* The values of the new object are arrays of keys that correspond to the value returned by the `iteratee` function. +* +* @param object - The object to iterate over. +* @param [iteratee] - Optional. A function that generates a key based on each value in the object. +* If not provided, the function defaults to using the value as a string. +* +* @returns An object where the keys are generated by the iteratee, and the values +* are arrays of property names (keys) from the input object that correspond to those keys. +* +* @example +* const obj = { a: 1, b: 2, c: 1 }; +* const result = invertBy(obj); +* // result => { '1': ['a', 'c'], '2': ['b'] } +* +* @example +* const obj = { a: 1, b: 2, c: 1 }; +* const result = invertBy(obj, value => `group${value}`); +* // result => { 'group1': ['a', 'c'], 'group2': ['b'] } +*/ +function invertBy(object, iteratee$1) { + const result = {}; + if (require_isNil.isNil(object)) return result; + if (iteratee$1 == null) iteratee$1 = require_identity.identity; + const keys = Object.keys(object); + const getString = require_iteratee.iteratee(iteratee$1); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = object[key]; + const valueStr = getString(value); + if (Array.isArray(result[valueStr])) result[valueStr].push(key); + else result[valueStr] = [key]; + } + return result; +} +//#endregion +exports.invertBy = invertBy; diff --git a/node_modules/es-toolkit/dist/compat/object/invertBy.mjs b/node_modules/es-toolkit/dist/compat/object/invertBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..948bc6598245ad3d27e223b22f955113cf3f4b05 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/invertBy.mjs @@ -0,0 +1,45 @@ +import { identity } from "../../function/identity.mjs"; +import { isNil } from "../../predicate/isNil.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +//#region src/compat/object/invertBy.ts +/** +* Creates a new object that reverses the keys and values of the given object, similar to the invert. +* +* 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. +* +* The values of the new object are arrays of keys that correspond to the value returned by the `iteratee` function. +* +* @param object - The object to iterate over. +* @param [iteratee] - Optional. A function that generates a key based on each value in the object. +* If not provided, the function defaults to using the value as a string. +* +* @returns An object where the keys are generated by the iteratee, and the values +* are arrays of property names (keys) from the input object that correspond to those keys. +* +* @example +* const obj = { a: 1, b: 2, c: 1 }; +* const result = invertBy(obj); +* // result => { '1': ['a', 'c'], '2': ['b'] } +* +* @example +* const obj = { a: 1, b: 2, c: 1 }; +* const result = invertBy(obj, value => `group${value}`); +* // result => { 'group1': ['a', 'c'], 'group2': ['b'] } +*/ +function invertBy(object, iteratee$1) { + const result = {}; + if (isNil(object)) return result; + if (iteratee$1 == null) iteratee$1 = identity; + const keys = Object.keys(object); + const getString = iteratee(iteratee$1); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = object[key]; + const valueStr = getString(value); + if (Array.isArray(result[valueStr])) result[valueStr].push(key); + else result[valueStr] = [key]; + } + return result; +} +//#endregion +export { invertBy }; diff --git a/node_modules/es-toolkit/dist/compat/object/keys.d.mts b/node_modules/es-toolkit/dist/compat/object/keys.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..98548764921fbc4cf6cb7befc596de92a7815b9a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/keys.d.mts @@ -0,0 +1,23 @@ +//#region src/compat/object/keys.d.ts +/** + * Creates an array of the own enumerable property names of `object`. + * + * Non-object values are coerced to objects. + * + * @param object The object to query. + * @returns Returns the array of property names. + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * Foo.prototype.c = 3; + * keys(new Foo); // ['a', 'b'] (iteration order is not guaranteed) + * + * keys('hi'); // ['0', '1'] + * keys([1, 2, 3]); // ['0', '1', '2'] + * keys({ a: 1, b: 2 }); // ['a', 'b'] + */ +declare function keys(object?: any): string[]; +//#endregion +export { keys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/keys.d.ts b/node_modules/es-toolkit/dist/compat/object/keys.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..98548764921fbc4cf6cb7befc596de92a7815b9a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/keys.d.ts @@ -0,0 +1,23 @@ +//#region src/compat/object/keys.d.ts +/** + * Creates an array of the own enumerable property names of `object`. + * + * Non-object values are coerced to objects. + * + * @param object The object to query. + * @returns Returns the array of property names. + * @example + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * Foo.prototype.c = 3; + * keys(new Foo); // ['a', 'b'] (iteration order is not guaranteed) + * + * keys('hi'); // ['0', '1'] + * keys([1, 2, 3]); // ['0', '1', '2'] + * keys({ a: 1, b: 2 }); // ['a', 'b'] + */ +declare function keys(object?: any): string[]; +//#endregion +export { keys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/keys.js b/node_modules/es-toolkit/dist/compat/object/keys.js new file mode 100644 index 0000000000000000000000000000000000000000..1cce2fee9fa03940195a84900deadcd2303f9a6f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/keys.js @@ -0,0 +1,49 @@ +const require_isBuffer = require("../../predicate/isBuffer.js"); +const require_isArrayLike = require("../predicate/isArrayLike.js"); +const require_isPrototype = require("../_internal/isPrototype.js"); +const require_isTypedArray = require("../predicate/isTypedArray.js"); +const require_times = require("../util/times.js"); +//#region src/compat/object/keys.ts +/** +* Creates an array of the own enumerable property names of `object`. +* +* Non-object values are coerced to objects. +* +* @param object The object to query. +* @returns Returns the array of property names. +* @example +* function Foo() { +* this.a = 1; +* this.b = 2; +* } +* Foo.prototype.c = 3; +* keys(new Foo); // ['a', 'b'] (iteration order is not guaranteed) +* +* keys('hi'); // ['0', '1'] +* keys([1, 2, 3]); // ['0', '1', '2'] +* keys({ a: 1, b: 2 }); // ['a', 'b'] +*/ +function keys(object) { + if (require_isArrayLike.isArrayLike(object)) return arrayLikeKeys(object); + const result = Object.keys(Object(object)); + if (!require_isPrototype.isPrototype(object)) return result; + return result.filter((key) => key !== "constructor"); +} +function arrayLikeKeys(object) { + const indices = require_times.times(object.length, (index) => `${index}`); + const filteredKeys = new Set(indices); + if (require_isBuffer.isBuffer(object)) { + filteredKeys.add("offset"); + filteredKeys.add("parent"); + } + if (require_isTypedArray.isTypedArray(object)) { + filteredKeys.add("buffer"); + filteredKeys.add("byteLength"); + filteredKeys.add("byteOffset"); + } + const inheritedKeys = Object.keys(object).filter((key) => !filteredKeys.has(key)); + if (Array.isArray(object)) return [...indices, ...inheritedKeys]; + return [...indices.filter((index) => Object.hasOwn(object, index)), ...inheritedKeys]; +} +//#endregion +exports.keys = keys; diff --git a/node_modules/es-toolkit/dist/compat/object/keys.mjs b/node_modules/es-toolkit/dist/compat/object/keys.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8e67b016139a75177602988d9e440eb9324cc062 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/keys.mjs @@ -0,0 +1,49 @@ +import { isBuffer } from "../../predicate/isBuffer.mjs"; +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +import { isPrototype } from "../_internal/isPrototype.mjs"; +import { isTypedArray } from "../predicate/isTypedArray.mjs"; +import { times } from "../util/times.mjs"; +//#region src/compat/object/keys.ts +/** +* Creates an array of the own enumerable property names of `object`. +* +* Non-object values are coerced to objects. +* +* @param object The object to query. +* @returns Returns the array of property names. +* @example +* function Foo() { +* this.a = 1; +* this.b = 2; +* } +* Foo.prototype.c = 3; +* keys(new Foo); // ['a', 'b'] (iteration order is not guaranteed) +* +* keys('hi'); // ['0', '1'] +* keys([1, 2, 3]); // ['0', '1', '2'] +* keys({ a: 1, b: 2 }); // ['a', 'b'] +*/ +function keys(object) { + if (isArrayLike(object)) return arrayLikeKeys(object); + const result = Object.keys(Object(object)); + if (!isPrototype(object)) return result; + return result.filter((key) => key !== "constructor"); +} +function arrayLikeKeys(object) { + const indices = times(object.length, (index) => `${index}`); + const filteredKeys = new Set(indices); + if (isBuffer(object)) { + filteredKeys.add("offset"); + filteredKeys.add("parent"); + } + if (isTypedArray(object)) { + filteredKeys.add("buffer"); + filteredKeys.add("byteLength"); + filteredKeys.add("byteOffset"); + } + const inheritedKeys = Object.keys(object).filter((key) => !filteredKeys.has(key)); + if (Array.isArray(object)) return [...indices, ...inheritedKeys]; + return [...indices.filter((index) => Object.hasOwn(object, index)), ...inheritedKeys]; +} +//#endregion +export { keys }; diff --git a/node_modules/es-toolkit/dist/compat/object/keysIn.d.mts b/node_modules/es-toolkit/dist/compat/object/keysIn.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6657731254ac6e41b96b5a145c98dda678541902 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/keysIn.d.mts @@ -0,0 +1,27 @@ +//#region src/compat/object/keysIn.d.ts +/** + * This function retrieves the names of string-keyed properties from an object, including those inherited from its prototype. + * + * - If the value is not an object, it is converted to an object. + * - Array-like objects are treated like arrays. + * - Sparse arrays with some missing indices are treated like dense arrays. + * - If the value is `null` or `undefined`, an empty array is returned. + * - When handling prototype objects, the `constructor` property is excluded from the results. + * + * @param [object] - The object to inspect for keys. + * @returns An array of string keys from the object. + * + * @example + * const obj = { a: 1, b: 2 }; + * console.log(keysIn(obj)); // ['a', 'b'] + * + * const arr = [1, 2, 3]; + * console.log(keysIn(arr)); // ['0', '1', '2'] + * + * function Foo() {} + * Foo.prototype.a = 1; + * console.log(keysIn(new Foo())); // ['a'] + */ +declare function keysIn(object?: any): string[]; +//#endregion +export { keysIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/keysIn.d.ts b/node_modules/es-toolkit/dist/compat/object/keysIn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6657731254ac6e41b96b5a145c98dda678541902 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/keysIn.d.ts @@ -0,0 +1,27 @@ +//#region src/compat/object/keysIn.d.ts +/** + * This function retrieves the names of string-keyed properties from an object, including those inherited from its prototype. + * + * - If the value is not an object, it is converted to an object. + * - Array-like objects are treated like arrays. + * - Sparse arrays with some missing indices are treated like dense arrays. + * - If the value is `null` or `undefined`, an empty array is returned. + * - When handling prototype objects, the `constructor` property is excluded from the results. + * + * @param [object] - The object to inspect for keys. + * @returns An array of string keys from the object. + * + * @example + * const obj = { a: 1, b: 2 }; + * console.log(keysIn(obj)); // ['a', 'b'] + * + * const arr = [1, 2, 3]; + * console.log(keysIn(arr)); // ['0', '1', '2'] + * + * function Foo() {} + * Foo.prototype.a = 1; + * console.log(keysIn(new Foo())); // ['a'] + */ +declare function keysIn(object?: any): string[]; +//#endregion +export { keysIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/keysIn.js b/node_modules/es-toolkit/dist/compat/object/keysIn.js new file mode 100644 index 0000000000000000000000000000000000000000..12974d7de44706b20e8d4f918d5c6ef7e91e3d0f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/keysIn.js @@ -0,0 +1,66 @@ +const require_isBuffer = require("../../predicate/isBuffer.js"); +const require_isArrayLike = require("../predicate/isArrayLike.js"); +const require_isPrototype = require("../_internal/isPrototype.js"); +const require_isTypedArray = require("../predicate/isTypedArray.js"); +const require_times = require("../util/times.js"); +//#region src/compat/object/keysIn.ts +/** +* This function retrieves the names of string-keyed properties from an object, including those inherited from its prototype. +* +* - If the value is not an object, it is converted to an object. +* - Array-like objects are treated like arrays. +* - Sparse arrays with some missing indices are treated like dense arrays. +* - If the value is `null` or `undefined`, an empty array is returned. +* - When handling prototype objects, the `constructor` property is excluded from the results. +* +* @param [object] - The object to inspect for keys. +* @returns An array of string keys from the object. +* +* @example +* const obj = { a: 1, b: 2 }; +* console.log(keysIn(obj)); // ['a', 'b'] +* +* const arr = [1, 2, 3]; +* console.log(keysIn(arr)); // ['0', '1', '2'] +* +* function Foo() {} +* Foo.prototype.a = 1; +* console.log(keysIn(new Foo())); // ['a'] +*/ +function keysIn(object) { + if (object == null) return []; + switch (typeof object) { + case "object": + case "function": + if (require_isArrayLike.isArrayLike(object)) return arrayLikeKeysIn(object); + if (require_isPrototype.isPrototype(object)) return prototypeKeysIn(object); + return keysInImpl(object); + default: return keysInImpl(Object(object)); + } +} +function keysInImpl(object) { + const result = []; + for (const key in object) result.push(key); + return result; +} +function prototypeKeysIn(object) { + return keysInImpl(object).filter((key) => key !== "constructor"); +} +function arrayLikeKeysIn(object) { + const indices = require_times.times(object.length, (index) => `${index}`); + const filteredKeys = new Set(indices); + if (require_isBuffer.isBuffer(object)) { + filteredKeys.add("offset"); + filteredKeys.add("parent"); + } + if (require_isTypedArray.isTypedArray(object)) { + filteredKeys.add("buffer"); + filteredKeys.add("byteLength"); + filteredKeys.add("byteOffset"); + } + const inheritedKeys = keysInImpl(object).filter((key) => !filteredKeys.has(key)); + if (Array.isArray(object)) return [...indices, ...inheritedKeys]; + return [...indices.filter((index) => Object.hasOwn(object, index)), ...inheritedKeys]; +} +//#endregion +exports.keysIn = keysIn; diff --git a/node_modules/es-toolkit/dist/compat/object/keysIn.mjs b/node_modules/es-toolkit/dist/compat/object/keysIn.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ba67ea73ab0e6b106725179b5b94ad4e600944ab --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/keysIn.mjs @@ -0,0 +1,66 @@ +import { isBuffer } from "../../predicate/isBuffer.mjs"; +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +import { isPrototype } from "../_internal/isPrototype.mjs"; +import { isTypedArray } from "../predicate/isTypedArray.mjs"; +import { times } from "../util/times.mjs"; +//#region src/compat/object/keysIn.ts +/** +* This function retrieves the names of string-keyed properties from an object, including those inherited from its prototype. +* +* - If the value is not an object, it is converted to an object. +* - Array-like objects are treated like arrays. +* - Sparse arrays with some missing indices are treated like dense arrays. +* - If the value is `null` or `undefined`, an empty array is returned. +* - When handling prototype objects, the `constructor` property is excluded from the results. +* +* @param [object] - The object to inspect for keys. +* @returns An array of string keys from the object. +* +* @example +* const obj = { a: 1, b: 2 }; +* console.log(keysIn(obj)); // ['a', 'b'] +* +* const arr = [1, 2, 3]; +* console.log(keysIn(arr)); // ['0', '1', '2'] +* +* function Foo() {} +* Foo.prototype.a = 1; +* console.log(keysIn(new Foo())); // ['a'] +*/ +function keysIn(object) { + if (object == null) return []; + switch (typeof object) { + case "object": + case "function": + if (isArrayLike(object)) return arrayLikeKeysIn(object); + if (isPrototype(object)) return prototypeKeysIn(object); + return keysInImpl(object); + default: return keysInImpl(Object(object)); + } +} +function keysInImpl(object) { + const result = []; + for (const key in object) result.push(key); + return result; +} +function prototypeKeysIn(object) { + return keysInImpl(object).filter((key) => key !== "constructor"); +} +function arrayLikeKeysIn(object) { + const indices = times(object.length, (index) => `${index}`); + const filteredKeys = new Set(indices); + if (isBuffer(object)) { + filteredKeys.add("offset"); + filteredKeys.add("parent"); + } + if (isTypedArray(object)) { + filteredKeys.add("buffer"); + filteredKeys.add("byteLength"); + filteredKeys.add("byteOffset"); + } + const inheritedKeys = keysInImpl(object).filter((key) => !filteredKeys.has(key)); + if (Array.isArray(object)) return [...indices, ...inheritedKeys]; + return [...indices.filter((index) => Object.hasOwn(object, index)), ...inheritedKeys]; +} +//#endregion +export { keysIn }; diff --git a/node_modules/es-toolkit/dist/compat/object/mapKeys.d.mts b/node_modules/es-toolkit/dist/compat/object/mapKeys.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..24b50472afc86a137186116efb039325f6b3f4f6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mapKeys.d.mts @@ -0,0 +1,32 @@ +import { ListIteratee } from "../_internal/ListIteratee.mjs"; +import { ObjectIteratee } from "../_internal/ObjectIteratee.mjs"; + +//#region src/compat/object/mapKeys.d.ts +/** + * Creates an object with the same values as `object` and keys generated by running each own enumerable string keyed property through `iteratee`. + * + * @template T + * @param object - The object to iterate over. + * @param [iteratee] - The function invoked per iteration. + * @returns Returns the new mapped object. + * + * @example + * mapKeys([1, 2, 3], (value, index) => `key${index}`); + * // => { 'key0': 1, 'key1': 2, 'key2': 3 } + */ +declare function mapKeys(object: ArrayLike | null | undefined, iteratee?: ListIteratee): Record; +/** + * Creates an object with the same values as `object` and keys generated by running each own enumerable string keyed property through `iteratee`. + * + * @template T + * @param object - The object to iterate over. + * @param [iteratee] - The function invoked per iteration. + * @returns Returns the new mapped object. + * + * @example + * mapKeys({ a: 1, b: 2 }, (value, key) => key + value); + * // => { 'a1': 1, 'b2': 2 } + */ +declare function mapKeys(object: T | null | undefined, iteratee?: ObjectIteratee): Record; +//#endregion +export { mapKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/mapKeys.d.ts b/node_modules/es-toolkit/dist/compat/object/mapKeys.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..194e5e65129772fb8967252260bb060515d74b51 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mapKeys.d.ts @@ -0,0 +1,32 @@ +import { ListIteratee } from "../_internal/ListIteratee.js"; +import { ObjectIteratee } from "../_internal/ObjectIteratee.js"; + +//#region src/compat/object/mapKeys.d.ts +/** + * Creates an object with the same values as `object` and keys generated by running each own enumerable string keyed property through `iteratee`. + * + * @template T + * @param object - The object to iterate over. + * @param [iteratee] - The function invoked per iteration. + * @returns Returns the new mapped object. + * + * @example + * mapKeys([1, 2, 3], (value, index) => `key${index}`); + * // => { 'key0': 1, 'key1': 2, 'key2': 3 } + */ +declare function mapKeys(object: ArrayLike | null | undefined, iteratee?: ListIteratee): Record; +/** + * Creates an object with the same values as `object` and keys generated by running each own enumerable string keyed property through `iteratee`. + * + * @template T + * @param object - The object to iterate over. + * @param [iteratee] - The function invoked per iteration. + * @returns Returns the new mapped object. + * + * @example + * mapKeys({ a: 1, b: 2 }, (value, key) => key + value); + * // => { 'a1': 1, 'b2': 2 } + */ +declare function mapKeys(object: T | null | undefined, iteratee?: ObjectIteratee): Record; +//#endregion +export { mapKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/mapKeys.js b/node_modules/es-toolkit/dist/compat/object/mapKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..358fb824e93877725b385b2a99f99b2cc59dc03e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mapKeys.js @@ -0,0 +1,28 @@ +const require_identity = require("../../function/identity.js"); +const require_mapKeys = require("../../object/mapKeys.js"); +const require_iteratee = require("../util/iteratee.js"); +//#region src/compat/object/mapKeys.ts +/** +* Creates a new object with the same values as the given object, but with keys generated +* by running each own enumerable property of the object through the iteratee function. +* +* @template T - The type of the object. +* @template K1 - The type of the keys in the object. +* @template K2 - The type of the new keys generated by the iteratee function. +* +* @param object - The object to iterate over. +* @param [getNewKey] - The function invoked per own enumerable property, or a path to generate new keys. +* @returns Returns the new mapped object. +* +* @example +* // Example usage: +* const obj = { a: 1, b: 2 }; +* const result = mapKeys(obj, (value, key) => key + value); +* console.log(result); // { a1: 1, b2: 2 } +*/ +function mapKeys(object, getNewKey = require_identity.identity) { + if (object == null) return {}; + return require_mapKeys.mapKeys(object, require_iteratee.iteratee(getNewKey)); +} +//#endregion +exports.mapKeys = mapKeys; diff --git a/node_modules/es-toolkit/dist/compat/object/mapKeys.mjs b/node_modules/es-toolkit/dist/compat/object/mapKeys.mjs new file mode 100644 index 0000000000000000000000000000000000000000..95ca0c1635ed385158a99f2b8ff13566618b74b9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mapKeys.mjs @@ -0,0 +1,28 @@ +import { identity } from "../../function/identity.mjs"; +import { mapKeys as mapKeys$1 } from "../../object/mapKeys.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +//#region src/compat/object/mapKeys.ts +/** +* Creates a new object with the same values as the given object, but with keys generated +* by running each own enumerable property of the object through the iteratee function. +* +* @template T - The type of the object. +* @template K1 - The type of the keys in the object. +* @template K2 - The type of the new keys generated by the iteratee function. +* +* @param object - The object to iterate over. +* @param [getNewKey] - The function invoked per own enumerable property, or a path to generate new keys. +* @returns Returns the new mapped object. +* +* @example +* // Example usage: +* const obj = { a: 1, b: 2 }; +* const result = mapKeys(obj, (value, key) => key + value); +* console.log(result); // { a1: 1, b2: 2 } +*/ +function mapKeys(object, getNewKey = identity) { + if (object == null) return {}; + return mapKeys$1(object, iteratee(getNewKey)); +} +//#endregion +export { mapKeys }; diff --git a/node_modules/es-toolkit/dist/compat/object/mapValues.d.mts b/node_modules/es-toolkit/dist/compat/object/mapValues.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..17f4b5237a2d7dad593f5b9bbbf0c4f4a3ef7c64 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mapValues.d.mts @@ -0,0 +1,125 @@ +import { ArrayIterator } from "../_internal/ArrayIterator.mjs"; +import { ObjectIterator } from "../_internal/ObjectIterator.mjs"; +import { StringIterator } from "../_internal/StringIterator.mjs"; + +//#region src/compat/object/mapValues.d.ts +/** + * Creates a new object by mapping each character in a string to a value. + * @param obj - The string to iterate over + * @param callback - The function invoked per character + * @returns A new object with numeric keys and mapped values + * @example + * mapValues('abc', (char) => char.toUpperCase()) + * // => { '0': 'A', '1': 'B', '2': 'C' } + */ +declare function mapValues(obj: string | null | undefined, callback: StringIterator): Record; +/** + * Creates a new object by mapping each element in an array to a value. + * @param array - The array to iterate over + * @param callback - The function invoked per element + * @returns A new object with numeric keys and mapped values + * @example + * mapValues([1, 2], (num) => num * 2) + * // => { '0': 2, '1': 4 } + */ +declare function mapValues(array: T[], callback: ArrayIterator): Record; +/** + * Creates a new object by mapping each property value in an object to a new value. + * @param obj - The object to iterate over + * @param callback - The function invoked per property + * @returns A new object with the same keys and mapped values + * @example + * mapValues({ a: 1, b: 2 }, (num) => num * 2) + * // => { a: 2, b: 4 } + */ +declare function mapValues(obj: T | null | undefined, callback: ObjectIterator): { [P in keyof T]: U }; +/** + * Creates a new object by checking each value against a matcher object. + * @param obj - The object to iterate over + * @param iteratee - The object to match against + * @returns A new object with boolean values indicating matches + * @example + * mapValues({ a: { x: 1 }, b: { x: 2 } }, { x: 2 }) + * // => { a: false, b: true } + */ +declare function mapValues(obj: Record | Record | null | undefined, iteratee: object): Record; +/** + * Creates a new object by checking each value against a matcher object. + * @param obj - The object to iterate over + * @param iteratee - The object to match against + * @returns A new object with boolean values indicating matches + * @example + * mapValues({ a: { x: 1 }, b: { x: 2 } }, { x: 2 }) + * // => { a: false, b: true } + */ +declare function mapValues(obj: T | null | undefined, iteratee: object): { [P in keyof T]: boolean }; +/** + * Creates a new object by extracting a property from each value. + * @param obj - The object to iterate over + * @param iteratee - The property key to extract + * @returns A new object with extracted property values + * @example + * mapValues({ a: { x: 1 }, b: { x: 2 } }, 'x') + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: Record | Record | null | undefined, iteratee: K): Record; +/** + * Creates a new object by extracting values at a path from each value. + * @param obj - The object to iterate over + * @param iteratee - The path to extract + * @returns A new object with extracted values + * @example + * mapValues({ a: { x: { y: 1 } }, b: { x: { y: 2 } } }, 'x.y') + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: Record | Record | null | undefined, iteratee: string): Record; +/** + * Creates a new object by extracting values at a path from each value. + * @param obj - The object to iterate over + * @param iteratee - The path to extract + * @returns A new object with extracted values + * @example + * mapValues({ a: { x: { y: 1 } }, b: { x: { y: 2 } } }, 'x.y') + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: T | null | undefined, iteratee: string): { [P in keyof T]: any }; +/** + * Creates a new object from a string using identity function. + * @param obj - The string to convert + * @returns A new object with characters as values + * @example + * mapValues('abc') + * // => { '0': 'a', '1': 'b', '2': 'c' } + */ +declare function mapValues(obj: string | null | undefined): Record; +/** + * Creates a new object using identity function. + * @param obj - The object to clone + * @returns A new object with the same values + * @example + * mapValues({ a: 1, b: 2 }) + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: Record | Record | null | undefined): Record; +/** + * Creates a new object using identity function. + * @param obj - The object to clone + * @returns A new object with the same values + * @example + * mapValues({ a: 1, b: 2 }) + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: T): T; +/** + * Creates a new object using identity function. + * @param obj - The object to clone + * @returns A new object with the same values, or empty object if input is null/undefined + * @example + * mapValues({ a: 1, b: 2 }) + * // => { a: 1, b: 2 } + * mapValues(null) + * // => {} + */ +declare function mapValues(obj: T | null | undefined): Partial; +//#endregion +export { mapValues }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/mapValues.d.ts b/node_modules/es-toolkit/dist/compat/object/mapValues.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d806a02e7e07ca3f86763f18db6da49dd60a7791 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mapValues.d.ts @@ -0,0 +1,125 @@ +import { ArrayIterator } from "../_internal/ArrayIterator.js"; +import { ObjectIterator } from "../_internal/ObjectIterator.js"; +import { StringIterator } from "../_internal/StringIterator.js"; + +//#region src/compat/object/mapValues.d.ts +/** + * Creates a new object by mapping each character in a string to a value. + * @param obj - The string to iterate over + * @param callback - The function invoked per character + * @returns A new object with numeric keys and mapped values + * @example + * mapValues('abc', (char) => char.toUpperCase()) + * // => { '0': 'A', '1': 'B', '2': 'C' } + */ +declare function mapValues(obj: string | null | undefined, callback: StringIterator): Record; +/** + * Creates a new object by mapping each element in an array to a value. + * @param array - The array to iterate over + * @param callback - The function invoked per element + * @returns A new object with numeric keys and mapped values + * @example + * mapValues([1, 2], (num) => num * 2) + * // => { '0': 2, '1': 4 } + */ +declare function mapValues(array: T[], callback: ArrayIterator): Record; +/** + * Creates a new object by mapping each property value in an object to a new value. + * @param obj - The object to iterate over + * @param callback - The function invoked per property + * @returns A new object with the same keys and mapped values + * @example + * mapValues({ a: 1, b: 2 }, (num) => num * 2) + * // => { a: 2, b: 4 } + */ +declare function mapValues(obj: T | null | undefined, callback: ObjectIterator): { [P in keyof T]: U }; +/** + * Creates a new object by checking each value against a matcher object. + * @param obj - The object to iterate over + * @param iteratee - The object to match against + * @returns A new object with boolean values indicating matches + * @example + * mapValues({ a: { x: 1 }, b: { x: 2 } }, { x: 2 }) + * // => { a: false, b: true } + */ +declare function mapValues(obj: Record | Record | null | undefined, iteratee: object): Record; +/** + * Creates a new object by checking each value against a matcher object. + * @param obj - The object to iterate over + * @param iteratee - The object to match against + * @returns A new object with boolean values indicating matches + * @example + * mapValues({ a: { x: 1 }, b: { x: 2 } }, { x: 2 }) + * // => { a: false, b: true } + */ +declare function mapValues(obj: T | null | undefined, iteratee: object): { [P in keyof T]: boolean }; +/** + * Creates a new object by extracting a property from each value. + * @param obj - The object to iterate over + * @param iteratee - The property key to extract + * @returns A new object with extracted property values + * @example + * mapValues({ a: { x: 1 }, b: { x: 2 } }, 'x') + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: Record | Record | null | undefined, iteratee: K): Record; +/** + * Creates a new object by extracting values at a path from each value. + * @param obj - The object to iterate over + * @param iteratee - The path to extract + * @returns A new object with extracted values + * @example + * mapValues({ a: { x: { y: 1 } }, b: { x: { y: 2 } } }, 'x.y') + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: Record | Record | null | undefined, iteratee: string): Record; +/** + * Creates a new object by extracting values at a path from each value. + * @param obj - The object to iterate over + * @param iteratee - The path to extract + * @returns A new object with extracted values + * @example + * mapValues({ a: { x: { y: 1 } }, b: { x: { y: 2 } } }, 'x.y') + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: T | null | undefined, iteratee: string): { [P in keyof T]: any }; +/** + * Creates a new object from a string using identity function. + * @param obj - The string to convert + * @returns A new object with characters as values + * @example + * mapValues('abc') + * // => { '0': 'a', '1': 'b', '2': 'c' } + */ +declare function mapValues(obj: string | null | undefined): Record; +/** + * Creates a new object using identity function. + * @param obj - The object to clone + * @returns A new object with the same values + * @example + * mapValues({ a: 1, b: 2 }) + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: Record | Record | null | undefined): Record; +/** + * Creates a new object using identity function. + * @param obj - The object to clone + * @returns A new object with the same values + * @example + * mapValues({ a: 1, b: 2 }) + * // => { a: 1, b: 2 } + */ +declare function mapValues(obj: T): T; +/** + * Creates a new object using identity function. + * @param obj - The object to clone + * @returns A new object with the same values, or empty object if input is null/undefined + * @example + * mapValues({ a: 1, b: 2 }) + * // => { a: 1, b: 2 } + * mapValues(null) + * // => {} + */ +declare function mapValues(obj: T | null | undefined): Partial; +//#endregion +export { mapValues }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/mapValues.js b/node_modules/es-toolkit/dist/compat/object/mapValues.js new file mode 100644 index 0000000000000000000000000000000000000000..5a6d065beafc7e30bc39e7382f253bdb39f28ea6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mapValues.js @@ -0,0 +1,29 @@ +const require_identity = require("../../function/identity.js"); +const require_mapValues = require("../../object/mapValues.js"); +const require_iteratee = require("../util/iteratee.js"); +//#region src/compat/object/mapValues.ts +/** +* Creates a new object with the same keys as the given object, but with values generated +* by running each own enumerable property of the object through the iteratee function. +* +* @template T - The type of the object. +* @template K - The type of the keys in the object. +* @template V - The type of the new values generated by the iteratee function. +* +* @param object - The object to iterate over. +* @param [getNewValue] - +* The function invoked per own enumerable property, or a path to generate new values. +* @returns Returns the new mapped object. +* +* @example +* // Example usage: +* const obj = { a: 1, b: 2 }; +* const result = mapValues(obj, (value) => value * 2); +* console.log(result); // { a: 2, b: 4 } +*/ +function mapValues(object, getNewValue = require_identity.identity) { + if (object == null) return {}; + return require_mapValues.mapValues(object, require_iteratee.iteratee(getNewValue)); +} +//#endregion +exports.mapValues = mapValues; diff --git a/node_modules/es-toolkit/dist/compat/object/mapValues.mjs b/node_modules/es-toolkit/dist/compat/object/mapValues.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ac8b254131b5c59b3737effcc95e084c1757dd6d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mapValues.mjs @@ -0,0 +1,29 @@ +import { identity } from "../../function/identity.mjs"; +import { mapValues as mapValues$1 } from "../../object/mapValues.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +//#region src/compat/object/mapValues.ts +/** +* Creates a new object with the same keys as the given object, but with values generated +* by running each own enumerable property of the object through the iteratee function. +* +* @template T - The type of the object. +* @template K - The type of the keys in the object. +* @template V - The type of the new values generated by the iteratee function. +* +* @param object - The object to iterate over. +* @param [getNewValue] - +* The function invoked per own enumerable property, or a path to generate new values. +* @returns Returns the new mapped object. +* +* @example +* // Example usage: +* const obj = { a: 1, b: 2 }; +* const result = mapValues(obj, (value) => value * 2); +* console.log(result); // { a: 2, b: 4 } +*/ +function mapValues(object, getNewValue = identity) { + if (object == null) return {}; + return mapValues$1(object, iteratee(getNewValue)); +} +//#endregion +export { mapValues }; diff --git a/node_modules/es-toolkit/dist/compat/object/merge.d.mts b/node_modules/es-toolkit/dist/compat/object/merge.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bb16e43d5bd7e3d0946fc00d3c18cd42e2bd12a0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/merge.d.mts @@ -0,0 +1,85 @@ +//#region src/compat/object/merge.d.ts +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @template T + * @template U + * @param object - The destination object. + * @param source - The source object. + * @returns Returns `object`. + * + * @example + * const object = { a: [{ b: 2 }, { d: 4 }] }; + * const other = { a: [{ c: 3 }, { e: 5 }] }; + * merge(object, other); + * // => { a: [{ b: 2, c: 3 }, { d: 4, e: 5 }] } + */ +declare function merge(object: T, source: U): T & U; +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @template T + * @template U + * @template V + * @param object - The destination object. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @returns Returns `object`. + * + * @example + * merge({ a: 1 }, { b: 2 }, { c: 3 }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function merge(object: T, source1: U, source2: V): T & U & V; +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @template T + * @template U + * @template V + * @template W + * @param object - The destination object. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param source3 - The third source object. + * @returns Returns `object`. + * + * @example + * merge({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function merge(object: T, source1: U, source2: V, source3: W): T & U & V & W; +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @template T + * @template U + * @template V + * @template W + * @template X + * @param object - The destination object. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param source3 - The third source object. + * @param source4 - The fourth source object. + * @returns Returns `object`. + * + * @example + * merge({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }, { e: 5 }); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function merge(object: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X; +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @param object - The destination object. + * @param otherArgs - The source objects. + * @returns Returns `object`. + * + * @example + * merge({ a: 1 }, { b: 2 }, { c: 3 }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function merge(object: any, ...otherArgs: any[]): any; +//#endregion +export { merge }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/merge.d.ts b/node_modules/es-toolkit/dist/compat/object/merge.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb16e43d5bd7e3d0946fc00d3c18cd42e2bd12a0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/merge.d.ts @@ -0,0 +1,85 @@ +//#region src/compat/object/merge.d.ts +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @template T + * @template U + * @param object - The destination object. + * @param source - The source object. + * @returns Returns `object`. + * + * @example + * const object = { a: [{ b: 2 }, { d: 4 }] }; + * const other = { a: [{ c: 3 }, { e: 5 }] }; + * merge(object, other); + * // => { a: [{ b: 2, c: 3 }, { d: 4, e: 5 }] } + */ +declare function merge(object: T, source: U): T & U; +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @template T + * @template U + * @template V + * @param object - The destination object. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @returns Returns `object`. + * + * @example + * merge({ a: 1 }, { b: 2 }, { c: 3 }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function merge(object: T, source1: U, source2: V): T & U & V; +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @template T + * @template U + * @template V + * @template W + * @param object - The destination object. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param source3 - The third source object. + * @returns Returns `object`. + * + * @example + * merge({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function merge(object: T, source1: U, source2: V, source3: W): T & U & V & W; +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @template T + * @template U + * @template V + * @template W + * @template X + * @param object - The destination object. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param source3 - The third source object. + * @param source4 - The fourth source object. + * @returns Returns `object`. + * + * @example + * merge({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }, { e: 5 }); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function merge(object: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X; +/** + * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. + * + * @param object - The destination object. + * @param otherArgs - The source objects. + * @returns Returns `object`. + * + * @example + * merge({ a: 1 }, { b: 2 }, { c: 3 }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function merge(object: any, ...otherArgs: any[]): any; +//#endregion +export { merge }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/merge.js b/node_modules/es-toolkit/dist/compat/object/merge.js new file mode 100644 index 0000000000000000000000000000000000000000..6f3a11b2ff8af5efb6309863624bd14de107b3a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/merge.js @@ -0,0 +1,45 @@ +const require_noop = require("../../function/noop.js"); +const require_mergeWith = require("./mergeWith.js"); +//#region src/compat/object/merge.ts +/** +* Merges the properties of one or more source objects into the target object. +* +* This function performs a deep merge, recursively merging nested objects and arrays. +* 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. +* If a property in the source object is `undefined`, it will not overwrite a defined property in the target object. +* +* The function can handle multiple source objects and will merge them all into the target object. +* +* @param object - The target object into which the source object properties will be merged. This object is modified in place. +* @param sources - The source objects whose properties will be merged into the target object. +* @returns The updated target object with properties from the source object(s) merged in. +* +* @example +* const target = { a: 1, b: { x: 1, y: 2 } }; +* const source = { b: { y: 3, z: 4 }, c: 5 }; +* +* const result = merge(target, source); +* console.log(result); +* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 } +* +* @example +* const target = { a: [1, 2], b: { x: 1 } }; +* const source = { a: [3], b: { y: 2 } }; +* +* const result = merge(target, source); +* console.log(result); +* // Output: { a: [3], b: { x: 1, y: 2 } } +* +* @example +* const target = { a: null }; +* const source = { a: [1, 2, 3] }; +* +* const result = merge(target, source); +* console.log(result); +* // Output: { a: [1, 2, 3] } +*/ +function merge(object, ...sources) { + return require_mergeWith.mergeWith(object, ...sources, require_noop.noop); +} +//#endregion +exports.merge = merge; diff --git a/node_modules/es-toolkit/dist/compat/object/merge.mjs b/node_modules/es-toolkit/dist/compat/object/merge.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d4d63f77f823d7e937639bfd333a40229e5ef302 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/merge.mjs @@ -0,0 +1,45 @@ +import { noop } from "../../function/noop.mjs"; +import { mergeWith } from "./mergeWith.mjs"; +//#region src/compat/object/merge.ts +/** +* Merges the properties of one or more source objects into the target object. +* +* This function performs a deep merge, recursively merging nested objects and arrays. +* 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. +* If a property in the source object is `undefined`, it will not overwrite a defined property in the target object. +* +* The function can handle multiple source objects and will merge them all into the target object. +* +* @param object - The target object into which the source object properties will be merged. This object is modified in place. +* @param sources - The source objects whose properties will be merged into the target object. +* @returns The updated target object with properties from the source object(s) merged in. +* +* @example +* const target = { a: 1, b: { x: 1, y: 2 } }; +* const source = { b: { y: 3, z: 4 }, c: 5 }; +* +* const result = merge(target, source); +* console.log(result); +* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 } +* +* @example +* const target = { a: [1, 2], b: { x: 1 } }; +* const source = { a: [3], b: { y: 2 } }; +* +* const result = merge(target, source); +* console.log(result); +* // Output: { a: [3], b: { x: 1, y: 2 } } +* +* @example +* const target = { a: null }; +* const source = { a: [1, 2, 3] }; +* +* const result = merge(target, source); +* console.log(result); +* // Output: { a: [1, 2, 3] } +*/ +function merge(object, ...sources) { + return mergeWith(object, ...sources, noop); +} +//#endregion +export { merge }; diff --git a/node_modules/es-toolkit/dist/compat/object/mergeWith.d.mts b/node_modules/es-toolkit/dist/compat/object/mergeWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b5fb4897fb8c1c2230cd4380c23b94766d47e3ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mergeWith.d.mts @@ -0,0 +1,126 @@ +//#region src/compat/object/mergeWith.d.ts +type MergeWithCustomizer = (objValue: any, srcValue: any, key: string, object: any, source: any, stack: any) => any; +/** + * Merges the properties of a source object into the target object using a customizer function. + * + * @template TObject + * @template TSource + * @param object - The target object into which the source object properties will be merged. + * @param source - The source object whose properties will be merged into the target object. + * @param customizer - The function to customize assigned values. + * @returns Returns the updated target object with properties from the source object merged in. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * + * const result = mergeWith(target, source, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + * } + * }); + * // => { a: 1, b: 5, c: 4 } + */ +declare function mergeWith(object: TObject, source: TSource, customizer: MergeWithCustomizer): TObject & TSource; +/** + * Merges the properties of two source objects into the target object using a customizer function. + * + * @template TObject + * @template TSource1 + * @template TSource2 + * @param object - The target object into which the source objects properties will be merged. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param customizer - The function to customize assigned values. + * @returns Returns the updated target object with properties from the source objects merged in. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * + * const result = mergeWith(target, source1, source2, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + * } + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function mergeWith(object: TObject, source1: TSource1, source2: TSource2, customizer: MergeWithCustomizer): TObject & TSource1 & TSource2; +/** + * Merges the properties of three source objects into the target object using a customizer function. + * + * @template TObject + * @template TSource1 + * @template TSource2 + * @template TSource3 + * @param object - The target object into which the source objects properties will be merged. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param source3 - The third source object. + * @param customizer - The function to customize assigned values. + * @returns Returns the updated target object with properties from the source objects merged in. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * + * const result = mergeWith(target, source1, source2, source3, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + * } + * }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function mergeWith(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, customizer: MergeWithCustomizer): TObject & TSource1 & TSource2 & TSource3; +/** + * Merges the properties of four source objects into the target object using a customizer function. + * + * @template TObject + * @template TSource1 + * @template TSource2 + * @template TSource3 + * @template TSource4 + * @param object - The target object into which the source objects properties will be merged. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param source3 - The third source object. + * @param source4 - The fourth source object. + * @param customizer - The function to customize assigned values. + * @returns Returns the updated target object with properties from the source objects merged in. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * + * const result = mergeWith(target, source1, source2, source3, source4, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + * } + * }); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function mergeWith(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4, customizer: MergeWithCustomizer): TObject & TSource1 & TSource2 & TSource3 & TSource4; +/** + * Merges the properties of one or more source objects into the target object. + * + * @param object - The target object into which the source object properties will be merged. + * @param otherArgs - Additional source objects to merge into the target object, including the custom `merge` function. + * @returns The updated target object with properties from the source object(s) merged in. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * + * const result = mergeWith(target, source, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + */ +declare function mergeWith(object: any, ...otherArgs: any[]): any; +//#endregion +export { mergeWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/mergeWith.d.ts b/node_modules/es-toolkit/dist/compat/object/mergeWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5fb4897fb8c1c2230cd4380c23b94766d47e3ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mergeWith.d.ts @@ -0,0 +1,126 @@ +//#region src/compat/object/mergeWith.d.ts +type MergeWithCustomizer = (objValue: any, srcValue: any, key: string, object: any, source: any, stack: any) => any; +/** + * Merges the properties of a source object into the target object using a customizer function. + * + * @template TObject + * @template TSource + * @param object - The target object into which the source object properties will be merged. + * @param source - The source object whose properties will be merged into the target object. + * @param customizer - The function to customize assigned values. + * @returns Returns the updated target object with properties from the source object merged in. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * + * const result = mergeWith(target, source, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + * } + * }); + * // => { a: 1, b: 5, c: 4 } + */ +declare function mergeWith(object: TObject, source: TSource, customizer: MergeWithCustomizer): TObject & TSource; +/** + * Merges the properties of two source objects into the target object using a customizer function. + * + * @template TObject + * @template TSource1 + * @template TSource2 + * @param object - The target object into which the source objects properties will be merged. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param customizer - The function to customize assigned values. + * @returns Returns the updated target object with properties from the source objects merged in. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * + * const result = mergeWith(target, source1, source2, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + * } + * }); + * // => { a: 1, b: 2, c: 3 } + */ +declare function mergeWith(object: TObject, source1: TSource1, source2: TSource2, customizer: MergeWithCustomizer): TObject & TSource1 & TSource2; +/** + * Merges the properties of three source objects into the target object using a customizer function. + * + * @template TObject + * @template TSource1 + * @template TSource2 + * @template TSource3 + * @param object - The target object into which the source objects properties will be merged. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param source3 - The third source object. + * @param customizer - The function to customize assigned values. + * @returns Returns the updated target object with properties from the source objects merged in. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * + * const result = mergeWith(target, source1, source2, source3, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + * } + * }); + * // => { a: 1, b: 2, c: 3, d: 4 } + */ +declare function mergeWith(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, customizer: MergeWithCustomizer): TObject & TSource1 & TSource2 & TSource3; +/** + * Merges the properties of four source objects into the target object using a customizer function. + * + * @template TObject + * @template TSource1 + * @template TSource2 + * @template TSource3 + * @template TSource4 + * @param object - The target object into which the source objects properties will be merged. + * @param source1 - The first source object. + * @param source2 - The second source object. + * @param source3 - The third source object. + * @param source4 - The fourth source object. + * @param customizer - The function to customize assigned values. + * @returns Returns the updated target object with properties from the source objects merged in. + * + * @example + * const target = { a: 1 }; + * const source1 = { b: 2 }; + * const source2 = { c: 3 }; + * const source3 = { d: 4 }; + * const source4 = { e: 5 }; + * + * const result = mergeWith(target, source1, source2, source3, source4, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + * } + * }); + * // => { a: 1, b: 2, c: 3, d: 4, e: 5 } + */ +declare function mergeWith(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4, customizer: MergeWithCustomizer): TObject & TSource1 & TSource2 & TSource3 & TSource4; +/** + * Merges the properties of one or more source objects into the target object. + * + * @param object - The target object into which the source object properties will be merged. + * @param otherArgs - Additional source objects to merge into the target object, including the custom `merge` function. + * @returns The updated target object with properties from the source object(s) merged in. + * + * @example + * const target = { a: 1, b: 2 }; + * const source = { b: 3, c: 4 }; + * + * const result = mergeWith(target, source, (objValue, srcValue) => { + * if (typeof objValue === 'number' && typeof srcValue === 'number') { + * return objValue + srcValue; + */ +declare function mergeWith(object: any, ...otherArgs: any[]): any; +//#endregion +export { mergeWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/mergeWith.js b/node_modules/es-toolkit/dist/compat/object/mergeWith.js new file mode 100644 index 0000000000000000000000000000000000000000..b618f016eb9a2bc939014fcc098d47793abb6e31 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mergeWith.js @@ -0,0 +1,111 @@ +const require_isPrimitive = require("../../predicate/isPrimitive.js"); +const require_clone = require("../../object/clone.js"); +const require_getSymbols = require("../_internal/getSymbols.js"); +const require_isBuffer = require("../../predicate/isBuffer.js"); +const require_isUnsafeProperty = require("../../_internal/isUnsafeProperty.js"); +const require_isPlainObject = require("../predicate/isPlainObject.js"); +const require_cloneDeep = require("./cloneDeep.js"); +const require_isArguments = require("../predicate/isArguments.js"); +const require_isObjectLike = require("../predicate/isObjectLike.js"); +const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js"); +const require_isTypedArray = require("../predicate/isTypedArray.js"); +//#region src/compat/object/mergeWith.ts +/** +* Merges the properties of one or more source objects into the target object using a customizer function. +* +* This function performs a deep merge, recursively merging nested objects and arrays. +* 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. +* If a property in the source object is `undefined`, it will not overwrite a defined property in the target object. +* +* 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: +* +* - `targetValue`: The current value of the property in the target object. +* - `sourceValue`: The value of the property in the source object. +* - `key`: The key of the property being merged. +* - `target`: The target object. +* - `source`: The source object. +* - `stack`: A `Map` used to keep track of objects that have already been processed to handle circular references. +* +* 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. +* +* The function can handle multiple source objects and will merge them all into the target object. +* +* @param object - The target object into which the source object properties will be merged. This object is modified in place. +* @param otherArgs - Additional source objects to merge into the target object, including the custom `merge` function. +* @returns The updated target object with properties from the source object(s) merged in. +* +* @example +* const target = { a: 1, b: 2 }; +* const source = { b: 3, c: 4 }; +* +* mergeWith(target, source, (targetValue, sourceValue) => { +* if (typeof targetValue === 'number' && typeof sourceValue === 'number') { +* return targetValue + sourceValue; +* } +* }); +* // Returns { a: 1, b: 5, c: 4 } +* @example +* const target = { a: [1], b: [2] }; +* const source = { a: [3], b: [4] }; +* +* const result = mergeWith(target, source, (objValue, srcValue) => { +* if (Array.isArray(objValue)) { +* return objValue.concat(srcValue); +* } +* }); +* +* expect(result).toEqual({ a: [1, 3], b: [2, 4] }); +*/ +function mergeWith(object, ...otherArgs) { + const sources = otherArgs.slice(0, -1); + const merge = otherArgs[otherArgs.length - 1]; + let result = object; + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + result = mergeWithDeep(result, source, merge, /* @__PURE__ */ new Map()); + } + return result; +} +function mergeWithDeep(target, source, merge, stack) { + if (require_isPrimitive.isPrimitive(target)) target = Object(target); + if (source == null || typeof source !== "object") return target; + if (stack.has(source)) return require_clone.clone(stack.get(source)); + stack.set(source, target); + if (Array.isArray(source)) { + source = source.slice(); + for (let i = 0; i < source.length; i++) source[i] = source[i] ?? void 0; + } + const sourceKeys = [...Object.keys(source), ...require_getSymbols.getSymbols(source)]; + for (let i = 0; i < sourceKeys.length; i++) { + const key = sourceKeys[i]; + if (require_isUnsafeProperty.isUnsafeProperty(key)) continue; + let sourceValue = source[key]; + let targetValue = target[key]; + if (require_isArguments.isArguments(sourceValue)) sourceValue = { ...sourceValue }; + if (require_isArguments.isArguments(targetValue)) targetValue = { ...targetValue }; + if (require_isBuffer.isBuffer(sourceValue)) sourceValue = require_cloneDeep.cloneDeep(sourceValue); + if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) { + const cloned = []; + const targetKeys = Reflect.ownKeys(targetValue); + for (let i = 0; i < targetKeys.length; i++) { + const targetKey = targetKeys[i]; + cloned[targetKey] = targetValue[targetKey]; + } + targetValue = cloned; + } else if (require_isArrayLikeObject.isArrayLikeObject(targetValue)) { + const cloned = []; + for (let i = 0; i < targetValue.length; i++) cloned[i] = targetValue[i]; + targetValue = cloned; + } else targetValue = []; + const merged = merge(targetValue, sourceValue, key, target, source, stack); + if (merged !== void 0) target[key] = merged; + else if (Array.isArray(sourceValue)) target[key] = mergeWithDeep(targetValue, sourceValue, merge, stack); + else if (require_isObjectLike.isObjectLike(targetValue) && require_isObjectLike.isObjectLike(sourceValue) && (require_isPlainObject.isPlainObject(targetValue) || require_isPlainObject.isPlainObject(sourceValue) || require_isTypedArray.isTypedArray(targetValue) || require_isTypedArray.isTypedArray(sourceValue))) target[key] = mergeWithDeep(targetValue, sourceValue, merge, stack); + else if (targetValue == null && require_isPlainObject.isPlainObject(sourceValue)) target[key] = mergeWithDeep({}, sourceValue, merge, stack); + else if (targetValue == null && require_isTypedArray.isTypedArray(sourceValue)) target[key] = require_cloneDeep.cloneDeep(sourceValue); + else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue; + } + return target; +} +//#endregion +exports.mergeWith = mergeWith; diff --git a/node_modules/es-toolkit/dist/compat/object/mergeWith.mjs b/node_modules/es-toolkit/dist/compat/object/mergeWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c65e6352e536c6b524865ec553c6d9b11979a8ef --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/mergeWith.mjs @@ -0,0 +1,111 @@ +import { isPrimitive } from "../../predicate/isPrimitive.mjs"; +import { clone } from "../../object/clone.mjs"; +import { getSymbols } from "../_internal/getSymbols.mjs"; +import { isBuffer } from "../../predicate/isBuffer.mjs"; +import { isUnsafeProperty } from "../../_internal/isUnsafeProperty.mjs"; +import { isPlainObject } from "../predicate/isPlainObject.mjs"; +import { cloneDeep } from "./cloneDeep.mjs"; +import { isArguments } from "../predicate/isArguments.mjs"; +import { isObjectLike } from "../predicate/isObjectLike.mjs"; +import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs"; +import { isTypedArray } from "../predicate/isTypedArray.mjs"; +//#region src/compat/object/mergeWith.ts +/** +* Merges the properties of one or more source objects into the target object using a customizer function. +* +* This function performs a deep merge, recursively merging nested objects and arrays. +* 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. +* If a property in the source object is `undefined`, it will not overwrite a defined property in the target object. +* +* 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: +* +* - `targetValue`: The current value of the property in the target object. +* - `sourceValue`: The value of the property in the source object. +* - `key`: The key of the property being merged. +* - `target`: The target object. +* - `source`: The source object. +* - `stack`: A `Map` used to keep track of objects that have already been processed to handle circular references. +* +* 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. +* +* The function can handle multiple source objects and will merge them all into the target object. +* +* @param object - The target object into which the source object properties will be merged. This object is modified in place. +* @param otherArgs - Additional source objects to merge into the target object, including the custom `merge` function. +* @returns The updated target object with properties from the source object(s) merged in. +* +* @example +* const target = { a: 1, b: 2 }; +* const source = { b: 3, c: 4 }; +* +* mergeWith(target, source, (targetValue, sourceValue) => { +* if (typeof targetValue === 'number' && typeof sourceValue === 'number') { +* return targetValue + sourceValue; +* } +* }); +* // Returns { a: 1, b: 5, c: 4 } +* @example +* const target = { a: [1], b: [2] }; +* const source = { a: [3], b: [4] }; +* +* const result = mergeWith(target, source, (objValue, srcValue) => { +* if (Array.isArray(objValue)) { +* return objValue.concat(srcValue); +* } +* }); +* +* expect(result).toEqual({ a: [1, 3], b: [2, 4] }); +*/ +function mergeWith(object, ...otherArgs) { + const sources = otherArgs.slice(0, -1); + const merge = otherArgs[otherArgs.length - 1]; + let result = object; + for (let i = 0; i < sources.length; i++) { + const source = sources[i]; + result = mergeWithDeep(result, source, merge, /* @__PURE__ */ new Map()); + } + return result; +} +function mergeWithDeep(target, source, merge, stack) { + if (isPrimitive(target)) target = Object(target); + if (source == null || typeof source !== "object") return target; + if (stack.has(source)) return clone(stack.get(source)); + stack.set(source, target); + if (Array.isArray(source)) { + source = source.slice(); + for (let i = 0; i < source.length; i++) source[i] = source[i] ?? void 0; + } + const sourceKeys = [...Object.keys(source), ...getSymbols(source)]; + for (let i = 0; i < sourceKeys.length; i++) { + const key = sourceKeys[i]; + if (isUnsafeProperty(key)) continue; + let sourceValue = source[key]; + let targetValue = target[key]; + if (isArguments(sourceValue)) sourceValue = { ...sourceValue }; + if (isArguments(targetValue)) targetValue = { ...targetValue }; + if (isBuffer(sourceValue)) sourceValue = cloneDeep(sourceValue); + if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) { + const cloned = []; + const targetKeys = Reflect.ownKeys(targetValue); + for (let i = 0; i < targetKeys.length; i++) { + const targetKey = targetKeys[i]; + cloned[targetKey] = targetValue[targetKey]; + } + targetValue = cloned; + } else if (isArrayLikeObject(targetValue)) { + const cloned = []; + for (let i = 0; i < targetValue.length; i++) cloned[i] = targetValue[i]; + targetValue = cloned; + } else targetValue = []; + const merged = merge(targetValue, sourceValue, key, target, source, stack); + if (merged !== void 0) target[key] = merged; + else if (Array.isArray(sourceValue)) target[key] = mergeWithDeep(targetValue, sourceValue, merge, stack); + else if (isObjectLike(targetValue) && isObjectLike(sourceValue) && (isPlainObject(targetValue) || isPlainObject(sourceValue) || isTypedArray(targetValue) || isTypedArray(sourceValue))) target[key] = mergeWithDeep(targetValue, sourceValue, merge, stack); + else if (targetValue == null && isPlainObject(sourceValue)) target[key] = mergeWithDeep({}, sourceValue, merge, stack); + else if (targetValue == null && isTypedArray(sourceValue)) target[key] = cloneDeep(sourceValue); + else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue; + } + return target; +} +//#endregion +export { mergeWith }; diff --git a/node_modules/es-toolkit/dist/compat/object/omit.d.mts b/node_modules/es-toolkit/dist/compat/object/omit.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..12c8832b1add25ddf7011cc3d329ea4b59bd9e0f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/omit.d.mts @@ -0,0 +1,46 @@ +import { Many } from "../_internal/Many.mjs"; + +//#region src/compat/object/omit.d.ts +/** + * Creates a new object with specified keys omitted. + * + * @template T - The type of object. + * @template K - The type of keys to omit. + * @param object - The object to omit keys from. + * @param paths - The keys to be omitted from the object. + * @returns A new object with the specified keys omitted. + * + * @example + * omit({ a: 1, b: 2, c: 3 }, 'a', 'c'); + * // => { b: 2 } + */ +declare function omit(object: T | null | undefined, ...paths: K): Pick>; +/** + * Creates a new object with specified keys omitted. + * + * @template T - The type of object. + * @template K - The type of keys to omit. + * @param object - The object to omit keys from. + * @param paths - The keys to be omitted from the object. + * @returns A new object with the specified keys omitted. + * + * @example + * omit({ a: 1, b: 2, c: 3 }, 'a', ['b', 'c']); + * // => {} + */ +declare function omit(object: T | null | undefined, ...paths: Array>): Omit; +/** + * Creates a new object with specified keys omitted. + * + * @template T - The type of object. + * @param object - The object to omit keys from. + * @param paths - The keys to be omitted from the object. + * @returns A new object with the specified keys omitted. + * + * @example + * omit({ a: 1, b: 2, c: 3 }, 'a', 'b'); + * // => { c: 3 } + */ +declare function omit(object: T | null | undefined, ...paths: Array>): Partial; +//#endregion +export { omit }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/omit.d.ts b/node_modules/es-toolkit/dist/compat/object/omit.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0c2594ff4155c85d73789e18e9b294d86c9fbe0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/omit.d.ts @@ -0,0 +1,46 @@ +import { Many } from "../_internal/Many.js"; + +//#region src/compat/object/omit.d.ts +/** + * Creates a new object with specified keys omitted. + * + * @template T - The type of object. + * @template K - The type of keys to omit. + * @param object - The object to omit keys from. + * @param paths - The keys to be omitted from the object. + * @returns A new object with the specified keys omitted. + * + * @example + * omit({ a: 1, b: 2, c: 3 }, 'a', 'c'); + * // => { b: 2 } + */ +declare function omit(object: T | null | undefined, ...paths: K): Pick>; +/** + * Creates a new object with specified keys omitted. + * + * @template T - The type of object. + * @template K - The type of keys to omit. + * @param object - The object to omit keys from. + * @param paths - The keys to be omitted from the object. + * @returns A new object with the specified keys omitted. + * + * @example + * omit({ a: 1, b: 2, c: 3 }, 'a', ['b', 'c']); + * // => {} + */ +declare function omit(object: T | null | undefined, ...paths: Array>): Omit; +/** + * Creates a new object with specified keys omitted. + * + * @template T - The type of object. + * @param object - The object to omit keys from. + * @param paths - The keys to be omitted from the object. + * @returns A new object with the specified keys omitted. + * + * @example + * omit({ a: 1, b: 2, c: 3 }, 'a', 'b'); + * // => { c: 3 } + */ +declare function omit(object: T | null | undefined, ...paths: Array>): Partial; +//#endregion +export { omit }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/omit.js b/node_modules/es-toolkit/dist/compat/object/omit.js new file mode 100644 index 0000000000000000000000000000000000000000..988fe3da3c8c674b9592f77beb134f1eb6d97015 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/omit.js @@ -0,0 +1,78 @@ +const require_isPlainObject = require("../predicate/isPlainObject.js"); +const require_isDeepKey = require("../_internal/isDeepKey.js"); +const require_cloneDeepWith = require("./cloneDeepWith.js"); +const require_flatten = require("../array/flatten.js"); +const require_unset = require("./unset.js"); +const require_keysIn = require("./keysIn.js"); +const require_getSymbolsIn = require("../_internal/getSymbolsIn.js"); +//#region src/compat/object/omit.ts +/** +* Creates a new object with specified keys omitted. +* +* This function takes an object and a variable number of keys, and returns a new object that +* excludes the properties corresponding to the specified keys. Note that keys can be deep. +* +* Deep keys can be specified for keys. +* +* @template T - The type of object. +* @param obj - The object to omit keys from. +* @param keysArr - A variable number of keys to be omitted from the object. +* @returns A new object with the specified keys omitted. +* +* @example +* omit({ a: 1, b: 2, c: 3 }, 'a', 'b'); +* // => { c: 3 } +* +* omit({ a: { b: 1, c: 2 }, d: 3 }, 'a.b', 'd'); +* // => { a: { c: 2 } } +*/ +function omit(obj, ...keysArr) { + if (obj == null) return {}; + keysArr = require_flatten.flatten(keysArr); + const result = cloneInOmit(obj, keysArr); + for (let i = 0; i < keysArr.length; i++) { + let keys = keysArr[i]; + switch (typeof keys) { + case "object": + if (!Array.isArray(keys)) keys = Array.from(keys); + for (let j = 0; j < keys.length; j++) { + const key = keys[j]; + require_unset.unset(result, key); + } + break; + case "string": + case "symbol": + case "number": + require_unset.unset(result, keys); + break; + } + } + return result; +} +function cloneInOmit(obj, keys) { + if (keys.some((key) => Array.isArray(key) || require_isDeepKey.isDeepKey(key))) return deepCloneInOmit(obj); + return shallowCloneInOmit(obj); +} +function shallowCloneInOmit(obj) { + const result = {}; + const keysToCopy = [...require_keysIn.keysIn(obj), ...require_getSymbolsIn.getSymbolsIn(obj)]; + for (let i = 0; i < keysToCopy.length; i++) { + const key = keysToCopy[i]; + result[key] = obj[key]; + } + return result; +} +function deepCloneInOmit(obj) { + const result = {}; + const keysToCopy = [...require_keysIn.keysIn(obj), ...require_getSymbolsIn.getSymbolsIn(obj)]; + for (let i = 0; i < keysToCopy.length; i++) { + const key = keysToCopy[i]; + result[key] = require_cloneDeepWith.cloneDeepWith(obj[key], (valueToClone) => { + if (require_isPlainObject.isPlainObject(valueToClone)) return; + return valueToClone; + }); + } + return result; +} +//#endregion +exports.omit = omit; diff --git a/node_modules/es-toolkit/dist/compat/object/omit.mjs b/node_modules/es-toolkit/dist/compat/object/omit.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c36e53b95085fe6d38a09da8fff27610c2204a95 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/omit.mjs @@ -0,0 +1,78 @@ +import { isPlainObject } from "../predicate/isPlainObject.mjs"; +import { isDeepKey } from "../_internal/isDeepKey.mjs"; +import { cloneDeepWith } from "./cloneDeepWith.mjs"; +import { flatten } from "../array/flatten.mjs"; +import { unset } from "./unset.mjs"; +import { keysIn } from "./keysIn.mjs"; +import { getSymbolsIn } from "../_internal/getSymbolsIn.mjs"; +//#region src/compat/object/omit.ts +/** +* Creates a new object with specified keys omitted. +* +* This function takes an object and a variable number of keys, and returns a new object that +* excludes the properties corresponding to the specified keys. Note that keys can be deep. +* +* Deep keys can be specified for keys. +* +* @template T - The type of object. +* @param obj - The object to omit keys from. +* @param keysArr - A variable number of keys to be omitted from the object. +* @returns A new object with the specified keys omitted. +* +* @example +* omit({ a: 1, b: 2, c: 3 }, 'a', 'b'); +* // => { c: 3 } +* +* omit({ a: { b: 1, c: 2 }, d: 3 }, 'a.b', 'd'); +* // => { a: { c: 2 } } +*/ +function omit(obj, ...keysArr) { + if (obj == null) return {}; + keysArr = flatten(keysArr); + const result = cloneInOmit(obj, keysArr); + for (let i = 0; i < keysArr.length; i++) { + let keys = keysArr[i]; + switch (typeof keys) { + case "object": + if (!Array.isArray(keys)) keys = Array.from(keys); + for (let j = 0; j < keys.length; j++) { + const key = keys[j]; + unset(result, key); + } + break; + case "string": + case "symbol": + case "number": + unset(result, keys); + break; + } + } + return result; +} +function cloneInOmit(obj, keys) { + if (keys.some((key) => Array.isArray(key) || isDeepKey(key))) return deepCloneInOmit(obj); + return shallowCloneInOmit(obj); +} +function shallowCloneInOmit(obj) { + const result = {}; + const keysToCopy = [...keysIn(obj), ...getSymbolsIn(obj)]; + for (let i = 0; i < keysToCopy.length; i++) { + const key = keysToCopy[i]; + result[key] = obj[key]; + } + return result; +} +function deepCloneInOmit(obj) { + const result = {}; + const keysToCopy = [...keysIn(obj), ...getSymbolsIn(obj)]; + for (let i = 0; i < keysToCopy.length; i++) { + const key = keysToCopy[i]; + result[key] = cloneDeepWith(obj[key], (valueToClone) => { + if (isPlainObject(valueToClone)) return; + return valueToClone; + }); + } + return result; +} +//#endregion +export { omit }; diff --git a/node_modules/es-toolkit/dist/compat/object/omitBy.d.mts b/node_modules/es-toolkit/dist/compat/object/omitBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4b07f100f77602644e483a6e528356098753f928 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/omitBy.d.mts @@ -0,0 +1,44 @@ +import { ValueKeyIteratee } from "../_internal/ValueKeyIteratee.mjs"; + +//#region src/compat/object/omitBy.d.ts +/** + * Creates a new object composed of the properties that do not satisfy the predicate function. + * + * @template T + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new object. + * + * @example + * omitBy({ 'a': 1, 'b': '2', 'c': 3 }, isString); + * // => { 'a': 1, 'c': 3 } + */ +declare function omitBy(object: Record | null | undefined, predicate?: ValueKeyIteratee): Record; +/** + * Creates a new object composed of the properties that do not satisfy the predicate function. + * + * @template T + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new object. + * + * @example + * omitBy({ 0: 1, 1: '2', 2: 3 }, isString); + * // => { 0: 1, 2: 3 } + */ +declare function omitBy(object: Record | null | undefined, predicate?: ValueKeyIteratee): Record; +/** + * Creates a new object composed of the properties that do not satisfy the predicate function. + * + * @template T + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new object. + * + * @example + * omitBy({ 'a': 1, 'b': '2', 'c': 3 }, isString); + * // => { 'a': 1, 'c': 3 } + */ +declare function omitBy(object: T | null | undefined, predicate: ValueKeyIteratee): Partial; +//#endregion +export { omitBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/omitBy.d.ts b/node_modules/es-toolkit/dist/compat/object/omitBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5cc3b79377195f95757c0e577f518e9d8acf62a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/omitBy.d.ts @@ -0,0 +1,44 @@ +import { ValueKeyIteratee } from "../_internal/ValueKeyIteratee.js"; + +//#region src/compat/object/omitBy.d.ts +/** + * Creates a new object composed of the properties that do not satisfy the predicate function. + * + * @template T + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new object. + * + * @example + * omitBy({ 'a': 1, 'b': '2', 'c': 3 }, isString); + * // => { 'a': 1, 'c': 3 } + */ +declare function omitBy(object: Record | null | undefined, predicate?: ValueKeyIteratee): Record; +/** + * Creates a new object composed of the properties that do not satisfy the predicate function. + * + * @template T + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new object. + * + * @example + * omitBy({ 0: 1, 1: '2', 2: 3 }, isString); + * // => { 0: 1, 2: 3 } + */ +declare function omitBy(object: Record | null | undefined, predicate?: ValueKeyIteratee): Record; +/** + * Creates a new object composed of the properties that do not satisfy the predicate function. + * + * @template T + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new object. + * + * @example + * omitBy({ 'a': 1, 'b': '2', 'c': 3 }, isString); + * // => { 'a': 1, 'c': 3 } + */ +declare function omitBy(object: T | null | undefined, predicate: ValueKeyIteratee): Partial; +//#endregion +export { omitBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/omitBy.js b/node_modules/es-toolkit/dist/compat/object/omitBy.js new file mode 100644 index 0000000000000000000000000000000000000000..6a6e0daa2041be45962f0a1a59976d1a4a752507 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/omitBy.js @@ -0,0 +1,39 @@ +const require_iteratee = require("../util/iteratee.js"); +const require_isSymbol = require("../predicate/isSymbol.js"); +const require_identity = require("../function/identity.js"); +const require_keysIn = require("./keysIn.js"); +const require_getSymbolsIn = require("../_internal/getSymbolsIn.js"); +//#region src/compat/object/omitBy.ts +/** +* Creates a new object composed of the properties that do not satisfy the predicate function. +* +* This function takes an object and a predicate function, and returns a new object that +* includes only the properties for which the predicate function returns false. +* +* @template T - The type of object. +* @param obj - The object to omit properties from. +* @param shouldOmit - A predicate function that determines +* whether a property should be omitted. It takes the property's value, key, and the source object as arguments and returns `true` +* if the property should be omitted, and `false` otherwise. +* @returns Returns the new object. +* +* @example +* const obj = { a: 1, b: 'omit', c: 3 }; +* const shouldOmit = (value) => typeof value === 'string'; +* const result = omitBy(obj, shouldOmit); +* // result will be { a: 1, c: 3 } +*/ +function omitBy(object, shouldOmit) { + if (object == null) return {}; + const result = {}; + const predicate = require_iteratee.iteratee(shouldOmit ?? require_identity.identity); + const keys = [...require_keysIn.keysIn(object), ...require_getSymbolsIn.getSymbolsIn(object)]; + for (let i = 0; i < keys.length; i++) { + const key = require_isSymbol.isSymbol(keys[i]) ? keys[i] : keys[i].toString(); + const value = object[key]; + if (!predicate(value, key, object)) result[key] = value; + } + return result; +} +//#endregion +exports.omitBy = omitBy; diff --git a/node_modules/es-toolkit/dist/compat/object/omitBy.mjs b/node_modules/es-toolkit/dist/compat/object/omitBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cf2119900825d746b72a67f933e7ff44029af64e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/omitBy.mjs @@ -0,0 +1,39 @@ +import { iteratee } from "../util/iteratee.mjs"; +import { isSymbol } from "../predicate/isSymbol.mjs"; +import { identity } from "../function/identity.mjs"; +import { keysIn } from "./keysIn.mjs"; +import { getSymbolsIn } from "../_internal/getSymbolsIn.mjs"; +//#region src/compat/object/omitBy.ts +/** +* Creates a new object composed of the properties that do not satisfy the predicate function. +* +* This function takes an object and a predicate function, and returns a new object that +* includes only the properties for which the predicate function returns false. +* +* @template T - The type of object. +* @param obj - The object to omit properties from. +* @param shouldOmit - A predicate function that determines +* whether a property should be omitted. It takes the property's value, key, and the source object as arguments and returns `true` +* if the property should be omitted, and `false` otherwise. +* @returns Returns the new object. +* +* @example +* const obj = { a: 1, b: 'omit', c: 3 }; +* const shouldOmit = (value) => typeof value === 'string'; +* const result = omitBy(obj, shouldOmit); +* // result will be { a: 1, c: 3 } +*/ +function omitBy(object, shouldOmit) { + if (object == null) return {}; + const result = {}; + const predicate = iteratee(shouldOmit ?? identity); + const keys = [...keysIn(object), ...getSymbolsIn(object)]; + for (let i = 0; i < keys.length; i++) { + const key = isSymbol(keys[i]) ? keys[i] : keys[i].toString(); + const value = object[key]; + if (!predicate(value, key, object)) result[key] = value; + } + return result; +} +//#endregion +export { omitBy }; diff --git a/node_modules/es-toolkit/dist/compat/object/pick.d.mts b/node_modules/es-toolkit/dist/compat/object/pick.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..858c3996af4a82a8cfcf61f9c57c98c0ad6f50ad --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/pick.d.mts @@ -0,0 +1,35 @@ +import { Many } from "../_internal/Many.mjs"; +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/pick.d.ts +/** + * Creates a new object composed of the picked object properties. + * + * @template T - The type of object. + * @template U - The type of keys to pick. + * @param object - The object to pick keys from. + * @param props - An array of keys to be picked from the object. + * @returns A new object with the specified keys picked. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * const result = pick(obj, ['a', 'c']); + * // result will be { a: 1, c: 3 } + */ +declare function pick(object: T, ...props: Array>): Pick; +/** + * Creates a new object composed of the picked object properties. + * + * @template T - The type of object. + * @param object - The object to pick keys from. + * @param props - An array of keys to be picked from the object. + * @returns A new object with the specified keys picked. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * const result = pick(obj, ['a', 'c']); + * // result will be { a: 1, c: 3 } + */ +declare function pick(object: T | null | undefined, ...props: Array>): Partial; +//#endregion +export { pick }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/pick.d.ts b/node_modules/es-toolkit/dist/compat/object/pick.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..787fec844a74afe20f63d3b7fbc01f69f0f703b2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/pick.d.ts @@ -0,0 +1,35 @@ +import { Many } from "../_internal/Many.js"; +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/pick.d.ts +/** + * Creates a new object composed of the picked object properties. + * + * @template T - The type of object. + * @template U - The type of keys to pick. + * @param object - The object to pick keys from. + * @param props - An array of keys to be picked from the object. + * @returns A new object with the specified keys picked. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * const result = pick(obj, ['a', 'c']); + * // result will be { a: 1, c: 3 } + */ +declare function pick(object: T, ...props: Array>): Pick; +/** + * Creates a new object composed of the picked object properties. + * + * @template T - The type of object. + * @param object - The object to pick keys from. + * @param props - An array of keys to be picked from the object. + * @returns A new object with the specified keys picked. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * const result = pick(obj, ['a', 'c']); + * // result will be { a: 1, c: 3 } + */ +declare function pick(object: T | null | undefined, ...props: Array>): Partial; +//#endregion +export { pick }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/pick.js b/node_modules/es-toolkit/dist/compat/object/pick.js new file mode 100644 index 0000000000000000000000000000000000000000..bc0c5e18ea3cd9e96d6309aba08145d869be5213 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/pick.js @@ -0,0 +1,60 @@ +const require_isArrayLike = require("../predicate/isArrayLike.js"); +const require_get = require("./get.js"); +const require_has = require("./has.js"); +const require_isNil = require("../predicate/isNil.js"); +const require_set = require("./set.js"); +//#region src/compat/object/pick.ts +/** +* Creates a new object composed of the picked object properties. +* +* This function takes an object and an array of keys, and returns a new object that +* includes only the properties corresponding to the specified keys. +* +* @template T - The type of object. +* @template U - The type of keys to pick. +* @param object - The object to pick keys from. +* @param props - An array of keys to be picked from the object. received keys goes through a flattening process before being used. +* @returns A new object with the specified keys picked. +* +* @example +* const obj = { a: 1, b: 2, c: 3 }; +* const result = pick(obj, ['a', 'c']); +* // result will be { a: 1, c: 3 } +* +* // each path can be passed individually as an argument +* const obj = { a: 1, b: 2, c: 3 }; +* const result = pick(obj, 'a', 'c'); +* // result will be { a: 1, c: 3 } +* +* // pick a key over a path +* const obj = { 'a.b': 1, a: { b: 2 } }; +* const result = pick(obj, 'a.b'); +* // result will be { 'a.b': 1 } +*/ +function pick(object, ...keysArr) { + if (require_isNil.isNil(object)) return {}; + const result = {}; + for (let i = 0; i < keysArr.length; i++) { + let keys = keysArr[i]; + switch (typeof keys) { + case "object": + if (!Array.isArray(keys)) if (require_isArrayLike.isArrayLike(keys)) keys = Array.from(keys); + else keys = [keys]; + break; + case "string": + case "symbol": + case "number": + keys = [keys]; + break; + } + for (const key of keys) { + const value = require_get.get(object, key); + if (value === void 0 && !require_has.has(object, key)) continue; + if (typeof key === "string" && Object.hasOwn(object, key)) result[key] = object[key]; + else require_set.set(result, key, value); + } + } + return result; +} +//#endregion +exports.pick = pick; diff --git a/node_modules/es-toolkit/dist/compat/object/pick.mjs b/node_modules/es-toolkit/dist/compat/object/pick.mjs new file mode 100644 index 0000000000000000000000000000000000000000..780266e0331e4e4590b028d3359ed13cb83c981f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/pick.mjs @@ -0,0 +1,60 @@ +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +import { get } from "./get.mjs"; +import { has } from "./has.mjs"; +import { isNil } from "../predicate/isNil.mjs"; +import { set } from "./set.mjs"; +//#region src/compat/object/pick.ts +/** +* Creates a new object composed of the picked object properties. +* +* This function takes an object and an array of keys, and returns a new object that +* includes only the properties corresponding to the specified keys. +* +* @template T - The type of object. +* @template U - The type of keys to pick. +* @param object - The object to pick keys from. +* @param props - An array of keys to be picked from the object. received keys goes through a flattening process before being used. +* @returns A new object with the specified keys picked. +* +* @example +* const obj = { a: 1, b: 2, c: 3 }; +* const result = pick(obj, ['a', 'c']); +* // result will be { a: 1, c: 3 } +* +* // each path can be passed individually as an argument +* const obj = { a: 1, b: 2, c: 3 }; +* const result = pick(obj, 'a', 'c'); +* // result will be { a: 1, c: 3 } +* +* // pick a key over a path +* const obj = { 'a.b': 1, a: { b: 2 } }; +* const result = pick(obj, 'a.b'); +* // result will be { 'a.b': 1 } +*/ +function pick(object, ...keysArr) { + if (isNil(object)) return {}; + const result = {}; + for (let i = 0; i < keysArr.length; i++) { + let keys = keysArr[i]; + switch (typeof keys) { + case "object": + if (!Array.isArray(keys)) if (isArrayLike(keys)) keys = Array.from(keys); + else keys = [keys]; + break; + case "string": + case "symbol": + case "number": + keys = [keys]; + break; + } + for (const key of keys) { + const value = get(object, key); + if (value === void 0 && !has(object, key)) continue; + if (typeof key === "string" && Object.hasOwn(object, key)) result[key] = object[key]; + else set(result, key, value); + } + } + return result; +} +//#endregion +export { pick }; diff --git a/node_modules/es-toolkit/dist/compat/object/pickBy.d.mts b/node_modules/es-toolkit/dist/compat/object/pickBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..63b7b6863ac370486814984cb17f614433f14d6d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/pickBy.d.mts @@ -0,0 +1,81 @@ +import { ValueKeyIteratee } from "../_internal/ValueKeyIteratee.mjs"; +import { ValueKeyIterateeTypeGuard } from "../_internal/ValueKeyIterateeTypeGuard.mjs"; + +//#region src/compat/object/pickBy.d.ts +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object values. + * @template S - The type of filtered values. + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const users = { + * 'fred': { 'user': 'fred', 'age': 40 }, + * 'pebbles': { 'user': 'pebbles', 'age': 1 } + * }; + * pickBy(users, ({ age }) => age < 40); + * // => { 'pebbles': { 'user': 'pebbles', 'age': 1 } } + */ +declare function pickBy(object: Record | null | undefined, predicate: ValueKeyIterateeTypeGuard): Record; +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object values. + * @template S - The type of filtered values. + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const array = [1, 2, 3, 4]; + * pickBy(array, (value) => value % 2 === 0); + * // => { 1: 2, 3: 4 } + */ +declare function pickBy(object: Record | null | undefined, predicate: ValueKeyIterateeTypeGuard): Record; +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object values. + * @param object - The source object. + * @param [predicate] - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const object = { 'a': 1, 'b': '2', 'c': 3 }; + * pickBy(object, (value) => typeof value === 'string'); + * // => { 'b': '2' } + */ +declare function pickBy(object: Record | null | undefined, predicate?: ValueKeyIteratee): Record; +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object values. + * @param object - The source object. + * @param [predicate] - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const array = [1, 2, 3, 4]; + * pickBy(array, (value) => value > 2); + * // => { 2: 3, 3: 4 } + */ +declare function pickBy(object: Record | null | undefined, predicate?: ValueKeyIteratee): Record; +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object. + * @param object - The source object. + * @param [predicate] - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const object = { 'a': 1, 'b': '2', 'c': 3 }; + * pickBy(object, (value) => typeof value === 'string'); + * // => { 'b': '2' } + */ +declare function pickBy(object: T | null | undefined, predicate?: ValueKeyIteratee): Partial; +//#endregion +export { pickBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/pickBy.d.ts b/node_modules/es-toolkit/dist/compat/object/pickBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..07f5aa0f5d21785eb306f38dd08c49876b224c4a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/pickBy.d.ts @@ -0,0 +1,81 @@ +import { ValueKeyIteratee } from "../_internal/ValueKeyIteratee.js"; +import { ValueKeyIterateeTypeGuard } from "../_internal/ValueKeyIterateeTypeGuard.js"; + +//#region src/compat/object/pickBy.d.ts +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object values. + * @template S - The type of filtered values. + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const users = { + * 'fred': { 'user': 'fred', 'age': 40 }, + * 'pebbles': { 'user': 'pebbles', 'age': 1 } + * }; + * pickBy(users, ({ age }) => age < 40); + * // => { 'pebbles': { 'user': 'pebbles', 'age': 1 } } + */ +declare function pickBy(object: Record | null | undefined, predicate: ValueKeyIterateeTypeGuard): Record; +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object values. + * @template S - The type of filtered values. + * @param object - The source object. + * @param predicate - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const array = [1, 2, 3, 4]; + * pickBy(array, (value) => value % 2 === 0); + * // => { 1: 2, 3: 4 } + */ +declare function pickBy(object: Record | null | undefined, predicate: ValueKeyIterateeTypeGuard): Record; +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object values. + * @param object - The source object. + * @param [predicate] - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const object = { 'a': 1, 'b': '2', 'c': 3 }; + * pickBy(object, (value) => typeof value === 'string'); + * // => { 'b': '2' } + */ +declare function pickBy(object: Record | null | undefined, predicate?: ValueKeyIteratee): Record; +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object values. + * @param object - The source object. + * @param [predicate] - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const array = [1, 2, 3, 4]; + * pickBy(array, (value) => value > 2); + * // => { 2: 3, 3: 4 } + */ +declare function pickBy(object: Record | null | undefined, predicate?: ValueKeyIteratee): Record; +/** + * Creates a new object composed of the properties that satisfy the predicate function. + * + * @template T - The type of object. + * @param object - The source object. + * @param [predicate] - The function invoked per property. + * @returns Returns the new filtered object. + * + * @example + * const object = { 'a': 1, 'b': '2', 'c': 3 }; + * pickBy(object, (value) => typeof value === 'string'); + * // => { 'b': '2' } + */ +declare function pickBy(object: T | null | undefined, predicate?: ValueKeyIteratee): Partial; +//#endregion +export { pickBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/pickBy.js b/node_modules/es-toolkit/dist/compat/object/pickBy.js new file mode 100644 index 0000000000000000000000000000000000000000..644432f457625f62b5e60afa3e9e637412054431 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/pickBy.js @@ -0,0 +1,41 @@ +const require_range = require("../../math/range.js"); +const require_isArrayLike = require("../predicate/isArrayLike.js"); +const require_iteratee = require("../util/iteratee.js"); +const require_isSymbol = require("../predicate/isSymbol.js"); +const require_identity = require("../function/identity.js"); +const require_keysIn = require("./keysIn.js"); +const require_getSymbolsIn = require("../_internal/getSymbolsIn.js"); +//#region src/compat/object/pickBy.ts +/** +* Creates a new object composed of the properties that satisfy the predicate function. +* +* This function takes an object and a predicate function, and returns a new object that +* includes only the properties for which the predicate function returns true. +* +* @template T - The type of object. +* @param obj - The object to pick properties from. +* @param [shouldPick] - A predicate function that determines +* whether a property should be picked. It takes the property's key and value as arguments and returns `true` +* if the property should be picked, and `false` otherwise. +* @returns A new object with the properties that satisfy the predicate function. +* +* @example +* const obj = { a: 1, b: 'pick', c: 3 }; +* const shouldPick = (value) => typeof value === 'string'; +* const result = pickBy(obj, shouldPick); +* // result will be { b: 'pick' } +*/ +function pickBy(obj, shouldPick) { + if (obj == null) return {}; + const predicate = require_iteratee.iteratee(shouldPick ?? require_identity.identity); + const result = {}; + const keys = require_isArrayLike.isArrayLike(obj) ? require_range.range(0, obj.length) : [...require_keysIn.keysIn(obj), ...require_getSymbolsIn.getSymbolsIn(obj)]; + for (let i = 0; i < keys.length; i++) { + const key = require_isSymbol.isSymbol(keys[i]) ? keys[i] : keys[i].toString(); + const value = obj[key]; + if (predicate(value, key, obj)) result[key] = value; + } + return result; +} +//#endregion +exports.pickBy = pickBy; diff --git a/node_modules/es-toolkit/dist/compat/object/pickBy.mjs b/node_modules/es-toolkit/dist/compat/object/pickBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ecc65d5a06a40a345a6d40ecf06bef15b8955e0e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/pickBy.mjs @@ -0,0 +1,41 @@ +import { range } from "../../math/range.mjs"; +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +import { isSymbol } from "../predicate/isSymbol.mjs"; +import { identity } from "../function/identity.mjs"; +import { keysIn } from "./keysIn.mjs"; +import { getSymbolsIn } from "../_internal/getSymbolsIn.mjs"; +//#region src/compat/object/pickBy.ts +/** +* Creates a new object composed of the properties that satisfy the predicate function. +* +* This function takes an object and a predicate function, and returns a new object that +* includes only the properties for which the predicate function returns true. +* +* @template T - The type of object. +* @param obj - The object to pick properties from. +* @param [shouldPick] - A predicate function that determines +* whether a property should be picked. It takes the property's key and value as arguments and returns `true` +* if the property should be picked, and `false` otherwise. +* @returns A new object with the properties that satisfy the predicate function. +* +* @example +* const obj = { a: 1, b: 'pick', c: 3 }; +* const shouldPick = (value) => typeof value === 'string'; +* const result = pickBy(obj, shouldPick); +* // result will be { b: 'pick' } +*/ +function pickBy(obj, shouldPick) { + if (obj == null) return {}; + const predicate = iteratee(shouldPick ?? identity); + const result = {}; + const keys = isArrayLike(obj) ? range(0, obj.length) : [...keysIn(obj), ...getSymbolsIn(obj)]; + for (let i = 0; i < keys.length; i++) { + const key = isSymbol(keys[i]) ? keys[i] : keys[i].toString(); + const value = obj[key]; + if (predicate(value, key, obj)) result[key] = value; + } + return result; +} +//#endregion +export { pickBy }; diff --git a/node_modules/es-toolkit/dist/compat/object/property.d.mts b/node_modules/es-toolkit/dist/compat/object/property.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..adf340d660d9845f72a3edec7f7870dabdfa18bf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/property.d.mts @@ -0,0 +1,6 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/property.d.ts +declare function property(path: PropertyPath): (obj: T) => R; +//#endregion +export { property }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/property.d.ts b/node_modules/es-toolkit/dist/compat/object/property.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..507c08a1e3dc75fc3ee300bed723b0190dfee171 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/property.d.ts @@ -0,0 +1,6 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/property.d.ts +declare function property(path: PropertyPath): (obj: T) => R; +//#endregion +export { property }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/property.js b/node_modules/es-toolkit/dist/compat/object/property.js new file mode 100644 index 0000000000000000000000000000000000000000..f1725989dd47c57b3a4ab7e94ae8c745f7cac49c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/property.js @@ -0,0 +1,27 @@ +const require_get = require("./get.js"); +//#region src/compat/object/property.ts +/** +* Creates a function that returns the value at a given path of an object. +* +* @template T - The type of object. +* @template R - The type of the value to return. +* @param path - The path of the property to get. +* @returns Returns a new function that takes an object and returns the value at the specified path. +* +* @example +* const getObjectValue = property('a.b.c'); +* const result = getObjectValue({ a: { b: { c: 3 } } }); +* console.log(result); // => 3 +* +* @example +* const getObjectValue = property(['a', 'b', 'c']); +* const result = getObjectValue({ a: { b: { c: 3 } } }); +* console.log(result); // => 3 +*/ +function property(path) { + return function(object) { + return require_get.get(object, path); + }; +} +//#endregion +exports.property = property; diff --git a/node_modules/es-toolkit/dist/compat/object/property.mjs b/node_modules/es-toolkit/dist/compat/object/property.mjs new file mode 100644 index 0000000000000000000000000000000000000000..99a255f6c78086ea409abd87205846fbf4eca6d6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/property.mjs @@ -0,0 +1,27 @@ +import { get } from "./get.mjs"; +//#region src/compat/object/property.ts +/** +* Creates a function that returns the value at a given path of an object. +* +* @template T - The type of object. +* @template R - The type of the value to return. +* @param path - The path of the property to get. +* @returns Returns a new function that takes an object and returns the value at the specified path. +* +* @example +* const getObjectValue = property('a.b.c'); +* const result = getObjectValue({ a: { b: { c: 3 } } }); +* console.log(result); // => 3 +* +* @example +* const getObjectValue = property(['a', 'b', 'c']); +* const result = getObjectValue({ a: { b: { c: 3 } } }); +* console.log(result); // => 3 +*/ +function property(path) { + return function(object) { + return get(object, path); + }; +} +//#endregion +export { property }; diff --git a/node_modules/es-toolkit/dist/compat/object/propertyOf.d.mts b/node_modules/es-toolkit/dist/compat/object/propertyOf.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c3160dcd5a91b99c015ea1217c961770a9b86eaf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/propertyOf.d.mts @@ -0,0 +1,6 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/propertyOf.d.ts +declare function propertyOf(object: T): (path: PropertyPath) => any; +//#endregion +export { propertyOf }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/propertyOf.d.ts b/node_modules/es-toolkit/dist/compat/object/propertyOf.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bda9eb59430bd55e98d15aea6a364a7d48cd3f2e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/propertyOf.d.ts @@ -0,0 +1,6 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/propertyOf.d.ts +declare function propertyOf(object: T): (path: PropertyPath) => any; +//#endregion +export { propertyOf }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/propertyOf.js b/node_modules/es-toolkit/dist/compat/object/propertyOf.js new file mode 100644 index 0000000000000000000000000000000000000000..8670d53e43566f685558c1906f5b2841e08a99ee --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/propertyOf.js @@ -0,0 +1,29 @@ +const require_get = require("./get.js"); +//#region src/compat/object/propertyOf.ts +/** +* Creates a function that returns the value at a given path of an object. +* +* Unlike `property`, which creates a function bound to a specific path and allows you to query different objects, +* `propertyOf` creates a function bound to a specific object and allows you to query different paths within that object. +* +* @template T - The type of object. +* @param object - The object to query. +* @returns Returns a new function that takes a path and retrieves the value from the object at the specified path. +* +* @example +* const getValue = propertyOf({ a: { b: { c: 3 } } }); +* const result = getValue('a.b.c'); +* console.log(result); // => 3 +* +* @example +* const getValue = propertyOf({ a: { b: { c: 3 } } }); +* const result = getValue(['a', 'b', 'c']); +* console.log(result); // => 3 +*/ +function propertyOf(object) { + return function(path) { + return require_get.get(object, path); + }; +} +//#endregion +exports.propertyOf = propertyOf; diff --git a/node_modules/es-toolkit/dist/compat/object/propertyOf.mjs b/node_modules/es-toolkit/dist/compat/object/propertyOf.mjs new file mode 100644 index 0000000000000000000000000000000000000000..05d1fbf83eb61f95f6191b8d57afd7e707932ddd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/propertyOf.mjs @@ -0,0 +1,29 @@ +import { get } from "./get.mjs"; +//#region src/compat/object/propertyOf.ts +/** +* Creates a function that returns the value at a given path of an object. +* +* Unlike `property`, which creates a function bound to a specific path and allows you to query different objects, +* `propertyOf` creates a function bound to a specific object and allows you to query different paths within that object. +* +* @template T - The type of object. +* @param object - The object to query. +* @returns Returns a new function that takes a path and retrieves the value from the object at the specified path. +* +* @example +* const getValue = propertyOf({ a: { b: { c: 3 } } }); +* const result = getValue('a.b.c'); +* console.log(result); // => 3 +* +* @example +* const getValue = propertyOf({ a: { b: { c: 3 } } }); +* const result = getValue(['a', 'b', 'c']); +* console.log(result); // => 3 +*/ +function propertyOf(object) { + return function(path) { + return get(object, path); + }; +} +//#endregion +export { propertyOf }; diff --git a/node_modules/es-toolkit/dist/compat/object/result.d.mts b/node_modules/es-toolkit/dist/compat/object/result.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..5c295b4f1fd26527b43e2ce9d8d51a071035bb39 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/result.d.mts @@ -0,0 +1,38 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/result.d.ts +/** + * Retrieves the value at a given path of an object. + * If the resolved value is a function, it is invoked with the object as its `this` context. + * If the value is `undefined`, the `defaultValue` is returned. + * + * @template T - The type of object. + * @template R - The type of the value to return. + * @param object - The object to query. + * @param path - The path of the property to get. + * @param [defaultValue] - The value returned if the resolved value is `undefined`. + * @returns Returns the resolved value. + * + * @example + * const obj = { a: { b: { c: 3 } } }; + * result(obj, 'a.b.c'); + * // => 3 + * + * @example + * const obj = { a: () => 5 }; + * result(obj, 'a'); + * // => 5 (calls the function `a` and returns its result) + * + * @example + * const obj = { a: { b: null } }; + * result(obj, 'a.b.c', 'default'); + * // => 'default' + * + * @example + * const obj = { a: { b: { c: 3 } } }; + * result(obj, 'a.b.d', () => 'default'); + * // => 'default' + */ +declare function result(object: any, path: PropertyPath, defaultValue?: R | ((...args: any[]) => R)): R; +//#endregion +export { result }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/result.d.ts b/node_modules/es-toolkit/dist/compat/object/result.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e60fbc0dc06958b886638d04cb5b2ae473c0e22 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/result.d.ts @@ -0,0 +1,38 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/result.d.ts +/** + * Retrieves the value at a given path of an object. + * If the resolved value is a function, it is invoked with the object as its `this` context. + * If the value is `undefined`, the `defaultValue` is returned. + * + * @template T - The type of object. + * @template R - The type of the value to return. + * @param object - The object to query. + * @param path - The path of the property to get. + * @param [defaultValue] - The value returned if the resolved value is `undefined`. + * @returns Returns the resolved value. + * + * @example + * const obj = { a: { b: { c: 3 } } }; + * result(obj, 'a.b.c'); + * // => 3 + * + * @example + * const obj = { a: () => 5 }; + * result(obj, 'a'); + * // => 5 (calls the function `a` and returns its result) + * + * @example + * const obj = { a: { b: null } }; + * result(obj, 'a.b.c', 'default'); + * // => 'default' + * + * @example + * const obj = { a: { b: { c: 3 } } }; + * result(obj, 'a.b.d', () => 'default'); + * // => 'default' + */ +declare function result(object: any, path: PropertyPath, defaultValue?: R | ((...args: any[]) => R)): R; +//#endregion +export { result }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/result.js b/node_modules/es-toolkit/dist/compat/object/result.js new file mode 100644 index 0000000000000000000000000000000000000000..354526b0660f4b7b54327afbb06a47ee8b60d298 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/result.js @@ -0,0 +1,50 @@ +const require_toKey = require("../_internal/toKey.js"); +const require_toString = require("../util/toString.js"); +const require_toPath = require("../util/toPath.js"); +const require_isKey = require("../_internal/isKey.js"); +//#region src/compat/object/result.ts +/** +* Retrieves the value at a given path of an object. +* If the resolved value is a function, it is invoked with the object as its `this` context. +* If the value is `undefined`, the `defaultValue` is returned. +* +* @template T - The type of object. +* @template R - The type of the value to return. +* @param object - The object to query. +* @param path - The path of the property to get. +* @param [defaultValue] - The value returned if the resolved value is `undefined`. +* @returns Returns the resolved value. +* +* @example +* const obj = { a: { b: { c: 3 } } }; +* result(obj, 'a.b.c'); +* // => 3 +* +* @example +* const obj = { a: () => 5 }; +* result(obj, 'a'); +* // => 5 (calls the function `a` and returns its result) +* +* @example +* const obj = { a: { b: null } }; +* result(obj, 'a.b.c', 'default'); +* // => 'default' +* +* @example +* const obj = { a: { b: { c: 3 } } }; +* result(obj, 'a.b.d', () => 'default'); +* // => 'default' +*/ +function result(object, path, defaultValue) { + if (require_isKey.isKey(path, object)) path = [path]; + else if (!Array.isArray(path)) path = require_toPath.toPath(require_toString.toString(path)); + const pathLength = Math.max(path.length, 1); + for (let index = 0; index < pathLength; index++) { + const value = object == null ? void 0 : object[require_toKey.toKey(path[index])]; + if (value === void 0) return typeof defaultValue === "function" ? defaultValue.call(object) : defaultValue; + object = typeof value === "function" ? value.call(object) : value; + } + return object; +} +//#endregion +exports.result = result; diff --git a/node_modules/es-toolkit/dist/compat/object/result.mjs b/node_modules/es-toolkit/dist/compat/object/result.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3ee4541632edfdc9f650b639e2381911c63512ec --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/result.mjs @@ -0,0 +1,50 @@ +import { toKey } from "../_internal/toKey.mjs"; +import { toString } from "../util/toString.mjs"; +import { toPath } from "../util/toPath.mjs"; +import { isKey } from "../_internal/isKey.mjs"; +//#region src/compat/object/result.ts +/** +* Retrieves the value at a given path of an object. +* If the resolved value is a function, it is invoked with the object as its `this` context. +* If the value is `undefined`, the `defaultValue` is returned. +* +* @template T - The type of object. +* @template R - The type of the value to return. +* @param object - The object to query. +* @param path - The path of the property to get. +* @param [defaultValue] - The value returned if the resolved value is `undefined`. +* @returns Returns the resolved value. +* +* @example +* const obj = { a: { b: { c: 3 } } }; +* result(obj, 'a.b.c'); +* // => 3 +* +* @example +* const obj = { a: () => 5 }; +* result(obj, 'a'); +* // => 5 (calls the function `a` and returns its result) +* +* @example +* const obj = { a: { b: null } }; +* result(obj, 'a.b.c', 'default'); +* // => 'default' +* +* @example +* const obj = { a: { b: { c: 3 } } }; +* result(obj, 'a.b.d', () => 'default'); +* // => 'default' +*/ +function result(object, path, defaultValue) { + if (isKey(path, object)) path = [path]; + else if (!Array.isArray(path)) path = toPath(toString(path)); + const pathLength = Math.max(path.length, 1); + for (let index = 0; index < pathLength; index++) { + const value = object == null ? void 0 : object[toKey(path[index])]; + if (value === void 0) return typeof defaultValue === "function" ? defaultValue.call(object) : defaultValue; + object = typeof value === "function" ? value.call(object) : value; + } + return object; +} +//#endregion +export { result }; diff --git a/node_modules/es-toolkit/dist/compat/object/set.d.mts b/node_modules/es-toolkit/dist/compat/object/set.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1ba0b42c19901b207453a6abaa837f04dcdc558e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/set.d.mts @@ -0,0 +1,61 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/set.d.ts +/** + * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created. + * + * @template T - The type of the object. + * @param object - The object to modify. + * @param path - The path of the property to set. + * @param value - The value to set. + * @returns The modified object. + * + * @example + * // Set a value in a nested object + * const obj = { a: { b: { c: 3 } } }; + * set(obj, 'a.b.c', 4); + * console.log(obj.a.b.c); // 4 + * + * @example + * // Set a value in an array + * const arr = [1, 2, 3]; + * set(arr, 1, 4); + * console.log(arr[1]); // 4 + * + * @example + * // Create non-existent path and set value + * const obj = {}; + * set(obj, 'a.b.c', 4); + * console.log(obj); // { a: { b: { c: 4 } } } + */ +declare function set(object: T, path: PropertyPath, value: any): T; +/** + * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created. + * + * @template R - The return type. + * @param object - The object to modify. + * @param path - The path of the property to set. + * @param value - The value to set. + * @returns The modified object. + * + * @example + * // Set a value in a nested object + * const obj = { a: { b: { c: 3 } } }; + * set(obj, 'a.b.c', 4); + * console.log(obj.a.b.c); // 4 + * + * @example + * // Set a value in an array + * const arr = [1, 2, 3]; + * set(arr, 1, 4); + * console.log(arr[1]); // 4 + * + * @example + * // Create non-existent path and set value + * const obj = {}; + * set(obj, 'a.b.c', 4); + * console.log(obj); // { a: { b: { c: 4 } } } + */ +declare function set(object: object, path: PropertyPath, value: any): R; +//#endregion +export { set }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/set.d.ts b/node_modules/es-toolkit/dist/compat/object/set.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b36d0944cf5c4b264d4edc21a7b65f33387ec9a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/set.d.ts @@ -0,0 +1,61 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/set.d.ts +/** + * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created. + * + * @template T - The type of the object. + * @param object - The object to modify. + * @param path - The path of the property to set. + * @param value - The value to set. + * @returns The modified object. + * + * @example + * // Set a value in a nested object + * const obj = { a: { b: { c: 3 } } }; + * set(obj, 'a.b.c', 4); + * console.log(obj.a.b.c); // 4 + * + * @example + * // Set a value in an array + * const arr = [1, 2, 3]; + * set(arr, 1, 4); + * console.log(arr[1]); // 4 + * + * @example + * // Create non-existent path and set value + * const obj = {}; + * set(obj, 'a.b.c', 4); + * console.log(obj); // { a: { b: { c: 4 } } } + */ +declare function set(object: T, path: PropertyPath, value: any): T; +/** + * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created. + * + * @template R - The return type. + * @param object - The object to modify. + * @param path - The path of the property to set. + * @param value - The value to set. + * @returns The modified object. + * + * @example + * // Set a value in a nested object + * const obj = { a: { b: { c: 3 } } }; + * set(obj, 'a.b.c', 4); + * console.log(obj.a.b.c); // 4 + * + * @example + * // Set a value in an array + * const arr = [1, 2, 3]; + * set(arr, 1, 4); + * console.log(arr[1]); // 4 + * + * @example + * // Create non-existent path and set value + * const obj = {}; + * set(obj, 'a.b.c', 4); + * console.log(obj); // { a: { b: { c: 4 } } } + */ +declare function set(object: object, path: PropertyPath, value: any): R; +//#endregion +export { set }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/set.js b/node_modules/es-toolkit/dist/compat/object/set.js new file mode 100644 index 0000000000000000000000000000000000000000..fe86fd503962961b2494e0a8c440bdccd9841b0c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/set.js @@ -0,0 +1,34 @@ +const require_updateWith = require("./updateWith.js"); +//#region src/compat/object/set.ts +/** +* Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created. +* +* @template T - The type of the object. +* @param obj - The object to modify. +* @param path - The path of the property to set. +* @param value - The value to set. +* @returns The modified object. +* +* @example +* // Set a value in a nested object +* const obj = { a: { b: { c: 3 } } }; +* set(obj, 'a.b.c', 4); +* console.log(obj.a.b.c); // 4 +* +* @example +* // Set a value in an array +* const arr = [1, 2, 3]; +* set(arr, 1, 4); +* console.log(arr[1]); // 4 +* +* @example +* // Create non-existent path and set value +* const obj = {}; +* set(obj, 'a.b.c', 4); +* console.log(obj); // { a: { b: { c: 4 } } } +*/ +function set(obj, path, value) { + return require_updateWith.updateWith(obj, path, () => value, () => void 0); +} +//#endregion +exports.set = set; diff --git a/node_modules/es-toolkit/dist/compat/object/set.mjs b/node_modules/es-toolkit/dist/compat/object/set.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b9fe202d7df46a8d26fe4b9585de14b0d54d57d3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/set.mjs @@ -0,0 +1,34 @@ +import { updateWith } from "./updateWith.mjs"; +//#region src/compat/object/set.ts +/** +* Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created. +* +* @template T - The type of the object. +* @param obj - The object to modify. +* @param path - The path of the property to set. +* @param value - The value to set. +* @returns The modified object. +* +* @example +* // Set a value in a nested object +* const obj = { a: { b: { c: 3 } } }; +* set(obj, 'a.b.c', 4); +* console.log(obj.a.b.c); // 4 +* +* @example +* // Set a value in an array +* const arr = [1, 2, 3]; +* set(arr, 1, 4); +* console.log(arr[1]); // 4 +* +* @example +* // Create non-existent path and set value +* const obj = {}; +* set(obj, 'a.b.c', 4); +* console.log(obj); // { a: { b: { c: 4 } } } +*/ +function set(obj, path, value) { + return updateWith(obj, path, () => value, () => void 0); +} +//#endregion +export { set }; diff --git a/node_modules/es-toolkit/dist/compat/object/setWith.d.mts b/node_modules/es-toolkit/dist/compat/object/setWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d8f3c590fa101674fa8085e63fbbb08b55afc6f5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/setWith.d.mts @@ -0,0 +1,52 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/setWith.d.ts +/** + * Sets the value at the specified path of the given object using a customizer function. + * If any part of the path does not exist, it will be created based on the customizer's result. + * + * The customizer is invoked to produce the objects of the path. If the customizer returns + * a value, that value is used for the current path segment. If the customizer returns + * `undefined`, the method will create an appropriate object based on the path - an array + * if the next path segment is a valid array index, or an object otherwise. + * + * @template T - The type of the object. + * @param object - The object to modify. + * @param path - The path of the property to set. + * @param value - The value to set. + * @param [customizer] - The function to customize assigned values. + * @returns The modified object. + * + * @example + * // Set a value with a customizer that creates arrays for numeric path segments + * const object = {}; + * setWith(object, '[0][1]', 'a', (value) => Array.isArray(value) ? value : []); + * // => { '0': [, 'a'] } + */ +declare function setWith(object: T, path: PropertyPath, value: any, customizer?: (nsValue: any, key: string, nsObject: T) => any): T; +/** + * Sets the value at the specified path of the given object using a customizer function. + * If any part of the path does not exist, it will be created based on the customizer's result. + * + * The customizer is invoked to produce the objects of the path. If the customizer returns + * a value, that value is used for the current path segment. If the customizer returns + * `undefined`, the method will create an appropriate object based on the path - an array + * if the next path segment is a valid array index, or an object otherwise. + * + * @template T - The type of the object. + * @template R - The type of the return value. + * @param object - The object to modify. + * @param path - The path of the property to set. + * @param value - The value to set. + * @param [customizer] - The function to customize assigned values. + * @returns The modified object. + * + * @example + * // Set a value with a customizer that creates arrays for numeric path segments + * const object = {}; + * setWith(object, '[0][1]', 'a', (value) => Array.isArray(value) ? value : []); + * // => { '0': [, 'a'] } + */ +declare function setWith(object: T, path: PropertyPath, value: any, customizer?: (nsValue: any, key: string, nsObject: T) => any): R; +//#endregion +export { setWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/setWith.d.ts b/node_modules/es-toolkit/dist/compat/object/setWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..60bc41be9e1c0e804f68c5f428fe8f5dab52c2af --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/setWith.d.ts @@ -0,0 +1,52 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/setWith.d.ts +/** + * Sets the value at the specified path of the given object using a customizer function. + * If any part of the path does not exist, it will be created based on the customizer's result. + * + * The customizer is invoked to produce the objects of the path. If the customizer returns + * a value, that value is used for the current path segment. If the customizer returns + * `undefined`, the method will create an appropriate object based on the path - an array + * if the next path segment is a valid array index, or an object otherwise. + * + * @template T - The type of the object. + * @param object - The object to modify. + * @param path - The path of the property to set. + * @param value - The value to set. + * @param [customizer] - The function to customize assigned values. + * @returns The modified object. + * + * @example + * // Set a value with a customizer that creates arrays for numeric path segments + * const object = {}; + * setWith(object, '[0][1]', 'a', (value) => Array.isArray(value) ? value : []); + * // => { '0': [, 'a'] } + */ +declare function setWith(object: T, path: PropertyPath, value: any, customizer?: (nsValue: any, key: string, nsObject: T) => any): T; +/** + * Sets the value at the specified path of the given object using a customizer function. + * If any part of the path does not exist, it will be created based on the customizer's result. + * + * The customizer is invoked to produce the objects of the path. If the customizer returns + * a value, that value is used for the current path segment. If the customizer returns + * `undefined`, the method will create an appropriate object based on the path - an array + * if the next path segment is a valid array index, or an object otherwise. + * + * @template T - The type of the object. + * @template R - The type of the return value. + * @param object - The object to modify. + * @param path - The path of the property to set. + * @param value - The value to set. + * @param [customizer] - The function to customize assigned values. + * @returns The modified object. + * + * @example + * // Set a value with a customizer that creates arrays for numeric path segments + * const object = {}; + * setWith(object, '[0][1]', 'a', (value) => Array.isArray(value) ? value : []); + * // => { '0': [, 'a'] } + */ +declare function setWith(object: T, path: PropertyPath, value: any, customizer?: (nsValue: any, key: string, nsObject: T) => any): R; +//#endregion +export { setWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/setWith.js b/node_modules/es-toolkit/dist/compat/object/setWith.js new file mode 100644 index 0000000000000000000000000000000000000000..627d491658923e30eaa70c9754b5f7ad86060c38 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/setWith.js @@ -0,0 +1,33 @@ +const require_updateWith = require("./updateWith.js"); +//#region src/compat/object/setWith.ts +/** +* Sets the value at the specified path of the given object using a customizer function. +* If any part of the path does not exist, it will be created based on the customizer's result. +* +* The customizer is invoked to produce the objects of the path. If the customizer returns +* a value, that value is used for the current path segment. If the customizer returns +* `undefined`, the method will create an appropriate object based on the path - an array +* if the next path segment is a valid array index, or an object otherwise. +* +* @template T - The type of the object. +* @template R - The type of the return value. +* @param obj - The object to modify. +* @param path - The path of the property to set. +* @param value - The value to set. +* @param [customizer] - The function to customize assigned values. +* @returns The modified object. +* +* @example +* // Set a value with a customizer that creates arrays for numeric path segments +* const object = {}; +* setWith(object, '[0][1]', 'a', (value) => Array.isArray(value) ? value : []); +* // => { '0': [, 'a'] } +*/ +function setWith(obj, path, value, customizer) { + let customizerFn; + if (typeof customizer === "function") customizerFn = customizer; + else customizerFn = () => void 0; + return require_updateWith.updateWith(obj, path, () => value, customizerFn); +} +//#endregion +exports.setWith = setWith; diff --git a/node_modules/es-toolkit/dist/compat/object/setWith.mjs b/node_modules/es-toolkit/dist/compat/object/setWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..632da7f99b2987dd2af684b79894ffd65e4d53e1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/setWith.mjs @@ -0,0 +1,33 @@ +import { updateWith } from "./updateWith.mjs"; +//#region src/compat/object/setWith.ts +/** +* Sets the value at the specified path of the given object using a customizer function. +* If any part of the path does not exist, it will be created based on the customizer's result. +* +* The customizer is invoked to produce the objects of the path. If the customizer returns +* a value, that value is used for the current path segment. If the customizer returns +* `undefined`, the method will create an appropriate object based on the path - an array +* if the next path segment is a valid array index, or an object otherwise. +* +* @template T - The type of the object. +* @template R - The type of the return value. +* @param obj - The object to modify. +* @param path - The path of the property to set. +* @param value - The value to set. +* @param [customizer] - The function to customize assigned values. +* @returns The modified object. +* +* @example +* // Set a value with a customizer that creates arrays for numeric path segments +* const object = {}; +* setWith(object, '[0][1]', 'a', (value) => Array.isArray(value) ? value : []); +* // => { '0': [, 'a'] } +*/ +function setWith(obj, path, value, customizer) { + let customizerFn; + if (typeof customizer === "function") customizerFn = customizer; + else customizerFn = () => void 0; + return updateWith(obj, path, () => value, customizerFn); +} +//#endregion +export { setWith }; diff --git a/node_modules/es-toolkit/dist/compat/object/toDefaulted.d.mts b/node_modules/es-toolkit/dist/compat/object/toDefaulted.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4215e85c8de7eb0f94f0f0cca5082eb8ca554e96 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toDefaulted.d.mts @@ -0,0 +1,123 @@ +//#region src/compat/object/toDefaulted.d.ts +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @param object - The target object. + * @returns The cloned object. + */ +declare function toDefaulted(object: T): T; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S - The type of the object that provides default values. + * @param object - The target object that will receive default values. + * @param source - The object that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + */ +declare function toDefaulted(object: T, source: S): NonNullable; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + */ +declare function toDefaulted(object: T, source1: S1, source2: S2): NonNullable; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @template S3 - The type of the third object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @param source3 - The third object that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + */ +declare function toDefaulted(object: T, source1: S1, source2: S2, source3: S3): NonNullable; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @template S3 - The type of the third object that provides default values. + * @template S4 - The type of the fourth object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @param source3 - The third object that specifies the default values to apply. + * @param source4 - The fourth object that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + */ +declare function toDefaulted(object: T, source1: S1, source2: S2, source3: S3, source4: S4): NonNullable; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S - The type of the objects that provides default values. + * @param object - The target object that will receive default values. + * @param sources - The objects that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + * + * @example + * toDefaulted({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } + * toDefaulted({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 } + * toDefaulted({ a: null }, { a: 1 }); // { a: null } + * toDefaulted({ a: undefined }, { a: 1 }); // { a: 1 } + */ +declare function toDefaulted(object: T, ...sources: S[]): object; +//#endregion +export { toDefaulted }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/toDefaulted.d.ts b/node_modules/es-toolkit/dist/compat/object/toDefaulted.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4215e85c8de7eb0f94f0f0cca5082eb8ca554e96 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toDefaulted.d.ts @@ -0,0 +1,123 @@ +//#region src/compat/object/toDefaulted.d.ts +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @param object - The target object. + * @returns The cloned object. + */ +declare function toDefaulted(object: T): T; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S - The type of the object that provides default values. + * @param object - The target object that will receive default values. + * @param source - The object that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + */ +declare function toDefaulted(object: T, source: S): NonNullable; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + */ +declare function toDefaulted(object: T, source1: S1, source2: S2): NonNullable; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @template S3 - The type of the third object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @param source3 - The third object that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + */ +declare function toDefaulted(object: T, source1: S1, source2: S2, source3: S3): NonNullable; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S1 - The type of the first object that provides default values. + * @template S2 - The type of the second object that provides default values. + * @template S3 - The type of the third object that provides default values. + * @template S4 - The type of the fourth object that provides default values. + * @param object - The target object that will receive default values. + * @param source1 - The first object that specifies the default values to apply. + * @param source2 - The second object that specifies the default values to apply. + * @param source3 - The third object that specifies the default values to apply. + * @param source4 - The fourth object that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + */ +declare function toDefaulted(object: T, source1: S1, source2: S2, source3: S3, source4: S4): NonNullable; +/** + * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. + * It assigns default values to properties that are either `undefined` or come from `Object.prototype`. + * + * You can provide multiple source objects to set these default values, + * and they will be applied in the order they are given, from left to right. + * Once a property has been set, any later values for that property will be ignored. + * + * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. + * + * @template T - The type of the object being processed. + * @template S - The type of the objects that provides default values. + * @param object - The target object that will receive default values. + * @param sources - The objects that specifies the default values to apply. + * @returns A new object that combines the target and default values, ensuring no properties are left undefined. + * + * @example + * toDefaulted({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } + * toDefaulted({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 } + * toDefaulted({ a: null }, { a: 1 }); // { a: null } + * toDefaulted({ a: undefined }, { a: 1 }); // { a: 1 } + */ +declare function toDefaulted(object: T, ...sources: S[]): object; +//#endregion +export { toDefaulted }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/toDefaulted.js b/node_modules/es-toolkit/dist/compat/object/toDefaulted.js new file mode 100644 index 0000000000000000000000000000000000000000..8a9c6b3b1902fe44c1c764160beb58861a571cc3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toDefaulted.js @@ -0,0 +1,31 @@ +const require_cloneDeep = require("./cloneDeep.js"); +const require_defaults = require("./defaults.js"); +//#region src/compat/object/toDefaulted.ts +/** +* Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. +* It assigns default values to properties that are either `undefined` or come from `Object.prototype`. +* +* You can provide multiple source objects to set these default values, +* and they will be applied in the order they are given, from left to right. +* Once a property has been set, any later values for that property will be ignored. +* +* Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. +* +* @template T - The type of the object being processed. +* @template S - The type of the objects that provides default values. +* @param object - The target object that will receive default values. +* @param sources - The objects that specifies the default values to apply. +* @returns A new object that combines the target and default values, ensuring no properties are left undefined. +* +* @example +* toDefaulted({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } +* toDefaulted({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 } +* toDefaulted({ a: null }, { a: 1 }); // { a: null } +* toDefaulted({ a: undefined }, { a: 1 }); // { a: 1 } +*/ +function toDefaulted(object, ...sources) { + const cloned = require_cloneDeep.cloneDeep(object); + return require_defaults.defaults(cloned, ...sources); +} +//#endregion +exports.toDefaulted = toDefaulted; diff --git a/node_modules/es-toolkit/dist/compat/object/toDefaulted.mjs b/node_modules/es-toolkit/dist/compat/object/toDefaulted.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0055d029a27864e6663bb83f0d97957e673e7ccb --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toDefaulted.mjs @@ -0,0 +1,30 @@ +import { cloneDeep } from "./cloneDeep.mjs"; +import { defaults } from "./defaults.mjs"; +//#region src/compat/object/toDefaulted.ts +/** +* Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`. +* It assigns default values to properties that are either `undefined` or come from `Object.prototype`. +* +* You can provide multiple source objects to set these default values, +* and they will be applied in the order they are given, from left to right. +* Once a property has been set, any later values for that property will be ignored. +* +* Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead. +* +* @template T - The type of the object being processed. +* @template S - The type of the objects that provides default values. +* @param object - The target object that will receive default values. +* @param sources - The objects that specifies the default values to apply. +* @returns A new object that combines the target and default values, ensuring no properties are left undefined. +* +* @example +* toDefaulted({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 } +* toDefaulted({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 } +* toDefaulted({ a: null }, { a: 1 }); // { a: null } +* toDefaulted({ a: undefined }, { a: 1 }); // { a: 1 } +*/ +function toDefaulted(object, ...sources) { + return defaults(cloneDeep(object), ...sources); +} +//#endregion +export { toDefaulted }; diff --git a/node_modules/es-toolkit/dist/compat/object/toPairs.d.mts b/node_modules/es-toolkit/dist/compat/object/toPairs.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9e0d41369e9c8883c747e3dc851d7fb41a5ae6d0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toPairs.d.mts @@ -0,0 +1,26 @@ +//#region src/compat/object/toPairs.d.ts +/** + * Creates an array of key-value pairs from an object. + * + * @template T + * @param object - The object to query. + * @returns Returns the array of key-value pairs. + * + * @example + * const object = { a: 1, b: 2 }; + * toPairs(object); // [['a', 1], ['b', 2]] + */ +declare function toPairs(object?: Record | Record): Array<[string, T]>; +/** + * Creates an array of key-value pairs from an object. + * + * @param object - The object to query. + * @returns Returns the array of key-value pairs. + * + * @example + * const object = { a: 1, b: 2 }; + * toPairs(object); // [['a', 1], ['b', 2]] + */ +declare function toPairs(object?: object): Array<[string, any]>; +//#endregion +export { toPairs }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/toPairs.d.ts b/node_modules/es-toolkit/dist/compat/object/toPairs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e0d41369e9c8883c747e3dc851d7fb41a5ae6d0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toPairs.d.ts @@ -0,0 +1,26 @@ +//#region src/compat/object/toPairs.d.ts +/** + * Creates an array of key-value pairs from an object. + * + * @template T + * @param object - The object to query. + * @returns Returns the array of key-value pairs. + * + * @example + * const object = { a: 1, b: 2 }; + * toPairs(object); // [['a', 1], ['b', 2]] + */ +declare function toPairs(object?: Record | Record): Array<[string, T]>; +/** + * Creates an array of key-value pairs from an object. + * + * @param object - The object to query. + * @returns Returns the array of key-value pairs. + * + * @example + * const object = { a: 1, b: 2 }; + * toPairs(object); // [['a', 1], ['b', 2]] + */ +declare function toPairs(object?: object): Array<[string, any]>; +//#endregion +export { toPairs }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/toPairs.js b/node_modules/es-toolkit/dist/compat/object/toPairs.js new file mode 100644 index 0000000000000000000000000000000000000000..197357c772b697c163329c48d45ce3c96ecb1239 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toPairs.js @@ -0,0 +1,37 @@ +const require_keys = require("./keys.js"); +const require_mapToEntries = require("../_internal/mapToEntries.js"); +const require_setToEntries = require("../_internal/setToEntries.js"); +//#region src/compat/object/toPairs.ts +/** +* Creates an array of key-value pairs from an object, set, or map. +* +* @template T +* @param object - The object, set, or map to query. +* @returns Returns the array of key-value pairs. +* +* @example +* const object = { a: 1, b: 2 }; +* toPairs(object); // [['a', 1], ['b', 2]] +* +* const set = new Set([1, 2]); +* toPairs(set); // [[1, 1], [2, 2]] +* +* const map = new Map(); +* map.set('a', 1); +* map.set('b', 2); +* toPairs(map); // [['a', 1], ['b', 2]] +*/ +function toPairs(object) { + if (object == null) return []; + if (object instanceof Set) return require_setToEntries.setToEntries(object); + if (object instanceof Map) return require_mapToEntries.mapToEntries(object); + const keys$1 = require_keys.keys(object); + const result = new Array(keys$1.length); + for (let i = 0; i < keys$1.length; i++) { + const key = keys$1[i]; + result[i] = [key, object[key]]; + } + return result; +} +//#endregion +exports.toPairs = toPairs; diff --git a/node_modules/es-toolkit/dist/compat/object/toPairs.mjs b/node_modules/es-toolkit/dist/compat/object/toPairs.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4ef16dd6a6a84bf6ebf2e2d86cc22e8918b6cdab --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toPairs.mjs @@ -0,0 +1,37 @@ +import { keys } from "./keys.mjs"; +import { mapToEntries } from "../_internal/mapToEntries.mjs"; +import { setToEntries } from "../_internal/setToEntries.mjs"; +//#region src/compat/object/toPairs.ts +/** +* Creates an array of key-value pairs from an object, set, or map. +* +* @template T +* @param object - The object, set, or map to query. +* @returns Returns the array of key-value pairs. +* +* @example +* const object = { a: 1, b: 2 }; +* toPairs(object); // [['a', 1], ['b', 2]] +* +* const set = new Set([1, 2]); +* toPairs(set); // [[1, 1], [2, 2]] +* +* const map = new Map(); +* map.set('a', 1); +* map.set('b', 2); +* toPairs(map); // [['a', 1], ['b', 2]] +*/ +function toPairs(object) { + if (object == null) return []; + if (object instanceof Set) return setToEntries(object); + if (object instanceof Map) return mapToEntries(object); + const keys$1 = keys(object); + const result = new Array(keys$1.length); + for (let i = 0; i < keys$1.length; i++) { + const key = keys$1[i]; + result[i] = [key, object[key]]; + } + return result; +} +//#endregion +export { toPairs }; diff --git a/node_modules/es-toolkit/dist/compat/object/toPairsIn.d.mts b/node_modules/es-toolkit/dist/compat/object/toPairsIn.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1919429b93822ffc83e7479c563fbad3aeabb094 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toPairsIn.d.mts @@ -0,0 +1,26 @@ +//#region src/compat/object/toPairsIn.d.ts +/** + * Creates an array of key-value pairs from an object, including inherited properties. + * + * @template T + * @param object - The object to query. + * @returns Returns the array of key-value pairs. + * + * @example + * const object = { a: 1, b: 2 }; + * toPairsIn(object); // [['a', 1], ['b', 2]] + */ +declare function toPairsIn(object?: Record | Record): Array<[string, T]>; +/** + * Creates an array of key-value pairs from an object, including inherited properties. + * + * @param object - The object to query. + * @returns Returns the array of key-value pairs. + * + * @example + * const object = { a: 1, b: 2 }; + * toPairsIn(object); // [['a', 1], ['b', 2]] + */ +declare function toPairsIn(object?: object): Array<[string, any]>; +//#endregion +export { toPairsIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/toPairsIn.d.ts b/node_modules/es-toolkit/dist/compat/object/toPairsIn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1919429b93822ffc83e7479c563fbad3aeabb094 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toPairsIn.d.ts @@ -0,0 +1,26 @@ +//#region src/compat/object/toPairsIn.d.ts +/** + * Creates an array of key-value pairs from an object, including inherited properties. + * + * @template T + * @param object - The object to query. + * @returns Returns the array of key-value pairs. + * + * @example + * const object = { a: 1, b: 2 }; + * toPairsIn(object); // [['a', 1], ['b', 2]] + */ +declare function toPairsIn(object?: Record | Record): Array<[string, T]>; +/** + * Creates an array of key-value pairs from an object, including inherited properties. + * + * @param object - The object to query. + * @returns Returns the array of key-value pairs. + * + * @example + * const object = { a: 1, b: 2 }; + * toPairsIn(object); // [['a', 1], ['b', 2]] + */ +declare function toPairsIn(object?: object): Array<[string, any]>; +//#endregion +export { toPairsIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/toPairsIn.js b/node_modules/es-toolkit/dist/compat/object/toPairsIn.js new file mode 100644 index 0000000000000000000000000000000000000000..63401c3950b3699a01620d59af02c81f2097cc6d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toPairsIn.js @@ -0,0 +1,35 @@ +const require_keysIn = require("./keysIn.js"); +const require_mapToEntries = require("../_internal/mapToEntries.js"); +const require_setToEntries = require("../_internal/setToEntries.js"); +//#region src/compat/object/toPairsIn.ts +/** +* Creates an array of key-value pairs from an object, set, or map, including inherited properties. +* +* @param object The object, set, or map to query. +* @returns Returns the array of key-value pairs. +* @example +* const object = { a: 1, b: 2 }; +* toPairsIn(object); // [['a', 1], ['b', 2]] +* +* const set = new Set([1, 2]); +* toPairsIn(set); // [[1, 1], [2, 2]] +* +* const map = new Map(); +* map.set('a', 1); +* map.set('b', 2); +* toPairsIn(map); // [['a', 1], ['b', 2]] +*/ +function toPairsIn(object) { + if (object == null) return []; + if (object instanceof Set) return require_setToEntries.setToEntries(object); + if (object instanceof Map) return require_mapToEntries.mapToEntries(object); + const keys = require_keysIn.keysIn(object); + const result = new Array(keys.length); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + result[i] = [key, object[key]]; + } + return result; +} +//#endregion +exports.toPairsIn = toPairsIn; diff --git a/node_modules/es-toolkit/dist/compat/object/toPairsIn.mjs b/node_modules/es-toolkit/dist/compat/object/toPairsIn.mjs new file mode 100644 index 0000000000000000000000000000000000000000..96538cf833edb0a83556c0f1312bd88588ee169e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/toPairsIn.mjs @@ -0,0 +1,35 @@ +import { keysIn } from "./keysIn.mjs"; +import { mapToEntries } from "../_internal/mapToEntries.mjs"; +import { setToEntries } from "../_internal/setToEntries.mjs"; +//#region src/compat/object/toPairsIn.ts +/** +* Creates an array of key-value pairs from an object, set, or map, including inherited properties. +* +* @param object The object, set, or map to query. +* @returns Returns the array of key-value pairs. +* @example +* const object = { a: 1, b: 2 }; +* toPairsIn(object); // [['a', 1], ['b', 2]] +* +* const set = new Set([1, 2]); +* toPairsIn(set); // [[1, 1], [2, 2]] +* +* const map = new Map(); +* map.set('a', 1); +* map.set('b', 2); +* toPairsIn(map); // [['a', 1], ['b', 2]] +*/ +function toPairsIn(object) { + if (object == null) return []; + if (object instanceof Set) return setToEntries(object); + if (object instanceof Map) return mapToEntries(object); + const keys = keysIn(object); + const result = new Array(keys.length); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + result[i] = [key, object[key]]; + } + return result; +} +//#endregion +export { toPairsIn }; diff --git a/node_modules/es-toolkit/dist/compat/object/transform.d.mts b/node_modules/es-toolkit/dist/compat/object/transform.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c29d3d8503e156b8d4271e462825e8f91bbc66d4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/transform.d.mts @@ -0,0 +1,75 @@ +//#region src/compat/object/transform.d.ts +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @template T - The type of object. + * @template R - The type of accumulator. + * @param object - The array to iterate over. + * @param iteratee - The function invoked per iteration. + * @param [accumulator] - The initial value. + * @returns Returns the accumulated value. + * + * @example + * const array = [2, 3, 4]; + * transform(array, (acc, value) => { acc.push(value * 2); }, []); + * // => [4, 6, 8] + */ +declare function transform(object: readonly T[], iteratee: (acc: R, curr: T, index: number, arr: T[]) => void, accumulator?: R): R; +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @template T - The type of object. + * @template R - The type of accumulator. + * @param object - The object to iterate over. + * @param iteratee - The function invoked per iteration. + * @param [accumulator] - The initial value. + * @returns Returns the accumulated value. + * + * @example + * const obj = { 'a': 1, 'b': 2, 'c': 1 }; + * transform(obj, (result, value, key) => { (result[value] || (result[value] = [])).push(key) }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } + */ +declare function transform(object: Record, iteratee: (acc: R, curr: T, key: string, dict: Record) => void, accumulator?: R): R; +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @template T - The type of object. + * @template R - The type of accumulator. + * @param object - The object to iterate over. + * @param iteratee - The function invoked per iteration. + * @param [accumulator] - The initial value. + * @returns Returns the accumulated value. + * + * @example + * const obj = { x: 1, y: 2, z: 3 }; + * transform(obj, (acc, value, key) => { acc[key] = value * 2; }, {}); + * // => { x: 2, y: 4, z: 6 } + */ +declare function transform(object: T, iteratee: (acc: R, curr: T[keyof T], key: keyof T, dict: Record) => void, accumulator?: R): R; +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @param object - The array to iterate over. + * @returns Returns the accumulated value. + * + * @example + * const array = [1, 2, 3]; + * transform(array); + * // => [1, 2, 3] + */ +declare function transform(object: any[]): any[]; +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @param object - The object to iterate over. + * @returns Returns the accumulated value. + * + * @example + * const obj = { a: 1, b: 2 }; + * transform(obj); + * // => { a: 1, b: 2 } + */ +declare function transform(object: object): Record; +//#endregion +export { transform }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/transform.d.ts b/node_modules/es-toolkit/dist/compat/object/transform.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c29d3d8503e156b8d4271e462825e8f91bbc66d4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/transform.d.ts @@ -0,0 +1,75 @@ +//#region src/compat/object/transform.d.ts +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @template T - The type of object. + * @template R - The type of accumulator. + * @param object - The array to iterate over. + * @param iteratee - The function invoked per iteration. + * @param [accumulator] - The initial value. + * @returns Returns the accumulated value. + * + * @example + * const array = [2, 3, 4]; + * transform(array, (acc, value) => { acc.push(value * 2); }, []); + * // => [4, 6, 8] + */ +declare function transform(object: readonly T[], iteratee: (acc: R, curr: T, index: number, arr: T[]) => void, accumulator?: R): R; +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @template T - The type of object. + * @template R - The type of accumulator. + * @param object - The object to iterate over. + * @param iteratee - The function invoked per iteration. + * @param [accumulator] - The initial value. + * @returns Returns the accumulated value. + * + * @example + * const obj = { 'a': 1, 'b': 2, 'c': 1 }; + * transform(obj, (result, value, key) => { (result[value] || (result[value] = [])).push(key) }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } + */ +declare function transform(object: Record, iteratee: (acc: R, curr: T, key: string, dict: Record) => void, accumulator?: R): R; +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @template T - The type of object. + * @template R - The type of accumulator. + * @param object - The object to iterate over. + * @param iteratee - The function invoked per iteration. + * @param [accumulator] - The initial value. + * @returns Returns the accumulated value. + * + * @example + * const obj = { x: 1, y: 2, z: 3 }; + * transform(obj, (acc, value, key) => { acc[key] = value * 2; }, {}); + * // => { x: 2, y: 4, z: 6 } + */ +declare function transform(object: T, iteratee: (acc: R, curr: T[keyof T], key: keyof T, dict: Record) => void, accumulator?: R): R; +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @param object - The array to iterate over. + * @returns Returns the accumulated value. + * + * @example + * const array = [1, 2, 3]; + * transform(array); + * // => [1, 2, 3] + */ +declare function transform(object: any[]): any[]; +/** + * Traverses object values and creates a new object by accumulating them in the desired form. + * + * @param object - The object to iterate over. + * @returns Returns the accumulated value. + * + * @example + * const obj = { a: 1, b: 2 }; + * transform(obj); + * // => { a: 1, b: 2 } + */ +declare function transform(object: object): Record; +//#endregion +export { transform }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/transform.js b/node_modules/es-toolkit/dist/compat/object/transform.js new file mode 100644 index 0000000000000000000000000000000000000000..5f778030ed1f107c7f0b52d7ad0e52b1f021229e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/transform.js @@ -0,0 +1,44 @@ +const require_identity = require("../../function/identity.js"); +const require_isFunction = require("../../predicate/isFunction.js"); +const require_isObject = require("../predicate/isObject.js"); +const require_iteratee = require("../util/iteratee.js"); +const require_forEach = require("../array/forEach.js"); +const require_isTypedArray = require("../predicate/isTypedArray.js"); +const require_isBuffer = require("../predicate/isBuffer.js"); +//#region src/compat/object/transform.ts +/** +* Traverses object values and creates a new object by accumulating them in the desired form. +* +* If no initial value is provided for `accumulator`, it creates a new array or object with the same prototype. +* +The traversal is interrupted when the `iteratee` function returns `false`. +* +* @template T - The type of object. +* @template U - The type of accumulator. +* @param object - The object to iterate over. +* @param [iteratee] - The function invoked per iteration. +* @param [accumulator] - The initial value. +* @returns Returns the accumulated value. +* +* @example +* // Transform an array +* const array = [2, 3, 4]; +* transform(array, (acc, value) => { acc += value; return value % 2 === 0; }, 0) // => 5 +* +* @example +* // Transform an object +* const obj = { 'a': 1, 'b': 2, 'c': 1 }; +* transform(obj, (result, value, key) => { (result[value] || (result[value] = [])).push(key) }, {}) // => { '1': ['a', 'c'], '2': ['b'] } +*/ +function transform(object, iteratee$1 = require_identity.identity, accumulator) { + const isArrayOrBufferOrTypedArray = Array.isArray(object) || require_isBuffer.isBuffer(object) || require_isTypedArray.isTypedArray(object); + iteratee$1 = require_iteratee.iteratee(iteratee$1); + if (accumulator == null) if (isArrayOrBufferOrTypedArray) accumulator = []; + else if (require_isObject.isObject(object) && require_isFunction.isFunction(object.constructor)) accumulator = Object.create(Object.getPrototypeOf(object)); + else accumulator = {}; + if (object == null) return accumulator; + require_forEach.forEach(object, (value, key, object) => iteratee$1(accumulator, value, key, object)); + return accumulator; +} +//#endregion +exports.transform = transform; diff --git a/node_modules/es-toolkit/dist/compat/object/transform.mjs b/node_modules/es-toolkit/dist/compat/object/transform.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6c520cd496d7f8321b1260a3e25a93789b269b38 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/transform.mjs @@ -0,0 +1,44 @@ +import { identity } from "../../function/identity.mjs"; +import { isFunction } from "../../predicate/isFunction.mjs"; +import { isObject } from "../predicate/isObject.mjs"; +import { iteratee } from "../util/iteratee.mjs"; +import { forEach } from "../array/forEach.mjs"; +import { isTypedArray } from "../predicate/isTypedArray.mjs"; +import { isBuffer } from "../predicate/isBuffer.mjs"; +//#region src/compat/object/transform.ts +/** +* Traverses object values and creates a new object by accumulating them in the desired form. +* +* If no initial value is provided for `accumulator`, it creates a new array or object with the same prototype. +* +The traversal is interrupted when the `iteratee` function returns `false`. +* +* @template T - The type of object. +* @template U - The type of accumulator. +* @param object - The object to iterate over. +* @param [iteratee] - The function invoked per iteration. +* @param [accumulator] - The initial value. +* @returns Returns the accumulated value. +* +* @example +* // Transform an array +* const array = [2, 3, 4]; +* transform(array, (acc, value) => { acc += value; return value % 2 === 0; }, 0) // => 5 +* +* @example +* // Transform an object +* const obj = { 'a': 1, 'b': 2, 'c': 1 }; +* transform(obj, (result, value, key) => { (result[value] || (result[value] = [])).push(key) }, {}) // => { '1': ['a', 'c'], '2': ['b'] } +*/ +function transform(object, iteratee$1 = identity, accumulator) { + const isArrayOrBufferOrTypedArray = Array.isArray(object) || isBuffer(object) || isTypedArray(object); + iteratee$1 = iteratee(iteratee$1); + if (accumulator == null) if (isArrayOrBufferOrTypedArray) accumulator = []; + else if (isObject(object) && isFunction(object.constructor)) accumulator = Object.create(Object.getPrototypeOf(object)); + else accumulator = {}; + if (object == null) return accumulator; + forEach(object, (value, key, object) => iteratee$1(accumulator, value, key, object)); + return accumulator; +} +//#endregion +export { transform }; diff --git a/node_modules/es-toolkit/dist/compat/object/unset.d.mts b/node_modules/es-toolkit/dist/compat/object/unset.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c36ba5749377b3ee40dfdf17374eaef992350c1c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/unset.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/object/unset.d.ts +/** + * Removes the property at the given path of the object. + * + * @param obj - The object to modify. + * @param path - The path of the property to unset. + * @returns Returns true if the property is deleted, else false. + * + * @example + * const obj = { a: { b: { c: 42 } } }; + * unset(obj, 'a.b.c'); // true + * console.log(obj); // { a: { b: {} } } + * + * @example + * const obj = { a: { b: { c: 42 } } }; + * unset(obj, ['a', 'b', 'c']); // true + * console.log(obj); // { a: { b: {} } } + */ +declare function unset(obj: any, path: PropertyKey | readonly PropertyKey[]): boolean; +//#endregion +export { unset }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/unset.d.ts b/node_modules/es-toolkit/dist/compat/object/unset.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c36ba5749377b3ee40dfdf17374eaef992350c1c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/unset.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/object/unset.d.ts +/** + * Removes the property at the given path of the object. + * + * @param obj - The object to modify. + * @param path - The path of the property to unset. + * @returns Returns true if the property is deleted, else false. + * + * @example + * const obj = { a: { b: { c: 42 } } }; + * unset(obj, 'a.b.c'); // true + * console.log(obj); // { a: { b: {} } } + * + * @example + * const obj = { a: { b: { c: 42 } } }; + * unset(obj, ['a', 'b', 'c']); // true + * console.log(obj); // { a: { b: {} } } + */ +declare function unset(obj: any, path: PropertyKey | readonly PropertyKey[]): boolean; +//#endregion +export { unset }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/unset.js b/node_modules/es-toolkit/dist/compat/object/unset.js new file mode 100644 index 0000000000000000000000000000000000000000..91e85cf7394e39ad7fc529471629774b214c9b44 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/unset.js @@ -0,0 +1,66 @@ +const require_isUnsafeProperty = require("../../_internal/isUnsafeProperty.js"); +const require_isDeepKey = require("../_internal/isDeepKey.js"); +const require_toKey = require("../_internal/toKey.js"); +const require_toPath = require("../util/toPath.js"); +const require_get = require("./get.js"); +//#region src/compat/object/unset.ts +/** +* Removes the property at the given path of the object. +* +* @param obj - The object to modify. +* @param path - The path of the property to unset. +* @returns Returns true if the property is deleted, else false. +* +* @example +* const obj = { a: { b: { c: 42 } } }; +* unset(obj, 'a.b.c'); // true +* console.log(obj); // { a: { b: {} } } +* +* @example +* const obj = { a: { b: { c: 42 } } }; +* unset(obj, ['a', 'b', 'c']); // true +* console.log(obj); // { a: { b: {} } } +*/ +function unset(obj, path) { + if (obj == null) return true; + switch (typeof path) { + case "symbol": + case "number": + case "object": + if (Array.isArray(path)) return unsetWithPath(obj, path); + if (typeof path === "number") path = require_toKey.toKey(path); + else if (typeof path === "object") if (Object.is(path?.valueOf(), -0)) path = "-0"; + else path = String(path); + if (require_isUnsafeProperty.isUnsafeProperty(path)) return false; + if (obj?.[path] === void 0) return true; + try { + delete obj[path]; + return true; + } catch { + return false; + } + case "string": + if (obj?.[path] === void 0 && require_isDeepKey.isDeepKey(path) && !Object.hasOwn(obj, path)) return unsetWithPath(obj, require_toPath.toPath(path)); + if (require_isUnsafeProperty.isUnsafeProperty(path)) return false; + try { + delete obj[path]; + return true; + } catch { + return false; + } + } +} +function unsetWithPath(obj, path) { + const parent = path.length === 1 ? obj : require_get.get(obj, path.slice(0, -1)); + const lastKey = path[path.length - 1]; + if (parent?.[lastKey] === void 0) return true; + if (require_isUnsafeProperty.isUnsafeProperty(lastKey)) return false; + try { + delete parent[lastKey]; + return true; + } catch { + return false; + } +} +//#endregion +exports.unset = unset; diff --git a/node_modules/es-toolkit/dist/compat/object/unset.mjs b/node_modules/es-toolkit/dist/compat/object/unset.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e39696f37b8cadd594a4cfdc0c91366fab91e818 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/unset.mjs @@ -0,0 +1,66 @@ +import { isUnsafeProperty } from "../../_internal/isUnsafeProperty.mjs"; +import { isDeepKey } from "../_internal/isDeepKey.mjs"; +import { toKey } from "../_internal/toKey.mjs"; +import { toPath } from "../util/toPath.mjs"; +import { get } from "./get.mjs"; +//#region src/compat/object/unset.ts +/** +* Removes the property at the given path of the object. +* +* @param obj - The object to modify. +* @param path - The path of the property to unset. +* @returns Returns true if the property is deleted, else false. +* +* @example +* const obj = { a: { b: { c: 42 } } }; +* unset(obj, 'a.b.c'); // true +* console.log(obj); // { a: { b: {} } } +* +* @example +* const obj = { a: { b: { c: 42 } } }; +* unset(obj, ['a', 'b', 'c']); // true +* console.log(obj); // { a: { b: {} } } +*/ +function unset(obj, path) { + if (obj == null) return true; + switch (typeof path) { + case "symbol": + case "number": + case "object": + if (Array.isArray(path)) return unsetWithPath(obj, path); + if (typeof path === "number") path = toKey(path); + else if (typeof path === "object") if (Object.is(path?.valueOf(), -0)) path = "-0"; + else path = String(path); + if (isUnsafeProperty(path)) return false; + if (obj?.[path] === void 0) return true; + try { + delete obj[path]; + return true; + } catch { + return false; + } + case "string": + if (obj?.[path] === void 0 && isDeepKey(path) && !Object.hasOwn(obj, path)) return unsetWithPath(obj, toPath(path)); + if (isUnsafeProperty(path)) return false; + try { + delete obj[path]; + return true; + } catch { + return false; + } + } +} +function unsetWithPath(obj, path) { + const parent = path.length === 1 ? obj : get(obj, path.slice(0, -1)); + const lastKey = path[path.length - 1]; + if (parent?.[lastKey] === void 0) return true; + if (isUnsafeProperty(lastKey)) return false; + try { + delete parent[lastKey]; + return true; + } catch { + return false; + } +} +//#endregion +export { unset }; diff --git a/node_modules/es-toolkit/dist/compat/object/update.d.mts b/node_modules/es-toolkit/dist/compat/object/update.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9cbec6f6e6b3831496ec54d9019669f25e7f6e3f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/update.d.mts @@ -0,0 +1,15 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/update.d.ts +/** + * Updates the value at the specified path of the given object using an updater function. + * If any part of the path does not exist, it will be created. + * + * @param obj - The object to modify. + * @param path - The path of the property to update. + * @param updater - The function to produce the updated value. + * @returns The modified object. + */ +declare function update(obj: object, path: PropertyPath, updater: (value: any) => any): any; +//#endregion +export { update }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/update.d.ts b/node_modules/es-toolkit/dist/compat/object/update.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6531c430e0e1d6053840dbb99f4999455c0d473e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/update.d.ts @@ -0,0 +1,15 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/update.d.ts +/** + * Updates the value at the specified path of the given object using an updater function. + * If any part of the path does not exist, it will be created. + * + * @param obj - The object to modify. + * @param path - The path of the property to update. + * @param updater - The function to produce the updated value. + * @returns The modified object. + */ +declare function update(obj: object, path: PropertyPath, updater: (value: any) => any): any; +//#endregion +export { update }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/update.js b/node_modules/es-toolkit/dist/compat/object/update.js new file mode 100644 index 0000000000000000000000000000000000000000..fbcb9b3e0bad1d184837342aef383d0d747fc48f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/update.js @@ -0,0 +1,16 @@ +const require_updateWith = require("./updateWith.js"); +//#region src/compat/object/update.ts +/** +* Updates the value at the specified path of the given object using an updater function. +* If any part of the path does not exist, it will be created. +* +* @param obj - The object to modify. +* @param path - The path of the property to update. +* @param updater - The function to produce the updated value. +* @returns The modified object. +*/ +function update(obj, path, updater) { + return require_updateWith.updateWith(obj, path, updater, () => void 0); +} +//#endregion +exports.update = update; diff --git a/node_modules/es-toolkit/dist/compat/object/update.mjs b/node_modules/es-toolkit/dist/compat/object/update.mjs new file mode 100644 index 0000000000000000000000000000000000000000..608d104aa1c3282ba685c838b5ab1645793187ac --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/update.mjs @@ -0,0 +1,16 @@ +import { updateWith } from "./updateWith.mjs"; +//#region src/compat/object/update.ts +/** +* Updates the value at the specified path of the given object using an updater function. +* If any part of the path does not exist, it will be created. +* +* @param obj - The object to modify. +* @param path - The path of the property to update. +* @param updater - The function to produce the updated value. +* @returns The modified object. +*/ +function update(obj, path, updater) { + return updateWith(obj, path, updater, () => void 0); +} +//#endregion +export { update }; diff --git a/node_modules/es-toolkit/dist/compat/object/updateWith.d.mts b/node_modules/es-toolkit/dist/compat/object/updateWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..15001b0d6f32267d62b839007234d03c4bc00dde --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/updateWith.d.mts @@ -0,0 +1,40 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/object/updateWith.d.ts +/** + * Updates the value at the specified path of the given object using an updater function and a customizer. + * If any part of the path does not exist, it will be created. + * + * @template T - The type of the object. + * @param object - The object to modify. + * @param path - The path of the property to update. + * @param updater - The function to produce the updated value. + * @param customizer - The function to customize the update process. + * @returns The modified object. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * updateWith(object, 'a[0].b.c', (n) => n * n); + * // => { 'a': [{ 'b': { 'c': 9 } }] } + */ +declare function updateWith(object: T, path: PropertyPath, updater: (oldValue: any) => any, customizer?: (value: any, key: string, object: T) => any): T; +/** + * Updates the value at the specified path of the given object using an updater function and a customizer. + * If any part of the path does not exist, it will be created. + * + * @template T - The type of the object. + * @template R - The type of the return value. + * @param object - The object to modify. + * @param path - The path of the property to update. + * @param updater - The function to produce the updated value. + * @param customizer - The function to customize the update process. + * @returns The modified object. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * updateWith(object, 'a[0].b.c', (n) => n * n); + * // => { 'a': [{ 'b': { 'c': 9 } }] } + */ +declare function updateWith(object: T, path: PropertyPath, updater: (oldValue: any) => any, customizer?: (value: any, key: string, object: T) => any): R; +//#endregion +export { updateWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/updateWith.d.ts b/node_modules/es-toolkit/dist/compat/object/updateWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dde293d67cb62663ccc73b87af74a5028763dd2c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/updateWith.d.ts @@ -0,0 +1,40 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/object/updateWith.d.ts +/** + * Updates the value at the specified path of the given object using an updater function and a customizer. + * If any part of the path does not exist, it will be created. + * + * @template T - The type of the object. + * @param object - The object to modify. + * @param path - The path of the property to update. + * @param updater - The function to produce the updated value. + * @param customizer - The function to customize the update process. + * @returns The modified object. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * updateWith(object, 'a[0].b.c', (n) => n * n); + * // => { 'a': [{ 'b': { 'c': 9 } }] } + */ +declare function updateWith(object: T, path: PropertyPath, updater: (oldValue: any) => any, customizer?: (value: any, key: string, object: T) => any): T; +/** + * Updates the value at the specified path of the given object using an updater function and a customizer. + * If any part of the path does not exist, it will be created. + * + * @template T - The type of the object. + * @template R - The type of the return value. + * @param object - The object to modify. + * @param path - The path of the property to update. + * @param updater - The function to produce the updated value. + * @param customizer - The function to customize the update process. + * @returns The modified object. + * + * @example + * const object = { 'a': [{ 'b': { 'c': 3 } }] }; + * updateWith(object, 'a[0].b.c', (n) => n * n); + * // => { 'a': [{ 'b': { 'c': 9 } }] } + */ +declare function updateWith(object: T, path: PropertyPath, updater: (oldValue: any) => any, customizer?: (value: any, key: string, object: T) => any): R; +//#endregion +export { updateWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/updateWith.js b/node_modules/es-toolkit/dist/compat/object/updateWith.js new file mode 100644 index 0000000000000000000000000000000000000000..4048447788712313208c9cf44587b20e9ddcdf87 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/updateWith.js @@ -0,0 +1,51 @@ +const require_isUnsafeProperty = require("../../_internal/isUnsafeProperty.js"); +const require_toKey = require("../_internal/toKey.js"); +const require_toPath = require("../util/toPath.js"); +const require_get = require("./get.js"); +const require_isObject = require("../predicate/isObject.js"); +const require_isIndex = require("../_internal/isIndex.js"); +const require_isKey = require("../_internal/isKey.js"); +const require_assignValue = require("../_internal/assignValue.js"); +//#region src/compat/object/updateWith.ts +/** +* Updates the value at the specified path of the given object using an updater function and a customizer. +* If any part of the path does not exist, it will be created. +* +* @template T - The type of the object. +* @template R - The type of the return value. +* @param obj - The object to modify. +* @param path - The path of the property to update. +* @param updater - The function to produce the updated value. +* @param customizer - The function to customize the update process. +* @returns The modified object. +* +* @example +* const object = { 'a': [{ 'b': { 'c': 3 } }] }; +* updateWith(object, 'a[0].b.c', (n) => n * n); +* // => { 'a': [{ 'b': { 'c': 9 } }] } +*/ +function updateWith(obj, path, updater, customizer) { + if (obj == null && !require_isObject.isObject(obj)) return obj; + let resolvedPath; + if (require_isKey.isKey(path, obj)) resolvedPath = [path]; + else if (Array.isArray(path)) resolvedPath = path; + else resolvedPath = require_toPath.toPath(path); + const updateValue = updater(require_get.get(obj, resolvedPath)); + let current = obj; + for (let i = 0; i < resolvedPath.length && current != null; i++) { + const key = require_toKey.toKey(resolvedPath[i]); + if (require_isUnsafeProperty.isUnsafeProperty(key)) continue; + let newValue; + if (i === resolvedPath.length - 1) newValue = updateValue; + else { + const objValue = current[key]; + const customizerResult = customizer?.(objValue, key, obj); + newValue = customizerResult !== void 0 ? customizerResult : require_isObject.isObject(objValue) ? objValue : require_isIndex.isIndex(resolvedPath[i + 1]) ? [] : {}; + } + require_assignValue.assignValue(current, key, newValue); + current = current[key]; + } + return obj; +} +//#endregion +exports.updateWith = updateWith; diff --git a/node_modules/es-toolkit/dist/compat/object/updateWith.mjs b/node_modules/es-toolkit/dist/compat/object/updateWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fc2096e6e6ba508af8d6d3003e61ad909c9aab04 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/updateWith.mjs @@ -0,0 +1,51 @@ +import { isUnsafeProperty } from "../../_internal/isUnsafeProperty.mjs"; +import { toKey } from "../_internal/toKey.mjs"; +import { toPath } from "../util/toPath.mjs"; +import { get } from "./get.mjs"; +import { isObject } from "../predicate/isObject.mjs"; +import { isIndex } from "../_internal/isIndex.mjs"; +import { isKey } from "../_internal/isKey.mjs"; +import { assignValue } from "../_internal/assignValue.mjs"; +//#region src/compat/object/updateWith.ts +/** +* Updates the value at the specified path of the given object using an updater function and a customizer. +* If any part of the path does not exist, it will be created. +* +* @template T - The type of the object. +* @template R - The type of the return value. +* @param obj - The object to modify. +* @param path - The path of the property to update. +* @param updater - The function to produce the updated value. +* @param customizer - The function to customize the update process. +* @returns The modified object. +* +* @example +* const object = { 'a': [{ 'b': { 'c': 3 } }] }; +* updateWith(object, 'a[0].b.c', (n) => n * n); +* // => { 'a': [{ 'b': { 'c': 9 } }] } +*/ +function updateWith(obj, path, updater, customizer) { + if (obj == null && !isObject(obj)) return obj; + let resolvedPath; + if (isKey(path, obj)) resolvedPath = [path]; + else if (Array.isArray(path)) resolvedPath = path; + else resolvedPath = toPath(path); + const updateValue = updater(get(obj, resolvedPath)); + let current = obj; + for (let i = 0; i < resolvedPath.length && current != null; i++) { + const key = toKey(resolvedPath[i]); + if (isUnsafeProperty(key)) continue; + let newValue; + if (i === resolvedPath.length - 1) newValue = updateValue; + else { + const objValue = current[key]; + const customizerResult = customizer?.(objValue, key, obj); + newValue = customizerResult !== void 0 ? customizerResult : isObject(objValue) ? objValue : isIndex(resolvedPath[i + 1]) ? [] : {}; + } + assignValue(current, key, newValue); + current = current[key]; + } + return obj; +} +//#endregion +export { updateWith }; diff --git a/node_modules/es-toolkit/dist/compat/object/values.d.mts b/node_modules/es-toolkit/dist/compat/object/values.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7dfe5e910394d974ca1de719a0d7fb94fddf58d3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/values.d.mts @@ -0,0 +1,38 @@ +//#region src/compat/object/values.d.ts +/** + * Creates an array of the own enumerable property values of `object`. + * + * @template T + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * values(obj); // => [1, 2, 3] + */ +declare function values(object: Record | Record | ArrayLike | null | undefined): T[]; +/** + * Creates an array of the own enumerable property values of `object`. + * + * @template T + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * values(obj); // => [1, 2, 3] + */ +declare function values(object: T | null | undefined): Array; +/** + * Creates an array of the own enumerable property values of `object`. + * + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * values(obj); // => [1, 2, 3] + */ +declare function values(object: any): any[]; +//#endregion +export { values }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/values.d.ts b/node_modules/es-toolkit/dist/compat/object/values.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7dfe5e910394d974ca1de719a0d7fb94fddf58d3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/values.d.ts @@ -0,0 +1,38 @@ +//#region src/compat/object/values.d.ts +/** + * Creates an array of the own enumerable property values of `object`. + * + * @template T + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * values(obj); // => [1, 2, 3] + */ +declare function values(object: Record | Record | ArrayLike | null | undefined): T[]; +/** + * Creates an array of the own enumerable property values of `object`. + * + * @template T + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * values(obj); // => [1, 2, 3] + */ +declare function values(object: T | null | undefined): Array; +/** + * Creates an array of the own enumerable property values of `object`. + * + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * values(obj); // => [1, 2, 3] + */ +declare function values(object: any): any[]; +//#endregion +export { values }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/values.js b/node_modules/es-toolkit/dist/compat/object/values.js new file mode 100644 index 0000000000000000000000000000000000000000..218c0150edb1fb2522f2fb24700ec99517386da8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/values.js @@ -0,0 +1,20 @@ +const require_keys = require("./keys.js"); +//#region src/compat/object/values.ts +/** +* Creates an array of the own enumerable property values of `object`. +* +* @param object The object to query. +* @returns Returns an array of property values. +* @example +* const obj = { a: 1, b: 2, c: 3 }; +* values(obj); // => [1, 2, 3] +*/ +function values(object) { + if (object == null) return []; + const objectKeys = require_keys.keys(object); + const result = new Array(objectKeys.length); + for (let i = 0; i < objectKeys.length; i++) result[i] = object[objectKeys[i]]; + return result; +} +//#endregion +exports.values = values; diff --git a/node_modules/es-toolkit/dist/compat/object/values.mjs b/node_modules/es-toolkit/dist/compat/object/values.mjs new file mode 100644 index 0000000000000000000000000000000000000000..923f6583709d88fe3e69970e59cc0600af299b0a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/values.mjs @@ -0,0 +1,20 @@ +import { keys } from "./keys.mjs"; +//#region src/compat/object/values.ts +/** +* Creates an array of the own enumerable property values of `object`. +* +* @param object The object to query. +* @returns Returns an array of property values. +* @example +* const obj = { a: 1, b: 2, c: 3 }; +* values(obj); // => [1, 2, 3] +*/ +function values(object) { + if (object == null) return []; + const objectKeys = keys(object); + const result = new Array(objectKeys.length); + for (let i = 0; i < objectKeys.length; i++) result[i] = object[objectKeys[i]]; + return result; +} +//#endregion +export { values }; diff --git a/node_modules/es-toolkit/dist/compat/object/valuesIn.d.mts b/node_modules/es-toolkit/dist/compat/object/valuesIn.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6c1500f7579c6b5a9d6bbfa9291556bc1115bc9e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/valuesIn.d.mts @@ -0,0 +1,27 @@ +//#region src/compat/object/valuesIn.d.ts +/** + * Retrieves the values from an object, including those inherited from its prototype. + * + * @template T + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * valuesIn(obj); // => [1, 2, 3] + */ +declare function valuesIn(object: Record | Record | ArrayLike | null | undefined): T[]; +/** + * Retrieves the values from an object, including those inherited from its prototype. + * + * @template T + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * valuesIn(obj); // => [1, 2, 3] + */ +declare function valuesIn(object: T | null | undefined): Array; +//#endregion +export { valuesIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/valuesIn.d.ts b/node_modules/es-toolkit/dist/compat/object/valuesIn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c1500f7579c6b5a9d6bbfa9291556bc1115bc9e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/valuesIn.d.ts @@ -0,0 +1,27 @@ +//#region src/compat/object/valuesIn.d.ts +/** + * Retrieves the values from an object, including those inherited from its prototype. + * + * @template T + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * valuesIn(obj); // => [1, 2, 3] + */ +declare function valuesIn(object: Record | Record | ArrayLike | null | undefined): T[]; +/** + * Retrieves the values from an object, including those inherited from its prototype. + * + * @template T + * @param object - The object to query. + * @returns Returns an array of property values. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * valuesIn(obj); // => [1, 2, 3] + */ +declare function valuesIn(object: T | null | undefined): Array; +//#endregion +export { valuesIn }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/object/valuesIn.js b/node_modules/es-toolkit/dist/compat/object/valuesIn.js new file mode 100644 index 0000000000000000000000000000000000000000..e35c28643daaec510b5ecdef30452587abae00b6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/valuesIn.js @@ -0,0 +1,25 @@ +const require_keysIn = require("./keysIn.js"); +//#region src/compat/object/valuesIn.ts +/** +* Retrieves the values from an object, including those inherited from its prototype. +* +* - If the value is not an object, it is converted to an object. +* - Array-like objects are treated like arrays. +* - Sparse arrays with some missing indices are treated like dense arrays. +* - If the value is `null` or `undefined`, an empty array is returned. +* - When handling prototype objects, the `constructor` property is excluded from the results. +* +* @param object The object to query. +* @returns Returns an array of property values. +* @example +* const obj = { a: 1, b: 2, c: 3 }; +* valuesIn(obj); // => [1, 2, 3] +*/ +function valuesIn(object) { + const keys = require_keysIn.keysIn(object); + const result = new Array(keys.length); + for (let i = 0; i < keys.length; i++) result[i] = object[keys[i]]; + return result; +} +//#endregion +exports.valuesIn = valuesIn; diff --git a/node_modules/es-toolkit/dist/compat/object/valuesIn.mjs b/node_modules/es-toolkit/dist/compat/object/valuesIn.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f4dc368b23f123122323cf96ee20dd2109ef1f91 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/object/valuesIn.mjs @@ -0,0 +1,25 @@ +import { keysIn } from "./keysIn.mjs"; +//#region src/compat/object/valuesIn.ts +/** +* Retrieves the values from an object, including those inherited from its prototype. +* +* - If the value is not an object, it is converted to an object. +* - Array-like objects are treated like arrays. +* - Sparse arrays with some missing indices are treated like dense arrays. +* - If the value is `null` or `undefined`, an empty array is returned. +* - When handling prototype objects, the `constructor` property is excluded from the results. +* +* @param object The object to query. +* @returns Returns an array of property values. +* @example +* const obj = { a: 1, b: 2, c: 3 }; +* valuesIn(obj); // => [1, 2, 3] +*/ +function valuesIn(object) { + const keys = keysIn(object); + const result = new Array(keys.length); + for (let i = 0; i < keys.length; i++) result[i] = object[keys[i]]; + return result; +} +//#endregion +export { valuesIn }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/conforms.d.mts b/node_modules/es-toolkit/dist/compat/predicate/conforms.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bd1c4287cfaf9db4593be0ca8ca1e40cde434428 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/conforms.d.mts @@ -0,0 +1,25 @@ +import { ConformsPredicateObject } from "../_internal/ConformsPredicateObject.mjs"; + +//#region src/compat/predicate/conforms.d.ts +/** + * 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`. + * + * Note: The created function is equivalent to `conformsTo` with source partially applied. + * + * @param source The object of property predicates to conform to. + * @returns Returns the new spec function. + * + * @example + * const isPositive = (n) => n > 0; + * const isEven = (n) => n % 2 === 0; + * const predicates = { a: isPositive, b: isEven }; + * const conform = conforms(predicates); + * + * console.log(conform({ a: 2, b: 4 })); // true + * console.log(conform({ a: -1, b: 4 })); // false + * console.log(conform({ a: 2, b: 3 })); // false + * console.log(conform({ a: 0, b: 2 })); // false + */ +declare function conforms(source: ConformsPredicateObject): (value: T) => boolean; +//#endregion +export { conforms }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/conforms.d.ts b/node_modules/es-toolkit/dist/compat/predicate/conforms.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d12ef1425457f1b2df96d44c7bd8569f8e9c73a1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/conforms.d.ts @@ -0,0 +1,25 @@ +import { ConformsPredicateObject } from "../_internal/ConformsPredicateObject.js"; + +//#region src/compat/predicate/conforms.d.ts +/** + * 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`. + * + * Note: The created function is equivalent to `conformsTo` with source partially applied. + * + * @param source The object of property predicates to conform to. + * @returns Returns the new spec function. + * + * @example + * const isPositive = (n) => n > 0; + * const isEven = (n) => n % 2 === 0; + * const predicates = { a: isPositive, b: isEven }; + * const conform = conforms(predicates); + * + * console.log(conform({ a: 2, b: 4 })); // true + * console.log(conform({ a: -1, b: 4 })); // false + * console.log(conform({ a: 2, b: 3 })); // false + * console.log(conform({ a: 0, b: 2 })); // false + */ +declare function conforms(source: ConformsPredicateObject): (value: T) => boolean; +//#endregion +export { conforms }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/conforms.js b/node_modules/es-toolkit/dist/compat/predicate/conforms.js new file mode 100644 index 0000000000000000000000000000000000000000..7f8171baab603d49783ada59b252ba4840b64a63 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/conforms.js @@ -0,0 +1,30 @@ +const require_cloneDeep = require("../../object/cloneDeep.js"); +const require_conformsTo = require("./conformsTo.js"); +//#region src/compat/predicate/conforms.ts +/** +* 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`. +* +* Note: The created function is equivalent to `conformsTo` with source partially applied. +* +* @param source The object of property predicates to conform to. +* @returns Returns the new spec function. +* +* @example +* const isPositive = (n) => n > 0; +* const isEven = (n) => n % 2 === 0; +* const predicates = { a: isPositive, b: isEven }; +* const conform = conforms(predicates); +* +* console.log(conform({ a: 2, b: 4 })); // true +* console.log(conform({ a: -1, b: 4 })); // false +* console.log(conform({ a: 2, b: 3 })); // false +* console.log(conform({ a: 0, b: 2 })); // false +*/ +function conforms(source) { + source = require_cloneDeep.cloneDeep(source); + return function(object) { + return require_conformsTo.conformsTo(object, source); + }; +} +//#endregion +exports.conforms = conforms; diff --git a/node_modules/es-toolkit/dist/compat/predicate/conforms.mjs b/node_modules/es-toolkit/dist/compat/predicate/conforms.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8ecba5271940a078156466f02779d5ce73f3594e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/conforms.mjs @@ -0,0 +1,30 @@ +import { cloneDeep } from "../../object/cloneDeep.mjs"; +import { conformsTo } from "./conformsTo.mjs"; +//#region src/compat/predicate/conforms.ts +/** +* 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`. +* +* Note: The created function is equivalent to `conformsTo` with source partially applied. +* +* @param source The object of property predicates to conform to. +* @returns Returns the new spec function. +* +* @example +* const isPositive = (n) => n > 0; +* const isEven = (n) => n % 2 === 0; +* const predicates = { a: isPositive, b: isEven }; +* const conform = conforms(predicates); +* +* console.log(conform({ a: 2, b: 4 })); // true +* console.log(conform({ a: -1, b: 4 })); // false +* console.log(conform({ a: 2, b: 3 })); // false +* console.log(conform({ a: 0, b: 2 })); // false +*/ +function conforms(source) { + source = cloneDeep(source); + return function(object) { + return conformsTo(object, source); + }; +} +//#endregion +export { conforms }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/conformsTo.d.mts b/node_modules/es-toolkit/dist/compat/predicate/conformsTo.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..29e06fa31a77a07b1ed3e1081daa73416f8687d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/conformsTo.d.mts @@ -0,0 +1,33 @@ +import { ConformsPredicateObject } from "../_internal/ConformsPredicateObject.mjs"; + +//#region src/compat/predicate/conformsTo.d.ts +/** + * Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`. + * + * Note: This method is equivalent to `conforms` when source is partially applied. + * + * @template T - The type of the target object. + * @param target The object to inspect. + * @param source The object of property predicates to conform to. + * @returns Returns `true` if `object` conforms, else `false`. + * + * @example + * + * const object = { 'a': 1, 'b': 2 }; + * const source = { + * 'a': (n) => n > 0, + * 'b': (n) => n > 1 + * }; + * + * console.log(conformsTo(object, source)); // => true + * + * const source2 = { + * 'a': (n) => n > 1, + * 'b': (n) => n > 1 + * }; + * + * console.log(conformsTo(object, source2)); // => false + */ +declare function conformsTo(target: T, source: ConformsPredicateObject): boolean; +//#endregion +export { conformsTo }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/conformsTo.d.ts b/node_modules/es-toolkit/dist/compat/predicate/conformsTo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..57e0bb8bf0d2c9190eee08e75c6be2dc2a1802a5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/conformsTo.d.ts @@ -0,0 +1,33 @@ +import { ConformsPredicateObject } from "../_internal/ConformsPredicateObject.js"; + +//#region src/compat/predicate/conformsTo.d.ts +/** + * Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`. + * + * Note: This method is equivalent to `conforms` when source is partially applied. + * + * @template T - The type of the target object. + * @param target The object to inspect. + * @param source The object of property predicates to conform to. + * @returns Returns `true` if `object` conforms, else `false`. + * + * @example + * + * const object = { 'a': 1, 'b': 2 }; + * const source = { + * 'a': (n) => n > 0, + * 'b': (n) => n > 1 + * }; + * + * console.log(conformsTo(object, source)); // => true + * + * const source2 = { + * 'a': (n) => n > 1, + * 'b': (n) => n > 1 + * }; + * + * console.log(conformsTo(object, source2)); // => false + */ +declare function conformsTo(target: T, source: ConformsPredicateObject): boolean; +//#endregion +export { conformsTo }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/conformsTo.js b/node_modules/es-toolkit/dist/compat/predicate/conformsTo.js new file mode 100644 index 0000000000000000000000000000000000000000..c9a9582427cd8362ed9b052c3da5bf761c6c7832 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/conformsTo.js @@ -0,0 +1,43 @@ +//#region src/compat/predicate/conformsTo.ts +/** +* Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`. +* +* Note: This method is equivalent to `conforms` when source is partially applied. +* +* @template T - The type of the target object. +* @param target The object to inspect. +* @param source The object of property predicates to conform to. +* @returns Returns `true` if `object` conforms, else `false`. +* +* @example +* +* const object = { 'a': 1, 'b': 2 }; +* const source = { +* 'a': (n) => n > 0, +* 'b': (n) => n > 1 +* }; +* +* console.log(conformsTo(object, source)); // => true +* +* const source2 = { +* 'a': (n) => n > 1, +* 'b': (n) => n > 1 +* }; +* +* console.log(conformsTo(object, source2)); // => false +*/ +function conformsTo(target, source) { + if (source == null) return true; + if (target == null) return Object.keys(source).length === 0; + const keys = Object.keys(source); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const predicate = source[key]; + const value = target[key]; + if (value === void 0 && !(key in target)) return false; + if (typeof predicate === "function" && !predicate(value)) return false; + } + return true; +} +//#endregion +exports.conformsTo = conformsTo; diff --git a/node_modules/es-toolkit/dist/compat/predicate/conformsTo.mjs b/node_modules/es-toolkit/dist/compat/predicate/conformsTo.mjs new file mode 100644 index 0000000000000000000000000000000000000000..045fd21a86df78db3aa37d0c9fc8567031b58159 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/conformsTo.mjs @@ -0,0 +1,43 @@ +//#region src/compat/predicate/conformsTo.ts +/** +* Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`. +* +* Note: This method is equivalent to `conforms` when source is partially applied. +* +* @template T - The type of the target object. +* @param target The object to inspect. +* @param source The object of property predicates to conform to. +* @returns Returns `true` if `object` conforms, else `false`. +* +* @example +* +* const object = { 'a': 1, 'b': 2 }; +* const source = { +* 'a': (n) => n > 0, +* 'b': (n) => n > 1 +* }; +* +* console.log(conformsTo(object, source)); // => true +* +* const source2 = { +* 'a': (n) => n > 1, +* 'b': (n) => n > 1 +* }; +* +* console.log(conformsTo(object, source2)); // => false +*/ +function conformsTo(target, source) { + if (source == null) return true; + if (target == null) return Object.keys(source).length === 0; + const keys = Object.keys(source); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const predicate = source[key]; + const value = target[key]; + if (value === void 0 && !(key in target)) return false; + if (typeof predicate === "function" && !predicate(value)) return false; + } + return true; +} +//#endregion +export { conformsTo }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArguments.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isArguments.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..954196c10be73cbbb61e94936bd88e600b8def24 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArguments.d.mts @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isArguments.d.ts +/** + * Checks if the given value is an arguments object. + * + * This function tests whether the provided value is an arguments object or not. + * It returns `true` if the value is an arguments object, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object. + * + * @param value - The value to test if it is an arguments object. + * @returns `true` if the value is an arguments, `false` otherwise. + * + * @example + * const args = (function() { return arguments; })(); + * const strictArgs = (function() { 'use strict'; return arguments; })(); + * const value = [1, 2, 3]; + * + * console.log(isArguments(args)); // true + * console.log(isArguments(strictArgs)); // true + * console.log(isArguments(value)); // false + */ +declare function isArguments(value?: any): value is IArguments; +//#endregion +export { isArguments }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArguments.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isArguments.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..954196c10be73cbbb61e94936bd88e600b8def24 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArguments.d.ts @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isArguments.d.ts +/** + * Checks if the given value is an arguments object. + * + * This function tests whether the provided value is an arguments object or not. + * It returns `true` if the value is an arguments object, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object. + * + * @param value - The value to test if it is an arguments object. + * @returns `true` if the value is an arguments, `false` otherwise. + * + * @example + * const args = (function() { return arguments; })(); + * const strictArgs = (function() { 'use strict'; return arguments; })(); + * const value = [1, 2, 3]; + * + * console.log(isArguments(args)); // true + * console.log(isArguments(strictArgs)); // true + * console.log(isArguments(value)); // false + */ +declare function isArguments(value?: any): value is IArguments; +//#endregion +export { isArguments }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArguments.js b/node_modules/es-toolkit/dist/compat/predicate/isArguments.js new file mode 100644 index 0000000000000000000000000000000000000000..e988084058132b8a8de3e6fd520843a417d11df3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArguments.js @@ -0,0 +1,27 @@ +const require_getTag = require("../_internal/getTag.js"); +//#region src/compat/predicate/isArguments.ts +/** +* Checks if the given value is an arguments object. +* +* This function tests whether the provided value is an arguments object or not. +* It returns `true` if the value is an arguments object, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object. +* +* @param value - The value to test if it is an arguments object. +* @returns `true` if the value is an arguments, `false` otherwise. +* +* @example +* const args = (function() { return arguments; })(); +* const strictArgs = (function() { 'use strict'; return arguments; })(); +* const value = [1, 2, 3]; +* +* console.log(isArguments(args)); // true +* console.log(isArguments(strictArgs)); // true +* console.log(isArguments(value)); // false +*/ +function isArguments(value) { + return value !== null && typeof value === "object" && require_getTag.getTag(value) === "[object Arguments]"; +} +//#endregion +exports.isArguments = isArguments; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArguments.mjs b/node_modules/es-toolkit/dist/compat/predicate/isArguments.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f596cf8b78dfaaab4b3f986c458138160beeefb0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArguments.mjs @@ -0,0 +1,27 @@ +import { getTag } from "../_internal/getTag.mjs"; +//#region src/compat/predicate/isArguments.ts +/** +* Checks if the given value is an arguments object. +* +* This function tests whether the provided value is an arguments object or not. +* It returns `true` if the value is an arguments object, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object. +* +* @param value - The value to test if it is an arguments object. +* @returns `true` if the value is an arguments, `false` otherwise. +* +* @example +* const args = (function() { return arguments; })(); +* const strictArgs = (function() { 'use strict'; return arguments; })(); +* const value = [1, 2, 3]; +* +* console.log(isArguments(args)); // true +* console.log(isArguments(strictArgs)); // true +* console.log(isArguments(value)); // false +*/ +function isArguments(value) { + return value !== null && typeof value === "object" && getTag(value) === "[object Arguments]"; +} +//#endregion +export { isArguments }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArray.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isArray.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7ffe0f9df82df47cdb7abe91f8d4d9cdba2c2ead --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArray.d.mts @@ -0,0 +1,46 @@ +//#region src/compat/predicate/isArray.d.ts +/** + * Checks if the given value is an array. + * + * This function tests whether the provided value is an array or not. + * It returns `true` if the value is an array, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array. + * + * @param value - The value to test if it is an array. + * @returns `true` if the value is an array, `false` otherwise. + * + * @example + * const value1 = [1, 2, 3]; + * const value2 = 'abc'; + * const value3 = () => {}; + * + * console.log(isArray(value1)); // true + * console.log(isArray(value2)); // false + * console.log(isArray(value3)); // false + */ +declare function isArray(value?: any): value is any[]; +/** + * Checks if the given value is an array with generic type support. + * + * This function tests whether the provided value is an array or not. + * It returns `true` if the value is an array, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array. + * + * @template T - The type of elements in the array. + * @param value - The value to test if it is an array. + * @returns `true` if the value is an array, `false` otherwise. + * + * @example + * const value1 = [1, 2, 3]; + * const value2 = 'abc'; + * const value3 = () => {}; + * + * console.log(isArray(value1)); // true + * console.log(isArray(value2)); // false + * console.log(isArray(value3)); // false + */ +declare function isArray(value?: any): value is any[]; +//#endregion +export { isArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArray.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isArray.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ffe0f9df82df47cdb7abe91f8d4d9cdba2c2ead --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArray.d.ts @@ -0,0 +1,46 @@ +//#region src/compat/predicate/isArray.d.ts +/** + * Checks if the given value is an array. + * + * This function tests whether the provided value is an array or not. + * It returns `true` if the value is an array, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array. + * + * @param value - The value to test if it is an array. + * @returns `true` if the value is an array, `false` otherwise. + * + * @example + * const value1 = [1, 2, 3]; + * const value2 = 'abc'; + * const value3 = () => {}; + * + * console.log(isArray(value1)); // true + * console.log(isArray(value2)); // false + * console.log(isArray(value3)); // false + */ +declare function isArray(value?: any): value is any[]; +/** + * Checks if the given value is an array with generic type support. + * + * This function tests whether the provided value is an array or not. + * It returns `true` if the value is an array, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array. + * + * @template T - The type of elements in the array. + * @param value - The value to test if it is an array. + * @returns `true` if the value is an array, `false` otherwise. + * + * @example + * const value1 = [1, 2, 3]; + * const value2 = 'abc'; + * const value3 = () => {}; + * + * console.log(isArray(value1)); // true + * console.log(isArray(value2)); // false + * console.log(isArray(value3)); // false + */ +declare function isArray(value?: any): value is any[]; +//#endregion +export { isArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArray.js b/node_modules/es-toolkit/dist/compat/predicate/isArray.js new file mode 100644 index 0000000000000000000000000000000000000000..e554475d114624d936c580f94d3ffd3cbcfdd6e1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArray.js @@ -0,0 +1,26 @@ +//#region src/compat/predicate/isArray.ts +/** +* Checks if the given value is an array. +* +* This function tests whether the provided value is an array or not. +* It returns `true` if the value is an array, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array. +* +* @param value - The value to test if it is an array. +* @returns `true` if the value is an array, `false` otherwise. +* +* @example +* const value1 = [1, 2, 3]; +* const value2 = 'abc'; +* const value3 = () => {}; +* +* console.log(isArray(value1)); // true +* console.log(isArray(value2)); // false +* console.log(isArray(value3)); // false +*/ +function isArray(value) { + return Array.isArray(value); +} +//#endregion +exports.isArray = isArray; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArray.mjs b/node_modules/es-toolkit/dist/compat/predicate/isArray.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7c7b9b0cc6cb575c503f6a75b2c4aa9c49b707a9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArray.mjs @@ -0,0 +1,26 @@ +//#region src/compat/predicate/isArray.ts +/** +* Checks if the given value is an array. +* +* This function tests whether the provided value is an array or not. +* It returns `true` if the value is an array, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array. +* +* @param value - The value to test if it is an array. +* @returns `true` if the value is an array, `false` otherwise. +* +* @example +* const value1 = [1, 2, 3]; +* const value2 = 'abc'; +* const value3 = () => {}; +* +* console.log(isArray(value1)); // true +* console.log(isArray(value2)); // false +* console.log(isArray(value3)); // false +*/ +function isArray(value) { + return Array.isArray(value); +} +//#endregion +export { isArray }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c69f080d0ad2b7a10cada57c9e2e2f0eb5042602 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isArrayBuffer.d.ts +/** + * Checks if a given value is `ArrayBuffer`. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`. + * + * @param value The value to check if it is a `ArrayBuffer`. + * @returns Returns `true` if `value` is a `ArrayBuffer`, else `false`. + * + * @example + * const value1 = new ArrayBuffer(); + * const value2 = new Array(); + * const value3 = new Map(); + * + * console.log(isArrayBuffer(value1)); // true + * console.log(isArrayBuffer(value2)); // false + * console.log(isArrayBuffer(value3)); // false + */ +declare function isArrayBuffer(value?: any): value is ArrayBuffer; +//#endregion +export { isArrayBuffer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c69f080d0ad2b7a10cada57c9e2e2f0eb5042602 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isArrayBuffer.d.ts +/** + * Checks if a given value is `ArrayBuffer`. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`. + * + * @param value The value to check if it is a `ArrayBuffer`. + * @returns Returns `true` if `value` is a `ArrayBuffer`, else `false`. + * + * @example + * const value1 = new ArrayBuffer(); + * const value2 = new Array(); + * const value3 = new Map(); + * + * console.log(isArrayBuffer(value1)); // true + * console.log(isArrayBuffer(value2)); // false + * console.log(isArrayBuffer(value3)); // false + */ +declare function isArrayBuffer(value?: any): value is ArrayBuffer; +//#endregion +export { isArrayBuffer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.js b/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..453d51cd703a7b0cc79d656b1a44a0074dbeb284 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.js @@ -0,0 +1,24 @@ +const require_isArrayBuffer = require("../../predicate/isArrayBuffer.js"); +//#region src/compat/predicate/isArrayBuffer.ts +/** +* Checks if a given value is `ArrayBuffer`. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`. +* +* @param value The value to check if it is a `ArrayBuffer`. +* @returns Returns `true` if `value` is a `ArrayBuffer`, else `false`. +* +* @example +* const value1 = new ArrayBuffer(); +* const value2 = new Array(); +* const value3 = new Map(); +* +* console.log(isArrayBuffer(value1)); // true +* console.log(isArrayBuffer(value2)); // false +* console.log(isArrayBuffer(value3)); // false +*/ +function isArrayBuffer(value) { + return require_isArrayBuffer.isArrayBuffer(value); +} +//#endregion +exports.isArrayBuffer = isArrayBuffer; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.mjs b/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ebf6b994e1ae9654b9593c93f507a8056932aee9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayBuffer.mjs @@ -0,0 +1,24 @@ +import { isArrayBuffer as isArrayBuffer$1 } from "../../predicate/isArrayBuffer.mjs"; +//#region src/compat/predicate/isArrayBuffer.ts +/** +* Checks if a given value is `ArrayBuffer`. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`. +* +* @param value The value to check if it is a `ArrayBuffer`. +* @returns Returns `true` if `value` is a `ArrayBuffer`, else `false`. +* +* @example +* const value1 = new ArrayBuffer(); +* const value2 = new Array(); +* const value3 = new Map(); +* +* console.log(isArrayBuffer(value1)); // true +* console.log(isArrayBuffer(value2)); // false +* console.log(isArrayBuffer(value3)); // false +*/ +function isArrayBuffer(value) { + return isArrayBuffer$1(value); +} +//#endregion +export { isArrayBuffer }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b053afefac56bdfbbc8d1964ca411a86ad140de9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.d.mts @@ -0,0 +1,28 @@ +//#region src/compat/predicate/isArrayLike.d.ts +/** + * Checks if `value` is array-like. This overload is for compatibility with lodash type checking. + * + * @param t The value to check. + * @returns Returns `true` if `value` is array-like, else `false`. + */ +declare function isArrayLike(t: T): boolean; +/** + * Checks if `value` is array-like. Functions, null, and undefined are never array-like. + * + * @param value The value to check. + * @returns Returns `false` for functions, null, and undefined. + */ +declare function isArrayLike(value: ((...args: any[]) => any) | null | undefined): value is never; +/** + * Checks if `value` is array-like. + * + * @param value The value to check. + * @returns} Returns `true` if `value` is array-like, else `false`. + */ +declare function isArrayLike(value: any): value is { + length: number; +}; +//#endregion +export { isArrayLike }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b053afefac56bdfbbc8d1964ca411a86ad140de9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.d.ts @@ -0,0 +1,28 @@ +//#region src/compat/predicate/isArrayLike.d.ts +/** + * Checks if `value` is array-like. This overload is for compatibility with lodash type checking. + * + * @param t The value to check. + * @returns Returns `true` if `value` is array-like, else `false`. + */ +declare function isArrayLike(t: T): boolean; +/** + * Checks if `value` is array-like. Functions, null, and undefined are never array-like. + * + * @param value The value to check. + * @returns Returns `false` for functions, null, and undefined. + */ +declare function isArrayLike(value: ((...args: any[]) => any) | null | undefined): value is never; +/** + * Checks if `value` is array-like. + * + * @param value The value to check. + * @returns} Returns `true` if `value` is array-like, else `false`. + */ +declare function isArrayLike(value: any): value is { + length: number; +}; +//#endregion +export { isArrayLike }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.js b/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..44fa920493abc2872b97fcabc1c185fd6b135113 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.js @@ -0,0 +1,21 @@ +const require_isLength = require("../../predicate/isLength.js"); +//#region src/compat/predicate/isArrayLike.ts +/** +* Checks if `value` is array-like. +* +* @param value The value to check. +* @returns Returns `true` if `value` is array-like, else `false`. +* +* @example +* isArrayLike([1, 2, 3]); // true +* isArrayLike('abc'); // true +* isArrayLike({ 0: 'a', length: 1 }); // true +* isArrayLike({}); // false +* isArrayLike(null); // false +* isArrayLike(undefined); // false +*/ +function isArrayLike(value) { + return value != null && typeof value !== "function" && require_isLength.isLength(value.length); +} +//#endregion +exports.isArrayLike = isArrayLike; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.mjs b/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.mjs new file mode 100644 index 0000000000000000000000000000000000000000..49bfc52e472b75373afcc348697b7ff7c74e46e4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.mjs @@ -0,0 +1,21 @@ +import { isLength } from "../../predicate/isLength.mjs"; +//#region src/compat/predicate/isArrayLike.ts +/** +* Checks if `value` is array-like. +* +* @param value The value to check. +* @returns Returns `true` if `value` is array-like, else `false`. +* +* @example +* isArrayLike([1, 2, 3]); // true +* isArrayLike('abc'); // true +* isArrayLike({ 0: 'a', length: 1 }); // true +* isArrayLike({}); // false +* isArrayLike(null); // false +* isArrayLike(undefined); // false +*/ +function isArrayLike(value) { + return value != null && typeof value !== "function" && isLength(value.length); +} +//#endregion +export { isArrayLike }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..65667cc662104b651ff6d5719dafb319b966eec5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.d.mts @@ -0,0 +1,10 @@ +//#region src/compat/predicate/isArrayLikeObject.d.ts +declare function isArrayLikeObject(value: T): boolean; +declare function isArrayLikeObject(value: ((...args: any[]) => any) | Function | string | boolean | number | null | undefined): value is never; +declare function isArrayLikeObject(value: any): value is object & { + length: number; +}; +//#endregion +export { isArrayLikeObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..65667cc662104b651ff6d5719dafb319b966eec5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.d.ts @@ -0,0 +1,10 @@ +//#region src/compat/predicate/isArrayLikeObject.d.ts +declare function isArrayLikeObject(value: T): boolean; +declare function isArrayLikeObject(value: ((...args: any[]) => any) | Function | string | boolean | number | null | undefined): value is never; +declare function isArrayLikeObject(value: any): value is object & { + length: number; +}; +//#endregion +export { isArrayLikeObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.js b/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.js new file mode 100644 index 0000000000000000000000000000000000000000..be3b4d66e2fa4124cbae5884bec7e07aa2da7961 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.js @@ -0,0 +1,20 @@ +const require_isArrayLike = require("./isArrayLike.js"); +const require_isObjectLike = require("./isObjectLike.js"); +//#region src/compat/predicate/isArrayLikeObject.ts +/** +* Checks if the given value is a non-primitive, array-like object. +* +* @param value The value to check. +* @returns `true` if the value is a non-primitive, array-like object, `false` otherwise. +* +* @example +* isArrayLikeObject([1, 2, 3]); // true +* isArrayLikeObject({ 0: 'a', length: 1 }); // true +* isArrayLikeObject('abc'); // false +* isArrayLikeObject(()=>{}); // false +*/ +function isArrayLikeObject(value) { + return require_isObjectLike.isObjectLike(value) && require_isArrayLike.isArrayLike(value); +} +//#endregion +exports.isArrayLikeObject = isArrayLikeObject; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.mjs b/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b740f922966a91afa6050191d0397f925e00cfae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isArrayLikeObject.mjs @@ -0,0 +1,20 @@ +import { isArrayLike } from "./isArrayLike.mjs"; +import { isObjectLike } from "./isObjectLike.mjs"; +//#region src/compat/predicate/isArrayLikeObject.ts +/** +* Checks if the given value is a non-primitive, array-like object. +* +* @param value The value to check. +* @returns `true` if the value is a non-primitive, array-like object, `false` otherwise. +* +* @example +* isArrayLikeObject([1, 2, 3]); // true +* isArrayLikeObject({ 0: 'a', length: 1 }); // true +* isArrayLikeObject('abc'); // false +* isArrayLikeObject(()=>{}); // false +*/ +function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); +} +//#endregion +export { isArrayLikeObject }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isBoolean.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isBoolean.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0d2c7670a72a76a8e113a4bcec39cdf186fa52c3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isBoolean.d.mts @@ -0,0 +1,26 @@ +//#region src/compat/predicate/isBoolean.d.ts +/** + * Checks if the given value is boolean. + * + * This function tests whether the provided value is strictly `boolean`. + * It returns `true` if the value is `boolean`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`. + * + * @param value - The Value to test if it is boolean. + * @returns True if the value is boolean, false otherwise. + * + * @example + * + * const value1 = true; + * const value2 = 0; + * const value3 = 'abc'; + * + * console.log(isBoolean(value1)); // true + * console.log(isBoolean(value2)); // false + * console.log(isBoolean(value3)); // false + * + */ +declare function isBoolean(value?: any): value is boolean; +//#endregion +export { isBoolean }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isBoolean.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isBoolean.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d2c7670a72a76a8e113a4bcec39cdf186fa52c3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isBoolean.d.ts @@ -0,0 +1,26 @@ +//#region src/compat/predicate/isBoolean.d.ts +/** + * Checks if the given value is boolean. + * + * This function tests whether the provided value is strictly `boolean`. + * It returns `true` if the value is `boolean`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`. + * + * @param value - The Value to test if it is boolean. + * @returns True if the value is boolean, false otherwise. + * + * @example + * + * const value1 = true; + * const value2 = 0; + * const value3 = 'abc'; + * + * console.log(isBoolean(value1)); // true + * console.log(isBoolean(value2)); // false + * console.log(isBoolean(value3)); // false + * + */ +declare function isBoolean(value?: any): value is boolean; +//#endregion +export { isBoolean }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isBoolean.js b/node_modules/es-toolkit/dist/compat/predicate/isBoolean.js new file mode 100644 index 0000000000000000000000000000000000000000..aa9a50c26802f302fbb3b6c99a6fc681eb40a5ad --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isBoolean.js @@ -0,0 +1,28 @@ +//#region src/compat/predicate/isBoolean.ts +/** +* Checks if the given value is boolean. +* +* This function tests whether the provided value is strictly `boolean`. +* It returns `true` if the value is `boolean`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`. +* +* @param value - The Value to test if it is boolean. +* @returns True if the value is boolean, false otherwise. +* +* @example +* +* const value1 = true; +* const value2 = 0; +* const value3 = 'abc'; +* +* console.log(isBoolean(value1)); // true +* console.log(isBoolean(value2)); // false +* console.log(isBoolean(value3)); // false +* +*/ +function isBoolean(value) { + return typeof value === "boolean" || value instanceof Boolean; +} +//#endregion +exports.isBoolean = isBoolean; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isBoolean.mjs b/node_modules/es-toolkit/dist/compat/predicate/isBoolean.mjs new file mode 100644 index 0000000000000000000000000000000000000000..da28b60065a2ed687412a2ff695d9537697fd4cf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isBoolean.mjs @@ -0,0 +1,28 @@ +//#region src/compat/predicate/isBoolean.ts +/** +* Checks if the given value is boolean. +* +* This function tests whether the provided value is strictly `boolean`. +* It returns `true` if the value is `boolean`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`. +* +* @param value - The Value to test if it is boolean. +* @returns True if the value is boolean, false otherwise. +* +* @example +* +* const value1 = true; +* const value2 = 0; +* const value3 = 'abc'; +* +* console.log(isBoolean(value1)); // true +* console.log(isBoolean(value2)); // false +* console.log(isBoolean(value3)); // false +* +*/ +function isBoolean(value) { + return typeof value === "boolean" || value instanceof Boolean; +} +//#endregion +export { isBoolean }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isBuffer.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isBuffer.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..69b03fd18e02cd02bac78e07f1212e1bf418a4e3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isBuffer.d.mts @@ -0,0 +1,22 @@ +//#region src/compat/predicate/isBuffer.d.ts +/** + * Checks if the given value is a Buffer instance. + * + * This function tests whether the provided value is an instance of Buffer. + * It returns `true` if the value is a Buffer, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`. + * + * @param x - The value to check if it is a Buffer. + * @returns Returns `true` if `x` is a Buffer, else `false`. + * + * @example + * const buffer = Buffer.from("test"); + * console.log(isBuffer(buffer)); // true + * + * const notBuffer = "not a buffer"; + * console.log(isBuffer(notBuffer)); // false + */ +declare function isBuffer(x?: any): boolean; +//#endregion +export { isBuffer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isBuffer.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isBuffer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..69b03fd18e02cd02bac78e07f1212e1bf418a4e3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isBuffer.d.ts @@ -0,0 +1,22 @@ +//#region src/compat/predicate/isBuffer.d.ts +/** + * Checks if the given value is a Buffer instance. + * + * This function tests whether the provided value is an instance of Buffer. + * It returns `true` if the value is a Buffer, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`. + * + * @param x - The value to check if it is a Buffer. + * @returns Returns `true` if `x` is a Buffer, else `false`. + * + * @example + * const buffer = Buffer.from("test"); + * console.log(isBuffer(buffer)); // true + * + * const notBuffer = "not a buffer"; + * console.log(isBuffer(notBuffer)); // false + */ +declare function isBuffer(x?: any): boolean; +//#endregion +export { isBuffer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isBuffer.js b/node_modules/es-toolkit/dist/compat/predicate/isBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..37d617250f5d90a1e5807ee76168a97105feebdd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isBuffer.js @@ -0,0 +1,25 @@ +const require_isBuffer = require("../../predicate/isBuffer.js"); +//#region src/compat/predicate/isBuffer.ts +/** +* Checks if the given value is a Buffer instance. +* +* This function tests whether the provided value is an instance of Buffer. +* It returns `true` if the value is a Buffer, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`. +* +* @param x - The value to check if it is a Buffer. +* @returns Returns `true` if `x` is a Buffer, else `false`. +* +* @example +* const buffer = Buffer.from("test"); +* console.log(isBuffer(buffer)); // true +* +* const notBuffer = "not a buffer"; +* console.log(isBuffer(notBuffer)); // false +*/ +function isBuffer(x) { + return require_isBuffer.isBuffer(x); +} +//#endregion +exports.isBuffer = isBuffer; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isBuffer.mjs b/node_modules/es-toolkit/dist/compat/predicate/isBuffer.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c16f460c33f424149335b528089b17d9dfd6bc84 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isBuffer.mjs @@ -0,0 +1,25 @@ +import { isBuffer as isBuffer$1 } from "../../predicate/isBuffer.mjs"; +//#region src/compat/predicate/isBuffer.ts +/** +* Checks if the given value is a Buffer instance. +* +* This function tests whether the provided value is an instance of Buffer. +* It returns `true` if the value is a Buffer, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`. +* +* @param x - The value to check if it is a Buffer. +* @returns Returns `true` if `x` is a Buffer, else `false`. +* +* @example +* const buffer = Buffer.from("test"); +* console.log(isBuffer(buffer)); // true +* +* const notBuffer = "not a buffer"; +* console.log(isBuffer(notBuffer)); // false +*/ +function isBuffer(x) { + return isBuffer$1(x); +} +//#endregion +export { isBuffer }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isDate.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isDate.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..31363e296a8b97ddc8a18d4c7d0666d98ccd2076 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isDate.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isDate.d.ts +/** + * Checks if `value` is a Date object. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a Date object, `false` otherwise. + * + * @example + * const value1 = new Date(); + * const value2 = '2024-01-01'; + * + * console.log(isDate(value1)); // true + * console.log(isDate(value2)); // false + */ +declare function isDate(value?: any): value is Date; +//#endregion +export { isDate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isDate.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isDate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..31363e296a8b97ddc8a18d4c7d0666d98ccd2076 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isDate.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isDate.d.ts +/** + * Checks if `value` is a Date object. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a Date object, `false` otherwise. + * + * @example + * const value1 = new Date(); + * const value2 = '2024-01-01'; + * + * console.log(isDate(value1)); // true + * console.log(isDate(value2)); // false + */ +declare function isDate(value?: any): value is Date; +//#endregion +export { isDate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isDate.js b/node_modules/es-toolkit/dist/compat/predicate/isDate.js new file mode 100644 index 0000000000000000000000000000000000000000..6372081ed7995e75dc1da2ebf2922ecf212e5055 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isDate.js @@ -0,0 +1,20 @@ +const require_isDate = require("../../predicate/isDate.js"); +//#region src/compat/predicate/isDate.ts +/** +* Checks if `value` is a Date object. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a Date object, `false` otherwise. +* +* @example +* const value1 = new Date(); +* const value2 = '2024-01-01'; +* +* console.log(isDate(value1)); // true +* console.log(isDate(value2)); // false +*/ +function isDate(value) { + return require_isDate.isDate(value); +} +//#endregion +exports.isDate = isDate; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isDate.mjs b/node_modules/es-toolkit/dist/compat/predicate/isDate.mjs new file mode 100644 index 0000000000000000000000000000000000000000..966d5d16cb80a797536e80890a9e768bd8e337b3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isDate.mjs @@ -0,0 +1,20 @@ +import { isDate as isDate$1 } from "../../predicate/isDate.mjs"; +//#region src/compat/predicate/isDate.ts +/** +* Checks if `value` is a Date object. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a Date object, `false` otherwise. +* +* @example +* const value1 = new Date(); +* const value2 = '2024-01-01'; +* +* console.log(isDate(value1)); // true +* console.log(isDate(value2)); // false +*/ +function isDate(value) { + return isDate$1(value); +} +//#endregion +export { isDate }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isElement.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isElement.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b7e9e425e1b83a9e23515895b2f064044408304e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isElement.d.mts @@ -0,0 +1,14 @@ +//#region src/compat/predicate/isElement.d.ts +/** + * Checks if `value` is likely a DOM element. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a DOM element, else `false`. + * + * @example + * console.log(isElement(document.body)); // true + * console.log(isElement('')); // false + */ +declare function isElement(value?: any): boolean; +//#endregion +export { isElement }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isElement.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isElement.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7e9e425e1b83a9e23515895b2f064044408304e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isElement.d.ts @@ -0,0 +1,14 @@ +//#region src/compat/predicate/isElement.d.ts +/** + * Checks if `value` is likely a DOM element. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a DOM element, else `false`. + * + * @example + * console.log(isElement(document.body)); // true + * console.log(isElement('')); // false + */ +declare function isElement(value?: any): boolean; +//#endregion +export { isElement }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isElement.js b/node_modules/es-toolkit/dist/compat/predicate/isElement.js new file mode 100644 index 0000000000000000000000000000000000000000..e2c1f34477d3f0f15c4c2fc0f585262356cdea10 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isElement.js @@ -0,0 +1,18 @@ +const require_isPlainObject = require("./isPlainObject.js"); +const require_isObjectLike = require("./isObjectLike.js"); +//#region src/compat/predicate/isElement.ts +/** +* Checks if `value` is likely a DOM element. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a DOM element, else `false`. +* +* @example +* console.log(isElement(document.body)); // true +* console.log(isElement('')); // false +*/ +function isElement(value) { + return require_isObjectLike.isObjectLike(value) && value.nodeType === 1 && !require_isPlainObject.isPlainObject(value); +} +//#endregion +exports.isElement = isElement; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isElement.mjs b/node_modules/es-toolkit/dist/compat/predicate/isElement.mjs new file mode 100644 index 0000000000000000000000000000000000000000..eae314d2e07aaaa66ab07b385697884e6971bda2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isElement.mjs @@ -0,0 +1,18 @@ +import { isPlainObject } from "./isPlainObject.mjs"; +import { isObjectLike } from "./isObjectLike.mjs"; +//#region src/compat/predicate/isElement.ts +/** +* Checks if `value` is likely a DOM element. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a DOM element, else `false`. +* +* @example +* console.log(isElement(document.body)); // true +* console.log(isElement('')); // false +*/ +function isElement(value) { + return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); +} +//#endregion +export { isElement }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isEmpty.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isEmpty.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9ab4228b648760b129c8e9766cd142cffcae49e1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isEmpty.d.mts @@ -0,0 +1,13 @@ +import { EmptyObjectOf } from "../_internal/EmptyObjectOf.mjs"; + +//#region src/compat/predicate/isEmpty.d.ts +declare function isEmpty(value?: T): boolean; +declare function isEmpty(value: string): value is ''; +declare function isEmpty(value: Map | Set | ArrayLike | null | undefined): boolean; +declare function isEmpty(value: object): boolean; +declare function isEmpty(value: T | null | undefined): value is EmptyObjectOf | null | undefined; +declare function isEmpty(value?: any): boolean; +//#endregion +export { isEmpty }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isEmpty.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isEmpty.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9cda7c1d3ec8c3f13f0b39dea451a8453bca55d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isEmpty.d.ts @@ -0,0 +1,13 @@ +import { EmptyObjectOf } from "../_internal/EmptyObjectOf.js"; + +//#region src/compat/predicate/isEmpty.d.ts +declare function isEmpty(value?: T): boolean; +declare function isEmpty(value: string): value is ''; +declare function isEmpty(value: Map | Set | ArrayLike | null | undefined): boolean; +declare function isEmpty(value: object): boolean; +declare function isEmpty(value: T | null | undefined): value is EmptyObjectOf | null | undefined; +declare function isEmpty(value?: any): boolean; +//#endregion +export { isEmpty }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isEmpty.js b/node_modules/es-toolkit/dist/compat/predicate/isEmpty.js new file mode 100644 index 0000000000000000000000000000000000000000..4daefa98c5d44db9f7e737dd1503c6cf61afcfc5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isEmpty.js @@ -0,0 +1,48 @@ +const require_isBuffer = require("../../predicate/isBuffer.js"); +const require_isArrayLike = require("./isArrayLike.js"); +const require_isArguments = require("./isArguments.js"); +const require_isPrototype = require("../_internal/isPrototype.js"); +const require_isTypedArray = require("./isTypedArray.js"); +//#region src/compat/predicate/isEmpty.ts +/** +* Checks if a given value is empty. +* +* - If the given value is a string, checks if it is an empty string. +* - If the given value is an array, `Map`, or `Set`, checks if its size is 0. +* - If the given value is an [array-like object](../predicate/isArrayLike.md), checks if its length is 0. +* - If the given value is an object, checks if it is an empty object with no properties. +* - Primitive values (booleans, numbers, or bigints) are considered empty. +* +* @param [value] - The value to check. +* @returns `true` if the value is empty, `false` otherwise. +* +* @example +* isEmpty(); // true +* isEmpty(null); // true +* isEmpty(""); // true +* isEmpty([]); // true +* isEmpty({}); // true +* isEmpty(new Map()); // true +* isEmpty(new Set()); // true +* isEmpty("hello"); // false +* isEmpty([1, 2, 3]); // false +* isEmpty({ a: 1 }); // false +* isEmpty(new Map([["key", "value"]])); // false +* isEmpty(new Set([1, 2, 3])); // false +*/ +function isEmpty(value) { + if (value == null) return true; + if (require_isArrayLike.isArrayLike(value)) { + if (typeof value.splice !== "function" && typeof value !== "string" && !require_isBuffer.isBuffer(value) && !require_isTypedArray.isTypedArray(value) && !require_isArguments.isArguments(value)) return false; + return value.length === 0; + } + if (typeof value === "object" || typeof value === "function") { + if (value instanceof Map || value instanceof Set) return value.size === 0; + const keys = Object.keys(value); + if (require_isPrototype.isPrototype(value)) return keys.filter((x) => x !== "constructor").length === 0; + return keys.length === 0; + } + return true; +} +//#endregion +exports.isEmpty = isEmpty; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isEmpty.mjs b/node_modules/es-toolkit/dist/compat/predicate/isEmpty.mjs new file mode 100644 index 0000000000000000000000000000000000000000..af0dd44ee95089e8c7f08a7409c3c0f4b2cd4ab7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isEmpty.mjs @@ -0,0 +1,48 @@ +import { isBuffer } from "../../predicate/isBuffer.mjs"; +import { isArrayLike } from "./isArrayLike.mjs"; +import { isArguments } from "./isArguments.mjs"; +import { isPrototype } from "../_internal/isPrototype.mjs"; +import { isTypedArray } from "./isTypedArray.mjs"; +//#region src/compat/predicate/isEmpty.ts +/** +* Checks if a given value is empty. +* +* - If the given value is a string, checks if it is an empty string. +* - If the given value is an array, `Map`, or `Set`, checks if its size is 0. +* - If the given value is an [array-like object](../predicate/isArrayLike.md), checks if its length is 0. +* - If the given value is an object, checks if it is an empty object with no properties. +* - Primitive values (booleans, numbers, or bigints) are considered empty. +* +* @param [value] - The value to check. +* @returns `true` if the value is empty, `false` otherwise. +* +* @example +* isEmpty(); // true +* isEmpty(null); // true +* isEmpty(""); // true +* isEmpty([]); // true +* isEmpty({}); // true +* isEmpty(new Map()); // true +* isEmpty(new Set()); // true +* isEmpty("hello"); // false +* isEmpty([1, 2, 3]); // false +* isEmpty({ a: 1 }); // false +* isEmpty(new Map([["key", "value"]])); // false +* isEmpty(new Set([1, 2, 3])); // false +*/ +function isEmpty(value) { + if (value == null) return true; + if (isArrayLike(value)) { + if (typeof value.splice !== "function" && typeof value !== "string" && !isBuffer(value) && !isTypedArray(value) && !isArguments(value)) return false; + return value.length === 0; + } + if (typeof value === "object" || typeof value === "function") { + if (value instanceof Map || value instanceof Set) return value.size === 0; + const keys = Object.keys(value); + if (isPrototype(value)) return keys.filter((x) => x !== "constructor").length === 0; + return keys.length === 0; + } + return true; +} +//#endregion +export { isEmpty }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..58fd416899f1ab566d9905f055a0dfa5aa42b6a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.d.mts @@ -0,0 +1,41 @@ +import { IsEqualCustomizer } from "../_internal/IsEqualCustomizer.mjs"; + +//#region src/compat/predicate/isEqualWith.d.ts +/** + * Compares two values for equality using a custom comparison function. + * + * 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. + * + * This function also uses the custom equality function to compare values inside objects, + * arrays, maps, sets, and other complex structures, ensuring a deep comparison. + * + * This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases. + * + * The custom comparison function can take up to six parameters: + * - `x`: The value from the first object `a`. + * - `y`: The value from the second object `b`. + * - `property`: The property key used to get `x` and `y`. + * - `xParent`: The parent of the first value `x`. + * - `yParent`: The parent of the second value `y`. + * - `stack`: An internal stack (Map) to handle circular references. + * + * @param a - The first value to compare. + * @param b - The second value to compare. + * @param [areValuesEqual=noop] - A function to customize the comparison. + * If it returns a boolean, that result will be used. If it returns undefined, + * the default equality comparison will be used. + * @returns `true` if the values are equal according to the customizer, otherwise `false`. + * + * @example + * const customizer = (a, b) => { + * if (typeof a === 'string' && typeof b === 'string') { + * return a.toLowerCase() === b.toLowerCase(); + * } + * }; + * isEqualWith('Hello', 'hello', customizer); // true + * isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true + * isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true + */ +declare function isEqualWith(a: any, b: any, areValuesEqual?: IsEqualCustomizer): boolean; +//#endregion +export { isEqualWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b2e40d10f2d7b4ec524f3b63a5d18563babefd63 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.d.ts @@ -0,0 +1,41 @@ +import { IsEqualCustomizer } from "../_internal/IsEqualCustomizer.js"; + +//#region src/compat/predicate/isEqualWith.d.ts +/** + * Compares two values for equality using a custom comparison function. + * + * 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. + * + * This function also uses the custom equality function to compare values inside objects, + * arrays, maps, sets, and other complex structures, ensuring a deep comparison. + * + * This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases. + * + * The custom comparison function can take up to six parameters: + * - `x`: The value from the first object `a`. + * - `y`: The value from the second object `b`. + * - `property`: The property key used to get `x` and `y`. + * - `xParent`: The parent of the first value `x`. + * - `yParent`: The parent of the second value `y`. + * - `stack`: An internal stack (Map) to handle circular references. + * + * @param a - The first value to compare. + * @param b - The second value to compare. + * @param [areValuesEqual=noop] - A function to customize the comparison. + * If it returns a boolean, that result will be used. If it returns undefined, + * the default equality comparison will be used. + * @returns `true` if the values are equal according to the customizer, otherwise `false`. + * + * @example + * const customizer = (a, b) => { + * if (typeof a === 'string' && typeof b === 'string') { + * return a.toLowerCase() === b.toLowerCase(); + * } + * }; + * isEqualWith('Hello', 'hello', customizer); // true + * isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true + * isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true + */ +declare function isEqualWith(a: any, b: any, areValuesEqual?: IsEqualCustomizer): boolean; +//#endregion +export { isEqualWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.js b/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.js new file mode 100644 index 0000000000000000000000000000000000000000..8556d63eca70870999db578ce02a26eb1f8360e2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.js @@ -0,0 +1,49 @@ +const require_after = require("../../function/after.js"); +const require_isEqualWith = require("../../predicate/isEqualWith.js"); +//#region src/compat/predicate/isEqualWith.ts +/** +* Compares two values for equality using a custom comparison function. +* +* 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. +* +* This function also uses the custom equality function to compare values inside objects, +* arrays, maps, sets, and other complex structures, ensuring a deep comparison. +* +* This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases. +* +* The custom comparison function can take up to six parameters: +* - `x`: The value from the first object `a`. +* - `y`: The value from the second object `b`. +* - `property`: The property key used to get `x` and `y`. +* - `xParent`: The parent of the first value `x`. +* - `yParent`: The parent of the second value `y`. +* - `stack`: An internal stack (Map) to handle circular references. +* +* @param a - The first value to compare. +* @param b - The second value to compare. +* @param [areValuesEqual=noop] - A function to customize the comparison. +* If it returns a boolean, that result will be used. If it returns undefined, +* the default equality comparison will be used. +* @returns `true` if the values are equal according to the customizer, otherwise `false`. +* +* @example +* const customizer = (a, b) => { +* if (typeof a === 'string' && typeof b === 'string') { +* return a.toLowerCase() === b.toLowerCase(); +* } +* }; +* isEqualWith('Hello', 'hello', customizer); // true +* isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true +* isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true +*/ +function isEqualWith(a, b, areValuesEqual) { + if (typeof areValuesEqual !== "function") areValuesEqual = () => void 0; + return require_isEqualWith.isEqualWith(a, b, (...args) => { + const result = areValuesEqual(...args); + if (result !== void 0) return Boolean(result); + if (a instanceof Map && b instanceof Map) return isEqualWith(Array.from(a), Array.from(b), require_after.after(2, areValuesEqual)); + if (a instanceof Set && b instanceof Set) return isEqualWith(Array.from(a), Array.from(b), require_after.after(2, areValuesEqual)); + }); +} +//#endregion +exports.isEqualWith = isEqualWith; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.mjs b/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..277efad39558825ffaa0852b226add5e2f6f770f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.mjs @@ -0,0 +1,49 @@ +import { after } from "../../function/after.mjs"; +import { isEqualWith as isEqualWith$1 } from "../../predicate/isEqualWith.mjs"; +//#region src/compat/predicate/isEqualWith.ts +/** +* Compares two values for equality using a custom comparison function. +* +* 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. +* +* This function also uses the custom equality function to compare values inside objects, +* arrays, maps, sets, and other complex structures, ensuring a deep comparison. +* +* This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases. +* +* The custom comparison function can take up to six parameters: +* - `x`: The value from the first object `a`. +* - `y`: The value from the second object `b`. +* - `property`: The property key used to get `x` and `y`. +* - `xParent`: The parent of the first value `x`. +* - `yParent`: The parent of the second value `y`. +* - `stack`: An internal stack (Map) to handle circular references. +* +* @param a - The first value to compare. +* @param b - The second value to compare. +* @param [areValuesEqual=noop] - A function to customize the comparison. +* If it returns a boolean, that result will be used. If it returns undefined, +* the default equality comparison will be used. +* @returns `true` if the values are equal according to the customizer, otherwise `false`. +* +* @example +* const customizer = (a, b) => { +* if (typeof a === 'string' && typeof b === 'string') { +* return a.toLowerCase() === b.toLowerCase(); +* } +* }; +* isEqualWith('Hello', 'hello', customizer); // true +* isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true +* isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true +*/ +function isEqualWith(a, b, areValuesEqual) { + if (typeof areValuesEqual !== "function") areValuesEqual = () => void 0; + return isEqualWith$1(a, b, (...args) => { + const result = areValuesEqual(...args); + if (result !== void 0) return Boolean(result); + if (a instanceof Map && b instanceof Map) return isEqualWith(Array.from(a), Array.from(b), after(2, areValuesEqual)); + if (a instanceof Set && b instanceof Set) return isEqualWith(Array.from(a), Array.from(b), after(2, areValuesEqual)); + }); +} +//#endregion +export { isEqualWith }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isError.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isError.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..14a5d72f3d5a395eddd2bc5ccfaec63c8b23c60a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isError.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isError.d.ts +/** + * Checks if `value` is an Error object. + * + * @param value The value to check. + * @returns Returns `true` if `value` is an Error object, `false` otherwise. + * + * @example + * ```typescript + * console.log(isError(new Error())); // true + * console.log(isError('Error')); // false + * console.log(isError({ name: 'Error', message: '' })); // false + * ``` + */ +declare function isError(value: any): value is Error; +//#endregion +export { isError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isError.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isError.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..14a5d72f3d5a395eddd2bc5ccfaec63c8b23c60a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isError.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isError.d.ts +/** + * Checks if `value` is an Error object. + * + * @param value The value to check. + * @returns Returns `true` if `value` is an Error object, `false` otherwise. + * + * @example + * ```typescript + * console.log(isError(new Error())); // true + * console.log(isError('Error')); // false + * console.log(isError({ name: 'Error', message: '' })); // false + * ``` + */ +declare function isError(value: any): value is Error; +//#endregion +export { isError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isError.js b/node_modules/es-toolkit/dist/compat/predicate/isError.js new file mode 100644 index 0000000000000000000000000000000000000000..722d58861828c87d998beb7219ea162f36b19413 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isError.js @@ -0,0 +1,20 @@ +const require_getTag = require("../_internal/getTag.js"); +//#region src/compat/predicate/isError.ts +/** +* Checks if `value` is an Error object. +* +* @param value The value to check. +* @returns Returns `true` if `value` is an Error object, `false` otherwise. +* +* @example +* ```typescript +* console.log(isError(new Error())); // true +* console.log(isError('Error')); // false +* console.log(isError({ name: 'Error', message: '' })); // false +* ``` +*/ +function isError(value) { + return require_getTag.getTag(value) === "[object Error]"; +} +//#endregion +exports.isError = isError; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isError.mjs b/node_modules/es-toolkit/dist/compat/predicate/isError.mjs new file mode 100644 index 0000000000000000000000000000000000000000..baf6b71270141d919244ce2331aa7ef0196902c7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isError.mjs @@ -0,0 +1,20 @@ +import { getTag } from "../_internal/getTag.mjs"; +//#region src/compat/predicate/isError.ts +/** +* Checks if `value` is an Error object. +* +* @param value The value to check. +* @returns Returns `true` if `value` is an Error object, `false` otherwise. +* +* @example +* ```typescript +* console.log(isError(new Error())); // true +* console.log(isError('Error')); // false +* console.log(isError({ name: 'Error', message: '' })); // false +* ``` +*/ +function isError(value) { + return getTag(value) === "[object Error]"; +} +//#endregion +export { isError }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isFinite.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isFinite.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..dfb032be29d4cb54f9d3381f4950e5b45421c800 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isFinite.d.mts @@ -0,0 +1,28 @@ +//#region src/compat/predicate/isFinite.d.ts +/** + * Checks if `value` is a finite number. + * + * Acts as a type guard for `number` values — returning `true` only when `value` + * is of type `number` and finite (not `Infinity`, `-Infinity`, or `NaN`). + * + * @param value The value to check. + * @returns Returns `true` if `value` is a finite number, `false` otherwise. + * + * @example + * ```typescript + * const value1 = 100; + * const value2 = Infinity; + * const value3 = '100'; + * + * console.log(isFinite(value1)); // true + * console.log(isFinite(value2)); // false + * console.log(isFinite(value3)); // false + * + * if (isFinite(value1)) { + * console.log(value1.toFixed(2)); + * } + * ``` + */ +declare function isFinite(value: unknown): value is number; +//#endregion +export { isFinite }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isFinite.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isFinite.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dfb032be29d4cb54f9d3381f4950e5b45421c800 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isFinite.d.ts @@ -0,0 +1,28 @@ +//#region src/compat/predicate/isFinite.d.ts +/** + * Checks if `value` is a finite number. + * + * Acts as a type guard for `number` values — returning `true` only when `value` + * is of type `number` and finite (not `Infinity`, `-Infinity`, or `NaN`). + * + * @param value The value to check. + * @returns Returns `true` if `value` is a finite number, `false` otherwise. + * + * @example + * ```typescript + * const value1 = 100; + * const value2 = Infinity; + * const value3 = '100'; + * + * console.log(isFinite(value1)); // true + * console.log(isFinite(value2)); // false + * console.log(isFinite(value3)); // false + * + * if (isFinite(value1)) { + * console.log(value1.toFixed(2)); + * } + * ``` + */ +declare function isFinite(value: unknown): value is number; +//#endregion +export { isFinite }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isFinite.js b/node_modules/es-toolkit/dist/compat/predicate/isFinite.js new file mode 100644 index 0000000000000000000000000000000000000000..e43bd7cb7b8de5c96bff82cb999ca27ec532942a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isFinite.js @@ -0,0 +1,30 @@ +//#region src/compat/predicate/isFinite.ts +/** +* Checks if `value` is a finite number. +* +* Acts as a type guard for `number` values — returning `true` only when `value` +* is of type `number` and finite (not `Infinity`, `-Infinity`, or `NaN`). +* +* @param value The value to check. +* @returns Returns `true` if `value` is a finite number, `false` otherwise. +* +* @example +* ```typescript +* const value1 = 100; +* const value2 = Infinity; +* const value3 = '100'; +* +* console.log(isFinite(value1)); // true +* console.log(isFinite(value2)); // false +* console.log(isFinite(value3)); // false +* +* if (isFinite(value1)) { +* console.log(value1.toFixed(2)); +* } +* ``` +*/ +function isFinite(value) { + return Number.isFinite(value); +} +//#endregion +exports.isFinite = isFinite; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isFinite.mjs b/node_modules/es-toolkit/dist/compat/predicate/isFinite.mjs new file mode 100644 index 0000000000000000000000000000000000000000..919e7fdbc90fecf930f3014f3443562e79561671 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isFinite.mjs @@ -0,0 +1,30 @@ +//#region src/compat/predicate/isFinite.ts +/** +* Checks if `value` is a finite number. +* +* Acts as a type guard for `number` values — returning `true` only when `value` +* is of type `number` and finite (not `Infinity`, `-Infinity`, or `NaN`). +* +* @param value The value to check. +* @returns Returns `true` if `value` is a finite number, `false` otherwise. +* +* @example +* ```typescript +* const value1 = 100; +* const value2 = Infinity; +* const value3 = '100'; +* +* console.log(isFinite(value1)); // true +* console.log(isFinite(value2)); // false +* console.log(isFinite(value3)); // false +* +* if (isFinite(value1)) { +* console.log(value1.toFixed(2)); +* } +* ``` +*/ +function isFinite(value) { + return Number.isFinite(value); +} +//#endregion +export { isFinite }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isFunction.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isFunction.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4b31a9f902637176a93d779bbe211f4959f54e6b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isFunction.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isFunction.d.ts +/** + * Checks if `value` is a function. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a function, else `false`. + * + * @example + * isFunction(Array.prototype.slice); // true + * isFunction(async function () {}); // true + * isFunction(function* () {}); // true + * isFunction(Proxy); // true + * isFunction(Int8Array); // true + */ +declare function isFunction(value: any): value is (...args: any[]) => any; +//#endregion +export { isFunction }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isFunction.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isFunction.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4b31a9f902637176a93d779bbe211f4959f54e6b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isFunction.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isFunction.d.ts +/** + * Checks if `value` is a function. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a function, else `false`. + * + * @example + * isFunction(Array.prototype.slice); // true + * isFunction(async function () {}); // true + * isFunction(function* () {}); // true + * isFunction(Proxy); // true + * isFunction(Int8Array); // true + */ +declare function isFunction(value: any): value is (...args: any[]) => any; +//#endregion +export { isFunction }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isFunction.js b/node_modules/es-toolkit/dist/compat/predicate/isFunction.js new file mode 100644 index 0000000000000000000000000000000000000000..e3500c4459b55024d35bf4bcbb87409ad76c1a9f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isFunction.js @@ -0,0 +1,19 @@ +//#region src/compat/predicate/isFunction.ts +/** +* Checks if `value` is a function. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a function, else `false`. +* +* @example +* isFunction(Array.prototype.slice); // true +* isFunction(async function () {}); // true +* isFunction(function* () {}); // true +* isFunction(Proxy); // true +* isFunction(Int8Array); // true +*/ +function isFunction(value) { + return typeof value === "function"; +} +//#endregion +exports.isFunction = isFunction; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isFunction.mjs b/node_modules/es-toolkit/dist/compat/predicate/isFunction.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d2bd058f7df874cefdb6e84ece4de4e30ddea937 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isFunction.mjs @@ -0,0 +1,19 @@ +//#region src/compat/predicate/isFunction.ts +/** +* Checks if `value` is a function. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a function, else `false`. +* +* @example +* isFunction(Array.prototype.slice); // true +* isFunction(async function () {}); // true +* isFunction(function* () {}); // true +* isFunction(Proxy); // true +* isFunction(Int8Array); // true +*/ +function isFunction(value) { + return typeof value === "function"; +} +//#endregion +export { isFunction }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isInteger.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isInteger.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..5d03a93bab19cb01a2d867954c742b508d245fdf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isInteger.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/predicate/isInteger.d.ts +/** + * Checks if `value` is an integer. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. + * + * @param value - The value to check + * @returns `true` if `value` is integer, otherwise `false`. + * + * @example + * isInteger(3); // Returns: true + * isInteger(Infinity); // Returns: false + * isInteger('3'); // Returns: false + * isInteger([]); // Returns: false + */ +declare function isInteger(value?: any): boolean; +//#endregion +export { isInteger }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isInteger.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isInteger.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d03a93bab19cb01a2d867954c742b508d245fdf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isInteger.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/predicate/isInteger.d.ts +/** + * Checks if `value` is an integer. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. + * + * @param value - The value to check + * @returns `true` if `value` is integer, otherwise `false`. + * + * @example + * isInteger(3); // Returns: true + * isInteger(Infinity); // Returns: false + * isInteger('3'); // Returns: false + * isInteger([]); // Returns: false + */ +declare function isInteger(value?: any): boolean; +//#endregion +export { isInteger }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isInteger.js b/node_modules/es-toolkit/dist/compat/predicate/isInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..23eb177995bd0f1a2f1901584df9d65679256041 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isInteger.js @@ -0,0 +1,20 @@ +//#region src/compat/predicate/isInteger.ts +/** +* Checks if `value` is an integer. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. +* +* @param value - The value to check +* @returns `true` if `value` is integer, otherwise `false`. +* +* @example +* isInteger(3); // Returns: true +* isInteger(Infinity); // Returns: false +* isInteger('3'); // Returns: false +* isInteger([]); // Returns: false +*/ +function isInteger(value) { + return Number.isInteger(value); +} +//#endregion +exports.isInteger = isInteger; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isInteger.mjs b/node_modules/es-toolkit/dist/compat/predicate/isInteger.mjs new file mode 100644 index 0000000000000000000000000000000000000000..188c92c9a451f7ed3069d97f2bba10007c50b42a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isInteger.mjs @@ -0,0 +1,20 @@ +//#region src/compat/predicate/isInteger.ts +/** +* Checks if `value` is an integer. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. +* +* @param value - The value to check +* @returns `true` if `value` is integer, otherwise `false`. +* +* @example +* isInteger(3); // Returns: true +* isInteger(Infinity); // Returns: false +* isInteger('3'); // Returns: false +* isInteger([]); // Returns: false +*/ +function isInteger(value) { + return Number.isInteger(value); +} +//#endregion +export { isInteger }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isLength.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isLength.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b3393077b8733f813616b69120746a7c7c72cd52 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isLength.d.mts @@ -0,0 +1,25 @@ +//#region src/compat/predicate/isLength.d.ts +/** + * Checks if a given value is a valid length. + * + * A valid length is of type `number`, is a non-negative integer, and is less than or equal to + * JavaScript's maximum safe integer (`Number.MAX_SAFE_INTEGER`). + * It returns `true` if the value is a valid length, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the + * argument to a valid length (`number`). + * + * @param value The value to check. + * @returns Returns `true` if `value` is a valid length, else `false`. + * + * @example + * isLength(0); // true + * isLength(42); // true + * isLength(-1); // false + * isLength(1.5); // false + * isLength(Number.MAX_SAFE_INTEGER); // true + * isLength(Number.MAX_SAFE_INTEGER + 1); // false + */ +declare function isLength(value?: any): boolean; +//#endregion +export { isLength }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isLength.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isLength.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3393077b8733f813616b69120746a7c7c72cd52 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isLength.d.ts @@ -0,0 +1,25 @@ +//#region src/compat/predicate/isLength.d.ts +/** + * Checks if a given value is a valid length. + * + * A valid length is of type `number`, is a non-negative integer, and is less than or equal to + * JavaScript's maximum safe integer (`Number.MAX_SAFE_INTEGER`). + * It returns `true` if the value is a valid length, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the + * argument to a valid length (`number`). + * + * @param value The value to check. + * @returns Returns `true` if `value` is a valid length, else `false`. + * + * @example + * isLength(0); // true + * isLength(42); // true + * isLength(-1); // false + * isLength(1.5); // false + * isLength(Number.MAX_SAFE_INTEGER); // true + * isLength(Number.MAX_SAFE_INTEGER + 1); // false + */ +declare function isLength(value?: any): boolean; +//#endregion +export { isLength }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isLength.js b/node_modules/es-toolkit/dist/compat/predicate/isLength.js new file mode 100644 index 0000000000000000000000000000000000000000..0ffa16991984fa64510ee5b497dcb9a091e12799 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isLength.js @@ -0,0 +1,27 @@ +//#region src/compat/predicate/isLength.ts +/** +* Checks if a given value is a valid length. +* +* A valid length is of type `number`, is a non-negative integer, and is less than or equal to +* JavaScript's maximum safe integer (`Number.MAX_SAFE_INTEGER`). +* It returns `true` if the value is a valid length, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the +* argument to a valid length (`number`). +* +* @param value The value to check. +* @returns Returns `true` if `value` is a valid length, else `false`. +* +* @example +* isLength(0); // true +* isLength(42); // true +* isLength(-1); // false +* isLength(1.5); // false +* isLength(Number.MAX_SAFE_INTEGER); // true +* isLength(Number.MAX_SAFE_INTEGER + 1); // false +*/ +function isLength(value) { + return Number.isSafeInteger(value) && value >= 0; +} +//#endregion +exports.isLength = isLength; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isLength.mjs b/node_modules/es-toolkit/dist/compat/predicate/isLength.mjs new file mode 100644 index 0000000000000000000000000000000000000000..364db558bc7cbd7bfab13b4a38333779b1b5b799 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isLength.mjs @@ -0,0 +1,27 @@ +//#region src/compat/predicate/isLength.ts +/** +* Checks if a given value is a valid length. +* +* A valid length is of type `number`, is a non-negative integer, and is less than or equal to +* JavaScript's maximum safe integer (`Number.MAX_SAFE_INTEGER`). +* It returns `true` if the value is a valid length, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the +* argument to a valid length (`number`). +* +* @param value The value to check. +* @returns Returns `true` if `value` is a valid length, else `false`. +* +* @example +* isLength(0); // true +* isLength(42); // true +* isLength(-1); // false +* isLength(1.5); // false +* isLength(Number.MAX_SAFE_INTEGER); // true +* isLength(Number.MAX_SAFE_INTEGER + 1); // false +*/ +function isLength(value) { + return Number.isSafeInteger(value) && value >= 0; +} +//#endregion +export { isLength }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMap.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isMap.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8338e819230a59ea32fb76af8398e93834039081 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMap.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isMap.d.ts +/** + * Checks if a given value is `Map`. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`. + * + * @param value The value to check if it is a `Map`. + * @returns Returns `true` if `value` is a `Map`, else `false`. + * + * @example + * const value1 = new Map(); + * const value2 = new Set(); + * const value3 = new WeakMap(); + * + * console.log(isMap(value1)); // true + * console.log(isMap(value2)); // false + * console.log(isMap(value3)); // false + */ +declare function isMap(value?: any): value is Map; +//#endregion +export { isMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMap.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8338e819230a59ea32fb76af8398e93834039081 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMap.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isMap.d.ts +/** + * Checks if a given value is `Map`. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`. + * + * @param value The value to check if it is a `Map`. + * @returns Returns `true` if `value` is a `Map`, else `false`. + * + * @example + * const value1 = new Map(); + * const value2 = new Set(); + * const value3 = new WeakMap(); + * + * console.log(isMap(value1)); // true + * console.log(isMap(value2)); // false + * console.log(isMap(value3)); // false + */ +declare function isMap(value?: any): value is Map; +//#endregion +export { isMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMap.js b/node_modules/es-toolkit/dist/compat/predicate/isMap.js new file mode 100644 index 0000000000000000000000000000000000000000..0b4148dfa2b2684e8b48395103d1f94645844c07 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMap.js @@ -0,0 +1,24 @@ +const require_isMap = require("../../predicate/isMap.js"); +//#region src/compat/predicate/isMap.ts +/** +* Checks if a given value is `Map`. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`. +* +* @param value The value to check if it is a `Map`. +* @returns Returns `true` if `value` is a `Map`, else `false`. +* +* @example +* const value1 = new Map(); +* const value2 = new Set(); +* const value3 = new WeakMap(); +* +* console.log(isMap(value1)); // true +* console.log(isMap(value2)); // false +* console.log(isMap(value3)); // false +*/ +function isMap(value) { + return require_isMap.isMap(value); +} +//#endregion +exports.isMap = isMap; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMap.mjs b/node_modules/es-toolkit/dist/compat/predicate/isMap.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6021e232d809ce0232b5d8513e28c246481942b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMap.mjs @@ -0,0 +1,24 @@ +import { isMap as isMap$1 } from "../../predicate/isMap.mjs"; +//#region src/compat/predicate/isMap.ts +/** +* Checks if a given value is `Map`. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`. +* +* @param value The value to check if it is a `Map`. +* @returns Returns `true` if `value` is a `Map`, else `false`. +* +* @example +* const value1 = new Map(); +* const value2 = new Set(); +* const value3 = new WeakMap(); +* +* console.log(isMap(value1)); // true +* console.log(isMap(value2)); // false +* console.log(isMap(value3)); // false +*/ +function isMap(value) { + return isMap$1(value); +} +//#endregion +export { isMap }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMatch.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isMatch.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9ac1e1923c57dfea1c3c4df78d077fc248550eb8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMatch.d.mts @@ -0,0 +1,32 @@ +//#region src/compat/predicate/isMatch.d.ts +/** + * Checks if the target matches the source by comparing their structures and values. + * This function supports deep comparison for objects, arrays, maps, and sets. + * + * @param target - The target value to match against. + * @param source - The source value to match with. + * @returns Returns `true` if the target matches the source, otherwise `false`. + * + * @example + * // Basic usage + * isMatch({ a: 1, b: 2 }, { a: 1 }); // true + * + * @example + * // Matching arrays + * isMatch([1, 2, 3], [1, 2, 3]); // true + * + * @example + * // Matching maps + * const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]); + * const sourceMap = new Map([['key1', 'value1']]); + * isMatch(targetMap, sourceMap); // true + * + * @example + * // Matching sets + * const targetSet = new Set([1, 2, 3]); + * const sourceSet = new Set([1, 2]); + * isMatch(targetSet, sourceSet); // true + */ +declare function isMatch(target: object, source: object): boolean; +//#endregion +export { isMatch }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMatch.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isMatch.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ac1e1923c57dfea1c3c4df78d077fc248550eb8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMatch.d.ts @@ -0,0 +1,32 @@ +//#region src/compat/predicate/isMatch.d.ts +/** + * Checks if the target matches the source by comparing their structures and values. + * This function supports deep comparison for objects, arrays, maps, and sets. + * + * @param target - The target value to match against. + * @param source - The source value to match with. + * @returns Returns `true` if the target matches the source, otherwise `false`. + * + * @example + * // Basic usage + * isMatch({ a: 1, b: 2 }, { a: 1 }); // true + * + * @example + * // Matching arrays + * isMatch([1, 2, 3], [1, 2, 3]); // true + * + * @example + * // Matching maps + * const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]); + * const sourceMap = new Map([['key1', 'value1']]); + * isMatch(targetMap, sourceMap); // true + * + * @example + * // Matching sets + * const targetSet = new Set([1, 2, 3]); + * const sourceSet = new Set([1, 2]); + * isMatch(targetSet, sourceSet); // true + */ +declare function isMatch(target: object, source: object): boolean; +//#endregion +export { isMatch }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMatch.js b/node_modules/es-toolkit/dist/compat/predicate/isMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..eed39738787551bc89ffa00190ed568938f62d3e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMatch.js @@ -0,0 +1,35 @@ +const require_isMatchWith = require("./isMatchWith.js"); +//#region src/compat/predicate/isMatch.ts +/** +* Checks if the target matches the source by comparing their structures and values. +* This function supports deep comparison for objects, arrays, maps, and sets. +* +* @param target - The target value to match against. +* @param source - The source value to match with. +* @returns Returns `true` if the target matches the source, otherwise `false`. +* +* @example +* // Basic usage +* isMatch({ a: 1, b: 2 }, { a: 1 }); // true +* +* @example +* // Matching arrays +* isMatch([1, 2, 3], [1, 2, 3]); // true +* +* @example +* // Matching maps +* const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]); +* const sourceMap = new Map([['key1', 'value1']]); +* isMatch(targetMap, sourceMap); // true +* +* @example +* // Matching sets +* const targetSet = new Set([1, 2, 3]); +* const sourceSet = new Set([1, 2]); +* isMatch(targetSet, sourceSet); // true +*/ +function isMatch(target, source) { + return require_isMatchWith.isMatchWith(target, source, () => void 0); +} +//#endregion +exports.isMatch = isMatch; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMatch.mjs b/node_modules/es-toolkit/dist/compat/predicate/isMatch.mjs new file mode 100644 index 0000000000000000000000000000000000000000..42414f43d550bd5a8c7c35bf1b188d1c0e9f7132 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMatch.mjs @@ -0,0 +1,35 @@ +import { isMatchWith } from "./isMatchWith.mjs"; +//#region src/compat/predicate/isMatch.ts +/** +* Checks if the target matches the source by comparing their structures and values. +* This function supports deep comparison for objects, arrays, maps, and sets. +* +* @param target - The target value to match against. +* @param source - The source value to match with. +* @returns Returns `true` if the target matches the source, otherwise `false`. +* +* @example +* // Basic usage +* isMatch({ a: 1, b: 2 }, { a: 1 }); // true +* +* @example +* // Matching arrays +* isMatch([1, 2, 3], [1, 2, 3]); // true +* +* @example +* // Matching maps +* const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]); +* const sourceMap = new Map([['key1', 'value1']]); +* isMatch(targetMap, sourceMap); // true +* +* @example +* // Matching sets +* const targetSet = new Set([1, 2, 3]); +* const sourceSet = new Set([1, 2]); +* isMatch(targetSet, sourceSet); // true +*/ +function isMatch(target, source) { + return isMatchWith(target, source, () => void 0); +} +//#endregion +export { isMatch }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..19bc72daf656b606b70c800791372ecaa913300f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.d.mts @@ -0,0 +1,31 @@ +import { IsMatchWithCustomizer } from "../_internal/IsMatchWithCustomizer.mjs"; + +//#region src/compat/predicate/isMatchWith.d.ts +/** + * Performs a deep comparison between a target value and a source pattern to determine if they match, + * using a custom comparison function for fine-grained control over the matching logic. + * + * @param target - The value to be tested for matching + * @param source - The pattern/template to match against + * @param compare - Custom comparison function for fine-grained control + * @returns `true` if the target matches the source pattern, `false` otherwise + * + * @example + * // Basic matching with custom comparator + * const caseInsensitiveCompare = (objVal, srcVal) => { + * if (typeof objVal === 'string' && typeof srcVal === 'string') { + * return objVal.toLowerCase() === srcVal.toLowerCase(); + * } + * return undefined; + * }; + * + * isMatchWith( + * { name: 'JOHN', age: 30 }, + * { name: 'john' }, + * caseInsensitiveCompare + * ); // true + */ +declare function isMatchWith(target: object, source: object, compare: IsMatchWithCustomizer): boolean; +declare function isSetMatch(target: unknown, source: Set, compare: (objValue: any, srcValue: any, key: PropertyKey, object: any, source: any, stack?: Map) => boolean | undefined, stack?: Map): boolean; +//#endregion +export { isMatchWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d5dc9657d8a6d1361829cf0fc8ea89f9281ef01 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.d.ts @@ -0,0 +1,31 @@ +import { IsMatchWithCustomizer } from "../_internal/IsMatchWithCustomizer.js"; + +//#region src/compat/predicate/isMatchWith.d.ts +/** + * Performs a deep comparison between a target value and a source pattern to determine if they match, + * using a custom comparison function for fine-grained control over the matching logic. + * + * @param target - The value to be tested for matching + * @param source - The pattern/template to match against + * @param compare - Custom comparison function for fine-grained control + * @returns `true` if the target matches the source pattern, `false` otherwise + * + * @example + * // Basic matching with custom comparator + * const caseInsensitiveCompare = (objVal, srcVal) => { + * if (typeof objVal === 'string' && typeof srcVal === 'string') { + * return objVal.toLowerCase() === srcVal.toLowerCase(); + * } + * return undefined; + * }; + * + * isMatchWith( + * { name: 'JOHN', age: 30 }, + * { name: 'john' }, + * caseInsensitiveCompare + * ); // true + */ +declare function isMatchWith(target: object, source: object, compare: IsMatchWithCustomizer): boolean; +declare function isSetMatch(target: unknown, source: Set, compare: (objValue: any, srcValue: any, key: PropertyKey, object: any, source: any, stack?: Map) => boolean | undefined, stack?: Map): boolean; +//#endregion +export { isMatchWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.js b/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.js new file mode 100644 index 0000000000000000000000000000000000000000..980bf2be8725dfec9b3e68e7b70838d0c95720ca --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.js @@ -0,0 +1,155 @@ +const require_isPrimitive = require("../../predicate/isPrimitive.js"); +const require_eq = require("../util/eq.js"); +const require_isObject = require("./isObject.js"); +//#region src/compat/predicate/isMatchWith.ts +/** +* Performs a deep comparison between a target value and a source pattern to determine if they match, +* using a custom comparison function for fine-grained control over the matching logic. +* +* This function recursively traverses both values, calling the custom compare function for each +* property/element pair. If the compare function returns a boolean, that result is used directly. +* If it returns undefined, the default matching behavior continues recursively. +* +* The matching behavior varies by data type: +* - **Objects**: Matches if all properties in the source exist in the target and match +* - **Arrays**: Matches if all elements in the source array can be found in the target array (order-independent) +* - **Maps**: Matches if all key-value pairs in the source Map exist and match in the target Map +* - **Sets**: Matches if all elements in the source Set can be found in the target Set +* - **Functions**: Matches using strict equality, or object comparison if the function has properties +* - **Primitives**: Matches using strict equality +* +* Special cases: +* - Empty objects, arrays, Maps, and Sets always match any target +* - `null` and `undefined` source values have specific matching rules +* - Circular references are handled using an internal stack to prevent infinite recursion +* +* @param target - The value to be tested for matching +* @param source - The pattern/template to match against +* @param [compare] - Optional custom comparison function that receives: +* - `objValue` - The value from the target at the current path +* - `srcValue` - The value from the source at the current path +* - `key` - The property key or array index being compared +* - `object` - The parent object/array from the target +* - `source` - The parent object/array from the source +* - `stack` - Internal Map used for circular reference detection +* Should return `true` for a match, `false` for no match, or `undefined` to continue with default behavior +* +* @returns `true` if the target matches the source pattern, `false` otherwise +* +* @example +* // Basic matching without custom comparator +* isMatchWith({ a: 1, b: 2 }, { a: 1 }); // true +* isMatchWith([1, 2, 3], [1, 3]); // true +* +* @example +* // Custom comparison for case-insensitive string matching +* const caseInsensitiveCompare = (objVal, srcVal) => { +* if (typeof objVal === 'string' && typeof srcVal === 'string') { +* return objVal.toLowerCase() === srcVal.toLowerCase(); +* } +* return undefined; // Use default behavior for non-strings +* }; +* +* isMatchWith( +* { name: 'JOHN', age: 30 }, +* { name: 'john' }, +* caseInsensitiveCompare +* ); // true +* +* @example +* // Custom comparison for range matching +* const rangeCompare = (objVal, srcVal, key) => { +* if (key === 'age' && typeof srcVal === 'object' && srcVal.min !== undefined) { +* return objVal >= srcVal.min && objVal <= srcVal.max; +* } +* return undefined; +* }; +* +* isMatchWith( +* { name: 'John', age: 25 }, +* { age: { min: 18, max: 30 } }, +* rangeCompare +* ); // true +*/ +function isMatchWith(target, source, compare) { + if (typeof compare !== "function") return isMatchWith(target, source, () => void 0); + return isMatchWithInternal(target, source, function doesMatch(objValue, srcValue, key, object, source, stack) { + const isEqual = compare(objValue, srcValue, key, object, source, stack); + if (isEqual !== void 0) return Boolean(isEqual); + return isMatchWithInternal(objValue, srcValue, doesMatch, stack, false); + }, /* @__PURE__ */ new Map(), true); +} +function isMatchWithInternal(target, source, compare, stack, isRoot = false) { + if (source === target) return true; + switch (typeof source) { + case "object": return isObjectMatch(target, source, compare, stack); + case "function": + if (Object.keys(source).length > 0) return isMatchWithInternal(target, { ...source }, compare, stack, isRoot); + return require_eq.eq(target, source); + default: + if (!require_isObject.isObject(target)) return require_eq.eq(target, source); + if (isRoot) { + if (typeof source === "string") return source === ""; + return true; + } + return require_eq.eq(target, source); + } +} +function isObjectMatch(target, source, compare, stack) { + if (source == null) return true; + if (Array.isArray(source)) return isArrayMatch(target, source, compare, stack); + if (source instanceof Map) return isMapMatch(target, source, compare, stack); + if (source instanceof Set) return isSetMatch(target, source, compare, stack); + const keys = Object.keys(source); + if (target == null || require_isPrimitive.isPrimitive(target)) return keys.length === 0; + if (keys.length === 0) return true; + if (stack?.has(source)) return stack.get(source) === target; + stack?.set(source, target); + try { + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (!require_isPrimitive.isPrimitive(target) && !(key in target)) return false; + if (source[key] === void 0 && target[key] !== void 0) return false; + if (source[key] === null && target[key] !== null) return false; + if (!compare(target[key], source[key], key, target, source, stack)) return false; + } + return true; + } finally { + stack?.delete(source); + } +} +function isMapMatch(target, source, compare, stack) { + if (source.size === 0) return true; + if (!(target instanceof Map)) return false; + for (const [key, sourceValue] of source.entries()) if (compare(target.get(key), sourceValue, key, target, source, stack) === false) return false; + return true; +} +function isArrayMatch(target, source, compare, stack) { + if (source.length === 0) return true; + if (!Array.isArray(target)) return false; + const countedIndex = /* @__PURE__ */ new Set(); + for (let i = 0; i < source.length; i++) { + const sourceItem = source[i]; + let found = false; + for (let j = 0; j < target.length; j++) { + if (countedIndex.has(j)) continue; + const targetItem = target[j]; + let matches = false; + if (compare(targetItem, sourceItem, i, target, source, stack)) matches = true; + if (matches) { + countedIndex.add(j); + found = true; + break; + } + } + if (!found) return false; + } + return true; +} +function isSetMatch(target, source, compare, stack) { + if (source.size === 0) return true; + if (!(target instanceof Set)) return false; + return isArrayMatch([...target], [...source], compare, stack); +} +//#endregion +exports.isMatchWith = isMatchWith; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.mjs b/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a58e7de4d3502c33fffd809ac61e6401adc57631 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isMatchWith.mjs @@ -0,0 +1,155 @@ +import { isPrimitive } from "../../predicate/isPrimitive.mjs"; +import { eq } from "../util/eq.mjs"; +import { isObject } from "./isObject.mjs"; +//#region src/compat/predicate/isMatchWith.ts +/** +* Performs a deep comparison between a target value and a source pattern to determine if they match, +* using a custom comparison function for fine-grained control over the matching logic. +* +* This function recursively traverses both values, calling the custom compare function for each +* property/element pair. If the compare function returns a boolean, that result is used directly. +* If it returns undefined, the default matching behavior continues recursively. +* +* The matching behavior varies by data type: +* - **Objects**: Matches if all properties in the source exist in the target and match +* - **Arrays**: Matches if all elements in the source array can be found in the target array (order-independent) +* - **Maps**: Matches if all key-value pairs in the source Map exist and match in the target Map +* - **Sets**: Matches if all elements in the source Set can be found in the target Set +* - **Functions**: Matches using strict equality, or object comparison if the function has properties +* - **Primitives**: Matches using strict equality +* +* Special cases: +* - Empty objects, arrays, Maps, and Sets always match any target +* - `null` and `undefined` source values have specific matching rules +* - Circular references are handled using an internal stack to prevent infinite recursion +* +* @param target - The value to be tested for matching +* @param source - The pattern/template to match against +* @param [compare] - Optional custom comparison function that receives: +* - `objValue` - The value from the target at the current path +* - `srcValue` - The value from the source at the current path +* - `key` - The property key or array index being compared +* - `object` - The parent object/array from the target +* - `source` - The parent object/array from the source +* - `stack` - Internal Map used for circular reference detection +* Should return `true` for a match, `false` for no match, or `undefined` to continue with default behavior +* +* @returns `true` if the target matches the source pattern, `false` otherwise +* +* @example +* // Basic matching without custom comparator +* isMatchWith({ a: 1, b: 2 }, { a: 1 }); // true +* isMatchWith([1, 2, 3], [1, 3]); // true +* +* @example +* // Custom comparison for case-insensitive string matching +* const caseInsensitiveCompare = (objVal, srcVal) => { +* if (typeof objVal === 'string' && typeof srcVal === 'string') { +* return objVal.toLowerCase() === srcVal.toLowerCase(); +* } +* return undefined; // Use default behavior for non-strings +* }; +* +* isMatchWith( +* { name: 'JOHN', age: 30 }, +* { name: 'john' }, +* caseInsensitiveCompare +* ); // true +* +* @example +* // Custom comparison for range matching +* const rangeCompare = (objVal, srcVal, key) => { +* if (key === 'age' && typeof srcVal === 'object' && srcVal.min !== undefined) { +* return objVal >= srcVal.min && objVal <= srcVal.max; +* } +* return undefined; +* }; +* +* isMatchWith( +* { name: 'John', age: 25 }, +* { age: { min: 18, max: 30 } }, +* rangeCompare +* ); // true +*/ +function isMatchWith(target, source, compare) { + if (typeof compare !== "function") return isMatchWith(target, source, () => void 0); + return isMatchWithInternal(target, source, function doesMatch(objValue, srcValue, key, object, source, stack) { + const isEqual = compare(objValue, srcValue, key, object, source, stack); + if (isEqual !== void 0) return Boolean(isEqual); + return isMatchWithInternal(objValue, srcValue, doesMatch, stack, false); + }, /* @__PURE__ */ new Map(), true); +} +function isMatchWithInternal(target, source, compare, stack, isRoot = false) { + if (source === target) return true; + switch (typeof source) { + case "object": return isObjectMatch(target, source, compare, stack); + case "function": + if (Object.keys(source).length > 0) return isMatchWithInternal(target, { ...source }, compare, stack, isRoot); + return eq(target, source); + default: + if (!isObject(target)) return eq(target, source); + if (isRoot) { + if (typeof source === "string") return source === ""; + return true; + } + return eq(target, source); + } +} +function isObjectMatch(target, source, compare, stack) { + if (source == null) return true; + if (Array.isArray(source)) return isArrayMatch(target, source, compare, stack); + if (source instanceof Map) return isMapMatch(target, source, compare, stack); + if (source instanceof Set) return isSetMatch(target, source, compare, stack); + const keys = Object.keys(source); + if (target == null || isPrimitive(target)) return keys.length === 0; + if (keys.length === 0) return true; + if (stack?.has(source)) return stack.get(source) === target; + stack?.set(source, target); + try { + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (!isPrimitive(target) && !(key in target)) return false; + if (source[key] === void 0 && target[key] !== void 0) return false; + if (source[key] === null && target[key] !== null) return false; + if (!compare(target[key], source[key], key, target, source, stack)) return false; + } + return true; + } finally { + stack?.delete(source); + } +} +function isMapMatch(target, source, compare, stack) { + if (source.size === 0) return true; + if (!(target instanceof Map)) return false; + for (const [key, sourceValue] of source.entries()) if (compare(target.get(key), sourceValue, key, target, source, stack) === false) return false; + return true; +} +function isArrayMatch(target, source, compare, stack) { + if (source.length === 0) return true; + if (!Array.isArray(target)) return false; + const countedIndex = /* @__PURE__ */ new Set(); + for (let i = 0; i < source.length; i++) { + const sourceItem = source[i]; + let found = false; + for (let j = 0; j < target.length; j++) { + if (countedIndex.has(j)) continue; + const targetItem = target[j]; + let matches = false; + if (compare(targetItem, sourceItem, i, target, source, stack)) matches = true; + if (matches) { + countedIndex.add(j); + found = true; + break; + } + } + if (!found) return false; + } + return true; +} +function isSetMatch(target, source, compare, stack) { + if (source.size === 0) return true; + if (!(target instanceof Set)) return false; + return isArrayMatch([...target], [...source], compare, stack); +} +//#endregion +export { isMatchWith }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNaN.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isNaN.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fea02ac72028706f77995226e9e1acb8e93061c5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNaN.d.mts @@ -0,0 +1,16 @@ +//#region src/compat/predicate/isNaN.d.ts +/** + * Checks if the value is NaN. + * + * @param value - The value to check. + * @returns `true` if the value is NaN, `false` otherwise. + * + * @example + * isNaN(NaN); // true + * isNaN(0); // false + * isNaN('NaN'); // false + * isNaN(undefined); // false + */ +declare function isNaN(value?: any): boolean; +//#endregion +export { isNaN }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNaN.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isNaN.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fea02ac72028706f77995226e9e1acb8e93061c5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNaN.d.ts @@ -0,0 +1,16 @@ +//#region src/compat/predicate/isNaN.d.ts +/** + * Checks if the value is NaN. + * + * @param value - The value to check. + * @returns `true` if the value is NaN, `false` otherwise. + * + * @example + * isNaN(NaN); // true + * isNaN(0); // false + * isNaN('NaN'); // false + * isNaN(undefined); // false + */ +declare function isNaN(value?: any): boolean; +//#endregion +export { isNaN }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNaN.js b/node_modules/es-toolkit/dist/compat/predicate/isNaN.js new file mode 100644 index 0000000000000000000000000000000000000000..1fd052d6e0a18f677c5e22e7c3db02fa8432852b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNaN.js @@ -0,0 +1,19 @@ +const require_isNumber = require("./isNumber.js"); +//#region src/compat/predicate/isNaN.ts +/** +* Checks if the value is NaN. +* +* @param value - The value to check. +* @returns `true` if the value is NaN, `false` otherwise. +* +* @example +* isNaN(NaN); // true +* isNaN(0); // false +* isNaN('NaN'); // false +* isNaN(undefined); // false +*/ +function isNaN(value) { + return require_isNumber.isNumber(value) && Number.isNaN(Number(value)); +} +//#endregion +exports.isNaN = isNaN; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNaN.mjs b/node_modules/es-toolkit/dist/compat/predicate/isNaN.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0affa7a6a9d76c2dd47a4026d2115315587ac600 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNaN.mjs @@ -0,0 +1,19 @@ +import { isNumber } from "./isNumber.mjs"; +//#region src/compat/predicate/isNaN.ts +/** +* Checks if the value is NaN. +* +* @param value - The value to check. +* @returns `true` if the value is NaN, `false` otherwise. +* +* @example +* isNaN(NaN); // true +* isNaN(0); // false +* isNaN('NaN'); // false +* isNaN(undefined); // false +*/ +function isNaN(value) { + return isNumber(value) && Number.isNaN(Number(value)); +} +//#endregion +export { isNaN }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNative.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isNative.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..720570420891fb92eeb4d9b20496d62e708aa3b6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNative.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/predicate/isNative.d.ts +/** + * Checks if a given value is a native function. + * + * This function tests whether the provided value is a native function implemented by the JavaScript engine. + * It returns `true` if the value is a native function, and `false` otherwise. + * + * @param value - The value to test for native function. + * @returns `true` if the value is a native function, `false` otherwise. + * + * @example + * const value1 = Array.prototype.push; + * const value2 = () => {}; + * const result1 = isNative(value1); // true + * const result2 = isNative(value2); // false + */ +declare function isNative(value: any): value is (...args: any[]) => any; +//#endregion +export { isNative }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNative.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isNative.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..720570420891fb92eeb4d9b20496d62e708aa3b6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNative.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/predicate/isNative.d.ts +/** + * Checks if a given value is a native function. + * + * This function tests whether the provided value is a native function implemented by the JavaScript engine. + * It returns `true` if the value is a native function, and `false` otherwise. + * + * @param value - The value to test for native function. + * @returns `true` if the value is a native function, `false` otherwise. + * + * @example + * const value1 = Array.prototype.push; + * const value2 = () => {}; + * const result1 = isNative(value1); // true + * const result2 = isNative(value2); // false + */ +declare function isNative(value: any): value is (...args: any[]) => any; +//#endregion +export { isNative }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNative.js b/node_modules/es-toolkit/dist/compat/predicate/isNative.js new file mode 100644 index 0000000000000000000000000000000000000000..a1e915fc8b822c694bd48392e43aaf69ece308ba --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNative.js @@ -0,0 +1,26 @@ +//#region src/compat/predicate/isNative.ts +const functionToString = Function.prototype.toString; +/** Used to detect if a method is native. */ +const IS_NATIVE_FUNCTION_REGEXP = RegExp(`^${functionToString.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?")}$`); +/** +* Checks if a given value is a native function. +* +* This function tests whether the provided value is a native function implemented by the JavaScript engine. +* It returns `true` if the value is a native function, and `false` otherwise. +* +* @param value - The value to test for native function. +* @returns `true` if the value is a native function, `false` otherwise. +* +* @example +* const value1 = Array.prototype.push; +* const value2 = () => {}; +* const result1 = isNative(value1); // true +* const result2 = isNative(value2); // false +*/ +function isNative(value) { + if (typeof value !== "function") return false; + if (globalThis?.["__core-js_shared__"] != null) throw new Error("Unsupported core-js use. Try https://npms.io/search?q=ponyfill."); + return IS_NATIVE_FUNCTION_REGEXP.test(functionToString.call(value)); +} +//#endregion +exports.isNative = isNative; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNative.mjs b/node_modules/es-toolkit/dist/compat/predicate/isNative.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2e521a5a5934c04e1015ee601234eed2d56d1df9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNative.mjs @@ -0,0 +1,26 @@ +//#region src/compat/predicate/isNative.ts +const functionToString = Function.prototype.toString; +/** Used to detect if a method is native. */ +const IS_NATIVE_FUNCTION_REGEXP = RegExp(`^${functionToString.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?")}$`); +/** +* Checks if a given value is a native function. +* +* This function tests whether the provided value is a native function implemented by the JavaScript engine. +* It returns `true` if the value is a native function, and `false` otherwise. +* +* @param value - The value to test for native function. +* @returns `true` if the value is a native function, `false` otherwise. +* +* @example +* const value1 = Array.prototype.push; +* const value2 = () => {}; +* const result1 = isNative(value1); // true +* const result2 = isNative(value2); // false +*/ +function isNative(value) { + if (typeof value !== "function") return false; + if (globalThis?.["__core-js_shared__"] != null) throw new Error("Unsupported core-js use. Try https://npms.io/search?q=ponyfill."); + return IS_NATIVE_FUNCTION_REGEXP.test(functionToString.call(value)); +} +//#endregion +export { isNative }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNil.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isNil.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e5d9af007d0106c11ede08441317048a45f97b86 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNil.d.mts @@ -0,0 +1,23 @@ +//#region src/compat/predicate/isNil.d.ts +/** + * Checks if a given value is null or undefined. + * + * This function tests whether the provided value is either `null` or `undefined`. + * It returns `true` if the value is `null` or `undefined`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`. + * + * @param x - The value to test for null or undefined. + * @returns `true` if the value is null or undefined, `false` otherwise. + * + * @example + * const value1 = null; + * const value2 = undefined; + * const value3 = 42; + * const result1 = isNil(value1); // true + * const result2 = isNil(value2); // true + * const result3 = isNil(value3); // false + */ +declare function isNil(x: any): x is null | undefined; +//#endregion +export { isNil }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNil.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isNil.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5d9af007d0106c11ede08441317048a45f97b86 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNil.d.ts @@ -0,0 +1,23 @@ +//#region src/compat/predicate/isNil.d.ts +/** + * Checks if a given value is null or undefined. + * + * This function tests whether the provided value is either `null` or `undefined`. + * It returns `true` if the value is `null` or `undefined`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`. + * + * @param x - The value to test for null or undefined. + * @returns `true` if the value is null or undefined, `false` otherwise. + * + * @example + * const value1 = null; + * const value2 = undefined; + * const value3 = 42; + * const result1 = isNil(value1); // true + * const result2 = isNil(value2); // true + * const result3 = isNil(value3); // false + */ +declare function isNil(x: any): x is null | undefined; +//#endregion +export { isNil }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNil.js b/node_modules/es-toolkit/dist/compat/predicate/isNil.js new file mode 100644 index 0000000000000000000000000000000000000000..830cffac0fac7dd2bdb291d5ae8f1c931822db12 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNil.js @@ -0,0 +1,25 @@ +//#region src/compat/predicate/isNil.ts +/** +* Checks if a given value is null or undefined. +* +* This function tests whether the provided value is either `null` or `undefined`. +* It returns `true` if the value is `null` or `undefined`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`. +* +* @param x - The value to test for null or undefined. +* @returns `true` if the value is null or undefined, `false` otherwise. +* +* @example +* const value1 = null; +* const value2 = undefined; +* const value3 = 42; +* const result1 = isNil(value1); // true +* const result2 = isNil(value2); // true +* const result3 = isNil(value3); // false +*/ +function isNil(x) { + return x == null; +} +//#endregion +exports.isNil = isNil; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNil.mjs b/node_modules/es-toolkit/dist/compat/predicate/isNil.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e7a5288f37025a74cab9d9f3b2d6ea0e60ed447d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNil.mjs @@ -0,0 +1,25 @@ +//#region src/compat/predicate/isNil.ts +/** +* Checks if a given value is null or undefined. +* +* This function tests whether the provided value is either `null` or `undefined`. +* It returns `true` if the value is `null` or `undefined`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`. +* +* @param x - The value to test for null or undefined. +* @returns `true` if the value is null or undefined, `false` otherwise. +* +* @example +* const value1 = null; +* const value2 = undefined; +* const value3 = 42; +* const result1 = isNil(value1); // true +* const result2 = isNil(value2); // true +* const result3 = isNil(value3); // false +*/ +function isNil(x) { + return x == null; +} +//#endregion +export { isNil }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNull.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isNull.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9a441570615bcb293e2981d734e913b11fc4903c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNull.d.mts @@ -0,0 +1,15 @@ +//#region src/compat/predicate/isNull.d.ts +/** + * Checks if `value` is `null`. + * + * @param value - The value to check. + * @returns Returns `true` if `value` is `null`, else `false`. + * + * @example + * isNull(null); // true + * isNull(undefined); // false + * isNull(0); // false + */ +declare function isNull(value: any): value is null; +//#endregion +export { isNull }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNull.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isNull.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a441570615bcb293e2981d734e913b11fc4903c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNull.d.ts @@ -0,0 +1,15 @@ +//#region src/compat/predicate/isNull.d.ts +/** + * Checks if `value` is `null`. + * + * @param value - The value to check. + * @returns Returns `true` if `value` is `null`, else `false`. + * + * @example + * isNull(null); // true + * isNull(undefined); // false + * isNull(0); // false + */ +declare function isNull(value: any): value is null; +//#endregion +export { isNull }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNull.js b/node_modules/es-toolkit/dist/compat/predicate/isNull.js new file mode 100644 index 0000000000000000000000000000000000000000..6ab6f7e226a1d0cfb4637e3291c5c21c51ec283e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNull.js @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isNull.ts +/** +* Checks if `value` is `null`. +* +* @param value - The value to check. +* @returns Returns `true` if `value` is `null`, else `false`. +* +* @example +* isNull(null); // true +* isNull(undefined); // false +* isNull(0); // false +*/ +function isNull(value) { + return value === null; +} +//#endregion +exports.isNull = isNull; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNull.mjs b/node_modules/es-toolkit/dist/compat/predicate/isNull.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5f8defb2cbefc0f034d269af562a14cc9c73e92d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNull.mjs @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isNull.ts +/** +* Checks if `value` is `null`. +* +* @param value - The value to check. +* @returns Returns `true` if `value` is `null`, else `false`. +* +* @example +* isNull(null); // true +* isNull(undefined); // false +* isNull(0); // false +*/ +function isNull(value) { + return value === null; +} +//#endregion +export { isNull }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNumber.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isNumber.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..60e94452a83e61b9a3f07d5034657e7e438ce88e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNumber.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isNumber.d.ts +/** + * Checks if a given value is a number. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. + * + * @param value The value to check if it is a number. + * @returns Returns `true` if `value` is a number, else `false`. + * + * @example + * const value1 = 123; + * const value2 = 'abc'; + * const value3 = true; + * + * console.log(isNumber(value1)); // true + * console.log(isNumber(value2)); // false + * console.log(isNumber(value3)); // false + */ +declare function isNumber(value?: any): value is number; +//#endregion +export { isNumber }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNumber.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isNumber.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..60e94452a83e61b9a3f07d5034657e7e438ce88e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNumber.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isNumber.d.ts +/** + * Checks if a given value is a number. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. + * + * @param value The value to check if it is a number. + * @returns Returns `true` if `value` is a number, else `false`. + * + * @example + * const value1 = 123; + * const value2 = 'abc'; + * const value3 = true; + * + * console.log(isNumber(value1)); // true + * console.log(isNumber(value2)); // false + * console.log(isNumber(value3)); // false + */ +declare function isNumber(value?: any): value is number; +//#endregion +export { isNumber }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNumber.js b/node_modules/es-toolkit/dist/compat/predicate/isNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..9275d35e39f53e1b91b608b0e9364eb772b9e0f2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNumber.js @@ -0,0 +1,26 @@ +const require_getTag = require("../_internal/getTag.js"); +require("../_internal/tags.js"); +const require_isObjectLike = require("./isObjectLike.js"); +//#region src/compat/predicate/isNumber.ts +/** +* Checks if a given value is a number. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. +* +* @param value The value to check if it is a number. +* @returns Returns `true` if `value` is a number, else `false`. +* +* @example +* const value1 = 123; +* const value2 = 'abc'; +* const value3 = true; +* +* console.log(isNumber(value1)); // true +* console.log(isNumber(value2)); // false +* console.log(isNumber(value3)); // false +*/ +function isNumber(value) { + return typeof value === "number" || require_isObjectLike.isObjectLike(value) && require_getTag.getTag(value) === "[object Number]"; +} +//#endregion +exports.isNumber = isNumber; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isNumber.mjs b/node_modules/es-toolkit/dist/compat/predicate/isNumber.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bf20a91dcca0010c0a08d1c54f1c9cc4d17add33 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isNumber.mjs @@ -0,0 +1,26 @@ +import { getTag } from "../_internal/getTag.mjs"; +import "../_internal/tags.mjs"; +import { isObjectLike } from "./isObjectLike.mjs"; +//#region src/compat/predicate/isNumber.ts +/** +* Checks if a given value is a number. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. +* +* @param value The value to check if it is a number. +* @returns Returns `true` if `value` is a number, else `false`. +* +* @example +* const value1 = 123; +* const value2 = 'abc'; +* const value3 = true; +* +* console.log(isNumber(value1)); // true +* console.log(isNumber(value2)); // false +* console.log(isNumber(value3)); // false +*/ +function isNumber(value) { + return typeof value === "number" || isObjectLike(value) && getTag(value) === "[object Number]"; +} +//#endregion +export { isNumber }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isObject.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d14f504e07da2ca823da34a50bbf1693d80ac391 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isObject.d.mts @@ -0,0 +1,27 @@ +//#region src/compat/predicate/isObject.d.ts +/** + * Checks if the given value is an object. An object is a value that is + * not a primitive type (string, number, boolean, symbol, null, or undefined). + * + * This function tests whether the provided value is an object or not. + * It returns `true` if the value is an object, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object value. + * + * @param value - The value to check if it is an object. + * @returns `true` if the value is an object, `false` otherwise. + * + * @example + * const value1 = {}; + * const value2 = [1, 2, 3]; + * const value3 = () => {}; + * const value4 = null; + * + * console.log(isObject(value1)); // true + * console.log(isObject(value2)); // true + * console.log(isObject(value3)); // true + * console.log(isObject(value4)); // false + */ +declare function isObject(value?: any): value is object; +//#endregion +export { isObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isObject.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d14f504e07da2ca823da34a50bbf1693d80ac391 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isObject.d.ts @@ -0,0 +1,27 @@ +//#region src/compat/predicate/isObject.d.ts +/** + * Checks if the given value is an object. An object is a value that is + * not a primitive type (string, number, boolean, symbol, null, or undefined). + * + * This function tests whether the provided value is an object or not. + * It returns `true` if the value is an object, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object value. + * + * @param value - The value to check if it is an object. + * @returns `true` if the value is an object, `false` otherwise. + * + * @example + * const value1 = {}; + * const value2 = [1, 2, 3]; + * const value3 = () => {}; + * const value4 = null; + * + * console.log(isObject(value1)); // true + * console.log(isObject(value2)); // true + * console.log(isObject(value3)); // true + * console.log(isObject(value4)); // false + */ +declare function isObject(value?: any): value is object; +//#endregion +export { isObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isObject.js b/node_modules/es-toolkit/dist/compat/predicate/isObject.js new file mode 100644 index 0000000000000000000000000000000000000000..fb434693e8c2256039504cc0e9aa3006b1235c40 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isObject.js @@ -0,0 +1,29 @@ +//#region src/compat/predicate/isObject.ts +/** +* Checks if the given value is an object. An object is a value that is +* not a primitive type (string, number, boolean, symbol, null, or undefined). +* +* This function tests whether the provided value is an object or not. +* It returns `true` if the value is an object, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object value. +* +* @param value - The value to check if it is an object. +* @returns `true` if the value is an object, `false` otherwise. +* +* @example +* const value1 = {}; +* const value2 = [1, 2, 3]; +* const value3 = () => {}; +* const value4 = null; +* +* console.log(isObject(value1)); // true +* console.log(isObject(value2)); // true +* console.log(isObject(value3)); // true +* console.log(isObject(value4)); // false +*/ +function isObject(value) { + return value !== null && (typeof value === "object" || typeof value === "function"); +} +//#endregion +exports.isObject = isObject; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isObject.mjs b/node_modules/es-toolkit/dist/compat/predicate/isObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..aa6b4acc927e6b6b113af2e9b8db624264bb15ca --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isObject.mjs @@ -0,0 +1,29 @@ +//#region src/compat/predicate/isObject.ts +/** +* Checks if the given value is an object. An object is a value that is +* not a primitive type (string, number, boolean, symbol, null, or undefined). +* +* This function tests whether the provided value is an object or not. +* It returns `true` if the value is an object, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object value. +* +* @param value - The value to check if it is an object. +* @returns `true` if the value is an object, `false` otherwise. +* +* @example +* const value1 = {}; +* const value2 = [1, 2, 3]; +* const value3 = () => {}; +* const value4 = null; +* +* console.log(isObject(value1)); // true +* console.log(isObject(value2)); // true +* console.log(isObject(value3)); // true +* console.log(isObject(value4)); // false +*/ +function isObject(value) { + return value !== null && (typeof value === "object" || typeof value === "function"); +} +//#endregion +export { isObject }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e0ea20002f91786b49da660a7e3486b9d8198a1b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.d.mts @@ -0,0 +1,27 @@ +//#region src/compat/predicate/isObjectLike.d.ts +/** + * Checks if the given value is object-like. + * + * A value is object-like if its type is object and it is not null. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object-like value. + * + * @param value - The value to test if it is an object-like. + * @returns `true` if the value is an object-like, `false` otherwise. + * + * @example + * const value1 = { a: 1 }; + * const value2 = [1, 2, 3]; + * const value3 = 'abc'; + * const value4 = () => {}; + * const value5 = null; + * + * console.log(isObjectLike(value1)); // true + * console.log(isObjectLike(value2)); // true + * console.log(isObjectLike(value3)); // false + * console.log(isObjectLike(value4)); // false + * console.log(isObjectLike(value5)); // false + */ +declare function isObjectLike(value?: any): boolean; +//#endregion +export { isObjectLike }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e0ea20002f91786b49da660a7e3486b9d8198a1b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.d.ts @@ -0,0 +1,27 @@ +//#region src/compat/predicate/isObjectLike.d.ts +/** + * Checks if the given value is object-like. + * + * A value is object-like if its type is object and it is not null. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object-like value. + * + * @param value - The value to test if it is an object-like. + * @returns `true` if the value is an object-like, `false` otherwise. + * + * @example + * const value1 = { a: 1 }; + * const value2 = [1, 2, 3]; + * const value3 = 'abc'; + * const value4 = () => {}; + * const value5 = null; + * + * console.log(isObjectLike(value1)); // true + * console.log(isObjectLike(value2)); // true + * console.log(isObjectLike(value3)); // false + * console.log(isObjectLike(value4)); // false + * console.log(isObjectLike(value5)); // false + */ +declare function isObjectLike(value?: any): boolean; +//#endregion +export { isObjectLike }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.js b/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.js new file mode 100644 index 0000000000000000000000000000000000000000..67b6e02dee88cfe1833a4434cc703a324cd86de7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.js @@ -0,0 +1,29 @@ +//#region src/compat/predicate/isObjectLike.ts +/** +* Checks if the given value is object-like. +* +* A value is object-like if its type is object and it is not null. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object-like value. +* +* @param value - The value to test if it is an object-like. +* @returns `true` if the value is an object-like, `false` otherwise. +* +* @example +* const value1 = { a: 1 }; +* const value2 = [1, 2, 3]; +* const value3 = 'abc'; +* const value4 = () => {}; +* const value5 = null; +* +* console.log(isObjectLike(value1)); // true +* console.log(isObjectLike(value2)); // true +* console.log(isObjectLike(value3)); // false +* console.log(isObjectLike(value4)); // false +* console.log(isObjectLike(value5)); // false +*/ +function isObjectLike(value) { + return typeof value === "object" && value !== null; +} +//#endregion +exports.isObjectLike = isObjectLike; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.mjs b/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.mjs new file mode 100644 index 0000000000000000000000000000000000000000..848b43e7b7057ec204cbdaea69e3c5ad5e4ed948 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isObjectLike.mjs @@ -0,0 +1,29 @@ +//#region src/compat/predicate/isObjectLike.ts +/** +* Checks if the given value is object-like. +* +* A value is object-like if its type is object and it is not null. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object-like value. +* +* @param value - The value to test if it is an object-like. +* @returns `true` if the value is an object-like, `false` otherwise. +* +* @example +* const value1 = { a: 1 }; +* const value2 = [1, 2, 3]; +* const value3 = 'abc'; +* const value4 = () => {}; +* const value5 = null; +* +* console.log(isObjectLike(value1)); // true +* console.log(isObjectLike(value2)); // true +* console.log(isObjectLike(value3)); // false +* console.log(isObjectLike(value4)); // false +* console.log(isObjectLike(value5)); // false +*/ +function isObjectLike(value) { + return typeof value === "object" && value !== null; +} +//#endregion +export { isObjectLike }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ab6e799472d8bbd04e06291158b346bce9c67f0c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.d.mts @@ -0,0 +1,26 @@ +//#region src/compat/predicate/isPlainObject.d.ts +/** + * Checks if a given value is a plain object. + * + * A plain object is an object created by the `{}` literal, `new Object()`, or + * `Object.create(null)`. + * + * This function also handles objects with custom + * `Symbol.toStringTag` properties. + * + * `Symbol.toStringTag` is a built-in symbol that a constructor can use to customize the + * default string description of objects. + * + * @param [object] - The value to check. + * @returns True if the value is a plain object, otherwise false. + * + * @example + * console.log(isPlainObject({})); // true + * console.log(isPlainObject([])); // false + * console.log(isPlainObject(null)); // false + * console.log(isPlainObject(Object.create(null))); // true + * console.log(isPlainObject(new Map())); // false + */ +declare function isPlainObject(object?: any): boolean; +//#endregion +export { isPlainObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ab6e799472d8bbd04e06291158b346bce9c67f0c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.d.ts @@ -0,0 +1,26 @@ +//#region src/compat/predicate/isPlainObject.d.ts +/** + * Checks if a given value is a plain object. + * + * A plain object is an object created by the `{}` literal, `new Object()`, or + * `Object.create(null)`. + * + * This function also handles objects with custom + * `Symbol.toStringTag` properties. + * + * `Symbol.toStringTag` is a built-in symbol that a constructor can use to customize the + * default string description of objects. + * + * @param [object] - The value to check. + * @returns True if the value is a plain object, otherwise false. + * + * @example + * console.log(isPlainObject({})); // true + * console.log(isPlainObject([])); // false + * console.log(isPlainObject(null)); // false + * console.log(isPlainObject(Object.create(null))); // true + * console.log(isPlainObject(new Map())); // false + */ +declare function isPlainObject(object?: any): boolean; +//#endregion +export { isPlainObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js b/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js new file mode 100644 index 0000000000000000000000000000000000000000..3b7ce3d126176a27134eadd4e93239d615dbca75 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js @@ -0,0 +1,39 @@ +//#region src/compat/predicate/isPlainObject.ts +/** +* Checks if a given value is a plain object. +* +* A plain object is an object created by the `{}` literal, `new Object()`, or +* `Object.create(null)`. +* +* This function also handles objects with custom +* `Symbol.toStringTag` properties. +* +* `Symbol.toStringTag` is a built-in symbol that a constructor can use to customize the +* default string description of objects. +* +* @param [object] - The value to check. +* @returns True if the value is a plain object, otherwise false. +* +* @example +* console.log(isPlainObject({})); // true +* console.log(isPlainObject([])); // false +* console.log(isPlainObject(null)); // false +* console.log(isPlainObject(Object.create(null))); // true +* console.log(isPlainObject(new Map())); // false +*/ +function isPlainObject(object) { + if (typeof object !== "object") return false; + if (object == null) return false; + if (Object.getPrototypeOf(object) === null) return true; + if (Object.prototype.toString.call(object) !== "[object Object]") { + const tag = object[Symbol.toStringTag]; + if (tag == null) return false; + if (!Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable) return false; + return object.toString() === `[object ${tag}]`; + } + let proto = object; + while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto); + return Object.getPrototypeOf(object) === proto; +} +//#endregion +exports.isPlainObject = isPlainObject; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.mjs b/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c54d610aea299df2a5d6125cde03a1ba83782985 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.mjs @@ -0,0 +1,39 @@ +//#region src/compat/predicate/isPlainObject.ts +/** +* Checks if a given value is a plain object. +* +* A plain object is an object created by the `{}` literal, `new Object()`, or +* `Object.create(null)`. +* +* This function also handles objects with custom +* `Symbol.toStringTag` properties. +* +* `Symbol.toStringTag` is a built-in symbol that a constructor can use to customize the +* default string description of objects. +* +* @param [object] - The value to check. +* @returns True if the value is a plain object, otherwise false. +* +* @example +* console.log(isPlainObject({})); // true +* console.log(isPlainObject([])); // false +* console.log(isPlainObject(null)); // false +* console.log(isPlainObject(Object.create(null))); // true +* console.log(isPlainObject(new Map())); // false +*/ +function isPlainObject(object) { + if (typeof object !== "object") return false; + if (object == null) return false; + if (Object.getPrototypeOf(object) === null) return true; + if (Object.prototype.toString.call(object) !== "[object Object]") { + const tag = object[Symbol.toStringTag]; + if (tag == null) return false; + if (!Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable) return false; + return object.toString() === `[object ${tag}]`; + } + let proto = object; + while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto); + return Object.getPrototypeOf(object) === proto; +} +//#endregion +export { isPlainObject }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isRegExp.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isRegExp.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..14b4479be8e8b6effdbc224215e8d224d3e03683 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isRegExp.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isRegExp.d.ts +/** + * Checks if `value` is a RegExp. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a RegExp, `false` otherwise. + * + * @example + * const value1 = /abc/; + * const value2 = '/abc/'; + * + * console.log(isRegExp(value1)); // true + * console.log(isRegExp(value2)); // false + */ +declare function isRegExp(value?: any): value is RegExp; +//#endregion +export { isRegExp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isRegExp.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isRegExp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..14b4479be8e8b6effdbc224215e8d224d3e03683 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isRegExp.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/predicate/isRegExp.d.ts +/** + * Checks if `value` is a RegExp. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a RegExp, `false` otherwise. + * + * @example + * const value1 = /abc/; + * const value2 = '/abc/'; + * + * console.log(isRegExp(value1)); // true + * console.log(isRegExp(value2)); // false + */ +declare function isRegExp(value?: any): value is RegExp; +//#endregion +export { isRegExp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isRegExp.js b/node_modules/es-toolkit/dist/compat/predicate/isRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..28da2c4450f40e1576904ac0987d9ba724c1282a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isRegExp.js @@ -0,0 +1,20 @@ +const require_isRegExp = require("../../predicate/isRegExp.js"); +//#region src/compat/predicate/isRegExp.ts +/** +* Checks if `value` is a RegExp. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a RegExp, `false` otherwise. +* +* @example +* const value1 = /abc/; +* const value2 = '/abc/'; +* +* console.log(isRegExp(value1)); // true +* console.log(isRegExp(value2)); // false +*/ +function isRegExp(value) { + return require_isRegExp.isRegExp(value); +} +//#endregion +exports.isRegExp = isRegExp; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isRegExp.mjs b/node_modules/es-toolkit/dist/compat/predicate/isRegExp.mjs new file mode 100644 index 0000000000000000000000000000000000000000..36cbec0e3a15b9255bfab706ea86430b0fefe3f9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isRegExp.mjs @@ -0,0 +1,20 @@ +import { isRegExp as isRegExp$1 } from "../../predicate/isRegExp.mjs"; +//#region src/compat/predicate/isRegExp.ts +/** +* Checks if `value` is a RegExp. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a RegExp, `false` otherwise. +* +* @example +* const value1 = /abc/; +* const value2 = '/abc/'; +* +* console.log(isRegExp(value1)); // true +* console.log(isRegExp(value2)); // false +*/ +function isRegExp(value) { + return isRegExp$1(value); +} +//#endregion +export { isRegExp }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7f33b81fc814770d2a9c8596c0e313c2e429022a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.d.mts @@ -0,0 +1,22 @@ +//#region src/compat/predicate/isSafeInteger.d.ts +/** + * Checks if `value` is a safe integer (between -(2^53 – 1) and (2^53 – 1), inclusive). + * + * A safe integer is an integer that can be precisely represented as a `number` in JavaScript, + * without any other integer being rounded to it. + * + * This function also serves as a type predicate in TypeScript, + * narrowing the type of the argument to `number`. + * + * @param value - The value to check + * @returns `true` if `value` is an integer and between the safe values, otherwise `false` + * + * @example + * isSafeInteger(3); // Returns: true + * isSafeInteger(Number.MIN_SAFE_INTEGER - 1); // Returns: false + * isSafeInteger(1n); // Returns: false + * isSafeInteger('1'); // Returns: false + */ +declare function isSafeInteger(value: unknown): value is number; +//#endregion +export { isSafeInteger }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f33b81fc814770d2a9c8596c0e313c2e429022a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.d.ts @@ -0,0 +1,22 @@ +//#region src/compat/predicate/isSafeInteger.d.ts +/** + * Checks if `value` is a safe integer (between -(2^53 – 1) and (2^53 – 1), inclusive). + * + * A safe integer is an integer that can be precisely represented as a `number` in JavaScript, + * without any other integer being rounded to it. + * + * This function also serves as a type predicate in TypeScript, + * narrowing the type of the argument to `number`. + * + * @param value - The value to check + * @returns `true` if `value` is an integer and between the safe values, otherwise `false` + * + * @example + * isSafeInteger(3); // Returns: true + * isSafeInteger(Number.MIN_SAFE_INTEGER - 1); // Returns: false + * isSafeInteger(1n); // Returns: false + * isSafeInteger('1'); // Returns: false + */ +declare function isSafeInteger(value: unknown): value is number; +//#endregion +export { isSafeInteger }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.js b/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..ab3b07a9af1fca8571c65a5e6978815821da4160 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.js @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isSafeInteger.ts +/** +* Checks if `value` is a safe integer (between -(2^53 – 1) and (2^53 – 1), inclusive). +* +* A safe integer is an integer that can be precisely represented as a `number` in JavaScript, +* without any other integer being rounded to it. +* +* This function also serves as a type predicate in TypeScript, +* narrowing the type of the argument to `number`. +* +* @param value - The value to check +* @returns `true` if `value` is an integer and between the safe values, otherwise `false` +* +* @example +* isSafeInteger(3); // Returns: true +* isSafeInteger(Number.MIN_SAFE_INTEGER - 1); // Returns: false +* isSafeInteger(1n); // Returns: false +* isSafeInteger('1'); // Returns: false +*/ +function isSafeInteger(value) { + return Number.isSafeInteger(value); +} +//#endregion +exports.isSafeInteger = isSafeInteger; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.mjs b/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.mjs new file mode 100644 index 0000000000000000000000000000000000000000..11753e8fc2274fa7814255114509c65e30313c8b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSafeInteger.mjs @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isSafeInteger.ts +/** +* Checks if `value` is a safe integer (between -(2^53 – 1) and (2^53 – 1), inclusive). +* +* A safe integer is an integer that can be precisely represented as a `number` in JavaScript, +* without any other integer being rounded to it. +* +* This function also serves as a type predicate in TypeScript, +* narrowing the type of the argument to `number`. +* +* @param value - The value to check +* @returns `true` if `value` is an integer and between the safe values, otherwise `false` +* +* @example +* isSafeInteger(3); // Returns: true +* isSafeInteger(Number.MIN_SAFE_INTEGER - 1); // Returns: false +* isSafeInteger(1n); // Returns: false +* isSafeInteger('1'); // Returns: false +*/ +function isSafeInteger(value) { + return Number.isSafeInteger(value); +} +//#endregion +export { isSafeInteger }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSet.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isSet.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1ca8a4c09ab5dd2fa1d49806fb36f5ed8300e9ff --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSet.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isSet.d.ts +/** + * Checks if a given value is `Set`. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Set`. + * + * @param value The value to check if it is a `Set`. + * @returns Returns `true` if `value` is a `Set`, else `false`. + * + * @example + * const value1 = new Set(); + * const value2 = new Map(); + * const value3 = new WeakSet(); + * + * console.log(isSet(value1)); // true + * console.log(isSet(value2)); // false + * console.log(isSet(value3)); // false + */ +declare function isSet(value?: any): value is Set; +//#endregion +export { isSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSet.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ca8a4c09ab5dd2fa1d49806fb36f5ed8300e9ff --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSet.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isSet.d.ts +/** + * Checks if a given value is `Set`. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Set`. + * + * @param value The value to check if it is a `Set`. + * @returns Returns `true` if `value` is a `Set`, else `false`. + * + * @example + * const value1 = new Set(); + * const value2 = new Map(); + * const value3 = new WeakSet(); + * + * console.log(isSet(value1)); // true + * console.log(isSet(value2)); // false + * console.log(isSet(value3)); // false + */ +declare function isSet(value?: any): value is Set; +//#endregion +export { isSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSet.js b/node_modules/es-toolkit/dist/compat/predicate/isSet.js new file mode 100644 index 0000000000000000000000000000000000000000..efe983a2bdc32ed06eddbe7ebc78900344c6ab5e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSet.js @@ -0,0 +1,24 @@ +const require_isSet = require("../../predicate/isSet.js"); +//#region src/compat/predicate/isSet.ts +/** +* Checks if a given value is `Set`. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Set`. +* +* @param value The value to check if it is a `Set`. +* @returns Returns `true` if `value` is a `Set`, else `false`. +* +* @example +* const value1 = new Set(); +* const value2 = new Map(); +* const value3 = new WeakSet(); +* +* console.log(isSet(value1)); // true +* console.log(isSet(value2)); // false +* console.log(isSet(value3)); // false +*/ +function isSet(value) { + return require_isSet.isSet(value); +} +//#endregion +exports.isSet = isSet; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSet.mjs b/node_modules/es-toolkit/dist/compat/predicate/isSet.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9316a5f4f447b47b773d19177a1587392edd4130 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSet.mjs @@ -0,0 +1,24 @@ +import { isSet as isSet$1 } from "../../predicate/isSet.mjs"; +//#region src/compat/predicate/isSet.ts +/** +* Checks if a given value is `Set`. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Set`. +* +* @param value The value to check if it is a `Set`. +* @returns Returns `true` if `value` is a `Set`, else `false`. +* +* @example +* const value1 = new Set(); +* const value2 = new Map(); +* const value3 = new WeakSet(); +* +* console.log(isSet(value1)); // true +* console.log(isSet(value2)); // false +* console.log(isSet(value3)); // false +*/ +function isSet(value) { + return isSet$1(value); +} +//#endregion +export { isSet }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isString.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isString.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b86d7659e2e53188d1a9b94de2af97ecf17e97e2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isString.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isString.d.ts +/** + * Checks if a given value is string. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `string`. + * + * @param value The value to check if it is string. + * @returns Returns `true` if `value` is a string, else `false`. + * + * @example + * const value1 = 'abc'; + * const value2 = 123; + * const value3 = true; + * + * console.log(isString(value1)); // true + * console.log(isString(value2)); // false + * console.log(isString(value3)); // false + */ +declare function isString(value?: any): value is string; +//#endregion +export { isString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isString.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isString.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b86d7659e2e53188d1a9b94de2af97ecf17e97e2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isString.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/predicate/isString.d.ts +/** + * Checks if a given value is string. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `string`. + * + * @param value The value to check if it is string. + * @returns Returns `true` if `value` is a string, else `false`. + * + * @example + * const value1 = 'abc'; + * const value2 = 123; + * const value3 = true; + * + * console.log(isString(value1)); // true + * console.log(isString(value2)); // false + * console.log(isString(value3)); // false + */ +declare function isString(value?: any): value is string; +//#endregion +export { isString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isString.js b/node_modules/es-toolkit/dist/compat/predicate/isString.js new file mode 100644 index 0000000000000000000000000000000000000000..e21c7dc9858b730edcdc191106a6d9a48c73a39b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isString.js @@ -0,0 +1,23 @@ +//#region src/compat/predicate/isString.ts +/** +* Checks if a given value is string. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `string`. +* +* @param value The value to check if it is string. +* @returns Returns `true` if `value` is a string, else `false`. +* +* @example +* const value1 = 'abc'; +* const value2 = 123; +* const value3 = true; +* +* console.log(isString(value1)); // true +* console.log(isString(value2)); // false +* console.log(isString(value3)); // false +*/ +function isString(value) { + return typeof value === "string" || value instanceof String; +} +//#endregion +exports.isString = isString; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isString.mjs b/node_modules/es-toolkit/dist/compat/predicate/isString.mjs new file mode 100644 index 0000000000000000000000000000000000000000..de03219d652f55c92466478790c5b6960b75e49f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isString.mjs @@ -0,0 +1,23 @@ +//#region src/compat/predicate/isString.ts +/** +* Checks if a given value is string. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `string`. +* +* @param value The value to check if it is string. +* @returns Returns `true` if `value` is a string, else `false`. +* +* @example +* const value1 = 'abc'; +* const value2 = 123; +* const value3 = true; +* +* console.log(isString(value1)); // true +* console.log(isString(value2)); // false +* console.log(isString(value3)); // false +*/ +function isString(value) { + return typeof value === "string" || value instanceof String; +} +//#endregion +export { isString }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSymbol.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isSymbol.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c2922c2da53545793ced7a5bfb4271f5ceea58ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSymbol.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/predicate/isSymbol.d.ts +/** + * Check whether a value is a symbol. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `symbol`. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a symbol, else `false`. + * @example + * isSymbol(Symbol.iterator); + * // => true + * + * isSymbol('abc'); + * // => false + */ +declare function isSymbol(value: any): value is symbol; +//#endregion +export { isSymbol }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSymbol.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isSymbol.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c2922c2da53545793ced7a5bfb4271f5ceea58ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSymbol.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/predicate/isSymbol.d.ts +/** + * Check whether a value is a symbol. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `symbol`. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a symbol, else `false`. + * @example + * isSymbol(Symbol.iterator); + * // => true + * + * isSymbol('abc'); + * // => false + */ +declare function isSymbol(value: any): value is symbol; +//#endregion +export { isSymbol }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSymbol.js b/node_modules/es-toolkit/dist/compat/predicate/isSymbol.js new file mode 100644 index 0000000000000000000000000000000000000000..ae52f5ef3b9495244707333d7ed81473d8729d5d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSymbol.js @@ -0,0 +1,20 @@ +//#region src/compat/predicate/isSymbol.ts +/** +* Check whether a value is a symbol. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `symbol`. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a symbol, else `false`. +* @example +* isSymbol(Symbol.iterator); +* // => true +* +* isSymbol('abc'); +* // => false +*/ +function isSymbol(value) { + return typeof value === "symbol" || value instanceof Symbol; +} +//#endregion +exports.isSymbol = isSymbol; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isSymbol.mjs b/node_modules/es-toolkit/dist/compat/predicate/isSymbol.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cd2c7f38ee683cdcb2744154c0faf3555f75597e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isSymbol.mjs @@ -0,0 +1,20 @@ +//#region src/compat/predicate/isSymbol.ts +/** +* Check whether a value is a symbol. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `symbol`. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a symbol, else `false`. +* @example +* isSymbol(Symbol.iterator); +* // => true +* +* isSymbol('abc'); +* // => false +*/ +function isSymbol(value) { + return typeof value === "symbol" || value instanceof Symbol; +} +//#endregion +export { isSymbol }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9100df4146b75b229bc413bd510273423512751d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/predicate/isTypedArray.d.ts +/** + * Checks if a value is a TypedArray. + * @param x The value to check. + * @returns Returns true if `x` is a TypedArray, false otherwise. + * + * @example + * const arr = new Uint8Array([1, 2, 3]); + * isTypedArray(arr); // true + * + * const regularArray = [1, 2, 3]; + * isTypedArray(regularArray); // false + * + * const buffer = new ArrayBuffer(16); + * isTypedArray(buffer); // false + */ +declare function isTypedArray(x: any): boolean; +//#endregion +export { isTypedArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9100df4146b75b229bc413bd510273423512751d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/predicate/isTypedArray.d.ts +/** + * Checks if a value is a TypedArray. + * @param x The value to check. + * @returns Returns true if `x` is a TypedArray, false otherwise. + * + * @example + * const arr = new Uint8Array([1, 2, 3]); + * isTypedArray(arr); // true + * + * const regularArray = [1, 2, 3]; + * isTypedArray(regularArray); // false + * + * const buffer = new ArrayBuffer(16); + * isTypedArray(buffer); // false + */ +declare function isTypedArray(x: any): boolean; +//#endregion +export { isTypedArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.js b/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..4a90560fa3e0aafe4cb3b9572797a095858005db --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.js @@ -0,0 +1,22 @@ +const require_isTypedArray = require("../../predicate/isTypedArray.js"); +//#region src/compat/predicate/isTypedArray.ts +/** +* Checks if a value is a TypedArray. +* @param x The value to check. +* @returns Returns true if `x` is a TypedArray, false otherwise. +* +* @example +* const arr = new Uint8Array([1, 2, 3]); +* isTypedArray(arr); // true +* +* const regularArray = [1, 2, 3]; +* isTypedArray(regularArray); // false +* +* const buffer = new ArrayBuffer(16); +* isTypedArray(buffer); // false +*/ +function isTypedArray(x) { + return require_isTypedArray.isTypedArray(x); +} +//#endregion +exports.isTypedArray = isTypedArray; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.mjs b/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d8aa9e149ca549edb0f43713c3eb1eced44c4339 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isTypedArray.mjs @@ -0,0 +1,22 @@ +import { isTypedArray as isTypedArray$1 } from "../../predicate/isTypedArray.mjs"; +//#region src/compat/predicate/isTypedArray.ts +/** +* Checks if a value is a TypedArray. +* @param x The value to check. +* @returns Returns true if `x` is a TypedArray, false otherwise. +* +* @example +* const arr = new Uint8Array([1, 2, 3]); +* isTypedArray(arr); // true +* +* const regularArray = [1, 2, 3]; +* isTypedArray(regularArray); // false +* +* const buffer = new ArrayBuffer(16); +* isTypedArray(buffer); // false +*/ +function isTypedArray(x) { + return isTypedArray$1(x); +} +//#endregion +export { isTypedArray }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isUndefined.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isUndefined.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9c7cef9ddb9652eefd99b67c09b1e8b1badfcaf4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isUndefined.d.mts @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isUndefined.d.ts +/** + * Checks if the given value is undefined. + * + * This function tests whether the provided value is strictly equal to `undefined`. + * It returns `true` if the value is `undefined`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`. + * + * @param x - The value to test if it is undefined. + * @returns true if the value is undefined, false otherwise. + * + * @example + * const value1 = undefined; + * const value2 = null; + * const value3 = 42; + * + * console.log(isUndefined(value1)); // true + * console.log(isUndefined(value2)); // false + * console.log(isUndefined(value3)); // false + */ +declare function isUndefined(x: any): x is undefined; +//#endregion +export { isUndefined }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isUndefined.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isUndefined.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c7cef9ddb9652eefd99b67c09b1e8b1badfcaf4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isUndefined.d.ts @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isUndefined.d.ts +/** + * Checks if the given value is undefined. + * + * This function tests whether the provided value is strictly equal to `undefined`. + * It returns `true` if the value is `undefined`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`. + * + * @param x - The value to test if it is undefined. + * @returns true if the value is undefined, false otherwise. + * + * @example + * const value1 = undefined; + * const value2 = null; + * const value3 = 42; + * + * console.log(isUndefined(value1)); // true + * console.log(isUndefined(value2)); // false + * console.log(isUndefined(value3)); // false + */ +declare function isUndefined(x: any): x is undefined; +//#endregion +export { isUndefined }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isUndefined.js b/node_modules/es-toolkit/dist/compat/predicate/isUndefined.js new file mode 100644 index 0000000000000000000000000000000000000000..9bf263bbccbb79267cc3ede92532822ee6608129 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isUndefined.js @@ -0,0 +1,27 @@ +const require_isUndefined = require("../../predicate/isUndefined.js"); +//#region src/compat/predicate/isUndefined.ts +/** +* Checks if the given value is undefined. +* +* This function tests whether the provided value is strictly equal to `undefined`. +* It returns `true` if the value is `undefined`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`. +* +* @param x - The value to test if it is undefined. +* @returns true if the value is undefined, false otherwise. +* +* @example +* const value1 = undefined; +* const value2 = null; +* const value3 = 42; +* +* console.log(isUndefined(value1)); // true +* console.log(isUndefined(value2)); // false +* console.log(isUndefined(value3)); // false +*/ +function isUndefined(x) { + return require_isUndefined.isUndefined(x); +} +//#endregion +exports.isUndefined = isUndefined; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isUndefined.mjs b/node_modules/es-toolkit/dist/compat/predicate/isUndefined.mjs new file mode 100644 index 0000000000000000000000000000000000000000..75a43882544402f0ff012963803a4318c0e68b3f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isUndefined.mjs @@ -0,0 +1,27 @@ +import { isUndefined as isUndefined$1 } from "../../predicate/isUndefined.mjs"; +//#region src/compat/predicate/isUndefined.ts +/** +* Checks if the given value is undefined. +* +* This function tests whether the provided value is strictly equal to `undefined`. +* It returns `true` if the value is `undefined`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`. +* +* @param x - The value to test if it is undefined. +* @returns true if the value is undefined, false otherwise. +* +* @example +* const value1 = undefined; +* const value2 = null; +* const value3 = 42; +* +* console.log(isUndefined(value1)); // true +* console.log(isUndefined(value2)); // false +* console.log(isUndefined(value3)); // false +*/ +function isUndefined(x) { + return isUndefined$1(x); +} +//#endregion +export { isUndefined }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..29b973e6d2a646035bde8bff48add9325c189068 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.d.mts @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isWeakMap.d.ts +/** + * Checks if the given value is a `WeakMap`. + * + * This function tests whether the provided value is an instance of `WeakMap`. + * It returns `true` if the value is a `WeakMap`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakMap`. + * + * @param value - The value to test if it is a `WeakMap`. + * @returns true if the value is a `WeakMap`, false otherwise. + * + * @example + * const value1 = new WeakMap(); + * const value2 = new Map(); + * const value3 = new Set(); + * + * console.log(isWeakMap(value1)); // true + * console.log(isWeakMap(value2)); // false + * console.log(isWeakMap(value3)); // false + */ +declare function isWeakMap(value?: any): value is WeakMap; +//#endregion +export { isWeakMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..29b973e6d2a646035bde8bff48add9325c189068 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.d.ts @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isWeakMap.d.ts +/** + * Checks if the given value is a `WeakMap`. + * + * This function tests whether the provided value is an instance of `WeakMap`. + * It returns `true` if the value is a `WeakMap`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakMap`. + * + * @param value - The value to test if it is a `WeakMap`. + * @returns true if the value is a `WeakMap`, false otherwise. + * + * @example + * const value1 = new WeakMap(); + * const value2 = new Map(); + * const value3 = new Set(); + * + * console.log(isWeakMap(value1)); // true + * console.log(isWeakMap(value2)); // false + * console.log(isWeakMap(value3)); // false + */ +declare function isWeakMap(value?: any): value is WeakMap; +//#endregion +export { isWeakMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.js b/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.js new file mode 100644 index 0000000000000000000000000000000000000000..8effb35ebfd3d0d12806000b67e6dc438d7a5389 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.js @@ -0,0 +1,27 @@ +const require_isWeakMap = require("../../predicate/isWeakMap.js"); +//#region src/compat/predicate/isWeakMap.ts +/** +* Checks if the given value is a `WeakMap`. +* +* This function tests whether the provided value is an instance of `WeakMap`. +* It returns `true` if the value is a `WeakMap`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakMap`. +* +* @param value - The value to test if it is a `WeakMap`. +* @returns true if the value is a `WeakMap`, false otherwise. +* +* @example +* const value1 = new WeakMap(); +* const value2 = new Map(); +* const value3 = new Set(); +* +* console.log(isWeakMap(value1)); // true +* console.log(isWeakMap(value2)); // false +* console.log(isWeakMap(value3)); // false +*/ +function isWeakMap(value) { + return require_isWeakMap.isWeakMap(value); +} +//#endregion +exports.isWeakMap = isWeakMap; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.mjs b/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5048b6a97915e89c7c64ace5abe41231fe6137cd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isWeakMap.mjs @@ -0,0 +1,27 @@ +import { isWeakMap as isWeakMap$1 } from "../../predicate/isWeakMap.mjs"; +//#region src/compat/predicate/isWeakMap.ts +/** +* Checks if the given value is a `WeakMap`. +* +* This function tests whether the provided value is an instance of `WeakMap`. +* It returns `true` if the value is a `WeakMap`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakMap`. +* +* @param value - The value to test if it is a `WeakMap`. +* @returns true if the value is a `WeakMap`, false otherwise. +* +* @example +* const value1 = new WeakMap(); +* const value2 = new Map(); +* const value3 = new Set(); +* +* console.log(isWeakMap(value1)); // true +* console.log(isWeakMap(value2)); // false +* console.log(isWeakMap(value3)); // false +*/ +function isWeakMap(value) { + return isWeakMap$1(value); +} +//#endregion +export { isWeakMap }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.d.mts b/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d10cd20212bb28f80eaada64f0d5caad08108f49 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.d.mts @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isWeakSet.d.ts +/** + * Checks if the given value is a `WeakSet`. + * + * This function tests whether the provided value is an instance of `WeakSet`. + * It returns `true` if the value is a `WeakSet`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakSet`. + * + * @param value - The value to test if it is a `WeakSet`. + * @returns true if the value is a `WeakSet`, false otherwise. + * + * @example + * const value1 = new WeakSet(); + * const value2 = new Map(); + * const value3 = new Set(); + * + * console.log(isWeakSet(value1)); // true + * console.log(isWeakSet(value2)); // false + * console.log(isWeakSet(value3)); // false + */ +declare function isWeakSet(value?: any): value is WeakSet; +//#endregion +export { isWeakSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.d.ts b/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d10cd20212bb28f80eaada64f0d5caad08108f49 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.d.ts @@ -0,0 +1,24 @@ +//#region src/compat/predicate/isWeakSet.d.ts +/** + * Checks if the given value is a `WeakSet`. + * + * This function tests whether the provided value is an instance of `WeakSet`. + * It returns `true` if the value is a `WeakSet`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakSet`. + * + * @param value - The value to test if it is a `WeakSet`. + * @returns true if the value is a `WeakSet`, false otherwise. + * + * @example + * const value1 = new WeakSet(); + * const value2 = new Map(); + * const value3 = new Set(); + * + * console.log(isWeakSet(value1)); // true + * console.log(isWeakSet(value2)); // false + * console.log(isWeakSet(value3)); // false + */ +declare function isWeakSet(value?: any): value is WeakSet; +//#endregion +export { isWeakSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.js b/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.js new file mode 100644 index 0000000000000000000000000000000000000000..24c50488e955edcdfd5d5016ff3af28deadad660 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.js @@ -0,0 +1,27 @@ +const require_isWeakSet = require("../../predicate/isWeakSet.js"); +//#region src/compat/predicate/isWeakSet.ts +/** +* Checks if the given value is a `WeakSet`. +* +* This function tests whether the provided value is an instance of `WeakSet`. +* It returns `true` if the value is a `WeakSet`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakSet`. +* +* @param value - The value to test if it is a `WeakSet`. +* @returns true if the value is a `WeakSet`, false otherwise. +* +* @example +* const value1 = new WeakSet(); +* const value2 = new Map(); +* const value3 = new Set(); +* +* console.log(isWeakSet(value1)); // true +* console.log(isWeakSet(value2)); // false +* console.log(isWeakSet(value3)); // false +*/ +function isWeakSet(value) { + return require_isWeakSet.isWeakSet(value); +} +//#endregion +exports.isWeakSet = isWeakSet; diff --git a/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.mjs b/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.mjs new file mode 100644 index 0000000000000000000000000000000000000000..29035f0372e0c8b8988414503bc580b3628f55ea --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/isWeakSet.mjs @@ -0,0 +1,27 @@ +import { isWeakSet as isWeakSet$1 } from "../../predicate/isWeakSet.mjs"; +//#region src/compat/predicate/isWeakSet.ts +/** +* Checks if the given value is a `WeakSet`. +* +* This function tests whether the provided value is an instance of `WeakSet`. +* It returns `true` if the value is a `WeakSet`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakSet`. +* +* @param value - The value to test if it is a `WeakSet`. +* @returns true if the value is a `WeakSet`, false otherwise. +* +* @example +* const value1 = new WeakSet(); +* const value2 = new Map(); +* const value3 = new Set(); +* +* console.log(isWeakSet(value1)); // true +* console.log(isWeakSet(value2)); // false +* console.log(isWeakSet(value3)); // false +*/ +function isWeakSet(value) { + return isWeakSet$1(value); +} +//#endregion +export { isWeakSet }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/matches.d.mts b/node_modules/es-toolkit/dist/compat/predicate/matches.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..30352dfaab49e1d2e08170a29e336fe68918e7ff --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/matches.d.mts @@ -0,0 +1,30 @@ +//#region src/compat/predicate/matches.d.ts +/** + * Creates a function that performs a deep comparison between a given target and the source object. + * + * @template T + * @param source - The source object to create the matcher from. + * @returns Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`. + * + * @example + * const matcher = matches({ a: 1, b: 2 }); + * matcher({ a: 1, b: 2, c: 3 }); // true + * matcher({ a: 1, c: 3 }); // false + */ +declare function matches(source: T): (value: any) => boolean; +/** + * Creates a function that performs a deep comparison between a given target and the source object. + * + * @template T + * @template V + * @param source - The source object to create the matcher from. + * @returns Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`. + * + * @example + * const matcher = matches<{ a: number }, { a: number; b?: number }>({ a: 1 }); + * matcher({ a: 1, b: 2 }); // true + * matcher({ a: 2 }); // false + */ +declare function matches(source: T): (value: V) => boolean; +//#endregion +export { matches }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/matches.d.ts b/node_modules/es-toolkit/dist/compat/predicate/matches.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..30352dfaab49e1d2e08170a29e336fe68918e7ff --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/matches.d.ts @@ -0,0 +1,30 @@ +//#region src/compat/predicate/matches.d.ts +/** + * Creates a function that performs a deep comparison between a given target and the source object. + * + * @template T + * @param source - The source object to create the matcher from. + * @returns Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`. + * + * @example + * const matcher = matches({ a: 1, b: 2 }); + * matcher({ a: 1, b: 2, c: 3 }); // true + * matcher({ a: 1, c: 3 }); // false + */ +declare function matches(source: T): (value: any) => boolean; +/** + * Creates a function that performs a deep comparison between a given target and the source object. + * + * @template T + * @template V + * @param source - The source object to create the matcher from. + * @returns Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`. + * + * @example + * const matcher = matches<{ a: number }, { a: number; b?: number }>({ a: 1 }); + * matcher({ a: 1, b: 2 }); // true + * matcher({ a: 2 }); // false + */ +declare function matches(source: T): (value: V) => boolean; +//#endregion +export { matches }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/matches.js b/node_modules/es-toolkit/dist/compat/predicate/matches.js new file mode 100644 index 0000000000000000000000000000000000000000..ad0e92f18ec2c0e04f2b210acdc6dd4b4b17184a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/matches.js @@ -0,0 +1,37 @@ +const require_cloneDeep = require("../../object/cloneDeep.js"); +const require_isMatch = require("./isMatch.js"); +//#region src/compat/predicate/matches.ts +/** +* Creates a function that performs a deep comparison between a given target and the source object. +* +* @template T +* @template V +* @param source - The source object to create the matcher from. +* @returns Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`. +* +* @example +* // Basic usage +* const matcher = matches({ a: 1, b: 2 }); +* matcher({ a: 1, b: 2, c: 3 }); // true +* matcher({ a: 1, c: 3 }); // false +* +* @example +* // Matching arrays +* const arrayMatcher = matches([1, 2, 3]); +* arrayMatcher([1, 2, 3, 4]); // true +* arrayMatcher([4, 5, 6]); // false +* +* @example +* // Matching objects with nested structures +* const nestedMatcher = matches({ a: { b: 2 } }); +* nestedMatcher({ a: { b: 2, c: 3 } }); // true +* nestedMatcher({ a: { c: 3 } }); // false +*/ +function matches(source) { + source = require_cloneDeep.cloneDeep(source); + return (target) => { + return require_isMatch.isMatch(target, source); + }; +} +//#endregion +exports.matches = matches; diff --git a/node_modules/es-toolkit/dist/compat/predicate/matches.mjs b/node_modules/es-toolkit/dist/compat/predicate/matches.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6f1e0ab42ea266c189cb422a0c4a14aeedf8756a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/matches.mjs @@ -0,0 +1,37 @@ +import { cloneDeep } from "../../object/cloneDeep.mjs"; +import { isMatch } from "./isMatch.mjs"; +//#region src/compat/predicate/matches.ts +/** +* Creates a function that performs a deep comparison between a given target and the source object. +* +* @template T +* @template V +* @param source - The source object to create the matcher from. +* @returns Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`. +* +* @example +* // Basic usage +* const matcher = matches({ a: 1, b: 2 }); +* matcher({ a: 1, b: 2, c: 3 }); // true +* matcher({ a: 1, c: 3 }); // false +* +* @example +* // Matching arrays +* const arrayMatcher = matches([1, 2, 3]); +* arrayMatcher([1, 2, 3, 4]); // true +* arrayMatcher([4, 5, 6]); // false +* +* @example +* // Matching objects with nested structures +* const nestedMatcher = matches({ a: { b: 2 } }); +* nestedMatcher({ a: { b: 2, c: 3 } }); // true +* nestedMatcher({ a: { c: 3 } }); // false +*/ +function matches(source) { + source = cloneDeep(source); + return (target) => { + return isMatch(target, source); + }; +} +//#endregion +export { matches }; diff --git a/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.d.mts b/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bc6baec44670adab2d705d66f0275dd4caebbcdc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.d.mts @@ -0,0 +1,39 @@ +import { PropertyPath } from "../_internal/PropertyPath.mjs"; + +//#region src/compat/predicate/matchesProperty.d.ts +/** + * Creates a function that checks if a given target object matches a specific property value. + * + * @template T + * @template V + * @param path - The property path to check within the target object. + * @param srcValue - The value to compare against the property value in the target object. + * @returns Returns a function that takes a target object and returns + * `true` if the property value at the given path in the target object matches the provided value, + * otherwise returns `false`. + * + * @example + * const checkName = matchesProperty('name', 'Alice'); + * console.log(checkName({ name: 'Alice' })); // true + * console.log(checkName({ name: 'Bob' })); // false + */ +declare function matchesProperty(path: PropertyPath, srcValue: T): (value: any) => boolean; +/** + * Creates a function that checks if a given target object matches a specific property value. + * + * @template T + * @template V + * @param path - The property path to check within the target object. + * @param srcValue - The value to compare against the property value in the target object. + * @returns Returns a function that takes a target object and returns + * `true` if the property value at the given path in the target object matches the provided value, + * otherwise returns `false`. + * + * @example + * const checkNested = matchesProperty(['address', 'city'], 'New York'); + * console.log(checkNested({ address: { city: 'New York' } })); // true + * console.log(checkNested({ address: { city: 'Los Angeles' } })); // false + */ +declare function matchesProperty(path: PropertyPath, srcValue: T): (value: V) => boolean; +//#endregion +export { matchesProperty }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.d.ts b/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..79c62f0d6e0a998dbf6cad5a45b532420ed79cdd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.d.ts @@ -0,0 +1,39 @@ +import { PropertyPath } from "../_internal/PropertyPath.js"; + +//#region src/compat/predicate/matchesProperty.d.ts +/** + * Creates a function that checks if a given target object matches a specific property value. + * + * @template T + * @template V + * @param path - The property path to check within the target object. + * @param srcValue - The value to compare against the property value in the target object. + * @returns Returns a function that takes a target object and returns + * `true` if the property value at the given path in the target object matches the provided value, + * otherwise returns `false`. + * + * @example + * const checkName = matchesProperty('name', 'Alice'); + * console.log(checkName({ name: 'Alice' })); // true + * console.log(checkName({ name: 'Bob' })); // false + */ +declare function matchesProperty(path: PropertyPath, srcValue: T): (value: any) => boolean; +/** + * Creates a function that checks if a given target object matches a specific property value. + * + * @template T + * @template V + * @param path - The property path to check within the target object. + * @param srcValue - The value to compare against the property value in the target object. + * @returns Returns a function that takes a target object and returns + * `true` if the property value at the given path in the target object matches the provided value, + * otherwise returns `false`. + * + * @example + * const checkNested = matchesProperty(['address', 'city'], 'New York'); + * console.log(checkNested({ address: { city: 'New York' } })); // true + * console.log(checkNested({ address: { city: 'Los Angeles' } })); // false + */ +declare function matchesProperty(path: PropertyPath, srcValue: T): (value: V) => boolean; +//#endregion +export { matchesProperty }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js b/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..1940ab328921aae80b5c47948bff1969d1059cde --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js @@ -0,0 +1,50 @@ +const require_toKey = require("../_internal/toKey.js"); +const require_get = require("../object/get.js"); +const require_isMatch = require("./isMatch.js"); +const require_cloneDeep = require("../object/cloneDeep.js"); +const require_has = require("../object/has.js"); +//#region src/compat/predicate/matchesProperty.ts +/** +* Creates a function that checks if a given target object matches a specific property value. +* +* The returned function takes a target object and determines if the property at the +* specified path within the target object is equal to the given value. +* +* @param property - The property path to check within the target object. +* This can be a single property key or an array of property keys. +* @param source - The value to compare against the property value in the target object. +* +* @returns A function that takes a target object and returns +* `true` if the property value at the given path in the target object matches the provided value, +* otherwise returns `false`. +* +* @example +* // Using a single property key +* const checkName = matchesProperty('name', 'Alice'); +* console.log(checkName({ name: 'Alice' })); // true +* console.log(checkName({ name: 'Bob' })); // false +* +* // Using an array of property keys +* const checkNested = matchesProperty(['address', 'city'], 'New York'); +* console.log(checkNested({ address: { city: 'New York' } })); // true +* console.log(checkNested({ address: { city: 'Los Angeles' } })); // false +*/ +function matchesProperty(property, source) { + switch (typeof property) { + case "object": + if (Object.is(property?.valueOf(), -0)) property = "-0"; + break; + case "number": + property = require_toKey.toKey(property); + break; + } + source = require_cloneDeep.cloneDeep(source); + return function(target) { + const result = require_get.get(target, property); + if (result === void 0) return require_has.has(target, property); + if (source === void 0) return result === void 0; + return require_isMatch.isMatch(result, source); + }; +} +//#endregion +exports.matchesProperty = matchesProperty; diff --git a/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.mjs b/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.mjs new file mode 100644 index 0000000000000000000000000000000000000000..579dca4355496af8fb32a316fcf49fcb07813b6b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.mjs @@ -0,0 +1,50 @@ +import { toKey } from "../_internal/toKey.mjs"; +import { get } from "../object/get.mjs"; +import { isMatch } from "./isMatch.mjs"; +import { cloneDeep } from "../object/cloneDeep.mjs"; +import { has } from "../object/has.mjs"; +//#region src/compat/predicate/matchesProperty.ts +/** +* Creates a function that checks if a given target object matches a specific property value. +* +* The returned function takes a target object and determines if the property at the +* specified path within the target object is equal to the given value. +* +* @param property - The property path to check within the target object. +* This can be a single property key or an array of property keys. +* @param source - The value to compare against the property value in the target object. +* +* @returns A function that takes a target object and returns +* `true` if the property value at the given path in the target object matches the provided value, +* otherwise returns `false`. +* +* @example +* // Using a single property key +* const checkName = matchesProperty('name', 'Alice'); +* console.log(checkName({ name: 'Alice' })); // true +* console.log(checkName({ name: 'Bob' })); // false +* +* // Using an array of property keys +* const checkNested = matchesProperty(['address', 'city'], 'New York'); +* console.log(checkNested({ address: { city: 'New York' } })); // true +* console.log(checkNested({ address: { city: 'Los Angeles' } })); // false +*/ +function matchesProperty(property, source) { + switch (typeof property) { + case "object": + if (Object.is(property?.valueOf(), -0)) property = "-0"; + break; + case "number": + property = toKey(property); + break; + } + source = cloneDeep(source); + return function(target) { + const result = get(target, property); + if (result === void 0) return has(target, property); + if (source === void 0) return result === void 0; + return isMatch(result, source); + }; +} +//#endregion +export { matchesProperty }; diff --git a/node_modules/es-toolkit/dist/compat/string/camelCase.d.mts b/node_modules/es-toolkit/dist/compat/string/camelCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a86a656e15dcd0ea834ee28c47818f2d711335ff --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/camelCase.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/string/camelCase.d.ts +/** + * Converts a string to camel case. + * + * Camel case is the naming convention in which the first word is written in lowercase and + * each subsequent word begins with a capital letter, concatenated without any separator characters. + * + * @param str - The string that is to be changed to camel case. + * @returns The converted string to camel case. + * + * @example + * const convertedStr1 = camelCase('camelCase') // returns 'camelCase' + * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace' + * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText' + * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest' + */ +declare function camelCase(str?: string): string; +//#endregion +export { camelCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/camelCase.d.ts b/node_modules/es-toolkit/dist/compat/string/camelCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a86a656e15dcd0ea834ee28c47818f2d711335ff --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/camelCase.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/string/camelCase.d.ts +/** + * Converts a string to camel case. + * + * Camel case is the naming convention in which the first word is written in lowercase and + * each subsequent word begins with a capital letter, concatenated without any separator characters. + * + * @param str - The string that is to be changed to camel case. + * @returns The converted string to camel case. + * + * @example + * const convertedStr1 = camelCase('camelCase') // returns 'camelCase' + * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace' + * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText' + * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest' + */ +declare function camelCase(str?: string): string; +//#endregion +export { camelCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/camelCase.js b/node_modules/es-toolkit/dist/compat/string/camelCase.js new file mode 100644 index 0000000000000000000000000000000000000000..36cbfeb40c9b7a5c68f1f6845103b1b117996bba --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/camelCase.js @@ -0,0 +1,28 @@ +const require_capitalize = require("../../string/capitalize.js"); +const require_deburr = require("./deburr.js"); +const require_words = require("./words.js"); +const require_normalizeForCase = require("../_internal/normalizeForCase.js"); +//#region src/compat/string/camelCase.ts +/** +* Converts a string to camel case. +* +* Camel case is the naming convention in which the first word is written in lowercase and +* each subsequent word begins with a capital letter, concatenated without any separator characters. +* +* @param str - The string that is to be changed to camel case. +* @returns The converted string to camel case. +* +* @example +* const convertedStr1 = camelCase('camelCase') // returns 'camelCase' +* const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace' +* const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText' +* const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest' +*/ +function camelCase(str) { + const splitWords = require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))); + if (splitWords.length === 0) return ""; + const [first, ...rest] = splitWords; + return `${first.toLowerCase()}${rest.map((word) => require_capitalize.capitalize(word)).join("")}`; +} +//#endregion +exports.camelCase = camelCase; diff --git a/node_modules/es-toolkit/dist/compat/string/camelCase.mjs b/node_modules/es-toolkit/dist/compat/string/camelCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..dd20eefbc89de31641dcc08b84e4e43094b7e774 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/camelCase.mjs @@ -0,0 +1,28 @@ +import { capitalize } from "../../string/capitalize.mjs"; +import { deburr } from "./deburr.mjs"; +import { words } from "./words.mjs"; +import { normalizeForCase } from "../_internal/normalizeForCase.mjs"; +//#region src/compat/string/camelCase.ts +/** +* Converts a string to camel case. +* +* Camel case is the naming convention in which the first word is written in lowercase and +* each subsequent word begins with a capital letter, concatenated without any separator characters. +* +* @param str - The string that is to be changed to camel case. +* @returns The converted string to camel case. +* +* @example +* const convertedStr1 = camelCase('camelCase') // returns 'camelCase' +* const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace' +* const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText' +* const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest' +*/ +function camelCase(str) { + const splitWords = words(normalizeForCase(deburr(str))); + if (splitWords.length === 0) return ""; + const [first, ...rest] = splitWords; + return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join("")}`; +} +//#endregion +export { camelCase }; diff --git a/node_modules/es-toolkit/dist/compat/string/capitalize.d.mts b/node_modules/es-toolkit/dist/compat/string/capitalize.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..eeb58d077da39eb342203b5a2d95a588ecf76b7a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/capitalize.d.mts @@ -0,0 +1,15 @@ +//#region src/compat/string/capitalize.d.ts +/** + * Converts the first character of string to upper case and the remaining to lower case. + * + * @param string - The string to capitalize. + * @returns The capitalized string. + * + * @example + * const convertedStr1 = capitalize('fred') // returns 'Fred' + * const convertedStr2 = capitalize('FRED') // returns 'Fred' + * const convertedStr3 = capitalize('') // returns '' + */ +declare function capitalize(str?: T): string extends T ? string : Capitalize>; +//#endregion +export { capitalize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/capitalize.d.ts b/node_modules/es-toolkit/dist/compat/string/capitalize.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..eeb58d077da39eb342203b5a2d95a588ecf76b7a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/capitalize.d.ts @@ -0,0 +1,15 @@ +//#region src/compat/string/capitalize.d.ts +/** + * Converts the first character of string to upper case and the remaining to lower case. + * + * @param string - The string to capitalize. + * @returns The capitalized string. + * + * @example + * const convertedStr1 = capitalize('fred') // returns 'Fred' + * const convertedStr2 = capitalize('FRED') // returns 'Fred' + * const convertedStr3 = capitalize('') // returns '' + */ +declare function capitalize(str?: T): string extends T ? string : Capitalize>; +//#endregion +export { capitalize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/capitalize.js b/node_modules/es-toolkit/dist/compat/string/capitalize.js new file mode 100644 index 0000000000000000000000000000000000000000..0d958ffa8104e3336ec899dec8351a7ae63a2ead --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/capitalize.js @@ -0,0 +1,19 @@ +const require_capitalize = require("../../string/capitalize.js"); +const require_toString = require("../util/toString.js"); +//#region src/compat/string/capitalize.ts +/** +* Converts the first character of string to upper case and the remaining to lower case. +* +* @param string - The string to capitalize. +* @returns The capitalized string. +* +* @example +* const convertedStr1 = capitalize('fred') // returns 'Fred' +* const convertedStr2 = capitalize('FRED') // returns 'Fred' +* const convertedStr3 = capitalize('') // returns '' +*/ +function capitalize(str) { + return require_capitalize.capitalize(require_toString.toString(str)); +} +//#endregion +exports.capitalize = capitalize; diff --git a/node_modules/es-toolkit/dist/compat/string/capitalize.mjs b/node_modules/es-toolkit/dist/compat/string/capitalize.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b53331f8d035a503fbe02d50c5c5db4586257d33 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/capitalize.mjs @@ -0,0 +1,19 @@ +import { capitalize as capitalize$1 } from "../../string/capitalize.mjs"; +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/capitalize.ts +/** +* Converts the first character of string to upper case and the remaining to lower case. +* +* @param string - The string to capitalize. +* @returns The capitalized string. +* +* @example +* const convertedStr1 = capitalize('fred') // returns 'Fred' +* const convertedStr2 = capitalize('FRED') // returns 'Fred' +* const convertedStr3 = capitalize('') // returns '' +*/ +function capitalize(str) { + return capitalize$1(toString(str)); +} +//#endregion +export { capitalize }; diff --git a/node_modules/es-toolkit/dist/compat/string/deburr.d.mts b/node_modules/es-toolkit/dist/compat/string/deburr.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..67ac07d81f29561f222f522ea676c0c47a89007c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/deburr.d.mts @@ -0,0 +1,23 @@ +//#region src/compat/string/deburr.d.ts +/** + * Converts a string by replacing special characters and diacritical marks with their ASCII equivalents. + * For example, "Crème brûlée" becomes "Creme brulee". + * + * @param str - The input string to be deburred. + * @returns The deburred string with special characters replaced by their ASCII equivalents. + * + * @example + * // Basic usage: + * deburr('Æthelred') // returns 'Aethelred' + * + * @example + * // Handling diacritical marks: + * deburr('München') // returns 'Munchen' + * + * @example + * // Special characters: + * deburr('Crème brûlée') // returns 'Creme brulee' + */ +declare function deburr(str?: string): string; +//#endregion +export { deburr }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/deburr.d.ts b/node_modules/es-toolkit/dist/compat/string/deburr.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..67ac07d81f29561f222f522ea676c0c47a89007c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/deburr.d.ts @@ -0,0 +1,23 @@ +//#region src/compat/string/deburr.d.ts +/** + * Converts a string by replacing special characters and diacritical marks with their ASCII equivalents. + * For example, "Crème brûlée" becomes "Creme brulee". + * + * @param str - The input string to be deburred. + * @returns The deburred string with special characters replaced by their ASCII equivalents. + * + * @example + * // Basic usage: + * deburr('Æthelred') // returns 'Aethelred' + * + * @example + * // Handling diacritical marks: + * deburr('München') // returns 'Munchen' + * + * @example + * // Special characters: + * deburr('Crème brûlée') // returns 'Creme brulee' + */ +declare function deburr(str?: string): string; +//#endregion +export { deburr }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/deburr.js b/node_modules/es-toolkit/dist/compat/string/deburr.js new file mode 100644 index 0000000000000000000000000000000000000000..84e64039dcbb29135ca543ece879cca3d3c9e167 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/deburr.js @@ -0,0 +1,27 @@ +const require_deburr = require("../../string/deburr.js"); +const require_toString = require("../util/toString.js"); +//#region src/compat/string/deburr.ts +/** +* Converts a string by replacing special characters and diacritical marks with their ASCII equivalents. +* For example, "Crème brûlée" becomes "Creme brulee". +* +* @param str - The input string to be deburred. +* @returns The deburred string with special characters replaced by their ASCII equivalents. +* +* @example +* // Basic usage: +* deburr('Æthelred') // returns 'Aethelred' +* +* @example +* // Handling diacritical marks: +* deburr('München') // returns 'Munchen' +* +* @example +* // Special characters: +* deburr('Crème brûlée') // returns 'Creme brulee' +*/ +function deburr(str) { + return require_deburr.deburr(require_toString.toString(str)); +} +//#endregion +exports.deburr = deburr; diff --git a/node_modules/es-toolkit/dist/compat/string/deburr.mjs b/node_modules/es-toolkit/dist/compat/string/deburr.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fe2dc915b886d211f513c399979fa0046ec324aa --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/deburr.mjs @@ -0,0 +1,27 @@ +import { deburr as deburr$1 } from "../../string/deburr.mjs"; +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/deburr.ts +/** +* Converts a string by replacing special characters and diacritical marks with their ASCII equivalents. +* For example, "Crème brûlée" becomes "Creme brulee". +* +* @param str - The input string to be deburred. +* @returns The deburred string with special characters replaced by their ASCII equivalents. +* +* @example +* // Basic usage: +* deburr('Æthelred') // returns 'Aethelred' +* +* @example +* // Handling diacritical marks: +* deburr('München') // returns 'Munchen' +* +* @example +* // Special characters: +* deburr('Crème brûlée') // returns 'Creme brulee' +*/ +function deburr(str) { + return deburr$1(toString(str)); +} +//#endregion +export { deburr }; diff --git a/node_modules/es-toolkit/dist/compat/string/endsWith.d.mts b/node_modules/es-toolkit/dist/compat/string/endsWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..09464aad8e989879651f095c4ffac139ea1efb11 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/endsWith.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/string/endsWith.d.ts +/** + * Checks if a string contains another string at the end of the string. + * + * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index. + * + * @param str - The string that might contain the target string. + * @param target - The string to search for. + * @param position - An optional position from the start to search up to this index + * @returns True if the str string ends with the target string. + * + * @example + * const isPrefix = endsWith('fooBar', 'foo') // returns true + * const isPrefix = endsWith('fooBar', 'bar') // returns false + * const isPrefix = endsWith('fooBar', 'abc') // returns false + * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true + * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false + */ +declare function endsWith(str?: string, target?: string, position?: number): boolean; +//#endregion +export { endsWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/endsWith.d.ts b/node_modules/es-toolkit/dist/compat/string/endsWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..09464aad8e989879651f095c4ffac139ea1efb11 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/endsWith.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/string/endsWith.d.ts +/** + * Checks if a string contains another string at the end of the string. + * + * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index. + * + * @param str - The string that might contain the target string. + * @param target - The string to search for. + * @param position - An optional position from the start to search up to this index + * @returns True if the str string ends with the target string. + * + * @example + * const isPrefix = endsWith('fooBar', 'foo') // returns true + * const isPrefix = endsWith('fooBar', 'bar') // returns false + * const isPrefix = endsWith('fooBar', 'abc') // returns false + * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true + * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false + */ +declare function endsWith(str?: string, target?: string, position?: number): boolean; +//#endregion +export { endsWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/endsWith.js b/node_modules/es-toolkit/dist/compat/string/endsWith.js new file mode 100644 index 0000000000000000000000000000000000000000..efe18dab0b571425041e9435982361080ab8a2f5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/endsWith.js @@ -0,0 +1,25 @@ +//#region src/compat/string/endsWith.ts +/** +* Checks if a string contains another string at the end of the string. +* +* Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index. +* +* @param str - The string that might contain the target string. +* @param target - The string to search for. +* @param position - An optional position from the start to search up to this index +* @returns True if the str string ends with the target string. +* +* @example +* const isPrefix = endsWith('fooBar', 'foo') // returns true +* const isPrefix = endsWith('fooBar', 'bar') // returns false +* const isPrefix = endsWith('fooBar', 'abc') // returns false +* const isPrefix = endsWith('fooBar', 'foo', 3) // returns true +* const isPrefix = endsWith('fooBar', 'abc', 5) // returns false +*/ +function endsWith(str, target, position) { + if (str == null || target == null) return false; + if (position == null) position = str.length; + return str.endsWith(target, position); +} +//#endregion +exports.endsWith = endsWith; diff --git a/node_modules/es-toolkit/dist/compat/string/endsWith.mjs b/node_modules/es-toolkit/dist/compat/string/endsWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..08504526f77fd9afe00e9364938bf45b60b4a962 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/endsWith.mjs @@ -0,0 +1,25 @@ +//#region src/compat/string/endsWith.ts +/** +* Checks if a string contains another string at the end of the string. +* +* Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index. +* +* @param str - The string that might contain the target string. +* @param target - The string to search for. +* @param position - An optional position from the start to search up to this index +* @returns True if the str string ends with the target string. +* +* @example +* const isPrefix = endsWith('fooBar', 'foo') // returns true +* const isPrefix = endsWith('fooBar', 'bar') // returns false +* const isPrefix = endsWith('fooBar', 'abc') // returns false +* const isPrefix = endsWith('fooBar', 'foo', 3) // returns true +* const isPrefix = endsWith('fooBar', 'abc', 5) // returns false +*/ +function endsWith(str, target, position) { + if (str == null || target == null) return false; + if (position == null) position = str.length; + return str.endsWith(target, position); +} +//#endregion +export { endsWith }; diff --git a/node_modules/es-toolkit/dist/compat/string/escape.d.mts b/node_modules/es-toolkit/dist/compat/string/escape.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8ca6e8b41f2bc504a4e50029e7b6ee27c0ae4fa7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/escape.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/string/escape.d.ts +/** + * Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities. + * For example, "<" becomes "<". + * + * @param str The string to escape. + * @returns Returns the escaped string. + * + * @example + * escape('This is a
element.'); // returns 'This is a <div> element.' + * escape('This is a "quote"'); // returns 'This is a "quote"' + * escape("This is a 'quote'"); // returns 'This is a 'quote'' + * escape('This is a & symbol'); // returns 'This is a & symbol' + */ +declare function escape(string?: string): string; +//#endregion +export { escape }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/escape.d.ts b/node_modules/es-toolkit/dist/compat/string/escape.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ca6e8b41f2bc504a4e50029e7b6ee27c0ae4fa7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/escape.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/string/escape.d.ts +/** + * Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities. + * For example, "<" becomes "<". + * + * @param str The string to escape. + * @returns Returns the escaped string. + * + * @example + * escape('This is a
element.'); // returns 'This is a <div> element.' + * escape('This is a "quote"'); // returns 'This is a "quote"' + * escape("This is a 'quote'"); // returns 'This is a 'quote'' + * escape('This is a & symbol'); // returns 'This is a & symbol' + */ +declare function escape(string?: string): string; +//#endregion +export { escape }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/escape.js b/node_modules/es-toolkit/dist/compat/string/escape.js new file mode 100644 index 0000000000000000000000000000000000000000..f78a77990f3cd8605e98725d6e578dac73e74630 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/escape.js @@ -0,0 +1,21 @@ +const require_escape = require("../../string/escape.js"); +const require_toString = require("../util/toString.js"); +//#region src/compat/string/escape.ts +/** +* Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities. +* For example, "<" becomes "<". +* +* @param str The string to escape. +* @returns Returns the escaped string. +* +* @example +* escape('This is a
element.'); // returns 'This is a <div> element.' +* escape('This is a "quote"'); // returns 'This is a "quote"' +* escape("This is a 'quote'"); // returns 'This is a 'quote'' +* escape('This is a & symbol'); // returns 'This is a & symbol' +*/ +function escape(string) { + return require_escape.escape(require_toString.toString(string)); +} +//#endregion +exports.escape = escape; diff --git a/node_modules/es-toolkit/dist/compat/string/escape.mjs b/node_modules/es-toolkit/dist/compat/string/escape.mjs new file mode 100644 index 0000000000000000000000000000000000000000..36b004473e8609bb6bbf4169aaf2257bc42e259e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/escape.mjs @@ -0,0 +1,21 @@ +import { escape as escape$1 } from "../../string/escape.mjs"; +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/escape.ts +/** +* Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities. +* For example, "<" becomes "<". +* +* @param str The string to escape. +* @returns Returns the escaped string. +* +* @example +* escape('This is a
element.'); // returns 'This is a <div> element.' +* escape('This is a "quote"'); // returns 'This is a "quote"' +* escape("This is a 'quote'"); // returns 'This is a 'quote'' +* escape('This is a & symbol'); // returns 'This is a & symbol' +*/ +function escape(string) { + return escape$1(toString(string)); +} +//#endregion +export { escape }; diff --git a/node_modules/es-toolkit/dist/compat/string/escapeRegExp.d.mts b/node_modules/es-toolkit/dist/compat/string/escapeRegExp.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7450247c563f69bcbfc8c43c766c6faadf76cc60 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/escapeRegExp.d.mts @@ -0,0 +1,15 @@ +//#region src/compat/string/escapeRegExp.d.ts +/** + * Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`. + * + * @param str The string to escape. + * @returns Returns the escaped string. + * + * @example + * import { escapeRegExp } from 'es-toolkit/string'; + * + * escapeRegExp('[es-toolkit](https://es-toolkit.dev/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.dev/\)' + */ +declare function escapeRegExp(str?: string): string; +//#endregion +export { escapeRegExp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/escapeRegExp.d.ts b/node_modules/es-toolkit/dist/compat/string/escapeRegExp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7450247c563f69bcbfc8c43c766c6faadf76cc60 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/escapeRegExp.d.ts @@ -0,0 +1,15 @@ +//#region src/compat/string/escapeRegExp.d.ts +/** + * Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`. + * + * @param str The string to escape. + * @returns Returns the escaped string. + * + * @example + * import { escapeRegExp } from 'es-toolkit/string'; + * + * escapeRegExp('[es-toolkit](https://es-toolkit.dev/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.dev/\)' + */ +declare function escapeRegExp(str?: string): string; +//#endregion +export { escapeRegExp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/escapeRegExp.js b/node_modules/es-toolkit/dist/compat/string/escapeRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..d60dd9c8c0bf7de4014a7f5bf27dac57620da815 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/escapeRegExp.js @@ -0,0 +1,19 @@ +const require_escapeRegExp = require("../../string/escapeRegExp.js"); +const require_toString = require("../util/toString.js"); +//#region src/compat/string/escapeRegExp.ts +/** +* Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`. +* +* @param str The string to escape. +* @returns Returns the escaped string. +* +* @example +* import { escapeRegExp } from 'es-toolkit/string'; +* +* escapeRegExp('[es-toolkit](https://es-toolkit.dev/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.dev/\)' +*/ +function escapeRegExp(str) { + return require_escapeRegExp.escapeRegExp(require_toString.toString(str)); +} +//#endregion +exports.escapeRegExp = escapeRegExp; diff --git a/node_modules/es-toolkit/dist/compat/string/escapeRegExp.mjs b/node_modules/es-toolkit/dist/compat/string/escapeRegExp.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6c7f98d15ebe2d96aea8708b8d708210c13da8be --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/escapeRegExp.mjs @@ -0,0 +1,19 @@ +import { escapeRegExp as escapeRegExp$1 } from "../../string/escapeRegExp.mjs"; +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/escapeRegExp.ts +/** +* Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`. +* +* @param str The string to escape. +* @returns Returns the escaped string. +* +* @example +* import { escapeRegExp } from 'es-toolkit/string'; +* +* escapeRegExp('[es-toolkit](https://es-toolkit.dev/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.dev/\)' +*/ +function escapeRegExp(str) { + return escapeRegExp$1(toString(str)); +} +//#endregion +export { escapeRegExp }; diff --git a/node_modules/es-toolkit/dist/compat/string/kebabCase.d.mts b/node_modules/es-toolkit/dist/compat/string/kebabCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..86f360af0ad9af6631d6c758363e83c1fa89652d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/kebabCase.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/string/kebabCase.d.ts +/** + * Converts a string to kebab case. + * + * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character. + * + * @param str - The string that is to be changed to kebab case. + * @returns The converted string to kebab case. + * + * @example + * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case' + * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace' + * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text' + * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request' + */ +declare function kebabCase(str?: string): string; +//#endregion +export { kebabCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/kebabCase.d.ts b/node_modules/es-toolkit/dist/compat/string/kebabCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..86f360af0ad9af6631d6c758363e83c1fa89652d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/kebabCase.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/string/kebabCase.d.ts +/** + * Converts a string to kebab case. + * + * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character. + * + * @param str - The string that is to be changed to kebab case. + * @returns The converted string to kebab case. + * + * @example + * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case' + * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace' + * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text' + * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request' + */ +declare function kebabCase(str?: string): string; +//#endregion +export { kebabCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/kebabCase.js b/node_modules/es-toolkit/dist/compat/string/kebabCase.js new file mode 100644 index 0000000000000000000000000000000000000000..6aa1706b1a39c2045ea72c49ea3cc8e2e6031bef --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/kebabCase.js @@ -0,0 +1,23 @@ +const require_deburr = require("./deburr.js"); +const require_words = require("./words.js"); +const require_normalizeForCase = require("../_internal/normalizeForCase.js"); +//#region src/compat/string/kebabCase.ts +/** +* Converts a string to kebab case. +* +* Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character. +* +* @param str - The string that is to be changed to kebab case. +* @returns The converted string to kebab case. +* +* @example +* const convertedStr1 = kebabCase('camelCase') // returns 'camel-case' +* const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace' +* const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text' +* const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request' +*/ +function kebabCase(str) { + return require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))).map((word) => word.toLowerCase()).join("-"); +} +//#endregion +exports.kebabCase = kebabCase; diff --git a/node_modules/es-toolkit/dist/compat/string/kebabCase.mjs b/node_modules/es-toolkit/dist/compat/string/kebabCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b99ab8939fe7adb050555319a0e39f011749e545 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/kebabCase.mjs @@ -0,0 +1,23 @@ +import { deburr } from "./deburr.mjs"; +import { words } from "./words.mjs"; +import { normalizeForCase } from "../_internal/normalizeForCase.mjs"; +//#region src/compat/string/kebabCase.ts +/** +* Converts a string to kebab case. +* +* Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character. +* +* @param str - The string that is to be changed to kebab case. +* @returns The converted string to kebab case. +* +* @example +* const convertedStr1 = kebabCase('camelCase') // returns 'camel-case' +* const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace' +* const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text' +* const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request' +*/ +function kebabCase(str) { + return words(normalizeForCase(deburr(str))).map((word) => word.toLowerCase()).join("-"); +} +//#endregion +export { kebabCase }; diff --git a/node_modules/es-toolkit/dist/compat/string/lowerCase.d.mts b/node_modules/es-toolkit/dist/compat/string/lowerCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..79b5ca692113b6350340bee9b0b9431d78ecda32 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/lowerCase.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/string/lowerCase.d.ts +/** + * Converts a string to lower case. + * + * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character. + * + * @param str - The string that is to be changed to lower case. + * @returns The converted string to lower case. + * + * @example + * const convertedStr1 = lowerCase('camelCase') // returns 'camel case' + * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace' + * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text' + * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request' + */ +declare function lowerCase(str?: string): string; +//#endregion +export { lowerCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/lowerCase.d.ts b/node_modules/es-toolkit/dist/compat/string/lowerCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..79b5ca692113b6350340bee9b0b9431d78ecda32 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/lowerCase.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/string/lowerCase.d.ts +/** + * Converts a string to lower case. + * + * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character. + * + * @param str - The string that is to be changed to lower case. + * @returns The converted string to lower case. + * + * @example + * const convertedStr1 = lowerCase('camelCase') // returns 'camel case' + * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace' + * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text' + * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request' + */ +declare function lowerCase(str?: string): string; +//#endregion +export { lowerCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/lowerCase.js b/node_modules/es-toolkit/dist/compat/string/lowerCase.js new file mode 100644 index 0000000000000000000000000000000000000000..30ec460d84167cd655edf575d9945582bb668e85 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/lowerCase.js @@ -0,0 +1,23 @@ +const require_deburr = require("./deburr.js"); +const require_words = require("./words.js"); +const require_normalizeForCase = require("../_internal/normalizeForCase.js"); +//#region src/compat/string/lowerCase.ts +/** +* Converts a string to lower case. +* +* Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character. +* +* @param str - The string that is to be changed to lower case. +* @returns The converted string to lower case. +* +* @example +* const convertedStr1 = lowerCase('camelCase') // returns 'camel case' +* const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace' +* const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text' +* const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request' +*/ +function lowerCase(str) { + return require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))).map((word) => word.toLowerCase()).join(" "); +} +//#endregion +exports.lowerCase = lowerCase; diff --git a/node_modules/es-toolkit/dist/compat/string/lowerCase.mjs b/node_modules/es-toolkit/dist/compat/string/lowerCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..86f906b6ca5b2fae3ba23b1bc9c6686d5a13b9b1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/lowerCase.mjs @@ -0,0 +1,23 @@ +import { deburr } from "./deburr.mjs"; +import { words } from "./words.mjs"; +import { normalizeForCase } from "../_internal/normalizeForCase.mjs"; +//#region src/compat/string/lowerCase.ts +/** +* Converts a string to lower case. +* +* Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character. +* +* @param str - The string that is to be changed to lower case. +* @returns The converted string to lower case. +* +* @example +* const convertedStr1 = lowerCase('camelCase') // returns 'camel case' +* const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace' +* const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text' +* const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request' +*/ +function lowerCase(str) { + return words(normalizeForCase(deburr(str))).map((word) => word.toLowerCase()).join(" "); +} +//#endregion +export { lowerCase }; diff --git a/node_modules/es-toolkit/dist/compat/string/lowerFirst.d.mts b/node_modules/es-toolkit/dist/compat/string/lowerFirst.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9ffe2c5d17c88d9cfd8b27037fb6c8dfe2f4dac0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/lowerFirst.d.mts @@ -0,0 +1,15 @@ +//#region src/compat/string/lowerFirst.d.ts +/** + * Converts the first character of string to lower case. + * + * @param str - The string that is to be changed + * @returns The converted string. + * + * @example + * const convertedStr1 = lowerCase('fred') // returns 'fred' + * const convertedStr2 = lowerCase('Fred') // returns 'fred' + * const convertedStr3 = lowerCase('FRED') // returns 'fRED' + */ +declare function lowerFirst(str?: T): Uncapitalize; +//#endregion +export { lowerFirst }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/lowerFirst.d.ts b/node_modules/es-toolkit/dist/compat/string/lowerFirst.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ffe2c5d17c88d9cfd8b27037fb6c8dfe2f4dac0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/lowerFirst.d.ts @@ -0,0 +1,15 @@ +//#region src/compat/string/lowerFirst.d.ts +/** + * Converts the first character of string to lower case. + * + * @param str - The string that is to be changed + * @returns The converted string. + * + * @example + * const convertedStr1 = lowerCase('fred') // returns 'fred' + * const convertedStr2 = lowerCase('Fred') // returns 'fred' + * const convertedStr3 = lowerCase('FRED') // returns 'fRED' + */ +declare function lowerFirst(str?: T): Uncapitalize; +//#endregion +export { lowerFirst }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/lowerFirst.js b/node_modules/es-toolkit/dist/compat/string/lowerFirst.js new file mode 100644 index 0000000000000000000000000000000000000000..f2d724d9f554e8f56136f11de0538a115eee4159 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/lowerFirst.js @@ -0,0 +1,19 @@ +const require_lowerFirst = require("../../string/lowerFirst.js"); +const require_toString = require("../util/toString.js"); +//#region src/compat/string/lowerFirst.ts +/** +* Converts the first character of string to lower case. +* +* @param str - The string that is to be changed +* @returns The converted string. +* +* @example +* const convertedStr1 = lowerCase('fred') // returns 'fred' +* const convertedStr2 = lowerCase('Fred') // returns 'fred' +* const convertedStr3 = lowerCase('FRED') // returns 'fRED' +*/ +function lowerFirst(str) { + return require_lowerFirst.lowerFirst(require_toString.toString(str)); +} +//#endregion +exports.lowerFirst = lowerFirst; diff --git a/node_modules/es-toolkit/dist/compat/string/lowerFirst.mjs b/node_modules/es-toolkit/dist/compat/string/lowerFirst.mjs new file mode 100644 index 0000000000000000000000000000000000000000..61e2306f6f2322048d1558bfc532cd6e6d2c362d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/lowerFirst.mjs @@ -0,0 +1,19 @@ +import { lowerFirst as lowerFirst$1 } from "../../string/lowerFirst.mjs"; +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/lowerFirst.ts +/** +* Converts the first character of string to lower case. +* +* @param str - The string that is to be changed +* @returns The converted string. +* +* @example +* const convertedStr1 = lowerCase('fred') // returns 'fred' +* const convertedStr2 = lowerCase('Fred') // returns 'fred' +* const convertedStr3 = lowerCase('FRED') // returns 'fRED' +*/ +function lowerFirst(str) { + return lowerFirst$1(toString(str)); +} +//#endregion +export { lowerFirst }; diff --git a/node_modules/es-toolkit/dist/compat/string/pad.d.mts b/node_modules/es-toolkit/dist/compat/string/pad.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6d3b36f4941bd5fb93140adc82a2c59ad1971bde --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/pad.d.mts @@ -0,0 +1,20 @@ +//#region src/compat/string/pad.d.ts +/** + * 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. + * 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. + * + * @param str - The string to pad. + * @param [length] - The length of the resulting string once padded. + * @param [chars] - The character(s) to use for padding. + * @returns The padded string, or the original string if padding is not required. + * + * @example + * const result1 = pad('abc', 8); // result will be ' abc ' + * const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_' + * const result3 = pad('abc', 3); // result will be 'abc' + * const result4 = pad('abc', 2); // result will be 'abc' + * + */ +declare function pad(str?: string, length?: number, chars?: string): string; +//#endregion +export { pad }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/pad.d.ts b/node_modules/es-toolkit/dist/compat/string/pad.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6d3b36f4941bd5fb93140adc82a2c59ad1971bde --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/pad.d.ts @@ -0,0 +1,20 @@ +//#region src/compat/string/pad.d.ts +/** + * 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. + * 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. + * + * @param str - The string to pad. + * @param [length] - The length of the resulting string once padded. + * @param [chars] - The character(s) to use for padding. + * @returns The padded string, or the original string if padding is not required. + * + * @example + * const result1 = pad('abc', 8); // result will be ' abc ' + * const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_' + * const result3 = pad('abc', 3); // result will be 'abc' + * const result4 = pad('abc', 2); // result will be 'abc' + * + */ +declare function pad(str?: string, length?: number, chars?: string): string; +//#endregion +export { pad }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/pad.js b/node_modules/es-toolkit/dist/compat/string/pad.js new file mode 100644 index 0000000000000000000000000000000000000000..e7bd946f97025d8c049f2ae90d9d03077068cc6d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/pad.js @@ -0,0 +1,31 @@ +const require_toString = require("../util/toString.js"); +const require_toInteger = require("../util/toInteger.js"); +const require_createPadding = require("../_internal/createPadding.js"); +//#region src/compat/string/pad.ts +/** +* 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. +* 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. +* +* @param str - The string to pad. +* @param [length] - The length of the resulting string once padded. +* @param [chars] - The character(s) to use for padding. +* @returns The padded string, or the original string if padding is not required. +* +* @example +* const result1 = pad('abc', 8); // result will be ' abc ' +* const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_' +* const result3 = pad('abc', 3); // result will be 'abc' +* const result4 = pad('abc', 2); // result will be 'abc' +* +*/ +function pad(str, length = 0, chars = " ") { + const value = require_toString.toString(str); + const targetLength = require_toInteger.toInteger(length); + const strLength = require_createPadding.stringSize(value); + if (targetLength <= strLength) return value; + const mid = (targetLength - strLength) / 2; + const padChars = `${chars}`; + return require_createPadding.createPadding(Math.floor(mid), padChars) + value + require_createPadding.createPadding(Math.ceil(mid), padChars); +} +//#endregion +exports.pad = pad; diff --git a/node_modules/es-toolkit/dist/compat/string/pad.mjs b/node_modules/es-toolkit/dist/compat/string/pad.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cfa4f96c1065d2bb23276506730423165ea2bc5f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/pad.mjs @@ -0,0 +1,31 @@ +import { toString } from "../util/toString.mjs"; +import { toInteger } from "../util/toInteger.mjs"; +import { createPadding, stringSize } from "../_internal/createPadding.mjs"; +//#region src/compat/string/pad.ts +/** +* 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. +* 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. +* +* @param str - The string to pad. +* @param [length] - The length of the resulting string once padded. +* @param [chars] - The character(s) to use for padding. +* @returns The padded string, or the original string if padding is not required. +* +* @example +* const result1 = pad('abc', 8); // result will be ' abc ' +* const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_' +* const result3 = pad('abc', 3); // result will be 'abc' +* const result4 = pad('abc', 2); // result will be 'abc' +* +*/ +function pad(str, length = 0, chars = " ") { + const value = toString(str); + const targetLength = toInteger(length); + const strLength = stringSize(value); + if (targetLength <= strLength) return value; + const mid = (targetLength - strLength) / 2; + const padChars = `${chars}`; + return createPadding(Math.floor(mid), padChars) + value + createPadding(Math.ceil(mid), padChars); +} +//#endregion +export { pad }; diff --git a/node_modules/es-toolkit/dist/compat/string/padEnd.d.mts b/node_modules/es-toolkit/dist/compat/string/padEnd.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1dc749eceb932d568a5963edc271791682c27a1d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/padEnd.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/string/padEnd.d.ts +/** + * Pads the end of a string with a given character until it reaches the specified length. + * + * 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. + * + * @param str - The string to pad. + * @param [length] - The length of the resulting string once padded. + * @param [chars] - The character(s) to use for padding. + * @returns The padded string, or the original string if padding is not required. + * + * @example + * const result1 = padEnd('abc', 6); // result will be 'abc ' + * const result2 = padEnd('abc', 6, '_-'); // result will be 'abc_-_' + * const result3 = padEnd('abc', 3); // result will be 'abc' + * const result4 = padEnd('abc', 2); // result will be 'abc' + */ +declare function padEnd(str?: string, length?: number, chars?: string): string; +//#endregion +export { padEnd }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/padEnd.d.ts b/node_modules/es-toolkit/dist/compat/string/padEnd.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1dc749eceb932d568a5963edc271791682c27a1d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/padEnd.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/string/padEnd.d.ts +/** + * Pads the end of a string with a given character until it reaches the specified length. + * + * 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. + * + * @param str - The string to pad. + * @param [length] - The length of the resulting string once padded. + * @param [chars] - The character(s) to use for padding. + * @returns The padded string, or the original string if padding is not required. + * + * @example + * const result1 = padEnd('abc', 6); // result will be 'abc ' + * const result2 = padEnd('abc', 6, '_-'); // result will be 'abc_-_' + * const result3 = padEnd('abc', 3); // result will be 'abc' + * const result4 = padEnd('abc', 2); // result will be 'abc' + */ +declare function padEnd(str?: string, length?: number, chars?: string): string; +//#endregion +export { padEnd }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/padEnd.js b/node_modules/es-toolkit/dist/compat/string/padEnd.js new file mode 100644 index 0000000000000000000000000000000000000000..eef5d9fb305b43b043daeb33e97da852e27e4aa6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/padEnd.js @@ -0,0 +1,30 @@ +const require_toString = require("../util/toString.js"); +const require_toInteger = require("../util/toInteger.js"); +const require_createPadding = require("../_internal/createPadding.js"); +//#region src/compat/string/padEnd.ts +/** +* Pads the end of a string with a given character until it reaches the specified length. +* +* 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. +* +* @param str - The string to pad. +* @param [length] - The length of the resulting string once padded. +* @param [chars] - The character(s) to use for padding. +* @returns The padded string, or the original string if padding is not required. +* +* @example +* const result1 = padEnd('abc', 6); // result will be 'abc ' +* const result2 = padEnd('abc', 6, '_-'); // result will be 'abc_-_' +* const result3 = padEnd('abc', 3); // result will be 'abc' +* const result4 = padEnd('abc', 2); // result will be 'abc' +*/ +function padEnd(str, length = 0, chars = " ") { + const value = require_toString.toString(str); + const targetLength = require_toInteger.toInteger(length); + const strLength = require_createPadding.stringSize(value); + if (targetLength <= strLength) return value; + return value + require_createPadding.createPadding(targetLength - strLength, `${chars}`); +} +//#endregion +exports.padEnd = padEnd; diff --git a/node_modules/es-toolkit/dist/compat/string/padEnd.mjs b/node_modules/es-toolkit/dist/compat/string/padEnd.mjs new file mode 100644 index 0000000000000000000000000000000000000000..53f541d2cebdc88a39298916a296b720806bb2f3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/padEnd.mjs @@ -0,0 +1,30 @@ +import { toString } from "../util/toString.mjs"; +import { toInteger } from "../util/toInteger.mjs"; +import { createPadding, stringSize } from "../_internal/createPadding.mjs"; +//#region src/compat/string/padEnd.ts +/** +* Pads the end of a string with a given character until it reaches the specified length. +* +* 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. +* +* @param str - The string to pad. +* @param [length] - The length of the resulting string once padded. +* @param [chars] - The character(s) to use for padding. +* @returns The padded string, or the original string if padding is not required. +* +* @example +* const result1 = padEnd('abc', 6); // result will be 'abc ' +* const result2 = padEnd('abc', 6, '_-'); // result will be 'abc_-_' +* const result3 = padEnd('abc', 3); // result will be 'abc' +* const result4 = padEnd('abc', 2); // result will be 'abc' +*/ +function padEnd(str, length = 0, chars = " ") { + const value = toString(str); + const targetLength = toInteger(length); + const strLength = stringSize(value); + if (targetLength <= strLength) return value; + return value + createPadding(targetLength - strLength, `${chars}`); +} +//#endregion +export { padEnd }; diff --git a/node_modules/es-toolkit/dist/compat/string/padStart.d.mts b/node_modules/es-toolkit/dist/compat/string/padStart.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..01c3c422ad554cde13a2b833be04e94c73a6d7c9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/padStart.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/string/padStart.d.ts +/** + * Pads the start of a string with a given character until it reaches the specified length. + * + * 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. + * + * @param str - The string to pad. + * @param [length] - The length of the resulting string once padded. + * @param [chars] - The character(s) to use for padding. + * @returns The padded string, or the original string if padding is not required. + * + * @example + * const result1 = padStart('abc', 6); // result will be ' abc' + * const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc' + * const result3 = padStart('abc', 3); // result will be 'abc' + * const result4 = padStart('abc', 2); // result will be 'abc' + */ +declare function padStart(str?: string, length?: number, chars?: string): string; +//#endregion +export { padStart }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/padStart.d.ts b/node_modules/es-toolkit/dist/compat/string/padStart.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..01c3c422ad554cde13a2b833be04e94c73a6d7c9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/padStart.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/string/padStart.d.ts +/** + * Pads the start of a string with a given character until it reaches the specified length. + * + * 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. + * + * @param str - The string to pad. + * @param [length] - The length of the resulting string once padded. + * @param [chars] - The character(s) to use for padding. + * @returns The padded string, or the original string if padding is not required. + * + * @example + * const result1 = padStart('abc', 6); // result will be ' abc' + * const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc' + * const result3 = padStart('abc', 3); // result will be 'abc' + * const result4 = padStart('abc', 2); // result will be 'abc' + */ +declare function padStart(str?: string, length?: number, chars?: string): string; +//#endregion +export { padStart }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/padStart.js b/node_modules/es-toolkit/dist/compat/string/padStart.js new file mode 100644 index 0000000000000000000000000000000000000000..47ee7b9ddaf08c8e3f8eacb35aaf9384c11d54f2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/padStart.js @@ -0,0 +1,30 @@ +const require_toString = require("../util/toString.js"); +const require_toInteger = require("../util/toInteger.js"); +const require_createPadding = require("../_internal/createPadding.js"); +//#region src/compat/string/padStart.ts +/** +* Pads the start of a string with a given character until it reaches the specified length. +* +* 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. +* +* @param str - The string to pad. +* @param [length] - The length of the resulting string once padded. +* @param [chars] - The character(s) to use for padding. +* @returns The padded string, or the original string if padding is not required. +* +* @example +* const result1 = padStart('abc', 6); // result will be ' abc' +* const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc' +* const result3 = padStart('abc', 3); // result will be 'abc' +* const result4 = padStart('abc', 2); // result will be 'abc' +*/ +function padStart(str, length = 0, chars = " ") { + const value = require_toString.toString(str); + const targetLength = require_toInteger.toInteger(length); + const strLength = require_createPadding.stringSize(value); + if (targetLength <= strLength) return value; + return require_createPadding.createPadding(targetLength - strLength, `${chars}`) + value; +} +//#endregion +exports.padStart = padStart; diff --git a/node_modules/es-toolkit/dist/compat/string/padStart.mjs b/node_modules/es-toolkit/dist/compat/string/padStart.mjs new file mode 100644 index 0000000000000000000000000000000000000000..533d051150012133565080eb8da8779764a11477 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/padStart.mjs @@ -0,0 +1,30 @@ +import { toString } from "../util/toString.mjs"; +import { toInteger } from "../util/toInteger.mjs"; +import { createPadding, stringSize } from "../_internal/createPadding.mjs"; +//#region src/compat/string/padStart.ts +/** +* Pads the start of a string with a given character until it reaches the specified length. +* +* 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. +* +* @param str - The string to pad. +* @param [length] - The length of the resulting string once padded. +* @param [chars] - The character(s) to use for padding. +* @returns The padded string, or the original string if padding is not required. +* +* @example +* const result1 = padStart('abc', 6); // result will be ' abc' +* const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc' +* const result3 = padStart('abc', 3); // result will be 'abc' +* const result4 = padStart('abc', 2); // result will be 'abc' +*/ +function padStart(str, length = 0, chars = " ") { + const value = toString(str); + const targetLength = toInteger(length); + const strLength = stringSize(value); + if (targetLength <= strLength) return value; + return createPadding(targetLength - strLength, `${chars}`) + value; +} +//#endregion +export { padStart }; diff --git a/node_modules/es-toolkit/dist/compat/string/repeat.d.mts b/node_modules/es-toolkit/dist/compat/string/repeat.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..13139c7f1768e27a3f8aae6484f76a7adc2cff85 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/repeat.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/string/repeat.d.ts +/** + * Repeats the given string n times. + * + * If n is less than 1, an empty string is returned, or if the string is an empty string, + * the original string is returned unchanged. + * + * @param str - The string to repeat. + * @param n - The number of times to repeat the string. + * @returns The repeated string, or an empty string if n is less than 1. + * + * @example + * repeat('abc', 0); // '' + * repeat('abc', 2); // 'abcabc' + */ +declare function repeat(str?: string, n?: number): string; +//#endregion +export { repeat }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/repeat.d.ts b/node_modules/es-toolkit/dist/compat/string/repeat.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13139c7f1768e27a3f8aae6484f76a7adc2cff85 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/repeat.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/string/repeat.d.ts +/** + * Repeats the given string n times. + * + * If n is less than 1, an empty string is returned, or if the string is an empty string, + * the original string is returned unchanged. + * + * @param str - The string to repeat. + * @param n - The number of times to repeat the string. + * @returns The repeated string, or an empty string if n is less than 1. + * + * @example + * repeat('abc', 0); // '' + * repeat('abc', 2); // 'abcabc' + */ +declare function repeat(str?: string, n?: number): string; +//#endregion +export { repeat }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/repeat.js b/node_modules/es-toolkit/dist/compat/string/repeat.js new file mode 100644 index 0000000000000000000000000000000000000000..5c88c9f35e515ca36237c59df60d53eb50bf9900 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/repeat.js @@ -0,0 +1,27 @@ +const require_toString = require("../util/toString.js"); +const require_toInteger = require("../util/toInteger.js"); +const require_isIterateeCall = require("../_internal/isIterateeCall.js"); +const require_MAX_SAFE_INTEGER = require("../_internal/MAX_SAFE_INTEGER.js"); +//#region src/compat/string/repeat.ts +/** +* Repeats the given string n times. +* +* If n is less than 1, an empty string is returned, or if the string is an empty string, +* the original string is returned unchanged. +* +* @param str - The string to repeat. +* @param n - The number of times to repeat the string. +* @returns The repeated string, or an empty string if n is less than 1. +* +* @example +* repeat('abc', 0); // '' +* repeat('abc', 2); // 'abcabc' +*/ +function repeat(str, n, guard) { + if (guard ? require_isIterateeCall.isIterateeCall(str, n, guard) : n === void 0) n = 1; + else n = require_toInteger.toInteger(n); + if (n < 1 || n > require_MAX_SAFE_INTEGER.MAX_SAFE_INTEGER) return ""; + return require_toString.toString(str).repeat(n); +} +//#endregion +exports.repeat = repeat; diff --git a/node_modules/es-toolkit/dist/compat/string/repeat.mjs b/node_modules/es-toolkit/dist/compat/string/repeat.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5493cbb109cfca3ec19aa0c4a604ad3e3d8454ce --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/repeat.mjs @@ -0,0 +1,27 @@ +import { toString } from "../util/toString.mjs"; +import { toInteger } from "../util/toInteger.mjs"; +import { isIterateeCall } from "../_internal/isIterateeCall.mjs"; +import { MAX_SAFE_INTEGER } from "../_internal/MAX_SAFE_INTEGER.mjs"; +//#region src/compat/string/repeat.ts +/** +* Repeats the given string n times. +* +* If n is less than 1, an empty string is returned, or if the string is an empty string, +* the original string is returned unchanged. +* +* @param str - The string to repeat. +* @param n - The number of times to repeat the string. +* @returns The repeated string, or an empty string if n is less than 1. +* +* @example +* repeat('abc', 0); // '' +* repeat('abc', 2); // 'abcabc' +*/ +function repeat(str, n, guard) { + if (guard ? isIterateeCall(str, n, guard) : n === void 0) n = 1; + else n = toInteger(n); + if (n < 1 || n > MAX_SAFE_INTEGER) return ""; + return toString(str).repeat(n); +} +//#endregion +export { repeat }; diff --git a/node_modules/es-toolkit/dist/compat/string/replace.d.mts b/node_modules/es-toolkit/dist/compat/string/replace.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..cf1474ec3cd2111ce6e0305f6a5574d5c3a32c10 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/replace.d.mts @@ -0,0 +1,6 @@ +//#region src/compat/string/replace.d.ts +type ReplaceFunction = (match: string, ...args: any[]) => string; +declare function replace(string: string, pattern: RegExp | string, replacement: ReplaceFunction | string): string; +declare function replace(pattern: RegExp | string, replacement: ReplaceFunction | string): string; +//#endregion +export { replace }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/replace.d.ts b/node_modules/es-toolkit/dist/compat/string/replace.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf1474ec3cd2111ce6e0305f6a5574d5c3a32c10 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/replace.d.ts @@ -0,0 +1,6 @@ +//#region src/compat/string/replace.d.ts +type ReplaceFunction = (match: string, ...args: any[]) => string; +declare function replace(string: string, pattern: RegExp | string, replacement: ReplaceFunction | string): string; +declare function replace(pattern: RegExp | string, replacement: ReplaceFunction | string): string; +//#endregion +export { replace }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/replace.js b/node_modules/es-toolkit/dist/compat/string/replace.js new file mode 100644 index 0000000000000000000000000000000000000000..7d4d064e774a550c5c68f9ba1f24e2c0b039a161 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/replace.js @@ -0,0 +1,22 @@ +const require_toString = require("../util/toString.js"); +//#region src/compat/string/replace.ts +/** +* Replaces the matched pattern with the replacement string. +* +* @param {} target - The target string. +* @param {} pattern - The pattern to match. +* @param {} replacement - The replacement string or a function that returns the replacement string. +* @returns The new string with the matched pattern replaced. +* +* @example +* replace('abcde', 'de', '123'); // 'abc123' +* replace('abcde', /[bd]/g, '-'); // 'a-c-e' +* replace('abcde', 'de', substring => substring.toUpperCase()); // 'abcDE' +* replace('abcde', /[bd]/g, substring => substring.toUpperCase()); // 'aBcDe' +*/ +function replace(target, pattern, replacement) { + if (arguments.length < 3) return require_toString.toString(target); + return require_toString.toString(target).replace(pattern, replacement); +} +//#endregion +exports.replace = replace; diff --git a/node_modules/es-toolkit/dist/compat/string/replace.mjs b/node_modules/es-toolkit/dist/compat/string/replace.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8178ba1c58953fd48178c5c9cd67cda36cd1e187 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/replace.mjs @@ -0,0 +1,22 @@ +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/replace.ts +/** +* Replaces the matched pattern with the replacement string. +* +* @param {} target - The target string. +* @param {} pattern - The pattern to match. +* @param {} replacement - The replacement string or a function that returns the replacement string. +* @returns The new string with the matched pattern replaced. +* +* @example +* replace('abcde', 'de', '123'); // 'abc123' +* replace('abcde', /[bd]/g, '-'); // 'a-c-e' +* replace('abcde', 'de', substring => substring.toUpperCase()); // 'abcDE' +* replace('abcde', /[bd]/g, substring => substring.toUpperCase()); // 'aBcDe' +*/ +function replace(target, pattern, replacement) { + if (arguments.length < 3) return toString(target); + return toString(target).replace(pattern, replacement); +} +//#endregion +export { replace }; diff --git a/node_modules/es-toolkit/dist/compat/string/snakeCase.d.mts b/node_modules/es-toolkit/dist/compat/string/snakeCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..15d6e887a97615188f900942a6b006a7fbc101f1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/snakeCase.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/string/snakeCase.d.ts +/** + * Converts a string to snake case. + * + * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character. + * + * @param str - The string that is to be changed to snake case. + * @returns The converted string to snake case. + * + * @example + * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case' + * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace' + * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text' + * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request' + */ +declare function snakeCase(str?: string): string; +//#endregion +export { snakeCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/snakeCase.d.ts b/node_modules/es-toolkit/dist/compat/string/snakeCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..15d6e887a97615188f900942a6b006a7fbc101f1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/snakeCase.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/string/snakeCase.d.ts +/** + * Converts a string to snake case. + * + * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character. + * + * @param str - The string that is to be changed to snake case. + * @returns The converted string to snake case. + * + * @example + * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case' + * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace' + * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text' + * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request' + */ +declare function snakeCase(str?: string): string; +//#endregion +export { snakeCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/snakeCase.js b/node_modules/es-toolkit/dist/compat/string/snakeCase.js new file mode 100644 index 0000000000000000000000000000000000000000..04d3b8e8cf4b135d8121cb865efe67a2c78f4043 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/snakeCase.js @@ -0,0 +1,23 @@ +const require_deburr = require("./deburr.js"); +const require_words = require("./words.js"); +const require_normalizeForCase = require("../_internal/normalizeForCase.js"); +//#region src/compat/string/snakeCase.ts +/** +* Converts a string to snake case. +* +* Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character. +* +* @param str - The string that is to be changed to snake case. +* @returns The converted string to snake case. +* +* @example +* const convertedStr1 = snakeCase('camelCase') // returns 'camel_case' +* const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace' +* const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text' +* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request' +*/ +function snakeCase(str) { + return require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))).map((word) => word.toLowerCase()).join("_"); +} +//#endregion +exports.snakeCase = snakeCase; diff --git a/node_modules/es-toolkit/dist/compat/string/snakeCase.mjs b/node_modules/es-toolkit/dist/compat/string/snakeCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..292ce418d874f5e28b4cf1ec17d7247031081675 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/snakeCase.mjs @@ -0,0 +1,23 @@ +import { deburr } from "./deburr.mjs"; +import { words } from "./words.mjs"; +import { normalizeForCase } from "../_internal/normalizeForCase.mjs"; +//#region src/compat/string/snakeCase.ts +/** +* Converts a string to snake case. +* +* Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character. +* +* @param str - The string that is to be changed to snake case. +* @returns The converted string to snake case. +* +* @example +* const convertedStr1 = snakeCase('camelCase') // returns 'camel_case' +* const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace' +* const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text' +* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request' +*/ +function snakeCase(str) { + return words(normalizeForCase(deburr(str))).map((word) => word.toLowerCase()).join("_"); +} +//#endregion +export { snakeCase }; diff --git a/node_modules/es-toolkit/dist/compat/string/split.d.mts b/node_modules/es-toolkit/dist/compat/string/split.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..75361d3174d93aee10d48a36dc8a6ec723183359 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/split.d.mts @@ -0,0 +1,37 @@ +//#region src/compat/string/split.d.ts +/** + * Splits the input string by the specified `separator` + * and returns a new array containing the split segments. + * + * @param [string=''] The string to split. + * @param [separator] The separator pattern to split by. + * @param [limit] The length to truncate results to. + * @returns Returns the string segments. + * + * @example + * split('a-b-c', '-'); + * // => ['a', 'b', 'c'] + * + * split('a-b-c', '-', 2); + * // => ['a', 'b'] + */ +declare function split(string: string | null | undefined, separator?: RegExp | string, limit?: number): string[]; +/** + * Splits the input string by the specified `separator` + * and returns a new array containing the split segments. + * + * @param [string=''] The string to split. + * @param [separator] The separator pattern to split by. + * @param [limit] The length to truncate results to. + * @returns Returns the string segments. + * + * @example + * split('a-b-c', '-'); + * // => ['a', 'b', 'c'] + * + * split('a-b-c', '-', 2); + * // => ['a', 'b'] + */ +declare function split(string: string | null | undefined, index: string | number, guard: object): string[]; +//#endregion +export { split }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/split.d.ts b/node_modules/es-toolkit/dist/compat/string/split.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..75361d3174d93aee10d48a36dc8a6ec723183359 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/split.d.ts @@ -0,0 +1,37 @@ +//#region src/compat/string/split.d.ts +/** + * Splits the input string by the specified `separator` + * and returns a new array containing the split segments. + * + * @param [string=''] The string to split. + * @param [separator] The separator pattern to split by. + * @param [limit] The length to truncate results to. + * @returns Returns the string segments. + * + * @example + * split('a-b-c', '-'); + * // => ['a', 'b', 'c'] + * + * split('a-b-c', '-', 2); + * // => ['a', 'b'] + */ +declare function split(string: string | null | undefined, separator?: RegExp | string, limit?: number): string[]; +/** + * Splits the input string by the specified `separator` + * and returns a new array containing the split segments. + * + * @param [string=''] The string to split. + * @param [separator] The separator pattern to split by. + * @param [limit] The length to truncate results to. + * @returns Returns the string segments. + * + * @example + * split('a-b-c', '-'); + * // => ['a', 'b', 'c'] + * + * split('a-b-c', '-', 2); + * // => ['a', 'b'] + */ +declare function split(string: string | null | undefined, index: string | number, guard: object): string[]; +//#endregion +export { split }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/split.js b/node_modules/es-toolkit/dist/compat/string/split.js new file mode 100644 index 0000000000000000000000000000000000000000..3b2d329dc165719fd39ea0a3025e5cdc1d3ada52 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/split.js @@ -0,0 +1,7 @@ +const require_toString = require("../util/toString.js"); +//#region src/compat/string/split.ts +function split(string, separator, limit) { + return require_toString.toString(string).split(separator, limit); +} +//#endregion +exports.split = split; diff --git a/node_modules/es-toolkit/dist/compat/string/split.mjs b/node_modules/es-toolkit/dist/compat/string/split.mjs new file mode 100644 index 0000000000000000000000000000000000000000..455c394862fdac463636aeacb0afc3ba550ae97b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/split.mjs @@ -0,0 +1,7 @@ +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/split.ts +function split(string, separator, limit) { + return toString(string).split(separator, limit); +} +//#endregion +export { split }; diff --git a/node_modules/es-toolkit/dist/compat/string/startCase.d.mts b/node_modules/es-toolkit/dist/compat/string/startCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..593b9bdb29f9e3280acb50bea8994659917e5d3a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/startCase.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/string/startCase.d.ts +/** + * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase. + * + * Start case is the naming convention in which each word is written with an initial capital letter. + * @param str - The string to convert. + * @returns The converted string. + * + * @example + * const result1 = startCase('hello world'); // result will be 'Hello World' + * const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD' + * const result3 = startCase('hello-world'); // result will be 'Hello World' + * const result4 = startCase('hello_world'); // result will be 'Hello World' + */ +declare function startCase(str?: string): string; +//#endregion +export { startCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/startCase.d.ts b/node_modules/es-toolkit/dist/compat/string/startCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..593b9bdb29f9e3280acb50bea8994659917e5d3a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/startCase.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/string/startCase.d.ts +/** + * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase. + * + * Start case is the naming convention in which each word is written with an initial capital letter. + * @param str - The string to convert. + * @returns The converted string. + * + * @example + * const result1 = startCase('hello world'); // result will be 'Hello World' + * const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD' + * const result3 = startCase('hello-world'); // result will be 'Hello World' + * const result4 = startCase('hello_world'); // result will be 'Hello World' + */ +declare function startCase(str?: string): string; +//#endregion +export { startCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/startCase.js b/node_modules/es-toolkit/dist/compat/string/startCase.js new file mode 100644 index 0000000000000000000000000000000000000000..626c2e192dc28b4b842a536bcf81a51a6befa691 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/startCase.js @@ -0,0 +1,30 @@ +const require_deburr = require("./deburr.js"); +const require_words = require("./words.js"); +const require_normalizeForCase = require("../_internal/normalizeForCase.js"); +//#region src/compat/string/startCase.ts +/** +* Converts the first character of each word in a string to uppercase and the remaining characters to lowercase. +* +* Start case is the naming convention in which each word is written with an initial capital letter. +* @param str - The string to convert. +* @returns The converted string. +* +* @example +* const result1 = startCase('hello world'); // result will be 'Hello World' +* const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD' +* const result3 = startCase('hello-world'); // result will be 'Hello World' +* const result4 = startCase('hello_world'); // result will be 'Hello World' +*/ +function startCase(str) { + const words$1 = require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str)).trim()); + let result = ""; + for (let i = 0; i < words$1.length; i++) { + const word = words$1[i]; + if (result) result += " "; + if (word === word.toUpperCase()) result += word; + else result += word[0].toUpperCase() + word.slice(1).toLowerCase(); + } + return result; +} +//#endregion +exports.startCase = startCase; diff --git a/node_modules/es-toolkit/dist/compat/string/startCase.mjs b/node_modules/es-toolkit/dist/compat/string/startCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c8dfcecf9f436c9070a4df8251e46f4cef9398f9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/startCase.mjs @@ -0,0 +1,30 @@ +import { deburr } from "./deburr.mjs"; +import { words } from "./words.mjs"; +import { normalizeForCase } from "../_internal/normalizeForCase.mjs"; +//#region src/compat/string/startCase.ts +/** +* Converts the first character of each word in a string to uppercase and the remaining characters to lowercase. +* +* Start case is the naming convention in which each word is written with an initial capital letter. +* @param str - The string to convert. +* @returns The converted string. +* +* @example +* const result1 = startCase('hello world'); // result will be 'Hello World' +* const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD' +* const result3 = startCase('hello-world'); // result will be 'Hello World' +* const result4 = startCase('hello_world'); // result will be 'Hello World' +*/ +function startCase(str) { + const words$1 = words(normalizeForCase(deburr(str)).trim()); + let result = ""; + for (let i = 0; i < words$1.length; i++) { + const word = words$1[i]; + if (result) result += " "; + if (word === word.toUpperCase()) result += word; + else result += word[0].toUpperCase() + word.slice(1).toLowerCase(); + } + return result; +} +//#endregion +export { startCase }; diff --git a/node_modules/es-toolkit/dist/compat/string/startsWith.d.mts b/node_modules/es-toolkit/dist/compat/string/startsWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c3d4175e9f5e18b8beb26a47c8008625d50db908 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/startsWith.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/string/startsWith.d.ts +/** + * Checks if a string contains another string at the beginning of the string. + * + * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index. + * + * @param str - The string that might contain the target string. + * @param target - The string to search for. + * @param position - An optional offset to start searching in the str string + * @returns True if the str string starts with the target string. + * + * @example + * const isPrefix = startsWith('fooBar', 'foo') // returns true + * const isPrefix = startsWith('fooBar', 'bar') // returns false + * const isPrefix = startsWith('fooBar', 'abc') // returns false + * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true + * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false + */ +declare function startsWith(str?: string, target?: string, position?: number): boolean; +//#endregion +export { startsWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/startsWith.d.ts b/node_modules/es-toolkit/dist/compat/string/startsWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3d4175e9f5e18b8beb26a47c8008625d50db908 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/startsWith.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/string/startsWith.d.ts +/** + * Checks if a string contains another string at the beginning of the string. + * + * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index. + * + * @param str - The string that might contain the target string. + * @param target - The string to search for. + * @param position - An optional offset to start searching in the str string + * @returns True if the str string starts with the target string. + * + * @example + * const isPrefix = startsWith('fooBar', 'foo') // returns true + * const isPrefix = startsWith('fooBar', 'bar') // returns false + * const isPrefix = startsWith('fooBar', 'abc') // returns false + * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true + * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false + */ +declare function startsWith(str?: string, target?: string, position?: number): boolean; +//#endregion +export { startsWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/startsWith.js b/node_modules/es-toolkit/dist/compat/string/startsWith.js new file mode 100644 index 0000000000000000000000000000000000000000..b0525aa2c621b61cd92ddd1bcc47d067bff67f8b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/startsWith.js @@ -0,0 +1,25 @@ +//#region src/compat/string/startsWith.ts +/** +* Checks if a string contains another string at the beginning of the string. +* +* Checks if one string startsWith another string. Optional position parameter to start searching from a certain index. +* +* @param str - The string that might contain the target string. +* @param target - The string to search for. +* @param position - An optional offset to start searching in the str string +* @returns True if the str string starts with the target string. +* +* @example +* const isPrefix = startsWith('fooBar', 'foo') // returns true +* const isPrefix = startsWith('fooBar', 'bar') // returns false +* const isPrefix = startsWith('fooBar', 'abc') // returns false +* const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true +* const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false +*/ +function startsWith(str, target, position) { + if (str == null || target == null) return false; + if (position == null) position = 0; + return str.startsWith(target, position); +} +//#endregion +exports.startsWith = startsWith; diff --git a/node_modules/es-toolkit/dist/compat/string/startsWith.mjs b/node_modules/es-toolkit/dist/compat/string/startsWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6ddc10a6bc224756a50c6cb67dbb7a5458998230 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/startsWith.mjs @@ -0,0 +1,25 @@ +//#region src/compat/string/startsWith.ts +/** +* Checks if a string contains another string at the beginning of the string. +* +* Checks if one string startsWith another string. Optional position parameter to start searching from a certain index. +* +* @param str - The string that might contain the target string. +* @param target - The string to search for. +* @param position - An optional offset to start searching in the str string +* @returns True if the str string starts with the target string. +* +* @example +* const isPrefix = startsWith('fooBar', 'foo') // returns true +* const isPrefix = startsWith('fooBar', 'bar') // returns false +* const isPrefix = startsWith('fooBar', 'abc') // returns false +* const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true +* const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false +*/ +function startsWith(str, target, position) { + if (str == null || target == null) return false; + if (position == null) position = 0; + return str.startsWith(target, position); +} +//#endregion +export { startsWith }; diff --git a/node_modules/es-toolkit/dist/compat/string/template.d.mts b/node_modules/es-toolkit/dist/compat/string/template.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a971acf7b20b5384e5aba9d2cdaae69ae2c5f330 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/template.d.mts @@ -0,0 +1,30 @@ +import { escape } from "./escape.mjs"; + +//#region src/compat/string/template.d.ts +declare const templateSettings: { + escape: RegExp; + evaluate: RegExp; + interpolate: RegExp; + variable: string; + imports: { + _: { + escape: typeof escape; + template: typeof template; + }; + }; +}; +interface TemplateOptions { + escape?: RegExp | null | undefined; + evaluate?: RegExp | null | undefined; + interpolate?: RegExp | null | undefined; + variable?: string | undefined; + imports?: Record | undefined; + sourceURL?: string; +} +interface TemplateExecutor { + (data?: object): string; + source: string; +} +declare function template(string?: string, options?: TemplateOptions): TemplateExecutor; +//#endregion +export { template }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/template.d.ts b/node_modules/es-toolkit/dist/compat/string/template.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f681a5a5e2876abe407fa622509f415c46e6e73e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/template.d.ts @@ -0,0 +1,30 @@ +import { escape } from "./escape.js"; + +//#region src/compat/string/template.d.ts +declare const templateSettings: { + escape: RegExp; + evaluate: RegExp; + interpolate: RegExp; + variable: string; + imports: { + _: { + escape: typeof escape; + template: typeof template; + }; + }; +}; +interface TemplateOptions { + escape?: RegExp | null | undefined; + evaluate?: RegExp | null | undefined; + interpolate?: RegExp | null | undefined; + variable?: string | undefined; + imports?: Record | undefined; + sourceURL?: string; +} +interface TemplateExecutor { + (data?: object): string; + source: string; +} +declare function template(string?: string, options?: TemplateOptions): TemplateExecutor; +//#endregion +export { template }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/template.js b/node_modules/es-toolkit/dist/compat/string/template.js new file mode 100644 index 0000000000000000000000000000000000000000..48b1dee944c96e68908f86f03245c41f784d0670 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/template.js @@ -0,0 +1,138 @@ +const require_toString = require("../util/toString.js"); +const require_attempt = require("../function/attempt.js"); +const require_defaults = require("../object/defaults.js"); +const require_escape = require("./escape.js"); +//#region src/compat/string/template.ts +const esTemplateRegExp = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; +const unEscapedRegExp = /['\n\r\u2028\u2029\\]/g; +const noMatchExp = /($^)/; +const escapeMap = new Map([ + ["\\", "\\"], + ["'", "'"], + ["\n", "n"], + ["\r", "r"], + ["\u2028", "u2028"], + ["\u2029", "u2029"] +]); +function escapeString(match) { + return `\\${escapeMap.get(match)}`; +} +const defaultInterpolateRegExp = /<%=([\s\S]+?)%>/g; +const templateSettings = { + escape: /<%-([\s\S]+?)%>/g, + evaluate: /<%([\s\S]+?)%>/g, + interpolate: defaultInterpolateRegExp, + variable: "", + imports: { _: { + escape: require_escape.escape, + template + } } +}; +/** +* Compiles a template string into a function that can interpolate data properties. +* +* This function allows you to create a template with custom delimiters for escaping, +* evaluating, and interpolating values. It can also handle custom variable names and +* imported functions. +* +* @param string - The template string. +* @param [options] - The options object. +* @param [options.escape] - The regular expression for "escape" delimiter. +* @param [options.evaluate] - The regular expression for "evaluate" delimiter. +* @param [options.interpolate] - The regular expression for "interpolate" delimiter. +* @param [options.variable] - The data object variable name. +* @param [options.imports] - The object of imported functions. +* @param [options.sourceURL] - The source URL of the template. +* @param [guard] - The guard to detect if the function is called with `options`. +* @returns Returns the compiled template function. +* +* @example +* // Use the "escape" delimiter to escape data properties. +* const compiled = template('<%- value %>'); +* compiled({ value: '
' }); // returns '<div>' +* +* @example +* // Use the "interpolate" delimiter to interpolate data properties. +* const compiled = template('<%= value %>'); +* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!' +* +* @example +* // Use the "evaluate" delimiter to evaluate JavaScript code. +* const compiled = template('<% if (value) { %>Yes<% } else { %>No<% } %>'); +* compiled({ value: true }); // returns 'Yes' +* +* @example +* // Use the "variable" option to specify the data object variable name. +* const compiled = template('<%= data.value %>', { variable: 'data' }); +* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!' +* +* @example +* // Use the "imports" option to import functions. +* const compiled = template('<%= _.toUpper(value) %>', { imports: { _: { toUpper } } }); +* compiled({ value: 'hello, world!' }); // returns 'HELLO, WORLD!' +* +* @example +* // Use the custom "escape" delimiter. +* const compiled = template('<@ value @>', { escape: /<@([\s\S]+?)@>/g }); +* compiled({ value: '
' }); // returns '<div>' +* +* @example +* // Use the custom "evaluate" delimiter. +* const compiled = template('<# if (value) { #>Yes<# } else { #>No<# } #>', { evaluate: /<#([\s\S]+?)#>/g }); +* compiled({ value: true }); // returns 'Yes' +* +* @example +* // Use the custom "interpolate" delimiter. +* const compiled = template('<$ value $>', { interpolate: /<\$([\s\S]+?)\$>/g }); +* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!' +* +* @example +* // Use the "sourceURL" option to specify the source URL of the template. +* const compiled = template('hello <%= user %>!', { sourceURL: 'template.js' }); +*/ +function template(string, options, guard) { + string = require_toString.toString(string); + if (guard) options = templateSettings; + options = require_defaults.defaults({ ...options }, templateSettings); + const delimitersRegExp = new RegExp([ + options.escape?.source ?? noMatchExp.source, + options.interpolate?.source ?? noMatchExp.source, + options.interpolate === defaultInterpolateRegExp ? esTemplateRegExp.source : noMatchExp.source, + options.evaluate?.source ?? noMatchExp.source, + "$" + ].join("|"), "g"); + let lastIndex = 0; + let isEvaluated = false; + let source = `__p += ''`; + for (const match of string.matchAll(delimitersRegExp)) { + const [fullMatch, escapeValue, interpolateValue, esTemplateValue, evaluateValue] = match; + const { index } = match; + source += ` + '${string.slice(lastIndex, index).replace(unEscapedRegExp, escapeString)}'`; + if (escapeValue) source += ` + _.escape(${escapeValue})`; + if (interpolateValue) source += ` + ((${interpolateValue}) == null ? '' : ${interpolateValue})`; + else if (esTemplateValue) source += ` + ((${esTemplateValue}) == null ? '' : ${esTemplateValue})`; + if (evaluateValue) { + source += `;\n${evaluateValue};\n __p += ''`; + isEvaluated = true; + } + lastIndex = index + fullMatch.length; + } + const imports = require_defaults.defaults({ ...options.imports }, templateSettings.imports); + const importsKeys = Object.keys(imports); + const importValues = Object.values(imports); + const sourceURL = `//# sourceURL=${options.sourceURL ? String(options.sourceURL).replace(/[\r\n]/g, " ") : `es-toolkit.templateSource[${Date.now()}]`}\n`; + const compiledFunction = `function(${options.variable || "obj"}) { + let __p = ''; + ${options.variable ? "" : "if (obj == null) { obj = {}; }"} + ${isEvaluated ? `function print() { __p += Array.prototype.join.call(arguments, ''); }` : ""} + ${options.variable ? source : `with(obj) {\n${source}\n}`} + return __p; + }`; + const result = require_attempt.attempt(() => new Function(...importsKeys, `${sourceURL}return ${compiledFunction}`)(...importValues)); + result.source = compiledFunction; + if (result instanceof Error) throw result; + return result; +} +//#endregion +exports.template = template; +exports.templateSettings = templateSettings; diff --git a/node_modules/es-toolkit/dist/compat/string/template.mjs b/node_modules/es-toolkit/dist/compat/string/template.mjs new file mode 100644 index 0000000000000000000000000000000000000000..01fdfdccab44dd24ca8cf4ce880e8b286daf56ef --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/template.mjs @@ -0,0 +1,137 @@ +import { toString } from "../util/toString.mjs"; +import { attempt } from "../function/attempt.mjs"; +import { defaults } from "../object/defaults.mjs"; +import { escape } from "./escape.mjs"; +//#region src/compat/string/template.ts +const esTemplateRegExp = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; +const unEscapedRegExp = /['\n\r\u2028\u2029\\]/g; +const noMatchExp = /($^)/; +const escapeMap = new Map([ + ["\\", "\\"], + ["'", "'"], + ["\n", "n"], + ["\r", "r"], + ["\u2028", "u2028"], + ["\u2029", "u2029"] +]); +function escapeString(match) { + return `\\${escapeMap.get(match)}`; +} +const defaultInterpolateRegExp = /<%=([\s\S]+?)%>/g; +const templateSettings = { + escape: /<%-([\s\S]+?)%>/g, + evaluate: /<%([\s\S]+?)%>/g, + interpolate: defaultInterpolateRegExp, + variable: "", + imports: { _: { + escape, + template + } } +}; +/** +* Compiles a template string into a function that can interpolate data properties. +* +* This function allows you to create a template with custom delimiters for escaping, +* evaluating, and interpolating values. It can also handle custom variable names and +* imported functions. +* +* @param string - The template string. +* @param [options] - The options object. +* @param [options.escape] - The regular expression for "escape" delimiter. +* @param [options.evaluate] - The regular expression for "evaluate" delimiter. +* @param [options.interpolate] - The regular expression for "interpolate" delimiter. +* @param [options.variable] - The data object variable name. +* @param [options.imports] - The object of imported functions. +* @param [options.sourceURL] - The source URL of the template. +* @param [guard] - The guard to detect if the function is called with `options`. +* @returns Returns the compiled template function. +* +* @example +* // Use the "escape" delimiter to escape data properties. +* const compiled = template('<%- value %>'); +* compiled({ value: '
' }); // returns '<div>' +* +* @example +* // Use the "interpolate" delimiter to interpolate data properties. +* const compiled = template('<%= value %>'); +* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!' +* +* @example +* // Use the "evaluate" delimiter to evaluate JavaScript code. +* const compiled = template('<% if (value) { %>Yes<% } else { %>No<% } %>'); +* compiled({ value: true }); // returns 'Yes' +* +* @example +* // Use the "variable" option to specify the data object variable name. +* const compiled = template('<%= data.value %>', { variable: 'data' }); +* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!' +* +* @example +* // Use the "imports" option to import functions. +* const compiled = template('<%= _.toUpper(value) %>', { imports: { _: { toUpper } } }); +* compiled({ value: 'hello, world!' }); // returns 'HELLO, WORLD!' +* +* @example +* // Use the custom "escape" delimiter. +* const compiled = template('<@ value @>', { escape: /<@([\s\S]+?)@>/g }); +* compiled({ value: '
' }); // returns '<div>' +* +* @example +* // Use the custom "evaluate" delimiter. +* const compiled = template('<# if (value) { #>Yes<# } else { #>No<# } #>', { evaluate: /<#([\s\S]+?)#>/g }); +* compiled({ value: true }); // returns 'Yes' +* +* @example +* // Use the custom "interpolate" delimiter. +* const compiled = template('<$ value $>', { interpolate: /<\$([\s\S]+?)\$>/g }); +* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!' +* +* @example +* // Use the "sourceURL" option to specify the source URL of the template. +* const compiled = template('hello <%= user %>!', { sourceURL: 'template.js' }); +*/ +function template(string, options, guard) { + string = toString(string); + if (guard) options = templateSettings; + options = defaults({ ...options }, templateSettings); + const delimitersRegExp = new RegExp([ + options.escape?.source ?? noMatchExp.source, + options.interpolate?.source ?? noMatchExp.source, + options.interpolate === defaultInterpolateRegExp ? esTemplateRegExp.source : noMatchExp.source, + options.evaluate?.source ?? noMatchExp.source, + "$" + ].join("|"), "g"); + let lastIndex = 0; + let isEvaluated = false; + let source = `__p += ''`; + for (const match of string.matchAll(delimitersRegExp)) { + const [fullMatch, escapeValue, interpolateValue, esTemplateValue, evaluateValue] = match; + const { index } = match; + source += ` + '${string.slice(lastIndex, index).replace(unEscapedRegExp, escapeString)}'`; + if (escapeValue) source += ` + _.escape(${escapeValue})`; + if (interpolateValue) source += ` + ((${interpolateValue}) == null ? '' : ${interpolateValue})`; + else if (esTemplateValue) source += ` + ((${esTemplateValue}) == null ? '' : ${esTemplateValue})`; + if (evaluateValue) { + source += `;\n${evaluateValue};\n __p += ''`; + isEvaluated = true; + } + lastIndex = index + fullMatch.length; + } + const imports = defaults({ ...options.imports }, templateSettings.imports); + const importsKeys = Object.keys(imports); + const importValues = Object.values(imports); + const sourceURL = `//# sourceURL=${options.sourceURL ? String(options.sourceURL).replace(/[\r\n]/g, " ") : `es-toolkit.templateSource[${Date.now()}]`}\n`; + const compiledFunction = `function(${options.variable || "obj"}) { + let __p = ''; + ${options.variable ? "" : "if (obj == null) { obj = {}; }"} + ${isEvaluated ? `function print() { __p += Array.prototype.join.call(arguments, ''); }` : ""} + ${options.variable ? source : `with(obj) {\n${source}\n}`} + return __p; + }`; + const result = attempt(() => new Function(...importsKeys, `${sourceURL}return ${compiledFunction}`)(...importValues)); + result.source = compiledFunction; + if (result instanceof Error) throw result; + return result; +} +//#endregion +export { template, templateSettings }; diff --git a/node_modules/es-toolkit/dist/compat/string/templateSettings.d.mts b/node_modules/es-toolkit/dist/compat/string/templateSettings.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..23c690a46bf32a9982bbc28a630fd594ee063046 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/templateSettings.d.mts @@ -0,0 +1,18 @@ +import { escape } from "./escape.mjs"; +import { template } from "./template.mjs"; + +//#region src/compat/string/templateSettings.d.ts +declare const templateSettings: { + escape: RegExp; + evaluate: RegExp; + interpolate: RegExp; + variable: string; + imports: { + _: { + escape: typeof escape; + template: typeof template; + }; + }; +}; +//#endregion +export { templateSettings }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/templateSettings.d.ts b/node_modules/es-toolkit/dist/compat/string/templateSettings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..87d33af056d196c28415b98531aab72cb9c55f09 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/templateSettings.d.ts @@ -0,0 +1,18 @@ +import { escape } from "./escape.js"; +import { template } from "./template.js"; + +//#region src/compat/string/templateSettings.d.ts +declare const templateSettings: { + escape: RegExp; + evaluate: RegExp; + interpolate: RegExp; + variable: string; + imports: { + _: { + escape: typeof escape; + template: typeof template; + }; + }; +}; +//#endregion +export { templateSettings }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/templateSettings.js b/node_modules/es-toolkit/dist/compat/string/templateSettings.js new file mode 100644 index 0000000000000000000000000000000000000000..7868e6abe674a0095005f02ddb20376382fcecaa --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/templateSettings.js @@ -0,0 +1,4 @@ +//#region src/compat/string/templateSettings.ts +const templateSettings = require("./template.js").templateSettings; +//#endregion +exports.templateSettings = templateSettings; diff --git a/node_modules/es-toolkit/dist/compat/string/templateSettings.mjs b/node_modules/es-toolkit/dist/compat/string/templateSettings.mjs new file mode 100644 index 0000000000000000000000000000000000000000..febd2c5f033b30936265289b1df02c6ba58ad734 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/templateSettings.mjs @@ -0,0 +1,5 @@ +import { templateSettings as templateSettings$1 } from "./template.mjs"; +//#region src/compat/string/templateSettings.ts +const templateSettings = templateSettings$1; +//#endregion +export { templateSettings }; diff --git a/node_modules/es-toolkit/dist/compat/string/toLower.d.mts b/node_modules/es-toolkit/dist/compat/string/toLower.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..090071830716d9626407d691aa87cc0953ba2982 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/toLower.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/string/toLower.d.ts +/** + * Converts the given value to a string and transforms it to lower case. + * The function can handle various input types by first converting them to strings. + * + * @param [value=''] The value to convert. + * @returns Returns the lower cased string. + * @example + * + * toLower('--FOO-BAR--'); + * // => '--foo-bar--' + * + * toLower(null); + * // => '' + * + * toLower([1, 2, 3]); + * // => '1,2,3' + */ +declare function toLower(value?: T): Lowercase; +//#endregion +export { toLower }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/toLower.d.ts b/node_modules/es-toolkit/dist/compat/string/toLower.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..090071830716d9626407d691aa87cc0953ba2982 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/toLower.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/string/toLower.d.ts +/** + * Converts the given value to a string and transforms it to lower case. + * The function can handle various input types by first converting them to strings. + * + * @param [value=''] The value to convert. + * @returns Returns the lower cased string. + * @example + * + * toLower('--FOO-BAR--'); + * // => '--foo-bar--' + * + * toLower(null); + * // => '' + * + * toLower([1, 2, 3]); + * // => '1,2,3' + */ +declare function toLower(value?: T): Lowercase; +//#endregion +export { toLower }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/toLower.js b/node_modules/es-toolkit/dist/compat/string/toLower.js new file mode 100644 index 0000000000000000000000000000000000000000..fc3e027869fce68987dcb01ed54f8a39bba5579e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/toLower.js @@ -0,0 +1,24 @@ +const require_toString = require("../util/toString.js"); +//#region src/compat/string/toLower.ts +/** +* Converts the given value to a string and transforms it to lower case. +* The function can handle various input types by first converting them to strings. +* +* @param [value=''] The value to convert. +* @returns Returns the lower cased string. +* @example +* +* toLower('--FOO-BAR--'); +* // => '--foo-bar--' +* +* toLower(null); +* // => '' +* +* toLower([1, 2, 3]); +* // => '1,2,3' +*/ +function toLower(value) { + return require_toString.toString(value).toLowerCase(); +} +//#endregion +exports.toLower = toLower; diff --git a/node_modules/es-toolkit/dist/compat/string/toLower.mjs b/node_modules/es-toolkit/dist/compat/string/toLower.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7cd94415bb16832b34aeea1662a2e74b0b528853 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/toLower.mjs @@ -0,0 +1,24 @@ +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/toLower.ts +/** +* Converts the given value to a string and transforms it to lower case. +* The function can handle various input types by first converting them to strings. +* +* @param [value=''] The value to convert. +* @returns Returns the lower cased string. +* @example +* +* toLower('--FOO-BAR--'); +* // => '--foo-bar--' +* +* toLower(null); +* // => '' +* +* toLower([1, 2, 3]); +* // => '1,2,3' +*/ +function toLower(value) { + return toString(value).toLowerCase(); +} +//#endregion +export { toLower }; diff --git a/node_modules/es-toolkit/dist/compat/string/toUpper.d.mts b/node_modules/es-toolkit/dist/compat/string/toUpper.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b422a05230a20b3a3ffd6b0412ba4e393c2e0617 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/toUpper.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/string/toUpper.d.ts +/** + * Converts `string`, as a whole, to upper case just like + * [String#toUpperCase](https://mdn.io/toUpperCase). + * + * @param [value=''] The value to convert. + * @returns Returns the upper cased string. + * @example + * + * toUpper('--foo-bar--'); + * // => '--FOO-BAR--' + * + * toUpper(null); + * // => '' + * + * toUpper([1, 2, 3]); + * // => '1,2,3' + */ +declare function toUpper(value?: T): Uppercase; +//#endregion +export { toUpper }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/toUpper.d.ts b/node_modules/es-toolkit/dist/compat/string/toUpper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b422a05230a20b3a3ffd6b0412ba4e393c2e0617 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/toUpper.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/string/toUpper.d.ts +/** + * Converts `string`, as a whole, to upper case just like + * [String#toUpperCase](https://mdn.io/toUpperCase). + * + * @param [value=''] The value to convert. + * @returns Returns the upper cased string. + * @example + * + * toUpper('--foo-bar--'); + * // => '--FOO-BAR--' + * + * toUpper(null); + * // => '' + * + * toUpper([1, 2, 3]); + * // => '1,2,3' + */ +declare function toUpper(value?: T): Uppercase; +//#endregion +export { toUpper }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/toUpper.js b/node_modules/es-toolkit/dist/compat/string/toUpper.js new file mode 100644 index 0000000000000000000000000000000000000000..d2a787a027aedb163fd313f0c53a2c3d2d71df9c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/toUpper.js @@ -0,0 +1,24 @@ +const require_toString = require("../util/toString.js"); +//#region src/compat/string/toUpper.ts +/** +* Converts `string`, as a whole, to upper case just like +* [String#toUpperCase](https://mdn.io/toUpperCase). +* +* @param [value=''] The value to convert. +* @returns Returns the upper cased string. +* @example +* +* toUpper('--foo-bar--'); +* // => '--FOO-BAR--' +* +* toUpper(null); +* // => '' +* +* toUpper([1, 2, 3]); +* // => '1,2,3' +*/ +function toUpper(value) { + return require_toString.toString(value).toUpperCase(); +} +//#endregion +exports.toUpper = toUpper; diff --git a/node_modules/es-toolkit/dist/compat/string/toUpper.mjs b/node_modules/es-toolkit/dist/compat/string/toUpper.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f3f7c63c50fc7b56f01bd1b2ea5d88098813ab45 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/toUpper.mjs @@ -0,0 +1,24 @@ +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/toUpper.ts +/** +* Converts `string`, as a whole, to upper case just like +* [String#toUpperCase](https://mdn.io/toUpperCase). +* +* @param [value=''] The value to convert. +* @returns Returns the upper cased string. +* @example +* +* toUpper('--foo-bar--'); +* // => '--FOO-BAR--' +* +* toUpper(null); +* // => '' +* +* toUpper([1, 2, 3]); +* // => '1,2,3' +*/ +function toUpper(value) { + return toString(value).toUpperCase(); +} +//#endregion +export { toUpper }; diff --git a/node_modules/es-toolkit/dist/compat/string/trim.d.mts b/node_modules/es-toolkit/dist/compat/string/trim.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..67600e4e687d83ec7111e1c06fcd9439fea080e7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trim.d.mts @@ -0,0 +1,29 @@ +//#region src/compat/string/trim.d.ts +/** + * Removes leading and trailing whitespace or specified characters from a string. + * + * @param str - The string from which leading and trailing characters will be trimmed. + * @param chars - The character(s) to remove from the end of the string. Defaults to `" "`. + * @returns The resulting string after the specified leading and trailing characters have been removed. + * + * @example + * trim(" hello "); // "hello" + * trim("--hello--", "-"); // "hello" + * trim("##hello##", ["#", "o"]); // "hell" + */ +declare function trim(string?: string, chars?: string): string; +/** + * Removes leading and trailing whitespace or specified characters from a string. + * + * @param str - The string from which leading and trailing characters will be trimmed. + * @param chars - The character(s) to remove from the end of the string. Defaults to `" "`. + * @returns The resulting string after the specified leading and trailing characters have been removed. + * + * @example + * trim(" hello "); // "hello" + * trim("--hello--", "-"); // "hello" + * trim("##hello##", ["#", "o"]); // "hell" + */ +declare function trim(string: string, index: string | number, guard: object): string; +//#endregion +export { trim }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/trim.d.ts b/node_modules/es-toolkit/dist/compat/string/trim.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..67600e4e687d83ec7111e1c06fcd9439fea080e7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trim.d.ts @@ -0,0 +1,29 @@ +//#region src/compat/string/trim.d.ts +/** + * Removes leading and trailing whitespace or specified characters from a string. + * + * @param str - The string from which leading and trailing characters will be trimmed. + * @param chars - The character(s) to remove from the end of the string. Defaults to `" "`. + * @returns The resulting string after the specified leading and trailing characters have been removed. + * + * @example + * trim(" hello "); // "hello" + * trim("--hello--", "-"); // "hello" + * trim("##hello##", ["#", "o"]); // "hell" + */ +declare function trim(string?: string, chars?: string): string; +/** + * Removes leading and trailing whitespace or specified characters from a string. + * + * @param str - The string from which leading and trailing characters will be trimmed. + * @param chars - The character(s) to remove from the end of the string. Defaults to `" "`. + * @returns The resulting string after the specified leading and trailing characters have been removed. + * + * @example + * trim(" hello "); // "hello" + * trim("--hello--", "-"); // "hello" + * trim("##hello##", ["#", "o"]); // "hell" + */ +declare function trim(string: string, index: string | number, guard: object): string; +//#endregion +export { trim }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/trim.js b/node_modules/es-toolkit/dist/compat/string/trim.js new file mode 100644 index 0000000000000000000000000000000000000000..b0e881fe48b560c41224ecbdae5f1cc90e180d36 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trim.js @@ -0,0 +1,13 @@ +const require_trim = require("../../string/trim.js"); +//#region src/compat/string/trim.ts +function trim(str, chars, guard) { + if (str == null) return ""; + if (guard != null || chars == null) return str.toString().trim(); + switch (typeof chars) { + case "object": if (Array.isArray(chars)) return require_trim.trim(str, chars.flatMap((x) => x.toString().split(""))); + else return require_trim.trim(str, chars.toString().split("")); + default: return require_trim.trim(str, chars.toString().split("")); + } +} +//#endregion +exports.trim = trim; diff --git a/node_modules/es-toolkit/dist/compat/string/trim.mjs b/node_modules/es-toolkit/dist/compat/string/trim.mjs new file mode 100644 index 0000000000000000000000000000000000000000..850092cc1ffa14c2fb15d6e1fec9dd35c655ea88 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trim.mjs @@ -0,0 +1,13 @@ +import { trim as trim$1 } from "../../string/trim.mjs"; +//#region src/compat/string/trim.ts +function trim(str, chars, guard) { + if (str == null) return ""; + if (guard != null || chars == null) return str.toString().trim(); + switch (typeof chars) { + case "object": if (Array.isArray(chars)) return trim$1(str, chars.flatMap((x) => x.toString().split(""))); + else return trim$1(str, chars.toString().split("")); + default: return trim$1(str, chars.toString().split("")); + } +} +//#endregion +export { trim }; diff --git a/node_modules/es-toolkit/dist/compat/string/trimEnd.d.mts b/node_modules/es-toolkit/dist/compat/string/trimEnd.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9e2c9fddfebccf3f074229963358fa565f897e09 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trimEnd.d.mts @@ -0,0 +1,31 @@ +//#region src/compat/string/trimEnd.d.ts +/** + * Removes trailing whitespace or specified characters from a string. + * + * @param string - The string to trim. + * @param chars - The characters to trim from the end of the string. + * @returns Returns the trimmed string. + * + * @example + * trimEnd(' abc '); + * // => ' abc' + * + * trimEnd('-_-abc-_-', '_-'); + * // => '-_-abc' + */ +declare function trimEnd(string?: string, chars?: string): string; +/** + * Removes trailing whitespace or specified characters from a string. + * + * @param string - The string to trim. + * @param index - The index parameter (used with guard). + * @param guard - Enables use as an iteratee for methods like `map`. + * @returns Returns the trimmed string. + * + * @example + * trimEnd(' abc ', 0, {}); + * // => ' abc' + */ +declare function trimEnd(string: string, index: string | number, guard: object): string; +//#endregion +export { trimEnd }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/trimEnd.d.ts b/node_modules/es-toolkit/dist/compat/string/trimEnd.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e2c9fddfebccf3f074229963358fa565f897e09 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trimEnd.d.ts @@ -0,0 +1,31 @@ +//#region src/compat/string/trimEnd.d.ts +/** + * Removes trailing whitespace or specified characters from a string. + * + * @param string - The string to trim. + * @param chars - The characters to trim from the end of the string. + * @returns Returns the trimmed string. + * + * @example + * trimEnd(' abc '); + * // => ' abc' + * + * trimEnd('-_-abc-_-', '_-'); + * // => '-_-abc' + */ +declare function trimEnd(string?: string, chars?: string): string; +/** + * Removes trailing whitespace or specified characters from a string. + * + * @param string - The string to trim. + * @param index - The index parameter (used with guard). + * @param guard - Enables use as an iteratee for methods like `map`. + * @returns Returns the trimmed string. + * + * @example + * trimEnd(' abc ', 0, {}); + * // => ' abc' + */ +declare function trimEnd(string: string, index: string | number, guard: object): string; +//#endregion +export { trimEnd }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/trimEnd.js b/node_modules/es-toolkit/dist/compat/string/trimEnd.js new file mode 100644 index 0000000000000000000000000000000000000000..6835f9d1ebf159e9f43206ea613b33b595d6216e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trimEnd.js @@ -0,0 +1,24 @@ +const require_trimEnd = require("../../string/trimEnd.js"); +//#region src/compat/string/trimEnd.ts +/** +* Removes trailing whitespace or specified characters from a string. +* +* @param str - The string from which trailing characters will be trimmed. +* @param chars - The character(s) to remove from the end of the string. +* @param guard - Enables use as an iteratee for methods like `map`. +* @returns Returns the trimmed string. +* +* @example +* trimEnd(' abc '); +* // => ' abc' +* +* trimEnd('-_-abc-_-', '_-'); +* // => '-_-abc' +*/ +function trimEnd(str, chars, guard) { + if (str == null) return ""; + if (guard != null || chars == null) return str.toString().trimEnd(); + return require_trimEnd.trimEnd(str, chars.toString().split("")); +} +//#endregion +exports.trimEnd = trimEnd; diff --git a/node_modules/es-toolkit/dist/compat/string/trimEnd.mjs b/node_modules/es-toolkit/dist/compat/string/trimEnd.mjs new file mode 100644 index 0000000000000000000000000000000000000000..dea17488effc4879ddcbb44f56b005a0f88f59b9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trimEnd.mjs @@ -0,0 +1,24 @@ +import { trimEnd as trimEnd$1 } from "../../string/trimEnd.mjs"; +//#region src/compat/string/trimEnd.ts +/** +* Removes trailing whitespace or specified characters from a string. +* +* @param str - The string from which trailing characters will be trimmed. +* @param chars - The character(s) to remove from the end of the string. +* @param guard - Enables use as an iteratee for methods like `map`. +* @returns Returns the trimmed string. +* +* @example +* trimEnd(' abc '); +* // => ' abc' +* +* trimEnd('-_-abc-_-', '_-'); +* // => '-_-abc' +*/ +function trimEnd(str, chars, guard) { + if (str == null) return ""; + if (guard != null || chars == null) return str.toString().trimEnd(); + return trimEnd$1(str, chars.toString().split("")); +} +//#endregion +export { trimEnd }; diff --git a/node_modules/es-toolkit/dist/compat/string/trimStart.d.mts b/node_modules/es-toolkit/dist/compat/string/trimStart.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..614887a6aceca4aaf82d74f6d8947658036ff602 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trimStart.d.mts @@ -0,0 +1,31 @@ +//#region src/compat/string/trimStart.d.ts +/** + * Removes leading whitespace or specified characters from a string. + * + * @param string - The string to trim. + * @param chars - The characters to trim from the start of the string. + * @returns Returns the trimmed string. + * + * @example + * trimStart(' abc '); + * // => 'abc ' + * + * trimStart('-_-abc-_-', '_-'); + * // => 'abc-_-' + */ +declare function trimStart(string?: string, chars?: string): string; +/** + * Removes leading whitespace or specified characters from a string. + * + * @param string - The string to trim. + * @param index - The index parameter (used with guard). + * @param guard - Enables use as an iteratee for methods like `map`. + * @returns Returns the trimmed string. + * + * @example + * trimStart(' abc ', 0, {}); + * // => 'abc ' + */ +declare function trimStart(string: string, index: string | number, guard: object): string; +//#endregion +export { trimStart }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/trimStart.d.ts b/node_modules/es-toolkit/dist/compat/string/trimStart.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..614887a6aceca4aaf82d74f6d8947658036ff602 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trimStart.d.ts @@ -0,0 +1,31 @@ +//#region src/compat/string/trimStart.d.ts +/** + * Removes leading whitespace or specified characters from a string. + * + * @param string - The string to trim. + * @param chars - The characters to trim from the start of the string. + * @returns Returns the trimmed string. + * + * @example + * trimStart(' abc '); + * // => 'abc ' + * + * trimStart('-_-abc-_-', '_-'); + * // => 'abc-_-' + */ +declare function trimStart(string?: string, chars?: string): string; +/** + * Removes leading whitespace or specified characters from a string. + * + * @param string - The string to trim. + * @param index - The index parameter (used with guard). + * @param guard - Enables use as an iteratee for methods like `map`. + * @returns Returns the trimmed string. + * + * @example + * trimStart(' abc ', 0, {}); + * // => 'abc ' + */ +declare function trimStart(string: string, index: string | number, guard: object): string; +//#endregion +export { trimStart }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/trimStart.js b/node_modules/es-toolkit/dist/compat/string/trimStart.js new file mode 100644 index 0000000000000000000000000000000000000000..5cb8f08f3375fd4d277bfc49b2714ed08f7701e8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trimStart.js @@ -0,0 +1,24 @@ +const require_trimStart = require("../../string/trimStart.js"); +//#region src/compat/string/trimStart.ts +/** +* Removes leading whitespace or specified characters from a string. +* +* @param str - The string from which leading characters will be trimmed. +* @param chars - The character(s) to remove from the start of the string. +* @param guard - Enables use as an iteratee for methods like `map`. +* @returns Returns the trimmed string. +* +* @example +* trimStart(' abc '); +* // => 'abc ' +* +* trimStart('-_-abc-_-', '_-'); +* // => 'abc-_-' +*/ +function trimStart(str, chars, guard) { + if (str == null) return ""; + if (guard != null || chars == null) return str.toString().trimStart(); + return require_trimStart.trimStart(str, chars.toString().split("")); +} +//#endregion +exports.trimStart = trimStart; diff --git a/node_modules/es-toolkit/dist/compat/string/trimStart.mjs b/node_modules/es-toolkit/dist/compat/string/trimStart.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bd230d89d563c270d794d55bfc365cbb7b4428e4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/trimStart.mjs @@ -0,0 +1,24 @@ +import { trimStart as trimStart$1 } from "../../string/trimStart.mjs"; +//#region src/compat/string/trimStart.ts +/** +* Removes leading whitespace or specified characters from a string. +* +* @param str - The string from which leading characters will be trimmed. +* @param chars - The character(s) to remove from the start of the string. +* @param guard - Enables use as an iteratee for methods like `map`. +* @returns Returns the trimmed string. +* +* @example +* trimStart(' abc '); +* // => 'abc ' +* +* trimStart('-_-abc-_-', '_-'); +* // => 'abc-_-' +*/ +function trimStart(str, chars, guard) { + if (str == null) return ""; + if (guard != null || chars == null) return str.toString().trimStart(); + return trimStart$1(str, chars.toString().split("")); +} +//#endregion +export { trimStart }; diff --git a/node_modules/es-toolkit/dist/compat/string/truncate.d.mts b/node_modules/es-toolkit/dist/compat/string/truncate.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3b5773cfa1a57ebdbc6409a057cf21a01d366b93 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/truncate.d.mts @@ -0,0 +1,35 @@ +//#region src/compat/string/truncate.d.ts +type TruncateOptions = { + length?: number; + separator?: string | RegExp; + omission?: string; +}; +/** + * This regex might more completely detect unicode, but it is slower and this project + * desires to mimic the behavior of lodash. + */ +/** + * Truncates `string` if it's longer than the given maximum string length. + * The last characters of the truncated string are replaced with the omission + * string which defaults to "...". + * + * @param [string=''] The string to truncate. + * @param [options={}] The options object. + * @param [options.length=30] The maximum string length. + * @param [options.omission='...'] The string to indicate text is omitted. + * @param [options.separator] The separator pattern to truncate to. + * + * @example + * const test = 'hi-diddly-ho there, neighborino'; + * const truncatedStr1 = truncate(test) // returns 'hi-diddly-ho there, neighbo...' + * const truncatedStr2 = truncate(test, { length: 24, separator: ' ' }) // returns 'hi-diddly-ho there,...' + * const truncatedStr3 = truncate(test, { length: 24, separator: /,? +/ }) // returns 'hi-diddly-ho there...' + * const truncatedStr4 = truncate(test, { omission: ' [...]' }) // returns 'hi-diddly-ho there, neig [...]' + * const truncatedStr5 = truncate('ABC', { length: 3 }) // returns 'ABC' + * const truncatedStr6 = truncate('ABC', { length: 2 }) // returns '...' + * const truncatedStr7 = truncate('¥§✈✉🤓', { length: 5 }) // returns '¥§✈✉🤓' + * const truncatedStr8 = truncate('¥§✈✉🤓', { length: 4, omission: '…' }) // returns '¥§✈…' + */ +declare function truncate(string?: string, options?: TruncateOptions): string; +//#endregion +export { truncate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/truncate.d.ts b/node_modules/es-toolkit/dist/compat/string/truncate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b5773cfa1a57ebdbc6409a057cf21a01d366b93 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/truncate.d.ts @@ -0,0 +1,35 @@ +//#region src/compat/string/truncate.d.ts +type TruncateOptions = { + length?: number; + separator?: string | RegExp; + omission?: string; +}; +/** + * This regex might more completely detect unicode, but it is slower and this project + * desires to mimic the behavior of lodash. + */ +/** + * Truncates `string` if it's longer than the given maximum string length. + * The last characters of the truncated string are replaced with the omission + * string which defaults to "...". + * + * @param [string=''] The string to truncate. + * @param [options={}] The options object. + * @param [options.length=30] The maximum string length. + * @param [options.omission='...'] The string to indicate text is omitted. + * @param [options.separator] The separator pattern to truncate to. + * + * @example + * const test = 'hi-diddly-ho there, neighborino'; + * const truncatedStr1 = truncate(test) // returns 'hi-diddly-ho there, neighbo...' + * const truncatedStr2 = truncate(test, { length: 24, separator: ' ' }) // returns 'hi-diddly-ho there,...' + * const truncatedStr3 = truncate(test, { length: 24, separator: /,? +/ }) // returns 'hi-diddly-ho there...' + * const truncatedStr4 = truncate(test, { omission: ' [...]' }) // returns 'hi-diddly-ho there, neig [...]' + * const truncatedStr5 = truncate('ABC', { length: 3 }) // returns 'ABC' + * const truncatedStr6 = truncate('ABC', { length: 2 }) // returns '...' + * const truncatedStr7 = truncate('¥§✈✉🤓', { length: 5 }) // returns '¥§✈✉🤓' + * const truncatedStr8 = truncate('¥§✈✉🤓', { length: 4, omission: '…' }) // returns '¥§✈…' + */ +declare function truncate(string?: string, options?: TruncateOptions): string; +//#endregion +export { truncate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/truncate.js b/node_modules/es-toolkit/dist/compat/string/truncate.js new file mode 100644 index 0000000000000000000000000000000000000000..a0c23b653ea6d6b98522249d7b23ab208b7e679f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/truncate.js @@ -0,0 +1,65 @@ +const require_isObject = require("../predicate/isObject.js"); +const require_regexMultiByte = require("../_internal/regexMultiByte.js"); +//#region src/compat/string/truncate.ts +/** +* This regex might more completely detect unicode, but it is slower and this project +* desires to mimic the behavior of lodash. +*/ +/** +* Truncates `string` if it's longer than the given maximum string length. +* The last characters of the truncated string are replaced with the omission +* string which defaults to "...". +* +* @param [string=''] The string to truncate. +* @param [options={}] The options object. +* @param [options.length=30] The maximum string length. +* @param [options.omission='...'] The string to indicate text is omitted. +* @param [options.separator] The separator pattern to truncate to. +* +* @example +* const test = 'hi-diddly-ho there, neighborino'; +* const truncatedStr1 = truncate(test) // returns 'hi-diddly-ho there, neighbo...' +* const truncatedStr2 = truncate(test, { length: 24, separator: ' ' }) // returns 'hi-diddly-ho there,...' +* const truncatedStr3 = truncate(test, { length: 24, separator: /,? +/ }) // returns 'hi-diddly-ho there...' +* const truncatedStr4 = truncate(test, { omission: ' [...]' }) // returns 'hi-diddly-ho there, neig [...]' +* const truncatedStr5 = truncate('ABC', { length: 3 }) // returns 'ABC' +* const truncatedStr6 = truncate('ABC', { length: 2 }) // returns '...' +* const truncatedStr7 = truncate('¥§✈✉🤓', { length: 5 }) // returns '¥§✈✉🤓' +* const truncatedStr8 = truncate('¥§✈✉🤓', { length: 4, omission: '…' }) // returns '¥§✈…' +*/ +function truncate(string, options) { + string = string != null ? `${string}` : ""; + let length = 30; + let omission = "..."; + if (require_isObject.isObject(options)) { + length = parseLength(options.length); + omission = "omission" in options ? `${options.omission}` : "..."; + } + let i = string.length; + const lengthOmission = Array.from(omission).length; + const lengthBase = Math.max(length - lengthOmission, 0); + let strArray = void 0; + if (require_regexMultiByte.regexMultiByte.test(string)) { + strArray = Array.from(string); + i = strArray.length; + } + if (length >= i) return string; + if (i <= lengthOmission) return omission; + let base = strArray === void 0 ? string.slice(0, lengthBase) : strArray?.slice(0, lengthBase).join(""); + const separator = options?.separator; + if (!separator) { + base += omission; + return base; + } + const search = separator instanceof RegExp ? separator.source : separator; + const flags = "u" + (separator instanceof RegExp ? separator.flags.replace("u", "") : ""); + const withoutSeparator = new RegExp(`(?.*(?:(?!${search}).))(?:${search})`, flags).exec(base); + return (!withoutSeparator?.groups ? base : withoutSeparator.groups.result) + omission; +} +function parseLength(length) { + if (length == null) return 30; + if (length <= 0) return 0; + return length; +} +//#endregion +exports.truncate = truncate; diff --git a/node_modules/es-toolkit/dist/compat/string/truncate.mjs b/node_modules/es-toolkit/dist/compat/string/truncate.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4568e9961c09884b5a735f34a807960367d158e6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/truncate.mjs @@ -0,0 +1,65 @@ +import { isObject } from "../predicate/isObject.mjs"; +import { regexMultiByte } from "../_internal/regexMultiByte.mjs"; +//#region src/compat/string/truncate.ts +/** +* This regex might more completely detect unicode, but it is slower and this project +* desires to mimic the behavior of lodash. +*/ +/** +* Truncates `string` if it's longer than the given maximum string length. +* The last characters of the truncated string are replaced with the omission +* string which defaults to "...". +* +* @param [string=''] The string to truncate. +* @param [options={}] The options object. +* @param [options.length=30] The maximum string length. +* @param [options.omission='...'] The string to indicate text is omitted. +* @param [options.separator] The separator pattern to truncate to. +* +* @example +* const test = 'hi-diddly-ho there, neighborino'; +* const truncatedStr1 = truncate(test) // returns 'hi-diddly-ho there, neighbo...' +* const truncatedStr2 = truncate(test, { length: 24, separator: ' ' }) // returns 'hi-diddly-ho there,...' +* const truncatedStr3 = truncate(test, { length: 24, separator: /,? +/ }) // returns 'hi-diddly-ho there...' +* const truncatedStr4 = truncate(test, { omission: ' [...]' }) // returns 'hi-diddly-ho there, neig [...]' +* const truncatedStr5 = truncate('ABC', { length: 3 }) // returns 'ABC' +* const truncatedStr6 = truncate('ABC', { length: 2 }) // returns '...' +* const truncatedStr7 = truncate('¥§✈✉🤓', { length: 5 }) // returns '¥§✈✉🤓' +* const truncatedStr8 = truncate('¥§✈✉🤓', { length: 4, omission: '…' }) // returns '¥§✈…' +*/ +function truncate(string, options) { + string = string != null ? `${string}` : ""; + let length = 30; + let omission = "..."; + if (isObject(options)) { + length = parseLength(options.length); + omission = "omission" in options ? `${options.omission}` : "..."; + } + let i = string.length; + const lengthOmission = Array.from(omission).length; + const lengthBase = Math.max(length - lengthOmission, 0); + let strArray = void 0; + if (regexMultiByte.test(string)) { + strArray = Array.from(string); + i = strArray.length; + } + if (length >= i) return string; + if (i <= lengthOmission) return omission; + let base = strArray === void 0 ? string.slice(0, lengthBase) : strArray?.slice(0, lengthBase).join(""); + const separator = options?.separator; + if (!separator) { + base += omission; + return base; + } + const search = separator instanceof RegExp ? separator.source : separator; + const flags = "u" + (separator instanceof RegExp ? separator.flags.replace("u", "") : ""); + const withoutSeparator = new RegExp(`(?.*(?:(?!${search}).))(?:${search})`, flags).exec(base); + return (!withoutSeparator?.groups ? base : withoutSeparator.groups.result) + omission; +} +function parseLength(length) { + if (length == null) return 30; + if (length <= 0) return 0; + return length; +} +//#endregion +export { truncate }; diff --git a/node_modules/es-toolkit/dist/compat/string/unescape.d.mts b/node_modules/es-toolkit/dist/compat/string/unescape.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..85f9d5d5e3b5a37213c654672bbed6c8e92c9732 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/unescape.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/string/unescape.d.ts +/** + * Converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `str` to their corresponding characters. + * It is the inverse of `escape`. + * + * @param str The string to unescape. + * @returns Returns the unescaped string. + * + * @example + * unescape('This is a <div> element.'); // returns 'This is a
element.' + * unescape('This is a "quote"'); // returns 'This is a "quote"' + * unescape('This is a 'quote''); // returns 'This is a 'quote'' + * unescape('This is a & symbol'); // returns 'This is a & symbol' + */ +declare function unescape(str?: string): string; +//#endregion +export { unescape }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/unescape.d.ts b/node_modules/es-toolkit/dist/compat/string/unescape.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..85f9d5d5e3b5a37213c654672bbed6c8e92c9732 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/unescape.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/string/unescape.d.ts +/** + * Converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `str` to their corresponding characters. + * It is the inverse of `escape`. + * + * @param str The string to unescape. + * @returns Returns the unescaped string. + * + * @example + * unescape('This is a <div> element.'); // returns 'This is a
element.' + * unescape('This is a "quote"'); // returns 'This is a "quote"' + * unescape('This is a 'quote''); // returns 'This is a 'quote'' + * unescape('This is a & symbol'); // returns 'This is a & symbol' + */ +declare function unescape(str?: string): string; +//#endregion +export { unescape }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/unescape.js b/node_modules/es-toolkit/dist/compat/string/unescape.js new file mode 100644 index 0000000000000000000000000000000000000000..a30ce8d3188de968bdd42d93885895be287044c4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/unescape.js @@ -0,0 +1,21 @@ +const require_unescape = require("../../string/unescape.js"); +const require_toString = require("../util/toString.js"); +//#region src/compat/string/unescape.ts +/** +* Converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `str` to their corresponding characters. +* It is the inverse of `escape`. +* +* @param str The string to unescape. +* @returns Returns the unescaped string. +* +* @example +* unescape('This is a <div> element.'); // returns 'This is a
element.' +* unescape('This is a "quote"'); // returns 'This is a "quote"' +* unescape('This is a 'quote''); // returns 'This is a 'quote'' +* unescape('This is a & symbol'); // returns 'This is a & symbol' +*/ +function unescape(str) { + return require_unescape.unescape(require_toString.toString(str)); +} +//#endregion +exports.unescape = unescape; diff --git a/node_modules/es-toolkit/dist/compat/string/unescape.mjs b/node_modules/es-toolkit/dist/compat/string/unescape.mjs new file mode 100644 index 0000000000000000000000000000000000000000..086e7180964fae606ffc2008b126f8e3eb093d04 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/unescape.mjs @@ -0,0 +1,21 @@ +import { unescape as unescape$1 } from "../../string/unescape.mjs"; +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/unescape.ts +/** +* Converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `str` to their corresponding characters. +* It is the inverse of `escape`. +* +* @param str The string to unescape. +* @returns Returns the unescaped string. +* +* @example +* unescape('This is a <div> element.'); // returns 'This is a
element.' +* unescape('This is a "quote"'); // returns 'This is a "quote"' +* unescape('This is a 'quote''); // returns 'This is a 'quote'' +* unescape('This is a & symbol'); // returns 'This is a & symbol' +*/ +function unescape(str) { + return unescape$1(toString(str)); +} +//#endregion +export { unescape }; diff --git a/node_modules/es-toolkit/dist/compat/string/upperCase.d.mts b/node_modules/es-toolkit/dist/compat/string/upperCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f8addc79ccc5c8c9ec0a564ed98ab867fb6e7b37 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/upperCase.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/string/upperCase.d.ts +/** + * Converts a string to upper case. + * + * Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character. + * + * @param str - The string that is to be changed to upper case. + * @returns The converted string to upper case. + * + * @example + * const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE' + * const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE' + * const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT' + * const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST' + */ +declare function upperCase(str?: string): string; +//#endregion +export { upperCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/upperCase.d.ts b/node_modules/es-toolkit/dist/compat/string/upperCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8addc79ccc5c8c9ec0a564ed98ab867fb6e7b37 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/upperCase.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/string/upperCase.d.ts +/** + * Converts a string to upper case. + * + * Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character. + * + * @param str - The string that is to be changed to upper case. + * @returns The converted string to upper case. + * + * @example + * const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE' + * const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE' + * const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT' + * const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST' + */ +declare function upperCase(str?: string): string; +//#endregion +export { upperCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/upperCase.js b/node_modules/es-toolkit/dist/compat/string/upperCase.js new file mode 100644 index 0000000000000000000000000000000000000000..343603544f9c763f5513d1cdbe188ed51f78b1a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/upperCase.js @@ -0,0 +1,23 @@ +const require_deburr = require("./deburr.js"); +const require_words = require("./words.js"); +const require_normalizeForCase = require("../_internal/normalizeForCase.js"); +//#region src/compat/string/upperCase.ts +/** +* Converts a string to upper case. +* +* Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character. +* +* @param str - The string that is to be changed to upper case. +* @returns The converted string to upper case. +* +* @example +* const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE' +* const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE' +* const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT' +* const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST' +*/ +function upperCase(str) { + return require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))).map((word) => word.toUpperCase()).join(" "); +} +//#endregion +exports.upperCase = upperCase; diff --git a/node_modules/es-toolkit/dist/compat/string/upperCase.mjs b/node_modules/es-toolkit/dist/compat/string/upperCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c7280980f735e3a889791cd7217b5255a579fffc --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/upperCase.mjs @@ -0,0 +1,23 @@ +import { deburr } from "./deburr.mjs"; +import { words } from "./words.mjs"; +import { normalizeForCase } from "../_internal/normalizeForCase.mjs"; +//#region src/compat/string/upperCase.ts +/** +* Converts a string to upper case. +* +* Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character. +* +* @param str - The string that is to be changed to upper case. +* @returns The converted string to upper case. +* +* @example +* const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE' +* const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE' +* const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT' +* const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST' +*/ +function upperCase(str) { + return words(normalizeForCase(deburr(str))).map((word) => word.toUpperCase()).join(" "); +} +//#endregion +export { upperCase }; diff --git a/node_modules/es-toolkit/dist/compat/string/upperFirst.d.mts b/node_modules/es-toolkit/dist/compat/string/upperFirst.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..30078a3d46a71f76bbfa01c8520f24201452244f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/upperFirst.d.mts @@ -0,0 +1,15 @@ +//#region src/compat/string/upperFirst.d.ts +/** + * Converts the first character of string to upper case. + * + * @param str - The string that is to be changed + * @returns The converted string. + * + * @example + * const convertedStr1 = upperFirst('fred') // returns 'Fred' + * const convertedStr2 = upperFirst('Fred') // returns 'Fred' + * const convertedStr3 = upperFirst('FRED') // returns 'FRED' + */ +declare function upperFirst(str?: T): Capitalize; +//#endregion +export { upperFirst }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/upperFirst.d.ts b/node_modules/es-toolkit/dist/compat/string/upperFirst.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..30078a3d46a71f76bbfa01c8520f24201452244f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/upperFirst.d.ts @@ -0,0 +1,15 @@ +//#region src/compat/string/upperFirst.d.ts +/** + * Converts the first character of string to upper case. + * + * @param str - The string that is to be changed + * @returns The converted string. + * + * @example + * const convertedStr1 = upperFirst('fred') // returns 'Fred' + * const convertedStr2 = upperFirst('Fred') // returns 'Fred' + * const convertedStr3 = upperFirst('FRED') // returns 'FRED' + */ +declare function upperFirst(str?: T): Capitalize; +//#endregion +export { upperFirst }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/upperFirst.js b/node_modules/es-toolkit/dist/compat/string/upperFirst.js new file mode 100644 index 0000000000000000000000000000000000000000..ea85cab03d23ac98d662a6e9b5e098c3b77e6834 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/upperFirst.js @@ -0,0 +1,19 @@ +const require_upperFirst = require("../../string/upperFirst.js"); +const require_toString = require("../util/toString.js"); +//#region src/compat/string/upperFirst.ts +/** +* Converts the first character of string to upper case. +* +* @param str - The string that is to be changed +* @returns The converted string. +* +* @example +* const convertedStr1 = upperFirst('fred') // returns 'Fred' +* const convertedStr2 = upperFirst('Fred') // returns 'Fred' +* const convertedStr3 = upperFirst('FRED') // returns 'FRED' +*/ +function upperFirst(str) { + return require_upperFirst.upperFirst(require_toString.toString(str)); +} +//#endregion +exports.upperFirst = upperFirst; diff --git a/node_modules/es-toolkit/dist/compat/string/upperFirst.mjs b/node_modules/es-toolkit/dist/compat/string/upperFirst.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a76a38d296e951a8d39ada46a1a090c9e78486ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/upperFirst.mjs @@ -0,0 +1,19 @@ +import { upperFirst as upperFirst$1 } from "../../string/upperFirst.mjs"; +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/upperFirst.ts +/** +* Converts the first character of string to upper case. +* +* @param str - The string that is to be changed +* @returns The converted string. +* +* @example +* const convertedStr1 = upperFirst('fred') // returns 'Fred' +* const convertedStr2 = upperFirst('Fred') // returns 'Fred' +* const convertedStr3 = upperFirst('FRED') // returns 'FRED' +*/ +function upperFirst(str) { + return upperFirst$1(toString(str)); +} +//#endregion +export { upperFirst }; diff --git a/node_modules/es-toolkit/dist/compat/string/words.d.mts b/node_modules/es-toolkit/dist/compat/string/words.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b731f2b886cf678487799d490cf14d77e8ca3f8d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/words.d.mts @@ -0,0 +1,28 @@ +//#region src/compat/string/words.d.ts +/** + * Splits `string` into an array of its words. + * + * @param str - The string or object that is to be split into words. + * @param [pattern] - The pattern to match words. + * @returns Returns the words of `string`. + * + * @example + * const wordsArray1 = words('fred, barney, & pebbles'); + * // => ['fred', 'barney', 'pebbles'] + * + */ +declare function words(string?: string, pattern?: string | RegExp): string[]; +/** + * Splits `string` into an array of its words. + * + * @param str - The string or object that is to be split into words. + * @param [pattern] - The pattern to match words. + * @returns Returns the words of `string`. + * + * @example + * const wordsArray1 = words('fred, barney, & pebbles'); + * // => ['fred', 'barney', 'pebbles'] + */ +declare function words(string: string, index: string | number, guard: object): string[]; +//#endregion +export { words }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/words.d.ts b/node_modules/es-toolkit/dist/compat/string/words.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b731f2b886cf678487799d490cf14d77e8ca3f8d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/words.d.ts @@ -0,0 +1,28 @@ +//#region src/compat/string/words.d.ts +/** + * Splits `string` into an array of its words. + * + * @param str - The string or object that is to be split into words. + * @param [pattern] - The pattern to match words. + * @returns Returns the words of `string`. + * + * @example + * const wordsArray1 = words('fred, barney, & pebbles'); + * // => ['fred', 'barney', 'pebbles'] + * + */ +declare function words(string?: string, pattern?: string | RegExp): string[]; +/** + * Splits `string` into an array of its words. + * + * @param str - The string or object that is to be split into words. + * @param [pattern] - The pattern to match words. + * @returns Returns the words of `string`. + * + * @example + * const wordsArray1 = words('fred, barney, & pebbles'); + * // => ['fred', 'barney', 'pebbles'] + */ +declare function words(string: string, index: string | number, guard: object): string[]; +//#endregion +export { words }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/string/words.js b/node_modules/es-toolkit/dist/compat/string/words.js new file mode 100644 index 0000000000000000000000000000000000000000..1b8dae6ac89a950d45ceb966f6a022ffee384ac6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/words.js @@ -0,0 +1,42 @@ +const require_toString = require("../util/toString.js"); +//#region src/compat/string/words.ts +const rNonCharLatin = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\xd7\\xf7"; +const rUnicodeUpper = "\\p{Lu}"; +const rUnicodeLower = "\\p{Ll}"; +const rMisc = "(?:[\\p{Lm}\\p{Lo}]\\p{M}*)"; +const rNumber = "\\d"; +const rUnicodeOptContrLower = "(?:['’](?:d|ll|m|re|s|t|ve))?"; +const rUnicodeOptContrUpper = "(?:['’](?:D|LL|M|RE|S|T|VE))?"; +const rUnicodeBreak = `[\\p{Z}\\p{P}${rNonCharLatin}]`; +const rUnicodeMiscUpper = `(?:${rUnicodeUpper}|${rMisc})`; +const rUnicodeMiscLower = `(?:${rUnicodeLower}|${rMisc})`; +const rUnicodeWord = RegExp([ + `${rUnicodeUpper}?${rUnicodeLower}+${rUnicodeOptContrLower}(?=${rUnicodeBreak}|${rUnicodeUpper}|$)`, + `${rUnicodeMiscUpper}+${rUnicodeOptContrUpper}(?=${rUnicodeBreak}|${rUnicodeUpper}${rUnicodeMiscLower}|$)`, + `${rUnicodeUpper}?${rUnicodeMiscLower}+${rUnicodeOptContrLower}`, + `${rUnicodeUpper}+${rUnicodeOptContrUpper}`, + `${rNumber}*(?:1ST|2ND|3RD|(?![123])${rNumber}TH)(?=\\b|[a-z_])`, + `${rNumber}*(?:1st|2nd|3rd|(?![123])${rNumber}th)(?=\\b|[A-Z_])`, + `${rNumber}+`, + "\\p{Emoji_Presentation}", + "\\p{Extended_Pictographic}" +].join("|"), "gu"); +/** +* Splits `string` into an array of its words. +* +* @param str - The string or object that is to be split into words. +* @param [pattern] - The pattern to match words. +* @returns Returns the words of `string`. +* +* @example +* const wordsArray1 = words('fred, barney, & pebbles'); +* // => ['fred', 'barney', 'pebbles'] +*/ +function words(str, pattern = rUnicodeWord, guard) { + const input = require_toString.toString(str); + if (guard) pattern = rUnicodeWord; + if (typeof pattern === "number") pattern = pattern.toString(); + return Array.from(input.match(pattern) ?? []).filter((x) => x !== ""); +} +//#endregion +exports.words = words; diff --git a/node_modules/es-toolkit/dist/compat/string/words.mjs b/node_modules/es-toolkit/dist/compat/string/words.mjs new file mode 100644 index 0000000000000000000000000000000000000000..80bb77db7b28ee50d7552c80780406222cfe8d8d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/string/words.mjs @@ -0,0 +1,42 @@ +import { toString } from "../util/toString.mjs"; +//#region src/compat/string/words.ts +const rNonCharLatin = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\xd7\\xf7"; +const rUnicodeUpper = "\\p{Lu}"; +const rUnicodeLower = "\\p{Ll}"; +const rMisc = "(?:[\\p{Lm}\\p{Lo}]\\p{M}*)"; +const rNumber = "\\d"; +const rUnicodeOptContrLower = "(?:['’](?:d|ll|m|re|s|t|ve))?"; +const rUnicodeOptContrUpper = "(?:['’](?:D|LL|M|RE|S|T|VE))?"; +const rUnicodeBreak = `[\\p{Z}\\p{P}${rNonCharLatin}]`; +const rUnicodeMiscUpper = `(?:${rUnicodeUpper}|${rMisc})`; +const rUnicodeMiscLower = `(?:${rUnicodeLower}|${rMisc})`; +const rUnicodeWord = RegExp([ + `${rUnicodeUpper}?${rUnicodeLower}+${rUnicodeOptContrLower}(?=${rUnicodeBreak}|${rUnicodeUpper}|$)`, + `${rUnicodeMiscUpper}+${rUnicodeOptContrUpper}(?=${rUnicodeBreak}|${rUnicodeUpper}${rUnicodeMiscLower}|$)`, + `${rUnicodeUpper}?${rUnicodeMiscLower}+${rUnicodeOptContrLower}`, + `${rUnicodeUpper}+${rUnicodeOptContrUpper}`, + `${rNumber}*(?:1ST|2ND|3RD|(?![123])${rNumber}TH)(?=\\b|[a-z_])`, + `${rNumber}*(?:1st|2nd|3rd|(?![123])${rNumber}th)(?=\\b|[A-Z_])`, + `${rNumber}+`, + "\\p{Emoji_Presentation}", + "\\p{Extended_Pictographic}" +].join("|"), "gu"); +/** +* Splits `string` into an array of its words. +* +* @param str - The string or object that is to be split into words. +* @param [pattern] - The pattern to match words. +* @returns Returns the words of `string`. +* +* @example +* const wordsArray1 = words('fred, barney, & pebbles'); +* // => ['fred', 'barney', 'pebbles'] +*/ +function words(str, pattern = rUnicodeWord, guard) { + const input = toString(str); + if (guard) pattern = rUnicodeWord; + if (typeof pattern === "number") pattern = pattern.toString(); + return Array.from(input.match(pattern) ?? []).filter((x) => x !== ""); +} +//#endregion +export { words }; diff --git a/node_modules/es-toolkit/dist/compat/toolkit.d.mts b/node_modules/es-toolkit/dist/compat/toolkit.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..73aefe83285610fda07bb05f1704d62854c7eef1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/toolkit.d.mts @@ -0,0 +1,9 @@ +import { compat_d_exports } from "./compat.mjs"; + +//#region src/compat/toolkit.d.ts +type ToolkitFn = (value: any) => any; +type Compat = typeof compat_d_exports; +interface Toolkit extends ToolkitFn, Compat {} +declare const toolkit: Toolkit; +//#endregion +export { Toolkit, toolkit }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/toolkit.d.ts b/node_modules/es-toolkit/dist/compat/toolkit.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..78a21c0543c9a1364e42133908dcac95679ee596 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/toolkit.d.ts @@ -0,0 +1,9 @@ +import { compat_d_exports } from "./compat.js"; + +//#region src/compat/toolkit.d.ts +type ToolkitFn = (value: any) => any; +type Compat = typeof compat_d_exports; +interface Toolkit extends ToolkitFn, Compat {} +declare const toolkit: Toolkit; +//#endregion +export { Toolkit, toolkit }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/toolkit.js b/node_modules/es-toolkit/dist/compat/toolkit.js new file mode 100644 index 0000000000000000000000000000000000000000..f7e1e4a1a3885595893e14e4e0b8df5b644a5dad --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/toolkit.js @@ -0,0 +1,10 @@ +const require_compat = require("./compat.js"); +//#region src/compat/toolkit.ts +const toolkit = ((value) => { + return value; +}); +Object.assign(toolkit, require_compat.compat_exports); +toolkit.partial.placeholder = toolkit; +toolkit.partialRight.placeholder = toolkit; +//#endregion +exports.toolkit = toolkit; diff --git a/node_modules/es-toolkit/dist/compat/toolkit.mjs b/node_modules/es-toolkit/dist/compat/toolkit.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a31bbdd2da5f6a39e305c3f114808d760294d233 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/toolkit.mjs @@ -0,0 +1,10 @@ +import { compat_exports } from "./compat.mjs"; +//#region src/compat/toolkit.ts +const toolkit = ((value) => { + return value; +}); +Object.assign(toolkit, compat_exports); +toolkit.partial.placeholder = toolkit; +toolkit.partialRight.placeholder = toolkit; +//#endregion +export { toolkit }; diff --git a/node_modules/es-toolkit/dist/compat/util/bindAll.d.mts b/node_modules/es-toolkit/dist/compat/util/bindAll.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..89f21786a93729aec2e35651567feb21a371e6d0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/bindAll.d.mts @@ -0,0 +1,32 @@ +import { Many } from "../_internal/Many.mjs"; + +//#region src/compat/util/bindAll.d.ts +/** + * Binds methods of an object to the object itself, overwriting the existing method. + * Method names may be specified as individual arguments or as arrays of method names. + * + * @template T - The type of the object. + * @param object - The object to bind methods to. + * @param [methodNames] - The method names to bind, specified individually or in arrays. + * @returns Returns the object. + * + * @example + * const view = { + * 'label': 'docs', + * 'click': function() { + * console.log('clicked ' + this.label); + * } + * }; + * + * bindAll(view, ['click']); + * jQuery(element).on('click', view.click); + * // => Logs 'clicked docs' when clicked. + * + * @example + * // Using individual method names + * bindAll(view, 'click'); + * // => Same as above + */ +declare function bindAll(object: T, ...methodNames: Array>): T; +//#endregion +export { bindAll }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/bindAll.d.ts b/node_modules/es-toolkit/dist/compat/util/bindAll.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bbb42aa43611c0153ecf5f2d4997832a0860af63 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/bindAll.d.ts @@ -0,0 +1,32 @@ +import { Many } from "../_internal/Many.js"; + +//#region src/compat/util/bindAll.d.ts +/** + * Binds methods of an object to the object itself, overwriting the existing method. + * Method names may be specified as individual arguments or as arrays of method names. + * + * @template T - The type of the object. + * @param object - The object to bind methods to. + * @param [methodNames] - The method names to bind, specified individually or in arrays. + * @returns Returns the object. + * + * @example + * const view = { + * 'label': 'docs', + * 'click': function() { + * console.log('clicked ' + this.label); + * } + * }; + * + * bindAll(view, ['click']); + * jQuery(element).on('click', view.click); + * // => Logs 'clicked docs' when clicked. + * + * @example + * // Using individual method names + * bindAll(view, 'click'); + * // => Same as above + */ +declare function bindAll(object: T, ...methodNames: Array>): T; +//#endregion +export { bindAll }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/bindAll.js b/node_modules/es-toolkit/dist/compat/util/bindAll.js new file mode 100644 index 0000000000000000000000000000000000000000..bba7b465951db4183c5c4fabc402db499ca36a84 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/bindAll.js @@ -0,0 +1,53 @@ +const require_isArray = require("../predicate/isArray.js"); +const require_isFunction = require("../../predicate/isFunction.js"); +const require_toString = require("./toString.js"); +const require_isObject = require("../predicate/isObject.js"); +//#region src/compat/util/bindAll.ts +/** +* Binds methods of an object to the object itself, overwriting the existing method. +* Method names may be specified as individual arguments or as arrays of method names. +* +* @template T - The type of the object. +* @param object - The object to bind methods to. +* @param [methodNames] - The method names to bind, specified individually or in arrays. +* @returns Returns the object. +* +* @example +* const view = { +* 'label': 'docs', +* 'click': function() { +* console.log('clicked ' + this.label); +* } +* }; +* +* bindAll(view, ['click']); +* jQuery(element).on('click', view.click); +* // => Logs 'clicked docs' when clicked. +* +* @example +* // Using individual method names +* bindAll(view, 'click'); +* // => Same as above +*/ +function bindAll(object, ...methodNames) { + if (object == null) return object; + if (!require_isObject.isObject(object)) return object; + if (require_isArray.isArray(object) && methodNames.length === 0) return object; + const methods = []; + for (let i = 0; i < methodNames.length; i++) { + const name = methodNames[i]; + if (require_isArray.isArray(name)) methods.push(...name); + else if (name && typeof name === "object" && "length" in name) methods.push(...Array.from(name)); + else methods.push(name); + } + if (methods.length === 0) return object; + for (let i = 0; i < methods.length; i++) { + const key = methods[i]; + const stringKey = require_toString.toString(key); + const func = object[stringKey]; + if (require_isFunction.isFunction(func)) object[stringKey] = func.bind(object); + } + return object; +} +//#endregion +exports.bindAll = bindAll; diff --git a/node_modules/es-toolkit/dist/compat/util/bindAll.mjs b/node_modules/es-toolkit/dist/compat/util/bindAll.mjs new file mode 100644 index 0000000000000000000000000000000000000000..27af47e65e2ec087d40ffe669c64fb08bdb8229a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/bindAll.mjs @@ -0,0 +1,53 @@ +import { isArray } from "../predicate/isArray.mjs"; +import { isFunction } from "../../predicate/isFunction.mjs"; +import { toString } from "./toString.mjs"; +import { isObject } from "../predicate/isObject.mjs"; +//#region src/compat/util/bindAll.ts +/** +* Binds methods of an object to the object itself, overwriting the existing method. +* Method names may be specified as individual arguments or as arrays of method names. +* +* @template T - The type of the object. +* @param object - The object to bind methods to. +* @param [methodNames] - The method names to bind, specified individually or in arrays. +* @returns Returns the object. +* +* @example +* const view = { +* 'label': 'docs', +* 'click': function() { +* console.log('clicked ' + this.label); +* } +* }; +* +* bindAll(view, ['click']); +* jQuery(element).on('click', view.click); +* // => Logs 'clicked docs' when clicked. +* +* @example +* // Using individual method names +* bindAll(view, 'click'); +* // => Same as above +*/ +function bindAll(object, ...methodNames) { + if (object == null) return object; + if (!isObject(object)) return object; + if (isArray(object) && methodNames.length === 0) return object; + const methods = []; + for (let i = 0; i < methodNames.length; i++) { + const name = methodNames[i]; + if (isArray(name)) methods.push(...name); + else if (name && typeof name === "object" && "length" in name) methods.push(...Array.from(name)); + else methods.push(name); + } + if (methods.length === 0) return object; + for (let i = 0; i < methods.length; i++) { + const key = methods[i]; + const stringKey = toString(key); + const func = object[stringKey]; + if (isFunction(func)) object[stringKey] = func.bind(object); + } + return object; +} +//#endregion +export { bindAll }; diff --git a/node_modules/es-toolkit/dist/compat/util/cond.d.mts b/node_modules/es-toolkit/dist/compat/util/cond.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ad06bf530048f71ae8e51b147e55f1a49e426abe --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/cond.d.mts @@ -0,0 +1,59 @@ +//#region src/compat/util/cond.d.ts +/** + * Creates a function that checks conditions one by one and runs the matching function. + * + * Each pair consists of a condition (predicate) and a function to run. + * The function goes through each condition in order until it finds one that's true. + * When it finds a true condition, it runs the corresponding function and returns its result. + * If none of the conditions are true, it returns undefined. + * + * @param pairs - Array of pairs. Each pair consists of a predicate function and a function to run. + * @returns A new composite function that checks conditions and runs the matching function. + * @example + * + * const func = cond([ + * [matches({ a: 1 }), constant('matches A')], + * [conforms({ b: isNumber }), constant('matches B')], + * [stubTrue, constant('no match')] + * ]); + * + * func({ a: 1, b: 2 }); + * // => 'matches A' + * + * func({ a: 0, b: 1 }); + * // => 'matches B' + * + * func({ a: '1', b: '2' }); + * // => 'no match' + */ +declare function cond(pairs: Array<[truthy: () => boolean, falsey: () => R]>): () => R; +/** + * Creates a function that checks conditions one by one and runs the matching function. + * + * Each pair consists of a condition (predicate) and a function to run. + * The function goes through each condition in order until it finds one that's true. + * When it finds a true condition, it runs the corresponding function and returns its result. + * If none of the conditions are true, it returns undefined. + * + * @param pairs - Array of pairs. Each pair consists of a predicate function and a function to run. + * @returns A new composite function that checks conditions and runs the matching function. + * @example + * + * const func = cond([ + * [matches({ a: 1 }), constant('matches A')], + * [conforms({ b: isNumber }), constant('matches B')], + * [stubTrue, constant('no match')] + * ]); + * + * func({ a: 1, b: 2 }); + * // => 'matches A' + * + * func({ a: 0, b: 1 }); + * // => 'matches B' + * + * func({ a: '1', b: '2' }); + * // => 'no match' + */ +declare function cond(pairs: Array<[truthy: (val: T) => boolean, falsey: (val: T) => R]>): (val: T) => R; +//#endregion +export { cond }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/cond.d.ts b/node_modules/es-toolkit/dist/compat/util/cond.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad06bf530048f71ae8e51b147e55f1a49e426abe --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/cond.d.ts @@ -0,0 +1,59 @@ +//#region src/compat/util/cond.d.ts +/** + * Creates a function that checks conditions one by one and runs the matching function. + * + * Each pair consists of a condition (predicate) and a function to run. + * The function goes through each condition in order until it finds one that's true. + * When it finds a true condition, it runs the corresponding function and returns its result. + * If none of the conditions are true, it returns undefined. + * + * @param pairs - Array of pairs. Each pair consists of a predicate function and a function to run. + * @returns A new composite function that checks conditions and runs the matching function. + * @example + * + * const func = cond([ + * [matches({ a: 1 }), constant('matches A')], + * [conforms({ b: isNumber }), constant('matches B')], + * [stubTrue, constant('no match')] + * ]); + * + * func({ a: 1, b: 2 }); + * // => 'matches A' + * + * func({ a: 0, b: 1 }); + * // => 'matches B' + * + * func({ a: '1', b: '2' }); + * // => 'no match' + */ +declare function cond(pairs: Array<[truthy: () => boolean, falsey: () => R]>): () => R; +/** + * Creates a function that checks conditions one by one and runs the matching function. + * + * Each pair consists of a condition (predicate) and a function to run. + * The function goes through each condition in order until it finds one that's true. + * When it finds a true condition, it runs the corresponding function and returns its result. + * If none of the conditions are true, it returns undefined. + * + * @param pairs - Array of pairs. Each pair consists of a predicate function and a function to run. + * @returns A new composite function that checks conditions and runs the matching function. + * @example + * + * const func = cond([ + * [matches({ a: 1 }), constant('matches A')], + * [conforms({ b: isNumber }), constant('matches B')], + * [stubTrue, constant('no match')] + * ]); + * + * func({ a: 1, b: 2 }); + * // => 'matches A' + * + * func({ a: 0, b: 1 }); + * // => 'matches B' + * + * func({ a: '1', b: '2' }); + * // => 'no match' + */ +declare function cond(pairs: Array<[truthy: (val: T) => boolean, falsey: (val: T) => R]>): (val: T) => R; +//#endregion +export { cond }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/cond.js b/node_modules/es-toolkit/dist/compat/util/cond.js new file mode 100644 index 0000000000000000000000000000000000000000..f183814d92c3dfa76bdeccd3189b4e4359f30a72 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/cond.js @@ -0,0 +1,22 @@ +const require_isFunction = require("../../predicate/isFunction.js"); +const require_iteratee = require("./iteratee.js"); +//#region src/compat/util/cond.ts +function cond(pairs) { + const length = pairs.length; + const processedPairs = pairs.map((pair) => { + const predicate = pair[0]; + const func = pair[1]; + if (!require_isFunction.isFunction(func)) throw new TypeError("Expected a function"); + return [require_iteratee.iteratee(predicate), func]; + }); + return function(...args) { + for (let i = 0; i < length; i++) { + const pair = processedPairs[i]; + const predicate = pair[0]; + const func = pair[1]; + if (predicate.apply(this, args)) return func.apply(this, args); + } + }; +} +//#endregion +exports.cond = cond; diff --git a/node_modules/es-toolkit/dist/compat/util/cond.mjs b/node_modules/es-toolkit/dist/compat/util/cond.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b82100d6ed5db91aae9b222b151a9769ab2fbb03 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/cond.mjs @@ -0,0 +1,22 @@ +import { isFunction } from "../../predicate/isFunction.mjs"; +import { iteratee } from "./iteratee.mjs"; +//#region src/compat/util/cond.ts +function cond(pairs) { + const length = pairs.length; + const processedPairs = pairs.map((pair) => { + const predicate = pair[0]; + const func = pair[1]; + if (!isFunction(func)) throw new TypeError("Expected a function"); + return [iteratee(predicate), func]; + }); + return function(...args) { + for (let i = 0; i < length; i++) { + const pair = processedPairs[i]; + const predicate = pair[0]; + const func = pair[1]; + if (predicate.apply(this, args)) return func.apply(this, args); + } + }; +} +//#endregion +export { cond }; diff --git a/node_modules/es-toolkit/dist/compat/util/constant.d.mts b/node_modules/es-toolkit/dist/compat/util/constant.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8db66d7ce30742763b8c943b37dd5348ca2067b6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/constant.d.mts @@ -0,0 +1,11 @@ +//#region src/compat/util/constant.d.ts +/** + * Creates a new function that always returns `value`. + * + * @template T - The type of the value to return. + * @param value - The value to return from the new function. + * @returns Returns the new constant function. + */ +declare function constant(value: T): () => T; +//#endregion +export { constant }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/constant.d.ts b/node_modules/es-toolkit/dist/compat/util/constant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8db66d7ce30742763b8c943b37dd5348ca2067b6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/constant.d.ts @@ -0,0 +1,11 @@ +//#region src/compat/util/constant.d.ts +/** + * Creates a new function that always returns `value`. + * + * @template T - The type of the value to return. + * @param value - The value to return from the new function. + * @returns Returns the new constant function. + */ +declare function constant(value: T): () => T; +//#endregion +export { constant }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/constant.js b/node_modules/es-toolkit/dist/compat/util/constant.js new file mode 100644 index 0000000000000000000000000000000000000000..47e78ceb3dc78b3d49b6524c25d77653c945194e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/constant.js @@ -0,0 +1,20 @@ +//#region src/compat/util/constant.ts +/** +* Creates a new function that always returns `value`. +* +* @template T - The type of the value to return. +* @param value - The value to return from the new function. +* @returns Returns the new constant function. +* +* @example +* const object = { a: 1 }; +* const returnsObject = constant(object); +* +* returnsObject(); // => { a: 1 } +* returnsObject() === object; // => true +*/ +function constant(value) { + return () => value; +} +//#endregion +exports.constant = constant; diff --git a/node_modules/es-toolkit/dist/compat/util/constant.mjs b/node_modules/es-toolkit/dist/compat/util/constant.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fe4492746959da5681c010d91768433a56115cdb --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/constant.mjs @@ -0,0 +1,20 @@ +//#region src/compat/util/constant.ts +/** +* Creates a new function that always returns `value`. +* +* @template T - The type of the value to return. +* @param value - The value to return from the new function. +* @returns Returns the new constant function. +* +* @example +* const object = { a: 1 }; +* const returnsObject = constant(object); +* +* returnsObject(); // => { a: 1 } +* returnsObject() === object; // => true +*/ +function constant(value) { + return () => value; +} +//#endregion +export { constant }; diff --git a/node_modules/es-toolkit/dist/compat/util/defaultTo.d.mts b/node_modules/es-toolkit/dist/compat/util/defaultTo.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..5a1c0efea08f7c48e9c09c93181c8e5d0998eae9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/defaultTo.d.mts @@ -0,0 +1,22 @@ +//#region src/compat/util/defaultTo.d.ts +/** + * Returns the default value for `null`, `undefined`, and `NaN`. + * + * @template T - The type of the value parameter + * @param value - The value to check. + * @param defaultValue - The default value to return if the first value is null, undefined, or NaN. + * @returns Returns either the first value or the default value. + */ +declare function defaultTo(value: T | null | undefined, defaultValue: T): T; +/** + * Returns the default value for `null`, `undefined`, and `NaN`. + * + * @template T - The type of the value parameter + * @template D - The type of the defaultValue parameter + * @param value - The value to check. + * @param defaultValue - The default value to return if the first value is null, undefined, or NaN. + * @returns Returns either the first value or the default value. + */ +declare function defaultTo(value: T | null | undefined, defaultValue: D): T | D; +//#endregion +export { defaultTo }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/defaultTo.d.ts b/node_modules/es-toolkit/dist/compat/util/defaultTo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a1c0efea08f7c48e9c09c93181c8e5d0998eae9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/defaultTo.d.ts @@ -0,0 +1,22 @@ +//#region src/compat/util/defaultTo.d.ts +/** + * Returns the default value for `null`, `undefined`, and `NaN`. + * + * @template T - The type of the value parameter + * @param value - The value to check. + * @param defaultValue - The default value to return if the first value is null, undefined, or NaN. + * @returns Returns either the first value or the default value. + */ +declare function defaultTo(value: T | null | undefined, defaultValue: T): T; +/** + * Returns the default value for `null`, `undefined`, and `NaN`. + * + * @template T - The type of the value parameter + * @template D - The type of the defaultValue parameter + * @param value - The value to check. + * @param defaultValue - The default value to return if the first value is null, undefined, or NaN. + * @returns Returns either the first value or the default value. + */ +declare function defaultTo(value: T | null | undefined, defaultValue: D): T | D; +//#endregion +export { defaultTo }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/defaultTo.js b/node_modules/es-toolkit/dist/compat/util/defaultTo.js new file mode 100644 index 0000000000000000000000000000000000000000..e064b8c855b7e9eb4f6db9b612897fb572b0447f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/defaultTo.js @@ -0,0 +1,23 @@ +//#region src/compat/util/defaultTo.ts +/** +* Returns the default value for `null`, `undefined`, and `NaN`. +* +* @template T - The type of the value parameter +* @template D - The type of the defaultValue parameter +* @param value - The value to check. +* @param defaultValue - The default value to return if the first value is null, undefined, or NaN. +* @returns Returns either the first value or the default value. +* +* @example +* defaultTo(null, 'default') // returns 'default' +* defaultTo(undefined, 42) // returns 42 +* defaultTo(NaN, 0) // returns 0 +* defaultTo('actual', 'default') // returns 'actual' +* defaultTo(123, 0) // returns 123 +*/ +function defaultTo(value, defaultValue) { + if (value == null || Number.isNaN(value)) return defaultValue; + return value; +} +//#endregion +exports.defaultTo = defaultTo; diff --git a/node_modules/es-toolkit/dist/compat/util/defaultTo.mjs b/node_modules/es-toolkit/dist/compat/util/defaultTo.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5b52e18eb07732a00fc8b1bd85d8b2de0db82cac --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/defaultTo.mjs @@ -0,0 +1,23 @@ +//#region src/compat/util/defaultTo.ts +/** +* Returns the default value for `null`, `undefined`, and `NaN`. +* +* @template T - The type of the value parameter +* @template D - The type of the defaultValue parameter +* @param value - The value to check. +* @param defaultValue - The default value to return if the first value is null, undefined, or NaN. +* @returns Returns either the first value or the default value. +* +* @example +* defaultTo(null, 'default') // returns 'default' +* defaultTo(undefined, 42) // returns 42 +* defaultTo(NaN, 0) // returns 0 +* defaultTo('actual', 'default') // returns 'actual' +* defaultTo(123, 0) // returns 123 +*/ +function defaultTo(value, defaultValue) { + if (value == null || Number.isNaN(value)) return defaultValue; + return value; +} +//#endregion +export { defaultTo }; diff --git a/node_modules/es-toolkit/dist/compat/util/eq.d.mts b/node_modules/es-toolkit/dist/compat/util/eq.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2378e40a1e78771d0a5f613b97eb3092f7a45f3b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/eq.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/util/eq.d.ts +/** + * Performs a `SameValueZero` comparison between two values to determine if they are equivalent. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if the values are equivalent, else `false`. + * + * @example + * eq(1, 1); // true + * eq(0, -0); // true + * eq(NaN, NaN); // true + * eq('a', Object('a')); // false + */ +declare function eq(value: any, other: any): boolean; +//#endregion +export { eq }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/eq.d.ts b/node_modules/es-toolkit/dist/compat/util/eq.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2378e40a1e78771d0a5f613b97eb3092f7a45f3b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/eq.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/util/eq.d.ts +/** + * Performs a `SameValueZero` comparison between two values to determine if they are equivalent. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if the values are equivalent, else `false`. + * + * @example + * eq(1, 1); // true + * eq(0, -0); // true + * eq(NaN, NaN); // true + * eq('a', Object('a')); // false + */ +declare function eq(value: any, other: any): boolean; +//#endregion +export { eq }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/eq.js b/node_modules/es-toolkit/dist/compat/util/eq.js new file mode 100644 index 0000000000000000000000000000000000000000..9d0d8ecede5c1c4686a553e102993fa3cd68c6e2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/eq.js @@ -0,0 +1,19 @@ +//#region src/compat/util/eq.ts +/** +* Performs a `SameValueZero` comparison between two values to determine if they are equivalent. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if the values are equivalent, else `false`. +* +* @example +* eq(1, 1); // true +* eq(0, -0); // true +* eq(NaN, NaN); // true +* eq('a', Object('a')); // false +*/ +function eq(value, other) { + return value === other || Number.isNaN(value) && Number.isNaN(other); +} +//#endregion +exports.eq = eq; diff --git a/node_modules/es-toolkit/dist/compat/util/eq.mjs b/node_modules/es-toolkit/dist/compat/util/eq.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d92b870e41e3723bd1c0ed8c69ec60109fcbd8f5 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/eq.mjs @@ -0,0 +1,19 @@ +//#region src/compat/util/eq.ts +/** +* Performs a `SameValueZero` comparison between two values to determine if they are equivalent. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if the values are equivalent, else `false`. +* +* @example +* eq(1, 1); // true +* eq(0, -0); // true +* eq(NaN, NaN); // true +* eq('a', Object('a')); // false +*/ +function eq(value, other) { + return value === other || Number.isNaN(value) && Number.isNaN(other); +} +//#endregion +export { eq }; diff --git a/node_modules/es-toolkit/dist/compat/util/gt.d.mts b/node_modules/es-toolkit/dist/compat/util/gt.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2803c4aaaf747f6cdc213fea3b93727e5d2971df --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/gt.d.mts @@ -0,0 +1,16 @@ +//#region src/compat/util/gt.d.ts +/** + * Checks if value is greater than other. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if value is greater than other, else `false`. + * + * @example + * gt(3, 1); // true + * gt(3, 3); // false + * gt(1, 3); // false + */ +declare function gt(value: any, other: any): boolean; +//#endregion +export { gt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/gt.d.ts b/node_modules/es-toolkit/dist/compat/util/gt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2803c4aaaf747f6cdc213fea3b93727e5d2971df --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/gt.d.ts @@ -0,0 +1,16 @@ +//#region src/compat/util/gt.d.ts +/** + * Checks if value is greater than other. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if value is greater than other, else `false`. + * + * @example + * gt(3, 1); // true + * gt(3, 3); // false + * gt(1, 3); // false + */ +declare function gt(value: any, other: any): boolean; +//#endregion +export { gt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/gt.js b/node_modules/es-toolkit/dist/compat/util/gt.js new file mode 100644 index 0000000000000000000000000000000000000000..8a73b443ef12c7ef3a20ef3971be85532d1203d9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/gt.js @@ -0,0 +1,20 @@ +const require_toNumber = require("./toNumber.js"); +//#region src/compat/util/gt.ts +/** +* Checks if value is greater than other. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if value is greater than other, else `false`. +* +* @example +* gt(3, 1); // true +* gt(3, 3); // false +* gt(1, 3); // false +*/ +function gt(value, other) { + if (typeof value === "string" && typeof other === "string") return value > other; + return require_toNumber.toNumber(value) > require_toNumber.toNumber(other); +} +//#endregion +exports.gt = gt; diff --git a/node_modules/es-toolkit/dist/compat/util/gt.mjs b/node_modules/es-toolkit/dist/compat/util/gt.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0b94222959ffe8d036745dcf9223ba937d88be21 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/gt.mjs @@ -0,0 +1,20 @@ +import { toNumber } from "./toNumber.mjs"; +//#region src/compat/util/gt.ts +/** +* Checks if value is greater than other. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if value is greater than other, else `false`. +* +* @example +* gt(3, 1); // true +* gt(3, 3); // false +* gt(1, 3); // false +*/ +function gt(value, other) { + if (typeof value === "string" && typeof other === "string") return value > other; + return toNumber(value) > toNumber(other); +} +//#endregion +export { gt }; diff --git a/node_modules/es-toolkit/dist/compat/util/gte.d.mts b/node_modules/es-toolkit/dist/compat/util/gte.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..dcffd132f511ed3d7e721ac4a803604103d755ef --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/gte.d.mts @@ -0,0 +1,16 @@ +//#region src/compat/util/gte.d.ts +/** + * Checks if value is greater than or equal to other. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if value is greater than or equal to other, else `false`. + * + * @example + * gte(3, 1); // => true + * gte(3, 3); // => true + * gte(1, 3); // => false + */ +declare function gte(value: any, other: any): boolean; +//#endregion +export { gte }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/gte.d.ts b/node_modules/es-toolkit/dist/compat/util/gte.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dcffd132f511ed3d7e721ac4a803604103d755ef --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/gte.d.ts @@ -0,0 +1,16 @@ +//#region src/compat/util/gte.d.ts +/** + * Checks if value is greater than or equal to other. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if value is greater than or equal to other, else `false`. + * + * @example + * gte(3, 1); // => true + * gte(3, 3); // => true + * gte(1, 3); // => false + */ +declare function gte(value: any, other: any): boolean; +//#endregion +export { gte }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/gte.js b/node_modules/es-toolkit/dist/compat/util/gte.js new file mode 100644 index 0000000000000000000000000000000000000000..917ef6989d30a2ef5d685c5289e147e94b7e5b64 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/gte.js @@ -0,0 +1,20 @@ +const require_toNumber = require("./toNumber.js"); +//#region src/compat/util/gte.ts +/** +* Checks if value is greater than or equal to other. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if value is greater than or equal to other, else `false`. +* +* @example +* gte(3, 1); // => true +* gte(3, 3); // => true +* gte(1, 3); // => false +*/ +function gte(value, other) { + if (typeof value === "string" && typeof other === "string") return value >= other; + return require_toNumber.toNumber(value) >= require_toNumber.toNumber(other); +} +//#endregion +exports.gte = gte; diff --git a/node_modules/es-toolkit/dist/compat/util/gte.mjs b/node_modules/es-toolkit/dist/compat/util/gte.mjs new file mode 100644 index 0000000000000000000000000000000000000000..54355ddd6d483922665d3b1ab893a35c36919c2c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/gte.mjs @@ -0,0 +1,20 @@ +import { toNumber } from "./toNumber.mjs"; +//#region src/compat/util/gte.ts +/** +* Checks if value is greater than or equal to other. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if value is greater than or equal to other, else `false`. +* +* @example +* gte(3, 1); // => true +* gte(3, 3); // => true +* gte(1, 3); // => false +*/ +function gte(value, other) { + if (typeof value === "string" && typeof other === "string") return value >= other; + return toNumber(value) >= toNumber(other); +} +//#endregion +export { gte }; diff --git a/node_modules/es-toolkit/dist/compat/util/invoke.d.mts b/node_modules/es-toolkit/dist/compat/util/invoke.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b1563539ca4ef8bda05e50757f751c67218f25e0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/invoke.d.mts @@ -0,0 +1,24 @@ +//#region src/compat/util/invoke.d.ts +/** + * Invokes the method at `path` of `object` with the given arguments. + * + * @param object - The object to query. + * @param path - The path of the method to invoke. + * @param args - The arguments to invoke the method with. + * @returns Returns the result of the invoked method. + * + * @example + * const object = { + * a: { + * b: function (x, y) { + * return x + y; + * } + * } + * }; + * + * invoke(object, 'a.b', [1, 2]); // => 3 + * invoke(object, ['a', 'b'], [1, 2]); // => 3 + */ +declare function invoke(object: any, path: PropertyKey | readonly PropertyKey[], ...args: any[]): any; +//#endregion +export { invoke }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/invoke.d.ts b/node_modules/es-toolkit/dist/compat/util/invoke.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b1563539ca4ef8bda05e50757f751c67218f25e0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/invoke.d.ts @@ -0,0 +1,24 @@ +//#region src/compat/util/invoke.d.ts +/** + * Invokes the method at `path` of `object` with the given arguments. + * + * @param object - The object to query. + * @param path - The path of the method to invoke. + * @param args - The arguments to invoke the method with. + * @returns Returns the result of the invoked method. + * + * @example + * const object = { + * a: { + * b: function (x, y) { + * return x + y; + * } + * } + * }; + * + * invoke(object, 'a.b', [1, 2]); // => 3 + * invoke(object, ['a', 'b'], [1, 2]); // => 3 + */ +declare function invoke(object: any, path: PropertyKey | readonly PropertyKey[], ...args: any[]): any; +//#endregion +export { invoke }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/invoke.js b/node_modules/es-toolkit/dist/compat/util/invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..7799556d09d708b93a098eea0972d5f9765d45e1 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/invoke.js @@ -0,0 +1,49 @@ +const require_toKey = require("../_internal/toKey.js"); +const require_toPath = require("./toPath.js"); +const require_get = require("../object/get.js"); +const require_last = require("../array/last.js"); +//#region src/compat/util/invoke.ts +/** +* Invokes the method at `path` of `object` with the given arguments. +* +* @param object - The object to query. +* @param path - The path of the method to invoke. +* @param args - The arguments to invoke the method with. +* @returns Returns the result of the invoked method. +* +* @example +* const object = { +* a: { +* b: function (x, y) { +* return x + y; +* } +* } +* }; +* +* invoke(object, 'a.b', [1, 2]); // => 3 +* invoke(object, ['a', 'b'], [1, 2]); // => 3 +*/ +function invoke(object, path, ...args) { + args = args.flat(1); + if (object == null) return; + switch (typeof path) { + case "string": + if (typeof object === "object" && Object.hasOwn(object, path)) return invokeImpl(object, [path], args); + return invokeImpl(object, require_toPath.toPath(path), args); + case "number": + case "symbol": return invokeImpl(object, [path], args); + default: if (Array.isArray(path)) return invokeImpl(object, path, args); + else return invokeImpl(object, [path], args); + } +} +function invokeImpl(object, path, args) { + const parent = require_get.get(object, path.slice(0, -1), object); + if (parent == null) return; + let lastKey = require_last.last(path); + const lastValue = lastKey?.valueOf(); + if (typeof lastValue === "number") lastKey = require_toKey.toKey(lastValue); + else lastKey = String(lastKey); + return require_get.get(parent, lastKey)?.apply(parent, args); +} +//#endregion +exports.invoke = invoke; diff --git a/node_modules/es-toolkit/dist/compat/util/invoke.mjs b/node_modules/es-toolkit/dist/compat/util/invoke.mjs new file mode 100644 index 0000000000000000000000000000000000000000..89121f0adae97ffd9884076c4fd9a0c90b1060f9 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/invoke.mjs @@ -0,0 +1,49 @@ +import { toKey } from "../_internal/toKey.mjs"; +import { toPath } from "./toPath.mjs"; +import { get } from "../object/get.mjs"; +import { last } from "../array/last.mjs"; +//#region src/compat/util/invoke.ts +/** +* Invokes the method at `path` of `object` with the given arguments. +* +* @param object - The object to query. +* @param path - The path of the method to invoke. +* @param args - The arguments to invoke the method with. +* @returns Returns the result of the invoked method. +* +* @example +* const object = { +* a: { +* b: function (x, y) { +* return x + y; +* } +* } +* }; +* +* invoke(object, 'a.b', [1, 2]); // => 3 +* invoke(object, ['a', 'b'], [1, 2]); // => 3 +*/ +function invoke(object, path, ...args) { + args = args.flat(1); + if (object == null) return; + switch (typeof path) { + case "string": + if (typeof object === "object" && Object.hasOwn(object, path)) return invokeImpl(object, [path], args); + return invokeImpl(object, toPath(path), args); + case "number": + case "symbol": return invokeImpl(object, [path], args); + default: if (Array.isArray(path)) return invokeImpl(object, path, args); + else return invokeImpl(object, [path], args); + } +} +function invokeImpl(object, path, args) { + const parent = get(object, path.slice(0, -1), object); + if (parent == null) return; + let lastKey = last(path); + const lastValue = lastKey?.valueOf(); + if (typeof lastValue === "number") lastKey = toKey(lastValue); + else lastKey = String(lastKey); + return get(parent, lastKey)?.apply(parent, args); +} +//#endregion +export { invoke }; diff --git a/node_modules/es-toolkit/dist/compat/util/iteratee.d.mts b/node_modules/es-toolkit/dist/compat/util/iteratee.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b039ffd5a733925c403d3e1c9c1d1e9eefc5134f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/iteratee.d.mts @@ -0,0 +1,34 @@ +//#region src/compat/util/iteratee.d.ts +/** + * Returns the provided function as-is when it is a function type. + * + * @template F - The function type + * @param func - The function to return + * @returns Returns the provided function unchanged + * + * @example + * const fn = (x: number) => x * 2; + * const iterateeFn = iteratee(fn); + * iterateeFn(4); // => 8 + */ +declare function iteratee any>(func: F): F; +/** + * Creates an iteratee function based on the provided property key or object. + * If given a property key, returns a function that gets that property from objects. + * If given an object, returns a function that matches objects against the provided one. + * + * @param func - The value to convert to an iteratee + * @returns Returns the iteratee function + * + * @example + * // With property key + * const getLength = iteratee('length'); + * getLength([1,2,3]); // => 3 + * + * // With object + * const matchObj = iteratee({ x: 1, y: 2 }); + * matchObj({ x: 1, y: 2, z: 3 }); // => true + */ +declare function iteratee(func: PropertyKey | object): (...args: any[]) => any; +//#endregion +export { iteratee }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/iteratee.d.ts b/node_modules/es-toolkit/dist/compat/util/iteratee.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b039ffd5a733925c403d3e1c9c1d1e9eefc5134f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/iteratee.d.ts @@ -0,0 +1,34 @@ +//#region src/compat/util/iteratee.d.ts +/** + * Returns the provided function as-is when it is a function type. + * + * @template F - The function type + * @param func - The function to return + * @returns Returns the provided function unchanged + * + * @example + * const fn = (x: number) => x * 2; + * const iterateeFn = iteratee(fn); + * iterateeFn(4); // => 8 + */ +declare function iteratee any>(func: F): F; +/** + * Creates an iteratee function based on the provided property key or object. + * If given a property key, returns a function that gets that property from objects. + * If given an object, returns a function that matches objects against the provided one. + * + * @param func - The value to convert to an iteratee + * @returns Returns the iteratee function + * + * @example + * // With property key + * const getLength = iteratee('length'); + * getLength([1,2,3]); // => 3 + * + * // With object + * const matchObj = iteratee({ x: 1, y: 2 }); + * matchObj({ x: 1, y: 2, z: 3 }); // => true + */ +declare function iteratee(func: PropertyKey | object): (...args: any[]) => any; +//#endregion +export { iteratee }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/iteratee.js b/node_modules/es-toolkit/dist/compat/util/iteratee.js new file mode 100644 index 0000000000000000000000000000000000000000..0ecad873226adf28eedb66743e5e1916fb2f9cdb --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/iteratee.js @@ -0,0 +1,49 @@ +const require_identity = require("../../function/identity.js"); +const require_property = require("../object/property.js"); +const require_matches = require("../predicate/matches.js"); +const require_matchesProperty = require("../predicate/matchesProperty.js"); +//#region src/compat/util/iteratee.ts +/** +* Creates a function that returns a value from an element in a collection. +* +* You can call `iteratee` with the following types of arguments: +* +* - **Function**: Returns the function as-is, which will be called with the element from the collection. +* - **Property name**: Returns the value of the specified property from the element. +* - **Property-value pair**: Returns a boolean indicating whether the element's property matches the given value. +* - **Partial object**: Returns a boolean indicating whether the element matches the properties of the partial object. +* +* If you don't provide any arguments or pass `null`, this function will return a function that simply returns its input unchanged. +* +* @param value - The value to convert to an iteratee. +* @returns Returns the new iteratee function. +* @example +* const func = iteratee(); +* [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [{ a: 1 }, { a: 2 }, { a: 3 }] +* +* const func = iteratee((object) => object.a); +* [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3] +* +* const func = iteratee('a'); +* [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3] +* +* const func = iteratee({ a: 1 }); +* [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 } +* +* const func = iteratee(['a', 1]); +* [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 } +*/ +function iteratee(value) { + if (value == null) return require_identity.identity; + switch (typeof value) { + case "function": return value; + case "object": + if (Array.isArray(value) && value.length === 2) return require_matchesProperty.matchesProperty(value[0], value[1]); + return require_matches.matches(value); + case "string": + case "symbol": + case "number": return require_property.property(value); + } +} +//#endregion +exports.iteratee = iteratee; diff --git a/node_modules/es-toolkit/dist/compat/util/iteratee.mjs b/node_modules/es-toolkit/dist/compat/util/iteratee.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0bff638b513d5a9865a84fa6671b79b38e637401 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/iteratee.mjs @@ -0,0 +1,49 @@ +import { identity } from "../../function/identity.mjs"; +import { property } from "../object/property.mjs"; +import { matches } from "../predicate/matches.mjs"; +import { matchesProperty } from "../predicate/matchesProperty.mjs"; +//#region src/compat/util/iteratee.ts +/** +* Creates a function that returns a value from an element in a collection. +* +* You can call `iteratee` with the following types of arguments: +* +* - **Function**: Returns the function as-is, which will be called with the element from the collection. +* - **Property name**: Returns the value of the specified property from the element. +* - **Property-value pair**: Returns a boolean indicating whether the element's property matches the given value. +* - **Partial object**: Returns a boolean indicating whether the element matches the properties of the partial object. +* +* If you don't provide any arguments or pass `null`, this function will return a function that simply returns its input unchanged. +* +* @param value - The value to convert to an iteratee. +* @returns Returns the new iteratee function. +* @example +* const func = iteratee(); +* [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [{ a: 1 }, { a: 2 }, { a: 3 }] +* +* const func = iteratee((object) => object.a); +* [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3] +* +* const func = iteratee('a'); +* [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3] +* +* const func = iteratee({ a: 1 }); +* [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 } +* +* const func = iteratee(['a', 1]); +* [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 } +*/ +function iteratee(value) { + if (value == null) return identity; + switch (typeof value) { + case "function": return value; + case "object": + if (Array.isArray(value) && value.length === 2) return matchesProperty(value[0], value[1]); + return matches(value); + case "string": + case "symbol": + case "number": return property(value); + } +} +//#endregion +export { iteratee }; diff --git a/node_modules/es-toolkit/dist/compat/util/lt.d.mts b/node_modules/es-toolkit/dist/compat/util/lt.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..5027805bcaafa521046f161a54b082da7d16c0df --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/lt.d.mts @@ -0,0 +1,16 @@ +//#region src/compat/util/lt.d.ts +/** + * Checks if value is less than other. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if value is less than other, else `false`. + * + * @example + * lt(1, 3); // true + * lt(3, 3); // false + * lt(3, 1); // false + */ +declare function lt(value: any, other: any): boolean; +//#endregion +export { lt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/lt.d.ts b/node_modules/es-toolkit/dist/compat/util/lt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5027805bcaafa521046f161a54b082da7d16c0df --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/lt.d.ts @@ -0,0 +1,16 @@ +//#region src/compat/util/lt.d.ts +/** + * Checks if value is less than other. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if value is less than other, else `false`. + * + * @example + * lt(1, 3); // true + * lt(3, 3); // false + * lt(3, 1); // false + */ +declare function lt(value: any, other: any): boolean; +//#endregion +export { lt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/lt.js b/node_modules/es-toolkit/dist/compat/util/lt.js new file mode 100644 index 0000000000000000000000000000000000000000..c7bd7985ad74f5af7e3e0d9ff289bc58a707788a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/lt.js @@ -0,0 +1,20 @@ +const require_toNumber = require("./toNumber.js"); +//#region src/compat/util/lt.ts +/** +* Checks if value is less than other. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if value is less than other, else `false`. +* +* @example +* lt(1, 3); // true +* lt(3, 3); // false +* lt(3, 1); // false +*/ +function lt(value, other) { + if (typeof value === "string" && typeof other === "string") return value < other; + return require_toNumber.toNumber(value) < require_toNumber.toNumber(other); +} +//#endregion +exports.lt = lt; diff --git a/node_modules/es-toolkit/dist/compat/util/lt.mjs b/node_modules/es-toolkit/dist/compat/util/lt.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7bf6839770e680f9a68b0a262b98eb00de96917c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/lt.mjs @@ -0,0 +1,20 @@ +import { toNumber } from "./toNumber.mjs"; +//#region src/compat/util/lt.ts +/** +* Checks if value is less than other. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if value is less than other, else `false`. +* +* @example +* lt(1, 3); // true +* lt(3, 3); // false +* lt(3, 1); // false +*/ +function lt(value, other) { + if (typeof value === "string" && typeof other === "string") return value < other; + return toNumber(value) < toNumber(other); +} +//#endregion +export { lt }; diff --git a/node_modules/es-toolkit/dist/compat/util/lte.d.mts b/node_modules/es-toolkit/dist/compat/util/lte.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bce5d458df14dbf274c4ca6fc3df3ce1e5b91349 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/lte.d.mts @@ -0,0 +1,16 @@ +//#region src/compat/util/lte.d.ts +/** + * Checks if value is less than or equal to other. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if value is less than or equal to other, else `false`. + * + * @example + * lte(1, 3); // => true + * lte(3, 3); // => true + * lte(3, 1); // => false + */ +declare function lte(value: any, other: any): boolean; +//#endregion +export { lte }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/lte.d.ts b/node_modules/es-toolkit/dist/compat/util/lte.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bce5d458df14dbf274c4ca6fc3df3ce1e5b91349 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/lte.d.ts @@ -0,0 +1,16 @@ +//#region src/compat/util/lte.d.ts +/** + * Checks if value is less than or equal to other. + * + * @param value The value to compare. + * @param other The other value to compare. + * @returns Returns `true` if value is less than or equal to other, else `false`. + * + * @example + * lte(1, 3); // => true + * lte(3, 3); // => true + * lte(3, 1); // => false + */ +declare function lte(value: any, other: any): boolean; +//#endregion +export { lte }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/lte.js b/node_modules/es-toolkit/dist/compat/util/lte.js new file mode 100644 index 0000000000000000000000000000000000000000..114ac56ff6f0dd271ef1ed7f5dcf609fa947700c --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/lte.js @@ -0,0 +1,20 @@ +const require_toNumber = require("./toNumber.js"); +//#region src/compat/util/lte.ts +/** +* Checks if value is less than or equal to other. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if value is less than or equal to other, else `false`. +* +* @example +* lte(1, 3); // => true +* lte(3, 3); // => true +* lte(3, 1); // => false +*/ +function lte(value, other) { + if (typeof value === "string" && typeof other === "string") return value <= other; + return require_toNumber.toNumber(value) <= require_toNumber.toNumber(other); +} +//#endregion +exports.lte = lte; diff --git a/node_modules/es-toolkit/dist/compat/util/lte.mjs b/node_modules/es-toolkit/dist/compat/util/lte.mjs new file mode 100644 index 0000000000000000000000000000000000000000..09e870c0f662bb27b7f0d91d2e3b3bf39c2f585d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/lte.mjs @@ -0,0 +1,20 @@ +import { toNumber } from "./toNumber.mjs"; +//#region src/compat/util/lte.ts +/** +* Checks if value is less than or equal to other. +* +* @param value The value to compare. +* @param other The other value to compare. +* @returns Returns `true` if value is less than or equal to other, else `false`. +* +* @example +* lte(1, 3); // => true +* lte(3, 3); // => true +* lte(3, 1); // => false +*/ +function lte(value, other) { + if (typeof value === "string" && typeof other === "string") return value <= other; + return toNumber(value) <= toNumber(other); +} +//#endregion +export { lte }; diff --git a/node_modules/es-toolkit/dist/compat/util/method.d.mts b/node_modules/es-toolkit/dist/compat/util/method.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..76ffc94fefb2a26999d8768d1782b10ddce1db76 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/method.d.mts @@ -0,0 +1,23 @@ +//#region src/compat/util/method.d.ts +/** + * Creates a function that invokes the method at `path` of a given object with the provided arguments. + * + * @param path - The path of the method to invoke. + * @param args - The arguments to invoke the method with. + * @returns Returns a new function that takes an object and invokes the method at `path` with `args`. + * + * @example + * const object = { + * a: { + * b: function (x, y) { + * return x + y; + * } + * } + * }; + * + * const add = method('a.b', 1, 2); + * console.log(add(object)); // => 3 + */ +declare function method(path: PropertyKey | readonly PropertyKey[], ...args: any[]): (object: any) => any; +//#endregion +export { method }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/method.d.ts b/node_modules/es-toolkit/dist/compat/util/method.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..76ffc94fefb2a26999d8768d1782b10ddce1db76 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/method.d.ts @@ -0,0 +1,23 @@ +//#region src/compat/util/method.d.ts +/** + * Creates a function that invokes the method at `path` of a given object with the provided arguments. + * + * @param path - The path of the method to invoke. + * @param args - The arguments to invoke the method with. + * @returns Returns a new function that takes an object and invokes the method at `path` with `args`. + * + * @example + * const object = { + * a: { + * b: function (x, y) { + * return x + y; + * } + * } + * }; + * + * const add = method('a.b', 1, 2); + * console.log(add(object)); // => 3 + */ +declare function method(path: PropertyKey | readonly PropertyKey[], ...args: any[]): (object: any) => any; +//#endregion +export { method }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/method.js b/node_modules/es-toolkit/dist/compat/util/method.js new file mode 100644 index 0000000000000000000000000000000000000000..cf2d6fc3c0d799678937ef08a302af7b850a79ae --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/method.js @@ -0,0 +1,28 @@ +const require_invoke = require("./invoke.js"); +//#region src/compat/util/method.ts +/** +* Creates a function that invokes the method at `path` of a given object with the provided arguments. +* +* @param path - The path of the method to invoke. +* @param args - The arguments to invoke the method with. +* @returns Returns a new function that takes an object and invokes the method at `path` with `args`. +* +* @example +* const object = { +* a: { +* b: function (x, y) { +* return x + y; +* } +* } +* }; +* +* const add = method('a.b', 1, 2); +* console.log(add(object)); // => 3 +*/ +function method(path, ...args) { + return function(object) { + return require_invoke.invoke(object, path, args); + }; +} +//#endregion +exports.method = method; diff --git a/node_modules/es-toolkit/dist/compat/util/method.mjs b/node_modules/es-toolkit/dist/compat/util/method.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2bad6ac7138b1ec837af7a41eeffae8285ddb145 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/method.mjs @@ -0,0 +1,28 @@ +import { invoke } from "./invoke.mjs"; +//#region src/compat/util/method.ts +/** +* Creates a function that invokes the method at `path` of a given object with the provided arguments. +* +* @param path - The path of the method to invoke. +* @param args - The arguments to invoke the method with. +* @returns Returns a new function that takes an object and invokes the method at `path` with `args`. +* +* @example +* const object = { +* a: { +* b: function (x, y) { +* return x + y; +* } +* } +* }; +* +* const add = method('a.b', 1, 2); +* console.log(add(object)); // => 3 +*/ +function method(path, ...args) { + return function(object) { + return invoke(object, path, args); + }; +} +//#endregion +export { method }; diff --git a/node_modules/es-toolkit/dist/compat/util/methodOf.d.mts b/node_modules/es-toolkit/dist/compat/util/methodOf.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0bb78608ced211198eda849664ddb2325c92f3f8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/methodOf.d.mts @@ -0,0 +1,23 @@ +//#region src/compat/util/methodOf.d.ts +/** + * Creates a function that invokes the method at a given path of `object` with the provided arguments. + * + * @param object - The object to query. + * @param args - The arguments to invoke the method with. + * @returns Returns a new function that takes a path and invokes the method at `path` with `args`. + * + * @example + * const object = { + * a: { + * b: function (x, y) { + * return x + y; + * } + * } + * }; + * + * const add = methodOf(object, 1, 2); + * console.log(add('a.b')); // => 3 + */ +declare function methodOf(object: object, ...args: any[]): (path: PropertyKey | readonly PropertyKey[]) => any; +//#endregion +export { methodOf }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/methodOf.d.ts b/node_modules/es-toolkit/dist/compat/util/methodOf.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0bb78608ced211198eda849664ddb2325c92f3f8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/methodOf.d.ts @@ -0,0 +1,23 @@ +//#region src/compat/util/methodOf.d.ts +/** + * Creates a function that invokes the method at a given path of `object` with the provided arguments. + * + * @param object - The object to query. + * @param args - The arguments to invoke the method with. + * @returns Returns a new function that takes a path and invokes the method at `path` with `args`. + * + * @example + * const object = { + * a: { + * b: function (x, y) { + * return x + y; + * } + * } + * }; + * + * const add = methodOf(object, 1, 2); + * console.log(add('a.b')); // => 3 + */ +declare function methodOf(object: object, ...args: any[]): (path: PropertyKey | readonly PropertyKey[]) => any; +//#endregion +export { methodOf }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/methodOf.js b/node_modules/es-toolkit/dist/compat/util/methodOf.js new file mode 100644 index 0000000000000000000000000000000000000000..3a0faa63dea501522dcf3f9781f4d74fbe42b4c3 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/methodOf.js @@ -0,0 +1,28 @@ +const require_invoke = require("./invoke.js"); +//#region src/compat/util/methodOf.ts +/** +* Creates a function that invokes the method at a given path of `object` with the provided arguments. +* +* @param object - The object to query. +* @param args - The arguments to invoke the method with. +* @returns Returns a new function that takes a path and invokes the method at `path` with `args`. +* +* @example +* const object = { +* a: { +* b: function (x, y) { +* return x + y; +* } +* } +* }; +* +* const add = methodOf(object, 1, 2); +* console.log(add('a.b')); // => 3 +*/ +function methodOf(object, ...args) { + return function(path) { + return require_invoke.invoke(object, path, args); + }; +} +//#endregion +exports.methodOf = methodOf; diff --git a/node_modules/es-toolkit/dist/compat/util/methodOf.mjs b/node_modules/es-toolkit/dist/compat/util/methodOf.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ff40412ba75a19d3d95a99c0254b065307e33e6b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/methodOf.mjs @@ -0,0 +1,28 @@ +import { invoke } from "./invoke.mjs"; +//#region src/compat/util/methodOf.ts +/** +* Creates a function that invokes the method at a given path of `object` with the provided arguments. +* +* @param object - The object to query. +* @param args - The arguments to invoke the method with. +* @returns Returns a new function that takes a path and invokes the method at `path` with `args`. +* +* @example +* const object = { +* a: { +* b: function (x, y) { +* return x + y; +* } +* } +* }; +* +* const add = methodOf(object, 1, 2); +* console.log(add('a.b')); // => 3 +*/ +function methodOf(object, ...args) { + return function(path) { + return invoke(object, path, args); + }; +} +//#endregion +export { methodOf }; diff --git a/node_modules/es-toolkit/dist/compat/util/now.d.mts b/node_modules/es-toolkit/dist/compat/util/now.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..56dc733e0113e4f3029f7078886eed508dc0bb90 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/now.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/util/now.d.ts +/** + * Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. + * + * @returns The current time in milliseconds. + * + * @example + * const currentTime = now(); + * console.log(currentTime); // Outputs the current time in milliseconds + * + * @example + * const startTime = now(); + * // Some time-consuming operation + * const endTime = now(); + * console.log(`Operation took ${endTime - startTime} milliseconds`); + */ +declare function now(): number; +//#endregion +export { now }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/now.d.ts b/node_modules/es-toolkit/dist/compat/util/now.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..56dc733e0113e4f3029f7078886eed508dc0bb90 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/now.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/util/now.d.ts +/** + * Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. + * + * @returns The current time in milliseconds. + * + * @example + * const currentTime = now(); + * console.log(currentTime); // Outputs the current time in milliseconds + * + * @example + * const startTime = now(); + * // Some time-consuming operation + * const endTime = now(); + * console.log(`Operation took ${endTime - startTime} milliseconds`); + */ +declare function now(): number; +//#endregion +export { now }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/now.js b/node_modules/es-toolkit/dist/compat/util/now.js new file mode 100644 index 0000000000000000000000000000000000000000..1f081f9a26cc5fe736031310e223f693163901ff --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/now.js @@ -0,0 +1,21 @@ +//#region src/compat/util/now.ts +/** +* Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. +* +* @returns The current time in milliseconds. +* +* @example +* const currentTime = now(); +* console.log(currentTime); // Outputs the current time in milliseconds +* +* @example +* const startTime = now(); +* // Some time-consuming operation +* const endTime = now(); +* console.log(`Operation took ${endTime - startTime} milliseconds`); +*/ +function now() { + return Date.now(); +} +//#endregion +exports.now = now; diff --git a/node_modules/es-toolkit/dist/compat/util/now.mjs b/node_modules/es-toolkit/dist/compat/util/now.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9ee355f090e17bd6530d7a34f8f34c3c68e2fa6f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/now.mjs @@ -0,0 +1,21 @@ +//#region src/compat/util/now.ts +/** +* Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. +* +* @returns The current time in milliseconds. +* +* @example +* const currentTime = now(); +* console.log(currentTime); // Outputs the current time in milliseconds +* +* @example +* const startTime = now(); +* // Some time-consuming operation +* const endTime = now(); +* console.log(`Operation took ${endTime - startTime} milliseconds`); +*/ +function now() { + return Date.now(); +} +//#endregion +export { now }; diff --git a/node_modules/es-toolkit/dist/compat/util/over.d.mts b/node_modules/es-toolkit/dist/compat/util/over.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..57b0cba6957b523cc27e6935a35d481e6aa3f3de --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/over.d.mts @@ -0,0 +1,30 @@ +//#region src/compat/util/over.d.ts +/** + * Creates a function that invokes given functions and returns their results as an array. + * + * @param iteratees - The iteratees to invoke. + * @returns Returns the new function. + * + * @example + * const func = over([Math.max, Math.min]); + * const func2 = over(Math.max, Math.min); // same as above + * func(1, 2, 3, 4); + * // => [4, 1] + * func2(1, 2, 3, 4); + * // => [4, 1] + * + * const func = over(['a', 'b']); + * func({ a: 1, b: 2 }); + * // => [1, 2] + * + * const func = over([{ a: 1 }, { b: 2 }]); + * func({ a: 1, b: 2 }); + * // => [true, true] + * + * const func = over([['a', 1], ['b', 2]]); + * func({ a: 1, b: 2 }); + * // => [true, true] + */ +declare function over(...iteratees: Array<((...args: any[]) => T) | ReadonlyArray<(...args: any[]) => T>>): (...args: any[]) => T[]; +//#endregion +export { over }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/over.d.ts b/node_modules/es-toolkit/dist/compat/util/over.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..57b0cba6957b523cc27e6935a35d481e6aa3f3de --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/over.d.ts @@ -0,0 +1,30 @@ +//#region src/compat/util/over.d.ts +/** + * Creates a function that invokes given functions and returns their results as an array. + * + * @param iteratees - The iteratees to invoke. + * @returns Returns the new function. + * + * @example + * const func = over([Math.max, Math.min]); + * const func2 = over(Math.max, Math.min); // same as above + * func(1, 2, 3, 4); + * // => [4, 1] + * func2(1, 2, 3, 4); + * // => [4, 1] + * + * const func = over(['a', 'b']); + * func({ a: 1, b: 2 }); + * // => [1, 2] + * + * const func = over([{ a: 1 }, { b: 2 }]); + * func({ a: 1, b: 2 }); + * // => [true, true] + * + * const func = over([['a', 1], ['b', 2]]); + * func({ a: 1, b: 2 }); + * // => [true, true] + */ +declare function over(...iteratees: Array<((...args: any[]) => T) | ReadonlyArray<(...args: any[]) => T>>): (...args: any[]) => T[]; +//#endregion +export { over }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/over.js b/node_modules/es-toolkit/dist/compat/util/over.js new file mode 100644 index 0000000000000000000000000000000000000000..bce5f5917d0ebcd84c5809c2479887a4f2e78554 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/over.js @@ -0,0 +1,37 @@ +const require_iteratee = require("./iteratee.js"); +//#region src/compat/util/over.ts +/** +* Creates a function that invokes given functions and returns their results as an array. +* +* @param iteratees - The iteratees to invoke. +* @returns Returns the new function. +* +* @example +* const func = over([Math.max, Math.min]); +* const func2 = over(Math.max, Math.min); // same as above +* func(1, 2, 3, 4); +* // => [4, 1] +* func2(1, 2, 3, 4); +* // => [4, 1] +* +* const func = over(['a', 'b']); +* func({ a: 1, b: 2 }); +* // => [1, 2] +* +* const func = over([{ a: 1 }, { b: 2 }]); +* func({ a: 1, b: 2 }); +* // => [true, true] +* +* const func = over([['a', 1], ['b', 2]]); +* func({ a: 1, b: 2 }); +* // => [true, true] +*/ +function over(...iteratees) { + if (iteratees.length === 1 && Array.isArray(iteratees[0])) iteratees = iteratees[0]; + const funcs = iteratees.map((item) => require_iteratee.iteratee(item)); + return function(...args) { + return funcs.map((func) => func.apply(this, args)); + }; +} +//#endregion +exports.over = over; diff --git a/node_modules/es-toolkit/dist/compat/util/over.mjs b/node_modules/es-toolkit/dist/compat/util/over.mjs new file mode 100644 index 0000000000000000000000000000000000000000..229f6421608483434d8a291de8191471a0b0434a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/over.mjs @@ -0,0 +1,37 @@ +import { iteratee } from "./iteratee.mjs"; +//#region src/compat/util/over.ts +/** +* Creates a function that invokes given functions and returns their results as an array. +* +* @param iteratees - The iteratees to invoke. +* @returns Returns the new function. +* +* @example +* const func = over([Math.max, Math.min]); +* const func2 = over(Math.max, Math.min); // same as above +* func(1, 2, 3, 4); +* // => [4, 1] +* func2(1, 2, 3, 4); +* // => [4, 1] +* +* const func = over(['a', 'b']); +* func({ a: 1, b: 2 }); +* // => [1, 2] +* +* const func = over([{ a: 1 }, { b: 2 }]); +* func({ a: 1, b: 2 }); +* // => [true, true] +* +* const func = over([['a', 1], ['b', 2]]); +* func({ a: 1, b: 2 }); +* // => [true, true] +*/ +function over(...iteratees) { + if (iteratees.length === 1 && Array.isArray(iteratees[0])) iteratees = iteratees[0]; + const funcs = iteratees.map((item) => iteratee(item)); + return function(...args) { + return funcs.map((func) => func.apply(this, args)); + }; +} +//#endregion +export { over }; diff --git a/node_modules/es-toolkit/dist/compat/util/overEvery.d.mts b/node_modules/es-toolkit/dist/compat/util/overEvery.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..98720ae50dfac272d157c9c0d9cfc0a39c5ec1d2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/overEvery.d.mts @@ -0,0 +1,68 @@ +//#region src/compat/util/overEvery.d.ts +/** + * Creates a predicate function that checks if a value satisfies all of the given predicates. + * + * @template T - The type of the value to be checked. + * @template U - The first possible type that the value could match. + * @template V - The second possible type that the value could match. + * + * @param predicate1 - A function that checks if the value matches type `U`. + * @param predicate2 - A function that checks if the value matches type `V`. + * + * @returns A function that takes a value and returns `true` if all predicates return truthy. + * + * @example + * const func = overEvery( + * (value) => typeof value === 'string', + * (value) => value === 'hello' + * ); + * + * func("hello"); // true + * func("world"); // false + * func(42); // false + */ +declare function overEvery(predicate1: (value: T) => value is U, predicate2: (value: T) => value is V): (value: T) => value is U & V; +/** + * Creates a function that checks if all of the given predicates return truthy for the provided values. + * + * @template T - The type of the values to be checked. + * + * @param predicates - + * A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of + * type `T` and returns a boolean indicating whether the condition is satisfied for those values. + * + * @returns A function that takes a list of values and returns `true` if all of the + * predicates return truthy for the provided values, and `false` otherwise. + * + * @example + * const func = overEvery( + * (value) => typeof value === 'string', + * (value) => value.length > 3 + * ); + * + * func("hello"); // true + * func("hi"); // false + * func(42); // false + * + * @example + * const func = overEvery([ + * (value) => value.a > 0, + * (value) => value.b > 0 + * ]); + * + * func({ a: 1, b: 2 }); // true + * func({ a: 0, b: 2 }); // false + * + * @example + * const func = overEvery( + * (a, b) => typeof a === 'string' && typeof b === 'string', + * (a, b) => a.length > 3 && b.length > 3 + * ); + * + * func("hello", "world"); // true + * func("hi", "world"); // false + * func(1, 10); // false + */ +declare function overEvery(...predicates: Array<((...args: T[]) => boolean) | ReadonlyArray<(...args: T[]) => boolean>>): (...args: T[]) => boolean; +//#endregion +export { overEvery }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/overEvery.d.ts b/node_modules/es-toolkit/dist/compat/util/overEvery.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..98720ae50dfac272d157c9c0d9cfc0a39c5ec1d2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/overEvery.d.ts @@ -0,0 +1,68 @@ +//#region src/compat/util/overEvery.d.ts +/** + * Creates a predicate function that checks if a value satisfies all of the given predicates. + * + * @template T - The type of the value to be checked. + * @template U - The first possible type that the value could match. + * @template V - The second possible type that the value could match. + * + * @param predicate1 - A function that checks if the value matches type `U`. + * @param predicate2 - A function that checks if the value matches type `V`. + * + * @returns A function that takes a value and returns `true` if all predicates return truthy. + * + * @example + * const func = overEvery( + * (value) => typeof value === 'string', + * (value) => value === 'hello' + * ); + * + * func("hello"); // true + * func("world"); // false + * func(42); // false + */ +declare function overEvery(predicate1: (value: T) => value is U, predicate2: (value: T) => value is V): (value: T) => value is U & V; +/** + * Creates a function that checks if all of the given predicates return truthy for the provided values. + * + * @template T - The type of the values to be checked. + * + * @param predicates - + * A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of + * type `T` and returns a boolean indicating whether the condition is satisfied for those values. + * + * @returns A function that takes a list of values and returns `true` if all of the + * predicates return truthy for the provided values, and `false` otherwise. + * + * @example + * const func = overEvery( + * (value) => typeof value === 'string', + * (value) => value.length > 3 + * ); + * + * func("hello"); // true + * func("hi"); // false + * func(42); // false + * + * @example + * const func = overEvery([ + * (value) => value.a > 0, + * (value) => value.b > 0 + * ]); + * + * func({ a: 1, b: 2 }); // true + * func({ a: 0, b: 2 }); // false + * + * @example + * const func = overEvery( + * (a, b) => typeof a === 'string' && typeof b === 'string', + * (a, b) => a.length > 3 && b.length > 3 + * ); + * + * func("hello", "world"); // true + * func("hi", "world"); // false + * func(1, 10); // false + */ +declare function overEvery(...predicates: Array<((...args: T[]) => boolean) | ReadonlyArray<(...args: T[]) => boolean>>): (...args: T[]) => boolean; +//#endregion +export { overEvery }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/overEvery.js b/node_modules/es-toolkit/dist/compat/util/overEvery.js new file mode 100644 index 0000000000000000000000000000000000000000..58256e2fc19d70d3d622a1440a836c9aa47c8826 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/overEvery.js @@ -0,0 +1,61 @@ +const require_iteratee = require("./iteratee.js"); +//#region src/compat/util/overEvery.ts +/** +* Creates a function that checks if all of the given predicates return truthy for the provided values. +* +* This function takes multiple predicates, which can either be individual predicate functions or arrays of predicates, +* and returns a new function that checks if all of the predicates return truthy when called with the provided values. +* +* @template T - The type of the values to be checked. +* +* @param predicates - +* A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of +* type `T` and returns a boolean indicating whether the condition is satisfied for those values. +* +* @returns A function that takes a list of values and returns `true` if all of the +* predicates return truthy for the provided values, and `false` otherwise. +* +* @example +* const func = overEvery( +* (value) => typeof value === 'string', +* (value) => value.length > 3 +* ); +* +* func("hello"); // true +* func("hi"); // false +* func(42); // false +* +* @example +* const func = overEvery([ +* (value) => value.a > 0, +* (value) => value.b > 0 +* ]); +* +* func({ a: 1, b: 2 }); // true +* func({ a: 0, b: 2 }); // false +* +* @example +* const func = overEvery( +* (a, b) => typeof a === 'string' && typeof b === 'string', +* (a, b) => a.length > 3 && b.length > 3 +* ); +* +* func("hello", "world"); // true +* func("hi", "world"); // false +* func(1, 10); // false +*/ +function overEvery(...predicates) { + return function(...values) { + for (let i = 0; i < predicates.length; ++i) { + const predicate = predicates[i]; + if (!Array.isArray(predicate)) { + if (!require_iteratee.iteratee(predicate).apply(this, values)) return false; + continue; + } + for (let j = 0; j < predicate.length; ++j) if (!require_iteratee.iteratee(predicate[j]).apply(this, values)) return false; + } + return true; + }; +} +//#endregion +exports.overEvery = overEvery; diff --git a/node_modules/es-toolkit/dist/compat/util/overEvery.mjs b/node_modules/es-toolkit/dist/compat/util/overEvery.mjs new file mode 100644 index 0000000000000000000000000000000000000000..04d2281fcbc58e96aee77d2fc1b94879a6fec0ee --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/overEvery.mjs @@ -0,0 +1,61 @@ +import { iteratee } from "./iteratee.mjs"; +//#region src/compat/util/overEvery.ts +/** +* Creates a function that checks if all of the given predicates return truthy for the provided values. +* +* This function takes multiple predicates, which can either be individual predicate functions or arrays of predicates, +* and returns a new function that checks if all of the predicates return truthy when called with the provided values. +* +* @template T - The type of the values to be checked. +* +* @param predicates - +* A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of +* type `T` and returns a boolean indicating whether the condition is satisfied for those values. +* +* @returns A function that takes a list of values and returns `true` if all of the +* predicates return truthy for the provided values, and `false` otherwise. +* +* @example +* const func = overEvery( +* (value) => typeof value === 'string', +* (value) => value.length > 3 +* ); +* +* func("hello"); // true +* func("hi"); // false +* func(42); // false +* +* @example +* const func = overEvery([ +* (value) => value.a > 0, +* (value) => value.b > 0 +* ]); +* +* func({ a: 1, b: 2 }); // true +* func({ a: 0, b: 2 }); // false +* +* @example +* const func = overEvery( +* (a, b) => typeof a === 'string' && typeof b === 'string', +* (a, b) => a.length > 3 && b.length > 3 +* ); +* +* func("hello", "world"); // true +* func("hi", "world"); // false +* func(1, 10); // false +*/ +function overEvery(...predicates) { + return function(...values) { + for (let i = 0; i < predicates.length; ++i) { + const predicate = predicates[i]; + if (!Array.isArray(predicate)) { + if (!iteratee(predicate).apply(this, values)) return false; + continue; + } + for (let j = 0; j < predicate.length; ++j) if (!iteratee(predicate[j]).apply(this, values)) return false; + } + return true; + }; +} +//#endregion +export { overEvery }; diff --git a/node_modules/es-toolkit/dist/compat/util/overSome.d.mts b/node_modules/es-toolkit/dist/compat/util/overSome.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..37d4df857689e7fb4ad5bd0ed174014993fdfe19 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/overSome.d.mts @@ -0,0 +1,70 @@ +//#region src/compat/util/overSome.d.ts +/** + * Creates a predicate function that checks if a value satisfies at least one of the given predicates. + * + * @template T - The type of the value to be checked. + * @template U - The first possible type that the value could match. + * @template V - The second possible type that the value could match. + * + * @param predicate1 - A function that checks if the value matches type `U`. + * @param predicate2 - A function that checks if the value matches type `V`. + * + * @returns A function that takes a value and returns `true` if any predicates return truthy. + * + * @example + * const func = overSome( + * (value) => typeof value === 'string', + * (value) => typeof value === 'number' + * ); + * + * func("hello"); // true + * func(42); // true + * func([]); // false + */ +declare function overSome(predicate1: (value: T) => value is U, predicate2: (value: T) => value is V): (value: T) => value is U | V; +/** + * Creates a function that checks if any of the given predicates return truthy for the provided values. + * + * @template T - The type of the values to be checked. + * + * @param predicates - + * A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of + * type `T` and returns a boolean indicating whether the condition is satisfied for those values. + * + * @returns A function that takes a list of values and returns `true` if any of the + * predicates return truthy for the provided values, and `false` otherwise. + * + * @example + * const func = overSome( + * (value) => typeof value === 'string', + * (value) => typeof value === 'number', + * (value) => typeof value === 'symbol' + * ); + * + * func("hello"); // true + * func(42); // true + * func(Symbol()); // true + * func([]); // false + * + * @example + * const func = overSome([ + * (value) => value.a > 0, + * (value) => value.b > 0 + * ]); + * + * func({ a: 0, b: 2 }); // true + * func({ a: 0, b: 0 }); // false + * + * @example + * const func = overSome( + * (a, b) => typeof a === 'string' && typeof b === 'string', + * (a, b) => a > 0 && b > 0 + * ); + * + * func("hello", "world"); // true + * func(1, 10); // true + * func(0, 2); // false + */ +declare function overSome(...predicates: Array<((...values: T[]) => boolean) | ReadonlyArray<(...values: T[]) => boolean>>): (...values: T[]) => boolean; +//#endregion +export { overSome }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/overSome.d.ts b/node_modules/es-toolkit/dist/compat/util/overSome.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..37d4df857689e7fb4ad5bd0ed174014993fdfe19 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/overSome.d.ts @@ -0,0 +1,70 @@ +//#region src/compat/util/overSome.d.ts +/** + * Creates a predicate function that checks if a value satisfies at least one of the given predicates. + * + * @template T - The type of the value to be checked. + * @template U - The first possible type that the value could match. + * @template V - The second possible type that the value could match. + * + * @param predicate1 - A function that checks if the value matches type `U`. + * @param predicate2 - A function that checks if the value matches type `V`. + * + * @returns A function that takes a value and returns `true` if any predicates return truthy. + * + * @example + * const func = overSome( + * (value) => typeof value === 'string', + * (value) => typeof value === 'number' + * ); + * + * func("hello"); // true + * func(42); // true + * func([]); // false + */ +declare function overSome(predicate1: (value: T) => value is U, predicate2: (value: T) => value is V): (value: T) => value is U | V; +/** + * Creates a function that checks if any of the given predicates return truthy for the provided values. + * + * @template T - The type of the values to be checked. + * + * @param predicates - + * A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of + * type `T` and returns a boolean indicating whether the condition is satisfied for those values. + * + * @returns A function that takes a list of values and returns `true` if any of the + * predicates return truthy for the provided values, and `false` otherwise. + * + * @example + * const func = overSome( + * (value) => typeof value === 'string', + * (value) => typeof value === 'number', + * (value) => typeof value === 'symbol' + * ); + * + * func("hello"); // true + * func(42); // true + * func(Symbol()); // true + * func([]); // false + * + * @example + * const func = overSome([ + * (value) => value.a > 0, + * (value) => value.b > 0 + * ]); + * + * func({ a: 0, b: 2 }); // true + * func({ a: 0, b: 0 }); // false + * + * @example + * const func = overSome( + * (a, b) => typeof a === 'string' && typeof b === 'string', + * (a, b) => a > 0 && b > 0 + * ); + * + * func("hello", "world"); // true + * func(1, 10); // true + * func(0, 2); // false + */ +declare function overSome(...predicates: Array<((...values: T[]) => boolean) | ReadonlyArray<(...values: T[]) => boolean>>): (...values: T[]) => boolean; +//#endregion +export { overSome }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/overSome.js b/node_modules/es-toolkit/dist/compat/util/overSome.js new file mode 100644 index 0000000000000000000000000000000000000000..bb9cae29d97e390c32b0f83f4aebee7d1d356188 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/overSome.js @@ -0,0 +1,63 @@ +const require_iteratee = require("./iteratee.js"); +//#region src/compat/util/overSome.ts +/** +* Creates a function that checks if any of the given predicates return truthy for the provided values. +* +* This function takes multiple predicates, which can either be individual predicate functions or arrays of predicates, +* and returns a new function that checks if any of the predicates return truthy when called with the provided values. +* +* @template T - The type of the values to be checked. +* +* @param predicates - +* A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of +* type `T` and returns a boolean indicating whether the condition is satisfied for those values. +* +* @returns A function that takes a list of values and returns `true` if any of the +* predicates return truthy for the provided values, and `false` otherwise. +* +* @example +* const func = overSome( +* (value) => typeof value === 'string', +* (value) => typeof value === 'number', +* (value) => typeof value === 'symbol' +* ); +* +* func("hello"); // true +* func(42); // true +* func(Symbol()); // true +* func([]); // false +* +* @example +* const func = overSome([ +* (value) => value.a > 0, +* (value) => value.b > 0 +* ]); +* +* func({ a: 0, b: 2 }); // true +* func({ a: 0, b: 0 }); // false +* +* @example +* const func = overSome( +* (a, b) => typeof a === 'string' && typeof b === 'string', +* (a, b) => a > 0 && b > 0 +* ); +* +* func("hello", "world"); // true +* func(1, 10); // true +* func(0, 2); // false +*/ +function overSome(...predicates) { + return function(...values) { + for (let i = 0; i < predicates.length; ++i) { + const predicate = predicates[i]; + if (!Array.isArray(predicate)) { + if (require_iteratee.iteratee(predicate).apply(this, values)) return true; + continue; + } + for (let j = 0; j < predicate.length; ++j) if (require_iteratee.iteratee(predicate[j]).apply(this, values)) return true; + } + return false; + }; +} +//#endregion +exports.overSome = overSome; diff --git a/node_modules/es-toolkit/dist/compat/util/overSome.mjs b/node_modules/es-toolkit/dist/compat/util/overSome.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2040018cf67003fa98f9dfa1d08816511dd78590 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/overSome.mjs @@ -0,0 +1,63 @@ +import { iteratee } from "./iteratee.mjs"; +//#region src/compat/util/overSome.ts +/** +* Creates a function that checks if any of the given predicates return truthy for the provided values. +* +* This function takes multiple predicates, which can either be individual predicate functions or arrays of predicates, +* and returns a new function that checks if any of the predicates return truthy when called with the provided values. +* +* @template T - The type of the values to be checked. +* +* @param predicates - +* A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of +* type `T` and returns a boolean indicating whether the condition is satisfied for those values. +* +* @returns A function that takes a list of values and returns `true` if any of the +* predicates return truthy for the provided values, and `false` otherwise. +* +* @example +* const func = overSome( +* (value) => typeof value === 'string', +* (value) => typeof value === 'number', +* (value) => typeof value === 'symbol' +* ); +* +* func("hello"); // true +* func(42); // true +* func(Symbol()); // true +* func([]); // false +* +* @example +* const func = overSome([ +* (value) => value.a > 0, +* (value) => value.b > 0 +* ]); +* +* func({ a: 0, b: 2 }); // true +* func({ a: 0, b: 0 }); // false +* +* @example +* const func = overSome( +* (a, b) => typeof a === 'string' && typeof b === 'string', +* (a, b) => a > 0 && b > 0 +* ); +* +* func("hello", "world"); // true +* func(1, 10); // true +* func(0, 2); // false +*/ +function overSome(...predicates) { + return function(...values) { + for (let i = 0; i < predicates.length; ++i) { + const predicate = predicates[i]; + if (!Array.isArray(predicate)) { + if (iteratee(predicate).apply(this, values)) return true; + continue; + } + for (let j = 0; j < predicate.length; ++j) if (iteratee(predicate[j]).apply(this, values)) return true; + } + return false; + }; +} +//#endregion +export { overSome }; diff --git a/node_modules/es-toolkit/dist/compat/util/stubArray.d.mts b/node_modules/es-toolkit/dist/compat/util/stubArray.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b73064fbb35850c44a16910c5f860a9a8ee90eba --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubArray.d.mts @@ -0,0 +1,11 @@ +//#region src/compat/util/stubArray.d.ts +/** + * Returns a new empty array. + * + * @returns A new empty array. + * @example + * stubArray() // Returns [] + */ +declare function stubArray(): any[]; +//#endregion +export { stubArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubArray.d.ts b/node_modules/es-toolkit/dist/compat/util/stubArray.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b73064fbb35850c44a16910c5f860a9a8ee90eba --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubArray.d.ts @@ -0,0 +1,11 @@ +//#region src/compat/util/stubArray.d.ts +/** + * Returns a new empty array. + * + * @returns A new empty array. + * @example + * stubArray() // Returns [] + */ +declare function stubArray(): any[]; +//#endregion +export { stubArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubArray.js b/node_modules/es-toolkit/dist/compat/util/stubArray.js new file mode 100644 index 0000000000000000000000000000000000000000..30f1775a08b2883e79a2c777e92f9d017b3daf2e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubArray.js @@ -0,0 +1,6 @@ +//#region src/compat/util/stubArray.ts +function stubArray() { + return []; +} +//#endregion +exports.stubArray = stubArray; diff --git a/node_modules/es-toolkit/dist/compat/util/stubArray.mjs b/node_modules/es-toolkit/dist/compat/util/stubArray.mjs new file mode 100644 index 0000000000000000000000000000000000000000..831dc0337bd20c79f697aa3b178859a632f64a7b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubArray.mjs @@ -0,0 +1,6 @@ +//#region src/compat/util/stubArray.ts +function stubArray() { + return []; +} +//#endregion +export { stubArray }; diff --git a/node_modules/es-toolkit/dist/compat/util/stubFalse.d.mts b/node_modules/es-toolkit/dist/compat/util/stubFalse.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..982f6e053df11d832cd937a79fcf97e41e36e1ec --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubFalse.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/util/stubFalse.d.ts +/** + * Returns false. + * + * @returns false. + * @example + * stubFalse() // Returns false + */ +declare function stubFalse(): false; +/** + * Returns false. + * + * @returns false. + * @example + * stubFalse() // Returns false + */ +declare function stubFalse(): false; +//#endregion +export { stubFalse }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubFalse.d.ts b/node_modules/es-toolkit/dist/compat/util/stubFalse.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..982f6e053df11d832cd937a79fcf97e41e36e1ec --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubFalse.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/util/stubFalse.d.ts +/** + * Returns false. + * + * @returns false. + * @example + * stubFalse() // Returns false + */ +declare function stubFalse(): false; +/** + * Returns false. + * + * @returns false. + * @example + * stubFalse() // Returns false + */ +declare function stubFalse(): false; +//#endregion +export { stubFalse }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubFalse.js b/node_modules/es-toolkit/dist/compat/util/stubFalse.js new file mode 100644 index 0000000000000000000000000000000000000000..782f4e39e674f4d86e812ded506b3cbd5fbfdc9e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubFalse.js @@ -0,0 +1,6 @@ +//#region src/compat/util/stubFalse.ts +function stubFalse() { + return false; +} +//#endregion +exports.stubFalse = stubFalse; diff --git a/node_modules/es-toolkit/dist/compat/util/stubFalse.mjs b/node_modules/es-toolkit/dist/compat/util/stubFalse.mjs new file mode 100644 index 0000000000000000000000000000000000000000..956ce09ac280ba8223877dc2eb3ce3bb3dc6c8f0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubFalse.mjs @@ -0,0 +1,6 @@ +//#region src/compat/util/stubFalse.ts +function stubFalse() { + return false; +} +//#endregion +export { stubFalse }; diff --git a/node_modules/es-toolkit/dist/compat/util/stubObject.d.mts b/node_modules/es-toolkit/dist/compat/util/stubObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e7f7786912988f5b8798f8af8000290feab7a9b6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubObject.d.mts @@ -0,0 +1,11 @@ +//#region src/compat/util/stubObject.d.ts +/** + * Returns an empty object. + * + * @returns An empty object. + * @example + * stubObject() // Returns {} + */ +declare function stubObject(): any; +//#endregion +export { stubObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubObject.d.ts b/node_modules/es-toolkit/dist/compat/util/stubObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e7f7786912988f5b8798f8af8000290feab7a9b6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubObject.d.ts @@ -0,0 +1,11 @@ +//#region src/compat/util/stubObject.d.ts +/** + * Returns an empty object. + * + * @returns An empty object. + * @example + * stubObject() // Returns {} + */ +declare function stubObject(): any; +//#endregion +export { stubObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubObject.js b/node_modules/es-toolkit/dist/compat/util/stubObject.js new file mode 100644 index 0000000000000000000000000000000000000000..b05d3fc7c056bb442e0a80b2a46bd8b2c9e2a115 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubObject.js @@ -0,0 +1,13 @@ +//#region src/compat/util/stubObject.ts +/** +* Returns an empty object. +* +* @returns An empty object. +* @example +* stubObject() // Returns {} +*/ +function stubObject() { + return {}; +} +//#endregion +exports.stubObject = stubObject; diff --git a/node_modules/es-toolkit/dist/compat/util/stubObject.mjs b/node_modules/es-toolkit/dist/compat/util/stubObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..469efbf552d5a703ddf137c37f5bac797a3b76c6 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubObject.mjs @@ -0,0 +1,13 @@ +//#region src/compat/util/stubObject.ts +/** +* Returns an empty object. +* +* @returns An empty object. +* @example +* stubObject() // Returns {} +*/ +function stubObject() { + return {}; +} +//#endregion +export { stubObject }; diff --git a/node_modules/es-toolkit/dist/compat/util/stubString.d.mts b/node_modules/es-toolkit/dist/compat/util/stubString.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..420232561036bb98f5a903395e81734ecda90e3e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubString.d.mts @@ -0,0 +1,11 @@ +//#region src/compat/util/stubString.d.ts +/** + * Returns an empty string. + * + * @returns An empty string. + * @example + * stubString() // Returns '' + */ +declare function stubString(): string; +//#endregion +export { stubString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubString.d.ts b/node_modules/es-toolkit/dist/compat/util/stubString.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..420232561036bb98f5a903395e81734ecda90e3e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubString.d.ts @@ -0,0 +1,11 @@ +//#region src/compat/util/stubString.d.ts +/** + * Returns an empty string. + * + * @returns An empty string. + * @example + * stubString() // Returns '' + */ +declare function stubString(): string; +//#endregion +export { stubString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubString.js b/node_modules/es-toolkit/dist/compat/util/stubString.js new file mode 100644 index 0000000000000000000000000000000000000000..4922f56da3a774b2c692c6b2080942032e75ea6d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubString.js @@ -0,0 +1,6 @@ +//#region src/compat/util/stubString.ts +function stubString() { + return ""; +} +//#endregion +exports.stubString = stubString; diff --git a/node_modules/es-toolkit/dist/compat/util/stubString.mjs b/node_modules/es-toolkit/dist/compat/util/stubString.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4cafaaf7c2c2e443a1bd6644295e2e49eb6cb311 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubString.mjs @@ -0,0 +1,6 @@ +//#region src/compat/util/stubString.ts +function stubString() { + return ""; +} +//#endregion +export { stubString }; diff --git a/node_modules/es-toolkit/dist/compat/util/stubTrue.d.mts b/node_modules/es-toolkit/dist/compat/util/stubTrue.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2caaa21c5e6c7b858f3862f1f55fb85722707bac --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubTrue.d.mts @@ -0,0 +1,19 @@ +//#region src/compat/util/stubTrue.d.ts +/** + * Returns true. + * + * @returns true. + * @example + * stubTrue() // Returns true + */ +declare function stubTrue(): true; +/** + * Returns true. + * + * @returns true. + * @example + * stubTrue() // Returns true + */ +declare function stubTrue(): true; +//#endregion +export { stubTrue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubTrue.d.ts b/node_modules/es-toolkit/dist/compat/util/stubTrue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2caaa21c5e6c7b858f3862f1f55fb85722707bac --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubTrue.d.ts @@ -0,0 +1,19 @@ +//#region src/compat/util/stubTrue.d.ts +/** + * Returns true. + * + * @returns true. + * @example + * stubTrue() // Returns true + */ +declare function stubTrue(): true; +/** + * Returns true. + * + * @returns true. + * @example + * stubTrue() // Returns true + */ +declare function stubTrue(): true; +//#endregion +export { stubTrue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/stubTrue.js b/node_modules/es-toolkit/dist/compat/util/stubTrue.js new file mode 100644 index 0000000000000000000000000000000000000000..98af579d7190cf9ad5215d01f9be455b2b8d831a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubTrue.js @@ -0,0 +1,6 @@ +//#region src/compat/util/stubTrue.ts +function stubTrue() { + return true; +} +//#endregion +exports.stubTrue = stubTrue; diff --git a/node_modules/es-toolkit/dist/compat/util/stubTrue.mjs b/node_modules/es-toolkit/dist/compat/util/stubTrue.mjs new file mode 100644 index 0000000000000000000000000000000000000000..aef26b7f87b84a2e43306aed8db2df1484519cdf --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/stubTrue.mjs @@ -0,0 +1,6 @@ +//#region src/compat/util/stubTrue.ts +function stubTrue() { + return true; +} +//#endregion +export { stubTrue }; diff --git a/node_modules/es-toolkit/dist/compat/util/times.d.mts b/node_modules/es-toolkit/dist/compat/util/times.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..02b649832d3b288f3bbdb6ec6053a61577d1e19f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/times.d.mts @@ -0,0 +1,24 @@ +//#region src/compat/util/times.d.ts +/** + * Invokes the iteratee function n times, returning an array of the results. + * + * @template T The return type of the iteratee function. + * @param n - The number of times to invoke iteratee. + * @param iteratee - The function to invoke for each index. + * @returns An array containing the results of invoking iteratee n times. + * @example + * times(3, (i) => i * 2); // => [0, 2, 4] + * times(2, () => 'es-toolkit'); // => ['es-toolkit', 'es-toolkit'] + */ +declare function times(n: number, iteratee: (num: number) => T): T[]; +/** + * Invokes the default iteratee function n times, returning an array of indices. + * + * @param n - The number of times to invoke the default iteratee. + * @returns An array containing indices from 0 to n-1. + * @example + * times(3); // => [0, 1, 2] + */ +declare function times(n: number): number[]; +//#endregion +export { times }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/times.d.ts b/node_modules/es-toolkit/dist/compat/util/times.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..02b649832d3b288f3bbdb6ec6053a61577d1e19f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/times.d.ts @@ -0,0 +1,24 @@ +//#region src/compat/util/times.d.ts +/** + * Invokes the iteratee function n times, returning an array of the results. + * + * @template T The return type of the iteratee function. + * @param n - The number of times to invoke iteratee. + * @param iteratee - The function to invoke for each index. + * @returns An array containing the results of invoking iteratee n times. + * @example + * times(3, (i) => i * 2); // => [0, 2, 4] + * times(2, () => 'es-toolkit'); // => ['es-toolkit', 'es-toolkit'] + */ +declare function times(n: number, iteratee: (num: number) => T): T[]; +/** + * Invokes the default iteratee function n times, returning an array of indices. + * + * @param n - The number of times to invoke the default iteratee. + * @returns An array containing indices from 0 to n-1. + * @example + * times(3); // => [0, 1, 2] + */ +declare function times(n: number): number[]; +//#endregion +export { times }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/times.js b/node_modules/es-toolkit/dist/compat/util/times.js new file mode 100644 index 0000000000000000000000000000000000000000..e6b13aeee2f21a45f6ffd44388508981cb3f23a7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/times.js @@ -0,0 +1,22 @@ +const require_toInteger = require("./toInteger.js"); +//#region src/compat/util/times.ts +/** +* Invokes the getValue function n times, returning an array of the results. +* +* @template R The return type of the getValue function. +* @param n - The number of times to invoke getValue. +* @param getValue - The function to invoke for each index. +* @returns An array containing the results of invoking getValue n times. +* @example +* times(3, (i) => i * 2); // => [0, 2, 4] +* times(2, () => 'es-toolkit'); // => ['es-toolkit', 'es-toolkit'] +*/ +function times(n, getValue) { + n = require_toInteger.toInteger(n); + if (n < 1 || !Number.isSafeInteger(n)) return []; + const result = new Array(n); + for (let i = 0; i < n; i++) result[i] = typeof getValue === "function" ? getValue(i) : i; + return result; +} +//#endregion +exports.times = times; diff --git a/node_modules/es-toolkit/dist/compat/util/times.mjs b/node_modules/es-toolkit/dist/compat/util/times.mjs new file mode 100644 index 0000000000000000000000000000000000000000..03fd13ec75776f3959f2598a097de7883e980451 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/times.mjs @@ -0,0 +1,22 @@ +import { toInteger } from "./toInteger.mjs"; +//#region src/compat/util/times.ts +/** +* Invokes the getValue function n times, returning an array of the results. +* +* @template R The return type of the getValue function. +* @param n - The number of times to invoke getValue. +* @param getValue - The function to invoke for each index. +* @returns An array containing the results of invoking getValue n times. +* @example +* times(3, (i) => i * 2); // => [0, 2, 4] +* times(2, () => 'es-toolkit'); // => ['es-toolkit', 'es-toolkit'] +*/ +function times(n, getValue) { + n = toInteger(n); + if (n < 1 || !Number.isSafeInteger(n)) return []; + const result = new Array(n); + for (let i = 0; i < n; i++) result[i] = typeof getValue === "function" ? getValue(i) : i; + return result; +} +//#endregion +export { times }; diff --git a/node_modules/es-toolkit/dist/compat/util/toArray.d.mts b/node_modules/es-toolkit/dist/compat/util/toArray.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ebe0a975610cdffe589d4d272597e20306cee5f8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toArray.d.mts @@ -0,0 +1,36 @@ +//#region src/compat/util/toArray.d.ts +/** + * Converts a record or null/undefined to an array of its values. + * + * @template T + * @param value - The record or null/undefined to convert. + * @returns Returns an array of the record's values or an empty array if null/undefined. + * + * @example + * toArray({ 'a': 1, 'b': 2 }) // => returns [1, 2] + * toArray(null) // => returns [] + */ +declare function toArray(value: Record | Record | null | undefined): T[]; +/** + * Converts a value to an array of its values. + * + * @template T + * @param value - The value to convert. + * @returns Returns an array of the value's values. + * + * @example + * toArray({ x: 10, y: 20 }) // => returns [10, 20] + * toArray('abc') // => returns ['a', 'b', 'c'] + */ +declare function toArray(value: T): Array; +/** + * Converts an undefined value to an empty array. + * + * @returns Returns an empty array. + * + * @example + * toArray() // => returns [] + */ +declare function toArray(): any[]; +//#endregion +export { toArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toArray.d.ts b/node_modules/es-toolkit/dist/compat/util/toArray.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ebe0a975610cdffe589d4d272597e20306cee5f8 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toArray.d.ts @@ -0,0 +1,36 @@ +//#region src/compat/util/toArray.d.ts +/** + * Converts a record or null/undefined to an array of its values. + * + * @template T + * @param value - The record or null/undefined to convert. + * @returns Returns an array of the record's values or an empty array if null/undefined. + * + * @example + * toArray({ 'a': 1, 'b': 2 }) // => returns [1, 2] + * toArray(null) // => returns [] + */ +declare function toArray(value: Record | Record | null | undefined): T[]; +/** + * Converts a value to an array of its values. + * + * @template T + * @param value - The value to convert. + * @returns Returns an array of the value's values. + * + * @example + * toArray({ x: 10, y: 20 }) // => returns [10, 20] + * toArray('abc') // => returns ['a', 'b', 'c'] + */ +declare function toArray(value: T): Array; +/** + * Converts an undefined value to an empty array. + * + * @returns Returns an empty array. + * + * @example + * toArray() // => returns [] + */ +declare function toArray(): any[]; +//#endregion +export { toArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toArray.js b/node_modules/es-toolkit/dist/compat/util/toArray.js new file mode 100644 index 0000000000000000000000000000000000000000..09c5ce28c8f7fad91722a8cebf95d19d6c7a022e --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toArray.js @@ -0,0 +1,24 @@ +const require_isArrayLike = require("../predicate/isArrayLike.js"); +const require_isMap = require("../predicate/isMap.js"); +const require_isSet = require("../predicate/isSet.js"); +//#region src/compat/util/toArray.ts +/** +* Converts a value to an array. +* +* @param value - The value to convert. +* @returns Returns the converted array. +* +* @example +* toArray({ 'a': 1, 'b': 2 }) // => returns [1,2] +* toArray('abc') // => returns ['a', 'b', 'c'] +* toArray(1) // => returns [] +* toArray(null) // => returns [] +*/ +function toArray(value) { + if (value == null) return []; + if (require_isArrayLike.isArrayLike(value) || require_isMap.isMap(value) || require_isSet.isSet(value)) return Array.from(value); + if (typeof value === "object") return Object.values(value); + return []; +} +//#endregion +exports.toArray = toArray; diff --git a/node_modules/es-toolkit/dist/compat/util/toArray.mjs b/node_modules/es-toolkit/dist/compat/util/toArray.mjs new file mode 100644 index 0000000000000000000000000000000000000000..15f4cf648fe6d393eab3a48e34a9d942c1239a19 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toArray.mjs @@ -0,0 +1,24 @@ +import { isArrayLike } from "../predicate/isArrayLike.mjs"; +import { isMap } from "../predicate/isMap.mjs"; +import { isSet } from "../predicate/isSet.mjs"; +//#region src/compat/util/toArray.ts +/** +* Converts a value to an array. +* +* @param value - The value to convert. +* @returns Returns the converted array. +* +* @example +* toArray({ 'a': 1, 'b': 2 }) // => returns [1,2] +* toArray('abc') // => returns ['a', 'b', 'c'] +* toArray(1) // => returns [] +* toArray(null) // => returns [] +*/ +function toArray(value) { + if (value == null) return []; + if (isArrayLike(value) || isMap(value) || isSet(value)) return Array.from(value); + if (typeof value === "object") return Object.values(value); + return []; +} +//#endregion +export { toArray }; diff --git a/node_modules/es-toolkit/dist/compat/util/toFinite.d.mts b/node_modules/es-toolkit/dist/compat/util/toFinite.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3c68634518b1c7d5f657517c214d4ddd6110c902 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toFinite.d.mts @@ -0,0 +1,18 @@ +//#region src/compat/util/toFinite.d.ts +/** + * Converts `value` to a finite number. + * + * @param value - The value to convert. + * @returns Returns the number. + * + * @example + * toFinite(3.2); // => 3.2 + * toFinite(Number.MIN_VALUE); // => 5e-324 + * toFinite(Infinity); // => 1.7976931348623157e+308 + * toFinite('3.2'); // => 3.2 + * toFinite(Symbol.iterator); // => 0 + * toFinite(NaN); // => 0 + */ +declare function toFinite(value: any): number; +//#endregion +export { toFinite }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toFinite.d.ts b/node_modules/es-toolkit/dist/compat/util/toFinite.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c68634518b1c7d5f657517c214d4ddd6110c902 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toFinite.d.ts @@ -0,0 +1,18 @@ +//#region src/compat/util/toFinite.d.ts +/** + * Converts `value` to a finite number. + * + * @param value - The value to convert. + * @returns Returns the number. + * + * @example + * toFinite(3.2); // => 3.2 + * toFinite(Number.MIN_VALUE); // => 5e-324 + * toFinite(Infinity); // => 1.7976931348623157e+308 + * toFinite('3.2'); // => 3.2 + * toFinite(Symbol.iterator); // => 0 + * toFinite(NaN); // => 0 + */ +declare function toFinite(value: any): number; +//#endregion +export { toFinite }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toFinite.js b/node_modules/es-toolkit/dist/compat/util/toFinite.js new file mode 100644 index 0000000000000000000000000000000000000000..d3df1f4bcf4f1c376cd6dba56d76b950cd146861 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toFinite.js @@ -0,0 +1,24 @@ +const require_toNumber = require("./toNumber.js"); +//#region src/compat/util/toFinite.ts +/** +* Converts `value` to a finite number. +* +* @param value - The value to convert. +* @returns Returns the number. +* +* @example +* toFinite(3.2); // => 3.2 +* toFinite(Number.MIN_VALUE); // => 5e-324 +* toFinite(Infinity); // => 1.7976931348623157e+308 +* toFinite('3.2'); // => 3.2 +* toFinite(Symbol.iterator); // => 0 +* toFinite(NaN); // => 0 +*/ +function toFinite(value) { + if (!value) return value === 0 ? value : 0; + value = require_toNumber.toNumber(value); + if (value === Infinity || value === -Infinity) return (value < 0 ? -1 : 1) * Number.MAX_VALUE; + return value === value ? value : 0; +} +//#endregion +exports.toFinite = toFinite; diff --git a/node_modules/es-toolkit/dist/compat/util/toFinite.mjs b/node_modules/es-toolkit/dist/compat/util/toFinite.mjs new file mode 100644 index 0000000000000000000000000000000000000000..17d6af0e837cef5d4efd5e303934fb9072b0b3fb --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toFinite.mjs @@ -0,0 +1,24 @@ +import { toNumber } from "./toNumber.mjs"; +//#region src/compat/util/toFinite.ts +/** +* Converts `value` to a finite number. +* +* @param value - The value to convert. +* @returns Returns the number. +* +* @example +* toFinite(3.2); // => 3.2 +* toFinite(Number.MIN_VALUE); // => 5e-324 +* toFinite(Infinity); // => 1.7976931348623157e+308 +* toFinite('3.2'); // => 3.2 +* toFinite(Symbol.iterator); // => 0 +* toFinite(NaN); // => 0 +*/ +function toFinite(value) { + if (!value) return value === 0 ? value : 0; + value = toNumber(value); + if (value === Infinity || value === -Infinity) return (value < 0 ? -1 : 1) * Number.MAX_VALUE; + return value === value ? value : 0; +} +//#endregion +export { toFinite }; diff --git a/node_modules/es-toolkit/dist/compat/util/toInteger.d.mts b/node_modules/es-toolkit/dist/compat/util/toInteger.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2e3e08b9c5432b7b1d2870d878eeaa3280db7127 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toInteger.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/util/toInteger.d.ts +/** + * Converts `value` to an integer. + * + * This function first converts `value` to a finite number. If the result has any decimal places, + * they are removed by rounding down to the nearest whole number. + * + * @param value - The value to convert. + * @returns Returns the number. + * + * @example + * toInteger(3.2); // => 3 + * toInteger(Number.MIN_VALUE); // => 0 + * toInteger(Infinity); // => 1.7976931348623157e+308 + * toInteger('3.2'); // => 3 + * toInteger(Symbol.iterator); // => 0 + * toInteger(NaN); // => 0 + */ +declare function toInteger(value: any): number; +//#endregion +export { toInteger }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toInteger.d.ts b/node_modules/es-toolkit/dist/compat/util/toInteger.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2e3e08b9c5432b7b1d2870d878eeaa3280db7127 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toInteger.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/util/toInteger.d.ts +/** + * Converts `value` to an integer. + * + * This function first converts `value` to a finite number. If the result has any decimal places, + * they are removed by rounding down to the nearest whole number. + * + * @param value - The value to convert. + * @returns Returns the number. + * + * @example + * toInteger(3.2); // => 3 + * toInteger(Number.MIN_VALUE); // => 0 + * toInteger(Infinity); // => 1.7976931348623157e+308 + * toInteger('3.2'); // => 3 + * toInteger(Symbol.iterator); // => 0 + * toInteger(NaN); // => 0 + */ +declare function toInteger(value: any): number; +//#endregion +export { toInteger }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toInteger.js b/node_modules/es-toolkit/dist/compat/util/toInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..5775aca216e242ae43b3fa267b54950e12b101b0 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toInteger.js @@ -0,0 +1,26 @@ +const require_toFinite = require("./toFinite.js"); +//#region src/compat/util/toInteger.ts +/** +* Converts `value` to an integer. +* +* This function first converts `value` to a finite number. If the result has any decimal places, +* they are removed by rounding down to the nearest whole number. +* +* @param value - The value to convert. +* @returns Returns the number. +* +* @example +* toInteger(3.2); // => 3 +* toInteger(Number.MIN_VALUE); // => 0 +* toInteger(Infinity); // => 1.7976931348623157e+308 +* toInteger('3.2'); // => 3 +* toInteger(Symbol.iterator); // => 0 +* toInteger(NaN); // => 0 +*/ +function toInteger(value) { + const finite = require_toFinite.toFinite(value); + const remainder = finite % 1; + return remainder ? finite - remainder : finite; +} +//#endregion +exports.toInteger = toInteger; diff --git a/node_modules/es-toolkit/dist/compat/util/toInteger.mjs b/node_modules/es-toolkit/dist/compat/util/toInteger.mjs new file mode 100644 index 0000000000000000000000000000000000000000..53b0af115ba46b65d9f4f08e9c9fb17ebf703782 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toInteger.mjs @@ -0,0 +1,26 @@ +import { toFinite } from "./toFinite.mjs"; +//#region src/compat/util/toInteger.ts +/** +* Converts `value` to an integer. +* +* This function first converts `value` to a finite number. If the result has any decimal places, +* they are removed by rounding down to the nearest whole number. +* +* @param value - The value to convert. +* @returns Returns the number. +* +* @example +* toInteger(3.2); // => 3 +* toInteger(Number.MIN_VALUE); // => 0 +* toInteger(Infinity); // => 1.7976931348623157e+308 +* toInteger('3.2'); // => 3 +* toInteger(Symbol.iterator); // => 0 +* toInteger(NaN); // => 0 +*/ +function toInteger(value) { + const finite = toFinite(value); + const remainder = finite % 1; + return remainder ? finite - remainder : finite; +} +//#endregion +export { toInteger }; diff --git a/node_modules/es-toolkit/dist/compat/util/toLength.d.mts b/node_modules/es-toolkit/dist/compat/util/toLength.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c7500399fbac5f548ddbd236cc0f0c7c581d4e9f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toLength.d.mts @@ -0,0 +1,20 @@ +//#region src/compat/util/toLength.d.ts +/** + * 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`. + * + * It converts the given value 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`. Values that cannot be converted to a number (such as `NaN` or non-numeric strings) return `0`. + * + * @param value - The value to convert to a valid index. + * @returns The converted value. + * + * @example + * toLength(3.2) // => 3 + * toLength(-1) // => 0 + * toLength(1.9) // => 1 + * toLength('42') // => 42 + * toLength(null) // => 0 + * toLength('a') // => 0 + */ +declare function toLength(value: any): number; +//#endregion +export { toLength }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toLength.d.ts b/node_modules/es-toolkit/dist/compat/util/toLength.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c7500399fbac5f548ddbd236cc0f0c7c581d4e9f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toLength.d.ts @@ -0,0 +1,20 @@ +//#region src/compat/util/toLength.d.ts +/** + * 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`. + * + * It converts the given value 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`. Values that cannot be converted to a number (such as `NaN` or non-numeric strings) return `0`. + * + * @param value - The value to convert to a valid index. + * @returns The converted value. + * + * @example + * toLength(3.2) // => 3 + * toLength(-1) // => 0 + * toLength(1.9) // => 1 + * toLength('42') // => 42 + * toLength(null) // => 0 + * toLength('a') // => 0 + */ +declare function toLength(value: any): number; +//#endregion +export { toLength }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toLength.js b/node_modules/es-toolkit/dist/compat/util/toLength.js new file mode 100644 index 0000000000000000000000000000000000000000..f8307ef2a35314141dfb8d6376b4674a38775f99 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toLength.js @@ -0,0 +1,26 @@ +const require_toInteger = require("./toInteger.js"); +const require_clamp = require("../math/clamp.js"); +const require_MAX_ARRAY_LENGTH = require("../_internal/MAX_ARRAY_LENGTH.js"); +//#region src/compat/util/toLength.ts +/** +* 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`. +* +* It converts the given value 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`. Values that cannot be converted to a number (such as `NaN` or non-numeric strings) return `0`. +* +* @param value - The value to convert to a valid index. +* @returns The converted value. +* +* @example +* toLength(3.2) // => 3 +* toLength(-1) // => 0 +* toLength(1.9) // => 1 +* toLength('42') // => 42 +* toLength(null) // => 0 +* toLength('a') // => 0 +*/ +function toLength(value) { + if (value == null) return 0; + return require_clamp.clamp(require_toInteger.toInteger(value), 0, require_MAX_ARRAY_LENGTH.MAX_ARRAY_LENGTH); +} +//#endregion +exports.toLength = toLength; diff --git a/node_modules/es-toolkit/dist/compat/util/toLength.mjs b/node_modules/es-toolkit/dist/compat/util/toLength.mjs new file mode 100644 index 0000000000000000000000000000000000000000..20e3e516a7e00c6d9683d5759e426cb4dae1f6d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toLength.mjs @@ -0,0 +1,26 @@ +import { toInteger } from "./toInteger.mjs"; +import { clamp } from "../math/clamp.mjs"; +import { MAX_ARRAY_LENGTH } from "../_internal/MAX_ARRAY_LENGTH.mjs"; +//#region src/compat/util/toLength.ts +/** +* 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`. +* +* It converts the given value 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`. Values that cannot be converted to a number (such as `NaN` or non-numeric strings) return `0`. +* +* @param value - The value to convert to a valid index. +* @returns The converted value. +* +* @example +* toLength(3.2) // => 3 +* toLength(-1) // => 0 +* toLength(1.9) // => 1 +* toLength('42') // => 42 +* toLength(null) // => 0 +* toLength('a') // => 0 +*/ +function toLength(value) { + if (value == null) return 0; + return clamp(toInteger(value), 0, MAX_ARRAY_LENGTH); +} +//#endregion +export { toLength }; diff --git a/node_modules/es-toolkit/dist/compat/util/toNumber.d.mts b/node_modules/es-toolkit/dist/compat/util/toNumber.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a23026831b1669ece492fa6932d9ca7f2daf0879 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toNumber.d.mts @@ -0,0 +1,20 @@ +//#region src/compat/util/toNumber.d.ts +/** + * Converts `value` to a number. + * + * Unlike `Number()`, this function returns `NaN` for symbols. + * + * @param value - The value to convert. + * @returns Returns the number. + * + * @example + * toNumber(3.2); // => 3.2 + * toNumber(Number.MIN_VALUE); // => 5e-324 + * toNumber(Infinity); // => Infinity + * toNumber('3.2'); // => 3.2 + * toNumber(Symbol.iterator); // => NaN + * toNumber(NaN); // => NaN + */ +declare function toNumber(value: any): number; +//#endregion +export { toNumber }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toNumber.d.ts b/node_modules/es-toolkit/dist/compat/util/toNumber.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a23026831b1669ece492fa6932d9ca7f2daf0879 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toNumber.d.ts @@ -0,0 +1,20 @@ +//#region src/compat/util/toNumber.d.ts +/** + * Converts `value` to a number. + * + * Unlike `Number()`, this function returns `NaN` for symbols. + * + * @param value - The value to convert. + * @returns Returns the number. + * + * @example + * toNumber(3.2); // => 3.2 + * toNumber(Number.MIN_VALUE); // => 5e-324 + * toNumber(Infinity); // => Infinity + * toNumber('3.2'); // => 3.2 + * toNumber(Symbol.iterator); // => NaN + * toNumber(NaN); // => NaN + */ +declare function toNumber(value: any): number; +//#endregion +export { toNumber }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toNumber.js b/node_modules/es-toolkit/dist/compat/util/toNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..66f6aabcb4b44bd9a51ca44f96258e963c824f27 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toNumber.js @@ -0,0 +1,24 @@ +const require_isSymbol = require("../predicate/isSymbol.js"); +//#region src/compat/util/toNumber.ts +/** +* Converts `value` to a number. +* +* Unlike `Number()`, this function returns `NaN` for symbols. +* +* @param value - The value to convert. +* @returns Returns the number. +* +* @example +* toNumber(3.2); // => 3.2 +* toNumber(Number.MIN_VALUE); // => 5e-324 +* toNumber(Infinity); // => Infinity +* toNumber('3.2'); // => 3.2 +* toNumber(Symbol.iterator); // => NaN +* toNumber(NaN); // => NaN +*/ +function toNumber(value) { + if (require_isSymbol.isSymbol(value)) return NaN; + return Number(value); +} +//#endregion +exports.toNumber = toNumber; diff --git a/node_modules/es-toolkit/dist/compat/util/toNumber.mjs b/node_modules/es-toolkit/dist/compat/util/toNumber.mjs new file mode 100644 index 0000000000000000000000000000000000000000..36043648796204a39a8610baf371860f12506a7d --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toNumber.mjs @@ -0,0 +1,24 @@ +import { isSymbol } from "../predicate/isSymbol.mjs"; +//#region src/compat/util/toNumber.ts +/** +* Converts `value` to a number. +* +* Unlike `Number()`, this function returns `NaN` for symbols. +* +* @param value - The value to convert. +* @returns Returns the number. +* +* @example +* toNumber(3.2); // => 3.2 +* toNumber(Number.MIN_VALUE); // => 5e-324 +* toNumber(Infinity); // => Infinity +* toNumber('3.2'); // => 3.2 +* toNumber(Symbol.iterator); // => NaN +* toNumber(NaN); // => NaN +*/ +function toNumber(value) { + if (isSymbol(value)) return NaN; + return Number(value); +} +//#endregion +export { toNumber }; diff --git a/node_modules/es-toolkit/dist/compat/util/toPath.d.mts b/node_modules/es-toolkit/dist/compat/util/toPath.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..828ba5e1e46f66e6bf6f3f4ee2c23b60a3778fe2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toPath.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/util/toPath.d.ts +/** + * Converts a deep key string into an array of path segments. + * + * 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. + * + * @param deepKey - The deep key string to convert. + * @returns An array of strings, each representing a segment of the path. + * + * Examples: + * + * toPath('a.b.c') // Returns ['a', 'b', 'c'] + * toPath('a[b][c]') // Returns ['a', 'b', 'c'] + * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c'] + * toPath('a["b.c"].d') // Returns ['a', 'b.c', 'd'] + * toPath('') // Returns [] + * toPath('.a[b].c.d[e]["f.g"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h'] + */ +declare function toPath(deepKey: any): string[]; +//#endregion +export { toPath }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toPath.d.ts b/node_modules/es-toolkit/dist/compat/util/toPath.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..828ba5e1e46f66e6bf6f3f4ee2c23b60a3778fe2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toPath.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/util/toPath.d.ts +/** + * Converts a deep key string into an array of path segments. + * + * 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. + * + * @param deepKey - The deep key string to convert. + * @returns An array of strings, each representing a segment of the path. + * + * Examples: + * + * toPath('a.b.c') // Returns ['a', 'b', 'c'] + * toPath('a[b][c]') // Returns ['a', 'b', 'c'] + * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c'] + * toPath('a["b.c"].d') // Returns ['a', 'b.c', 'd'] + * toPath('') // Returns [] + * toPath('.a[b].c.d[e]["f.g"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h'] + */ +declare function toPath(deepKey: any): string[]; +//#endregion +export { toPath }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toPath.js b/node_modules/es-toolkit/dist/compat/util/toPath.js new file mode 100644 index 0000000000000000000000000000000000000000..68cc4973e89de4b8d1e21420277d6793a36bd7ee --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toPath.js @@ -0,0 +1,66 @@ +const require_toKey = require("../_internal/toKey.js"); +const require_toString = require("./toString.js"); +//#region src/compat/util/toPath.ts +/** +* Converts a deep key string into an array of path segments. +* +* 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. +* +* @param deepKey - The deep key string to convert. +* @returns An array of strings, each representing a segment of the path. +* +* Examples: +* +* toPath('a.b.c') // Returns ['a', 'b', 'c'] +* toPath('a[b][c]') // Returns ['a', 'b', 'c'] +* toPath('.a.b.c') // Returns ['', 'a', 'b', 'c'] +* toPath('a["b.c"].d') // Returns ['a', 'b.c', 'd'] +* toPath('') // Returns [] +* toPath('.a[b].c.d[e]["f.g"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h'] +*/ +function toPath(deepKey) { + if (Array.isArray(deepKey)) return deepKey.map(require_toKey.toKey); + if (typeof deepKey === "symbol") return [deepKey]; + deepKey = require_toString.toString(deepKey); + const result = []; + const length = deepKey.length; + if (length === 0) return result; + let index = 0; + let key = ""; + let quoteChar = ""; + let bracket = false; + if (deepKey.charCodeAt(0) === 46) result.push(""); + while (index < length) { + const char = deepKey[index]; + if (quoteChar) if (char === "\\" && index + 1 < length) { + index++; + key += deepKey[index]; + } else if (char === quoteChar) quoteChar = ""; + else key += char; + else if (bracket) if (char === "\"" || char === "'") quoteChar = char; + else if (char === "]") { + bracket = false; + result.push(key); + key = ""; + } else key += char; + else if (char === "[") { + bracket = true; + if (key) { + result.push(key); + key = ""; + } + } else if (char === ".") { + if (key) { + result.push(key); + key = ""; + } + const next = deepKey[index + 1]; + if (next === void 0 || next === ".") result.push(""); + } else key += char; + index++; + } + if (key) result.push(key); + return result; +} +//#endregion +exports.toPath = toPath; diff --git a/node_modules/es-toolkit/dist/compat/util/toPath.mjs b/node_modules/es-toolkit/dist/compat/util/toPath.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8ea94013cb22cef6f8837d041090de54dbcb9acd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toPath.mjs @@ -0,0 +1,66 @@ +import { toKey } from "../_internal/toKey.mjs"; +import { toString } from "./toString.mjs"; +//#region src/compat/util/toPath.ts +/** +* Converts a deep key string into an array of path segments. +* +* 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. +* +* @param deepKey - The deep key string to convert. +* @returns An array of strings, each representing a segment of the path. +* +* Examples: +* +* toPath('a.b.c') // Returns ['a', 'b', 'c'] +* toPath('a[b][c]') // Returns ['a', 'b', 'c'] +* toPath('.a.b.c') // Returns ['', 'a', 'b', 'c'] +* toPath('a["b.c"].d') // Returns ['a', 'b.c', 'd'] +* toPath('') // Returns [] +* toPath('.a[b].c.d[e]["f.g"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h'] +*/ +function toPath(deepKey) { + if (Array.isArray(deepKey)) return deepKey.map(toKey); + if (typeof deepKey === "symbol") return [deepKey]; + deepKey = toString(deepKey); + const result = []; + const length = deepKey.length; + if (length === 0) return result; + let index = 0; + let key = ""; + let quoteChar = ""; + let bracket = false; + if (deepKey.charCodeAt(0) === 46) result.push(""); + while (index < length) { + const char = deepKey[index]; + if (quoteChar) if (char === "\\" && index + 1 < length) { + index++; + key += deepKey[index]; + } else if (char === quoteChar) quoteChar = ""; + else key += char; + else if (bracket) if (char === "\"" || char === "'") quoteChar = char; + else if (char === "]") { + bracket = false; + result.push(key); + key = ""; + } else key += char; + else if (char === "[") { + bracket = true; + if (key) { + result.push(key); + key = ""; + } + } else if (char === ".") { + if (key) { + result.push(key); + key = ""; + } + const next = deepKey[index + 1]; + if (next === void 0 || next === ".") result.push(""); + } else key += char; + index++; + } + if (key) result.push(key); + return result; +} +//#endregion +export { toPath }; diff --git a/node_modules/es-toolkit/dist/compat/util/toPlainObject.d.mts b/node_modules/es-toolkit/dist/compat/util/toPlainObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..cc8a7069fae4d18c7086cd15676dfc1aad7f25c4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toPlainObject.d.mts @@ -0,0 +1,17 @@ +//#region src/compat/util/toPlainObject.d.ts +/** + * Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object. + * + * @param value The value to convert. + * @returns Returns the converted plain object. + * + * @example + * function Foo() { + * this.b = 2; + * } + * Foo.prototype.c = 3; + * toPlainObject(new Foo()); // { b: 2, c: 3 } + */ +declare function toPlainObject(value?: any): any; +//#endregion +export { toPlainObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toPlainObject.d.ts b/node_modules/es-toolkit/dist/compat/util/toPlainObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc8a7069fae4d18c7086cd15676dfc1aad7f25c4 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toPlainObject.d.ts @@ -0,0 +1,17 @@ +//#region src/compat/util/toPlainObject.d.ts +/** + * Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object. + * + * @param value The value to convert. + * @returns Returns the converted plain object. + * + * @example + * function Foo() { + * this.b = 2; + * } + * Foo.prototype.c = 3; + * toPlainObject(new Foo()); // { b: 2, c: 3 } + */ +declare function toPlainObject(value?: any): any; +//#endregion +export { toPlainObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toPlainObject.js b/node_modules/es-toolkit/dist/compat/util/toPlainObject.js new file mode 100644 index 0000000000000000000000000000000000000000..91c0269fa167bc45416d1fc4313fbead02d78617 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toPlainObject.js @@ -0,0 +1,33 @@ +const require_keysIn = require("../object/keysIn.js"); +//#region src/compat/util/toPlainObject.ts +/** +* Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object. +* +* @param value The value to convert. +* @returns Returns the converted plain object. +* +* @example +* function Foo() { +* this.b = 2; +* } +* Foo.prototype.c = 3; +* toPlainObject(new Foo()); // { b: 2, c: 3 } +*/ +function toPlainObject(value) { + const plainObject = {}; + const valueKeys = require_keysIn.keysIn(value); + for (let i = 0; i < valueKeys.length; i++) { + const key = valueKeys[i]; + const objValue = value[key]; + if (key === "__proto__") Object.defineProperty(plainObject, key, { + configurable: true, + enumerable: true, + value: objValue, + writable: true + }); + else plainObject[key] = objValue; + } + return plainObject; +} +//#endregion +exports.toPlainObject = toPlainObject; diff --git a/node_modules/es-toolkit/dist/compat/util/toPlainObject.mjs b/node_modules/es-toolkit/dist/compat/util/toPlainObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1b91dce6f8d25af9f1f7c8264d14fdaaad6c384f --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toPlainObject.mjs @@ -0,0 +1,33 @@ +import { keysIn } from "../object/keysIn.mjs"; +//#region src/compat/util/toPlainObject.ts +/** +* Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object. +* +* @param value The value to convert. +* @returns Returns the converted plain object. +* +* @example +* function Foo() { +* this.b = 2; +* } +* Foo.prototype.c = 3; +* toPlainObject(new Foo()); // { b: 2, c: 3 } +*/ +function toPlainObject(value) { + const plainObject = {}; + const valueKeys = keysIn(value); + for (let i = 0; i < valueKeys.length; i++) { + const key = valueKeys[i]; + const objValue = value[key]; + if (key === "__proto__") Object.defineProperty(plainObject, key, { + configurable: true, + enumerable: true, + value: objValue, + writable: true + }); + else plainObject[key] = objValue; + } + return plainObject; +} +//#endregion +export { toPlainObject }; diff --git a/node_modules/es-toolkit/dist/compat/util/toSafeInteger.d.mts b/node_modules/es-toolkit/dist/compat/util/toSafeInteger.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c7d01175f62846b6c005548ef8a0fc45d849eacd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toSafeInteger.d.mts @@ -0,0 +1,21 @@ +//#region src/compat/util/toSafeInteger.d.ts +/** + * Converts `value` to a safe integer. + * + * A safe integer can be compared and represented correctly. + * + * @param value - The value to convert. + * @returns Returns the value converted to a safe integer. + * + * @example + * toSafeInteger(3.2); // => 3 + * toSafeInteger(Number.MAX_VALUE); // => 9007199254740991 + * toSafeInteger(Infinity); // => 9007199254740991 + * toSafeInteger('3.2'); // => 3 + * toSafeInteger(NaN); // => 0 + * toSafeInteger(null); // => 0 + * toSafeInteger(-Infinity); // => -9007199254740991 + */ +declare function toSafeInteger(value: any): number; +//#endregion +export { toSafeInteger }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toSafeInteger.d.ts b/node_modules/es-toolkit/dist/compat/util/toSafeInteger.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c7d01175f62846b6c005548ef8a0fc45d849eacd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toSafeInteger.d.ts @@ -0,0 +1,21 @@ +//#region src/compat/util/toSafeInteger.d.ts +/** + * Converts `value` to a safe integer. + * + * A safe integer can be compared and represented correctly. + * + * @param value - The value to convert. + * @returns Returns the value converted to a safe integer. + * + * @example + * toSafeInteger(3.2); // => 3 + * toSafeInteger(Number.MAX_VALUE); // => 9007199254740991 + * toSafeInteger(Infinity); // => 9007199254740991 + * toSafeInteger('3.2'); // => 3 + * toSafeInteger(NaN); // => 0 + * toSafeInteger(null); // => 0 + * toSafeInteger(-Infinity); // => -9007199254740991 + */ +declare function toSafeInteger(value: any): number; +//#endregion +export { toSafeInteger }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toSafeInteger.js b/node_modules/es-toolkit/dist/compat/util/toSafeInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..92a5804fd5c7327e4c4904e60b585dbd0cefa286 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toSafeInteger.js @@ -0,0 +1,27 @@ +const require_toInteger = require("./toInteger.js"); +const require_clamp = require("../math/clamp.js"); +const require_MAX_SAFE_INTEGER = require("../_internal/MAX_SAFE_INTEGER.js"); +//#region src/compat/util/toSafeInteger.ts +/** +* Converts `value` to a safe integer. +* +* A safe integer can be compared and represented correctly. +* +* @param value - The value to convert. +* @returns Returns the value converted to a safe integer. +* +* @example +* toSafeInteger(3.2); // => 3 +* toSafeInteger(Number.MAX_VALUE); // => 9007199254740991 +* toSafeInteger(Infinity); // => 9007199254740991 +* toSafeInteger('3.2'); // => 3 +* toSafeInteger(NaN); // => 0 +* toSafeInteger(null); // => 0 +* toSafeInteger(-Infinity); // => -9007199254740991 +*/ +function toSafeInteger(value) { + if (value == null) return 0; + return require_clamp.clamp(require_toInteger.toInteger(value), -require_MAX_SAFE_INTEGER.MAX_SAFE_INTEGER, require_MAX_SAFE_INTEGER.MAX_SAFE_INTEGER); +} +//#endregion +exports.toSafeInteger = toSafeInteger; diff --git a/node_modules/es-toolkit/dist/compat/util/toSafeInteger.mjs b/node_modules/es-toolkit/dist/compat/util/toSafeInteger.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1dae054f08418a974989379b5449fe083793f7b2 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toSafeInteger.mjs @@ -0,0 +1,27 @@ +import { toInteger } from "./toInteger.mjs"; +import { clamp } from "../math/clamp.mjs"; +import { MAX_SAFE_INTEGER } from "../_internal/MAX_SAFE_INTEGER.mjs"; +//#region src/compat/util/toSafeInteger.ts +/** +* Converts `value` to a safe integer. +* +* A safe integer can be compared and represented correctly. +* +* @param value - The value to convert. +* @returns Returns the value converted to a safe integer. +* +* @example +* toSafeInteger(3.2); // => 3 +* toSafeInteger(Number.MAX_VALUE); // => 9007199254740991 +* toSafeInteger(Infinity); // => 9007199254740991 +* toSafeInteger('3.2'); // => 3 +* toSafeInteger(NaN); // => 0 +* toSafeInteger(null); // => 0 +* toSafeInteger(-Infinity); // => -9007199254740991 +*/ +function toSafeInteger(value) { + if (value == null) return 0; + return clamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER); +} +//#endregion +export { toSafeInteger }; diff --git a/node_modules/es-toolkit/dist/compat/util/toString.d.mts b/node_modules/es-toolkit/dist/compat/util/toString.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9cda5c229d10f92dafb2e65138d3a1dd20483c7a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toString.d.mts @@ -0,0 +1,20 @@ +//#region src/compat/util/toString.d.ts +/** + * Converts `value` to a string. + * + * An empty string is returned for `null` and `undefined` values. + * The sign of `-0` is preserved. + * + * @param value - The value to convert. + * @returns Returns the converted string. + * + * @example + * toString(null) // returns '' + * toString(undefined) // returns '' + * toString(-0) // returns '-0' + * toString([1, 2, -0]) // returns '1,2,-0' + * toString([Symbol('a'), Symbol('b')]) // returns 'Symbol(a),Symbol(b)' + */ +declare function toString(value: any): string; +//#endregion +export { toString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toString.d.ts b/node_modules/es-toolkit/dist/compat/util/toString.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9cda5c229d10f92dafb2e65138d3a1dd20483c7a --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toString.d.ts @@ -0,0 +1,20 @@ +//#region src/compat/util/toString.d.ts +/** + * Converts `value` to a string. + * + * An empty string is returned for `null` and `undefined` values. + * The sign of `-0` is preserved. + * + * @param value - The value to convert. + * @returns Returns the converted string. + * + * @example + * toString(null) // returns '' + * toString(undefined) // returns '' + * toString(-0) // returns '-0' + * toString([1, 2, -0]) // returns '1,2,-0' + * toString([Symbol('a'), Symbol('b')]) // returns 'Symbol(a),Symbol(b)' + */ +declare function toString(value: any): string; +//#endregion +export { toString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/toString.js b/node_modules/es-toolkit/dist/compat/util/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..80c15a8174f2a29b1cbaad853e955c0304d19cbd --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toString.js @@ -0,0 +1,27 @@ +//#region src/compat/util/toString.ts +/** +* Converts `value` to a string. +* +* An empty string is returned for `null` and `undefined` values. +* The sign of `-0` is preserved. +* +* @param value - The value to convert. +* @returns Returns the converted string. +* +* @example +* toString(null) // returns '' +* toString(undefined) // returns '' +* toString(-0) // returns '-0' +* toString([1, 2, -0]) // returns '1,2,-0' +* toString([Symbol('a'), Symbol('b')]) // returns 'Symbol(a),Symbol(b)' +*/ +function toString(value) { + if (value == null) return ""; + if (typeof value === "string") return value; + if (Array.isArray(value)) return value.map(toString).join(","); + const result = String(value); + if (result === "0" && Object.is(Number(value), -0)) return "-0"; + return result; +} +//#endregion +exports.toString = toString; diff --git a/node_modules/es-toolkit/dist/compat/util/toString.mjs b/node_modules/es-toolkit/dist/compat/util/toString.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8fc3004aa16b19bd59cef1a5fe774744cd25ef96 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/toString.mjs @@ -0,0 +1,27 @@ +//#region src/compat/util/toString.ts +/** +* Converts `value` to a string. +* +* An empty string is returned for `null` and `undefined` values. +* The sign of `-0` is preserved. +* +* @param value - The value to convert. +* @returns Returns the converted string. +* +* @example +* toString(null) // returns '' +* toString(undefined) // returns '' +* toString(-0) // returns '-0' +* toString([1, 2, -0]) // returns '1,2,-0' +* toString([Symbol('a'), Symbol('b')]) // returns 'Symbol(a),Symbol(b)' +*/ +function toString(value) { + if (value == null) return ""; + if (typeof value === "string") return value; + if (Array.isArray(value)) return value.map(toString).join(","); + const result = String(value); + if (result === "0" && Object.is(Number(value), -0)) return "-0"; + return result; +} +//#endregion +export { toString }; diff --git a/node_modules/es-toolkit/dist/compat/util/uniqueId.d.mts b/node_modules/es-toolkit/dist/compat/util/uniqueId.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..887c29531690bd989606a2461fa937f139d5260b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/uniqueId.d.mts @@ -0,0 +1,26 @@ +//#region src/compat/util/uniqueId.d.ts +/** + * Generates a unique identifier, optionally prefixed with a given string. + * + * @param [prefix] - An optional string to prefix the unique identifier. + * If not provided or not a string, only the unique + * numeric identifier is returned. + * @returns A string containing the unique identifier, with the optional + * prefix if provided. + * + * @example + * // Generate a unique ID with a prefix + * uniqueId('user_'); // => 'user_1' + * + * @example + * // Generate a unique ID without a prefix + * uniqueId(); // => '2' + * + * @example + * // Subsequent calls increment the internal counter + * uniqueId('item_'); // => 'item_3' + * uniqueId(); // => '4' + */ +declare function uniqueId(prefix?: string): string; +//#endregion +export { uniqueId }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/uniqueId.d.ts b/node_modules/es-toolkit/dist/compat/util/uniqueId.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..887c29531690bd989606a2461fa937f139d5260b --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/uniqueId.d.ts @@ -0,0 +1,26 @@ +//#region src/compat/util/uniqueId.d.ts +/** + * Generates a unique identifier, optionally prefixed with a given string. + * + * @param [prefix] - An optional string to prefix the unique identifier. + * If not provided or not a string, only the unique + * numeric identifier is returned. + * @returns A string containing the unique identifier, with the optional + * prefix if provided. + * + * @example + * // Generate a unique ID with a prefix + * uniqueId('user_'); // => 'user_1' + * + * @example + * // Generate a unique ID without a prefix + * uniqueId(); // => '2' + * + * @example + * // Subsequent calls increment the internal counter + * uniqueId('item_'); // => 'item_3' + * uniqueId(); // => '4' + */ +declare function uniqueId(prefix?: string): string; +//#endregion +export { uniqueId }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/compat/util/uniqueId.js b/node_modules/es-toolkit/dist/compat/util/uniqueId.js new file mode 100644 index 0000000000000000000000000000000000000000..f74e57026dd1c07d91945d2371b9df8f3c9cc491 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/uniqueId.js @@ -0,0 +1,30 @@ +//#region src/compat/util/uniqueId.ts +/** Counter used to generate unique numeric identifiers. */ +let idCounter = 0; +/** +* Generates a unique identifier, optionally prefixed with a given string. +* +* @param [prefix] - An optional string to prefix the unique identifier. +* If not provided or not a string, only the unique +* numeric identifier is returned. +* @returns A string containing the unique identifier, with the optional +* prefix if provided. +* +* @example +* // Generate a unique ID with a prefix +* uniqueId('user_'); // => 'user_1' +* +* @example +* // Generate a unique ID without a prefix +* uniqueId(); // => '2' +* +* @example +* // Subsequent calls increment the internal counter +* uniqueId('item_'); // => 'item_3' +* uniqueId(); // => '4' +*/ +function uniqueId(prefix = "") { + return `${prefix}${++idCounter}`; +} +//#endregion +exports.uniqueId = uniqueId; diff --git a/node_modules/es-toolkit/dist/compat/util/uniqueId.mjs b/node_modules/es-toolkit/dist/compat/util/uniqueId.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d40505874703057e3c6a4d914b6317b7563fc488 --- /dev/null +++ b/node_modules/es-toolkit/dist/compat/util/uniqueId.mjs @@ -0,0 +1,30 @@ +//#region src/compat/util/uniqueId.ts +/** Counter used to generate unique numeric identifiers. */ +let idCounter = 0; +/** +* Generates a unique identifier, optionally prefixed with a given string. +* +* @param [prefix] - An optional string to prefix the unique identifier. +* If not provided or not a string, only the unique +* numeric identifier is returned. +* @returns A string containing the unique identifier, with the optional +* prefix if provided. +* +* @example +* // Generate a unique ID with a prefix +* uniqueId('user_'); // => 'user_1' +* +* @example +* // Generate a unique ID without a prefix +* uniqueId(); // => '2' +* +* @example +* // Subsequent calls increment the internal counter +* uniqueId('item_'); // => 'item_3' +* uniqueId(); // => '4' +*/ +function uniqueId(prefix = "") { + return `${prefix}${++idCounter}`; +} +//#endregion +export { uniqueId }; diff --git a/node_modules/es-toolkit/dist/error/AbortError.d.mts b/node_modules/es-toolkit/dist/error/AbortError.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bac4e99ff420adebece7bd889bd8f804d28f659d --- /dev/null +++ b/node_modules/es-toolkit/dist/error/AbortError.d.mts @@ -0,0 +1,12 @@ +import { DOMException } from "../_internal/DOMException.mjs"; + +//#region src/error/AbortError.d.ts +/** + * An error class representing an aborted operation. + * @augments DOMException + */ +declare class AbortError extends DOMException { + constructor(message?: string); +} +//#endregion +export { AbortError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/error/AbortError.d.ts b/node_modules/es-toolkit/dist/error/AbortError.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..be46c2509ec9442df75daed96612f81c83b6cef3 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/AbortError.d.ts @@ -0,0 +1,12 @@ +import { DOMException } from "../_internal/DOMException.js"; + +//#region src/error/AbortError.d.ts +/** + * An error class representing an aborted operation. + * @augments DOMException + */ +declare class AbortError extends DOMException { + constructor(message?: string); +} +//#endregion +export { AbortError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/error/AbortError.js b/node_modules/es-toolkit/dist/error/AbortError.js new file mode 100644 index 0000000000000000000000000000000000000000..8427b37492a4492a771996e195c6b2db94819cf2 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/AbortError.js @@ -0,0 +1,13 @@ +const require_DOMException = require("../_internal/DOMException.js"); +//#region src/error/AbortError.ts +/** +* An error class representing an aborted operation. +* @augments DOMException +*/ +var AbortError = class extends require_DOMException.DOMException { + constructor(message = "The operation was aborted") { + super(message); + } +}; +//#endregion +exports.AbortError = AbortError; diff --git a/node_modules/es-toolkit/dist/error/AbortError.mjs b/node_modules/es-toolkit/dist/error/AbortError.mjs new file mode 100644 index 0000000000000000000000000000000000000000..69999eab31e401f36d5e28348152aa78cc0044d4 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/AbortError.mjs @@ -0,0 +1,13 @@ +import { DOMException } from "../_internal/DOMException.mjs"; +//#region src/error/AbortError.ts +/** +* An error class representing an aborted operation. +* @augments DOMException +*/ +var AbortError = class extends DOMException { + constructor(message = "The operation was aborted") { + super(message); + } +}; +//#endregion +export { AbortError }; diff --git a/node_modules/es-toolkit/dist/error/TimeoutError.d.mts b/node_modules/es-toolkit/dist/error/TimeoutError.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ec15da04004465b513e31432364963c1f95cc614 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/TimeoutError.d.mts @@ -0,0 +1,12 @@ +import { DOMException } from "../_internal/DOMException.mjs"; + +//#region src/error/TimeoutError.d.ts +/** + * An error class representing a timeout operation. + * @augments DOMException + */ +declare class TimeoutError extends DOMException { + constructor(message?: string); +} +//#endregion +export { TimeoutError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/error/TimeoutError.d.ts b/node_modules/es-toolkit/dist/error/TimeoutError.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c52fe5eae7252c1810ea9610846f9384f465b86 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/TimeoutError.d.ts @@ -0,0 +1,12 @@ +import { DOMException } from "../_internal/DOMException.js"; + +//#region src/error/TimeoutError.d.ts +/** + * An error class representing a timeout operation. + * @augments DOMException + */ +declare class TimeoutError extends DOMException { + constructor(message?: string); +} +//#endregion +export { TimeoutError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/error/TimeoutError.js b/node_modules/es-toolkit/dist/error/TimeoutError.js new file mode 100644 index 0000000000000000000000000000000000000000..cb4f170ad6fd73e78feaceea6362b32a7b648396 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/TimeoutError.js @@ -0,0 +1,13 @@ +const require_DOMException = require("../_internal/DOMException.js"); +//#region src/error/TimeoutError.ts +/** +* An error class representing a timeout operation. +* @augments DOMException +*/ +var TimeoutError = class extends require_DOMException.DOMException { + constructor(message = "The operation was timed out") { + super(message); + } +}; +//#endregion +exports.TimeoutError = TimeoutError; diff --git a/node_modules/es-toolkit/dist/error/TimeoutError.mjs b/node_modules/es-toolkit/dist/error/TimeoutError.mjs new file mode 100644 index 0000000000000000000000000000000000000000..24c00c7bdf9d2cbbcc78e118d7c484906603d1d6 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/TimeoutError.mjs @@ -0,0 +1,13 @@ +import { DOMException } from "../_internal/DOMException.mjs"; +//#region src/error/TimeoutError.ts +/** +* An error class representing a timeout operation. +* @augments DOMException +*/ +var TimeoutError = class extends DOMException { + constructor(message = "The operation was timed out") { + super(message); + } +}; +//#endregion +export { TimeoutError }; diff --git a/node_modules/es-toolkit/dist/error/index.d.mts b/node_modules/es-toolkit/dist/error/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9faec5976fd7671f46ca4231deb86d5b55ceb902 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/index.d.mts @@ -0,0 +1,3 @@ +import { AbortError } from "./AbortError.mjs"; +import { TimeoutError } from "./TimeoutError.mjs"; +export { AbortError, TimeoutError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/error/index.d.ts b/node_modules/es-toolkit/dist/error/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dd25ebf43f67eb40be4b796000392f58593413d1 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/index.d.ts @@ -0,0 +1,3 @@ +import { AbortError } from "./AbortError.js"; +import { TimeoutError } from "./TimeoutError.js"; +export { AbortError, TimeoutError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/error/index.js b/node_modules/es-toolkit/dist/error/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a8c7140ac291c4cb1533a97f38defad1c653d197 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/index.js @@ -0,0 +1,5 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_AbortError = require("./AbortError.js"); +const require_TimeoutError = require("./TimeoutError.js"); +exports.AbortError = require_AbortError.AbortError; +exports.TimeoutError = require_TimeoutError.TimeoutError; diff --git a/node_modules/es-toolkit/dist/error/index.mjs b/node_modules/es-toolkit/dist/error/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..55c7f7a844c096da790e577d502105e4d3fc0dd1 --- /dev/null +++ b/node_modules/es-toolkit/dist/error/index.mjs @@ -0,0 +1,3 @@ +import { AbortError } from "./AbortError.mjs"; +import { TimeoutError } from "./TimeoutError.mjs"; +export { AbortError, TimeoutError }; diff --git a/node_modules/es-toolkit/dist/fp/_internal/lazy.js b/node_modules/es-toolkit/dist/fp/_internal/lazy.js new file mode 100644 index 0000000000000000000000000000000000000000..2a099e936df56ae4bc56efdaf992a627c14ee89d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/_internal/lazy.js @@ -0,0 +1,58 @@ +//#region src/fp/_internal/lazy.ts +/** +* Pairs an eager data-last function with a lazy transform (see +* {@link createLazyFunction}). +* +* The returned function behaves exactly like `eager` when called directly. When +* placed inside a {@link pipe}, the attached transform lets `pipe` fuse it with +* adjacent lazy functions into a single, short-circuiting pass. +* +* @template Eager - The eager data-last function type. +* @param eager - The eager `(array) => result` implementation. +* @param lazy - The lazy transform built by {@link createLazyFunction}. +* @param options - Set `shortCircuit: true` for functions that can end a run early. +* @returns `eager`, augmented in place with the lazy metadata. +*/ +function combineEagerAndLazyFunctions(eager, lazy, { shortCircuit } = {}) { + return Object.assign(eager, { + lazy, + shortCircuit + }); +} +/** +* Builds a {@link LazyTransform} from a per-element `step`. +* +* `step` receives each input `value`, its zero-based `index` within this stage, +* and an `emit` callback that forwards a result to the next stage. Call `emit` +* zero times (drop), once (`map`), or many times (`flatMap`). Return +* `false` to end the run after this element (used by short-circuiting functions +* like `take`); returning nothing continues. +* +* @template T - The type of values entering this stage. +* @template U - The type of values it emits. +* @param step - The per-element push function. +* @returns A lazy transform that `pipe` can fuse and drive. +* +* @example +* // map +* createLazyFunction((value, index, emit) => { +* emit(callback(value, index)); +* }); +*/ +function createLazyFunction(step) { + return (emit) => { + let index = 0; + let active = true; + const _emit = (value) => { + if (!active) return; + if (emit(value) === false) active = false; + }; + return (value) => { + if (step(value, index++, _emit) === false) active = false; + return active; + }; + }; +} +//#endregion +exports.combineEagerAndLazyFunctions = combineEagerAndLazyFunctions; +exports.createLazyFunction = createLazyFunction; diff --git a/node_modules/es-toolkit/dist/fp/_internal/lazy.mjs b/node_modules/es-toolkit/dist/fp/_internal/lazy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0a3c8d418380572224e165a31bdd73b7c267d1fe --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/_internal/lazy.mjs @@ -0,0 +1,57 @@ +//#region src/fp/_internal/lazy.ts +/** +* Pairs an eager data-last function with a lazy transform (see +* {@link createLazyFunction}). +* +* The returned function behaves exactly like `eager` when called directly. When +* placed inside a {@link pipe}, the attached transform lets `pipe` fuse it with +* adjacent lazy functions into a single, short-circuiting pass. +* +* @template Eager - The eager data-last function type. +* @param eager - The eager `(array) => result` implementation. +* @param lazy - The lazy transform built by {@link createLazyFunction}. +* @param options - Set `shortCircuit: true` for functions that can end a run early. +* @returns `eager`, augmented in place with the lazy metadata. +*/ +function combineEagerAndLazyFunctions(eager, lazy, { shortCircuit } = {}) { + return Object.assign(eager, { + lazy, + shortCircuit + }); +} +/** +* Builds a {@link LazyTransform} from a per-element `step`. +* +* `step` receives each input `value`, its zero-based `index` within this stage, +* and an `emit` callback that forwards a result to the next stage. Call `emit` +* zero times (drop), once (`map`), or many times (`flatMap`). Return +* `false` to end the run after this element (used by short-circuiting functions +* like `take`); returning nothing continues. +* +* @template T - The type of values entering this stage. +* @template U - The type of values it emits. +* @param step - The per-element push function. +* @returns A lazy transform that `pipe` can fuse and drive. +* +* @example +* // map +* createLazyFunction((value, index, emit) => { +* emit(callback(value, index)); +* }); +*/ +function createLazyFunction(step) { + return (emit) => { + let index = 0; + let active = true; + const _emit = (value) => { + if (!active) return; + if (emit(value) === false) active = false; + }; + return (value) => { + if (step(value, index++, _emit) === false) active = false; + return active; + }; + }; +} +//#endregion +export { combineEagerAndLazyFunctions, createLazyFunction }; diff --git a/node_modules/es-toolkit/dist/fp/array/at.d.mts b/node_modules/es-toolkit/dist/fp/array/at.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1f42600abd6249bb4d73a518a1dc02e807142751 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/at.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/at.d.ts +/** + * Creates a function that retrieves elements from the piped array at the specified indices. + * + * Negative indices count back from the end of the array, matching the main {@link at} + * implementation. Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param indices - The indices of the elements to retrieve from the piped array. + * @returns A function that maps a readonly array to a new array of selected values. + * + * @example + * import { at, pipe } from 'es-toolkit/fp'; + * + * pipe([10, 20, 30, 40], at([1, -1])); + * // => [20, 40] + */ +declare function at(indices: number[]): (array: readonly T[]) => T[]; +//#endregion +export { at }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/at.d.ts b/node_modules/es-toolkit/dist/fp/array/at.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f42600abd6249bb4d73a518a1dc02e807142751 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/at.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/at.d.ts +/** + * Creates a function that retrieves elements from the piped array at the specified indices. + * + * Negative indices count back from the end of the array, matching the main {@link at} + * implementation. Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param indices - The indices of the elements to retrieve from the piped array. + * @returns A function that maps a readonly array to a new array of selected values. + * + * @example + * import { at, pipe } from 'es-toolkit/fp'; + * + * pipe([10, 20, 30, 40], at([1, -1])); + * // => [20, 40] + */ +declare function at(indices: number[]): (array: readonly T[]) => T[]; +//#endregion +export { at }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/at.js b/node_modules/es-toolkit/dist/fp/array/at.js new file mode 100644 index 0000000000000000000000000000000000000000..a98741136ebffa42a297991627e98ce3cd4cd5ed --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/at.js @@ -0,0 +1,25 @@ +const require_at = require("../../array/at.js"); +//#region src/fp/array/at.ts +/** +* Creates a function that retrieves elements from the piped array at the specified indices. +* +* Negative indices count back from the end of the array, matching the main {@link at} +* implementation. Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param indices - The indices of the elements to retrieve from the piped array. +* @returns A function that maps a readonly array to a new array of selected values. +* +* @example +* import { at, pipe } from 'es-toolkit/fp'; +* +* pipe([10, 20, 30, 40], at([1, -1])); +* // => [20, 40] +*/ +function at(indices) { + return function(array) { + return require_at.at(array, indices); + }; +} +//#endregion +exports.at = at; diff --git a/node_modules/es-toolkit/dist/fp/array/at.mjs b/node_modules/es-toolkit/dist/fp/array/at.mjs new file mode 100644 index 0000000000000000000000000000000000000000..403ae0cc7b6a30086049c1dba8f675cf7bc9959e --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/at.mjs @@ -0,0 +1,25 @@ +import { at as at$1 } from "../../array/at.mjs"; +//#region src/fp/array/at.ts +/** +* Creates a function that retrieves elements from the piped array at the specified indices. +* +* Negative indices count back from the end of the array, matching the main {@link at} +* implementation. Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param indices - The indices of the elements to retrieve from the piped array. +* @returns A function that maps a readonly array to a new array of selected values. +* +* @example +* import { at, pipe } from 'es-toolkit/fp'; +* +* pipe([10, 20, 30, 40], at([1, -1])); +* // => [20, 40] +*/ +function at(indices) { + return function(array) { + return at$1(array, indices); + }; +} +//#endregion +export { at }; diff --git a/node_modules/es-toolkit/dist/fp/array/cartesianProduct.d.mts b/node_modules/es-toolkit/dist/fp/array/cartesianProduct.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c47e7e018c9980ed450a1a70cad6568f01222288 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/cartesianProduct.d.mts @@ -0,0 +1,61 @@ +//#region src/fp/array/cartesianProduct.d.ts +/** + * Creates a function that wraps each element of the piped array in a one-item tuple. + * + * @template T - The type of elements in the piped array. + * @returns A function that maps the piped array to one-item cartesian product tuples. + * + * @example + * import { cartesianProduct, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2], cartesianProduct()); + * // => [[1], [2]] + */ +declare function cartesianProduct(): (array: readonly T[]) => Array<[T]>; +/** + * Creates a function that computes the cartesian product of the piped array and one configured array. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the configured array. + * @param arr2 - The second array in the cartesian product. + * @returns A function that maps the piped array to two-item cartesian product tuples. + * + * @example + * pipe([1, 2], cartesianProduct(['a', 'b'])); + * // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] + */ +declare function cartesianProduct(arr2: readonly U[]): (array: readonly T[]) => Array<[T, U]>; +/** + * Creates a function that computes the cartesian product of the piped array and two configured arrays. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @param arr2 - The second array in the cartesian product. + * @param arr3 - The third array in the cartesian product. + * @returns A function that maps the piped array to three-item cartesian product tuples. + */ +declare function cartesianProduct(arr2: readonly U[], arr3: readonly V[]): (array: readonly T[]) => Array<[T, U, V]>; +/** + * Creates a function that computes the cartesian product of the piped array and three configured arrays. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @template W - The type of elements in the fourth array. + * @param arr2 - The second array in the cartesian product. + * @param arr3 - The third array in the cartesian product. + * @param arr4 - The fourth array in the cartesian product. + * @returns A function that maps the piped array to four-item cartesian product tuples. + */ +declare function cartesianProduct(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): (array: readonly T[]) => Array<[T, U, V, W]>; +/** + * Creates a function that computes the cartesian product of the piped array and any number of configured arrays. + * + * @template T - The shared element type of the arrays. + * @param arrs - Additional arrays included in the cartesian product. + * @returns A function that maps the piped array to cartesian product rows. + */ +declare function cartesianProduct(...arrs: Array): (array: readonly T[]) => T[][]; +//#endregion +export { cartesianProduct }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/cartesianProduct.d.ts b/node_modules/es-toolkit/dist/fp/array/cartesianProduct.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c47e7e018c9980ed450a1a70cad6568f01222288 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/cartesianProduct.d.ts @@ -0,0 +1,61 @@ +//#region src/fp/array/cartesianProduct.d.ts +/** + * Creates a function that wraps each element of the piped array in a one-item tuple. + * + * @template T - The type of elements in the piped array. + * @returns A function that maps the piped array to one-item cartesian product tuples. + * + * @example + * import { cartesianProduct, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2], cartesianProduct()); + * // => [[1], [2]] + */ +declare function cartesianProduct(): (array: readonly T[]) => Array<[T]>; +/** + * Creates a function that computes the cartesian product of the piped array and one configured array. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the configured array. + * @param arr2 - The second array in the cartesian product. + * @returns A function that maps the piped array to two-item cartesian product tuples. + * + * @example + * pipe([1, 2], cartesianProduct(['a', 'b'])); + * // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] + */ +declare function cartesianProduct(arr2: readonly U[]): (array: readonly T[]) => Array<[T, U]>; +/** + * Creates a function that computes the cartesian product of the piped array and two configured arrays. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @param arr2 - The second array in the cartesian product. + * @param arr3 - The third array in the cartesian product. + * @returns A function that maps the piped array to three-item cartesian product tuples. + */ +declare function cartesianProduct(arr2: readonly U[], arr3: readonly V[]): (array: readonly T[]) => Array<[T, U, V]>; +/** + * Creates a function that computes the cartesian product of the piped array and three configured arrays. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the second array. + * @template V - The type of elements in the third array. + * @template W - The type of elements in the fourth array. + * @param arr2 - The second array in the cartesian product. + * @param arr3 - The third array in the cartesian product. + * @param arr4 - The fourth array in the cartesian product. + * @returns A function that maps the piped array to four-item cartesian product tuples. + */ +declare function cartesianProduct(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): (array: readonly T[]) => Array<[T, U, V, W]>; +/** + * Creates a function that computes the cartesian product of the piped array and any number of configured arrays. + * + * @template T - The shared element type of the arrays. + * @param arrs - Additional arrays included in the cartesian product. + * @returns A function that maps the piped array to cartesian product rows. + */ +declare function cartesianProduct(...arrs: Array): (array: readonly T[]) => T[][]; +//#endregion +export { cartesianProduct }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/cartesianProduct.js b/node_modules/es-toolkit/dist/fp/array/cartesianProduct.js new file mode 100644 index 0000000000000000000000000000000000000000..ed770ea4f634dc9fe27c8a59165628eee741170b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/cartesianProduct.js @@ -0,0 +1,9 @@ +const require_cartesianProduct = require("../../array/cartesianProduct.js"); +//#region src/fp/array/cartesianProduct.ts +function cartesianProduct(...arrs) { + return function(array) { + return require_cartesianProduct.cartesianProduct(array, ...arrs); + }; +} +//#endregion +exports.cartesianProduct = cartesianProduct; diff --git a/node_modules/es-toolkit/dist/fp/array/cartesianProduct.mjs b/node_modules/es-toolkit/dist/fp/array/cartesianProduct.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0c6ad8b0ba1c7178397acaf6b81dee85a25456fe --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/cartesianProduct.mjs @@ -0,0 +1,9 @@ +import { cartesianProduct as cartesianProduct$1 } from "../../array/cartesianProduct.mjs"; +//#region src/fp/array/cartesianProduct.ts +function cartesianProduct(...arrs) { + return function(array) { + return cartesianProduct$1(array, ...arrs); + }; +} +//#endregion +export { cartesianProduct }; diff --git a/node_modules/es-toolkit/dist/fp/array/chunk.d.mts b/node_modules/es-toolkit/dist/fp/array/chunk.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a25f2fa2ddc33932519d3bc1a8370079645c14aa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/chunk.d.mts @@ -0,0 +1,19 @@ +//#region src/fp/array/chunk.d.ts +/** + * Creates a function that splits an array into sub-arrays of length `size`. The + * final chunk holds the remaining elements when the array cannot be divided + * evenly. Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param size - The length of each chunk. Must be a positive integer. + * @returns A function that maps a `readonly T[]` to a `T[][]`. + * @throws {Error} When `size` is not a positive integer (propagated from the underlying implementation). + * + * @example + * import { pipe, chunk } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4, 5], chunk(2)); // => [[1, 2], [3, 4], [5]] + */ +declare function chunk(size: number): (array: readonly T[]) => T[][]; +//#endregion +export { chunk }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/chunk.d.ts b/node_modules/es-toolkit/dist/fp/array/chunk.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a25f2fa2ddc33932519d3bc1a8370079645c14aa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/chunk.d.ts @@ -0,0 +1,19 @@ +//#region src/fp/array/chunk.d.ts +/** + * Creates a function that splits an array into sub-arrays of length `size`. The + * final chunk holds the remaining elements when the array cannot be divided + * evenly. Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param size - The length of each chunk. Must be a positive integer. + * @returns A function that maps a `readonly T[]` to a `T[][]`. + * @throws {Error} When `size` is not a positive integer (propagated from the underlying implementation). + * + * @example + * import { pipe, chunk } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4, 5], chunk(2)); // => [[1, 2], [3, 4], [5]] + */ +declare function chunk(size: number): (array: readonly T[]) => T[][]; +//#endregion +export { chunk }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/chunk.js b/node_modules/es-toolkit/dist/fp/array/chunk.js new file mode 100644 index 0000000000000000000000000000000000000000..0b740253a5332c52ab07a743df8444297730027a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/chunk.js @@ -0,0 +1,24 @@ +const require_chunk = require("../../array/chunk.js"); +//#region src/fp/array/chunk.ts +/** +* Creates a function that splits an array into sub-arrays of length `size`. The +* final chunk holds the remaining elements when the array cannot be divided +* evenly. Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param size - The length of each chunk. Must be a positive integer. +* @returns A function that maps a `readonly T[]` to a `T[][]`. +* @throws {Error} When `size` is not a positive integer (propagated from the underlying implementation). +* +* @example +* import { pipe, chunk } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4, 5], chunk(2)); // => [[1, 2], [3, 4], [5]] +*/ +function chunk(size) { + return function(array) { + return require_chunk.chunk(array, size); + }; +} +//#endregion +exports.chunk = chunk; diff --git a/node_modules/es-toolkit/dist/fp/array/chunk.mjs b/node_modules/es-toolkit/dist/fp/array/chunk.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b6e500d82982fa8019a63292ded418505f0130e8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/chunk.mjs @@ -0,0 +1,24 @@ +import { chunk as chunk$1 } from "../../array/chunk.mjs"; +//#region src/fp/array/chunk.ts +/** +* Creates a function that splits an array into sub-arrays of length `size`. The +* final chunk holds the remaining elements when the array cannot be divided +* evenly. Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param size - The length of each chunk. Must be a positive integer. +* @returns A function that maps a `readonly T[]` to a `T[][]`. +* @throws {Error} When `size` is not a positive integer (propagated from the underlying implementation). +* +* @example +* import { pipe, chunk } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4, 5], chunk(2)); // => [[1, 2], [3, 4], [5]] +*/ +function chunk(size) { + return function(array) { + return chunk$1(array, size); + }; +} +//#endregion +export { chunk }; diff --git a/node_modules/es-toolkit/dist/fp/array/chunkBy.d.mts b/node_modules/es-toolkit/dist/fp/array/chunkBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a5b20bed2055f73f5e74e907131ca24f768a3dd8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/chunkBy.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/chunkBy.d.ts +/** + * Creates a function that splits consecutive elements whenever the derived key changes. + * + * The iteratee is called from left to right. A new chunk starts when its key differs + * from the previous key by strict inequality. Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param iteratee - Called for each value to produce the comparison key. + * @returns A function that maps a readonly array to consecutive same-key chunks. + * + * @example + * import { chunkBy, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 1, 2, 3, 3], chunkBy(value => value)); + * // => [[1, 1], [2], [3, 3]] + */ +declare function chunkBy(iteratee: (value: T) => unknown): (array: readonly T[]) => T[][]; +//#endregion +export { chunkBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/chunkBy.d.ts b/node_modules/es-toolkit/dist/fp/array/chunkBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a5b20bed2055f73f5e74e907131ca24f768a3dd8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/chunkBy.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/chunkBy.d.ts +/** + * Creates a function that splits consecutive elements whenever the derived key changes. + * + * The iteratee is called from left to right. A new chunk starts when its key differs + * from the previous key by strict inequality. Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param iteratee - Called for each value to produce the comparison key. + * @returns A function that maps a readonly array to consecutive same-key chunks. + * + * @example + * import { chunkBy, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 1, 2, 3, 3], chunkBy(value => value)); + * // => [[1, 1], [2], [3, 3]] + */ +declare function chunkBy(iteratee: (value: T) => unknown): (array: readonly T[]) => T[][]; +//#endregion +export { chunkBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/chunkBy.js b/node_modules/es-toolkit/dist/fp/array/chunkBy.js new file mode 100644 index 0000000000000000000000000000000000000000..c95d0f49b19668da8fe672688690f2e8f3c11911 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/chunkBy.js @@ -0,0 +1,25 @@ +const require_chunkBy = require("../../array/chunkBy.js"); +//#region src/fp/array/chunkBy.ts +/** +* Creates a function that splits consecutive elements whenever the derived key changes. +* +* The iteratee is called from left to right. A new chunk starts when its key differs +* from the previous key by strict inequality. Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param iteratee - Called for each value to produce the comparison key. +* @returns A function that maps a readonly array to consecutive same-key chunks. +* +* @example +* import { chunkBy, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 1, 2, 3, 3], chunkBy(value => value)); +* // => [[1, 1], [2], [3, 3]] +*/ +function chunkBy(iteratee) { + return function(array) { + return require_chunkBy.chunkBy(array, iteratee); + }; +} +//#endregion +exports.chunkBy = chunkBy; diff --git a/node_modules/es-toolkit/dist/fp/array/chunkBy.mjs b/node_modules/es-toolkit/dist/fp/array/chunkBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..db7433ac862e20f852dec73b5b29ffbd76b6f316 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/chunkBy.mjs @@ -0,0 +1,25 @@ +import { chunkBy as chunkBy$1 } from "../../array/chunkBy.mjs"; +//#region src/fp/array/chunkBy.ts +/** +* Creates a function that splits consecutive elements whenever the derived key changes. +* +* The iteratee is called from left to right. A new chunk starts when its key differs +* from the previous key by strict inequality. Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param iteratee - Called for each value to produce the comparison key. +* @returns A function that maps a readonly array to consecutive same-key chunks. +* +* @example +* import { chunkBy, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 1, 2, 3, 3], chunkBy(value => value)); +* // => [[1, 1], [2], [3, 3]] +*/ +function chunkBy(iteratee) { + return function(array) { + return chunkBy$1(array, iteratee); + }; +} +//#endregion +export { chunkBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/combinations.d.mts b/node_modules/es-toolkit/dist/fp/array/combinations.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6f213d375bdbca65c28f448dba273609bbdd77aa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/combinations.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/combinations.d.ts +/** + * Creates a function that returns every combination of the configured size. + * + * Elements are treated as unique by position, so duplicate values can produce identical-looking + * combinations. The returned function throws when size is not a non-negative integer. + * + * @template T - The type of elements in the array. + * @param size - The number of items in each combination. + * @returns A function that maps a readonly array to its size-length combinations. + * @throws {Error} When size is not a non-negative integer. + * + * @example + * import { combinations, pipe } from 'es-toolkit/fp'; + * + * pipe(['A', 'B', 'C'], combinations(2)); + * // => [['A', 'B'], ['A', 'C'], ['B', 'C']] + */ +declare function combinations(size: number): (array: readonly T[]) => T[][]; +//#endregion +export { combinations }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/combinations.d.ts b/node_modules/es-toolkit/dist/fp/array/combinations.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f213d375bdbca65c28f448dba273609bbdd77aa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/combinations.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/combinations.d.ts +/** + * Creates a function that returns every combination of the configured size. + * + * Elements are treated as unique by position, so duplicate values can produce identical-looking + * combinations. The returned function throws when size is not a non-negative integer. + * + * @template T - The type of elements in the array. + * @param size - The number of items in each combination. + * @returns A function that maps a readonly array to its size-length combinations. + * @throws {Error} When size is not a non-negative integer. + * + * @example + * import { combinations, pipe } from 'es-toolkit/fp'; + * + * pipe(['A', 'B', 'C'], combinations(2)); + * // => [['A', 'B'], ['A', 'C'], ['B', 'C']] + */ +declare function combinations(size: number): (array: readonly T[]) => T[][]; +//#endregion +export { combinations }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/combinations.js b/node_modules/es-toolkit/dist/fp/array/combinations.js new file mode 100644 index 0000000000000000000000000000000000000000..432df2ba8858efd08d0852af23b72cca574c212d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/combinations.js @@ -0,0 +1,26 @@ +const require_combinations = require("../../array/combinations.js"); +//#region src/fp/array/combinations.ts +/** +* Creates a function that returns every combination of the configured size. +* +* Elements are treated as unique by position, so duplicate values can produce identical-looking +* combinations. The returned function throws when size is not a non-negative integer. +* +* @template T - The type of elements in the array. +* @param size - The number of items in each combination. +* @returns A function that maps a readonly array to its size-length combinations. +* @throws {Error} When size is not a non-negative integer. +* +* @example +* import { combinations, pipe } from 'es-toolkit/fp'; +* +* pipe(['A', 'B', 'C'], combinations(2)); +* // => [['A', 'B'], ['A', 'C'], ['B', 'C']] +*/ +function combinations(size) { + return function(array) { + return require_combinations.combinations(array, size); + }; +} +//#endregion +exports.combinations = combinations; diff --git a/node_modules/es-toolkit/dist/fp/array/combinations.mjs b/node_modules/es-toolkit/dist/fp/array/combinations.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7187e316fff68551a51b4e3f2954caaae49edab2 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/combinations.mjs @@ -0,0 +1,26 @@ +import { combinations as combinations$1 } from "../../array/combinations.mjs"; +//#region src/fp/array/combinations.ts +/** +* Creates a function that returns every combination of the configured size. +* +* Elements are treated as unique by position, so duplicate values can produce identical-looking +* combinations. The returned function throws when size is not a non-negative integer. +* +* @template T - The type of elements in the array. +* @param size - The number of items in each combination. +* @returns A function that maps a readonly array to its size-length combinations. +* @throws {Error} When size is not a non-negative integer. +* +* @example +* import { combinations, pipe } from 'es-toolkit/fp'; +* +* pipe(['A', 'B', 'C'], combinations(2)); +* // => [['A', 'B'], ['A', 'C'], ['B', 'C']] +*/ +function combinations(size) { + return function(array) { + return combinations$1(array, size); + }; +} +//#endregion +export { combinations }; diff --git a/node_modules/es-toolkit/dist/fp/array/compact.d.mts b/node_modules/es-toolkit/dist/fp/array/compact.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..39e2a4220e88931499f920d86c1b41bde465fd49 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/compact.d.mts @@ -0,0 +1,22 @@ +//#region src/fp/array/compact.d.ts +type NotFalsey = Exclude; +/** + * Creates a function that removes falsey values from an array. Use it with {@link pipe}. + * + * Falsey values include false, null, 0, -0, 0n, an empty string, undefined, + * and NaN. The returned function is lazy-capable inside {@link pipe}, so a + * trailing short-circuiting operator such as {@link take} can stop once enough + * truthy values have been emitted. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a new array with falsey values removed. + * + * @example + * import { compact, pipe } from 'es-toolkit/fp'; + * + * pipe([0, 1, false, 2, '', 3], compact()); + * // => [1, 2, 3] + */ +declare function compact(): (array: readonly T[]) => Array>; +//#endregion +export { compact }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/compact.d.ts b/node_modules/es-toolkit/dist/fp/array/compact.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39e2a4220e88931499f920d86c1b41bde465fd49 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/compact.d.ts @@ -0,0 +1,22 @@ +//#region src/fp/array/compact.d.ts +type NotFalsey = Exclude; +/** + * Creates a function that removes falsey values from an array. Use it with {@link pipe}. + * + * Falsey values include false, null, 0, -0, 0n, an empty string, undefined, + * and NaN. The returned function is lazy-capable inside {@link pipe}, so a + * trailing short-circuiting operator such as {@link take} can stop once enough + * truthy values have been emitted. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a new array with falsey values removed. + * + * @example + * import { compact, pipe } from 'es-toolkit/fp'; + * + * pipe([0, 1, false, 2, '', 3], compact()); + * // => [1, 2, 3] + */ +declare function compact(): (array: readonly T[]) => Array>; +//#endregion +export { compact }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/compact.js b/node_modules/es-toolkit/dist/fp/array/compact.js new file mode 100644 index 0000000000000000000000000000000000000000..a1fa8383a26259fc8e5d7524bccb1f2fb0b874db --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/compact.js @@ -0,0 +1,31 @@ +const require_compact = require("../../array/compact.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/compact.ts +/** +* Creates a function that removes falsey values from an array. Use it with {@link pipe}. +* +* Falsey values include false, null, 0, -0, 0n, an empty string, undefined, +* and NaN. The returned function is lazy-capable inside {@link pipe}, so a +* trailing short-circuiting operator such as {@link take} can stop once enough +* truthy values have been emitted. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a new array with falsey values removed. +* +* @example +* import { compact, pipe } from 'es-toolkit/fp'; +* +* pipe([0, 1, false, 2, '', 3], compact()); +* // => [1, 2, 3] +*/ +function compact() { + function compactEager(array) { + return require_compact.compact(array); + } + const compactLazy = require_lazy.createLazyFunction((value, _index, emit) => { + if (value) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(compactEager, compactLazy); +} +//#endregion +exports.compact = compact; diff --git a/node_modules/es-toolkit/dist/fp/array/compact.mjs b/node_modules/es-toolkit/dist/fp/array/compact.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cc30021e11048d6310bc8604ee3f04f1c318f29a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/compact.mjs @@ -0,0 +1,30 @@ +import { compact as compact$1 } from "../../array/compact.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/compact.ts +/** +* Creates a function that removes falsey values from an array. Use it with {@link pipe}. +* +* Falsey values include false, null, 0, -0, 0n, an empty string, undefined, +* and NaN. The returned function is lazy-capable inside {@link pipe}, so a +* trailing short-circuiting operator such as {@link take} can stop once enough +* truthy values have been emitted. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a new array with falsey values removed. +* +* @example +* import { compact, pipe } from 'es-toolkit/fp'; +* +* pipe([0, 1, false, 2, '', 3], compact()); +* // => [1, 2, 3] +*/ +function compact() { + function compactEager(array) { + return compact$1(array); + } + return combineEagerAndLazyFunctions(compactEager, createLazyFunction((value, _index, emit) => { + if (value) emit(value); + })); +} +//#endregion +export { compact }; diff --git a/node_modules/es-toolkit/dist/fp/array/countBy.d.mts b/node_modules/es-toolkit/dist/fp/array/countBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..83ed89af46adfb815ddb3d9659da7b58ce553b83 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/countBy.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/countBy.d.ts +/** + * Creates a function that counts values by a derived key. + * + * The mapper receives each value, its index, and the full input array. The returned object + * uses mapper results as keys and occurrence counts as values. + * + * @template T - The type of elements in the array. + * @template K - The property-key type produced by the mapper. + * @param mapper - Called with each value, index, and array to produce a key. + * @returns A function that maps a readonly array to counts by key. + * + * @example + * import { countBy, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4, 5], countBy(value => (value % 2 === 0 ? 'even' : 'odd'))); + * // => { odd: 3, even: 2 } + */ +declare function countBy(mapper: (item: T, index: number, array: readonly T[]) => K): (array: readonly T[]) => Record; +//#endregion +export { countBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/countBy.d.ts b/node_modules/es-toolkit/dist/fp/array/countBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..83ed89af46adfb815ddb3d9659da7b58ce553b83 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/countBy.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/countBy.d.ts +/** + * Creates a function that counts values by a derived key. + * + * The mapper receives each value, its index, and the full input array. The returned object + * uses mapper results as keys and occurrence counts as values. + * + * @template T - The type of elements in the array. + * @template K - The property-key type produced by the mapper. + * @param mapper - Called with each value, index, and array to produce a key. + * @returns A function that maps a readonly array to counts by key. + * + * @example + * import { countBy, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4, 5], countBy(value => (value % 2 === 0 ? 'even' : 'odd'))); + * // => { odd: 3, even: 2 } + */ +declare function countBy(mapper: (item: T, index: number, array: readonly T[]) => K): (array: readonly T[]) => Record; +//#endregion +export { countBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/countBy.js b/node_modules/es-toolkit/dist/fp/array/countBy.js new file mode 100644 index 0000000000000000000000000000000000000000..2301be9a4ec7c578ffb0835a32da7b49bb8b9ef8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/countBy.js @@ -0,0 +1,26 @@ +const require_countBy = require("../../array/countBy.js"); +//#region src/fp/array/countBy.ts +/** +* Creates a function that counts values by a derived key. +* +* The mapper receives each value, its index, and the full input array. The returned object +* uses mapper results as keys and occurrence counts as values. +* +* @template T - The type of elements in the array. +* @template K - The property-key type produced by the mapper. +* @param mapper - Called with each value, index, and array to produce a key. +* @returns A function that maps a readonly array to counts by key. +* +* @example +* import { countBy, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4, 5], countBy(value => (value % 2 === 0 ? 'even' : 'odd'))); +* // => { odd: 3, even: 2 } +*/ +function countBy(mapper) { + return function(array) { + return require_countBy.countBy(array, mapper); + }; +} +//#endregion +exports.countBy = countBy; diff --git a/node_modules/es-toolkit/dist/fp/array/countBy.mjs b/node_modules/es-toolkit/dist/fp/array/countBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..09b5d8485532099b34d450ae8d01fee3c8d471c3 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/countBy.mjs @@ -0,0 +1,26 @@ +import { countBy as countBy$1 } from "../../array/countBy.mjs"; +//#region src/fp/array/countBy.ts +/** +* Creates a function that counts values by a derived key. +* +* The mapper receives each value, its index, and the full input array. The returned object +* uses mapper results as keys and occurrence counts as values. +* +* @template T - The type of elements in the array. +* @template K - The property-key type produced by the mapper. +* @param mapper - Called with each value, index, and array to produce a key. +* @returns A function that maps a readonly array to counts by key. +* +* @example +* import { countBy, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4, 5], countBy(value => (value % 2 === 0 ? 'even' : 'odd'))); +* // => { odd: 3, even: 2 } +*/ +function countBy(mapper) { + return function(array) { + return countBy$1(array, mapper); + }; +} +//#endregion +export { countBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/difference.d.mts b/node_modules/es-toolkit/dist/fp/array/difference.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..675443eba955114b8acd073962eff57e0b14ab90 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/difference.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/difference.d.ts +/** + * Creates a function that returns values from the piped array that are not present in another array. + * + * Equality follows SameValueZero through Set membership, matching the main + * {@link difference} implementation. The returned function is lazy-capable + * inside {@link pipe}. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to exclude from the piped array. + * @returns A function that maps the piped array to its difference. + * + * @example + * import { difference, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], difference([2, 4])); + * // => [1, 3] + */ +declare function difference(secondArray: readonly T[]): (array: readonly T[]) => T[]; +//#endregion +export { difference }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/difference.d.ts b/node_modules/es-toolkit/dist/fp/array/difference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..675443eba955114b8acd073962eff57e0b14ab90 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/difference.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/difference.d.ts +/** + * Creates a function that returns values from the piped array that are not present in another array. + * + * Equality follows SameValueZero through Set membership, matching the main + * {@link difference} implementation. The returned function is lazy-capable + * inside {@link pipe}. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to exclude from the piped array. + * @returns A function that maps the piped array to its difference. + * + * @example + * import { difference, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], difference([2, 4])); + * // => [1, 3] + */ +declare function difference(secondArray: readonly T[]): (array: readonly T[]) => T[]; +//#endregion +export { difference }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/difference.js b/node_modules/es-toolkit/dist/fp/array/difference.js new file mode 100644 index 0000000000000000000000000000000000000000..11a2c38270d9e429eafd050491e0d683c05dd4a0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/difference.js @@ -0,0 +1,32 @@ +const require_difference = require("../../array/difference.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/difference.ts +/** +* Creates a function that returns values from the piped array that are not present in another array. +* +* Equality follows SameValueZero through Set membership, matching the main +* {@link difference} implementation. The returned function is lazy-capable +* inside {@link pipe}. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to exclude from the piped array. +* @returns A function that maps the piped array to its difference. +* +* @example +* import { difference, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], difference([2, 4])); +* // => [1, 3] +*/ +function difference(secondArray) { + const secondSet = new Set(secondArray); + function differenceEager(array) { + return require_difference.difference(array, secondArray); + } + const differenceLazy = require_lazy.createLazyFunction((value, _index, emit) => { + if (!secondSet.has(value)) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(differenceEager, differenceLazy); +} +//#endregion +exports.difference = difference; diff --git a/node_modules/es-toolkit/dist/fp/array/difference.mjs b/node_modules/es-toolkit/dist/fp/array/difference.mjs new file mode 100644 index 0000000000000000000000000000000000000000..99fc2a19d387668cbd7167deb20611d0e20f9903 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/difference.mjs @@ -0,0 +1,31 @@ +import { difference as difference$1 } from "../../array/difference.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/difference.ts +/** +* Creates a function that returns values from the piped array that are not present in another array. +* +* Equality follows SameValueZero through Set membership, matching the main +* {@link difference} implementation. The returned function is lazy-capable +* inside {@link pipe}. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to exclude from the piped array. +* @returns A function that maps the piped array to its difference. +* +* @example +* import { difference, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], difference([2, 4])); +* // => [1, 3] +*/ +function difference(secondArray) { + const secondSet = new Set(secondArray); + function differenceEager(array) { + return difference$1(array, secondArray); + } + return combineEagerAndLazyFunctions(differenceEager, createLazyFunction((value, _index, emit) => { + if (!secondSet.has(value)) emit(value); + })); +} +//#endregion +export { difference }; diff --git a/node_modules/es-toolkit/dist/fp/array/differenceBy.d.mts b/node_modules/es-toolkit/dist/fp/array/differenceBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a020c29f78939f1b2e7e6586fb8640ce81fb77db --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/differenceBy.d.mts @@ -0,0 +1,22 @@ +//#region src/fp/array/differenceBy.d.ts +/** + * Creates a function that returns values whose mapped identity is absent from another array. + * + * The mapper is applied to values from both arrays. The returned function is + * lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the configured array. + * @param secondArray - Values to exclude from the piped array after mapping. + * @param mapper - Maps values from both arrays to comparison keys. + * @returns A function that maps the piped array to its mapped difference. + * + * @example + * import { differenceBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], differenceBy([2], value => typeof value === 'number' ? value : value.id)); + * // => [{ id: 1 }] + */ +declare function differenceBy(secondArray: readonly U[], mapper: (value: T | U) => unknown): (array: readonly T[]) => T[]; +//#endregion +export { differenceBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/differenceBy.d.ts b/node_modules/es-toolkit/dist/fp/array/differenceBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a020c29f78939f1b2e7e6586fb8640ce81fb77db --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/differenceBy.d.ts @@ -0,0 +1,22 @@ +//#region src/fp/array/differenceBy.d.ts +/** + * Creates a function that returns values whose mapped identity is absent from another array. + * + * The mapper is applied to values from both arrays. The returned function is + * lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the configured array. + * @param secondArray - Values to exclude from the piped array after mapping. + * @param mapper - Maps values from both arrays to comparison keys. + * @returns A function that maps the piped array to its mapped difference. + * + * @example + * import { differenceBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], differenceBy([2], value => typeof value === 'number' ? value : value.id)); + * // => [{ id: 1 }] + */ +declare function differenceBy(secondArray: readonly U[], mapper: (value: T | U) => unknown): (array: readonly T[]) => T[]; +//#endregion +export { differenceBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/differenceBy.js b/node_modules/es-toolkit/dist/fp/array/differenceBy.js new file mode 100644 index 0000000000000000000000000000000000000000..039f106fe1317c766e5e867320f255c34ccf3395 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/differenceBy.js @@ -0,0 +1,33 @@ +const require_differenceBy = require("../../array/differenceBy.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/differenceBy.ts +/** +* Creates a function that returns values whose mapped identity is absent from another array. +* +* The mapper is applied to values from both arrays. The returned function is +* lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the piped array. +* @template U - The type of elements in the configured array. +* @param secondArray - Values to exclude from the piped array after mapping. +* @param mapper - Maps values from both arrays to comparison keys. +* @returns A function that maps the piped array to its mapped difference. +* +* @example +* import { differenceBy, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], differenceBy([2], value => typeof value === 'number' ? value : value.id)); +* // => [{ id: 1 }] +*/ +function differenceBy(secondArray, mapper) { + const mappedSecondSet = new Set(secondArray.map((item) => mapper(item))); + function differenceByEager(array) { + return require_differenceBy.differenceBy(array, secondArray, mapper); + } + const differenceByLazy = require_lazy.createLazyFunction((value, _index, emit) => { + if (!mappedSecondSet.has(mapper(value))) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(differenceByEager, differenceByLazy); +} +//#endregion +exports.differenceBy = differenceBy; diff --git a/node_modules/es-toolkit/dist/fp/array/differenceBy.mjs b/node_modules/es-toolkit/dist/fp/array/differenceBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..adc34fe88c87ff136d7cddd7216e96836ab77082 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/differenceBy.mjs @@ -0,0 +1,32 @@ +import { differenceBy as differenceBy$1 } from "../../array/differenceBy.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/differenceBy.ts +/** +* Creates a function that returns values whose mapped identity is absent from another array. +* +* The mapper is applied to values from both arrays. The returned function is +* lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the piped array. +* @template U - The type of elements in the configured array. +* @param secondArray - Values to exclude from the piped array after mapping. +* @param mapper - Maps values from both arrays to comparison keys. +* @returns A function that maps the piped array to its mapped difference. +* +* @example +* import { differenceBy, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], differenceBy([2], value => typeof value === 'number' ? value : value.id)); +* // => [{ id: 1 }] +*/ +function differenceBy(secondArray, mapper) { + const mappedSecondSet = new Set(secondArray.map((item) => mapper(item))); + function differenceByEager(array) { + return differenceBy$1(array, secondArray, mapper); + } + return combineEagerAndLazyFunctions(differenceByEager, createLazyFunction((value, _index, emit) => { + if (!mappedSecondSet.has(mapper(value))) emit(value); + })); +} +//#endregion +export { differenceBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/differenceWith.d.mts b/node_modules/es-toolkit/dist/fp/array/differenceWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..77dbaee18b9c3403877c584310e25ba4d76133da --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/differenceWith.d.mts @@ -0,0 +1,22 @@ +//#region src/fp/array/differenceWith.d.ts +/** + * Creates a function that returns values that are not equal to any configured value. + * + * Equality is decided by the provided comparator. The returned function is + * lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the configured array. + * @param secondArray - Values to compare against the piped array. + * @param areItemsEqual - Returns true when a piped value equals a configured value. + * @returns A function that maps the piped array to its custom difference. + * + * @example + * import { differenceWith, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], differenceWith([2], (item, id) => item.id === id)); + * // => [{ id: 1 }] + */ +declare function differenceWith(secondArray: readonly U[], areItemsEqual: (item: T, other: U) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { differenceWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/differenceWith.d.ts b/node_modules/es-toolkit/dist/fp/array/differenceWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..77dbaee18b9c3403877c584310e25ba4d76133da --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/differenceWith.d.ts @@ -0,0 +1,22 @@ +//#region src/fp/array/differenceWith.d.ts +/** + * Creates a function that returns values that are not equal to any configured value. + * + * Equality is decided by the provided comparator. The returned function is + * lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the configured array. + * @param secondArray - Values to compare against the piped array. + * @param areItemsEqual - Returns true when a piped value equals a configured value. + * @returns A function that maps the piped array to its custom difference. + * + * @example + * import { differenceWith, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], differenceWith([2], (item, id) => item.id === id)); + * // => [{ id: 1 }] + */ +declare function differenceWith(secondArray: readonly U[], areItemsEqual: (item: T, other: U) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { differenceWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/differenceWith.js b/node_modules/es-toolkit/dist/fp/array/differenceWith.js new file mode 100644 index 0000000000000000000000000000000000000000..2e6bd7a3d002cea12477705309425854d308935a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/differenceWith.js @@ -0,0 +1,32 @@ +const require_differenceWith = require("../../array/differenceWith.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/differenceWith.ts +/** +* Creates a function that returns values that are not equal to any configured value. +* +* Equality is decided by the provided comparator. The returned function is +* lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the piped array. +* @template U - The type of elements in the configured array. +* @param secondArray - Values to compare against the piped array. +* @param areItemsEqual - Returns true when a piped value equals a configured value. +* @returns A function that maps the piped array to its custom difference. +* +* @example +* import { differenceWith, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], differenceWith([2], (item, id) => item.id === id)); +* // => [{ id: 1 }] +*/ +function differenceWith(secondArray, areItemsEqual) { + function differenceWithEager(array) { + return require_differenceWith.differenceWith(array, secondArray, areItemsEqual); + } + const differenceWithLazy = require_lazy.createLazyFunction((value, _index, emit) => { + if (secondArray.every((other) => !areItemsEqual(value, other))) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(differenceWithEager, differenceWithLazy); +} +//#endregion +exports.differenceWith = differenceWith; diff --git a/node_modules/es-toolkit/dist/fp/array/differenceWith.mjs b/node_modules/es-toolkit/dist/fp/array/differenceWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2b22b9f0afaac0e46e5b4c7f08bbb9cb2891e963 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/differenceWith.mjs @@ -0,0 +1,31 @@ +import { differenceWith as differenceWith$1 } from "../../array/differenceWith.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/differenceWith.ts +/** +* Creates a function that returns values that are not equal to any configured value. +* +* Equality is decided by the provided comparator. The returned function is +* lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the piped array. +* @template U - The type of elements in the configured array. +* @param secondArray - Values to compare against the piped array. +* @param areItemsEqual - Returns true when a piped value equals a configured value. +* @returns A function that maps the piped array to its custom difference. +* +* @example +* import { differenceWith, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], differenceWith([2], (item, id) => item.id === id)); +* // => [{ id: 1 }] +*/ +function differenceWith(secondArray, areItemsEqual) { + function differenceWithEager(array) { + return differenceWith$1(array, secondArray, areItemsEqual); + } + return combineEagerAndLazyFunctions(differenceWithEager, createLazyFunction((value, _index, emit) => { + if (secondArray.every((other) => !areItemsEqual(value, other))) emit(value); + })); +} +//#endregion +export { differenceWith }; diff --git a/node_modules/es-toolkit/dist/fp/array/drop.d.mts b/node_modules/es-toolkit/dist/fp/array/drop.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..57dc7f0cdfadcd93ccbb448f55b1a73f1f0c4c3e --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/drop.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/drop.d.ts +/** + * Creates a function that removes a number of values from the start of an array. + * + * Negative counts are treated as 0, matching the main {@link drop} + * implementation. The returned function is lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param count - The number of values to skip from the start. + * @returns A function that maps the piped array to the remaining suffix. + * + * @example + * import { drop, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], drop(2)); + * // => [3, 4] + */ +declare function drop(count: number): (array: readonly T[]) => T[]; +//#endregion +export { drop }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/drop.d.ts b/node_modules/es-toolkit/dist/fp/array/drop.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..57dc7f0cdfadcd93ccbb448f55b1a73f1f0c4c3e --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/drop.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/drop.d.ts +/** + * Creates a function that removes a number of values from the start of an array. + * + * Negative counts are treated as 0, matching the main {@link drop} + * implementation. The returned function is lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param count - The number of values to skip from the start. + * @returns A function that maps the piped array to the remaining suffix. + * + * @example + * import { drop, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], drop(2)); + * // => [3, 4] + */ +declare function drop(count: number): (array: readonly T[]) => T[]; +//#endregion +export { drop }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/drop.js b/node_modules/es-toolkit/dist/fp/array/drop.js new file mode 100644 index 0000000000000000000000000000000000000000..a6d3f84f5cdd002f5aa66397fddd513f1ff86ec0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/drop.js @@ -0,0 +1,31 @@ +const require_drop = require("../../array/drop.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/drop.ts +/** +* Creates a function that removes a number of values from the start of an array. +* +* Negative counts are treated as 0, matching the main {@link drop} +* implementation. The returned function is lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param count - The number of values to skip from the start. +* @returns A function that maps the piped array to the remaining suffix. +* +* @example +* import { drop, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], drop(2)); +* // => [3, 4] +*/ +function drop(count) { + const normalizedCount = Number.isNaN(count) ? 0 : Math.trunc(Math.max(count, 0)); + function dropEager(array) { + return require_drop.drop(array, count); + } + const dropLazy = require_lazy.createLazyFunction((value, index, emit) => { + if (index >= normalizedCount) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(dropEager, dropLazy); +} +//#endregion +exports.drop = drop; diff --git a/node_modules/es-toolkit/dist/fp/array/drop.mjs b/node_modules/es-toolkit/dist/fp/array/drop.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e4b9b72854b8335045acf20f77240396b33372b5 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/drop.mjs @@ -0,0 +1,30 @@ +import { drop as drop$1 } from "../../array/drop.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/drop.ts +/** +* Creates a function that removes a number of values from the start of an array. +* +* Negative counts are treated as 0, matching the main {@link drop} +* implementation. The returned function is lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param count - The number of values to skip from the start. +* @returns A function that maps the piped array to the remaining suffix. +* +* @example +* import { drop, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], drop(2)); +* // => [3, 4] +*/ +function drop(count) { + const normalizedCount = Number.isNaN(count) ? 0 : Math.trunc(Math.max(count, 0)); + function dropEager(array) { + return drop$1(array, count); + } + return combineEagerAndLazyFunctions(dropEager, createLazyFunction((value, index, emit) => { + if (index >= normalizedCount) emit(value); + })); +} +//#endregion +export { drop }; diff --git a/node_modules/es-toolkit/dist/fp/array/dropRight.d.mts b/node_modules/es-toolkit/dist/fp/array/dropRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3d80364e36d208a777798e12d37a648661400b71 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropRight.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/dropRight.d.ts +/** + * Creates a function that removes a number of values from the end of an array. + * + * The returned function follows the main {@link dropRight} behavior and returns a new array. + * Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param count - The number of values to drop from the end. + * @returns A function that maps a readonly array to the remaining prefix. + * + * @example + * import { dropRight, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], dropRight(2)); + * // => [1, 2] + */ +declare function dropRight(count: number): (array: readonly T[]) => T[]; +//#endregion +export { dropRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/dropRight.d.ts b/node_modules/es-toolkit/dist/fp/array/dropRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d80364e36d208a777798e12d37a648661400b71 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropRight.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/dropRight.d.ts +/** + * Creates a function that removes a number of values from the end of an array. + * + * The returned function follows the main {@link dropRight} behavior and returns a new array. + * Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param count - The number of values to drop from the end. + * @returns A function that maps a readonly array to the remaining prefix. + * + * @example + * import { dropRight, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], dropRight(2)); + * // => [1, 2] + */ +declare function dropRight(count: number): (array: readonly T[]) => T[]; +//#endregion +export { dropRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/dropRight.js b/node_modules/es-toolkit/dist/fp/array/dropRight.js new file mode 100644 index 0000000000000000000000000000000000000000..4ba06f8dd52b0ee94bb4cb964ec8cbc31aaf844f --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropRight.js @@ -0,0 +1,25 @@ +const require_dropRight = require("../../array/dropRight.js"); +//#region src/fp/array/dropRight.ts +/** +* Creates a function that removes a number of values from the end of an array. +* +* The returned function follows the main {@link dropRight} behavior and returns a new array. +* Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param count - The number of values to drop from the end. +* @returns A function that maps a readonly array to the remaining prefix. +* +* @example +* import { dropRight, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], dropRight(2)); +* // => [1, 2] +*/ +function dropRight(count) { + return function(array) { + return require_dropRight.dropRight(array, count); + }; +} +//#endregion +exports.dropRight = dropRight; diff --git a/node_modules/es-toolkit/dist/fp/array/dropRight.mjs b/node_modules/es-toolkit/dist/fp/array/dropRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4fb5735cbeced729605981b5eaa31da98eed13d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropRight.mjs @@ -0,0 +1,25 @@ +import { dropRight as dropRight$1 } from "../../array/dropRight.mjs"; +//#region src/fp/array/dropRight.ts +/** +* Creates a function that removes a number of values from the end of an array. +* +* The returned function follows the main {@link dropRight} behavior and returns a new array. +* Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param count - The number of values to drop from the end. +* @returns A function that maps a readonly array to the remaining prefix. +* +* @example +* import { dropRight, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], dropRight(2)); +* // => [1, 2] +*/ +function dropRight(count) { + return function(array) { + return dropRight$1(array, count); + }; +} +//#endregion +export { dropRight }; diff --git a/node_modules/es-toolkit/dist/fp/array/dropRightWhile.d.mts b/node_modules/es-toolkit/dist/fp/array/dropRightWhile.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c75faab4ddbbf32570de4dbbab036564ceb99c71 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropRightWhile.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/dropRightWhile.d.ts +/** + * Creates a function that drops trailing values while a predicate returns true. + * + * The predicate is evaluated from right to left and receives the value, index, and full + * input array. Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each value, index, and array while dropping from the end. + * @returns A function that maps a readonly array to the remaining prefix. + * + * @example + * import { dropRightWhile, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], dropRightWhile(value => value > 2)); + * // => [1, 2] + */ +declare function dropRightWhile(predicate: (item: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { dropRightWhile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/dropRightWhile.d.ts b/node_modules/es-toolkit/dist/fp/array/dropRightWhile.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c75faab4ddbbf32570de4dbbab036564ceb99c71 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropRightWhile.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/dropRightWhile.d.ts +/** + * Creates a function that drops trailing values while a predicate returns true. + * + * The predicate is evaluated from right to left and receives the value, index, and full + * input array. Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each value, index, and array while dropping from the end. + * @returns A function that maps a readonly array to the remaining prefix. + * + * @example + * import { dropRightWhile, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], dropRightWhile(value => value > 2)); + * // => [1, 2] + */ +declare function dropRightWhile(predicate: (item: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { dropRightWhile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/dropRightWhile.js b/node_modules/es-toolkit/dist/fp/array/dropRightWhile.js new file mode 100644 index 0000000000000000000000000000000000000000..2eec3d3c1d382792e83ac1fce0e8e7b798baab0f --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropRightWhile.js @@ -0,0 +1,25 @@ +const require_dropRightWhile = require("../../array/dropRightWhile.js"); +//#region src/fp/array/dropRightWhile.ts +/** +* Creates a function that drops trailing values while a predicate returns true. +* +* The predicate is evaluated from right to left and receives the value, index, and full +* input array. Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each value, index, and array while dropping from the end. +* @returns A function that maps a readonly array to the remaining prefix. +* +* @example +* import { dropRightWhile, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], dropRightWhile(value => value > 2)); +* // => [1, 2] +*/ +function dropRightWhile(predicate) { + return function(array) { + return require_dropRightWhile.dropRightWhile(array, predicate); + }; +} +//#endregion +exports.dropRightWhile = dropRightWhile; diff --git a/node_modules/es-toolkit/dist/fp/array/dropRightWhile.mjs b/node_modules/es-toolkit/dist/fp/array/dropRightWhile.mjs new file mode 100644 index 0000000000000000000000000000000000000000..879d681b0458cd9dbfadef7b6d60c811e630dad0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropRightWhile.mjs @@ -0,0 +1,25 @@ +import { dropRightWhile as dropRightWhile$1 } from "../../array/dropRightWhile.mjs"; +//#region src/fp/array/dropRightWhile.ts +/** +* Creates a function that drops trailing values while a predicate returns true. +* +* The predicate is evaluated from right to left and receives the value, index, and full +* input array. Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each value, index, and array while dropping from the end. +* @returns A function that maps a readonly array to the remaining prefix. +* +* @example +* import { dropRightWhile, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], dropRightWhile(value => value > 2)); +* // => [1, 2] +*/ +function dropRightWhile(predicate) { + return function(array) { + return dropRightWhile$1(array, predicate); + }; +} +//#endregion +export { dropRightWhile }; diff --git a/node_modules/es-toolkit/dist/fp/array/dropWhile.d.mts b/node_modules/es-toolkit/dist/fp/array/dropWhile.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0a3a9f0026baa627c20b187af6385b2d81fb6079 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropWhile.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/dropWhile.d.ts +/** + * Creates a function that removes leading values while a predicate returns true. + * + * Once the predicate returns false, that value and all following values are + * emitted. The returned function is lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each leading value and index while values are being dropped. + * @returns A function that maps the piped array to the remaining suffix. + * + * @example + * import { dropWhile, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 1], dropWhile(value => value < 3)); + * // => [3, 1] + */ +declare function dropWhile(predicate: (item: T, index: number) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { dropWhile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/dropWhile.d.ts b/node_modules/es-toolkit/dist/fp/array/dropWhile.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a3a9f0026baa627c20b187af6385b2d81fb6079 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropWhile.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/dropWhile.d.ts +/** + * Creates a function that removes leading values while a predicate returns true. + * + * Once the predicate returns false, that value and all following values are + * emitted. The returned function is lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each leading value and index while values are being dropped. + * @returns A function that maps the piped array to the remaining suffix. + * + * @example + * import { dropWhile, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 1], dropWhile(value => value < 3)); + * // => [3, 1] + */ +declare function dropWhile(predicate: (item: T, index: number) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { dropWhile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/dropWhile.js b/node_modules/es-toolkit/dist/fp/array/dropWhile.js new file mode 100644 index 0000000000000000000000000000000000000000..77155fb443a567eb56973e1b54503fa737861daf --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropWhile.js @@ -0,0 +1,36 @@ +const require_dropWhile = require("../../array/dropWhile.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/dropWhile.ts +/** +* Creates a function that removes leading values while a predicate returns true. +* +* Once the predicate returns false, that value and all following values are +* emitted. The returned function is lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each leading value and index while values are being dropped. +* @returns A function that maps the piped array to the remaining suffix. +* +* @example +* import { dropWhile, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 1], dropWhile(value => value < 3)); +* // => [3, 1] +*/ +function dropWhile(predicate) { + function dropWhileEager(array) { + return require_dropWhile.dropWhile(array, (item, index) => predicate(item, index)); + } + const dropWhileLazy = (emit) => { + let dropping = true; + let index = 0; + return (value) => { + if (dropping && predicate(value, index++)) return true; + dropping = false; + return emit(value); + }; + }; + return require_lazy.combineEagerAndLazyFunctions(dropWhileEager, dropWhileLazy); +} +//#endregion +exports.dropWhile = dropWhile; diff --git a/node_modules/es-toolkit/dist/fp/array/dropWhile.mjs b/node_modules/es-toolkit/dist/fp/array/dropWhile.mjs new file mode 100644 index 0000000000000000000000000000000000000000..99197f6b628878eae8d0b0db3cfe33b801a43217 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/dropWhile.mjs @@ -0,0 +1,36 @@ +import { dropWhile as dropWhile$1 } from "../../array/dropWhile.mjs"; +import { combineEagerAndLazyFunctions } from "../_internal/lazy.mjs"; +//#region src/fp/array/dropWhile.ts +/** +* Creates a function that removes leading values while a predicate returns true. +* +* Once the predicate returns false, that value and all following values are +* emitted. The returned function is lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each leading value and index while values are being dropped. +* @returns A function that maps the piped array to the remaining suffix. +* +* @example +* import { dropWhile, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 1], dropWhile(value => value < 3)); +* // => [3, 1] +*/ +function dropWhile(predicate) { + function dropWhileEager(array) { + return dropWhile$1(array, (item, index) => predicate(item, index)); + } + const dropWhileLazy = (emit) => { + let dropping = true; + let index = 0; + return (value) => { + if (dropping && predicate(value, index++)) return true; + dropping = false; + return emit(value); + }; + }; + return combineEagerAndLazyFunctions(dropWhileEager, dropWhileLazy); +} +//#endregion +export { dropWhile }; diff --git a/node_modules/es-toolkit/dist/fp/array/filter.d.mts b/node_modules/es-toolkit/dist/fp/array/filter.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..db7cd1df6b03680da555005c8aae1d26bbf9e1d8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/filter.d.mts @@ -0,0 +1,45 @@ +//#region src/fp/array/filter.d.ts +/** + * Creates a function that keeps only the elements for which `predicate` returns + * a truthy value, equivalent to `Array.prototype.filter`. A type predicate + * narrows the element type of the result. Use it with {@link pipe}. + * + * The returned function is **lazy-capable**: inside a {@link pipe} it is fused + * with adjacent lazy functions and runs element-by-element. + * + * @template T - The type of elements in the input array. + * @template S - The narrowed element type when `predicate` is a type guard. + * @param predicate - Called with `(value, index)` for each element; return + * `true` to keep the element. + * @returns A function that maps a `readonly T[]` to a filtered array. + * + * @example + * import { pipe, filter } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], filter(x => x % 2 === 0)); // => [2, 4] + * + * @example + * // A type guard narrows the result type to `string[]`. + * pipe([1, 'a', 2, 'b'], filter((x): x is string => typeof x === 'string')); // => ['a', 'b'] + */ +declare function filter(predicate: (value: T, index: number) => value is S): (array: readonly T[]) => S[]; +/** + * Creates a function that keeps only the elements for which `predicate` returns + * a truthy value, equivalent to `Array.prototype.filter`. Use it with {@link pipe}. + * + * The returned function is **lazy-capable**: inside a {@link pipe} it is fused + * with adjacent lazy functions and runs element-by-element. + * + * @template T - The type of elements in the input array. + * @param predicate - Called with `(value, index)` for each element; return + * `true` to keep the element. + * @returns A function that maps a `readonly T[]` to a filtered array. + * + * @example + * import { pipe, filter } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], filter(x => x % 2 === 0)); // => [2, 4] + */ +declare function filter(predicate: (value: T, index: number) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { filter }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/filter.d.ts b/node_modules/es-toolkit/dist/fp/array/filter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..db7cd1df6b03680da555005c8aae1d26bbf9e1d8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/filter.d.ts @@ -0,0 +1,45 @@ +//#region src/fp/array/filter.d.ts +/** + * Creates a function that keeps only the elements for which `predicate` returns + * a truthy value, equivalent to `Array.prototype.filter`. A type predicate + * narrows the element type of the result. Use it with {@link pipe}. + * + * The returned function is **lazy-capable**: inside a {@link pipe} it is fused + * with adjacent lazy functions and runs element-by-element. + * + * @template T - The type of elements in the input array. + * @template S - The narrowed element type when `predicate` is a type guard. + * @param predicate - Called with `(value, index)` for each element; return + * `true` to keep the element. + * @returns A function that maps a `readonly T[]` to a filtered array. + * + * @example + * import { pipe, filter } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], filter(x => x % 2 === 0)); // => [2, 4] + * + * @example + * // A type guard narrows the result type to `string[]`. + * pipe([1, 'a', 2, 'b'], filter((x): x is string => typeof x === 'string')); // => ['a', 'b'] + */ +declare function filter(predicate: (value: T, index: number) => value is S): (array: readonly T[]) => S[]; +/** + * Creates a function that keeps only the elements for which `predicate` returns + * a truthy value, equivalent to `Array.prototype.filter`. Use it with {@link pipe}. + * + * The returned function is **lazy-capable**: inside a {@link pipe} it is fused + * with adjacent lazy functions and runs element-by-element. + * + * @template T - The type of elements in the input array. + * @param predicate - Called with `(value, index)` for each element; return + * `true` to keep the element. + * @returns A function that maps a `readonly T[]` to a filtered array. + * + * @example + * import { pipe, filter } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], filter(x => x % 2 === 0)); // => [2, 4] + */ +declare function filter(predicate: (value: T, index: number) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { filter }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/filter.js b/node_modules/es-toolkit/dist/fp/array/filter.js new file mode 100644 index 0000000000000000000000000000000000000000..42c32c92c2114fd8769e59049cb4b03f7e6b0570 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/filter.js @@ -0,0 +1,13 @@ +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/filter.ts +function filter(predicate) { + function filterEager(array) { + return array.filter(predicate); + } + const filterLazy = require_lazy.createLazyFunction((value, index, emit) => { + if (predicate(value, index)) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(filterEager, filterLazy); +} +//#endregion +exports.filter = filter; diff --git a/node_modules/es-toolkit/dist/fp/array/filter.mjs b/node_modules/es-toolkit/dist/fp/array/filter.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e6faa796f4e1a8bab0c17f0ae1e70a6cc1449ff2 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/filter.mjs @@ -0,0 +1,12 @@ +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/filter.ts +function filter(predicate) { + function filterEager(array) { + return array.filter(predicate); + } + return combineEagerAndLazyFunctions(filterEager, createLazyFunction((value, index, emit) => { + if (predicate(value, index)) emit(value); + })); +} +//#endregion +export { filter }; diff --git a/node_modules/es-toolkit/dist/fp/array/find.d.mts b/node_modules/es-toolkit/dist/fp/array/find.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3ba4d4e59689cc7138c59f7ad2cae7e49e516daa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/find.d.mts @@ -0,0 +1,39 @@ +//#region src/fp/array/find.d.ts +/** + * Creates a function that returns the first value accepted by a type guard. + * + * The predicate receives the value, index, and full input array. The returned + * function returns undefined when no value matches. + * + * @template T - The type of elements in the array. + * @template S - The narrowed element type accepted by the type guard. + * @param predicate - Type guard called with each value, index, and array until it returns true. + * @returns A function that maps a readonly array to the first matching value, or undefined. + * + * @example + * import { find, pipe } from 'es-toolkit/fp'; + * + * const isString = (value: string | number): value is string => typeof value === 'string'; + * pipe([1, 'a', 2], find(isString)); + * // => 'a' + */ +declare function find(predicate: (value: T, index: number, array: readonly T[]) => value is S): (array: readonly T[]) => S | undefined; +/** + * Creates a function that returns the first value matching a predicate. + * + * The predicate receives the value, index, and full input array. The returned + * function returns undefined when no value matches. + * + * @template T - The type of elements in the array. + * @param predicate - Predicate called with each value, index, and array until it returns true. + * @returns A function that maps a readonly array to the first matching value, or undefined. + * + * @example + * import { find, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], find(item => item.id === 2)); + * // => { id: 2 } + */ +declare function find(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => T | undefined; +//#endregion +export { find }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/find.d.ts b/node_modules/es-toolkit/dist/fp/array/find.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3ba4d4e59689cc7138c59f7ad2cae7e49e516daa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/find.d.ts @@ -0,0 +1,39 @@ +//#region src/fp/array/find.d.ts +/** + * Creates a function that returns the first value accepted by a type guard. + * + * The predicate receives the value, index, and full input array. The returned + * function returns undefined when no value matches. + * + * @template T - The type of elements in the array. + * @template S - The narrowed element type accepted by the type guard. + * @param predicate - Type guard called with each value, index, and array until it returns true. + * @returns A function that maps a readonly array to the first matching value, or undefined. + * + * @example + * import { find, pipe } from 'es-toolkit/fp'; + * + * const isString = (value: string | number): value is string => typeof value === 'string'; + * pipe([1, 'a', 2], find(isString)); + * // => 'a' + */ +declare function find(predicate: (value: T, index: number, array: readonly T[]) => value is S): (array: readonly T[]) => S | undefined; +/** + * Creates a function that returns the first value matching a predicate. + * + * The predicate receives the value, index, and full input array. The returned + * function returns undefined when no value matches. + * + * @template T - The type of elements in the array. + * @param predicate - Predicate called with each value, index, and array until it returns true. + * @returns A function that maps a readonly array to the first matching value, or undefined. + * + * @example + * import { find, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], find(item => item.id === 2)); + * // => { id: 2 } + */ +declare function find(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => T | undefined; +//#endregion +export { find }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/find.js b/node_modules/es-toolkit/dist/fp/array/find.js new file mode 100644 index 0000000000000000000000000000000000000000..1688b5d6bf3b936de297e43bcb7ecb949fcaae45 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/find.js @@ -0,0 +1,8 @@ +//#region src/fp/array/find.ts +function find(predicate) { + return function(array) { + return array.find(predicate); + }; +} +//#endregion +exports.find = find; diff --git a/node_modules/es-toolkit/dist/fp/array/find.mjs b/node_modules/es-toolkit/dist/fp/array/find.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ae088537c31e1bd1a930cd9fa50f8d9c1896ca39 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/find.mjs @@ -0,0 +1,8 @@ +//#region src/fp/array/find.ts +function find(predicate) { + return function(array) { + return array.find(predicate); + }; +} +//#endregion +export { find }; diff --git a/node_modules/es-toolkit/dist/fp/array/findIndex.d.mts b/node_modules/es-toolkit/dist/fp/array/findIndex.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..83f58aee6fdae6c33e9beb71125c9479414d6cfb --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findIndex.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/findIndex.d.ts +/** + * Creates a function that returns the index of the first value matching a predicate. + * + * The predicate receives the value, index, and full input array. The returned function + * returns -1 when no value matches, matching Array.prototype.findIndex. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each value, index, and array until it returns true. + * @returns A function that maps a readonly array to the first matching index, or -1. + * + * @example + * import { findIndex, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], findIndex(item => item.id === 2)); + * // => 1 + */ +declare function findIndex(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => number; +//#endregion +export { findIndex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/findIndex.d.ts b/node_modules/es-toolkit/dist/fp/array/findIndex.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..83f58aee6fdae6c33e9beb71125c9479414d6cfb --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findIndex.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/findIndex.d.ts +/** + * Creates a function that returns the index of the first value matching a predicate. + * + * The predicate receives the value, index, and full input array. The returned function + * returns -1 when no value matches, matching Array.prototype.findIndex. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each value, index, and array until it returns true. + * @returns A function that maps a readonly array to the first matching index, or -1. + * + * @example + * import { findIndex, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], findIndex(item => item.id === 2)); + * // => 1 + */ +declare function findIndex(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => number; +//#endregion +export { findIndex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/findIndex.js b/node_modules/es-toolkit/dist/fp/array/findIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..38e071a455cf3184661658f2cc9394f7a84eacc6 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findIndex.js @@ -0,0 +1,24 @@ +//#region src/fp/array/findIndex.ts +/** +* Creates a function that returns the index of the first value matching a predicate. +* +* The predicate receives the value, index, and full input array. The returned function +* returns -1 when no value matches, matching Array.prototype.findIndex. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each value, index, and array until it returns true. +* @returns A function that maps a readonly array to the first matching index, or -1. +* +* @example +* import { findIndex, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], findIndex(item => item.id === 2)); +* // => 1 +*/ +function findIndex(predicate) { + return function(array) { + return array.findIndex(predicate); + }; +} +//#endregion +exports.findIndex = findIndex; diff --git a/node_modules/es-toolkit/dist/fp/array/findIndex.mjs b/node_modules/es-toolkit/dist/fp/array/findIndex.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3d55479a377451641e74fd48d522ac4013d4edd4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findIndex.mjs @@ -0,0 +1,24 @@ +//#region src/fp/array/findIndex.ts +/** +* Creates a function that returns the index of the first value matching a predicate. +* +* The predicate receives the value, index, and full input array. The returned function +* returns -1 when no value matches, matching Array.prototype.findIndex. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each value, index, and array until it returns true. +* @returns A function that maps a readonly array to the first matching index, or -1. +* +* @example +* import { findIndex, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], findIndex(item => item.id === 2)); +* // => 1 +*/ +function findIndex(predicate) { + return function(array) { + return array.findIndex(predicate); + }; +} +//#endregion +export { findIndex }; diff --git a/node_modules/es-toolkit/dist/fp/array/findLast.d.mts b/node_modules/es-toolkit/dist/fp/array/findLast.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9410c4b3b48ba1cfa60de870bb9b3f8f86aeb56a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findLast.d.mts @@ -0,0 +1,39 @@ +//#region src/fp/array/findLast.d.ts +/** + * Creates a function that returns the last value accepted by a type guard. + * + * The predicate receives the value, index, and full input array while scanning + * from right to left. The returned function returns undefined when no value matches. + * + * @template T - The type of elements in the array. + * @template S - The narrowed element type accepted by the type guard. + * @param predicate - Type guard called with each value, index, and array from right to left. + * @returns A function that maps a readonly array to the last matching value, or undefined. + * + * @example + * import { findLast, pipe } from 'es-toolkit/fp'; + * + * const isString = (value: string | number): value is string => typeof value === 'string'; + * pipe([1, 'a', 2, 'b'], findLast(isString)); + * // => 'b' + */ +declare function findLast(predicate: (value: T, index: number, array: readonly T[]) => value is S): (array: readonly T[]) => S | undefined; +/** + * Creates a function that returns the last value matching a predicate. + * + * The predicate receives the value, index, and full input array while scanning + * from right to left. The returned function returns undefined when no value matches. + * + * @template T - The type of elements in the array. + * @param predicate - Predicate called with each value, index, and array from right to left. + * @returns A function that maps a readonly array to the last matching value, or undefined. + * + * @example + * import { findLast, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }, { id: 1 }], findLast(item => item.id === 1)); + * // => { id: 1 } + */ +declare function findLast(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => T | undefined; +//#endregion +export { findLast }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/findLast.d.ts b/node_modules/es-toolkit/dist/fp/array/findLast.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9410c4b3b48ba1cfa60de870bb9b3f8f86aeb56a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findLast.d.ts @@ -0,0 +1,39 @@ +//#region src/fp/array/findLast.d.ts +/** + * Creates a function that returns the last value accepted by a type guard. + * + * The predicate receives the value, index, and full input array while scanning + * from right to left. The returned function returns undefined when no value matches. + * + * @template T - The type of elements in the array. + * @template S - The narrowed element type accepted by the type guard. + * @param predicate - Type guard called with each value, index, and array from right to left. + * @returns A function that maps a readonly array to the last matching value, or undefined. + * + * @example + * import { findLast, pipe } from 'es-toolkit/fp'; + * + * const isString = (value: string | number): value is string => typeof value === 'string'; + * pipe([1, 'a', 2, 'b'], findLast(isString)); + * // => 'b' + */ +declare function findLast(predicate: (value: T, index: number, array: readonly T[]) => value is S): (array: readonly T[]) => S | undefined; +/** + * Creates a function that returns the last value matching a predicate. + * + * The predicate receives the value, index, and full input array while scanning + * from right to left. The returned function returns undefined when no value matches. + * + * @template T - The type of elements in the array. + * @param predicate - Predicate called with each value, index, and array from right to left. + * @returns A function that maps a readonly array to the last matching value, or undefined. + * + * @example + * import { findLast, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }, { id: 1 }], findLast(item => item.id === 1)); + * // => { id: 1 } + */ +declare function findLast(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => T | undefined; +//#endregion +export { findLast }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/findLast.js b/node_modules/es-toolkit/dist/fp/array/findLast.js new file mode 100644 index 0000000000000000000000000000000000000000..e667c2ee9659007f3eb8a6ce23d3dd7e3e265040 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findLast.js @@ -0,0 +1,11 @@ +//#region src/fp/array/findLast.ts +function findLast(predicate) { + return function(array) { + for (let index = array.length - 1; index >= 0; index--) { + const value = array[index]; + if (predicate(value, index, array)) return value; + } + }; +} +//#endregion +exports.findLast = findLast; diff --git a/node_modules/es-toolkit/dist/fp/array/findLast.mjs b/node_modules/es-toolkit/dist/fp/array/findLast.mjs new file mode 100644 index 0000000000000000000000000000000000000000..51c0ae1e822fc898c7befe6cac2eb0daae6b410c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findLast.mjs @@ -0,0 +1,11 @@ +//#region src/fp/array/findLast.ts +function findLast(predicate) { + return function(array) { + for (let index = array.length - 1; index >= 0; index--) { + const value = array[index]; + if (predicate(value, index, array)) return value; + } + }; +} +//#endregion +export { findLast }; diff --git a/node_modules/es-toolkit/dist/fp/array/findLastIndex.d.mts b/node_modules/es-toolkit/dist/fp/array/findLastIndex.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..36eaa33593cd386b988cc2fc08d83d57bf861a4f --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findLastIndex.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/findLastIndex.d.ts +/** + * Creates a function that returns the index of the last value matching a predicate. + * + * The predicate receives the value, index, and full input array while scanning from right + * to left. The returned function returns -1 when no value matches. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each value, index, and array from right to left until it returns true. + * @returns A function that maps a readonly array to the last matching index, or -1. + * + * @example + * import { findLastIndex, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 2], findLastIndex(value => value === 2)); + * // => 3 + */ +declare function findLastIndex(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => number; +//#endregion +export { findLastIndex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/findLastIndex.d.ts b/node_modules/es-toolkit/dist/fp/array/findLastIndex.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..36eaa33593cd386b988cc2fc08d83d57bf861a4f --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findLastIndex.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/findLastIndex.d.ts +/** + * Creates a function that returns the index of the last value matching a predicate. + * + * The predicate receives the value, index, and full input array while scanning from right + * to left. The returned function returns -1 when no value matches. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each value, index, and array from right to left until it returns true. + * @returns A function that maps a readonly array to the last matching index, or -1. + * + * @example + * import { findLastIndex, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 2], findLastIndex(value => value === 2)); + * // => 3 + */ +declare function findLastIndex(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => number; +//#endregion +export { findLastIndex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/findLastIndex.js b/node_modules/es-toolkit/dist/fp/array/findLastIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..30fc0c182fc48a6b4eab4272313e5a3614ccd65b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findLastIndex.js @@ -0,0 +1,25 @@ +//#region src/fp/array/findLastIndex.ts +/** +* Creates a function that returns the index of the last value matching a predicate. +* +* The predicate receives the value, index, and full input array while scanning from right +* to left. The returned function returns -1 when no value matches. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each value, index, and array from right to left until it returns true. +* @returns A function that maps a readonly array to the last matching index, or -1. +* +* @example +* import { findLastIndex, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 2], findLastIndex(value => value === 2)); +* // => 3 +*/ +function findLastIndex(predicate) { + return function(array) { + for (let index = array.length - 1; index >= 0; index--) if (predicate(array[index], index, array)) return index; + return -1; + }; +} +//#endregion +exports.findLastIndex = findLastIndex; diff --git a/node_modules/es-toolkit/dist/fp/array/findLastIndex.mjs b/node_modules/es-toolkit/dist/fp/array/findLastIndex.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ddb93e70496849f3b4e360faf5caebbb141d4f86 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/findLastIndex.mjs @@ -0,0 +1,25 @@ +//#region src/fp/array/findLastIndex.ts +/** +* Creates a function that returns the index of the last value matching a predicate. +* +* The predicate receives the value, index, and full input array while scanning from right +* to left. The returned function returns -1 when no value matches. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each value, index, and array from right to left until it returns true. +* @returns A function that maps a readonly array to the last matching index, or -1. +* +* @example +* import { findLastIndex, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 2], findLastIndex(value => value === 2)); +* // => 3 +*/ +function findLastIndex(predicate) { + return function(array) { + for (let index = array.length - 1; index >= 0; index--) if (predicate(array[index], index, array)) return index; + return -1; + }; +} +//#endregion +export { findLastIndex }; diff --git a/node_modules/es-toolkit/dist/fp/array/flatMap.d.mts b/node_modules/es-toolkit/dist/fp/array/flatMap.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..accab151106f32df7d2b105941a8d7aa1e190514 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatMap.d.mts @@ -0,0 +1,28 @@ +//#region src/fp/array/flatMap.d.ts +/** + * Creates a function that maps every element to an array with `callback` and + * concatenates the results, equivalent to `Array.prototype.flatMap`. Use it + * with {@link pipe}. + * + * The returned function is **lazy-capable**: inside a {@link pipe} it is fused + * with adjacent lazy functions and runs element-by-element, so a trailing + * `take` can terminate the walk early without expanding the rest of the input. + * + * @template T - The type of elements in the input array. + * @template U - The type of elements in the output array. + * @param callback - Called with `(value, index)` for each element; returns an + * array whose elements are flattened into the output. + * @returns A function that maps a `readonly T[]` to a new `U[]`. + * + * @example + * import { pipe, flatMap } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], flatMap(x => [x, x * 10])); // => [1, 10, 2, 20, 3, 30] + * + * @example + * // Returning an empty array drops the element. + * pipe([1, 2, 3, 4], flatMap(x => (x % 2 === 0 ? [x] : []))); // => [2, 4] + */ +declare function flatMap(callback: (value: T, index: number) => U[]): (array: readonly T[]) => U[]; +//#endregion +export { flatMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/flatMap.d.ts b/node_modules/es-toolkit/dist/fp/array/flatMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..accab151106f32df7d2b105941a8d7aa1e190514 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatMap.d.ts @@ -0,0 +1,28 @@ +//#region src/fp/array/flatMap.d.ts +/** + * Creates a function that maps every element to an array with `callback` and + * concatenates the results, equivalent to `Array.prototype.flatMap`. Use it + * with {@link pipe}. + * + * The returned function is **lazy-capable**: inside a {@link pipe} it is fused + * with adjacent lazy functions and runs element-by-element, so a trailing + * `take` can terminate the walk early without expanding the rest of the input. + * + * @template T - The type of elements in the input array. + * @template U - The type of elements in the output array. + * @param callback - Called with `(value, index)` for each element; returns an + * array whose elements are flattened into the output. + * @returns A function that maps a `readonly T[]` to a new `U[]`. + * + * @example + * import { pipe, flatMap } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], flatMap(x => [x, x * 10])); // => [1, 10, 2, 20, 3, 30] + * + * @example + * // Returning an empty array drops the element. + * pipe([1, 2, 3, 4], flatMap(x => (x % 2 === 0 ? [x] : []))); // => [2, 4] + */ +declare function flatMap(callback: (value: T, index: number) => U[]): (array: readonly T[]) => U[]; +//#endregion +export { flatMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/flatMap.js b/node_modules/es-toolkit/dist/fp/array/flatMap.js new file mode 100644 index 0000000000000000000000000000000000000000..9a7d2ea687366914ed2433f13284e816074b1b61 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatMap.js @@ -0,0 +1,39 @@ +const require_flatMap = require("../../array/flatMap.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/flatMap.ts +/** +* Creates a function that maps every element to an array with `callback` and +* concatenates the results, equivalent to `Array.prototype.flatMap`. Use it +* with {@link pipe}. +* +* The returned function is **lazy-capable**: inside a {@link pipe} it is fused +* with adjacent lazy functions and runs element-by-element, so a trailing +* `take` can terminate the walk early without expanding the rest of the input. +* +* @template T - The type of elements in the input array. +* @template U - The type of elements in the output array. +* @param callback - Called with `(value, index)` for each element; returns an +* array whose elements are flattened into the output. +* @returns A function that maps a `readonly T[]` to a new `U[]`. +* +* @example +* import { pipe, flatMap } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], flatMap(x => [x, x * 10])); // => [1, 10, 2, 20, 3, 30] +* +* @example +* // Returning an empty array drops the element. +* pipe([1, 2, 3, 4], flatMap(x => (x % 2 === 0 ? [x] : []))); // => [2, 4] +*/ +function flatMap(callback) { + function flatMapEager(array) { + return require_flatMap.flatMap(array, callback); + } + const flatMapLazy = require_lazy.createLazyFunction((value, index, emit) => { + const items = callback(value, index); + for (let i = 0; i < items.length; i++) emit(items[i]); + }); + return require_lazy.combineEagerAndLazyFunctions(flatMapEager, flatMapLazy); +} +//#endregion +exports.flatMap = flatMap; diff --git a/node_modules/es-toolkit/dist/fp/array/flatMap.mjs b/node_modules/es-toolkit/dist/fp/array/flatMap.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3a6d0a8fb86541bfcf64ebdf45055b3920f580b6 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatMap.mjs @@ -0,0 +1,38 @@ +import { flatMap as flatMap$1 } from "../../array/flatMap.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/flatMap.ts +/** +* Creates a function that maps every element to an array with `callback` and +* concatenates the results, equivalent to `Array.prototype.flatMap`. Use it +* with {@link pipe}. +* +* The returned function is **lazy-capable**: inside a {@link pipe} it is fused +* with adjacent lazy functions and runs element-by-element, so a trailing +* `take` can terminate the walk early without expanding the rest of the input. +* +* @template T - The type of elements in the input array. +* @template U - The type of elements in the output array. +* @param callback - Called with `(value, index)` for each element; returns an +* array whose elements are flattened into the output. +* @returns A function that maps a `readonly T[]` to a new `U[]`. +* +* @example +* import { pipe, flatMap } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], flatMap(x => [x, x * 10])); // => [1, 10, 2, 20, 3, 30] +* +* @example +* // Returning an empty array drops the element. +* pipe([1, 2, 3, 4], flatMap(x => (x % 2 === 0 ? [x] : []))); // => [2, 4] +*/ +function flatMap(callback) { + function flatMapEager(array) { + return flatMap$1(array, callback); + } + return combineEagerAndLazyFunctions(flatMapEager, createLazyFunction((value, index, emit) => { + const items = callback(value, index); + for (let i = 0; i < items.length; i++) emit(items[i]); + })); +} +//#endregion +export { flatMap }; diff --git a/node_modules/es-toolkit/dist/fp/array/flatMapDeep.d.mts b/node_modules/es-toolkit/dist/fp/array/flatMapDeep.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ee94b0582efc92cdc031ed472f4f8836b7cbf78f --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatMapDeep.d.mts @@ -0,0 +1,23 @@ +import { ExtractNestedArrayType } from "../../array/flattenDeep.mjs"; + +//#region src/fp/array/flatMapDeep.d.ts +/** + * Creates a function that maps each element and recursively flattens the mapped values. + * + * The iteratee receives each value and index. The returned function is lazy-capable inside + * {@link pipe}; a trailing short-circuiting operator can stop before later input values are mapped. + * + * @template T - The type of elements in the input array. + * @template U - The type returned by the iteratee before recursive flattening. + * @param iteratee - Called with each value and index to produce values to flatten. + * @returns A function that maps a readonly array to a deeply flattened array. + * + * @example + * import { flatMapDeep, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2], flatMapDeep(value => [[value, value * 10]])); + * // => [1, 10, 2, 20] + */ +declare function flatMapDeep(iteratee: (item: T, index: number) => U): (array: readonly T[]) => Array>; +//#endregion +export { flatMapDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/flatMapDeep.d.ts b/node_modules/es-toolkit/dist/fp/array/flatMapDeep.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..96e7f3ef978446b40946dd8cdccfcd16989add89 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatMapDeep.d.ts @@ -0,0 +1,23 @@ +import { ExtractNestedArrayType } from "../../array/flattenDeep.js"; + +//#region src/fp/array/flatMapDeep.d.ts +/** + * Creates a function that maps each element and recursively flattens the mapped values. + * + * The iteratee receives each value and index. The returned function is lazy-capable inside + * {@link pipe}; a trailing short-circuiting operator can stop before later input values are mapped. + * + * @template T - The type of elements in the input array. + * @template U - The type returned by the iteratee before recursive flattening. + * @param iteratee - Called with each value and index to produce values to flatten. + * @returns A function that maps a readonly array to a deeply flattened array. + * + * @example + * import { flatMapDeep, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2], flatMapDeep(value => [[value, value * 10]])); + * // => [1, 10, 2, 20] + */ +declare function flatMapDeep(iteratee: (item: T, index: number) => U): (array: readonly T[]) => Array>; +//#endregion +export { flatMapDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/flatMapDeep.js b/node_modules/es-toolkit/dist/fp/array/flatMapDeep.js new file mode 100644 index 0000000000000000000000000000000000000000..8f8337e1c3e4f258bcb6b1ec29d051c76338ca5d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatMapDeep.js @@ -0,0 +1,38 @@ +const require_flatMapDeep = require("../../array/flatMapDeep.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/flatMapDeep.ts +/** +* Creates a function that maps each element and recursively flattens the mapped values. +* +* The iteratee receives each value and index. The returned function is lazy-capable inside +* {@link pipe}; a trailing short-circuiting operator can stop before later input values are mapped. +* +* @template T - The type of elements in the input array. +* @template U - The type returned by the iteratee before recursive flattening. +* @param iteratee - Called with each value and index to produce values to flatten. +* @returns A function that maps a readonly array to a deeply flattened array. +* +* @example +* import { flatMapDeep, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2], flatMapDeep(value => [[value, value * 10]])); +* // => [1, 10, 2, 20] +*/ +function flatMapDeep(iteratee) { + function flatMapDeepEager(array) { + return require_flatMapDeep.flatMapDeep(array, (item, index) => iteratee(item, index)); + } + const flatMapDeepLazy = require_lazy.createLazyFunction((value, index, emit) => { + emitDeep(iteratee(value, index), emit); + }); + return require_lazy.combineEagerAndLazyFunctions(flatMapDeepEager, flatMapDeepLazy); +} +function emitDeep(value, emit) { + if (Array.isArray(value)) { + for (let index = 0; index < value.length; index++) emitDeep(value[index], emit); + return; + } + emit(value); +} +//#endregion +exports.flatMapDeep = flatMapDeep; diff --git a/node_modules/es-toolkit/dist/fp/array/flatMapDeep.mjs b/node_modules/es-toolkit/dist/fp/array/flatMapDeep.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9892677f14182611bca09e718ae3103f92063eb1 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatMapDeep.mjs @@ -0,0 +1,37 @@ +import { flatMapDeep as flatMapDeep$1 } from "../../array/flatMapDeep.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/flatMapDeep.ts +/** +* Creates a function that maps each element and recursively flattens the mapped values. +* +* The iteratee receives each value and index. The returned function is lazy-capable inside +* {@link pipe}; a trailing short-circuiting operator can stop before later input values are mapped. +* +* @template T - The type of elements in the input array. +* @template U - The type returned by the iteratee before recursive flattening. +* @param iteratee - Called with each value and index to produce values to flatten. +* @returns A function that maps a readonly array to a deeply flattened array. +* +* @example +* import { flatMapDeep, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2], flatMapDeep(value => [[value, value * 10]])); +* // => [1, 10, 2, 20] +*/ +function flatMapDeep(iteratee) { + function flatMapDeepEager(array) { + return flatMapDeep$1(array, (item, index) => iteratee(item, index)); + } + return combineEagerAndLazyFunctions(flatMapDeepEager, createLazyFunction((value, index, emit) => { + emitDeep(iteratee(value, index), emit); + })); +} +function emitDeep(value, emit) { + if (Array.isArray(value)) { + for (let index = 0; index < value.length; index++) emitDeep(value[index], emit); + return; + } + emit(value); +} +//#endregion +export { flatMapDeep }; diff --git a/node_modules/es-toolkit/dist/fp/array/flatten.d.mts b/node_modules/es-toolkit/dist/fp/array/flatten.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2f006a617121da18b2b0e9c1a12ac937045db4e2 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatten.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/flatten.d.ts +/** + * Creates a function that flattens an array up to the specified depth. + * + * The returned function is lazy-capable inside {@link pipe}. A trailing + * short-circuiting operator can stop before later nested values are visited. + * + * @template T - The type of elements in the array. + * @template D - The depth to which nested arrays should be flattened. + * @param depth - The flattening depth. Defaults to 1. + * @returns A function that maps the piped array to a flattened array. + * + * @example + * import { flatten, pipe } from 'es-toolkit/fp'; + * + * pipe([1, [2, [3]]], flatten(2)); + * // => [1, 2, 3] + */ +declare function flatten(depth?: D): (array: readonly T[]) => Array>; +//#endregion +export { flatten }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/flatten.d.ts b/node_modules/es-toolkit/dist/fp/array/flatten.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f006a617121da18b2b0e9c1a12ac937045db4e2 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatten.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/flatten.d.ts +/** + * Creates a function that flattens an array up to the specified depth. + * + * The returned function is lazy-capable inside {@link pipe}. A trailing + * short-circuiting operator can stop before later nested values are visited. + * + * @template T - The type of elements in the array. + * @template D - The depth to which nested arrays should be flattened. + * @param depth - The flattening depth. Defaults to 1. + * @returns A function that maps the piped array to a flattened array. + * + * @example + * import { flatten, pipe } from 'es-toolkit/fp'; + * + * pipe([1, [2, [3]]], flatten(2)); + * // => [1, 2, 3] + */ +declare function flatten(depth?: D): (array: readonly T[]) => Array>; +//#endregion +export { flatten }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/flatten.js b/node_modules/es-toolkit/dist/fp/array/flatten.js new file mode 100644 index 0000000000000000000000000000000000000000..4dfebc432bf9b2538753f2a7a062c49714d57a91 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatten.js @@ -0,0 +1,39 @@ +const require_flatten = require("../../array/flatten.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/flatten.ts +/** +* Creates a function that flattens an array up to the specified depth. +* +* The returned function is lazy-capable inside {@link pipe}. A trailing +* short-circuiting operator can stop before later nested values are visited. +* +* @template T - The type of elements in the array. +* @template D - The depth to which nested arrays should be flattened. +* @param depth - The flattening depth. Defaults to 1. +* @returns A function that maps the piped array to a flattened array. +* +* @example +* import { flatten, pipe } from 'es-toolkit/fp'; +* +* pipe([1, [2, [3]]], flatten(2)); +* // => [1, 2, 3] +*/ +function flatten(depth = 1) { + const flooredDepth = Math.floor(depth); + function flattenEager(array) { + return require_flatten.flatten(array, depth); + } + const flattenLazy = require_lazy.createLazyFunction((value, _index, emit) => { + emitFlattened(value, 0, flooredDepth, emit); + }); + return require_lazy.combineEagerAndLazyFunctions(flattenEager, flattenLazy); +} +function emitFlattened(value, currentDepth, maxDepth, emit) { + if (Array.isArray(value) && currentDepth < maxDepth) { + for (let index = 0; index < value.length; index++) emitFlattened(value[index], currentDepth + 1, maxDepth, emit); + return; + } + emit(value); +} +//#endregion +exports.flatten = flatten; diff --git a/node_modules/es-toolkit/dist/fp/array/flatten.mjs b/node_modules/es-toolkit/dist/fp/array/flatten.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5dd3f87b49f497d665c71b36110b8ec20c2fd558 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flatten.mjs @@ -0,0 +1,38 @@ +import { flatten as flatten$1 } from "../../array/flatten.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/flatten.ts +/** +* Creates a function that flattens an array up to the specified depth. +* +* The returned function is lazy-capable inside {@link pipe}. A trailing +* short-circuiting operator can stop before later nested values are visited. +* +* @template T - The type of elements in the array. +* @template D - The depth to which nested arrays should be flattened. +* @param depth - The flattening depth. Defaults to 1. +* @returns A function that maps the piped array to a flattened array. +* +* @example +* import { flatten, pipe } from 'es-toolkit/fp'; +* +* pipe([1, [2, [3]]], flatten(2)); +* // => [1, 2, 3] +*/ +function flatten(depth = 1) { + const flooredDepth = Math.floor(depth); + function flattenEager(array) { + return flatten$1(array, depth); + } + return combineEagerAndLazyFunctions(flattenEager, createLazyFunction((value, _index, emit) => { + emitFlattened(value, 0, flooredDepth, emit); + })); +} +function emitFlattened(value, currentDepth, maxDepth, emit) { + if (Array.isArray(value) && currentDepth < maxDepth) { + for (let index = 0; index < value.length; index++) emitFlattened(value[index], currentDepth + 1, maxDepth, emit); + return; + } + emit(value); +} +//#endregion +export { flatten }; diff --git a/node_modules/es-toolkit/dist/fp/array/flattenDeep.d.mts b/node_modules/es-toolkit/dist/fp/array/flattenDeep.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7dd639ff7245cb05d37f4edfc8b7352fcc1fdd44 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flattenDeep.d.mts @@ -0,0 +1,21 @@ +import { ExtractNestedArrayType } from "../../array/flattenDeep.mjs"; + +//#region src/fp/array/flattenDeep.d.ts +/** + * Creates a function that recursively flattens an array. + * + * The returned function is lazy-capable inside {@link pipe}. A trailing + * short-circuiting operator can stop before later nested values are visited. + * + * @template T - The type of elements in the array. + * @returns A function that maps the piped array to a deeply flattened array. + * + * @example + * import { flattenDeep, pipe } from 'es-toolkit/fp'; + * + * pipe([1, [2, [3]]], flattenDeep()); + * // => [1, 2, 3] + */ +declare function flattenDeep(): (array: readonly T[]) => Array>; +//#endregion +export { flattenDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/flattenDeep.d.ts b/node_modules/es-toolkit/dist/fp/array/flattenDeep.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..de046565a5b71a859d8a26bacc0969982b7de515 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flattenDeep.d.ts @@ -0,0 +1,21 @@ +import { ExtractNestedArrayType } from "../../array/flattenDeep.js"; + +//#region src/fp/array/flattenDeep.d.ts +/** + * Creates a function that recursively flattens an array. + * + * The returned function is lazy-capable inside {@link pipe}. A trailing + * short-circuiting operator can stop before later nested values are visited. + * + * @template T - The type of elements in the array. + * @returns A function that maps the piped array to a deeply flattened array. + * + * @example + * import { flattenDeep, pipe } from 'es-toolkit/fp'; + * + * pipe([1, [2, [3]]], flattenDeep()); + * // => [1, 2, 3] + */ +declare function flattenDeep(): (array: readonly T[]) => Array>; +//#endregion +export { flattenDeep }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/flattenDeep.js b/node_modules/es-toolkit/dist/fp/array/flattenDeep.js new file mode 100644 index 0000000000000000000000000000000000000000..b3b03641b08584794fd083bf1268a2f43e274b08 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flattenDeep.js @@ -0,0 +1,36 @@ +const require_flattenDeep = require("../../array/flattenDeep.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/flattenDeep.ts +/** +* Creates a function that recursively flattens an array. +* +* The returned function is lazy-capable inside {@link pipe}. A trailing +* short-circuiting operator can stop before later nested values are visited. +* +* @template T - The type of elements in the array. +* @returns A function that maps the piped array to a deeply flattened array. +* +* @example +* import { flattenDeep, pipe } from 'es-toolkit/fp'; +* +* pipe([1, [2, [3]]], flattenDeep()); +* // => [1, 2, 3] +*/ +function flattenDeep() { + function flattenDeepEager(array) { + return require_flattenDeep.flattenDeep(array); + } + const flattenDeepLazy = require_lazy.createLazyFunction((value, _index, emit) => { + emitDeep(value, emit); + }); + return require_lazy.combineEagerAndLazyFunctions(flattenDeepEager, flattenDeepLazy); +} +function emitDeep(value, emit) { + if (Array.isArray(value)) { + for (let index = 0; index < value.length; index++) emitDeep(value[index], emit); + return; + } + emit(value); +} +//#endregion +exports.flattenDeep = flattenDeep; diff --git a/node_modules/es-toolkit/dist/fp/array/flattenDeep.mjs b/node_modules/es-toolkit/dist/fp/array/flattenDeep.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2cb7dc2890b6c3a8f63f820eafd04fe8f8665877 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/flattenDeep.mjs @@ -0,0 +1,35 @@ +import { flattenDeep as flattenDeep$1 } from "../../array/flattenDeep.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/flattenDeep.ts +/** +* Creates a function that recursively flattens an array. +* +* The returned function is lazy-capable inside {@link pipe}. A trailing +* short-circuiting operator can stop before later nested values are visited. +* +* @template T - The type of elements in the array. +* @returns A function that maps the piped array to a deeply flattened array. +* +* @example +* import { flattenDeep, pipe } from 'es-toolkit/fp'; +* +* pipe([1, [2, [3]]], flattenDeep()); +* // => [1, 2, 3] +*/ +function flattenDeep() { + function flattenDeepEager(array) { + return flattenDeep$1(array); + } + return combineEagerAndLazyFunctions(flattenDeepEager, createLazyFunction((value, _index, emit) => { + emitDeep(value, emit); + })); +} +function emitDeep(value, emit) { + if (Array.isArray(value)) { + for (let index = 0; index < value.length; index++) emitDeep(value[index], emit); + return; + } + emit(value); +} +//#endregion +export { flattenDeep }; diff --git a/node_modules/es-toolkit/dist/fp/array/forEach.d.mts b/node_modules/es-toolkit/dist/fp/array/forEach.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b05cde999babe0045371368db01c94eb685d6610 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/forEach.d.mts @@ -0,0 +1,22 @@ +//#region src/fp/array/forEach.d.ts +/** + * Creates a function that runs a callback for every element and returns the original array. + * + * This mirrors Remeda's pipeline-friendly `forEach` behavior: the side effect + * runs, then the input continues through the pipeline by reference. The returned + * function is lazy-capable inside {@link pipe}; when followed by a + * short-circuiting operator, the callback only runs for consumed values. + * + * @template T - The type of elements in the array. + * @param callback - Called with each value and index. + * @returns A function that performs the side effect and returns the original array. + * + * @example + * import { forEach, map, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], forEach(value => console.log(value)), map(value => value * 2)); + * // => [2, 4, 6] + */ +declare function forEach(callback: (value: T, index: number) => void): (array: readonly T[]) => readonly T[]; +//#endregion +export { forEach }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/forEach.d.ts b/node_modules/es-toolkit/dist/fp/array/forEach.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b05cde999babe0045371368db01c94eb685d6610 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/forEach.d.ts @@ -0,0 +1,22 @@ +//#region src/fp/array/forEach.d.ts +/** + * Creates a function that runs a callback for every element and returns the original array. + * + * This mirrors Remeda's pipeline-friendly `forEach` behavior: the side effect + * runs, then the input continues through the pipeline by reference. The returned + * function is lazy-capable inside {@link pipe}; when followed by a + * short-circuiting operator, the callback only runs for consumed values. + * + * @template T - The type of elements in the array. + * @param callback - Called with each value and index. + * @returns A function that performs the side effect and returns the original array. + * + * @example + * import { forEach, map, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], forEach(value => console.log(value)), map(value => value * 2)); + * // => [2, 4, 6] + */ +declare function forEach(callback: (value: T, index: number) => void): (array: readonly T[]) => readonly T[]; +//#endregion +export { forEach }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/forEach.js b/node_modules/es-toolkit/dist/fp/array/forEach.js new file mode 100644 index 0000000000000000000000000000000000000000..01ce3bb570844c85bd6fb4da4f05b7bf0a44af3c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/forEach.js @@ -0,0 +1,33 @@ +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/forEach.ts +/** +* Creates a function that runs a callback for every element and returns the original array. +* +* This mirrors Remeda's pipeline-friendly `forEach` behavior: the side effect +* runs, then the input continues through the pipeline by reference. The returned +* function is lazy-capable inside {@link pipe}; when followed by a +* short-circuiting operator, the callback only runs for consumed values. +* +* @template T - The type of elements in the array. +* @param callback - Called with each value and index. +* @returns A function that performs the side effect and returns the original array. +* +* @example +* import { forEach, map, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], forEach(value => console.log(value)), map(value => value * 2)); +* // => [2, 4, 6] +*/ +function forEach(callback) { + function forEachEager(array) { + array.forEach(callback); + return array; + } + const forEachLazy = require_lazy.createLazyFunction((value, index, emit) => { + callback(value, index); + emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(forEachEager, forEachLazy); +} +//#endregion +exports.forEach = forEach; diff --git a/node_modules/es-toolkit/dist/fp/array/forEach.mjs b/node_modules/es-toolkit/dist/fp/array/forEach.mjs new file mode 100644 index 0000000000000000000000000000000000000000..af36badd81fe0670a7bf494594092430774ff789 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/forEach.mjs @@ -0,0 +1,32 @@ +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/forEach.ts +/** +* Creates a function that runs a callback for every element and returns the original array. +* +* This mirrors Remeda's pipeline-friendly `forEach` behavior: the side effect +* runs, then the input continues through the pipeline by reference. The returned +* function is lazy-capable inside {@link pipe}; when followed by a +* short-circuiting operator, the callback only runs for consumed values. +* +* @template T - The type of elements in the array. +* @param callback - Called with each value and index. +* @returns A function that performs the side effect and returns the original array. +* +* @example +* import { forEach, map, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], forEach(value => console.log(value)), map(value => value * 2)); +* // => [2, 4, 6] +*/ +function forEach(callback) { + function forEachEager(array) { + array.forEach(callback); + return array; + } + return combineEagerAndLazyFunctions(forEachEager, createLazyFunction((value, index, emit) => { + callback(value, index); + emit(value); + })); +} +//#endregion +export { forEach }; diff --git a/node_modules/es-toolkit/dist/fp/array/groupBy.d.mts b/node_modules/es-toolkit/dist/fp/array/groupBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ba0d334bf7c15276bcb2e4c7e39dc9ea24ac15a5 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/groupBy.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/groupBy.d.ts +/** + * Creates a function that groups values by a derived key. + * + * The key selector receives each value, index, and full input array. Values that produce + * the same key are collected in insertion order. + * + * @template T - The type of elements in the array. + * @template K - The property-key type produced by the selector. + * @param getKey - Called with each value, index, and array to produce a group key. + * @returns A function that maps a readonly array to grouped values. + * + * @example + * import { groupBy, pipe } from 'es-toolkit/fp'; + * + * pipe(['ant', 'bear', 'cat'], groupBy(word => word.length)); + * // => { 3: ['ant', 'cat'], 4: ['bear'] } + */ +declare function groupBy(getKey: (item: T, index: number, array: readonly T[]) => K): (array: readonly T[]) => Record; +//#endregion +export { groupBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/groupBy.d.ts b/node_modules/es-toolkit/dist/fp/array/groupBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba0d334bf7c15276bcb2e4c7e39dc9ea24ac15a5 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/groupBy.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/groupBy.d.ts +/** + * Creates a function that groups values by a derived key. + * + * The key selector receives each value, index, and full input array. Values that produce + * the same key are collected in insertion order. + * + * @template T - The type of elements in the array. + * @template K - The property-key type produced by the selector. + * @param getKey - Called with each value, index, and array to produce a group key. + * @returns A function that maps a readonly array to grouped values. + * + * @example + * import { groupBy, pipe } from 'es-toolkit/fp'; + * + * pipe(['ant', 'bear', 'cat'], groupBy(word => word.length)); + * // => { 3: ['ant', 'cat'], 4: ['bear'] } + */ +declare function groupBy(getKey: (item: T, index: number, array: readonly T[]) => K): (array: readonly T[]) => Record; +//#endregion +export { groupBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/groupBy.js b/node_modules/es-toolkit/dist/fp/array/groupBy.js new file mode 100644 index 0000000000000000000000000000000000000000..933494379e53c9042aedc99cabee2cf6b167ed0d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/groupBy.js @@ -0,0 +1,26 @@ +const require_groupBy = require("../../array/groupBy.js"); +//#region src/fp/array/groupBy.ts +/** +* Creates a function that groups values by a derived key. +* +* The key selector receives each value, index, and full input array. Values that produce +* the same key are collected in insertion order. +* +* @template T - The type of elements in the array. +* @template K - The property-key type produced by the selector. +* @param getKey - Called with each value, index, and array to produce a group key. +* @returns A function that maps a readonly array to grouped values. +* +* @example +* import { groupBy, pipe } from 'es-toolkit/fp'; +* +* pipe(['ant', 'bear', 'cat'], groupBy(word => word.length)); +* // => { 3: ['ant', 'cat'], 4: ['bear'] } +*/ +function groupBy(getKey) { + return function(array) { + return require_groupBy.groupBy(array, getKey); + }; +} +//#endregion +exports.groupBy = groupBy; diff --git a/node_modules/es-toolkit/dist/fp/array/groupBy.mjs b/node_modules/es-toolkit/dist/fp/array/groupBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3ec6b20e22496f94e66acb043436ff173645c093 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/groupBy.mjs @@ -0,0 +1,26 @@ +import { groupBy as groupBy$1 } from "../../array/groupBy.mjs"; +//#region src/fp/array/groupBy.ts +/** +* Creates a function that groups values by a derived key. +* +* The key selector receives each value, index, and full input array. Values that produce +* the same key are collected in insertion order. +* +* @template T - The type of elements in the array. +* @template K - The property-key type produced by the selector. +* @param getKey - Called with each value, index, and array to produce a group key. +* @returns A function that maps a readonly array to grouped values. +* +* @example +* import { groupBy, pipe } from 'es-toolkit/fp'; +* +* pipe(['ant', 'bear', 'cat'], groupBy(word => word.length)); +* // => { 3: ['ant', 'cat'], 4: ['bear'] } +*/ +function groupBy(getKey) { + return function(array) { + return groupBy$1(array, getKey); + }; +} +//#endregion +export { groupBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/head.d.mts b/node_modules/es-toolkit/dist/fp/array/head.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ef18029859932f56d36c23c9251b88f5137e980f --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/head.d.mts @@ -0,0 +1,35 @@ +//#region src/fp/array/head.d.ts +/** + * Creates a function that returns the first element of a non-empty array. + * + * This overload preserves the non-empty tuple guarantee: the returned function + * always returns T when the piped array has at least one element. + * + * @template T - The type of elements in the array. + * @returns A function that maps a non-empty readonly array to its first element. + * + * @example + * import { head, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3] as const, head()); + * // => 1 + */ +declare function head(): (array: readonly [T, ...T[]]) => T; +/** + * Creates a function that returns the first element of an array, or undefined. + * + * Empty arrays return undefined, matching the main {@link head} behavior. Use + * the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to its first element, or undefined. + * + * @example + * import { head, pipe } from 'es-toolkit/fp'; + * + * pipe([] as number[], head()); + * // => undefined + */ +declare function head(): (array: readonly T[]) => T | undefined; +//#endregion +export { head }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/head.d.ts b/node_modules/es-toolkit/dist/fp/array/head.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef18029859932f56d36c23c9251b88f5137e980f --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/head.d.ts @@ -0,0 +1,35 @@ +//#region src/fp/array/head.d.ts +/** + * Creates a function that returns the first element of a non-empty array. + * + * This overload preserves the non-empty tuple guarantee: the returned function + * always returns T when the piped array has at least one element. + * + * @template T - The type of elements in the array. + * @returns A function that maps a non-empty readonly array to its first element. + * + * @example + * import { head, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3] as const, head()); + * // => 1 + */ +declare function head(): (array: readonly [T, ...T[]]) => T; +/** + * Creates a function that returns the first element of an array, or undefined. + * + * Empty arrays return undefined, matching the main {@link head} behavior. Use + * the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to its first element, or undefined. + * + * @example + * import { head, pipe } from 'es-toolkit/fp'; + * + * pipe([] as number[], head()); + * // => undefined + */ +declare function head(): (array: readonly T[]) => T | undefined; +//#endregion +export { head }; \ No newline at end of file