diff --git a/node_modules/es-toolkit/dist/fp/array/head.js b/node_modules/es-toolkit/dist/fp/array/head.js new file mode 100644 index 0000000000000000000000000000000000000000..f2ede37a110c849f933b81958de5d08b39b1b92c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/head.js @@ -0,0 +1,9 @@ +const require_head = require("../../array/head.js"); +//#region src/fp/array/head.ts +function head() { + return function(array) { + return require_head.head(array); + }; +} +//#endregion +exports.head = head; diff --git a/node_modules/es-toolkit/dist/fp/array/head.mjs b/node_modules/es-toolkit/dist/fp/array/head.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4267b019f0a4bf377c7b1948abc6a20ec8fe670b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/head.mjs @@ -0,0 +1,9 @@ +import { head as head$1 } from "../../array/head.mjs"; +//#region src/fp/array/head.ts +function head() { + return function(array) { + return head$1(array); + }; +} +//#endregion +export { head }; diff --git a/node_modules/es-toolkit/dist/fp/array/index.d.mts b/node_modules/es-toolkit/dist/fp/array/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e5f60e8ec2deefb32bbc8cd98228797d1b6f010a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/index.d.mts @@ -0,0 +1,69 @@ +import { WindowedOptions } from "../../array/windowed.mjs"; +import { at } from "./at.mjs"; +import { cartesianProduct } from "./cartesianProduct.mjs"; +import { chunk } from "./chunk.mjs"; +import { chunkBy } from "./chunkBy.mjs"; +import { combinations } from "./combinations.mjs"; +import { compact } from "./compact.mjs"; +import { countBy } from "./countBy.mjs"; +import { difference } from "./difference.mjs"; +import { differenceBy } from "./differenceBy.mjs"; +import { differenceWith } from "./differenceWith.mjs"; +import { drop } from "./drop.mjs"; +import { dropRight } from "./dropRight.mjs"; +import { dropRightWhile } from "./dropRightWhile.mjs"; +import { dropWhile } from "./dropWhile.mjs"; +import { filter } from "./filter.mjs"; +import { find } from "./find.mjs"; +import { findIndex } from "./findIndex.mjs"; +import { findLast } from "./findLast.mjs"; +import { findLastIndex } from "./findLastIndex.mjs"; +import { flatMap } from "./flatMap.mjs"; +import { flatMapDeep } from "./flatMapDeep.mjs"; +import { flatten } from "./flatten.mjs"; +import { flattenDeep } from "./flattenDeep.mjs"; +import { forEach } from "./forEach.mjs"; +import { groupBy } from "./groupBy.mjs"; +import { head } from "./head.mjs"; +import { initial } from "./initial.mjs"; +import { intersection } from "./intersection.mjs"; +import { intersectionBy } from "./intersectionBy.mjs"; +import { intersectionWith } from "./intersectionWith.mjs"; +import { isSubset } from "./isSubset.mjs"; +import { isSubsetWith } from "./isSubsetWith.mjs"; +import { join } from "./join.mjs"; +import { keyBy } from "./keyBy.mjs"; +import { last } from "./last.mjs"; +import { length } from "./length.mjs"; +import { map } from "./map.mjs"; +import { maxBy } from "./maxBy.mjs"; +import { minBy } from "./minBy.mjs"; +import { orderBy } from "./orderBy.mjs"; +import { partition } from "./partition.mjs"; +import { reverse } from "./reverse.mjs"; +import { sample } from "./sample.mjs"; +import { sampleSize } from "./sampleSize.mjs"; +import { shuffle } from "./shuffle.mjs"; +import { sortBy } from "./sortBy.mjs"; +import { tail } from "./tail.mjs"; +import { take } from "./take.mjs"; +import { takeRight } from "./takeRight.mjs"; +import { takeRightWhile } from "./takeRightWhile.mjs"; +import { takeWhile } from "./takeWhile.mjs"; +import { toFilled } from "./toFilled.mjs"; +import { union } from "./union.mjs"; +import { unionBy } from "./unionBy.mjs"; +import { unionWith } from "./unionWith.mjs"; +import { uniq } from "./uniq.mjs"; +import { uniqBy } from "./uniqBy.mjs"; +import { uniqWith } from "./uniqWith.mjs"; +import { unzip } from "./unzip.mjs"; +import { unzipWith } from "./unzipWith.mjs"; +import { windowed } from "./windowed.mjs"; +import { without } from "./without.mjs"; +import { xor } from "./xor.mjs"; +import { xorBy } from "./xorBy.mjs"; +import { xorWith } from "./xorWith.mjs"; +import { zip } from "./zip.mjs"; +import { zipObject } from "./zipObject.mjs"; +import { zipWith } from "./zipWith.mjs"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/index.d.ts b/node_modules/es-toolkit/dist/fp/array/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ab43cb32ea461720fa39066eb7598aadb6928cab --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/index.d.ts @@ -0,0 +1,69 @@ +import { WindowedOptions } from "../../array/windowed.js"; +import { at } from "./at.js"; +import { cartesianProduct } from "./cartesianProduct.js"; +import { chunk } from "./chunk.js"; +import { chunkBy } from "./chunkBy.js"; +import { combinations } from "./combinations.js"; +import { compact } from "./compact.js"; +import { countBy } from "./countBy.js"; +import { difference } from "./difference.js"; +import { differenceBy } from "./differenceBy.js"; +import { differenceWith } from "./differenceWith.js"; +import { drop } from "./drop.js"; +import { dropRight } from "./dropRight.js"; +import { dropRightWhile } from "./dropRightWhile.js"; +import { dropWhile } from "./dropWhile.js"; +import { filter } from "./filter.js"; +import { find } from "./find.js"; +import { findIndex } from "./findIndex.js"; +import { findLast } from "./findLast.js"; +import { findLastIndex } from "./findLastIndex.js"; +import { flatMap } from "./flatMap.js"; +import { flatMapDeep } from "./flatMapDeep.js"; +import { flatten } from "./flatten.js"; +import { flattenDeep } from "./flattenDeep.js"; +import { forEach } from "./forEach.js"; +import { groupBy } from "./groupBy.js"; +import { head } from "./head.js"; +import { initial } from "./initial.js"; +import { intersection } from "./intersection.js"; +import { intersectionBy } from "./intersectionBy.js"; +import { intersectionWith } from "./intersectionWith.js"; +import { isSubset } from "./isSubset.js"; +import { isSubsetWith } from "./isSubsetWith.js"; +import { join } from "./join.js"; +import { keyBy } from "./keyBy.js"; +import { last } from "./last.js"; +import { length } from "./length.js"; +import { map } from "./map.js"; +import { maxBy } from "./maxBy.js"; +import { minBy } from "./minBy.js"; +import { orderBy } from "./orderBy.js"; +import { partition } from "./partition.js"; +import { reverse } from "./reverse.js"; +import { sample } from "./sample.js"; +import { sampleSize } from "./sampleSize.js"; +import { shuffle } from "./shuffle.js"; +import { sortBy } from "./sortBy.js"; +import { tail } from "./tail.js"; +import { take } from "./take.js"; +import { takeRight } from "./takeRight.js"; +import { takeRightWhile } from "./takeRightWhile.js"; +import { takeWhile } from "./takeWhile.js"; +import { toFilled } from "./toFilled.js"; +import { union } from "./union.js"; +import { unionBy } from "./unionBy.js"; +import { unionWith } from "./unionWith.js"; +import { uniq } from "./uniq.js"; +import { uniqBy } from "./uniqBy.js"; +import { uniqWith } from "./uniqWith.js"; +import { unzip } from "./unzip.js"; +import { unzipWith } from "./unzipWith.js"; +import { windowed } from "./windowed.js"; +import { without } from "./without.js"; +import { xor } from "./xor.js"; +import { xorBy } from "./xorBy.js"; +import { xorWith } from "./xorWith.js"; +import { zip } from "./zip.js"; +import { zipObject } from "./zipObject.js"; +import { zipWith } from "./zipWith.js"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/index.js b/node_modules/es-toolkit/dist/fp/array/index.js new file mode 100644 index 0000000000000000000000000000000000000000..addc37bf3699bb7bf1b8a86115584b31b0f6fb41 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/index.js @@ -0,0 +1,68 @@ +require("./at.js"); +require("./cartesianProduct.js"); +require("./chunk.js"); +require("./chunkBy.js"); +require("./combinations.js"); +require("./compact.js"); +require("./countBy.js"); +require("./difference.js"); +require("./differenceBy.js"); +require("./differenceWith.js"); +require("./drop.js"); +require("./dropRight.js"); +require("./dropRightWhile.js"); +require("./dropWhile.js"); +require("./filter.js"); +require("./find.js"); +require("./findIndex.js"); +require("./findLast.js"); +require("./findLastIndex.js"); +require("./flatMap.js"); +require("./flatMapDeep.js"); +require("./flatten.js"); +require("./flattenDeep.js"); +require("./forEach.js"); +require("./groupBy.js"); +require("./head.js"); +require("./initial.js"); +require("./intersection.js"); +require("./intersectionBy.js"); +require("./intersectionWith.js"); +require("./isSubset.js"); +require("./isSubsetWith.js"); +require("./join.js"); +require("./keyBy.js"); +require("./last.js"); +require("./length.js"); +require("./map.js"); +require("./maxBy.js"); +require("./minBy.js"); +require("./orderBy.js"); +require("./partition.js"); +require("./reverse.js"); +require("./sample.js"); +require("./sampleSize.js"); +require("./shuffle.js"); +require("./sortBy.js"); +require("./tail.js"); +require("./take.js"); +require("./takeRight.js"); +require("./takeRightWhile.js"); +require("./takeWhile.js"); +require("./toFilled.js"); +require("./union.js"); +require("./unionBy.js"); +require("./unionWith.js"); +require("./uniq.js"); +require("./uniqBy.js"); +require("./uniqWith.js"); +require("./unzip.js"); +require("./unzipWith.js"); +require("./windowed.js"); +require("./without.js"); +require("./xor.js"); +require("./xorBy.js"); +require("./xorWith.js"); +require("./zip.js"); +require("./zipObject.js"); +require("./zipWith.js"); diff --git a/node_modules/es-toolkit/dist/fp/array/index.mjs b/node_modules/es-toolkit/dist/fp/array/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6e6fc17c4d7b60bd17471857e6989ee72bc66b58 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/index.mjs @@ -0,0 +1,68 @@ +import "./at.mjs"; +import "./cartesianProduct.mjs"; +import "./chunk.mjs"; +import "./chunkBy.mjs"; +import "./combinations.mjs"; +import "./compact.mjs"; +import "./countBy.mjs"; +import "./difference.mjs"; +import "./differenceBy.mjs"; +import "./differenceWith.mjs"; +import "./drop.mjs"; +import "./dropRight.mjs"; +import "./dropRightWhile.mjs"; +import "./dropWhile.mjs"; +import "./filter.mjs"; +import "./find.mjs"; +import "./findIndex.mjs"; +import "./findLast.mjs"; +import "./findLastIndex.mjs"; +import "./flatMap.mjs"; +import "./flatMapDeep.mjs"; +import "./flatten.mjs"; +import "./flattenDeep.mjs"; +import "./forEach.mjs"; +import "./groupBy.mjs"; +import "./head.mjs"; +import "./initial.mjs"; +import "./intersection.mjs"; +import "./intersectionBy.mjs"; +import "./intersectionWith.mjs"; +import "./isSubset.mjs"; +import "./isSubsetWith.mjs"; +import "./join.mjs"; +import "./keyBy.mjs"; +import "./last.mjs"; +import "./length.mjs"; +import "./map.mjs"; +import "./maxBy.mjs"; +import "./minBy.mjs"; +import "./orderBy.mjs"; +import "./partition.mjs"; +import "./reverse.mjs"; +import "./sample.mjs"; +import "./sampleSize.mjs"; +import "./shuffle.mjs"; +import "./sortBy.mjs"; +import "./tail.mjs"; +import "./take.mjs"; +import "./takeRight.mjs"; +import "./takeRightWhile.mjs"; +import "./takeWhile.mjs"; +import "./toFilled.mjs"; +import "./union.mjs"; +import "./unionBy.mjs"; +import "./unionWith.mjs"; +import "./uniq.mjs"; +import "./uniqBy.mjs"; +import "./uniqWith.mjs"; +import "./unzip.mjs"; +import "./unzipWith.mjs"; +import "./windowed.mjs"; +import "./without.mjs"; +import "./xor.mjs"; +import "./xorBy.mjs"; +import "./xorWith.mjs"; +import "./zip.mjs"; +import "./zipObject.mjs"; +import "./zipWith.mjs"; diff --git a/node_modules/es-toolkit/dist/fp/array/initial.d.mts b/node_modules/es-toolkit/dist/fp/array/initial.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d1d13603687ea8dc3cf96ac839d9014d6aab7a66 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/initial.d.mts @@ -0,0 +1,19 @@ +//#region src/fp/array/initial.d.ts +/** + * Creates a function that returns every element except the last one. + * + * The returned function follows the main {@link initial} behavior and always returns a new array. + * Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to its initial elements. + * + * @example + * import { initial, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], initial()); + * // => [1, 2] + */ +declare function initial(): (array: readonly T[]) => T[]; +//#endregion +export { initial }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/initial.d.ts b/node_modules/es-toolkit/dist/fp/array/initial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1d13603687ea8dc3cf96ac839d9014d6aab7a66 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/initial.d.ts @@ -0,0 +1,19 @@ +//#region src/fp/array/initial.d.ts +/** + * Creates a function that returns every element except the last one. + * + * The returned function follows the main {@link initial} behavior and always returns a new array. + * Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to its initial elements. + * + * @example + * import { initial, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], initial()); + * // => [1, 2] + */ +declare function initial(): (array: readonly T[]) => T[]; +//#endregion +export { initial }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/initial.js b/node_modules/es-toolkit/dist/fp/array/initial.js new file mode 100644 index 0000000000000000000000000000000000000000..6fcc56dcd8574598ed5345535b8a3334c0868a56 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/initial.js @@ -0,0 +1,24 @@ +const require_initial = require("../../array/initial.js"); +//#region src/fp/array/initial.ts +/** +* Creates a function that returns every element except the last one. +* +* The returned function follows the main {@link initial} behavior and always returns a new array. +* Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to its initial elements. +* +* @example +* import { initial, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], initial()); +* // => [1, 2] +*/ +function initial() { + return function(array) { + return require_initial.initial(array); + }; +} +//#endregion +exports.initial = initial; diff --git a/node_modules/es-toolkit/dist/fp/array/initial.mjs b/node_modules/es-toolkit/dist/fp/array/initial.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5a6039d02c923507d22908654254a735608b2df6 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/initial.mjs @@ -0,0 +1,24 @@ +import { initial as initial$1 } from "../../array/initial.mjs"; +//#region src/fp/array/initial.ts +/** +* Creates a function that returns every element except the last one. +* +* The returned function follows the main {@link initial} behavior and always returns a new array. +* Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to its initial elements. +* +* @example +* import { initial, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], initial()); +* // => [1, 2] +*/ +function initial() { + return function(array) { + return initial$1(array); + }; +} +//#endregion +export { initial }; diff --git a/node_modules/es-toolkit/dist/fp/array/intersection.d.mts b/node_modules/es-toolkit/dist/fp/array/intersection.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3c6ffa6bec025303bdf7fdfa0d318393ce3595b1 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersection.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/intersection.d.ts +/** + * Creates a function that keeps values from the piped array that are also present in another array. + * + * Equality follows SameValueZero through Set membership, matching the main + * {@link intersection} implementation. The returned function is lazy-capable + * inside {@link pipe}. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to intersect with the piped array. + * @returns A function that maps the piped array to its intersection. + * + * @example + * import { intersection, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], intersection([2, 4])); + * // => [2] + */ +declare function intersection(secondArray: readonly T[]): (array: readonly T[]) => T[]; +//#endregion +export { intersection }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/intersection.d.ts b/node_modules/es-toolkit/dist/fp/array/intersection.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c6ffa6bec025303bdf7fdfa0d318393ce3595b1 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersection.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/intersection.d.ts +/** + * Creates a function that keeps values from the piped array that are also present in another array. + * + * Equality follows SameValueZero through Set membership, matching the main + * {@link intersection} implementation. The returned function is lazy-capable + * inside {@link pipe}. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to intersect with the piped array. + * @returns A function that maps the piped array to its intersection. + * + * @example + * import { intersection, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], intersection([2, 4])); + * // => [2] + */ +declare function intersection(secondArray: readonly T[]): (array: readonly T[]) => T[]; +//#endregion +export { intersection }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/intersection.js b/node_modules/es-toolkit/dist/fp/array/intersection.js new file mode 100644 index 0000000000000000000000000000000000000000..c4d1ce026a5e91c1bb404149865f46d7a78c389d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersection.js @@ -0,0 +1,32 @@ +const require_intersection = require("../../array/intersection.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/intersection.ts +/** +* Creates a function that keeps values from the piped array that are also present in another array. +* +* Equality follows SameValueZero through Set membership, matching the main +* {@link intersection} implementation. The returned function is lazy-capable +* inside {@link pipe}. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to intersect with the piped array. +* @returns A function that maps the piped array to its intersection. +* +* @example +* import { intersection, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], intersection([2, 4])); +* // => [2] +*/ +function intersection(secondArray) { + const secondSet = new Set(secondArray); + function intersectionEager(array) { + return require_intersection.intersection(array, secondArray); + } + const intersectionLazy = require_lazy.createLazyFunction((value, _index, emit) => { + if (secondSet.has(value)) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(intersectionEager, intersectionLazy); +} +//#endregion +exports.intersection = intersection; diff --git a/node_modules/es-toolkit/dist/fp/array/intersection.mjs b/node_modules/es-toolkit/dist/fp/array/intersection.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b5b9cf3f0bcc2f53dc67477a1fb9fba201f19ed1 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersection.mjs @@ -0,0 +1,31 @@ +import { intersection as intersection$1 } from "../../array/intersection.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/intersection.ts +/** +* Creates a function that keeps values from the piped array that are also present in another array. +* +* Equality follows SameValueZero through Set membership, matching the main +* {@link intersection} implementation. The returned function is lazy-capable +* inside {@link pipe}. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to intersect with the piped array. +* @returns A function that maps the piped array to its intersection. +* +* @example +* import { intersection, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], intersection([2, 4])); +* // => [2] +*/ +function intersection(secondArray) { + const secondSet = new Set(secondArray); + function intersectionEager(array) { + return intersection$1(array, secondArray); + } + return combineEagerAndLazyFunctions(intersectionEager, createLazyFunction((value, _index, emit) => { + if (secondSet.has(value)) emit(value); + })); +} +//#endregion +export { intersection }; diff --git a/node_modules/es-toolkit/dist/fp/array/intersectionBy.d.mts b/node_modules/es-toolkit/dist/fp/array/intersectionBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3f632df68c67ba340e61d5bcee2d7989141ae442 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersectionBy.d.mts @@ -0,0 +1,22 @@ +//#region src/fp/array/intersectionBy.d.ts +/** + * Creates a function that keeps values whose mapped identity appears in 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 intersect with 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 intersection. + * + * @example + * import { intersectionBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], intersectionBy([2], value => typeof value === 'number' ? value : value.id)); + * // => [{ id: 2 }] + */ +declare function intersectionBy(secondArray: readonly U[], mapper: (value: T | U) => unknown): (array: readonly T[]) => T[]; +//#endregion +export { intersectionBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/intersectionBy.d.ts b/node_modules/es-toolkit/dist/fp/array/intersectionBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f632df68c67ba340e61d5bcee2d7989141ae442 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersectionBy.d.ts @@ -0,0 +1,22 @@ +//#region src/fp/array/intersectionBy.d.ts +/** + * Creates a function that keeps values whose mapped identity appears in 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 intersect with 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 intersection. + * + * @example + * import { intersectionBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], intersectionBy([2], value => typeof value === 'number' ? value : value.id)); + * // => [{ id: 2 }] + */ +declare function intersectionBy(secondArray: readonly U[], mapper: (value: T | U) => unknown): (array: readonly T[]) => T[]; +//#endregion +export { intersectionBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/intersectionBy.js b/node_modules/es-toolkit/dist/fp/array/intersectionBy.js new file mode 100644 index 0000000000000000000000000000000000000000..57336e5af696a427a0e6dad12c2c0658538224a8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersectionBy.js @@ -0,0 +1,33 @@ +const require_intersectionBy = require("../../array/intersectionBy.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/intersectionBy.ts +/** +* Creates a function that keeps values whose mapped identity appears in 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 intersect with 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 intersection. +* +* @example +* import { intersectionBy, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], intersectionBy([2], value => typeof value === 'number' ? value : value.id)); +* // => [{ id: 2 }] +*/ +function intersectionBy(secondArray, mapper) { + const mappedSecondSet = new Set(secondArray.map((item) => mapper(item))); + function intersectionByEager(array) { + return require_intersectionBy.intersectionBy(array, secondArray, mapper); + } + const intersectionByLazy = require_lazy.createLazyFunction((value, _index, emit) => { + if (mappedSecondSet.has(mapper(value))) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(intersectionByEager, intersectionByLazy); +} +//#endregion +exports.intersectionBy = intersectionBy; diff --git a/node_modules/es-toolkit/dist/fp/array/intersectionBy.mjs b/node_modules/es-toolkit/dist/fp/array/intersectionBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e261b78e0c2263ed9363c474af2ff78b988d5600 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersectionBy.mjs @@ -0,0 +1,32 @@ +import { intersectionBy as intersectionBy$1 } from "../../array/intersectionBy.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/intersectionBy.ts +/** +* Creates a function that keeps values whose mapped identity appears in 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 intersect with 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 intersection. +* +* @example +* import { intersectionBy, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], intersectionBy([2], value => typeof value === 'number' ? value : value.id)); +* // => [{ id: 2 }] +*/ +function intersectionBy(secondArray, mapper) { + const mappedSecondSet = new Set(secondArray.map((item) => mapper(item))); + function intersectionByEager(array) { + return intersectionBy$1(array, secondArray, mapper); + } + return combineEagerAndLazyFunctions(intersectionByEager, createLazyFunction((value, _index, emit) => { + if (mappedSecondSet.has(mapper(value))) emit(value); + })); +} +//#endregion +export { intersectionBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/intersectionWith.d.mts b/node_modules/es-toolkit/dist/fp/array/intersectionWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..972dea1ccba5d9278ec331457cd2fb78cd5accc1 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersectionWith.d.mts @@ -0,0 +1,22 @@ +//#region src/fp/array/intersectionWith.d.ts +/** + * Creates a function that keeps values equal to at least one 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 intersection. + * + * @example + * import { intersectionWith, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], intersectionWith([2], (item, id) => item.id === id)); + * // => [{ id: 2 }] + */ +declare function intersectionWith(secondArray: readonly U[], areItemsEqual: (item: T, other: U) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { intersectionWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/intersectionWith.d.ts b/node_modules/es-toolkit/dist/fp/array/intersectionWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..972dea1ccba5d9278ec331457cd2fb78cd5accc1 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersectionWith.d.ts @@ -0,0 +1,22 @@ +//#region src/fp/array/intersectionWith.d.ts +/** + * Creates a function that keeps values equal to at least one 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 intersection. + * + * @example + * import { intersectionWith, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], intersectionWith([2], (item, id) => item.id === id)); + * // => [{ id: 2 }] + */ +declare function intersectionWith(secondArray: readonly U[], areItemsEqual: (item: T, other: U) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { intersectionWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/intersectionWith.js b/node_modules/es-toolkit/dist/fp/array/intersectionWith.js new file mode 100644 index 0000000000000000000000000000000000000000..dc7fbe380c4bf37d714439bf923863355bac4871 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersectionWith.js @@ -0,0 +1,32 @@ +const require_intersectionWith = require("../../array/intersectionWith.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/intersectionWith.ts +/** +* Creates a function that keeps values equal to at least one 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 intersection. +* +* @example +* import { intersectionWith, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], intersectionWith([2], (item, id) => item.id === id)); +* // => [{ id: 2 }] +*/ +function intersectionWith(secondArray, areItemsEqual) { + function intersectionWithEager(array) { + return require_intersectionWith.intersectionWith(array, secondArray, areItemsEqual); + } + const intersectionWithLazy = require_lazy.createLazyFunction((value, _index, emit) => { + if (secondArray.some((other) => areItemsEqual(value, other))) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(intersectionWithEager, intersectionWithLazy); +} +//#endregion +exports.intersectionWith = intersectionWith; diff --git a/node_modules/es-toolkit/dist/fp/array/intersectionWith.mjs b/node_modules/es-toolkit/dist/fp/array/intersectionWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..905794bf3d7b0c6470874585be8e74716f3a4ddd --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/intersectionWith.mjs @@ -0,0 +1,31 @@ +import { intersectionWith as intersectionWith$1 } from "../../array/intersectionWith.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/intersectionWith.ts +/** +* Creates a function that keeps values equal to at least one 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 intersection. +* +* @example +* import { intersectionWith, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], intersectionWith([2], (item, id) => item.id === id)); +* // => [{ id: 2 }] +*/ +function intersectionWith(secondArray, areItemsEqual) { + function intersectionWithEager(array) { + return intersectionWith$1(array, secondArray, areItemsEqual); + } + return combineEagerAndLazyFunctions(intersectionWithEager, createLazyFunction((value, _index, emit) => { + if (secondArray.some((other) => areItemsEqual(value, other))) emit(value); + })); +} +//#endregion +export { intersectionWith }; diff --git a/node_modules/es-toolkit/dist/fp/array/isSubset.d.mts b/node_modules/es-toolkit/dist/fp/array/isSubset.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d3dd5290dd35902cec6b45c625fd7496dfc8dbaf --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/isSubset.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/isSubset.d.ts +/** + * Creates a predicate that checks whether the piped array is a subset of superset. + * + * Every value in the piped array must be present in superset, using the main + * {@link isSubset} equality behavior. + * + * @template T - The type of elements in the arrays. + * @param superset - The array that may contain all values from the piped array. + * @returns A predicate for the piped array. + * + * @example + * import { isSubset, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2], isSubset([1, 2, 3])); + * // => true + */ +declare function isSubset(superset: readonly T[]): (array: readonly T[]) => boolean; +//#endregion +export { isSubset }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/isSubset.d.ts b/node_modules/es-toolkit/dist/fp/array/isSubset.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3dd5290dd35902cec6b45c625fd7496dfc8dbaf --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/isSubset.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/isSubset.d.ts +/** + * Creates a predicate that checks whether the piped array is a subset of superset. + * + * Every value in the piped array must be present in superset, using the main + * {@link isSubset} equality behavior. + * + * @template T - The type of elements in the arrays. + * @param superset - The array that may contain all values from the piped array. + * @returns A predicate for the piped array. + * + * @example + * import { isSubset, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2], isSubset([1, 2, 3])); + * // => true + */ +declare function isSubset(superset: readonly T[]): (array: readonly T[]) => boolean; +//#endregion +export { isSubset }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/isSubset.js b/node_modules/es-toolkit/dist/fp/array/isSubset.js new file mode 100644 index 0000000000000000000000000000000000000000..d71f0bc5df3c9e4ed793adfdfa0d5941b3b60792 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/isSubset.js @@ -0,0 +1,25 @@ +const require_isSubset = require("../../array/isSubset.js"); +//#region src/fp/array/isSubset.ts +/** +* Creates a predicate that checks whether the piped array is a subset of superset. +* +* Every value in the piped array must be present in superset, using the main +* {@link isSubset} equality behavior. +* +* @template T - The type of elements in the arrays. +* @param superset - The array that may contain all values from the piped array. +* @returns A predicate for the piped array. +* +* @example +* import { isSubset, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2], isSubset([1, 2, 3])); +* // => true +*/ +function isSubset(superset) { + return function(array) { + return require_isSubset.isSubset(superset, array); + }; +} +//#endregion +exports.isSubset = isSubset; diff --git a/node_modules/es-toolkit/dist/fp/array/isSubset.mjs b/node_modules/es-toolkit/dist/fp/array/isSubset.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8e89edc6abe20ab5cdfc77ccfc1c818b7cd0833e --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/isSubset.mjs @@ -0,0 +1,25 @@ +import { isSubset as isSubset$1 } from "../../array/isSubset.mjs"; +//#region src/fp/array/isSubset.ts +/** +* Creates a predicate that checks whether the piped array is a subset of superset. +* +* Every value in the piped array must be present in superset, using the main +* {@link isSubset} equality behavior. +* +* @template T - The type of elements in the arrays. +* @param superset - The array that may contain all values from the piped array. +* @returns A predicate for the piped array. +* +* @example +* import { isSubset, pipe } from 'es-toolkit/fp'; +* +* pipe([1, 2], isSubset([1, 2, 3])); +* // => true +*/ +function isSubset(superset) { + return function(array) { + return isSubset$1(superset, array); + }; +} +//#endregion +export { isSubset }; diff --git a/node_modules/es-toolkit/dist/fp/array/isSubsetWith.d.mts b/node_modules/es-toolkit/dist/fp/array/isSubsetWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8d9323b0b670419713e9a0192fd257b0843390a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/isSubsetWith.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/isSubsetWith.d.ts +/** + * Creates a predicate that checks subset membership with a custom equality function. + * + * Every value in the piped array must match at least one value in superset according + * to areItemsEqual. + * + * @template T - The type of elements in the arrays. + * @param superset - The array that may contain all values from the piped array. + * @param areItemsEqual - Returns true when a piped value and a superset value are equal. + * @returns A predicate for the piped array. + * + * @example + * import { isSubsetWith, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }], isSubsetWith([{ id: 1 }, { id: 2 }], (a, b) => a.id === b.id)); + * // => true + */ +declare function isSubsetWith(superset: readonly T[], areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => boolean; +//#endregion +export { isSubsetWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/isSubsetWith.d.ts b/node_modules/es-toolkit/dist/fp/array/isSubsetWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8d9323b0b670419713e9a0192fd257b0843390a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/isSubsetWith.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/isSubsetWith.d.ts +/** + * Creates a predicate that checks subset membership with a custom equality function. + * + * Every value in the piped array must match at least one value in superset according + * to areItemsEqual. + * + * @template T - The type of elements in the arrays. + * @param superset - The array that may contain all values from the piped array. + * @param areItemsEqual - Returns true when a piped value and a superset value are equal. + * @returns A predicate for the piped array. + * + * @example + * import { isSubsetWith, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }], isSubsetWith([{ id: 1 }, { id: 2 }], (a, b) => a.id === b.id)); + * // => true + */ +declare function isSubsetWith(superset: readonly T[], areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => boolean; +//#endregion +export { isSubsetWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/isSubsetWith.js b/node_modules/es-toolkit/dist/fp/array/isSubsetWith.js new file mode 100644 index 0000000000000000000000000000000000000000..1a6d9ff6913002faf3edd4ebf3669a99d9f2e785 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/isSubsetWith.js @@ -0,0 +1,26 @@ +const require_isSubsetWith = require("../../array/isSubsetWith.js"); +//#region src/fp/array/isSubsetWith.ts +/** +* Creates a predicate that checks subset membership with a custom equality function. +* +* Every value in the piped array must match at least one value in superset according +* to areItemsEqual. +* +* @template T - The type of elements in the arrays. +* @param superset - The array that may contain all values from the piped array. +* @param areItemsEqual - Returns true when a piped value and a superset value are equal. +* @returns A predicate for the piped array. +* +* @example +* import { isSubsetWith, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }], isSubsetWith([{ id: 1 }, { id: 2 }], (a, b) => a.id === b.id)); +* // => true +*/ +function isSubsetWith(superset, areItemsEqual) { + return function(array) { + return require_isSubsetWith.isSubsetWith(superset, array, areItemsEqual); + }; +} +//#endregion +exports.isSubsetWith = isSubsetWith; diff --git a/node_modules/es-toolkit/dist/fp/array/isSubsetWith.mjs b/node_modules/es-toolkit/dist/fp/array/isSubsetWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..53b5c4a6fd0c6ba3a4551c8583d3695c0ae2ba00 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/isSubsetWith.mjs @@ -0,0 +1,26 @@ +import { isSubsetWith as isSubsetWith$1 } from "../../array/isSubsetWith.mjs"; +//#region src/fp/array/isSubsetWith.ts +/** +* Creates a predicate that checks subset membership with a custom equality function. +* +* Every value in the piped array must match at least one value in superset according +* to areItemsEqual. +* +* @template T - The type of elements in the arrays. +* @param superset - The array that may contain all values from the piped array. +* @param areItemsEqual - Returns true when a piped value and a superset value are equal. +* @returns A predicate for the piped array. +* +* @example +* import { isSubsetWith, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }], isSubsetWith([{ id: 1 }, { id: 2 }], (a, b) => a.id === b.id)); +* // => true +*/ +function isSubsetWith(superset, areItemsEqual) { + return function(array) { + return isSubsetWith$1(superset, array, areItemsEqual); + }; +} +//#endregion +export { isSubsetWith }; diff --git a/node_modules/es-toolkit/dist/fp/array/join.d.mts b/node_modules/es-toolkit/dist/fp/array/join.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..311ea4f92f866ac24dc3665381ab8665e844fdcd --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/join.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/join.d.ts +/** + * Creates a function that joins array values into a string. + * + * The separator is passed to Array.prototype.join, so undefined uses a comma. + * Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param separator - The separator placed between values. + * @returns A function that maps a readonly array to a joined string. + * + * @example + * import { join, pipe } from 'es-toolkit/fp'; + * + * pipe(['a', 'b', 'c'], join('-')); + * // => 'a-b-c' + */ +declare function join(separator?: string): (array: readonly T[]) => string; +//#endregion +export { join }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/join.d.ts b/node_modules/es-toolkit/dist/fp/array/join.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..311ea4f92f866ac24dc3665381ab8665e844fdcd --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/join.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/join.d.ts +/** + * Creates a function that joins array values into a string. + * + * The separator is passed to Array.prototype.join, so undefined uses a comma. + * Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param separator - The separator placed between values. + * @returns A function that maps a readonly array to a joined string. + * + * @example + * import { join, pipe } from 'es-toolkit/fp'; + * + * pipe(['a', 'b', 'c'], join('-')); + * // => 'a-b-c' + */ +declare function join(separator?: string): (array: readonly T[]) => string; +//#endregion +export { join }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/join.js b/node_modules/es-toolkit/dist/fp/array/join.js new file mode 100644 index 0000000000000000000000000000000000000000..438c76407deb8b83af59d88264c356a6c1e260aa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/join.js @@ -0,0 +1,24 @@ +//#region src/fp/array/join.ts +/** +* Creates a function that joins array values into a string. +* +* The separator is passed to Array.prototype.join, so undefined uses a comma. +* Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param separator - The separator placed between values. +* @returns A function that maps a readonly array to a joined string. +* +* @example +* import { join, pipe } from 'es-toolkit/fp'; +* +* pipe(['a', 'b', 'c'], join('-')); +* // => 'a-b-c' +*/ +function join(separator) { + return function(array) { + return array.join(separator); + }; +} +//#endregion +exports.join = join; diff --git a/node_modules/es-toolkit/dist/fp/array/join.mjs b/node_modules/es-toolkit/dist/fp/array/join.mjs new file mode 100644 index 0000000000000000000000000000000000000000..db09116ea5f292c39c21a684a49d09ec977ad6ca --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/join.mjs @@ -0,0 +1,24 @@ +//#region src/fp/array/join.ts +/** +* Creates a function that joins array values into a string. +* +* The separator is passed to Array.prototype.join, so undefined uses a comma. +* Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param separator - The separator placed between values. +* @returns A function that maps a readonly array to a joined string. +* +* @example +* import { join, pipe } from 'es-toolkit/fp'; +* +* pipe(['a', 'b', 'c'], join('-')); +* // => 'a-b-c' +*/ +function join(separator) { + return function(array) { + return array.join(separator); + }; +} +//#endregion +export { join }; diff --git a/node_modules/es-toolkit/dist/fp/array/keyBy.d.mts b/node_modules/es-toolkit/dist/fp/array/keyBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..919d189d6c946015fbdf338b879342fe18f60d9d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/keyBy.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/keyBy.d.ts +/** + * Creates a function that indexes values by a derived key. + * + * The key selector receives each value, index, and full input array. When multiple values + * produce the same key, the last value wins, matching the main {@link keyBy} behavior. + * + * @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 an object key. + * @returns A function that maps a readonly array to an object keyed by the derived keys. + * + * @example + * import { keyBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 'a', value: 1 }, { id: 'b', value: 2 }], keyBy(item => item.id)); + * // => { a: { id: 'a', value: 1 }, b: { id: 'b', value: 2 } } + */ +declare function keyBy(getKey: (item: T, index: number, array: readonly T[]) => K): (array: readonly T[]) => Record; +//#endregion +export { keyBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/keyBy.d.ts b/node_modules/es-toolkit/dist/fp/array/keyBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..919d189d6c946015fbdf338b879342fe18f60d9d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/keyBy.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/keyBy.d.ts +/** + * Creates a function that indexes values by a derived key. + * + * The key selector receives each value, index, and full input array. When multiple values + * produce the same key, the last value wins, matching the main {@link keyBy} behavior. + * + * @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 an object key. + * @returns A function that maps a readonly array to an object keyed by the derived keys. + * + * @example + * import { keyBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ id: 'a', value: 1 }, { id: 'b', value: 2 }], keyBy(item => item.id)); + * // => { a: { id: 'a', value: 1 }, b: { id: 'b', value: 2 } } + */ +declare function keyBy(getKey: (item: T, index: number, array: readonly T[]) => K): (array: readonly T[]) => Record; +//#endregion +export { keyBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/keyBy.js b/node_modules/es-toolkit/dist/fp/array/keyBy.js new file mode 100644 index 0000000000000000000000000000000000000000..039b52b941e336686471a52c2b4e74812e0671c4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/keyBy.js @@ -0,0 +1,26 @@ +const require_keyBy = require("../../array/keyBy.js"); +//#region src/fp/array/keyBy.ts +/** +* Creates a function that indexes values by a derived key. +* +* The key selector receives each value, index, and full input array. When multiple values +* produce the same key, the last value wins, matching the main {@link keyBy} behavior. +* +* @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 an object key. +* @returns A function that maps a readonly array to an object keyed by the derived keys. +* +* @example +* import { keyBy, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 'a', value: 1 }, { id: 'b', value: 2 }], keyBy(item => item.id)); +* // => { a: { id: 'a', value: 1 }, b: { id: 'b', value: 2 } } +*/ +function keyBy(getKey) { + return function(array) { + return require_keyBy.keyBy(array, getKey); + }; +} +//#endregion +exports.keyBy = keyBy; diff --git a/node_modules/es-toolkit/dist/fp/array/keyBy.mjs b/node_modules/es-toolkit/dist/fp/array/keyBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f1d262a5f293b2242846d3e7c3d5707bbe642d65 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/keyBy.mjs @@ -0,0 +1,26 @@ +import { keyBy as keyBy$1 } from "../../array/keyBy.mjs"; +//#region src/fp/array/keyBy.ts +/** +* Creates a function that indexes values by a derived key. +* +* The key selector receives each value, index, and full input array. When multiple values +* produce the same key, the last value wins, matching the main {@link keyBy} behavior. +* +* @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 an object key. +* @returns A function that maps a readonly array to an object keyed by the derived keys. +* +* @example +* import { keyBy, pipe } from 'es-toolkit/fp'; +* +* pipe([{ id: 'a', value: 1 }, { id: 'b', value: 2 }], keyBy(item => item.id)); +* // => { a: { id: 'a', value: 1 }, b: { id: 'b', value: 2 } } +*/ +function keyBy(getKey) { + return function(array) { + return keyBy$1(array, getKey); + }; +} +//#endregion +export { keyBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/last.d.mts b/node_modules/es-toolkit/dist/fp/array/last.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a92831ce2476f32cfb8ce69de79773609f5ce9b9 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/last.d.mts @@ -0,0 +1,35 @@ +//#region src/fp/array/last.d.ts +/** + * Creates a function that returns the last 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 last element. + * + * @example + * import { last, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3] as const, last()); + * // => 3 + */ +declare function last(): (array: readonly [...T[], T]) => T; +/** + * Creates a function that returns the last element of an array, or undefined. + * + * Empty arrays return undefined, matching the main {@link last} 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 last element, or undefined. + * + * @example + * import { last, pipe } from 'es-toolkit/fp'; + * + * pipe([] as number[], last()); + * // => undefined + */ +declare function last(): (array: readonly T[]) => T | undefined; +//#endregion +export { last }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/last.d.ts b/node_modules/es-toolkit/dist/fp/array/last.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a92831ce2476f32cfb8ce69de79773609f5ce9b9 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/last.d.ts @@ -0,0 +1,35 @@ +//#region src/fp/array/last.d.ts +/** + * Creates a function that returns the last 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 last element. + * + * @example + * import { last, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3] as const, last()); + * // => 3 + */ +declare function last(): (array: readonly [...T[], T]) => T; +/** + * Creates a function that returns the last element of an array, or undefined. + * + * Empty arrays return undefined, matching the main {@link last} 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 last element, or undefined. + * + * @example + * import { last, pipe } from 'es-toolkit/fp'; + * + * pipe([] as number[], last()); + * // => undefined + */ +declare function last(): (array: readonly T[]) => T | undefined; +//#endregion +export { last }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/last.js b/node_modules/es-toolkit/dist/fp/array/last.js new file mode 100644 index 0000000000000000000000000000000000000000..e4832660500ab28fae2aa578c09917b45a1b888d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/last.js @@ -0,0 +1,9 @@ +const require_last = require("../../array/last.js"); +//#region src/fp/array/last.ts +function last() { + return function(array) { + return require_last.last(array); + }; +} +//#endregion +exports.last = last; diff --git a/node_modules/es-toolkit/dist/fp/array/last.mjs b/node_modules/es-toolkit/dist/fp/array/last.mjs new file mode 100644 index 0000000000000000000000000000000000000000..89ce84f735fbe0437dfa10ced1cf5a674db9f9b0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/last.mjs @@ -0,0 +1,9 @@ +import { last as last$1 } from "../../array/last.mjs"; +//#region src/fp/array/last.ts +function last() { + return function(array) { + return last$1(array); + }; +} +//#endregion +export { last }; diff --git a/node_modules/es-toolkit/dist/fp/array/length.d.mts b/node_modules/es-toolkit/dist/fp/array/length.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8445a59d5924cd5a306f730f0259f2303dd02058 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/length.d.mts @@ -0,0 +1,18 @@ +//#region src/fp/array/length.d.ts +/** + * Creates a function that returns the length of an array. + * + * Use it with {@link pipe} when a pipeline should end with the number of input values. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to its length. + * + * @example + * import { length, pipe } from 'es-toolkit/fp'; + * + * pipe(['a', 'b', 'c'], length()); + * // => 3 + */ +declare function length(): (array: readonly T[]) => number; +//#endregion +export { length }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/length.d.ts b/node_modules/es-toolkit/dist/fp/array/length.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8445a59d5924cd5a306f730f0259f2303dd02058 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/length.d.ts @@ -0,0 +1,18 @@ +//#region src/fp/array/length.d.ts +/** + * Creates a function that returns the length of an array. + * + * Use it with {@link pipe} when a pipeline should end with the number of input values. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to its length. + * + * @example + * import { length, pipe } from 'es-toolkit/fp'; + * + * pipe(['a', 'b', 'c'], length()); + * // => 3 + */ +declare function length(): (array: readonly T[]) => number; +//#endregion +export { length }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/length.js b/node_modules/es-toolkit/dist/fp/array/length.js new file mode 100644 index 0000000000000000000000000000000000000000..e7aa37b3dd1809a7e30e14d90186d2dfb1cffe57 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/length.js @@ -0,0 +1,22 @@ +//#region src/fp/array/length.ts +/** +* Creates a function that returns the length of an array. +* +* Use it with {@link pipe} when a pipeline should end with the number of input values. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to its length. +* +* @example +* import { length, pipe } from 'es-toolkit/fp'; +* +* pipe(['a', 'b', 'c'], length()); +* // => 3 +*/ +function length() { + return function(array) { + return array.length; + }; +} +//#endregion +exports.length = length; diff --git a/node_modules/es-toolkit/dist/fp/array/length.mjs b/node_modules/es-toolkit/dist/fp/array/length.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ec74a0626805e29a5be1e15033986abd38169cd6 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/length.mjs @@ -0,0 +1,22 @@ +//#region src/fp/array/length.ts +/** +* Creates a function that returns the length of an array. +* +* Use it with {@link pipe} when a pipeline should end with the number of input values. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to its length. +* +* @example +* import { length, pipe } from 'es-toolkit/fp'; +* +* pipe(['a', 'b', 'c'], length()); +* // => 3 +*/ +function length() { + return function(array) { + return array.length; + }; +} +//#endregion +export { length }; diff --git a/node_modules/es-toolkit/dist/fp/array/map.d.mts b/node_modules/es-toolkit/dist/fp/array/map.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d62acaecc53e2d00544b8a2dfb37197103f0142b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/map.d.mts @@ -0,0 +1,27 @@ +//#region src/fp/array/map.d.ts +/** + * Creates a function that builds a new array by calling `callback` on every + * element, equivalent to `Array.prototype.map`. 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 mapping 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; its return + * value becomes the corresponding element of the output array. + * @returns A function that maps a `readonly T[]` to a new `U[]`. + * + * @example + * import { pipe, map } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], map(x => x * 2)); // => [2, 4, 6] + * + * @example + * // The index is available as the second argument. + * pipe([10, 20, 30], map((value, index) => value + index)); // => [10, 21, 32] + */ +declare function map(callback: (value: T, index: number) => U): (array: readonly T[]) => U[]; +//#endregion +export { map }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/map.d.ts b/node_modules/es-toolkit/dist/fp/array/map.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d62acaecc53e2d00544b8a2dfb37197103f0142b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/map.d.ts @@ -0,0 +1,27 @@ +//#region src/fp/array/map.d.ts +/** + * Creates a function that builds a new array by calling `callback` on every + * element, equivalent to `Array.prototype.map`. 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 mapping 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; its return + * value becomes the corresponding element of the output array. + * @returns A function that maps a `readonly T[]` to a new `U[]`. + * + * @example + * import { pipe, map } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], map(x => x * 2)); // => [2, 4, 6] + * + * @example + * // The index is available as the second argument. + * pipe([10, 20, 30], map((value, index) => value + index)); // => [10, 21, 32] + */ +declare function map(callback: (value: T, index: number) => U): (array: readonly T[]) => U[]; +//#endregion +export { map }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/map.js b/node_modules/es-toolkit/dist/fp/array/map.js new file mode 100644 index 0000000000000000000000000000000000000000..28c0fa759372fbac1c6145264c443abd84e32619 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/map.js @@ -0,0 +1,36 @@ +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/map.ts +/** +* Creates a function that builds a new array by calling `callback` on every +* element, equivalent to `Array.prototype.map`. 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 mapping 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; its return +* value becomes the corresponding element of the output array. +* @returns A function that maps a `readonly T[]` to a new `U[]`. +* +* @example +* import { pipe, map } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], map(x => x * 2)); // => [2, 4, 6] +* +* @example +* // The index is available as the second argument. +* pipe([10, 20, 30], map((value, index) => value + index)); // => [10, 21, 32] +*/ +function map(callback) { + function mapEager(array) { + return array.map(callback); + } + const mapLazy = require_lazy.createLazyFunction((value, index, emit) => { + emit(callback(value, index)); + }); + return require_lazy.combineEagerAndLazyFunctions(mapEager, mapLazy); +} +//#endregion +exports.map = map; diff --git a/node_modules/es-toolkit/dist/fp/array/map.mjs b/node_modules/es-toolkit/dist/fp/array/map.mjs new file mode 100644 index 0000000000000000000000000000000000000000..50cc7ab11c4f7cb1a6dfe457f852c0d4375c10fd --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/map.mjs @@ -0,0 +1,35 @@ +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/map.ts +/** +* Creates a function that builds a new array by calling `callback` on every +* element, equivalent to `Array.prototype.map`. 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 mapping 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; its return +* value becomes the corresponding element of the output array. +* @returns A function that maps a `readonly T[]` to a new `U[]`. +* +* @example +* import { pipe, map } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], map(x => x * 2)); // => [2, 4, 6] +* +* @example +* // The index is available as the second argument. +* pipe([10, 20, 30], map((value, index) => value + index)); // => [10, 21, 32] +*/ +function map(callback) { + function mapEager(array) { + return array.map(callback); + } + return combineEagerAndLazyFunctions(mapEager, createLazyFunction((value, index, emit) => { + emit(callback(value, index)); + })); +} +//#endregion +export { map }; diff --git a/node_modules/es-toolkit/dist/fp/array/maxBy.d.mts b/node_modules/es-toolkit/dist/fp/array/maxBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b5be6aac08d644c82d5969eff19e075159d32804 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/maxBy.d.mts @@ -0,0 +1,37 @@ +//#region src/fp/array/maxBy.d.ts +/** + * Creates a function that returns the element with the maximum selected number from a non-empty array. + * + * If the selector returns NaN, the element that produced NaN is returned, matching + * the main {@link maxBy} behavior. + * + * @template T - The type of elements in the array. + * @param getValue - Selects a numeric value from each element, index, and array. + * @returns A function that maps a non-empty readonly array to the maximum element. + * + * @example + * import { maxBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ score: 10 }, { score: 20 }] as const, maxBy(item => item.score)); + * // => { score: 20 } + */ +declare function maxBy(getValue: (element: T, index: number, array: readonly T[]) => number): (array: readonly [T, ...T[]]) => T; +/** + * Creates a function that returns the element with the maximum selected number. + * + * Empty arrays return undefined. If the selector returns NaN, the element that + * produced NaN is returned, matching the main {@link maxBy} behavior. + * + * @template T - The type of elements in the array. + * @param getValue - Selects a numeric value from each element, index, and array. + * @returns A function that maps a readonly array to the maximum element, or undefined. + * + * @example + * import { maxBy, pipe } from 'es-toolkit/fp'; + * + * pipe([] as Array<{ score: number }>, maxBy(item => item.score)); + * // => undefined + */ +declare function maxBy(getValue: (element: T, index: number, array: readonly T[]) => number): (array: readonly T[]) => T | undefined; +//#endregion +export { maxBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/maxBy.d.ts b/node_modules/es-toolkit/dist/fp/array/maxBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5be6aac08d644c82d5969eff19e075159d32804 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/maxBy.d.ts @@ -0,0 +1,37 @@ +//#region src/fp/array/maxBy.d.ts +/** + * Creates a function that returns the element with the maximum selected number from a non-empty array. + * + * If the selector returns NaN, the element that produced NaN is returned, matching + * the main {@link maxBy} behavior. + * + * @template T - The type of elements in the array. + * @param getValue - Selects a numeric value from each element, index, and array. + * @returns A function that maps a non-empty readonly array to the maximum element. + * + * @example + * import { maxBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ score: 10 }, { score: 20 }] as const, maxBy(item => item.score)); + * // => { score: 20 } + */ +declare function maxBy(getValue: (element: T, index: number, array: readonly T[]) => number): (array: readonly [T, ...T[]]) => T; +/** + * Creates a function that returns the element with the maximum selected number. + * + * Empty arrays return undefined. If the selector returns NaN, the element that + * produced NaN is returned, matching the main {@link maxBy} behavior. + * + * @template T - The type of elements in the array. + * @param getValue - Selects a numeric value from each element, index, and array. + * @returns A function that maps a readonly array to the maximum element, or undefined. + * + * @example + * import { maxBy, pipe } from 'es-toolkit/fp'; + * + * pipe([] as Array<{ score: number }>, maxBy(item => item.score)); + * // => undefined + */ +declare function maxBy(getValue: (element: T, index: number, array: readonly T[]) => number): (array: readonly T[]) => T | undefined; +//#endregion +export { maxBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/maxBy.js b/node_modules/es-toolkit/dist/fp/array/maxBy.js new file mode 100644 index 0000000000000000000000000000000000000000..81a34a0754ab489ea8f7e5978ca44307ad4bd596 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/maxBy.js @@ -0,0 +1,9 @@ +const require_maxBy = require("../../array/maxBy.js"); +//#region src/fp/array/maxBy.ts +function maxBy(getValue) { + return function(array) { + return require_maxBy.maxBy(array, getValue); + }; +} +//#endregion +exports.maxBy = maxBy; diff --git a/node_modules/es-toolkit/dist/fp/array/maxBy.mjs b/node_modules/es-toolkit/dist/fp/array/maxBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1d94e0fd8d19f5f599adc8e663f6a509da48772e --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/maxBy.mjs @@ -0,0 +1,9 @@ +import { maxBy as maxBy$1 } from "../../array/maxBy.mjs"; +//#region src/fp/array/maxBy.ts +function maxBy(getValue) { + return function(array) { + return maxBy$1(array, getValue); + }; +} +//#endregion +export { maxBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/minBy.d.mts b/node_modules/es-toolkit/dist/fp/array/minBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b4c242c5956a57f353888666df2a1671d8ace3e8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/minBy.d.mts @@ -0,0 +1,37 @@ +//#region src/fp/array/minBy.d.ts +/** + * Creates a function that returns the element with the minimum selected number from a non-empty array. + * + * If the selector returns NaN, the element that produced NaN is returned, matching + * the main {@link minBy} behavior. + * + * @template T - The type of elements in the array. + * @param getValue - Selects a numeric value from each element, index, and array. + * @returns A function that maps a non-empty readonly array to the minimum element. + * + * @example + * import { minBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ score: 10 }, { score: 20 }] as const, minBy(item => item.score)); + * // => { score: 10 } + */ +declare function minBy(getValue: (element: T, index: number, array: readonly T[]) => number): (array: readonly [T, ...T[]]) => T; +/** + * Creates a function that returns the element with the minimum selected number. + * + * Empty arrays return undefined. If the selector returns NaN, the element that + * produced NaN is returned, matching the main {@link minBy} behavior. + * + * @template T - The type of elements in the array. + * @param getValue - Selects a numeric value from each element, index, and array. + * @returns A function that maps a readonly array to the minimum element, or undefined. + * + * @example + * import { minBy, pipe } from 'es-toolkit/fp'; + * + * pipe([] as Array<{ score: number }>, minBy(item => item.score)); + * // => undefined + */ +declare function minBy(getValue: (element: T, index: number, array: readonly T[]) => number): (array: readonly T[]) => T | undefined; +//#endregion +export { minBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/minBy.d.ts b/node_modules/es-toolkit/dist/fp/array/minBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b4c242c5956a57f353888666df2a1671d8ace3e8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/minBy.d.ts @@ -0,0 +1,37 @@ +//#region src/fp/array/minBy.d.ts +/** + * Creates a function that returns the element with the minimum selected number from a non-empty array. + * + * If the selector returns NaN, the element that produced NaN is returned, matching + * the main {@link minBy} behavior. + * + * @template T - The type of elements in the array. + * @param getValue - Selects a numeric value from each element, index, and array. + * @returns A function that maps a non-empty readonly array to the minimum element. + * + * @example + * import { minBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ score: 10 }, { score: 20 }] as const, minBy(item => item.score)); + * // => { score: 10 } + */ +declare function minBy(getValue: (element: T, index: number, array: readonly T[]) => number): (array: readonly [T, ...T[]]) => T; +/** + * Creates a function that returns the element with the minimum selected number. + * + * Empty arrays return undefined. If the selector returns NaN, the element that + * produced NaN is returned, matching the main {@link minBy} behavior. + * + * @template T - The type of elements in the array. + * @param getValue - Selects a numeric value from each element, index, and array. + * @returns A function that maps a readonly array to the minimum element, or undefined. + * + * @example + * import { minBy, pipe } from 'es-toolkit/fp'; + * + * pipe([] as Array<{ score: number }>, minBy(item => item.score)); + * // => undefined + */ +declare function minBy(getValue: (element: T, index: number, array: readonly T[]) => number): (array: readonly T[]) => T | undefined; +//#endregion +export { minBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/minBy.js b/node_modules/es-toolkit/dist/fp/array/minBy.js new file mode 100644 index 0000000000000000000000000000000000000000..bbcdf9488729fe113c8447619f22dc79bcee3420 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/minBy.js @@ -0,0 +1,9 @@ +const require_minBy = require("../../array/minBy.js"); +//#region src/fp/array/minBy.ts +function minBy(getValue) { + return function(array) { + return require_minBy.minBy(array, getValue); + }; +} +//#endregion +exports.minBy = minBy; diff --git a/node_modules/es-toolkit/dist/fp/array/minBy.mjs b/node_modules/es-toolkit/dist/fp/array/minBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..78ae26faf2660a47746a558e766dfba5e616b9c0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/minBy.mjs @@ -0,0 +1,9 @@ +import { minBy as minBy$1 } from "../../array/minBy.mjs"; +//#region src/fp/array/minBy.ts +function minBy(getValue) { + return function(array) { + return minBy$1(array, getValue); + }; +} +//#endregion +export { minBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/orderBy.d.mts b/node_modules/es-toolkit/dist/fp/array/orderBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..5f98b7daa34d887bb0408263dd6a9d8aa90c24db --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/orderBy.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/orderBy.d.ts +/** + * Creates a function that sorts objects by criteria and order directions. + * + * Criteria can be object keys or selector functions. The returned function does not mutate + * the input array; it returns a sorted copy following the main {@link orderBy} behavior. + * + * @template T - The object type in the array. + * @param criteria - Keys or selector functions used for comparison. + * @param orders - Sort directions corresponding to the criteria. + * @returns A function that maps a readonly array to a sorted copy. + * + * @example + * import { orderBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ name: 'a', age: 2 }, { name: 'b', age: 1 }], orderBy(['age'], ['asc'])); + * // => [{ name: 'b', age: 1 }, { name: 'a', age: 2 }] + */ +declare function orderBy(criteria: Array<((item: T) => unknown) | keyof T>, orders: Array<'asc' | 'desc'>): (array: readonly T[]) => T[]; +//#endregion +export { orderBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/orderBy.d.ts b/node_modules/es-toolkit/dist/fp/array/orderBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f98b7daa34d887bb0408263dd6a9d8aa90c24db --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/orderBy.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/orderBy.d.ts +/** + * Creates a function that sorts objects by criteria and order directions. + * + * Criteria can be object keys or selector functions. The returned function does not mutate + * the input array; it returns a sorted copy following the main {@link orderBy} behavior. + * + * @template T - The object type in the array. + * @param criteria - Keys or selector functions used for comparison. + * @param orders - Sort directions corresponding to the criteria. + * @returns A function that maps a readonly array to a sorted copy. + * + * @example + * import { orderBy, pipe } from 'es-toolkit/fp'; + * + * pipe([{ name: 'a', age: 2 }, { name: 'b', age: 1 }], orderBy(['age'], ['asc'])); + * // => [{ name: 'b', age: 1 }, { name: 'a', age: 2 }] + */ +declare function orderBy(criteria: Array<((item: T) => unknown) | keyof T>, orders: Array<'asc' | 'desc'>): (array: readonly T[]) => T[]; +//#endregion +export { orderBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/orderBy.js b/node_modules/es-toolkit/dist/fp/array/orderBy.js new file mode 100644 index 0000000000000000000000000000000000000000..09942747577ef291ca6e954ca6b234b368a7f5af --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/orderBy.js @@ -0,0 +1,26 @@ +const require_orderBy = require("../../array/orderBy.js"); +//#region src/fp/array/orderBy.ts +/** +* Creates a function that sorts objects by criteria and order directions. +* +* Criteria can be object keys or selector functions. The returned function does not mutate +* the input array; it returns a sorted copy following the main {@link orderBy} behavior. +* +* @template T - The object type in the array. +* @param criteria - Keys or selector functions used for comparison. +* @param orders - Sort directions corresponding to the criteria. +* @returns A function that maps a readonly array to a sorted copy. +* +* @example +* import { orderBy, pipe } from 'es-toolkit/fp'; +* +* pipe([{ name: 'a', age: 2 }, { name: 'b', age: 1 }], orderBy(['age'], ['asc'])); +* // => [{ name: 'b', age: 1 }, { name: 'a', age: 2 }] +*/ +function orderBy(criteria, orders) { + return function(array) { + return require_orderBy.orderBy(array, criteria, orders); + }; +} +//#endregion +exports.orderBy = orderBy; diff --git a/node_modules/es-toolkit/dist/fp/array/orderBy.mjs b/node_modules/es-toolkit/dist/fp/array/orderBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..372b20d7799f671d9268f9eebd98ef0e1d2c5ffe --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/orderBy.mjs @@ -0,0 +1,26 @@ +import { orderBy as orderBy$1 } from "../../array/orderBy.mjs"; +//#region src/fp/array/orderBy.ts +/** +* Creates a function that sorts objects by criteria and order directions. +* +* Criteria can be object keys or selector functions. The returned function does not mutate +* the input array; it returns a sorted copy following the main {@link orderBy} behavior. +* +* @template T - The object type in the array. +* @param criteria - Keys or selector functions used for comparison. +* @param orders - Sort directions corresponding to the criteria. +* @returns A function that maps a readonly array to a sorted copy. +* +* @example +* import { orderBy, pipe } from 'es-toolkit/fp'; +* +* pipe([{ name: 'a', age: 2 }, { name: 'b', age: 1 }], orderBy(['age'], ['asc'])); +* // => [{ name: 'b', age: 1 }, { name: 'a', age: 2 }] +*/ +function orderBy(criteria, orders) { + return function(array) { + return orderBy$1(array, criteria, orders); + }; +} +//#endregion +export { orderBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/partition.d.mts b/node_modules/es-toolkit/dist/fp/array/partition.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fc56b56712b79350a9bd3e473a8e744073fc7f6b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/partition.d.mts @@ -0,0 +1,39 @@ +//#region src/fp/array/partition.d.ts +/** + * Creates a function that splits an array with a type-guard predicate. + * + * Values for which the predicate returns true are placed in the first array and + * narrowed to U. The remaining values are placed in the second array as Exclude. + * + * @template T - The type of elements in the array. + * @template U - The narrowed element type accepted by the type guard. + * @param predicate - Type guard called with each value, index, and array. + * @returns A function that maps a readonly array to truthy and falsy partitions. + * + * @example + * import { partition, pipe } from 'es-toolkit/fp'; + * + * const isString = (value: string | number): value is string => typeof value === 'string'; + * pipe([1, 'a', 2, 'b'], partition(isString)); + * // => [['a', 'b'], [1, 2]] + */ +declare function partition(predicate: (value: T, index: number, array: readonly T[]) => value is U): (array: readonly T[]) => [truthy: U[], falsy: Array>]; +/** + * Creates a function that splits an array by a predicate. + * + * Values for which the predicate returns true are placed in the first array; all + * other values are placed in the second array. + * + * @template T - The type of elements in the array. + * @param predicate - Predicate called with each value, index, and array. + * @returns A function that maps a readonly array to truthy and falsy partitions. + * + * @example + * import { partition, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], partition(value => value % 2 === 0)); + * // => [[2, 4], [1, 3]] + */ +declare function partition(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => [truthy: T[], falsy: T[]]; +//#endregion +export { partition }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/partition.d.ts b/node_modules/es-toolkit/dist/fp/array/partition.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc56b56712b79350a9bd3e473a8e744073fc7f6b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/partition.d.ts @@ -0,0 +1,39 @@ +//#region src/fp/array/partition.d.ts +/** + * Creates a function that splits an array with a type-guard predicate. + * + * Values for which the predicate returns true are placed in the first array and + * narrowed to U. The remaining values are placed in the second array as Exclude. + * + * @template T - The type of elements in the array. + * @template U - The narrowed element type accepted by the type guard. + * @param predicate - Type guard called with each value, index, and array. + * @returns A function that maps a readonly array to truthy and falsy partitions. + * + * @example + * import { partition, pipe } from 'es-toolkit/fp'; + * + * const isString = (value: string | number): value is string => typeof value === 'string'; + * pipe([1, 'a', 2, 'b'], partition(isString)); + * // => [['a', 'b'], [1, 2]] + */ +declare function partition(predicate: (value: T, index: number, array: readonly T[]) => value is U): (array: readonly T[]) => [truthy: U[], falsy: Array>]; +/** + * Creates a function that splits an array by a predicate. + * + * Values for which the predicate returns true are placed in the first array; all + * other values are placed in the second array. + * + * @template T - The type of elements in the array. + * @param predicate - Predicate called with each value, index, and array. + * @returns A function that maps a readonly array to truthy and falsy partitions. + * + * @example + * import { partition, pipe } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], partition(value => value % 2 === 0)); + * // => [[2, 4], [1, 3]] + */ +declare function partition(predicate: (value: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => [truthy: T[], falsy: T[]]; +//#endregion +export { partition }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/partition.js b/node_modules/es-toolkit/dist/fp/array/partition.js new file mode 100644 index 0000000000000000000000000000000000000000..8f6b7f87782af9a9286b79f038131f8443b761ce --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/partition.js @@ -0,0 +1,9 @@ +const require_partition = require("../../array/partition.js"); +//#region src/fp/array/partition.ts +function partition(predicate) { + return function(array) { + return require_partition.partition(array, predicate); + }; +} +//#endregion +exports.partition = partition; diff --git a/node_modules/es-toolkit/dist/fp/array/partition.mjs b/node_modules/es-toolkit/dist/fp/array/partition.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fb2d3b454630964433ba2b55eb2440bf3a439d94 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/partition.mjs @@ -0,0 +1,9 @@ +import { partition as partition$1 } from "../../array/partition.mjs"; +//#region src/fp/array/partition.ts +function partition(predicate) { + return function(array) { + return partition$1(array, predicate); + }; +} +//#endregion +export { partition }; diff --git a/node_modules/es-toolkit/dist/fp/array/reverse.d.mts b/node_modules/es-toolkit/dist/fp/array/reverse.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c57798777d9f62b6e50009814fa3993109fff658 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/reverse.d.mts @@ -0,0 +1,19 @@ +//#region src/fp/array/reverse.d.ts +/** + * Creates a function that returns a reversed copy of an array. + * + * Unlike Array.prototype.reverse, the returned function does not mutate the input array. + * Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a reversed copy. + * + * @example + * import { pipe, reverse } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], reverse()); + * // => [3, 2, 1] + */ +declare function reverse(): (array: readonly T[]) => T[]; +//#endregion +export { reverse }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/reverse.d.ts b/node_modules/es-toolkit/dist/fp/array/reverse.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c57798777d9f62b6e50009814fa3993109fff658 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/reverse.d.ts @@ -0,0 +1,19 @@ +//#region src/fp/array/reverse.d.ts +/** + * Creates a function that returns a reversed copy of an array. + * + * Unlike Array.prototype.reverse, the returned function does not mutate the input array. + * Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a reversed copy. + * + * @example + * import { pipe, reverse } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], reverse()); + * // => [3, 2, 1] + */ +declare function reverse(): (array: readonly T[]) => T[]; +//#endregion +export { reverse }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/reverse.js b/node_modules/es-toolkit/dist/fp/array/reverse.js new file mode 100644 index 0000000000000000000000000000000000000000..7fc7163c3fb983864cf86e41f0383a4f032a14d8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/reverse.js @@ -0,0 +1,23 @@ +//#region src/fp/array/reverse.ts +/** +* Creates a function that returns a reversed copy of an array. +* +* Unlike Array.prototype.reverse, the returned function does not mutate the input array. +* Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a reversed copy. +* +* @example +* import { pipe, reverse } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], reverse()); +* // => [3, 2, 1] +*/ +function reverse() { + return function(array) { + return array.slice().reverse(); + }; +} +//#endregion +exports.reverse = reverse; diff --git a/node_modules/es-toolkit/dist/fp/array/reverse.mjs b/node_modules/es-toolkit/dist/fp/array/reverse.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e8aeb8ab554e1ff99429131baebd99dbc5186961 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/reverse.mjs @@ -0,0 +1,23 @@ +//#region src/fp/array/reverse.ts +/** +* Creates a function that returns a reversed copy of an array. +* +* Unlike Array.prototype.reverse, the returned function does not mutate the input array. +* Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a reversed copy. +* +* @example +* import { pipe, reverse } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], reverse()); +* // => [3, 2, 1] +*/ +function reverse() { + return function(array) { + return array.slice().reverse(); + }; +} +//#endregion +export { reverse }; diff --git a/node_modules/es-toolkit/dist/fp/array/sample.d.mts b/node_modules/es-toolkit/dist/fp/array/sample.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..266dffe81d1c334703140bdaa459c990aa8ad9c1 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sample.d.mts @@ -0,0 +1,18 @@ +//#region src/fp/array/sample.d.ts +/** + * Creates a function that returns one random element from an array. + * + * The returned function follows the main {@link sample} behavior. Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a random element. + * + * @example + * import { pipe, sample } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], sample()); + * // => one of 1, 2, or 3 + */ +declare function sample(): (array: readonly T[]) => T; +//#endregion +export { sample }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/sample.d.ts b/node_modules/es-toolkit/dist/fp/array/sample.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..266dffe81d1c334703140bdaa459c990aa8ad9c1 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sample.d.ts @@ -0,0 +1,18 @@ +//#region src/fp/array/sample.d.ts +/** + * Creates a function that returns one random element from an array. + * + * The returned function follows the main {@link sample} behavior. Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a random element. + * + * @example + * import { pipe, sample } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], sample()); + * // => one of 1, 2, or 3 + */ +declare function sample(): (array: readonly T[]) => T; +//#endregion +export { sample }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/sample.js b/node_modules/es-toolkit/dist/fp/array/sample.js new file mode 100644 index 0000000000000000000000000000000000000000..19a97682864f74fb12df031ded44d743ea5db5a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sample.js @@ -0,0 +1,23 @@ +const require_sample = require("../../array/sample.js"); +//#region src/fp/array/sample.ts +/** +* Creates a function that returns one random element from an array. +* +* The returned function follows the main {@link sample} behavior. Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a random element. +* +* @example +* import { pipe, sample } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], sample()); +* // => one of 1, 2, or 3 +*/ +function sample() { + return function(array) { + return require_sample.sample(array); + }; +} +//#endregion +exports.sample = sample; diff --git a/node_modules/es-toolkit/dist/fp/array/sample.mjs b/node_modules/es-toolkit/dist/fp/array/sample.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e04544fe3b195752905b029650529c97d94d72bd --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sample.mjs @@ -0,0 +1,23 @@ +import { sample as sample$1 } from "../../array/sample.mjs"; +//#region src/fp/array/sample.ts +/** +* Creates a function that returns one random element from an array. +* +* The returned function follows the main {@link sample} behavior. Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a random element. +* +* @example +* import { pipe, sample } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], sample()); +* // => one of 1, 2, or 3 +*/ +function sample() { + return function(array) { + return sample$1(array); + }; +} +//#endregion +export { sample }; diff --git a/node_modules/es-toolkit/dist/fp/array/sampleSize.d.mts b/node_modules/es-toolkit/dist/fp/array/sampleSize.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b776b592646b7efccf1366aa8979008c8d8ce79c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sampleSize.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/sampleSize.d.ts +/** + * Creates a function that returns random elements from an array. + * + * The returned function follows the main {@link sampleSize} behavior and returns a new array. + * Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param size - The number of elements to sample. + * @returns A function that maps a readonly array to sampled elements. + * + * @example + * import { pipe, sampleSize } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], sampleSize(2)); + * // => two random elements + */ +declare function sampleSize(size: number): (array: readonly T[]) => T[]; +//#endregion +export { sampleSize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/sampleSize.d.ts b/node_modules/es-toolkit/dist/fp/array/sampleSize.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b776b592646b7efccf1366aa8979008c8d8ce79c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sampleSize.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/sampleSize.d.ts +/** + * Creates a function that returns random elements from an array. + * + * The returned function follows the main {@link sampleSize} behavior and returns a new array. + * Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @param size - The number of elements to sample. + * @returns A function that maps a readonly array to sampled elements. + * + * @example + * import { pipe, sampleSize } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], sampleSize(2)); + * // => two random elements + */ +declare function sampleSize(size: number): (array: readonly T[]) => T[]; +//#endregion +export { sampleSize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/sampleSize.js b/node_modules/es-toolkit/dist/fp/array/sampleSize.js new file mode 100644 index 0000000000000000000000000000000000000000..8c8ef45a6631a32fabc7e88b48f95f6ac13cdf84 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sampleSize.js @@ -0,0 +1,25 @@ +const require_sampleSize = require("../../array/sampleSize.js"); +//#region src/fp/array/sampleSize.ts +/** +* Creates a function that returns random elements from an array. +* +* The returned function follows the main {@link sampleSize} behavior and returns a new array. +* Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param size - The number of elements to sample. +* @returns A function that maps a readonly array to sampled elements. +* +* @example +* import { pipe, sampleSize } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], sampleSize(2)); +* // => two random elements +*/ +function sampleSize(size) { + return function(array) { + return require_sampleSize.sampleSize(array, size); + }; +} +//#endregion +exports.sampleSize = sampleSize; diff --git a/node_modules/es-toolkit/dist/fp/array/sampleSize.mjs b/node_modules/es-toolkit/dist/fp/array/sampleSize.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6865144ab1d544753b86408d69516273e70f75de --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sampleSize.mjs @@ -0,0 +1,25 @@ +import { sampleSize as sampleSize$1 } from "../../array/sampleSize.mjs"; +//#region src/fp/array/sampleSize.ts +/** +* Creates a function that returns random elements from an array. +* +* The returned function follows the main {@link sampleSize} behavior and returns a new array. +* Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @param size - The number of elements to sample. +* @returns A function that maps a readonly array to sampled elements. +* +* @example +* import { pipe, sampleSize } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], sampleSize(2)); +* // => two random elements +*/ +function sampleSize(size) { + return function(array) { + return sampleSize$1(array, size); + }; +} +//#endregion +export { sampleSize }; diff --git a/node_modules/es-toolkit/dist/fp/array/shuffle.d.mts b/node_modules/es-toolkit/dist/fp/array/shuffle.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e9683dfe50e7686db44e6b634de0a146db16d5aa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/shuffle.d.mts @@ -0,0 +1,19 @@ +//#region src/fp/array/shuffle.d.ts +/** + * Creates a function that returns a shuffled copy of an array. + * + * The returned function uses the main {@link shuffle} implementation and does not mutate + * the input array. Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a shuffled copy. + * + * @example + * import { pipe, shuffle } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], shuffle()); + * // => the same values in random order + */ +declare function shuffle(): (array: readonly T[]) => T[]; +//#endregion +export { shuffle }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/shuffle.d.ts b/node_modules/es-toolkit/dist/fp/array/shuffle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9683dfe50e7686db44e6b634de0a146db16d5aa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/shuffle.d.ts @@ -0,0 +1,19 @@ +//#region src/fp/array/shuffle.d.ts +/** + * Creates a function that returns a shuffled copy of an array. + * + * The returned function uses the main {@link shuffle} implementation and does not mutate + * the input array. Use it with {@link pipe}. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a shuffled copy. + * + * @example + * import { pipe, shuffle } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], shuffle()); + * // => the same values in random order + */ +declare function shuffle(): (array: readonly T[]) => T[]; +//#endregion +export { shuffle }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/shuffle.js b/node_modules/es-toolkit/dist/fp/array/shuffle.js new file mode 100644 index 0000000000000000000000000000000000000000..20bb2589a69691faefc4ea081d958c4a1ba1145f --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/shuffle.js @@ -0,0 +1,24 @@ +const require_shuffle = require("../../array/shuffle.js"); +//#region src/fp/array/shuffle.ts +/** +* Creates a function that returns a shuffled copy of an array. +* +* The returned function uses the main {@link shuffle} implementation and does not mutate +* the input array. Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a shuffled copy. +* +* @example +* import { pipe, shuffle } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], shuffle()); +* // => the same values in random order +*/ +function shuffle() { + return function(array) { + return require_shuffle.shuffle(array); + }; +} +//#endregion +exports.shuffle = shuffle; diff --git a/node_modules/es-toolkit/dist/fp/array/shuffle.mjs b/node_modules/es-toolkit/dist/fp/array/shuffle.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ce071abc578867bdbdc7e103f687bb395cdf07d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/shuffle.mjs @@ -0,0 +1,24 @@ +import { shuffle as shuffle$1 } from "../../array/shuffle.mjs"; +//#region src/fp/array/shuffle.ts +/** +* Creates a function that returns a shuffled copy of an array. +* +* The returned function uses the main {@link shuffle} implementation and does not mutate +* the input array. Use it with {@link pipe}. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a shuffled copy. +* +* @example +* import { pipe, shuffle } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], shuffle()); +* // => the same values in random order +*/ +function shuffle() { + return function(array) { + return shuffle$1(array); + }; +} +//#endregion +export { shuffle }; diff --git a/node_modules/es-toolkit/dist/fp/array/sortBy.d.mts b/node_modules/es-toolkit/dist/fp/array/sortBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7ee84de432952c8251f386452b6a8cc387ac9dd4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sortBy.d.mts @@ -0,0 +1,26 @@ +//#region src/fp/array/sortBy.d.ts +/** + * Creates a function that sorts an array of objects in ascending order by the + * given `criteria`. Each criterion is either an object key or a function + * returning the value to compare. When two elements tie on a criterion, the + * next criterion breaks the tie. The sort is stable. Use it with {@link pipe}. + * + * @template T - The type of the objects in the array. + * @param criteria - Object keys and/or selector functions used for comparison, applied in order. + * @returns A function that maps a `readonly T[]` to a new, sorted `T[]`. + * + * @example + * import { pipe, sortBy } from 'es-toolkit/fp'; + * + * const users = [ + * { user: 'foo', age: 24 }, + * { user: 'bar', age: 7 }, + * { user: 'foo', age: 8 }, + * ]; + * + * pipe(users, sortBy(['user', 'age'])); + * // => [{ user: 'bar', age: 7 }, { user: 'foo', age: 8 }, { user: 'foo', age: 24 }] + */ +declare function sortBy(criteria: Array<((item: T) => unknown) | keyof T>): (array: readonly T[]) => T[]; +//#endregion +export { sortBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/sortBy.d.ts b/node_modules/es-toolkit/dist/fp/array/sortBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ee84de432952c8251f386452b6a8cc387ac9dd4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sortBy.d.ts @@ -0,0 +1,26 @@ +//#region src/fp/array/sortBy.d.ts +/** + * Creates a function that sorts an array of objects in ascending order by the + * given `criteria`. Each criterion is either an object key or a function + * returning the value to compare. When two elements tie on a criterion, the + * next criterion breaks the tie. The sort is stable. Use it with {@link pipe}. + * + * @template T - The type of the objects in the array. + * @param criteria - Object keys and/or selector functions used for comparison, applied in order. + * @returns A function that maps a `readonly T[]` to a new, sorted `T[]`. + * + * @example + * import { pipe, sortBy } from 'es-toolkit/fp'; + * + * const users = [ + * { user: 'foo', age: 24 }, + * { user: 'bar', age: 7 }, + * { user: 'foo', age: 8 }, + * ]; + * + * pipe(users, sortBy(['user', 'age'])); + * // => [{ user: 'bar', age: 7 }, { user: 'foo', age: 8 }, { user: 'foo', age: 24 }] + */ +declare function sortBy(criteria: Array<((item: T) => unknown) | keyof T>): (array: readonly T[]) => T[]; +//#endregion +export { sortBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/sortBy.js b/node_modules/es-toolkit/dist/fp/array/sortBy.js new file mode 100644 index 0000000000000000000000000000000000000000..ac1a5c472e81fa0196a84cf1145df7217fba44ca --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sortBy.js @@ -0,0 +1,31 @@ +const require_sortBy = require("../../array/sortBy.js"); +//#region src/fp/array/sortBy.ts +/** +* Creates a function that sorts an array of objects in ascending order by the +* given `criteria`. Each criterion is either an object key or a function +* returning the value to compare. When two elements tie on a criterion, the +* next criterion breaks the tie. The sort is stable. Use it with {@link pipe}. +* +* @template T - The type of the objects in the array. +* @param criteria - Object keys and/or selector functions used for comparison, applied in order. +* @returns A function that maps a `readonly T[]` to a new, sorted `T[]`. +* +* @example +* import { pipe, sortBy } from 'es-toolkit/fp'; +* +* const users = [ +* { user: 'foo', age: 24 }, +* { user: 'bar', age: 7 }, +* { user: 'foo', age: 8 }, +* ]; +* +* pipe(users, sortBy(['user', 'age'])); +* // => [{ user: 'bar', age: 7 }, { user: 'foo', age: 8 }, { user: 'foo', age: 24 }] +*/ +function sortBy(criteria) { + return function(array) { + return require_sortBy.sortBy(array, criteria); + }; +} +//#endregion +exports.sortBy = sortBy; diff --git a/node_modules/es-toolkit/dist/fp/array/sortBy.mjs b/node_modules/es-toolkit/dist/fp/array/sortBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f44b9a32dc7afd4329ecf83d050a3af831a2c781 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/sortBy.mjs @@ -0,0 +1,31 @@ +import { sortBy as sortBy$1 } from "../../array/sortBy.mjs"; +//#region src/fp/array/sortBy.ts +/** +* Creates a function that sorts an array of objects in ascending order by the +* given `criteria`. Each criterion is either an object key or a function +* returning the value to compare. When two elements tie on a criterion, the +* next criterion breaks the tie. The sort is stable. Use it with {@link pipe}. +* +* @template T - The type of the objects in the array. +* @param criteria - Object keys and/or selector functions used for comparison, applied in order. +* @returns A function that maps a `readonly T[]` to a new, sorted `T[]`. +* +* @example +* import { pipe, sortBy } from 'es-toolkit/fp'; +* +* const users = [ +* { user: 'foo', age: 24 }, +* { user: 'bar', age: 7 }, +* { user: 'foo', age: 8 }, +* ]; +* +* pipe(users, sortBy(['user', 'age'])); +* // => [{ user: 'bar', age: 7 }, { user: 'foo', age: 8 }, { user: 'foo', age: 24 }] +*/ +function sortBy(criteria) { + return function(array) { + return sortBy$1(array, criteria); + }; +} +//#endregion +export { sortBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/tail.d.mts b/node_modules/es-toolkit/dist/fp/array/tail.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..05c6f1cae63e749adee92ccfd3f6215ce5a4a518 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/tail.d.mts @@ -0,0 +1,19 @@ +//#region src/fp/array/tail.d.ts +/** + * Creates a function that returns every element except the first one. + * + * Empty and single-element arrays return an empty array, matching the main {@link tail} + * 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 tail elements. + * + * @example + * import { pipe, tail } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], tail()); + * // => [2, 3] + */ +declare function tail(): (array: readonly T[]) => T[]; +//#endregion +export { tail }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/tail.d.ts b/node_modules/es-toolkit/dist/fp/array/tail.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..05c6f1cae63e749adee92ccfd3f6215ce5a4a518 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/tail.d.ts @@ -0,0 +1,19 @@ +//#region src/fp/array/tail.d.ts +/** + * Creates a function that returns every element except the first one. + * + * Empty and single-element arrays return an empty array, matching the main {@link tail} + * 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 tail elements. + * + * @example + * import { pipe, tail } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], tail()); + * // => [2, 3] + */ +declare function tail(): (array: readonly T[]) => T[]; +//#endregion +export { tail }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/tail.js b/node_modules/es-toolkit/dist/fp/array/tail.js new file mode 100644 index 0000000000000000000000000000000000000000..3173807ce58b74de5bf647105ac453b529ef5b65 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/tail.js @@ -0,0 +1,24 @@ +const require_tail = require("../../array/tail.js"); +//#region src/fp/array/tail.ts +/** +* Creates a function that returns every element except the first one. +* +* Empty and single-element arrays return an empty array, matching the main {@link tail} +* 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 tail elements. +* +* @example +* import { pipe, tail } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], tail()); +* // => [2, 3] +*/ +function tail() { + return function(array) { + return require_tail.tail(array); + }; +} +//#endregion +exports.tail = tail; diff --git a/node_modules/es-toolkit/dist/fp/array/tail.mjs b/node_modules/es-toolkit/dist/fp/array/tail.mjs new file mode 100644 index 0000000000000000000000000000000000000000..264fe2ffa47c8e63f0f1871c9ec2f37b18b432cf --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/tail.mjs @@ -0,0 +1,24 @@ +import { tail as tail$1 } from "../../array/tail.mjs"; +//#region src/fp/array/tail.ts +/** +* Creates a function that returns every element except the first one. +* +* Empty and single-element arrays return an empty array, matching the main {@link tail} +* 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 tail elements. +* +* @example +* import { pipe, tail } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], tail()); +* // => [2, 3] +*/ +function tail() { + return function(array) { + return tail$1(array); + }; +} +//#endregion +export { tail }; diff --git a/node_modules/es-toolkit/dist/fp/array/take.d.mts b/node_modules/es-toolkit/dist/fp/array/take.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bfb534a49ddce9c2a4681627fa95f6fe106ffbcc --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/take.d.mts @@ -0,0 +1,26 @@ +//#region src/fp/array/take.d.ts +/** + * Creates a function that returns the first `count` elements of an array. If + * `count` is greater than the array length, the whole array is returned. Use it + * with {@link pipe}. + * + * The returned function is **lazy-capable** for a non-negative integer `count`: + * inside a {@link pipe} it stops the walk as soon as `count` elements have been + * collected, so preceding lazy functions never process the rest of the input. + * + * @template T - The type of elements in the array. + * @param count - The number of elements to take from the front of the array. + * @returns A function that maps a `readonly T[]` to a new `T[]`. + * + * @example + * import { pipe, take } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4, 5], take(3)); // => [1, 2, 3] + * + * @example + * // Early termination: `map` only runs three times. + * pipe([1, 2, 3, 4, 5], map(expensive), take(3)); + */ +declare function take(count: number): (array: readonly T[]) => T[]; +//#endregion +export { take }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/take.d.ts b/node_modules/es-toolkit/dist/fp/array/take.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bfb534a49ddce9c2a4681627fa95f6fe106ffbcc --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/take.d.ts @@ -0,0 +1,26 @@ +//#region src/fp/array/take.d.ts +/** + * Creates a function that returns the first `count` elements of an array. If + * `count` is greater than the array length, the whole array is returned. Use it + * with {@link pipe}. + * + * The returned function is **lazy-capable** for a non-negative integer `count`: + * inside a {@link pipe} it stops the walk as soon as `count` elements have been + * collected, so preceding lazy functions never process the rest of the input. + * + * @template T - The type of elements in the array. + * @param count - The number of elements to take from the front of the array. + * @returns A function that maps a `readonly T[]` to a new `T[]`. + * + * @example + * import { pipe, take } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4, 5], take(3)); // => [1, 2, 3] + * + * @example + * // Early termination: `map` only runs three times. + * pipe([1, 2, 3, 4, 5], map(expensive), take(3)); + */ +declare function take(count: number): (array: readonly T[]) => T[]; +//#endregion +export { take }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/take.js b/node_modules/es-toolkit/dist/fp/array/take.js new file mode 100644 index 0000000000000000000000000000000000000000..0d295e69cd4ed4ec9178f430ef4cfd2389d31f0b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/take.js @@ -0,0 +1,39 @@ +const require_take = require("../../array/take.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/take.ts +/** +* Creates a function that returns the first `count` elements of an array. If +* `count` is greater than the array length, the whole array is returned. Use it +* with {@link pipe}. +* +* The returned function is **lazy-capable** for a non-negative integer `count`: +* inside a {@link pipe} it stops the walk as soon as `count` elements have been +* collected, so preceding lazy functions never process the rest of the input. +* +* @template T - The type of elements in the array. +* @param count - The number of elements to take from the front of the array. +* @returns A function that maps a `readonly T[]` to a new `T[]`. +* +* @example +* import { pipe, take } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4, 5], take(3)); // => [1, 2, 3] +* +* @example +* // Early termination: `map` only runs three times. +* pipe([1, 2, 3, 4, 5], map(expensive), take(3)); +*/ +function take(count) { + function takeEager(array) { + return require_take.take(array, count); + } + if (!Number.isInteger(count) || count < 0) return takeEager; + const takeLazy = require_lazy.createLazyFunction((value, index, emit) => { + if (index >= count) return false; + emit(value); + return index < count - 1; + }); + return require_lazy.combineEagerAndLazyFunctions(takeEager, takeLazy, { shortCircuit: true }); +} +//#endregion +exports.take = take; diff --git a/node_modules/es-toolkit/dist/fp/array/take.mjs b/node_modules/es-toolkit/dist/fp/array/take.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4b1ea023a22bdbab9677491b3e22bf41c94b900a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/take.mjs @@ -0,0 +1,38 @@ +import { take as take$1 } from "../../array/take.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/take.ts +/** +* Creates a function that returns the first `count` elements of an array. If +* `count` is greater than the array length, the whole array is returned. Use it +* with {@link pipe}. +* +* The returned function is **lazy-capable** for a non-negative integer `count`: +* inside a {@link pipe} it stops the walk as soon as `count` elements have been +* collected, so preceding lazy functions never process the rest of the input. +* +* @template T - The type of elements in the array. +* @param count - The number of elements to take from the front of the array. +* @returns A function that maps a `readonly T[]` to a new `T[]`. +* +* @example +* import { pipe, take } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4, 5], take(3)); // => [1, 2, 3] +* +* @example +* // Early termination: `map` only runs three times. +* pipe([1, 2, 3, 4, 5], map(expensive), take(3)); +*/ +function take(count) { + function takeEager(array) { + return take$1(array, count); + } + if (!Number.isInteger(count) || count < 0) return takeEager; + return combineEagerAndLazyFunctions(takeEager, createLazyFunction((value, index, emit) => { + if (index >= count) return false; + emit(value); + return index < count - 1; + }), { shortCircuit: true }); +} +//#endregion +export { take }; diff --git a/node_modules/es-toolkit/dist/fp/array/takeRight.d.mts b/node_modules/es-toolkit/dist/fp/array/takeRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..23ef4e9b40bce3cc7fc1879149a6658a74695555 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeRight.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/takeRight.d.ts +/** + * Creates a function that returns the last count values of an array. + * + * The returned function follows the main {@link takeRight} 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 take from the end. + * @returns A function that maps a readonly array to its suffix. + * + * @example + * import { pipe, takeRight } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], takeRight(2)); + * // => [3, 4] + */ +declare function takeRight(count: number): (array: readonly T[]) => T[]; +//#endregion +export { takeRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/takeRight.d.ts b/node_modules/es-toolkit/dist/fp/array/takeRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..23ef4e9b40bce3cc7fc1879149a6658a74695555 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeRight.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/takeRight.d.ts +/** + * Creates a function that returns the last count values of an array. + * + * The returned function follows the main {@link takeRight} 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 take from the end. + * @returns A function that maps a readonly array to its suffix. + * + * @example + * import { pipe, takeRight } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], takeRight(2)); + * // => [3, 4] + */ +declare function takeRight(count: number): (array: readonly T[]) => T[]; +//#endregion +export { takeRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/takeRight.js b/node_modules/es-toolkit/dist/fp/array/takeRight.js new file mode 100644 index 0000000000000000000000000000000000000000..ad7586e2de24f7570aa39892aa3a9ac102facef7 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeRight.js @@ -0,0 +1,25 @@ +const require_takeRight = require("../../array/takeRight.js"); +//#region src/fp/array/takeRight.ts +/** +* Creates a function that returns the last count values of an array. +* +* The returned function follows the main {@link takeRight} 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 take from the end. +* @returns A function that maps a readonly array to its suffix. +* +* @example +* import { pipe, takeRight } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], takeRight(2)); +* // => [3, 4] +*/ +function takeRight(count) { + return function(array) { + return require_takeRight.takeRight(array, count); + }; +} +//#endregion +exports.takeRight = takeRight; diff --git a/node_modules/es-toolkit/dist/fp/array/takeRight.mjs b/node_modules/es-toolkit/dist/fp/array/takeRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2b99a9878d36e6e14290df8f6e8246a971d562dc --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeRight.mjs @@ -0,0 +1,25 @@ +import { takeRight as takeRight$1 } from "../../array/takeRight.mjs"; +//#region src/fp/array/takeRight.ts +/** +* Creates a function that returns the last count values of an array. +* +* The returned function follows the main {@link takeRight} 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 take from the end. +* @returns A function that maps a readonly array to its suffix. +* +* @example +* import { pipe, takeRight } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], takeRight(2)); +* // => [3, 4] +*/ +function takeRight(count) { + return function(array) { + return takeRight$1(array, count); + }; +} +//#endregion +export { takeRight }; diff --git a/node_modules/es-toolkit/dist/fp/array/takeRightWhile.d.mts b/node_modules/es-toolkit/dist/fp/array/takeRightWhile.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..54072ba1b3366e27f1699581ddeb49279857e968 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeRightWhile.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/takeRightWhile.d.ts +/** + * Creates a function that takes 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 taking from the end. + * @returns A function that maps a readonly array to the matching suffix. + * + * @example + * import { pipe, takeRightWhile } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], takeRightWhile(value => value > 2)); + * // => [3, 4] + */ +declare function takeRightWhile(predicate: (element: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { takeRightWhile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/takeRightWhile.d.ts b/node_modules/es-toolkit/dist/fp/array/takeRightWhile.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..54072ba1b3366e27f1699581ddeb49279857e968 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeRightWhile.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/takeRightWhile.d.ts +/** + * Creates a function that takes 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 taking from the end. + * @returns A function that maps a readonly array to the matching suffix. + * + * @example + * import { pipe, takeRightWhile } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], takeRightWhile(value => value > 2)); + * // => [3, 4] + */ +declare function takeRightWhile(predicate: (element: T, index: number, array: readonly T[]) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { takeRightWhile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/takeRightWhile.js b/node_modules/es-toolkit/dist/fp/array/takeRightWhile.js new file mode 100644 index 0000000000000000000000000000000000000000..a83749aebe9e7f26e7607931cdf478d1ed0f3560 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeRightWhile.js @@ -0,0 +1,25 @@ +const require_takeRightWhile = require("../../array/takeRightWhile.js"); +//#region src/fp/array/takeRightWhile.ts +/** +* Creates a function that takes 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 taking from the end. +* @returns A function that maps a readonly array to the matching suffix. +* +* @example +* import { pipe, takeRightWhile } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], takeRightWhile(value => value > 2)); +* // => [3, 4] +*/ +function takeRightWhile(predicate) { + return function(array) { + return require_takeRightWhile.takeRightWhile(array, predicate); + }; +} +//#endregion +exports.takeRightWhile = takeRightWhile; diff --git a/node_modules/es-toolkit/dist/fp/array/takeRightWhile.mjs b/node_modules/es-toolkit/dist/fp/array/takeRightWhile.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f3a4820e12bdaf446a819121dba5f5721faac2ef --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeRightWhile.mjs @@ -0,0 +1,25 @@ +import { takeRightWhile as takeRightWhile$1 } from "../../array/takeRightWhile.mjs"; +//#region src/fp/array/takeRightWhile.ts +/** +* Creates a function that takes 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 taking from the end. +* @returns A function that maps a readonly array to the matching suffix. +* +* @example +* import { pipe, takeRightWhile } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], takeRightWhile(value => value > 2)); +* // => [3, 4] +*/ +function takeRightWhile(predicate) { + return function(array) { + return takeRightWhile$1(array, predicate); + }; +} +//#endregion +export { takeRightWhile }; diff --git a/node_modules/es-toolkit/dist/fp/array/takeWhile.d.mts b/node_modules/es-toolkit/dist/fp/array/takeWhile.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..29a4ec0c44ee5dcc75a26d6c9e1a036ee87542b2 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeWhile.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/takeWhile.d.ts +/** + * Creates a function that takes leading values while a predicate returns true. + * + * The returned function is lazy-capable and short-circuiting inside + * {@link pipe}; once the predicate returns false, upstream lazy operators stop + * processing further input. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each value and index until it returns false. + * @returns A function that maps the piped array to the matching prefix. + * + * @example + * import { pipe, takeWhile } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 1], takeWhile(value => value < 3)); + * // => [1, 2] + */ +declare function takeWhile(predicate: (element: T, index: number) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { takeWhile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/takeWhile.d.ts b/node_modules/es-toolkit/dist/fp/array/takeWhile.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..29a4ec0c44ee5dcc75a26d6c9e1a036ee87542b2 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeWhile.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/takeWhile.d.ts +/** + * Creates a function that takes leading values while a predicate returns true. + * + * The returned function is lazy-capable and short-circuiting inside + * {@link pipe}; once the predicate returns false, upstream lazy operators stop + * processing further input. + * + * @template T - The type of elements in the array. + * @param predicate - Called with each value and index until it returns false. + * @returns A function that maps the piped array to the matching prefix. + * + * @example + * import { pipe, takeWhile } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 1], takeWhile(value => value < 3)); + * // => [1, 2] + */ +declare function takeWhile(predicate: (element: T, index: number) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { takeWhile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/takeWhile.js b/node_modules/es-toolkit/dist/fp/array/takeWhile.js new file mode 100644 index 0000000000000000000000000000000000000000..f35b552f31e4cacf2e19021395c243ec929817a6 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeWhile.js @@ -0,0 +1,32 @@ +const require_takeWhile = require("../../array/takeWhile.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/takeWhile.ts +/** +* Creates a function that takes leading values while a predicate returns true. +* +* The returned function is lazy-capable and short-circuiting inside +* {@link pipe}; once the predicate returns false, upstream lazy operators stop +* processing further input. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each value and index until it returns false. +* @returns A function that maps the piped array to the matching prefix. +* +* @example +* import { pipe, takeWhile } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 1], takeWhile(value => value < 3)); +* // => [1, 2] +*/ +function takeWhile(predicate) { + function takeWhileEager(array) { + return require_takeWhile.takeWhile(array, (element, index) => predicate(element, index)); + } + const takeWhileLazy = require_lazy.createLazyFunction((value, index, emit) => { + if (!predicate(value, index)) return false; + emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(takeWhileEager, takeWhileLazy, { shortCircuit: true }); +} +//#endregion +exports.takeWhile = takeWhile; diff --git a/node_modules/es-toolkit/dist/fp/array/takeWhile.mjs b/node_modules/es-toolkit/dist/fp/array/takeWhile.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5f7881147b167bd7b63ad0b2dfbdc87055e5e5a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/takeWhile.mjs @@ -0,0 +1,31 @@ +import { takeWhile as takeWhile$1 } from "../../array/takeWhile.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/takeWhile.ts +/** +* Creates a function that takes leading values while a predicate returns true. +* +* The returned function is lazy-capable and short-circuiting inside +* {@link pipe}; once the predicate returns false, upstream lazy operators stop +* processing further input. +* +* @template T - The type of elements in the array. +* @param predicate - Called with each value and index until it returns false. +* @returns A function that maps the piped array to the matching prefix. +* +* @example +* import { pipe, takeWhile } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 1], takeWhile(value => value < 3)); +* // => [1, 2] +*/ +function takeWhile(predicate) { + function takeWhileEager(array) { + return takeWhile$1(array, (element, index) => predicate(element, index)); + } + return combineEagerAndLazyFunctions(takeWhileEager, createLazyFunction((value, index, emit) => { + if (!predicate(value, index)) return false; + emit(value); + }), { shortCircuit: true }); +} +//#endregion +export { takeWhile }; diff --git a/node_modules/es-toolkit/dist/fp/array/toFilled.d.mts b/node_modules/es-toolkit/dist/fp/array/toFilled.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..864f9b87692d7321613dd19b793101fa3e40d228 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/toFilled.d.mts @@ -0,0 +1,23 @@ +//#region src/fp/array/toFilled.d.ts +/** + * Creates a function that returns a filled copy of an array. + * + * The returned function follows Array.prototype.fill indexing semantics through the main + * {@link toFilled} implementation and does not mutate the input array. + * + * @template T - The type of elements in the input array. + * @template U - The type of the fill value. + * @param value - The value to write into the returned array. + * @param start - The start index. Defaults to 0. + * @param end - The end index. Defaults to the array length. + * @returns A function that maps a readonly array to a filled copy. + * + * @example + * import { pipe, toFilled } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], toFilled(0, 1)); + * // => [1, 0, 0] + */ +declare function toFilled(value: U, start?: number, end?: number): (array: readonly T[]) => Array; +//#endregion +export { toFilled }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/toFilled.d.ts b/node_modules/es-toolkit/dist/fp/array/toFilled.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..864f9b87692d7321613dd19b793101fa3e40d228 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/toFilled.d.ts @@ -0,0 +1,23 @@ +//#region src/fp/array/toFilled.d.ts +/** + * Creates a function that returns a filled copy of an array. + * + * The returned function follows Array.prototype.fill indexing semantics through the main + * {@link toFilled} implementation and does not mutate the input array. + * + * @template T - The type of elements in the input array. + * @template U - The type of the fill value. + * @param value - The value to write into the returned array. + * @param start - The start index. Defaults to 0. + * @param end - The end index. Defaults to the array length. + * @returns A function that maps a readonly array to a filled copy. + * + * @example + * import { pipe, toFilled } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3], toFilled(0, 1)); + * // => [1, 0, 0] + */ +declare function toFilled(value: U, start?: number, end?: number): (array: readonly T[]) => Array; +//#endregion +export { toFilled }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/toFilled.js b/node_modules/es-toolkit/dist/fp/array/toFilled.js new file mode 100644 index 0000000000000000000000000000000000000000..8bd40d679c4947b423cb35bdcf4afc0855761ba0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/toFilled.js @@ -0,0 +1,30 @@ +const require_toFilled = require("../../array/toFilled.js"); +//#region src/fp/array/toFilled.ts +/** +* Creates a function that returns a filled copy of an array. +* +* The returned function follows Array.prototype.fill indexing semantics through the main +* {@link toFilled} implementation and does not mutate the input array. +* +* @template T - The type of elements in the input array. +* @template U - The type of the fill value. +* @param value - The value to write into the returned array. +* @param start - The start index. Defaults to 0. +* @param end - The end index. Defaults to the array length. +* @returns A function that maps a readonly array to a filled copy. +* +* @example +* import { pipe, toFilled } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], toFilled(0, 1)); +* // => [1, 0, 0] +*/ +function toFilled(value, start, end) { + return function(array) { + if (start == null) return require_toFilled.toFilled(array, value); + if (end == null) return require_toFilled.toFilled(array, value, start); + return require_toFilled.toFilled(array, value, start, end); + }; +} +//#endregion +exports.toFilled = toFilled; diff --git a/node_modules/es-toolkit/dist/fp/array/toFilled.mjs b/node_modules/es-toolkit/dist/fp/array/toFilled.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c1e1eaba31f42302f389fb1a4bddbe989859b1aa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/toFilled.mjs @@ -0,0 +1,30 @@ +import { toFilled as toFilled$1 } from "../../array/toFilled.mjs"; +//#region src/fp/array/toFilled.ts +/** +* Creates a function that returns a filled copy of an array. +* +* The returned function follows Array.prototype.fill indexing semantics through the main +* {@link toFilled} implementation and does not mutate the input array. +* +* @template T - The type of elements in the input array. +* @template U - The type of the fill value. +* @param value - The value to write into the returned array. +* @param start - The start index. Defaults to 0. +* @param end - The end index. Defaults to the array length. +* @returns A function that maps a readonly array to a filled copy. +* +* @example +* import { pipe, toFilled } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], toFilled(0, 1)); +* // => [1, 0, 0] +*/ +function toFilled(value, start, end) { + return function(array) { + if (start == null) return toFilled$1(array, value); + if (end == null) return toFilled$1(array, value, start); + return toFilled$1(array, value, start, end); + }; +} +//#endregion +export { toFilled }; diff --git a/node_modules/es-toolkit/dist/fp/array/union.d.mts b/node_modules/es-toolkit/dist/fp/array/union.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7914c993db0e7ddcfcc03f59db698e43be5402e0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/union.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/union.d.ts +/** + * Creates a function that returns unique values from the piped array and secondArray. + * + * Values keep their first occurrence order, matching the main {@link union} behavior. + * Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to include after the piped array. + * @returns A function that maps a readonly array to its union with secondArray. + * + * @example + * import { pipe, union } from 'es-toolkit/fp'; + * + * pipe([1, 2], union([2, 3])); + * // => [1, 2, 3] + */ +declare function union(secondArray: readonly T[]): (array: readonly T[]) => T[]; +//#endregion +export { union }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/union.d.ts b/node_modules/es-toolkit/dist/fp/array/union.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7914c993db0e7ddcfcc03f59db698e43be5402e0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/union.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/union.d.ts +/** + * Creates a function that returns unique values from the piped array and secondArray. + * + * Values keep their first occurrence order, matching the main {@link union} behavior. + * Use the returned function with {@link pipe}. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to include after the piped array. + * @returns A function that maps a readonly array to its union with secondArray. + * + * @example + * import { pipe, union } from 'es-toolkit/fp'; + * + * pipe([1, 2], union([2, 3])); + * // => [1, 2, 3] + */ +declare function union(secondArray: readonly T[]): (array: readonly T[]) => T[]; +//#endregion +export { union }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/union.js b/node_modules/es-toolkit/dist/fp/array/union.js new file mode 100644 index 0000000000000000000000000000000000000000..97c73b1d7b91d4d58f29765fc7fe49df3d0c6c76 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/union.js @@ -0,0 +1,25 @@ +const require_union = require("../../array/union.js"); +//#region src/fp/array/union.ts +/** +* Creates a function that returns unique values from the piped array and secondArray. +* +* Values keep their first occurrence order, matching the main {@link union} behavior. +* Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to include after the piped array. +* @returns A function that maps a readonly array to its union with secondArray. +* +* @example +* import { pipe, union } from 'es-toolkit/fp'; +* +* pipe([1, 2], union([2, 3])); +* // => [1, 2, 3] +*/ +function union(secondArray) { + return function(array) { + return require_union.union(array, secondArray); + }; +} +//#endregion +exports.union = union; diff --git a/node_modules/es-toolkit/dist/fp/array/union.mjs b/node_modules/es-toolkit/dist/fp/array/union.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2976261eb150944892def2941b084358a3130e5d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/union.mjs @@ -0,0 +1,25 @@ +import { union as union$1 } from "../../array/union.mjs"; +//#region src/fp/array/union.ts +/** +* Creates a function that returns unique values from the piped array and secondArray. +* +* Values keep their first occurrence order, matching the main {@link union} behavior. +* Use the returned function with {@link pipe}. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to include after the piped array. +* @returns A function that maps a readonly array to its union with secondArray. +* +* @example +* import { pipe, union } from 'es-toolkit/fp'; +* +* pipe([1, 2], union([2, 3])); +* // => [1, 2, 3] +*/ +function union(secondArray) { + return function(array) { + return union$1(array, secondArray); + }; +} +//#endregion +export { union }; diff --git a/node_modules/es-toolkit/dist/fp/array/unionBy.d.mts b/node_modules/es-toolkit/dist/fp/array/unionBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4315a7ca6163d3bb3ad69ea4a7348e209c5a3c26 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unionBy.d.mts @@ -0,0 +1,22 @@ +//#region src/fp/array/unionBy.d.ts +/** + * Creates a function that returns unique values by mapped identity. + * + * Values from the piped array are considered before values from secondArray. The mapper + * is used to compare identities, matching the main {@link unionBy} behavior. + * + * @template T - The type of elements in the arrays. + * @template U - The type of comparison keys returned by the mapper. + * @param secondArray - Values to include after the piped array. + * @param mapper - Called for values from both arrays to produce comparison keys. + * @returns A function that maps a readonly array to its union with secondArray. + * + * @example + * import { pipe, unionBy } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }], unionBy([{ id: 1 }, { id: 2 }], item => item.id)); + * // => [{ id: 1 }, { id: 2 }] + */ +declare function unionBy(secondArray: readonly T[], mapper: (item: T) => U): (array: readonly T[]) => T[]; +//#endregion +export { unionBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/unionBy.d.ts b/node_modules/es-toolkit/dist/fp/array/unionBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4315a7ca6163d3bb3ad69ea4a7348e209c5a3c26 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unionBy.d.ts @@ -0,0 +1,22 @@ +//#region src/fp/array/unionBy.d.ts +/** + * Creates a function that returns unique values by mapped identity. + * + * Values from the piped array are considered before values from secondArray. The mapper + * is used to compare identities, matching the main {@link unionBy} behavior. + * + * @template T - The type of elements in the arrays. + * @template U - The type of comparison keys returned by the mapper. + * @param secondArray - Values to include after the piped array. + * @param mapper - Called for values from both arrays to produce comparison keys. + * @returns A function that maps a readonly array to its union with secondArray. + * + * @example + * import { pipe, unionBy } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }], unionBy([{ id: 1 }, { id: 2 }], item => item.id)); + * // => [{ id: 1 }, { id: 2 }] + */ +declare function unionBy(secondArray: readonly T[], mapper: (item: T) => U): (array: readonly T[]) => T[]; +//#endregion +export { unionBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/unionBy.js b/node_modules/es-toolkit/dist/fp/array/unionBy.js new file mode 100644 index 0000000000000000000000000000000000000000..c15c3d24365a50f025fe871b453eb1a58aa517cd --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unionBy.js @@ -0,0 +1,27 @@ +const require_unionBy = require("../../array/unionBy.js"); +//#region src/fp/array/unionBy.ts +/** +* Creates a function that returns unique values by mapped identity. +* +* Values from the piped array are considered before values from secondArray. The mapper +* is used to compare identities, matching the main {@link unionBy} behavior. +* +* @template T - The type of elements in the arrays. +* @template U - The type of comparison keys returned by the mapper. +* @param secondArray - Values to include after the piped array. +* @param mapper - Called for values from both arrays to produce comparison keys. +* @returns A function that maps a readonly array to its union with secondArray. +* +* @example +* import { pipe, unionBy } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }], unionBy([{ id: 1 }, { id: 2 }], item => item.id)); +* // => [{ id: 1 }, { id: 2 }] +*/ +function unionBy(secondArray, mapper) { + return function(array) { + return require_unionBy.unionBy(array, secondArray, mapper); + }; +} +//#endregion +exports.unionBy = unionBy; diff --git a/node_modules/es-toolkit/dist/fp/array/unionBy.mjs b/node_modules/es-toolkit/dist/fp/array/unionBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a28220d346e1981a435214f59e6b48d0a8d2ad84 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unionBy.mjs @@ -0,0 +1,27 @@ +import { unionBy as unionBy$1 } from "../../array/unionBy.mjs"; +//#region src/fp/array/unionBy.ts +/** +* Creates a function that returns unique values by mapped identity. +* +* Values from the piped array are considered before values from secondArray. The mapper +* is used to compare identities, matching the main {@link unionBy} behavior. +* +* @template T - The type of elements in the arrays. +* @template U - The type of comparison keys returned by the mapper. +* @param secondArray - Values to include after the piped array. +* @param mapper - Called for values from both arrays to produce comparison keys. +* @returns A function that maps a readonly array to its union with secondArray. +* +* @example +* import { pipe, unionBy } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }], unionBy([{ id: 1 }, { id: 2 }], item => item.id)); +* // => [{ id: 1 }, { id: 2 }] +*/ +function unionBy(secondArray, mapper) { + return function(array) { + return unionBy$1(array, secondArray, mapper); + }; +} +//#endregion +export { unionBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/unionWith.d.mts b/node_modules/es-toolkit/dist/fp/array/unionWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..58cde764b26ecac8fbd317934f3956f17d7c440b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unionWith.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/unionWith.d.ts +/** + * Creates a function that returns unique values using a custom equality function. + * + * Values from the piped array are considered before values from secondArray. The equality + * function decides whether two values represent the same item. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to include after the piped array. + * @param areItemsEqual - Returns true when two values are equal. + * @returns A function that maps a readonly array to its union with secondArray. + * + * @example + * import { pipe, unionWith } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }], unionWith([{ id: 1 }, { id: 2 }], (a, b) => a.id === b.id)); + * // => [{ id: 1 }, { id: 2 }] + */ +declare function unionWith(secondArray: readonly T[], areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { unionWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/unionWith.d.ts b/node_modules/es-toolkit/dist/fp/array/unionWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..58cde764b26ecac8fbd317934f3956f17d7c440b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unionWith.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/unionWith.d.ts +/** + * Creates a function that returns unique values using a custom equality function. + * + * Values from the piped array are considered before values from secondArray. The equality + * function decides whether two values represent the same item. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to include after the piped array. + * @param areItemsEqual - Returns true when two values are equal. + * @returns A function that maps a readonly array to its union with secondArray. + * + * @example + * import { pipe, unionWith } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }], unionWith([{ id: 1 }, { id: 2 }], (a, b) => a.id === b.id)); + * // => [{ id: 1 }, { id: 2 }] + */ +declare function unionWith(secondArray: readonly T[], areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { unionWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/unionWith.js b/node_modules/es-toolkit/dist/fp/array/unionWith.js new file mode 100644 index 0000000000000000000000000000000000000000..468f86230640a498797a0f0c25da04113000b2e8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unionWith.js @@ -0,0 +1,26 @@ +const require_unionWith = require("../../array/unionWith.js"); +//#region src/fp/array/unionWith.ts +/** +* Creates a function that returns unique values using a custom equality function. +* +* Values from the piped array are considered before values from secondArray. The equality +* function decides whether two values represent the same item. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to include after the piped array. +* @param areItemsEqual - Returns true when two values are equal. +* @returns A function that maps a readonly array to its union with secondArray. +* +* @example +* import { pipe, unionWith } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }], unionWith([{ id: 1 }, { id: 2 }], (a, b) => a.id === b.id)); +* // => [{ id: 1 }, { id: 2 }] +*/ +function unionWith(secondArray, areItemsEqual) { + return function(array) { + return require_unionWith.unionWith(array, secondArray, areItemsEqual); + }; +} +//#endregion +exports.unionWith = unionWith; diff --git a/node_modules/es-toolkit/dist/fp/array/unionWith.mjs b/node_modules/es-toolkit/dist/fp/array/unionWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2e725ef35a481c902142b1d32128b4d9b1090b0d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unionWith.mjs @@ -0,0 +1,26 @@ +import { unionWith as unionWith$1 } from "../../array/unionWith.mjs"; +//#region src/fp/array/unionWith.ts +/** +* Creates a function that returns unique values using a custom equality function. +* +* Values from the piped array are considered before values from secondArray. The equality +* function decides whether two values represent the same item. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to include after the piped array. +* @param areItemsEqual - Returns true when two values are equal. +* @returns A function that maps a readonly array to its union with secondArray. +* +* @example +* import { pipe, unionWith } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }], unionWith([{ id: 1 }, { id: 2 }], (a, b) => a.id === b.id)); +* // => [{ id: 1 }, { id: 2 }] +*/ +function unionWith(secondArray, areItemsEqual) { + return function(array) { + return unionWith$1(array, secondArray, areItemsEqual); + }; +} +//#endregion +export { unionWith }; diff --git a/node_modules/es-toolkit/dist/fp/array/uniq.d.mts b/node_modules/es-toolkit/dist/fp/array/uniq.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..97480915f09bd6dd6e5e3b958aeb19b87c0309b8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniq.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/uniq.d.ts +/** + * Creates a function that removes duplicate values from an array, preserving + * the order of first occurrence. Equality follows SameValueZero, matching + * Set semantics. Use it with {@link pipe}. + * + * The returned function is lazy-capable inside {@link pipe}. It keeps a Set of + * values already emitted during each pipeline run. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a duplicate-free array. + * + * @example + * import { pipe, uniq } from 'es-toolkit/fp'; + * + * pipe([1, 2, 2, 3, 3, 3], uniq()); + * // => [1, 2, 3] + */ +declare function uniq(): (array: readonly T[]) => T[]; +//#endregion +export { uniq }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/uniq.d.ts b/node_modules/es-toolkit/dist/fp/array/uniq.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..97480915f09bd6dd6e5e3b958aeb19b87c0309b8 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniq.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/uniq.d.ts +/** + * Creates a function that removes duplicate values from an array, preserving + * the order of first occurrence. Equality follows SameValueZero, matching + * Set semantics. Use it with {@link pipe}. + * + * The returned function is lazy-capable inside {@link pipe}. It keeps a Set of + * values already emitted during each pipeline run. + * + * @template T - The type of elements in the array. + * @returns A function that maps a readonly array to a duplicate-free array. + * + * @example + * import { pipe, uniq } from 'es-toolkit/fp'; + * + * pipe([1, 2, 2, 3, 3, 3], uniq()); + * // => [1, 2, 3] + */ +declare function uniq(): (array: readonly T[]) => T[]; +//#endregion +export { uniq }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/uniq.js b/node_modules/es-toolkit/dist/fp/array/uniq.js new file mode 100644 index 0000000000000000000000000000000000000000..11e686af7fe8765dc286ad794d27e5b962b62e9a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniq.js @@ -0,0 +1,36 @@ +const require_uniq = require("../../array/uniq.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/uniq.ts +/** +* Creates a function that removes duplicate values from an array, preserving +* the order of first occurrence. Equality follows SameValueZero, matching +* Set semantics. Use it with {@link pipe}. +* +* The returned function is lazy-capable inside {@link pipe}. It keeps a Set of +* values already emitted during each pipeline run. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a duplicate-free array. +* +* @example +* import { pipe, uniq } from 'es-toolkit/fp'; +* +* pipe([1, 2, 2, 3, 3, 3], uniq()); +* // => [1, 2, 3] +*/ +function uniq() { + function uniqEager(array) { + return require_uniq.uniq(array); + } + const uniqLazy = (emit) => { + const seen = /* @__PURE__ */ new Set(); + return (value) => { + if (seen.has(value)) return true; + seen.add(value); + return emit(value); + }; + }; + return require_lazy.combineEagerAndLazyFunctions(uniqEager, uniqLazy); +} +//#endregion +exports.uniq = uniq; diff --git a/node_modules/es-toolkit/dist/fp/array/uniq.mjs b/node_modules/es-toolkit/dist/fp/array/uniq.mjs new file mode 100644 index 0000000000000000000000000000000000000000..85ad046705316c01f94ce095a3554d484f9a1abe --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniq.mjs @@ -0,0 +1,36 @@ +import { uniq as uniq$1 } from "../../array/uniq.mjs"; +import { combineEagerAndLazyFunctions } from "../_internal/lazy.mjs"; +//#region src/fp/array/uniq.ts +/** +* Creates a function that removes duplicate values from an array, preserving +* the order of first occurrence. Equality follows SameValueZero, matching +* Set semantics. Use it with {@link pipe}. +* +* The returned function is lazy-capable inside {@link pipe}. It keeps a Set of +* values already emitted during each pipeline run. +* +* @template T - The type of elements in the array. +* @returns A function that maps a readonly array to a duplicate-free array. +* +* @example +* import { pipe, uniq } from 'es-toolkit/fp'; +* +* pipe([1, 2, 2, 3, 3, 3], uniq()); +* // => [1, 2, 3] +*/ +function uniq() { + function uniqEager(array) { + return uniq$1(array); + } + const uniqLazy = (emit) => { + const seen = /* @__PURE__ */ new Set(); + return (value) => { + if (seen.has(value)) return true; + seen.add(value); + return emit(value); + }; + }; + return combineEagerAndLazyFunctions(uniqEager, uniqLazy); +} +//#endregion +export { uniq }; diff --git a/node_modules/es-toolkit/dist/fp/array/uniqBy.d.mts b/node_modules/es-toolkit/dist/fp/array/uniqBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7c261f85bb496a2327efac005cd511abeb290b5d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniqBy.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/uniqBy.d.ts +/** + * Creates a function that removes duplicate values by mapped identity. + * + * The first value for each mapped key is preserved. The returned function is + * lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @template U - The type of comparison keys returned by the mapper. + * @param mapper - Called with each value and index to produce a comparison key. + * @returns A function that maps the piped array to unique values. + * + * @example + * import { pipe, uniqBy } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 1 }, { id: 2 }], uniqBy(item => item.id)); + * // => [{ id: 1 }, { id: 2 }] + */ +declare function uniqBy(mapper: (item: T, index: number) => U): (array: readonly T[]) => T[]; +//#endregion +export { uniqBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/uniqBy.d.ts b/node_modules/es-toolkit/dist/fp/array/uniqBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c261f85bb496a2327efac005cd511abeb290b5d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniqBy.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/uniqBy.d.ts +/** + * Creates a function that removes duplicate values by mapped identity. + * + * The first value for each mapped key is preserved. The returned function is + * lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @template U - The type of comparison keys returned by the mapper. + * @param mapper - Called with each value and index to produce a comparison key. + * @returns A function that maps the piped array to unique values. + * + * @example + * import { pipe, uniqBy } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 1 }, { id: 2 }], uniqBy(item => item.id)); + * // => [{ id: 1 }, { id: 2 }] + */ +declare function uniqBy(mapper: (item: T, index: number) => U): (array: readonly T[]) => T[]; +//#endregion +export { uniqBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/uniqBy.js b/node_modules/es-toolkit/dist/fp/array/uniqBy.js new file mode 100644 index 0000000000000000000000000000000000000000..174e60db4293994e8d5488325e5a01ce2c0b84f3 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniqBy.js @@ -0,0 +1,38 @@ +const require_uniqBy = require("../../array/uniqBy.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/uniqBy.ts +/** +* Creates a function that removes duplicate values by mapped identity. +* +* The first value for each mapped key is preserved. The returned function is +* lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @template U - The type of comparison keys returned by the mapper. +* @param mapper - Called with each value and index to produce a comparison key. +* @returns A function that maps the piped array to unique values. +* +* @example +* import { pipe, uniqBy } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 1 }, { id: 2 }], uniqBy(item => item.id)); +* // => [{ id: 1 }, { id: 2 }] +*/ +function uniqBy(mapper) { + function uniqByEager(array) { + return require_uniqBy.uniqBy(array, (item, index) => mapper(item, index)); + } + const uniqByLazy = (emit) => { + const seen = /* @__PURE__ */ new Set(); + let index = 0; + return (value) => { + const key = mapper(value, index++); + if (seen.has(key)) return true; + seen.add(key); + return emit(value); + }; + }; + return require_lazy.combineEagerAndLazyFunctions(uniqByEager, uniqByLazy); +} +//#endregion +exports.uniqBy = uniqBy; diff --git a/node_modules/es-toolkit/dist/fp/array/uniqBy.mjs b/node_modules/es-toolkit/dist/fp/array/uniqBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5f644b529d157b75edb9e4081fbbd19454fe79f3 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniqBy.mjs @@ -0,0 +1,38 @@ +import { uniqBy as uniqBy$1 } from "../../array/uniqBy.mjs"; +import { combineEagerAndLazyFunctions } from "../_internal/lazy.mjs"; +//#region src/fp/array/uniqBy.ts +/** +* Creates a function that removes duplicate values by mapped identity. +* +* The first value for each mapped key is preserved. The returned function is +* lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @template U - The type of comparison keys returned by the mapper. +* @param mapper - Called with each value and index to produce a comparison key. +* @returns A function that maps the piped array to unique values. +* +* @example +* import { pipe, uniqBy } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 1 }, { id: 2 }], uniqBy(item => item.id)); +* // => [{ id: 1 }, { id: 2 }] +*/ +function uniqBy(mapper) { + function uniqByEager(array) { + return uniqBy$1(array, (item, index) => mapper(item, index)); + } + const uniqByLazy = (emit) => { + const seen = /* @__PURE__ */ new Set(); + let index = 0; + return (value) => { + const key = mapper(value, index++); + if (seen.has(key)) return true; + seen.add(key); + return emit(value); + }; + }; + return combineEagerAndLazyFunctions(uniqByEager, uniqByLazy); +} +//#endregion +export { uniqBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/uniqWith.d.mts b/node_modules/es-toolkit/dist/fp/array/uniqWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1aeebe6f3ccaec99d7056ca8ed5ed21454f42f98 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniqWith.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/uniqWith.d.ts +/** + * Creates a function that removes duplicate values using a custom equality function. + * + * The first value in each equality group is preserved. The returned function is + * lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param areItemsEqual - Returns true when two values should be treated as equal. + * @returns A function that maps the piped array to unique values. + * + * @example + * import { pipe, uniqWith } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 1 }, { id: 2 }], uniqWith((a, b) => a.id === b.id)); + * // => [{ id: 1 }, { id: 2 }] + */ +declare function uniqWith(areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { uniqWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/uniqWith.d.ts b/node_modules/es-toolkit/dist/fp/array/uniqWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1aeebe6f3ccaec99d7056ca8ed5ed21454f42f98 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniqWith.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/uniqWith.d.ts +/** + * Creates a function that removes duplicate values using a custom equality function. + * + * The first value in each equality group is preserved. The returned function is + * lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param areItemsEqual - Returns true when two values should be treated as equal. + * @returns A function that maps the piped array to unique values. + * + * @example + * import { pipe, uniqWith } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 1 }, { id: 2 }], uniqWith((a, b) => a.id === b.id)); + * // => [{ id: 1 }, { id: 2 }] + */ +declare function uniqWith(areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { uniqWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/uniqWith.js b/node_modules/es-toolkit/dist/fp/array/uniqWith.js new file mode 100644 index 0000000000000000000000000000000000000000..138d716e4645c964c85e23ed16c21142bf6d158a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniqWith.js @@ -0,0 +1,35 @@ +const require_uniqWith = require("../../array/uniqWith.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/uniqWith.ts +/** +* Creates a function that removes duplicate values using a custom equality function. +* +* The first value in each equality group is preserved. The returned function is +* lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param areItemsEqual - Returns true when two values should be treated as equal. +* @returns A function that maps the piped array to unique values. +* +* @example +* import { pipe, uniqWith } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 1 }, { id: 2 }], uniqWith((a, b) => a.id === b.id)); +* // => [{ id: 1 }, { id: 2 }] +*/ +function uniqWith(areItemsEqual) { + function uniqWithEager(array) { + return require_uniqWith.uniqWith(array, areItemsEqual); + } + const uniqWithLazy = (emit) => { + const seen = []; + return (value) => { + if (seen.some((item) => areItemsEqual(item, value))) return true; + seen.push(value); + return emit(value); + }; + }; + return require_lazy.combineEagerAndLazyFunctions(uniqWithEager, uniqWithLazy); +} +//#endregion +exports.uniqWith = uniqWith; diff --git a/node_modules/es-toolkit/dist/fp/array/uniqWith.mjs b/node_modules/es-toolkit/dist/fp/array/uniqWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3056758c3d8038cfb2e83ceb619b1910fb7f9e40 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/uniqWith.mjs @@ -0,0 +1,35 @@ +import { uniqWith as uniqWith$1 } from "../../array/uniqWith.mjs"; +import { combineEagerAndLazyFunctions } from "../_internal/lazy.mjs"; +//#region src/fp/array/uniqWith.ts +/** +* Creates a function that removes duplicate values using a custom equality function. +* +* The first value in each equality group is preserved. The returned function is +* lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param areItemsEqual - Returns true when two values should be treated as equal. +* @returns A function that maps the piped array to unique values. +* +* @example +* import { pipe, uniqWith } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 1 }, { id: 2 }], uniqWith((a, b) => a.id === b.id)); +* // => [{ id: 1 }, { id: 2 }] +*/ +function uniqWith(areItemsEqual) { + function uniqWithEager(array) { + return uniqWith$1(array, areItemsEqual); + } + const uniqWithLazy = (emit) => { + const seen = []; + return (value) => { + if (seen.some((item) => areItemsEqual(item, value))) return true; + seen.push(value); + return emit(value); + }; + }; + return combineEagerAndLazyFunctions(uniqWithEager, uniqWithLazy); +} +//#endregion +export { uniqWith }; diff --git a/node_modules/es-toolkit/dist/fp/array/unzip.d.mts b/node_modules/es-toolkit/dist/fp/array/unzip.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8fc4d758f5f1f8048b608f394b03bedefa5cdd6c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unzip.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/unzip.d.ts +type Unzip = { [I in keyof K]: Array }; +/** + * Creates a function that unzips grouped tuples into arrays by position. + * + * The returned function is the data-last form of the main {@link unzip} utility. + * Use it with {@link pipe}. + * + * @template T - The tuple type inside the zipped array. + * @returns A function that maps zipped tuples to arrays grouped by tuple position. + * + * @example + * import { pipe, unzip } from 'es-toolkit/fp'; + * + * pipe([[1, 'a'], [2, 'b']] as Array<[number, string]>, unzip()); + * // => [[1, 2], ['a', 'b']] + */ +declare function unzip(): (zipped: ReadonlyArray<[...T]>) => Unzip; +//#endregion +export { unzip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/unzip.d.ts b/node_modules/es-toolkit/dist/fp/array/unzip.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8fc4d758f5f1f8048b608f394b03bedefa5cdd6c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unzip.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/unzip.d.ts +type Unzip = { [I in keyof K]: Array }; +/** + * Creates a function that unzips grouped tuples into arrays by position. + * + * The returned function is the data-last form of the main {@link unzip} utility. + * Use it with {@link pipe}. + * + * @template T - The tuple type inside the zipped array. + * @returns A function that maps zipped tuples to arrays grouped by tuple position. + * + * @example + * import { pipe, unzip } from 'es-toolkit/fp'; + * + * pipe([[1, 'a'], [2, 'b']] as Array<[number, string]>, unzip()); + * // => [[1, 2], ['a', 'b']] + */ +declare function unzip(): (zipped: ReadonlyArray<[...T]>) => Unzip; +//#endregion +export { unzip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/unzip.js b/node_modules/es-toolkit/dist/fp/array/unzip.js new file mode 100644 index 0000000000000000000000000000000000000000..c75afcf8f2aa31ca5e76ff24e270cfd11cb96824 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unzip.js @@ -0,0 +1,24 @@ +const require_unzip = require("../../array/unzip.js"); +//#region src/fp/array/unzip.ts +/** +* Creates a function that unzips grouped tuples into arrays by position. +* +* The returned function is the data-last form of the main {@link unzip} utility. +* Use it with {@link pipe}. +* +* @template T - The tuple type inside the zipped array. +* @returns A function that maps zipped tuples to arrays grouped by tuple position. +* +* @example +* import { pipe, unzip } from 'es-toolkit/fp'; +* +* pipe([[1, 'a'], [2, 'b']] as Array<[number, string]>, unzip()); +* // => [[1, 2], ['a', 'b']] +*/ +function unzip() { + return function(zipped) { + return require_unzip.unzip(zipped); + }; +} +//#endregion +exports.unzip = unzip; diff --git a/node_modules/es-toolkit/dist/fp/array/unzip.mjs b/node_modules/es-toolkit/dist/fp/array/unzip.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c78bbc34d14f564cecfdc39f93dae86a1f05dada --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unzip.mjs @@ -0,0 +1,24 @@ +import { unzip as unzip$1 } from "../../array/unzip.mjs"; +//#region src/fp/array/unzip.ts +/** +* Creates a function that unzips grouped tuples into arrays by position. +* +* The returned function is the data-last form of the main {@link unzip} utility. +* Use it with {@link pipe}. +* +* @template T - The tuple type inside the zipped array. +* @returns A function that maps zipped tuples to arrays grouped by tuple position. +* +* @example +* import { pipe, unzip } from 'es-toolkit/fp'; +* +* pipe([[1, 'a'], [2, 'b']] as Array<[number, string]>, unzip()); +* // => [[1, 2], ['a', 'b']] +*/ +function unzip() { + return function(zipped) { + return unzip$1(zipped); + }; +} +//#endregion +export { unzip }; diff --git a/node_modules/es-toolkit/dist/fp/array/unzipWith.d.mts b/node_modules/es-toolkit/dist/fp/array/unzipWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..14c7878b2a0c3d70ef4a7e20963ece24154d4bcd --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unzipWith.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/unzipWith.d.ts +/** + * Creates a function that unzips grouped arrays and combines values by position. + * + * Values at the same position are passed to iteratee, and its return values form the + * resulting array. + * + * @template T - The element type inside each grouped array. + * @template R - The value returned by the iteratee. + * @param iteratee - Called with the values at each position. + * @returns A function that maps grouped arrays to combined values. + * + * @example + * import { pipe, unzipWith } from 'es-toolkit/fp'; + * + * pipe([[1, 10], [2, 20]], unzipWith((a, b) => a + b)); + * // => [3, 30] + */ +declare function unzipWith(iteratee: (...args: T[]) => R): (target: readonly T[][]) => R[]; +//#endregion +export { unzipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/unzipWith.d.ts b/node_modules/es-toolkit/dist/fp/array/unzipWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..14c7878b2a0c3d70ef4a7e20963ece24154d4bcd --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unzipWith.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/unzipWith.d.ts +/** + * Creates a function that unzips grouped arrays and combines values by position. + * + * Values at the same position are passed to iteratee, and its return values form the + * resulting array. + * + * @template T - The element type inside each grouped array. + * @template R - The value returned by the iteratee. + * @param iteratee - Called with the values at each position. + * @returns A function that maps grouped arrays to combined values. + * + * @example + * import { pipe, unzipWith } from 'es-toolkit/fp'; + * + * pipe([[1, 10], [2, 20]], unzipWith((a, b) => a + b)); + * // => [3, 30] + */ +declare function unzipWith(iteratee: (...args: T[]) => R): (target: readonly T[][]) => R[]; +//#endregion +export { unzipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/unzipWith.js b/node_modules/es-toolkit/dist/fp/array/unzipWith.js new file mode 100644 index 0000000000000000000000000000000000000000..9711fde66aa73713670f1a4ca8dc22caac289748 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unzipWith.js @@ -0,0 +1,26 @@ +const require_unzipWith = require("../../array/unzipWith.js"); +//#region src/fp/array/unzipWith.ts +/** +* Creates a function that unzips grouped arrays and combines values by position. +* +* Values at the same position are passed to iteratee, and its return values form the +* resulting array. +* +* @template T - The element type inside each grouped array. +* @template R - The value returned by the iteratee. +* @param iteratee - Called with the values at each position. +* @returns A function that maps grouped arrays to combined values. +* +* @example +* import { pipe, unzipWith } from 'es-toolkit/fp'; +* +* pipe([[1, 10], [2, 20]], unzipWith((a, b) => a + b)); +* // => [3, 30] +*/ +function unzipWith(iteratee) { + return function(target) { + return require_unzipWith.unzipWith(target, iteratee); + }; +} +//#endregion +exports.unzipWith = unzipWith; diff --git a/node_modules/es-toolkit/dist/fp/array/unzipWith.mjs b/node_modules/es-toolkit/dist/fp/array/unzipWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bc15d3c0929214414309beeb5a3b81734f04b7f2 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/unzipWith.mjs @@ -0,0 +1,26 @@ +import { unzipWith as unzipWith$1 } from "../../array/unzipWith.mjs"; +//#region src/fp/array/unzipWith.ts +/** +* Creates a function that unzips grouped arrays and combines values by position. +* +* Values at the same position are passed to iteratee, and its return values form the +* resulting array. +* +* @template T - The element type inside each grouped array. +* @template R - The value returned by the iteratee. +* @param iteratee - Called with the values at each position. +* @returns A function that maps grouped arrays to combined values. +* +* @example +* import { pipe, unzipWith } from 'es-toolkit/fp'; +* +* pipe([[1, 10], [2, 20]], unzipWith((a, b) => a + b)); +* // => [3, 30] +*/ +function unzipWith(iteratee) { + return function(target) { + return unzipWith$1(target, iteratee); + }; +} +//#endregion +export { unzipWith }; diff --git a/node_modules/es-toolkit/dist/fp/array/windowed.d.mts b/node_modules/es-toolkit/dist/fp/array/windowed.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..927d140129c5a2a3b49a741879b86bc68b2c30b3 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/windowed.d.mts @@ -0,0 +1,25 @@ +import { WindowedOptions } from "../../array/windowed.mjs"; + +//#region src/fp/array/windowed.d.ts +/** + * Creates a function that returns sliding windows from an array. + * + * By default only full windows are returned. Pass partialWindows: true to include shorter + * trailing windows. The full-window form is lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param size - The size of each window. Must be a positive integer. + * @param step - The step between window starts. Defaults to 1. + * @param options - Window options. + * @returns A function that maps a readonly array to sliding windows. + * @throws {Error} When size or step is not a positive integer. + * + * @example + * import { pipe, windowed } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], windowed(2)); + * // => [[1, 2], [2, 3], [3, 4]] + */ +declare function windowed(size: number, step?: number, options?: WindowedOptions): (array: readonly T[]) => T[][]; +//#endregion +export { windowed }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/windowed.d.ts b/node_modules/es-toolkit/dist/fp/array/windowed.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d835f3b6d67ed8e1c5b1c2b5c4411ea89fbfcb97 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/windowed.d.ts @@ -0,0 +1,25 @@ +import { WindowedOptions } from "../../array/windowed.js"; + +//#region src/fp/array/windowed.d.ts +/** + * Creates a function that returns sliding windows from an array. + * + * By default only full windows are returned. Pass partialWindows: true to include shorter + * trailing windows. The full-window form is lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param size - The size of each window. Must be a positive integer. + * @param step - The step between window starts. Defaults to 1. + * @param options - Window options. + * @returns A function that maps a readonly array to sliding windows. + * @throws {Error} When size or step is not a positive integer. + * + * @example + * import { pipe, windowed } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 4], windowed(2)); + * // => [[1, 2], [2, 3], [3, 4]] + */ +declare function windowed(size: number, step?: number, options?: WindowedOptions): (array: readonly T[]) => T[][]; +//#endregion +export { windowed }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/windowed.js b/node_modules/es-toolkit/dist/fp/array/windowed.js new file mode 100644 index 0000000000000000000000000000000000000000..5087f10cc4df3c187847b564f911aff257bb1e55 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/windowed.js @@ -0,0 +1,50 @@ +const require_windowed = require("../../array/windowed.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/windowed.ts +/** +* Creates a function that returns sliding windows from an array. +* +* By default only full windows are returned. Pass partialWindows: true to include shorter +* trailing windows. The full-window form is lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param size - The size of each window. Must be a positive integer. +* @param step - The step between window starts. Defaults to 1. +* @param options - Window options. +* @returns A function that maps a readonly array to sliding windows. +* @throws {Error} When size or step is not a positive integer. +* +* @example +* import { pipe, windowed } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], windowed(2)); +* // => [[1, 2], [2, 3], [3, 4]] +*/ +function windowed(size, step, options) { + const resolvedStep = step ?? 1; + const partialWindows = options?.partialWindows ?? false; + function windowedEager(array) { + return require_windowed.windowed(array, size, step, options); + } + if (partialWindows || !Number.isInteger(size) || size <= 0 || !Number.isInteger(resolvedStep) || resolvedStep <= 0) return windowedEager; + const windowedLazy = (emit) => { + const buffer = []; + let index = 0; + return (value) => { + buffer.push(value); + if (buffer.length > size) buffer.shift(); + if (buffer.length === size) { + if ((index - size + 1) % resolvedStep === 0) { + const shouldContinue = emit(buffer.slice()); + index++; + return shouldContinue; + } + } + index++; + return true; + }; + }; + return require_lazy.combineEagerAndLazyFunctions(windowedEager, windowedLazy); +} +//#endregion +exports.windowed = windowed; diff --git a/node_modules/es-toolkit/dist/fp/array/windowed.mjs b/node_modules/es-toolkit/dist/fp/array/windowed.mjs new file mode 100644 index 0000000000000000000000000000000000000000..13bc9ee82f70d657f488eece812ffeb29daae751 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/windowed.mjs @@ -0,0 +1,50 @@ +import { windowed as windowed$1 } from "../../array/windowed.mjs"; +import { combineEagerAndLazyFunctions } from "../_internal/lazy.mjs"; +//#region src/fp/array/windowed.ts +/** +* Creates a function that returns sliding windows from an array. +* +* By default only full windows are returned. Pass partialWindows: true to include shorter +* trailing windows. The full-window form is lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param size - The size of each window. Must be a positive integer. +* @param step - The step between window starts. Defaults to 1. +* @param options - Window options. +* @returns A function that maps a readonly array to sliding windows. +* @throws {Error} When size or step is not a positive integer. +* +* @example +* import { pipe, windowed } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 4], windowed(2)); +* // => [[1, 2], [2, 3], [3, 4]] +*/ +function windowed(size, step, options) { + const resolvedStep = step ?? 1; + const partialWindows = options?.partialWindows ?? false; + function windowedEager(array) { + return windowed$1(array, size, step, options); + } + if (partialWindows || !Number.isInteger(size) || size <= 0 || !Number.isInteger(resolvedStep) || resolvedStep <= 0) return windowedEager; + const windowedLazy = (emit) => { + const buffer = []; + let index = 0; + return (value) => { + buffer.push(value); + if (buffer.length > size) buffer.shift(); + if (buffer.length === size) { + if ((index - size + 1) % resolvedStep === 0) { + const shouldContinue = emit(buffer.slice()); + index++; + return shouldContinue; + } + } + index++; + return true; + }; + }; + return combineEagerAndLazyFunctions(windowedEager, windowedLazy); +} +//#endregion +export { windowed }; diff --git a/node_modules/es-toolkit/dist/fp/array/without.d.mts b/node_modules/es-toolkit/dist/fp/array/without.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d27dcc53823fa7edf97897e6b45e6850aa7d4522 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/without.d.mts @@ -0,0 +1,19 @@ +//#region src/fp/array/without.d.ts +/** + * Creates a function that removes the configured values from an array. + * + * The returned function is lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param values - Values to remove from the piped array. + * @returns A function that maps the piped array to the remaining values. + * + * @example + * import { pipe, without } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 2], without(2)); + * // => [1, 3] + */ +declare function without(...values: T[]): (array: readonly T[]) => T[]; +//#endregion +export { without }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/without.d.ts b/node_modules/es-toolkit/dist/fp/array/without.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d27dcc53823fa7edf97897e6b45e6850aa7d4522 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/without.d.ts @@ -0,0 +1,19 @@ +//#region src/fp/array/without.d.ts +/** + * Creates a function that removes the configured values from an array. + * + * The returned function is lazy-capable inside {@link pipe}. + * + * @template T - The type of elements in the array. + * @param values - Values to remove from the piped array. + * @returns A function that maps the piped array to the remaining values. + * + * @example + * import { pipe, without } from 'es-toolkit/fp'; + * + * pipe([1, 2, 3, 2], without(2)); + * // => [1, 3] + */ +declare function without(...values: T[]): (array: readonly T[]) => T[]; +//#endregion +export { without }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/without.js b/node_modules/es-toolkit/dist/fp/array/without.js new file mode 100644 index 0000000000000000000000000000000000000000..244d6cf4b70b32238bf4a3adbe367ad468678038 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/without.js @@ -0,0 +1,30 @@ +const require_without = require("../../array/without.js"); +const require_lazy = require("../_internal/lazy.js"); +//#region src/fp/array/without.ts +/** +* Creates a function that removes the configured values from an array. +* +* The returned function is lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param values - Values to remove from the piped array. +* @returns A function that maps the piped array to the remaining values. +* +* @example +* import { pipe, without } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 2], without(2)); +* // => [1, 3] +*/ +function without(...values) { + const valueSet = new Set(values); + function withoutEager(array) { + return require_without.without(array, ...values); + } + const withoutLazy = require_lazy.createLazyFunction((value, _index, emit) => { + if (!valueSet.has(value)) emit(value); + }); + return require_lazy.combineEagerAndLazyFunctions(withoutEager, withoutLazy); +} +//#endregion +exports.without = without; diff --git a/node_modules/es-toolkit/dist/fp/array/without.mjs b/node_modules/es-toolkit/dist/fp/array/without.mjs new file mode 100644 index 0000000000000000000000000000000000000000..de4af4c73ae4734d0dc406495b61799a56291f6b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/without.mjs @@ -0,0 +1,29 @@ +import { without as without$1 } from "../../array/without.mjs"; +import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; +//#region src/fp/array/without.ts +/** +* Creates a function that removes the configured values from an array. +* +* The returned function is lazy-capable inside {@link pipe}. +* +* @template T - The type of elements in the array. +* @param values - Values to remove from the piped array. +* @returns A function that maps the piped array to the remaining values. +* +* @example +* import { pipe, without } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3, 2], without(2)); +* // => [1, 3] +*/ +function without(...values) { + const valueSet = new Set(values); + function withoutEager(array) { + return without$1(array, ...values); + } + return combineEagerAndLazyFunctions(withoutEager, createLazyFunction((value, _index, emit) => { + if (!valueSet.has(value)) emit(value); + })); +} +//#endregion +export { without }; diff --git a/node_modules/es-toolkit/dist/fp/array/xor.d.mts b/node_modules/es-toolkit/dist/fp/array/xor.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..12d7dc7704453a6edb15595856c22a67ebce33a3 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xor.d.mts @@ -0,0 +1,20 @@ +//#region src/fp/array/xor.d.ts +/** + * Creates a function that returns the symmetric difference with secondArray. + * + * The result contains values that appear in exactly one of the arrays, matching the main + * {@link xor} behavior. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to compare with the piped array. + * @returns A function that maps a readonly array to its symmetric difference. + * + * @example + * import { pipe, xor } from 'es-toolkit/fp'; + * + * pipe([1, 2], xor([2, 3])); + * // => [1, 3] + */ +declare function xor(secondArray: readonly T[]): (array: readonly T[]) => T[]; +//#endregion +export { xor }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/xor.d.ts b/node_modules/es-toolkit/dist/fp/array/xor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..12d7dc7704453a6edb15595856c22a67ebce33a3 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xor.d.ts @@ -0,0 +1,20 @@ +//#region src/fp/array/xor.d.ts +/** + * Creates a function that returns the symmetric difference with secondArray. + * + * The result contains values that appear in exactly one of the arrays, matching the main + * {@link xor} behavior. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to compare with the piped array. + * @returns A function that maps a readonly array to its symmetric difference. + * + * @example + * import { pipe, xor } from 'es-toolkit/fp'; + * + * pipe([1, 2], xor([2, 3])); + * // => [1, 3] + */ +declare function xor(secondArray: readonly T[]): (array: readonly T[]) => T[]; +//#endregion +export { xor }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/xor.js b/node_modules/es-toolkit/dist/fp/array/xor.js new file mode 100644 index 0000000000000000000000000000000000000000..8ee37bb4d2cee962c607d57682bdcd047aa0cfa3 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xor.js @@ -0,0 +1,25 @@ +const require_xor = require("../../array/xor.js"); +//#region src/fp/array/xor.ts +/** +* Creates a function that returns the symmetric difference with secondArray. +* +* The result contains values that appear in exactly one of the arrays, matching the main +* {@link xor} behavior. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to compare with the piped array. +* @returns A function that maps a readonly array to its symmetric difference. +* +* @example +* import { pipe, xor } from 'es-toolkit/fp'; +* +* pipe([1, 2], xor([2, 3])); +* // => [1, 3] +*/ +function xor(secondArray) { + return function(array) { + return require_xor.xor(array, secondArray); + }; +} +//#endregion +exports.xor = xor; diff --git a/node_modules/es-toolkit/dist/fp/array/xor.mjs b/node_modules/es-toolkit/dist/fp/array/xor.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b0466b3b3608bc08ebb3f4c1f332599dde364d82 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xor.mjs @@ -0,0 +1,25 @@ +import { xor as xor$1 } from "../../array/xor.mjs"; +//#region src/fp/array/xor.ts +/** +* Creates a function that returns the symmetric difference with secondArray. +* +* The result contains values that appear in exactly one of the arrays, matching the main +* {@link xor} behavior. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to compare with the piped array. +* @returns A function that maps a readonly array to its symmetric difference. +* +* @example +* import { pipe, xor } from 'es-toolkit/fp'; +* +* pipe([1, 2], xor([2, 3])); +* // => [1, 3] +*/ +function xor(secondArray) { + return function(array) { + return xor$1(array, secondArray); + }; +} +//#endregion +export { xor }; diff --git a/node_modules/es-toolkit/dist/fp/array/xorBy.d.mts b/node_modules/es-toolkit/dist/fp/array/xorBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..25e9c981f6d5706f3815aa91f1e1bb772e5c55e9 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xorBy.d.mts @@ -0,0 +1,22 @@ +//#region src/fp/array/xorBy.d.ts +/** + * Creates a function that returns the symmetric difference by mapped identity. + * + * The mapper is used to decide which values appear in exactly one array, matching the main + * {@link xorBy} behavior. + * + * @template T - The type of elements in the arrays. + * @template U - The type of comparison keys returned by the mapper. + * @param secondArray - Values to compare with the piped array. + * @param mapper - Called for values from both arrays to produce comparison keys. + * @returns A function that maps a readonly array to its symmetric difference. + * + * @example + * import { pipe, xorBy } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], xorBy([{ id: 2 }, { id: 3 }], item => item.id)); + * // => [{ id: 1 }, { id: 3 }] + */ +declare function xorBy(secondArray: readonly T[], mapper: (item: T) => U): (array: readonly T[]) => T[]; +//#endregion +export { xorBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/xorBy.d.ts b/node_modules/es-toolkit/dist/fp/array/xorBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..25e9c981f6d5706f3815aa91f1e1bb772e5c55e9 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xorBy.d.ts @@ -0,0 +1,22 @@ +//#region src/fp/array/xorBy.d.ts +/** + * Creates a function that returns the symmetric difference by mapped identity. + * + * The mapper is used to decide which values appear in exactly one array, matching the main + * {@link xorBy} behavior. + * + * @template T - The type of elements in the arrays. + * @template U - The type of comparison keys returned by the mapper. + * @param secondArray - Values to compare with the piped array. + * @param mapper - Called for values from both arrays to produce comparison keys. + * @returns A function that maps a readonly array to its symmetric difference. + * + * @example + * import { pipe, xorBy } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], xorBy([{ id: 2 }, { id: 3 }], item => item.id)); + * // => [{ id: 1 }, { id: 3 }] + */ +declare function xorBy(secondArray: readonly T[], mapper: (item: T) => U): (array: readonly T[]) => T[]; +//#endregion +export { xorBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/xorBy.js b/node_modules/es-toolkit/dist/fp/array/xorBy.js new file mode 100644 index 0000000000000000000000000000000000000000..08462a2a01c308301707ecb07bfe1304a3ab3010 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xorBy.js @@ -0,0 +1,27 @@ +const require_xorBy = require("../../array/xorBy.js"); +//#region src/fp/array/xorBy.ts +/** +* Creates a function that returns the symmetric difference by mapped identity. +* +* The mapper is used to decide which values appear in exactly one array, matching the main +* {@link xorBy} behavior. +* +* @template T - The type of elements in the arrays. +* @template U - The type of comparison keys returned by the mapper. +* @param secondArray - Values to compare with the piped array. +* @param mapper - Called for values from both arrays to produce comparison keys. +* @returns A function that maps a readonly array to its symmetric difference. +* +* @example +* import { pipe, xorBy } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], xorBy([{ id: 2 }, { id: 3 }], item => item.id)); +* // => [{ id: 1 }, { id: 3 }] +*/ +function xorBy(secondArray, mapper) { + return function(array) { + return require_xorBy.xorBy(array, secondArray, mapper); + }; +} +//#endregion +exports.xorBy = xorBy; diff --git a/node_modules/es-toolkit/dist/fp/array/xorBy.mjs b/node_modules/es-toolkit/dist/fp/array/xorBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fcbcf81ce680ce69f9778721633328784be36781 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xorBy.mjs @@ -0,0 +1,27 @@ +import { xorBy as xorBy$1 } from "../../array/xorBy.mjs"; +//#region src/fp/array/xorBy.ts +/** +* Creates a function that returns the symmetric difference by mapped identity. +* +* The mapper is used to decide which values appear in exactly one array, matching the main +* {@link xorBy} behavior. +* +* @template T - The type of elements in the arrays. +* @template U - The type of comparison keys returned by the mapper. +* @param secondArray - Values to compare with the piped array. +* @param mapper - Called for values from both arrays to produce comparison keys. +* @returns A function that maps a readonly array to its symmetric difference. +* +* @example +* import { pipe, xorBy } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], xorBy([{ id: 2 }, { id: 3 }], item => item.id)); +* // => [{ id: 1 }, { id: 3 }] +*/ +function xorBy(secondArray, mapper) { + return function(array) { + return xorBy$1(array, secondArray, mapper); + }; +} +//#endregion +export { xorBy }; diff --git a/node_modules/es-toolkit/dist/fp/array/xorWith.d.mts b/node_modules/es-toolkit/dist/fp/array/xorWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2bbfe5c47d1d008b38f1992e1075bbb55e4cedee --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xorWith.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/xorWith.d.ts +/** + * Creates a function that returns the symmetric difference using a custom equality function. + * + * The equality function decides whether two values represent the same item, matching the + * main {@link xorWith} behavior. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to compare with the piped array. + * @param areItemsEqual - Returns true when two values are equal. + * @returns A function that maps a readonly array to its symmetric difference. + * + * @example + * import { pipe, xorWith } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], xorWith([{ id: 2 }, { id: 3 }], (a, b) => a.id === b.id)); + * // => [{ id: 1 }, { id: 3 }] + */ +declare function xorWith(secondArray: readonly T[], areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { xorWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/xorWith.d.ts b/node_modules/es-toolkit/dist/fp/array/xorWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2bbfe5c47d1d008b38f1992e1075bbb55e4cedee --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xorWith.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/xorWith.d.ts +/** + * Creates a function that returns the symmetric difference using a custom equality function. + * + * The equality function decides whether two values represent the same item, matching the + * main {@link xorWith} behavior. + * + * @template T - The type of elements in the arrays. + * @param secondArray - Values to compare with the piped array. + * @param areItemsEqual - Returns true when two values are equal. + * @returns A function that maps a readonly array to its symmetric difference. + * + * @example + * import { pipe, xorWith } from 'es-toolkit/fp'; + * + * pipe([{ id: 1 }, { id: 2 }], xorWith([{ id: 2 }, { id: 3 }], (a, b) => a.id === b.id)); + * // => [{ id: 1 }, { id: 3 }] + */ +declare function xorWith(secondArray: readonly T[], areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => T[]; +//#endregion +export { xorWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/xorWith.js b/node_modules/es-toolkit/dist/fp/array/xorWith.js new file mode 100644 index 0000000000000000000000000000000000000000..6a22c57e4bfadf7c5ad452854a7a4b83e864cf90 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xorWith.js @@ -0,0 +1,26 @@ +const require_xorWith = require("../../array/xorWith.js"); +//#region src/fp/array/xorWith.ts +/** +* Creates a function that returns the symmetric difference using a custom equality function. +* +* The equality function decides whether two values represent the same item, matching the +* main {@link xorWith} behavior. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to compare with the piped array. +* @param areItemsEqual - Returns true when two values are equal. +* @returns A function that maps a readonly array to its symmetric difference. +* +* @example +* import { pipe, xorWith } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], xorWith([{ id: 2 }, { id: 3 }], (a, b) => a.id === b.id)); +* // => [{ id: 1 }, { id: 3 }] +*/ +function xorWith(secondArray, areItemsEqual) { + return function(array) { + return require_xorWith.xorWith(array, secondArray, areItemsEqual); + }; +} +//#endregion +exports.xorWith = xorWith; diff --git a/node_modules/es-toolkit/dist/fp/array/xorWith.mjs b/node_modules/es-toolkit/dist/fp/array/xorWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..725b654709913675c4f85de8325acc667208354a --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/xorWith.mjs @@ -0,0 +1,26 @@ +import { xorWith as xorWith$1 } from "../../array/xorWith.mjs"; +//#region src/fp/array/xorWith.ts +/** +* Creates a function that returns the symmetric difference using a custom equality function. +* +* The equality function decides whether two values represent the same item, matching the +* main {@link xorWith} behavior. +* +* @template T - The type of elements in the arrays. +* @param secondArray - Values to compare with the piped array. +* @param areItemsEqual - Returns true when two values are equal. +* @returns A function that maps a readonly array to its symmetric difference. +* +* @example +* import { pipe, xorWith } from 'es-toolkit/fp'; +* +* pipe([{ id: 1 }, { id: 2 }], xorWith([{ id: 2 }, { id: 3 }], (a, b) => a.id === b.id)); +* // => [{ id: 1 }, { id: 3 }] +*/ +function xorWith(secondArray, areItemsEqual) { + return function(array) { + return xorWith$1(array, secondArray, areItemsEqual); + }; +} +//#endregion +export { xorWith }; diff --git a/node_modules/es-toolkit/dist/fp/array/zip.d.mts b/node_modules/es-toolkit/dist/fp/array/zip.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0a745d861320dba05d2f55fbeeab35c10cd9d963 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zip.d.mts @@ -0,0 +1,61 @@ +//#region src/fp/array/zip.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 tuples. + * + * @example + * import { pipe, zip } from 'es-toolkit/fp'; + * + * pipe([1, 2], zip()); + * // => [[1], [2]] + */ +declare function zip(): (array: readonly T[]) => Array<[T]>; +/** + * Creates a function that zips the piped array with 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 to zip. + * @returns A function that maps the piped array to two-item tuples. + * + * @example + * pipe([1, 2], zip(['a', 'b'])); + * // => [[1, 'a'], [2, 'b']] + */ +declare function zip(arr2: readonly U[]): (array: readonly T[]) => Array<[T, U]>; +/** + * Creates a function that zips the piped array with 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 to zip. + * @param arr3 - The third array to zip. + * @returns A function that maps the piped array to three-item tuples. + */ +declare function zip(arr2: readonly U[], arr3: readonly V[]): (array: readonly T[]) => Array<[T, U, V]>; +/** + * Creates a function that zips the piped array with 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 to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @returns A function that maps the piped array to four-item tuples. + */ +declare function zip(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): (array: readonly T[]) => Array<[T, U, V, W]>; +/** + * Creates a function that zips the piped array with any number of configured arrays. + * + * @template T - The shared element type of the arrays. + * @param arrs - Additional arrays to zip. + * @returns A function that maps the piped array to grouped rows. + */ +declare function zip(...arrs: Array): (array: readonly T[]) => T[][]; +//#endregion +export { zip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/zip.d.ts b/node_modules/es-toolkit/dist/fp/array/zip.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a745d861320dba05d2f55fbeeab35c10cd9d963 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zip.d.ts @@ -0,0 +1,61 @@ +//#region src/fp/array/zip.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 tuples. + * + * @example + * import { pipe, zip } from 'es-toolkit/fp'; + * + * pipe([1, 2], zip()); + * // => [[1], [2]] + */ +declare function zip(): (array: readonly T[]) => Array<[T]>; +/** + * Creates a function that zips the piped array with 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 to zip. + * @returns A function that maps the piped array to two-item tuples. + * + * @example + * pipe([1, 2], zip(['a', 'b'])); + * // => [[1, 'a'], [2, 'b']] + */ +declare function zip(arr2: readonly U[]): (array: readonly T[]) => Array<[T, U]>; +/** + * Creates a function that zips the piped array with 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 to zip. + * @param arr3 - The third array to zip. + * @returns A function that maps the piped array to three-item tuples. + */ +declare function zip(arr2: readonly U[], arr3: readonly V[]): (array: readonly T[]) => Array<[T, U, V]>; +/** + * Creates a function that zips the piped array with 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 to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @returns A function that maps the piped array to four-item tuples. + */ +declare function zip(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): (array: readonly T[]) => Array<[T, U, V, W]>; +/** + * Creates a function that zips the piped array with any number of configured arrays. + * + * @template T - The shared element type of the arrays. + * @param arrs - Additional arrays to zip. + * @returns A function that maps the piped array to grouped rows. + */ +declare function zip(...arrs: Array): (array: readonly T[]) => T[][]; +//#endregion +export { zip }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/zip.js b/node_modules/es-toolkit/dist/fp/array/zip.js new file mode 100644 index 0000000000000000000000000000000000000000..423c7cdde693111cf1d3973bb370598829fe6059 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zip.js @@ -0,0 +1,9 @@ +const require_zip = require("../../array/zip.js"); +//#region src/fp/array/zip.ts +function zip(...arrs) { + return function(array) { + return require_zip.zip(array, ...arrs); + }; +} +//#endregion +exports.zip = zip; diff --git a/node_modules/es-toolkit/dist/fp/array/zip.mjs b/node_modules/es-toolkit/dist/fp/array/zip.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d6b801d15a005eebabed767ab24e15db368fd353 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zip.mjs @@ -0,0 +1,9 @@ +import { zip as zip$1 } from "../../array/zip.mjs"; +//#region src/fp/array/zip.ts +function zip(...arrs) { + return function(array) { + return zip$1(array, ...arrs); + }; +} +//#endregion +export { zip }; diff --git a/node_modules/es-toolkit/dist/fp/array/zipObject.d.mts b/node_modules/es-toolkit/dist/fp/array/zipObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..97dd334e37e1f9dc5441dc118e8007a0ae708a13 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zipObject.d.mts @@ -0,0 +1,21 @@ +//#region src/fp/array/zipObject.d.ts +/** + * Creates a function that builds an object from the piped keys and configured values. + * + * Keys are read from the piped array and paired with values by index, matching the main + * {@link zipObject} behavior. + * + * @template P - The property-key type from the piped keys. + * @template V - The type of configured values. + * @param values - Values assigned to the piped keys by index. + * @returns A function that maps keys to an object. + * + * @example + * import { pipe, zipObject } from 'es-toolkit/fp'; + * + * pipe(['a', 'b'] as const, zipObject([1, 2])); + * // => { a: 1, b: 2 } + */ +declare function zipObject

(values: readonly V[]): (keys: readonly P[]) => Record; +//#endregion +export { zipObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/zipObject.d.ts b/node_modules/es-toolkit/dist/fp/array/zipObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..97dd334e37e1f9dc5441dc118e8007a0ae708a13 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zipObject.d.ts @@ -0,0 +1,21 @@ +//#region src/fp/array/zipObject.d.ts +/** + * Creates a function that builds an object from the piped keys and configured values. + * + * Keys are read from the piped array and paired with values by index, matching the main + * {@link zipObject} behavior. + * + * @template P - The property-key type from the piped keys. + * @template V - The type of configured values. + * @param values - Values assigned to the piped keys by index. + * @returns A function that maps keys to an object. + * + * @example + * import { pipe, zipObject } from 'es-toolkit/fp'; + * + * pipe(['a', 'b'] as const, zipObject([1, 2])); + * // => { a: 1, b: 2 } + */ +declare function zipObject

(values: readonly V[]): (keys: readonly P[]) => Record; +//#endregion +export { zipObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/zipObject.js b/node_modules/es-toolkit/dist/fp/array/zipObject.js new file mode 100644 index 0000000000000000000000000000000000000000..5aa81e454a1e1722d74243287e125a06f37bccd1 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zipObject.js @@ -0,0 +1,26 @@ +const require_zipObject = require("../../array/zipObject.js"); +//#region src/fp/array/zipObject.ts +/** +* Creates a function that builds an object from the piped keys and configured values. +* +* Keys are read from the piped array and paired with values by index, matching the main +* {@link zipObject} behavior. +* +* @template P - The property-key type from the piped keys. +* @template V - The type of configured values. +* @param values - Values assigned to the piped keys by index. +* @returns A function that maps keys to an object. +* +* @example +* import { pipe, zipObject } from 'es-toolkit/fp'; +* +* pipe(['a', 'b'] as const, zipObject([1, 2])); +* // => { a: 1, b: 2 } +*/ +function zipObject(values) { + return function(keys) { + return require_zipObject.zipObject(keys, values); + }; +} +//#endregion +exports.zipObject = zipObject; diff --git a/node_modules/es-toolkit/dist/fp/array/zipObject.mjs b/node_modules/es-toolkit/dist/fp/array/zipObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e8a5a21abab77d15585b9b66d78944f4a43fa16d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zipObject.mjs @@ -0,0 +1,26 @@ +import { zipObject as zipObject$1 } from "../../array/zipObject.mjs"; +//#region src/fp/array/zipObject.ts +/** +* Creates a function that builds an object from the piped keys and configured values. +* +* Keys are read from the piped array and paired with values by index, matching the main +* {@link zipObject} behavior. +* +* @template P - The property-key type from the piped keys. +* @template V - The type of configured values. +* @param values - Values assigned to the piped keys by index. +* @returns A function that maps keys to an object. +* +* @example +* import { pipe, zipObject } from 'es-toolkit/fp'; +* +* pipe(['a', 'b'] as const, zipObject([1, 2])); +* // => { a: 1, b: 2 } +*/ +function zipObject(values) { + return function(keys) { + return zipObject$1(keys, values); + }; +} +//#endregion +export { zipObject }; diff --git a/node_modules/es-toolkit/dist/fp/array/zipWith.d.mts b/node_modules/es-toolkit/dist/fp/array/zipWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bb99d84584a4b80368f542544b05da2fa19e0a18 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zipWith.d.mts @@ -0,0 +1,57 @@ +//#region src/fp/array/zipWith.d.ts +/** + * Creates a function that maps each value in the piped array with its index. + * + * @template T - The type of elements in the piped array. + * @template R - The type returned by the combiner. + * @param combine - Called with each value and index. + * @returns A function that maps the piped array to combined values. + * + * @example + * import { pipe, zipWith } from 'es-toolkit/fp'; + * + * pipe([1, 2], zipWith((value, index) => value + index)); + * // => [1, 3] + */ +declare function zipWith(combine: (item: T, index: number) => R): (array: readonly T[]) => R[]; +/** + * Creates a function that zips the piped array with one configured array and combines each group. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the configured array. + * @template R - The type returned by the combiner. + * @param arr2 - The second array to zip. + * @param combine - Called with a value from each array and the index. + * @returns A function that maps the piped array to combined values. + */ +declare function zipWith(arr2: readonly U[], combine: (item1: T, item2: U, index: number) => R): (array: readonly T[]) => R[]; +/** + * Creates a function that zips the piped array with two configured arrays and combines each group. + * + * @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 R - The type returned by the combiner. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param combine - Called with a value from each array and the index. + * @returns A function that maps the piped array to combined values. + */ +declare function zipWith(arr2: readonly U[], arr3: readonly V[], combine: (item1: T, item2: U, item3: V, index: number) => R): (array: readonly T[]) => R[]; +/** + * Creates a function that zips the piped array with three configured arrays and combines each group. + * + * @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. + * @template R - The type returned by the combiner. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param combine - Called with a value from each array and the index. + * @returns A function that maps the piped array to combined values. + */ +declare function zipWith(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[], combine: (item1: T, item2: U, item3: V, item4: W, index: number) => R): (array: readonly T[]) => R[]; +//#endregion +export { zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/zipWith.d.ts b/node_modules/es-toolkit/dist/fp/array/zipWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb99d84584a4b80368f542544b05da2fa19e0a18 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zipWith.d.ts @@ -0,0 +1,57 @@ +//#region src/fp/array/zipWith.d.ts +/** + * Creates a function that maps each value in the piped array with its index. + * + * @template T - The type of elements in the piped array. + * @template R - The type returned by the combiner. + * @param combine - Called with each value and index. + * @returns A function that maps the piped array to combined values. + * + * @example + * import { pipe, zipWith } from 'es-toolkit/fp'; + * + * pipe([1, 2], zipWith((value, index) => value + index)); + * // => [1, 3] + */ +declare function zipWith(combine: (item: T, index: number) => R): (array: readonly T[]) => R[]; +/** + * Creates a function that zips the piped array with one configured array and combines each group. + * + * @template T - The type of elements in the piped array. + * @template U - The type of elements in the configured array. + * @template R - The type returned by the combiner. + * @param arr2 - The second array to zip. + * @param combine - Called with a value from each array and the index. + * @returns A function that maps the piped array to combined values. + */ +declare function zipWith(arr2: readonly U[], combine: (item1: T, item2: U, index: number) => R): (array: readonly T[]) => R[]; +/** + * Creates a function that zips the piped array with two configured arrays and combines each group. + * + * @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 R - The type returned by the combiner. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param combine - Called with a value from each array and the index. + * @returns A function that maps the piped array to combined values. + */ +declare function zipWith(arr2: readonly U[], arr3: readonly V[], combine: (item1: T, item2: U, item3: V, index: number) => R): (array: readonly T[]) => R[]; +/** + * Creates a function that zips the piped array with three configured arrays and combines each group. + * + * @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. + * @template R - The type returned by the combiner. + * @param arr2 - The second array to zip. + * @param arr3 - The third array to zip. + * @param arr4 - The fourth array to zip. + * @param combine - Called with a value from each array and the index. + * @returns A function that maps the piped array to combined values. + */ +declare function zipWith(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[], combine: (item1: T, item2: U, item3: V, item4: W, index: number) => R): (array: readonly T[]) => R[]; +//#endregion +export { zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/array/zipWith.js b/node_modules/es-toolkit/dist/fp/array/zipWith.js new file mode 100644 index 0000000000000000000000000000000000000000..0f47b3cdceaf81cda0ca631f4ad0984974058974 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zipWith.js @@ -0,0 +1,9 @@ +const require_zipWith = require("../../array/zipWith.js"); +//#region src/fp/array/zipWith.ts +function zipWith(...rest) { + return function(array) { + return require_zipWith.zipWith(array, ...rest); + }; +} +//#endregion +exports.zipWith = zipWith; diff --git a/node_modules/es-toolkit/dist/fp/array/zipWith.mjs b/node_modules/es-toolkit/dist/fp/array/zipWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6213ef1bec335cf2dd0440b343ba66b526cba4fa --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/array/zipWith.mjs @@ -0,0 +1,9 @@ +import { zipWith as zipWith$1 } from "../../array/zipWith.mjs"; +//#region src/fp/array/zipWith.ts +function zipWith(...rest) { + return function(array) { + return zipWith$1(array, ...rest); + }; +} +//#endregion +export { zipWith }; diff --git a/node_modules/es-toolkit/dist/fp/flow.d.mts b/node_modules/es-toolkit/dist/fp/flow.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d3f62f03d95c85a2d8083f8384dfb452f82e8f36 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/flow.d.mts @@ -0,0 +1,213 @@ +//#region src/fp/flow.d.ts +/** + * Creates a reusable function from a single function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @returns A function with the same parameters as `fn1` that returns its result. + */ +declare function flow(fn1: (...args: A) => R1): (...args: A) => R1; +/** + * Composes `fn1` and `fn2` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn2`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2): (...args: A) => R2; +/** + * Composes `fn1` through `fn3` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn3`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3): (...args: A) => R3; +/** + * Composes `fn1` through `fn4` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn4`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4): (...args: A) => R4; +/** + * Composes `fn1` through `fn5` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn5`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5): (...args: A) => R5; +/** + * Composes `fn1` through `fn6` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn6`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6): (...args: A) => R6; +/** + * Composes `fn1` through `fn7` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn7`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7): (...args: A) => R7; +/** + * Composes `fn1` through `fn8` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn8`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8): (...args: A) => R8; +/** + * Composes `fn1` through `fn9` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn9`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9): (...args: A) => R9; +/** + * Composes `fn1` through `fn10` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn10`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10): (...args: A) => R10; +/** + * Composes `fn1` through `fn11` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn11`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11): (...args: A) => R11; +/** + * Composes `fn1` through `fn12` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn12`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12): (...args: A) => R12; +/** + * Composes `fn1` through `fn13` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn13`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13): (...args: A) => R13; +/** + * Composes `fn1` through `fn14` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @param fn14 - Applied to the result of `fn13`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn14`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13, fn14: (input: R13) => R14): (...args: A) => R14; +/** + * Composes `fn1` through `fn15` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @param fn14 - Applied to the result of `fn13`. + * @param fn15 - Applied to the result of `fn14`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn15`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13, fn14: (input: R13) => R14, fn15: (input: R14) => R15): (...args: A) => R15; +//#endregion +export { flow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/flow.d.ts b/node_modules/es-toolkit/dist/fp/flow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3f62f03d95c85a2d8083f8384dfb452f82e8f36 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/flow.d.ts @@ -0,0 +1,213 @@ +//#region src/fp/flow.d.ts +/** + * Creates a reusable function from a single function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @returns A function with the same parameters as `fn1` that returns its result. + */ +declare function flow(fn1: (...args: A) => R1): (...args: A) => R1; +/** + * Composes `fn1` and `fn2` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn2`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2): (...args: A) => R2; +/** + * Composes `fn1` through `fn3` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn3`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3): (...args: A) => R3; +/** + * Composes `fn1` through `fn4` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn4`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4): (...args: A) => R4; +/** + * Composes `fn1` through `fn5` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn5`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5): (...args: A) => R5; +/** + * Composes `fn1` through `fn6` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn6`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6): (...args: A) => R6; +/** + * Composes `fn1` through `fn7` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn7`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7): (...args: A) => R7; +/** + * Composes `fn1` through `fn8` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn8`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8): (...args: A) => R8; +/** + * Composes `fn1` through `fn9` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn9`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9): (...args: A) => R9; +/** + * Composes `fn1` through `fn10` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn10`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10): (...args: A) => R10; +/** + * Composes `fn1` through `fn11` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn11`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11): (...args: A) => R11; +/** + * Composes `fn1` through `fn12` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn12`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12): (...args: A) => R12; +/** + * Composes `fn1` through `fn13` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn13`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13): (...args: A) => R13; +/** + * Composes `fn1` through `fn14` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @param fn14 - Applied to the result of `fn13`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn14`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13, fn14: (input: R13) => R14): (...args: A) => R14; +/** + * Composes `fn1` through `fn15` left-to-right into a single reusable function. + * + * @param fn1 - The first function, which may take any number of arguments. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @param fn14 - Applied to the result of `fn13`. + * @param fn15 - Applied to the result of `fn14`. + * @returns A function with the same parameters as `fn1` that returns the result of `fn15`. + */ +declare function flow(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13, fn14: (input: R13) => R14, fn15: (input: R14) => R15): (...args: A) => R15; +//#endregion +export { flow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/flow.js b/node_modules/es-toolkit/dist/fp/flow.js new file mode 100644 index 0000000000000000000000000000000000000000..9ba5c36a29752c6182c1f6fad399529cb7abcf05 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/flow.js @@ -0,0 +1,50 @@ +const require_pipe = require("./pipe.js"); +//#region src/fp/flow.ts +/** +* Performs left-to-right function composition, returning a **reusable function** +* instead of running immediately. The first function may take any number of +* arguments; every later function is unary and receives the previous result. +* +* `flow` is the deferred sibling of {@link pipe}: where `pipe(value, ...fns)` +* threads a concrete value through the functions right away, `flow(...fns)` +* builds a function you can call later (and reuse) with the data. Internally it +* delegates to `pipe`, so lazy-capable functions (`map`, `filter`, `take`, …) +* are fused exactly the same way and benefit from early termination. +* +* @param functions - The functions to compose. The first may be variadic; the +* rest are unary, each receiving the previous function's output. +* @returns A function that, when called, applies every function left-to-right. +* +* @example +* import { flow } from 'es-toolkit/fp'; +* +* const addThenSquare = flow( +* (x: number, y: number) => x + y, +* n => n * n +* ); +* +* addThenSquare(1, 2); // => 9 +* +* @example +* import { flow, map, filter, take } from 'es-toolkit/fp'; +* +* // A reusable lazy pipeline. Only the first two even squares are computed. +* const firstTwoEvenSquares = flow( +* map((x: number) => x * x), +* filter(x => x % 2 === 0), +* take(2) +* ); +* +* firstTwoEvenSquares([1, 2, 3, 4, 5, 6, 7, 8]); // => [4, 16] +*/ +function flow(...functions) { + const run = require_pipe.pipe; + return function(...args) { + if (functions.length === 0) return args[0]; + if (args.length <= 1) return run(args[0], ...functions); + const [first, ...rest] = functions; + return run(first.apply(this, args), ...rest); + }; +} +//#endregion +exports.flow = flow; diff --git a/node_modules/es-toolkit/dist/fp/flow.mjs b/node_modules/es-toolkit/dist/fp/flow.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a54858b45ddb5d37c0a98f2509a248db8afdcd7c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/flow.mjs @@ -0,0 +1,50 @@ +import { pipe } from "./pipe.mjs"; +//#region src/fp/flow.ts +/** +* Performs left-to-right function composition, returning a **reusable function** +* instead of running immediately. The first function may take any number of +* arguments; every later function is unary and receives the previous result. +* +* `flow` is the deferred sibling of {@link pipe}: where `pipe(value, ...fns)` +* threads a concrete value through the functions right away, `flow(...fns)` +* builds a function you can call later (and reuse) with the data. Internally it +* delegates to `pipe`, so lazy-capable functions (`map`, `filter`, `take`, …) +* are fused exactly the same way and benefit from early termination. +* +* @param functions - The functions to compose. The first may be variadic; the +* rest are unary, each receiving the previous function's output. +* @returns A function that, when called, applies every function left-to-right. +* +* @example +* import { flow } from 'es-toolkit/fp'; +* +* const addThenSquare = flow( +* (x: number, y: number) => x + y, +* n => n * n +* ); +* +* addThenSquare(1, 2); // => 9 +* +* @example +* import { flow, map, filter, take } from 'es-toolkit/fp'; +* +* // A reusable lazy pipeline. Only the first two even squares are computed. +* const firstTwoEvenSquares = flow( +* map((x: number) => x * x), +* filter(x => x % 2 === 0), +* take(2) +* ); +* +* firstTwoEvenSquares([1, 2, 3, 4, 5, 6, 7, 8]); // => [4, 16] +*/ +function flow(...functions) { + const run = pipe; + return function(...args) { + if (functions.length === 0) return args[0]; + if (args.length <= 1) return run(args[0], ...functions); + const [first, ...rest] = functions; + return run(first.apply(this, args), ...rest); + }; +} +//#endregion +export { flow }; diff --git a/node_modules/es-toolkit/dist/fp/index.d.mts b/node_modules/es-toolkit/dist/fp/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..638f3938fb41dbe680b24432f979367a1731452b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/index.d.mts @@ -0,0 +1,76 @@ +import { WindowedOptions } from "../array/windowed.mjs"; +import { at } from "./array/at.mjs"; +import { cartesianProduct } from "./array/cartesianProduct.mjs"; +import { chunk } from "./array/chunk.mjs"; +import { chunkBy } from "./array/chunkBy.mjs"; +import { combinations } from "./array/combinations.mjs"; +import { compact } from "./array/compact.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 { 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 { flatMap } from "./array/flatMap.mjs"; +import { flatMapDeep } from "./array/flatMapDeep.mjs"; +import { flatten } from "./array/flatten.mjs"; +import { flattenDeep } from "./array/flattenDeep.mjs"; +import { forEach } from "./array/forEach.mjs"; +import { groupBy } from "./array/groupBy.mjs"; +import { head } from "./array/head.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 { isSubset } from "./array/isSubset.mjs"; +import { isSubsetWith } from "./array/isSubsetWith.mjs"; +import { join } from "./array/join.mjs"; +import { keyBy } from "./array/keyBy.mjs"; +import { last } from "./array/last.mjs"; +import { length } from "./array/length.mjs"; +import { map } from "./array/map.mjs"; +import { maxBy } from "./array/maxBy.mjs"; +import { minBy } from "./array/minBy.mjs"; +import { orderBy } from "./array/orderBy.mjs"; +import { partition } from "./array/partition.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 { sortBy } from "./array/sortBy.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 { toFilled } from "./array/toFilled.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 { windowed } from "./array/windowed.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 { zipWith } from "./array/zipWith.mjs"; +import { flow } from "./flow.mjs"; +import { add } from "./math/add.mjs"; +import { multiply } from "./math/multiply.mjs"; +import { omit } from "./object/omit.mjs"; +import { pick } from "./object/pick.mjs"; +import { pipe } from "./pipe.mjs"; +export { WindowedOptions, add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/index.d.ts b/node_modules/es-toolkit/dist/fp/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4687a6c4915a8ec25c08d2e8cd8a4112da03ec4b --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/index.d.ts @@ -0,0 +1,76 @@ +import { WindowedOptions } from "../array/windowed.js"; +import { at } from "./array/at.js"; +import { cartesianProduct } from "./array/cartesianProduct.js"; +import { chunk } from "./array/chunk.js"; +import { chunkBy } from "./array/chunkBy.js"; +import { combinations } from "./array/combinations.js"; +import { compact } from "./array/compact.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 { 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 { flatMap } from "./array/flatMap.js"; +import { flatMapDeep } from "./array/flatMapDeep.js"; +import { flatten } from "./array/flatten.js"; +import { flattenDeep } from "./array/flattenDeep.js"; +import { forEach } from "./array/forEach.js"; +import { groupBy } from "./array/groupBy.js"; +import { head } from "./array/head.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 { isSubset } from "./array/isSubset.js"; +import { isSubsetWith } from "./array/isSubsetWith.js"; +import { join } from "./array/join.js"; +import { keyBy } from "./array/keyBy.js"; +import { last } from "./array/last.js"; +import { length } from "./array/length.js"; +import { map } from "./array/map.js"; +import { maxBy } from "./array/maxBy.js"; +import { minBy } from "./array/minBy.js"; +import { orderBy } from "./array/orderBy.js"; +import { partition } from "./array/partition.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 { sortBy } from "./array/sortBy.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 { toFilled } from "./array/toFilled.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 { windowed } from "./array/windowed.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 { zipWith } from "./array/zipWith.js"; +import { flow } from "./flow.js"; +import { add } from "./math/add.js"; +import { multiply } from "./math/multiply.js"; +import { omit } from "./object/omit.js"; +import { pick } from "./object/pick.js"; +import { pipe } from "./pipe.js"; +export { WindowedOptions, add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/index.js b/node_modules/es-toolkit/dist/fp/index.js new file mode 100644 index 0000000000000000000000000000000000000000..0eb6b5df14c4090b8c2665c27a9c3b9d3a9e3965 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/index.js @@ -0,0 +1,152 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_at = require("./array/at.js"); +const require_cartesianProduct = require("./array/cartesianProduct.js"); +const require_chunk = require("./array/chunk.js"); +const require_chunkBy = require("./array/chunkBy.js"); +const require_combinations = require("./array/combinations.js"); +const require_compact = require("./array/compact.js"); +const require_countBy = require("./array/countBy.js"); +const require_difference = require("./array/difference.js"); +const require_differenceBy = require("./array/differenceBy.js"); +const require_differenceWith = require("./array/differenceWith.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_filter = require("./array/filter.js"); +const require_find = require("./array/find.js"); +const require_findIndex = require("./array/findIndex.js"); +const require_findLast = require("./array/findLast.js"); +const require_findLastIndex = require("./array/findLastIndex.js"); +const require_flatMap = require("./array/flatMap.js"); +const require_flatMapDeep = require("./array/flatMapDeep.js"); +const require_flatten = require("./array/flatten.js"); +const require_flattenDeep = require("./array/flattenDeep.js"); +const require_forEach = require("./array/forEach.js"); +const require_groupBy = require("./array/groupBy.js"); +const require_head = require("./array/head.js"); +const require_initial = require("./array/initial.js"); +const require_intersection = require("./array/intersection.js"); +const require_intersectionBy = require("./array/intersectionBy.js"); +const require_intersectionWith = require("./array/intersectionWith.js"); +const require_isSubset = require("./array/isSubset.js"); +const require_isSubsetWith = require("./array/isSubsetWith.js"); +const require_join = require("./array/join.js"); +const require_keyBy = require("./array/keyBy.js"); +const require_last = require("./array/last.js"); +const require_length = require("./array/length.js"); +const require_map = require("./array/map.js"); +const require_maxBy = require("./array/maxBy.js"); +const require_minBy = require("./array/minBy.js"); +const require_orderBy = require("./array/orderBy.js"); +const require_partition = require("./array/partition.js"); +const require_reverse = require("./array/reverse.js"); +const require_sample = require("./array/sample.js"); +const require_sampleSize = require("./array/sampleSize.js"); +const require_shuffle = require("./array/shuffle.js"); +const require_sortBy = require("./array/sortBy.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_toFilled = require("./array/toFilled.js"); +const require_union = require("./array/union.js"); +const require_unionBy = require("./array/unionBy.js"); +const require_unionWith = require("./array/unionWith.js"); +const require_uniq = require("./array/uniq.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_windowed = require("./array/windowed.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_zipWith = require("./array/zipWith.js"); +require("./array/index.js"); +const require_pipe = require("./pipe.js"); +const require_flow = require("./flow.js"); +const require_add = require("./math/add.js"); +const require_multiply = require("./math/multiply.js"); +require("./math/index.js"); +const require_omit = require("./object/omit.js"); +const require_pick = require("./object/pick.js"); +require("./object/index.js"); +exports.add = require_add.add; +exports.at = require_at.at; +exports.cartesianProduct = require_cartesianProduct.cartesianProduct; +exports.chunk = require_chunk.chunk; +exports.chunkBy = require_chunkBy.chunkBy; +exports.combinations = require_combinations.combinations; +exports.compact = require_compact.compact; +exports.countBy = require_countBy.countBy; +exports.difference = require_difference.difference; +exports.differenceBy = require_differenceBy.differenceBy; +exports.differenceWith = require_differenceWith.differenceWith; +exports.drop = require_drop.drop; +exports.dropRight = require_dropRight.dropRight; +exports.dropRightWhile = require_dropRightWhile.dropRightWhile; +exports.dropWhile = require_dropWhile.dropWhile; +exports.filter = require_filter.filter; +exports.find = require_find.find; +exports.findIndex = require_findIndex.findIndex; +exports.findLast = require_findLast.findLast; +exports.findLastIndex = require_findLastIndex.findLastIndex; +exports.flatMap = require_flatMap.flatMap; +exports.flatMapDeep = require_flatMapDeep.flatMapDeep; +exports.flatten = require_flatten.flatten; +exports.flattenDeep = require_flattenDeep.flattenDeep; +exports.flow = require_flow.flow; +exports.forEach = require_forEach.forEach; +exports.groupBy = require_groupBy.groupBy; +exports.head = require_head.head; +exports.initial = require_initial.initial; +exports.intersection = require_intersection.intersection; +exports.intersectionBy = require_intersectionBy.intersectionBy; +exports.intersectionWith = require_intersectionWith.intersectionWith; +exports.isSubset = require_isSubset.isSubset; +exports.isSubsetWith = require_isSubsetWith.isSubsetWith; +exports.join = require_join.join; +exports.keyBy = require_keyBy.keyBy; +exports.last = require_last.last; +exports.length = require_length.length; +exports.map = require_map.map; +exports.maxBy = require_maxBy.maxBy; +exports.minBy = require_minBy.minBy; +exports.multiply = require_multiply.multiply; +exports.omit = require_omit.omit; +exports.orderBy = require_orderBy.orderBy; +exports.partition = require_partition.partition; +exports.pick = require_pick.pick; +exports.pipe = require_pipe.pipe; +exports.reverse = require_reverse.reverse; +exports.sample = require_sample.sample; +exports.sampleSize = require_sampleSize.sampleSize; +exports.shuffle = require_shuffle.shuffle; +exports.sortBy = require_sortBy.sortBy; +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.toFilled = require_toFilled.toFilled; +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.unzip = require_unzip.unzip; +exports.unzipWith = require_unzipWith.unzipWith; +exports.windowed = require_windowed.windowed; +exports.without = require_without.without; +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.zipWith = require_zipWith.zipWith; diff --git a/node_modules/es-toolkit/dist/fp/index.mjs b/node_modules/es-toolkit/dist/fp/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ca9311568f0edddec6721d5720b5febf7bf6f16d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/index.mjs @@ -0,0 +1,78 @@ +import { at } from "./array/at.mjs"; +import { cartesianProduct } from "./array/cartesianProduct.mjs"; +import { chunk } from "./array/chunk.mjs"; +import { chunkBy } from "./array/chunkBy.mjs"; +import { combinations } from "./array/combinations.mjs"; +import { compact } from "./array/compact.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 { 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 { flatMap } from "./array/flatMap.mjs"; +import { flatMapDeep } from "./array/flatMapDeep.mjs"; +import { flatten } from "./array/flatten.mjs"; +import { flattenDeep } from "./array/flattenDeep.mjs"; +import { forEach } from "./array/forEach.mjs"; +import { groupBy } from "./array/groupBy.mjs"; +import { head } from "./array/head.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 { isSubset } from "./array/isSubset.mjs"; +import { isSubsetWith } from "./array/isSubsetWith.mjs"; +import { join } from "./array/join.mjs"; +import { keyBy } from "./array/keyBy.mjs"; +import { last } from "./array/last.mjs"; +import { length } from "./array/length.mjs"; +import { map } from "./array/map.mjs"; +import { maxBy } from "./array/maxBy.mjs"; +import { minBy } from "./array/minBy.mjs"; +import { orderBy } from "./array/orderBy.mjs"; +import { partition } from "./array/partition.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 { sortBy } from "./array/sortBy.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 { toFilled } from "./array/toFilled.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 { windowed } from "./array/windowed.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 { zipWith } from "./array/zipWith.mjs"; +import "./array/index.mjs"; +import { pipe } from "./pipe.mjs"; +import { flow } from "./flow.mjs"; +import { add } from "./math/add.mjs"; +import { multiply } from "./math/multiply.mjs"; +import "./math/index.mjs"; +import { omit } from "./object/omit.mjs"; +import { pick } from "./object/pick.mjs"; +import "./object/index.mjs"; +export { add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith }; diff --git a/node_modules/es-toolkit/dist/fp/math/add.d.mts b/node_modules/es-toolkit/dist/fp/math/add.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..313d3b7b25e6237962f204152aa8df395451efb7 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/add.d.mts @@ -0,0 +1,17 @@ +//#region src/fp/math/add.d.ts +/** + * Creates a function that adds `addend` to its input. Use it with {@link pipe}, + * or as the callback of a function such as {@link map}. + * + * @param addend - The number to add to the input. + * @returns A function that maps a `number` to `value + addend`. + * + * @example + * import { pipe, map, add } from 'es-toolkit/fp'; + * + * pipe(3, add(2)); // => 5 + * pipe([1, 2, 3], map(add(10))); // => [11, 12, 13] + */ +declare function add(addend: number): (value: number) => number; +//#endregion +export { add }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/math/add.d.ts b/node_modules/es-toolkit/dist/fp/math/add.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..313d3b7b25e6237962f204152aa8df395451efb7 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/add.d.ts @@ -0,0 +1,17 @@ +//#region src/fp/math/add.d.ts +/** + * Creates a function that adds `addend` to its input. Use it with {@link pipe}, + * or as the callback of a function such as {@link map}. + * + * @param addend - The number to add to the input. + * @returns A function that maps a `number` to `value + addend`. + * + * @example + * import { pipe, map, add } from 'es-toolkit/fp'; + * + * pipe(3, add(2)); // => 5 + * pipe([1, 2, 3], map(add(10))); // => [11, 12, 13] + */ +declare function add(addend: number): (value: number) => number; +//#endregion +export { add }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/math/add.js b/node_modules/es-toolkit/dist/fp/math/add.js new file mode 100644 index 0000000000000000000000000000000000000000..b704cf6d980053c48a25bf8725b3f1ae72f3a3d0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/add.js @@ -0,0 +1,21 @@ +//#region src/fp/math/add.ts +/** +* Creates a function that adds `addend` to its input. Use it with {@link pipe}, +* or as the callback of a function such as {@link map}. +* +* @param addend - The number to add to the input. +* @returns A function that maps a `number` to `value + addend`. +* +* @example +* import { pipe, map, add } from 'es-toolkit/fp'; +* +* pipe(3, add(2)); // => 5 +* pipe([1, 2, 3], map(add(10))); // => [11, 12, 13] +*/ +function add(addend) { + return function(value) { + return value + addend; + }; +} +//#endregion +exports.add = add; diff --git a/node_modules/es-toolkit/dist/fp/math/add.mjs b/node_modules/es-toolkit/dist/fp/math/add.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9fd10cb5e8f7fd6545ed5b528f25bca2b4cac70d --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/add.mjs @@ -0,0 +1,21 @@ +//#region src/fp/math/add.ts +/** +* Creates a function that adds `addend` to its input. Use it with {@link pipe}, +* or as the callback of a function such as {@link map}. +* +* @param addend - The number to add to the input. +* @returns A function that maps a `number` to `value + addend`. +* +* @example +* import { pipe, map, add } from 'es-toolkit/fp'; +* +* pipe(3, add(2)); // => 5 +* pipe([1, 2, 3], map(add(10))); // => [11, 12, 13] +*/ +function add(addend) { + return function(value) { + return value + addend; + }; +} +//#endregion +export { add }; diff --git a/node_modules/es-toolkit/dist/fp/math/index.d.mts b/node_modules/es-toolkit/dist/fp/math/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b6087f4867b0147c1014e25e66c9e06d02abf805 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/index.d.mts @@ -0,0 +1,2 @@ +import { add } from "./add.mjs"; +import { multiply } from "./multiply.mjs"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/math/index.d.ts b/node_modules/es-toolkit/dist/fp/math/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1eca2a25f2f6f413f5a262d391a98113752d0d6c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/index.d.ts @@ -0,0 +1,2 @@ +import { add } from "./add.js"; +import { multiply } from "./multiply.js"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/math/index.js b/node_modules/es-toolkit/dist/fp/math/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9f0ca265dc290b20522e2447c0aae5f16ce43624 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/index.js @@ -0,0 +1,2 @@ +require("./add.js"); +require("./multiply.js"); diff --git a/node_modules/es-toolkit/dist/fp/math/index.mjs b/node_modules/es-toolkit/dist/fp/math/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..71073a9e03ab63eeb0c6dade8e331ce512adce45 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/index.mjs @@ -0,0 +1,2 @@ +import "./add.mjs"; +import "./multiply.mjs"; diff --git a/node_modules/es-toolkit/dist/fp/math/multiply.d.mts b/node_modules/es-toolkit/dist/fp/math/multiply.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0cf4a7d22525ad1afdcfcf97f65fc72d6e7628c0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/multiply.d.mts @@ -0,0 +1,17 @@ +//#region src/fp/math/multiply.d.ts +/** + * Creates a function that multiplies its input by `multiplicand`. Use it with + * {@link pipe}, or as the callback of a function such as {@link map}. + * + * @param multiplicand - The number to multiply the input by. + * @returns A function that maps a `number` to `value * multiplicand`. + * + * @example + * import { pipe, map, multiply } from 'es-toolkit/fp'; + * + * pipe(3, multiply(2)); // => 6 + * pipe([1, 2, 3], map(multiply(3))); // => [3, 6, 9] + */ +declare function multiply(multiplicand: number): (value: number) => number; +//#endregion +export { multiply }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/math/multiply.d.ts b/node_modules/es-toolkit/dist/fp/math/multiply.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0cf4a7d22525ad1afdcfcf97f65fc72d6e7628c0 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/multiply.d.ts @@ -0,0 +1,17 @@ +//#region src/fp/math/multiply.d.ts +/** + * Creates a function that multiplies its input by `multiplicand`. Use it with + * {@link pipe}, or as the callback of a function such as {@link map}. + * + * @param multiplicand - The number to multiply the input by. + * @returns A function that maps a `number` to `value * multiplicand`. + * + * @example + * import { pipe, map, multiply } from 'es-toolkit/fp'; + * + * pipe(3, multiply(2)); // => 6 + * pipe([1, 2, 3], map(multiply(3))); // => [3, 6, 9] + */ +declare function multiply(multiplicand: number): (value: number) => number; +//#endregion +export { multiply }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/math/multiply.js b/node_modules/es-toolkit/dist/fp/math/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..4f7bac84ca163bd8455d299898ed96ff5099de2f --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/multiply.js @@ -0,0 +1,21 @@ +//#region src/fp/math/multiply.ts +/** +* Creates a function that multiplies its input by `multiplicand`. Use it with +* {@link pipe}, or as the callback of a function such as {@link map}. +* +* @param multiplicand - The number to multiply the input by. +* @returns A function that maps a `number` to `value * multiplicand`. +* +* @example +* import { pipe, map, multiply } from 'es-toolkit/fp'; +* +* pipe(3, multiply(2)); // => 6 +* pipe([1, 2, 3], map(multiply(3))); // => [3, 6, 9] +*/ +function multiply(multiplicand) { + return function(value) { + return value * multiplicand; + }; +} +//#endregion +exports.multiply = multiply; diff --git a/node_modules/es-toolkit/dist/fp/math/multiply.mjs b/node_modules/es-toolkit/dist/fp/math/multiply.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cc80f0feef28956cd8e1c36b9dbcc08cf250e1a2 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/math/multiply.mjs @@ -0,0 +1,21 @@ +//#region src/fp/math/multiply.ts +/** +* Creates a function that multiplies its input by `multiplicand`. Use it with +* {@link pipe}, or as the callback of a function such as {@link map}. +* +* @param multiplicand - The number to multiply the input by. +* @returns A function that maps a `number` to `value * multiplicand`. +* +* @example +* import { pipe, map, multiply } from 'es-toolkit/fp'; +* +* pipe(3, multiply(2)); // => 6 +* pipe([1, 2, 3], map(multiply(3))); // => [3, 6, 9] +*/ +function multiply(multiplicand) { + return function(value) { + return value * multiplicand; + }; +} +//#endregion +export { multiply }; diff --git a/node_modules/es-toolkit/dist/fp/object/index.d.mts b/node_modules/es-toolkit/dist/fp/object/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..98a8732ec393ad52ab7967b798e440196d6bb149 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/index.d.mts @@ -0,0 +1,2 @@ +import { omit } from "./omit.mjs"; +import { pick } from "./pick.mjs"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/object/index.d.ts b/node_modules/es-toolkit/dist/fp/object/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..215f000bc3930fa3f1452fc5c8f742fea70bc272 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/index.d.ts @@ -0,0 +1,2 @@ +import { omit } from "./omit.js"; +import { pick } from "./pick.js"; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/object/index.js b/node_modules/es-toolkit/dist/fp/object/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c51381be1462302f448a5683f94d6a85784dc78c --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/index.js @@ -0,0 +1,2 @@ +require("./omit.js"); +require("./pick.js"); diff --git a/node_modules/es-toolkit/dist/fp/object/index.mjs b/node_modules/es-toolkit/dist/fp/object/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9b2ddf3d63598c8da37d6ed46b7105d622877bd9 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/index.mjs @@ -0,0 +1,2 @@ +import "./omit.mjs"; +import "./pick.mjs"; diff --git a/node_modules/es-toolkit/dist/fp/object/omit.d.mts b/node_modules/es-toolkit/dist/fp/object/omit.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ed27a4f445b2b5338a225e0788b46674d4d7c592 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/omit.d.mts @@ -0,0 +1,18 @@ +//#region src/fp/object/omit.d.ts +/** + * Creates a function that builds a new object with the given `keys` removed from + * the input object. Use it with {@link pipe}. + * + * @template T - The type of the input object. + * @template K - The union of keys to omit. + * @param keys - The keys to exclude from the new object. + * @returns A function that maps an object `T` to `Omit`. + * + * @example + * import { pipe, omit } from 'es-toolkit/fp'; + * + * pipe({ a: 1, b: 2, c: 3 }, omit(['b', 'c'])); // => { a: 1 } + */ +declare function omit, K extends keyof T>(keys: readonly K[]): (obj: T) => Omit; +//#endregion +export { omit }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/object/omit.d.ts b/node_modules/es-toolkit/dist/fp/object/omit.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed27a4f445b2b5338a225e0788b46674d4d7c592 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/omit.d.ts @@ -0,0 +1,18 @@ +//#region src/fp/object/omit.d.ts +/** + * Creates a function that builds a new object with the given `keys` removed from + * the input object. Use it with {@link pipe}. + * + * @template T - The type of the input object. + * @template K - The union of keys to omit. + * @param keys - The keys to exclude from the new object. + * @returns A function that maps an object `T` to `Omit`. + * + * @example + * import { pipe, omit } from 'es-toolkit/fp'; + * + * pipe({ a: 1, b: 2, c: 3 }, omit(['b', 'c'])); // => { a: 1 } + */ +declare function omit, K extends keyof T>(keys: readonly K[]): (obj: T) => Omit; +//#endregion +export { omit }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/object/omit.js b/node_modules/es-toolkit/dist/fp/object/omit.js new file mode 100644 index 0000000000000000000000000000000000000000..1a2a38ad8cb0d06172576e0b03ee6ea12b74dbfc --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/omit.js @@ -0,0 +1,23 @@ +const require_omit = require("../../object/omit.js"); +//#region src/fp/object/omit.ts +/** +* Creates a function that builds a new object with the given `keys` removed from +* the input object. Use it with {@link pipe}. +* +* @template T - The type of the input object. +* @template K - The union of keys to omit. +* @param keys - The keys to exclude from the new object. +* @returns A function that maps an object `T` to `Omit`. +* +* @example +* import { pipe, omit } from 'es-toolkit/fp'; +* +* pipe({ a: 1, b: 2, c: 3 }, omit(['b', 'c'])); // => { a: 1 } +*/ +function omit(keys) { + return function(obj) { + return require_omit.omit(obj, keys); + }; +} +//#endregion +exports.omit = omit; diff --git a/node_modules/es-toolkit/dist/fp/object/omit.mjs b/node_modules/es-toolkit/dist/fp/object/omit.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f4286db783f93bd91003144e59f287620c0e6a78 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/omit.mjs @@ -0,0 +1,23 @@ +import { omit as omit$1 } from "../../object/omit.mjs"; +//#region src/fp/object/omit.ts +/** +* Creates a function that builds a new object with the given `keys` removed from +* the input object. Use it with {@link pipe}. +* +* @template T - The type of the input object. +* @template K - The union of keys to omit. +* @param keys - The keys to exclude from the new object. +* @returns A function that maps an object `T` to `Omit`. +* +* @example +* import { pipe, omit } from 'es-toolkit/fp'; +* +* pipe({ a: 1, b: 2, c: 3 }, omit(['b', 'c'])); // => { a: 1 } +*/ +function omit(keys) { + return function(obj) { + return omit$1(obj, keys); + }; +} +//#endregion +export { omit }; diff --git a/node_modules/es-toolkit/dist/fp/object/pick.d.mts b/node_modules/es-toolkit/dist/fp/object/pick.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f290a65dcd3c6df713eaf1d5e17ea1f5115a4be4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/pick.d.mts @@ -0,0 +1,19 @@ +//#region src/fp/object/pick.d.ts +/** + * Creates a function that builds a new object containing only the given `keys` + * from the input object. Keys that are absent on the input are skipped. Use it + * with {@link pipe}. + * + * @template T - The type of the input object. + * @template K - The union of keys to pick. + * @param keys - The keys to copy into the new object. + * @returns A function that maps an object `T` to `Pick`. + * + * @example + * import { pipe, pick } from 'es-toolkit/fp'; + * + * pipe({ a: 1, b: 2, c: 3 }, pick(['a', 'c'])); // => { a: 1, c: 3 } + */ +declare function pick, K extends keyof T>(keys: readonly K[]): (obj: T) => Pick; +//#endregion +export { pick }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/object/pick.d.ts b/node_modules/es-toolkit/dist/fp/object/pick.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f290a65dcd3c6df713eaf1d5e17ea1f5115a4be4 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/pick.d.ts @@ -0,0 +1,19 @@ +//#region src/fp/object/pick.d.ts +/** + * Creates a function that builds a new object containing only the given `keys` + * from the input object. Keys that are absent on the input are skipped. Use it + * with {@link pipe}. + * + * @template T - The type of the input object. + * @template K - The union of keys to pick. + * @param keys - The keys to copy into the new object. + * @returns A function that maps an object `T` to `Pick`. + * + * @example + * import { pipe, pick } from 'es-toolkit/fp'; + * + * pipe({ a: 1, b: 2, c: 3 }, pick(['a', 'c'])); // => { a: 1, c: 3 } + */ +declare function pick, K extends keyof T>(keys: readonly K[]): (obj: T) => Pick; +//#endregion +export { pick }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/object/pick.js b/node_modules/es-toolkit/dist/fp/object/pick.js new file mode 100644 index 0000000000000000000000000000000000000000..426aa2b5f62e07752ebb49740cf2d757c33ae198 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/pick.js @@ -0,0 +1,24 @@ +const require_pick = require("../../object/pick.js"); +//#region src/fp/object/pick.ts +/** +* Creates a function that builds a new object containing only the given `keys` +* from the input object. Keys that are absent on the input are skipped. Use it +* with {@link pipe}. +* +* @template T - The type of the input object. +* @template K - The union of keys to pick. +* @param keys - The keys to copy into the new object. +* @returns A function that maps an object `T` to `Pick`. +* +* @example +* import { pipe, pick } from 'es-toolkit/fp'; +* +* pipe({ a: 1, b: 2, c: 3 }, pick(['a', 'c'])); // => { a: 1, c: 3 } +*/ +function pick(keys) { + return function(obj) { + return require_pick.pick(obj, keys); + }; +} +//#endregion +exports.pick = pick; diff --git a/node_modules/es-toolkit/dist/fp/object/pick.mjs b/node_modules/es-toolkit/dist/fp/object/pick.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ff7dd3cdb874db22b63c01a586da8892ffd329fb --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/object/pick.mjs @@ -0,0 +1,24 @@ +import { pick as pick$1 } from "../../object/pick.mjs"; +//#region src/fp/object/pick.ts +/** +* Creates a function that builds a new object containing only the given `keys` +* from the input object. Keys that are absent on the input are skipped. Use it +* with {@link pipe}. +* +* @template T - The type of the input object. +* @template K - The union of keys to pick. +* @param keys - The keys to copy into the new object. +* @returns A function that maps an object `T` to `Pick`. +* +* @example +* import { pipe, pick } from 'es-toolkit/fp'; +* +* pipe({ a: 1, b: 2, c: 3 }, pick(['a', 'c'])); // => { a: 1, c: 3 } +*/ +function pick(keys) { + return function(obj) { + return pick$1(obj, keys); + }; +} +//#endregion +export { pick }; diff --git a/node_modules/es-toolkit/dist/fp/pipe.d.mts b/node_modules/es-toolkit/dist/fp/pipe.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ea1af59d29d9e1278fd4d99487123e53dd2474f5 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/pipe.d.mts @@ -0,0 +1,235 @@ +//#region src/fp/pipe.d.ts +/** + * Returns `value` unchanged — the identity case of {@link pipe} with no functions. + * + * @param value - The initial value fed into the pipe. + * @returns `value`, unchanged. + */ +declare function pipe(value: A): A; +/** + * Pipes `value` through `fn1`, returning its result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @returns The result of `fn1`. + */ +declare function pipe(value: A, fn1: (input: A) => B): B; +/** + * Pipes `value` left-to-right through `fn1` to `fn2`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @returns The result of `fn2` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C): C; +/** + * Pipes `value` left-to-right through `fn1` to `fn3`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @returns The result of `fn3` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D): D; +/** + * Pipes `value` left-to-right through `fn1` to `fn4`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @returns The result of `fn4` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E): E; +/** + * Pipes `value` left-to-right through `fn1` to `fn5`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @returns The result of `fn5` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F): F; +/** + * Pipes `value` left-to-right through `fn1` to `fn6`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @returns The result of `fn6` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G): G; +/** + * Pipes `value` left-to-right through `fn1` to `fn7`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @returns The result of `fn7` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H): H; +/** + * Pipes `value` left-to-right through `fn1` to `fn8`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @returns The result of `fn8` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I): I; +/** + * Pipes `value` left-to-right through `fn1` to `fn9`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @returns The result of `fn9` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J): J; +/** + * Pipes `value` left-to-right through `fn1` to `fn10`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @returns The result of `fn10` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K): K; +/** + * Pipes `value` left-to-right through `fn1` to `fn11`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @returns The result of `fn11` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L): L; +/** + * Pipes `value` left-to-right through `fn1` to `fn12`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @returns The result of `fn12` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L, fn12: (input: L) => M): M; +/** + * Pipes `value` left-to-right through `fn1` to `fn13`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @returns The result of `fn13` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L, fn12: (input: L) => M, fn13: (input: M) => N): N; +/** + * Pipes `value` left-to-right through `fn1` to `fn14`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @param fn14 - Applied to the result of `fn13`. + * @returns The result of `fn14` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L, fn12: (input: L) => M, fn13: (input: M) => N, fn14: (input: N) => O): O; +/** + * Pipes `value` left-to-right through `fn1` to `fn15`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @param fn14 - Applied to the result of `fn13`. + * @param fn15 - Applied to the result of `fn14`. + * @returns The result of `fn15` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L, fn12: (input: L) => M, fn13: (input: M) => N, fn14: (input: N) => O, fn15: (input: O) => P): P; +//#endregion +export { pipe }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/pipe.d.ts b/node_modules/es-toolkit/dist/fp/pipe.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea1af59d29d9e1278fd4d99487123e53dd2474f5 --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/pipe.d.ts @@ -0,0 +1,235 @@ +//#region src/fp/pipe.d.ts +/** + * Returns `value` unchanged — the identity case of {@link pipe} with no functions. + * + * @param value - The initial value fed into the pipe. + * @returns `value`, unchanged. + */ +declare function pipe(value: A): A; +/** + * Pipes `value` through `fn1`, returning its result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @returns The result of `fn1`. + */ +declare function pipe(value: A, fn1: (input: A) => B): B; +/** + * Pipes `value` left-to-right through `fn1` to `fn2`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @returns The result of `fn2` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C): C; +/** + * Pipes `value` left-to-right through `fn1` to `fn3`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @returns The result of `fn3` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D): D; +/** + * Pipes `value` left-to-right through `fn1` to `fn4`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @returns The result of `fn4` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E): E; +/** + * Pipes `value` left-to-right through `fn1` to `fn5`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @returns The result of `fn5` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F): F; +/** + * Pipes `value` left-to-right through `fn1` to `fn6`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @returns The result of `fn6` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G): G; +/** + * Pipes `value` left-to-right through `fn1` to `fn7`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @returns The result of `fn7` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H): H; +/** + * Pipes `value` left-to-right through `fn1` to `fn8`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @returns The result of `fn8` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I): I; +/** + * Pipes `value` left-to-right through `fn1` to `fn9`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @returns The result of `fn9` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J): J; +/** + * Pipes `value` left-to-right through `fn1` to `fn10`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @returns The result of `fn10` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K): K; +/** + * Pipes `value` left-to-right through `fn1` to `fn11`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @returns The result of `fn11` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L): L; +/** + * Pipes `value` left-to-right through `fn1` to `fn12`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @returns The result of `fn12` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L, fn12: (input: L) => M): M; +/** + * Pipes `value` left-to-right through `fn1` to `fn13`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @returns The result of `fn13` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L, fn12: (input: L) => M, fn13: (input: M) => N): N; +/** + * Pipes `value` left-to-right through `fn1` to `fn14`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @param fn14 - Applied to the result of `fn13`. + * @returns The result of `fn14` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L, fn12: (input: L) => M, fn13: (input: M) => N, fn14: (input: N) => O): O; +/** + * Pipes `value` left-to-right through `fn1` to `fn15`, returning the final result. + * + * @param value - The initial value fed into the pipe. + * @param fn1 - Applied to `value`. + * @param fn2 - Applied to the result of `fn1`. + * @param fn3 - Applied to the result of `fn2`. + * @param fn4 - Applied to the result of `fn3`. + * @param fn5 - Applied to the result of `fn4`. + * @param fn6 - Applied to the result of `fn5`. + * @param fn7 - Applied to the result of `fn6`. + * @param fn8 - Applied to the result of `fn7`. + * @param fn9 - Applied to the result of `fn8`. + * @param fn10 - Applied to the result of `fn9`. + * @param fn11 - Applied to the result of `fn10`. + * @param fn12 - Applied to the result of `fn11`. + * @param fn13 - Applied to the result of `fn12`. + * @param fn14 - Applied to the result of `fn13`. + * @param fn15 - Applied to the result of `fn14`. + * @returns The result of `fn15` — the value returned by the last function. + */ +declare function pipe(value: A, fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K, fn11: (input: K) => L, fn12: (input: L) => M, fn13: (input: M) => N, fn14: (input: N) => O, fn15: (input: O) => P): P; +//#endregion +export { pipe }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/fp/pipe.js b/node_modules/es-toolkit/dist/fp/pipe.js new file mode 100644 index 0000000000000000000000000000000000000000..44d8768879c13cfa0132d7ba4110a6ed58a710bc --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/pipe.js @@ -0,0 +1,112 @@ +//#region src/fp/pipe.ts +/** +* Performs left-to-right function composition, threading `value` through each +* function in sequence. Every function receives the output of the previous +* one, so the data flows top-to-bottom in the same order it is read. This +* turns deeply nested calls into clear, sequential steps without temporary +* variables. +* +* This is the entry point of `es-toolkit/fp`. Each `es-toolkit/fp` function is +* called with its configuration (e.g. `map(fn)`, `take(2)`) and returns a +* function that takes the data, which `pipe` then supplies. +* +* When consecutive **lazy-capable** functions (`map`, `filter`, `take`, ...) +* appear together, `pipe` fuses them and processes the input element-by-element +* instead of building an intermediate array after every step. This allows +* early termination: a trailing `take(n)` stops the walk as soon as `n` +* results exist, so the remaining input is never visited. +* +* @param value - The initial value fed into the pipe. +* @param functions - Data-last operators (or any unary functions) applied in order. +* @returns The result of applying every function, left to right. +* +* @example +* import { pipe, map, filter, take } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], map(x => x * 3)); // => [3, 6, 9] +* +* @example +* // Lazy evaluation with early termination: only the first two even squares +* // are ever computed, the rest of the array is never touched. +* pipe( +* [1, 2, 3, 4, 5, 6, 7, 8], +* map(x => x * x), +* filter(x => x % 2 === 0), +* take(2) +* ); // => [4, 16] +* +* @example +* // Any unary function works inside a pipe, not just es-toolkit operators. +* pipe( +* ' Hello ', +* s => s.trim(), +* s => s.toLowerCase() +* ); // => 'hello' +*/ +function pipe(value, ...functions) { + let output = value; + const groups = chunkFunctions(functions); + for (let groupIndex = 0; groupIndex < groups.length; groupIndex++) { + const group = groups[groupIndex]; + if (group.lazy && isIterable(output) && (group.shortCircuit || !Array.isArray(output))) output = lazyPipe(output, group); + else for (let index = 0; index < group.length; index++) output = group[index](output); + } + return output; +} +function chunkFunctions(functions) { + const result = []; + let currentGroup; + for (let index = 0; index < functions.length; index++) { + const func = functions[index]; + const isLazy = func.lazy != null; + if (currentGroup === void 0 || currentGroup.lazy !== isLazy) { + currentGroup = []; + currentGroup.lazy = isLazy; + result.push(currentGroup); + } + currentGroup.push(func); + if (func.shortCircuit) currentGroup.shortCircuit = true; + } + return result; +} +/** +* Fuses a run of lazy functions into a single pass over `data`. The functions' +* push transforms are composed (last function first) into one sink, then `data` +* is driven through it element-by-element. A short-circuiting function (e.g. +* `take`) returns `false`, which stops the drive loop at once, so the functions +* before it never run on the rest of the input — no intermediate arrays. +* +* @param data - The iterable fed into the run (an array, `Set`, generator, ...). +* @param lazyFunctions - The consecutive lazy functions to fuse, in order. +* @returns The collected results. +*/ +function lazyPipe(data, lazyFunctions) { + const result = []; + let sink = (value) => { + result.push(value); + return true; + }; + for (let index = lazyFunctions.length - 1; index >= 0; index--) sink = lazyFunctions[index].lazy(sink); + if (Array.isArray(data)) { + for (let index = 0; index < data.length; index++) if (sink(data[index]) === false) break; + } else { + const iterator = data[Symbol.iterator](); + let step = iterator.next(); + while (!step.done) { + if (sink(step.value) === false) break; + step = iterator.next(); + } + } + return result; +} +/** +* Whether `value` can be fed through the lazy path. A non-array iterable (a +* `Set`, a generator, ...) can only go through `lazyPipe`, since the eager path +* relies on array methods. Primitives and plain objects (no `Symbol.iterator`) +* fall through to the eager branch. +*/ +function isIterable(value) { + return typeof value === "object" && value !== null && Symbol.iterator in value; +} +//#endregion +exports.pipe = pipe; diff --git a/node_modules/es-toolkit/dist/fp/pipe.mjs b/node_modules/es-toolkit/dist/fp/pipe.mjs new file mode 100644 index 0000000000000000000000000000000000000000..93fe329b1dc58a4ae95e4413f5c4abfae444c1dd --- /dev/null +++ b/node_modules/es-toolkit/dist/fp/pipe.mjs @@ -0,0 +1,112 @@ +//#region src/fp/pipe.ts +/** +* Performs left-to-right function composition, threading `value` through each +* function in sequence. Every function receives the output of the previous +* one, so the data flows top-to-bottom in the same order it is read. This +* turns deeply nested calls into clear, sequential steps without temporary +* variables. +* +* This is the entry point of `es-toolkit/fp`. Each `es-toolkit/fp` function is +* called with its configuration (e.g. `map(fn)`, `take(2)`) and returns a +* function that takes the data, which `pipe` then supplies. +* +* When consecutive **lazy-capable** functions (`map`, `filter`, `take`, ...) +* appear together, `pipe` fuses them and processes the input element-by-element +* instead of building an intermediate array after every step. This allows +* early termination: a trailing `take(n)` stops the walk as soon as `n` +* results exist, so the remaining input is never visited. +* +* @param value - The initial value fed into the pipe. +* @param functions - Data-last operators (or any unary functions) applied in order. +* @returns The result of applying every function, left to right. +* +* @example +* import { pipe, map, filter, take } from 'es-toolkit/fp'; +* +* pipe([1, 2, 3], map(x => x * 3)); // => [3, 6, 9] +* +* @example +* // Lazy evaluation with early termination: only the first two even squares +* // are ever computed, the rest of the array is never touched. +* pipe( +* [1, 2, 3, 4, 5, 6, 7, 8], +* map(x => x * x), +* filter(x => x % 2 === 0), +* take(2) +* ); // => [4, 16] +* +* @example +* // Any unary function works inside a pipe, not just es-toolkit operators. +* pipe( +* ' Hello ', +* s => s.trim(), +* s => s.toLowerCase() +* ); // => 'hello' +*/ +function pipe(value, ...functions) { + let output = value; + const groups = chunkFunctions(functions); + for (let groupIndex = 0; groupIndex < groups.length; groupIndex++) { + const group = groups[groupIndex]; + if (group.lazy && isIterable(output) && (group.shortCircuit || !Array.isArray(output))) output = lazyPipe(output, group); + else for (let index = 0; index < group.length; index++) output = group[index](output); + } + return output; +} +function chunkFunctions(functions) { + const result = []; + let currentGroup; + for (let index = 0; index < functions.length; index++) { + const func = functions[index]; + const isLazy = func.lazy != null; + if (currentGroup === void 0 || currentGroup.lazy !== isLazy) { + currentGroup = []; + currentGroup.lazy = isLazy; + result.push(currentGroup); + } + currentGroup.push(func); + if (func.shortCircuit) currentGroup.shortCircuit = true; + } + return result; +} +/** +* Fuses a run of lazy functions into a single pass over `data`. The functions' +* push transforms are composed (last function first) into one sink, then `data` +* is driven through it element-by-element. A short-circuiting function (e.g. +* `take`) returns `false`, which stops the drive loop at once, so the functions +* before it never run on the rest of the input — no intermediate arrays. +* +* @param data - The iterable fed into the run (an array, `Set`, generator, ...). +* @param lazyFunctions - The consecutive lazy functions to fuse, in order. +* @returns The collected results. +*/ +function lazyPipe(data, lazyFunctions) { + const result = []; + let sink = (value) => { + result.push(value); + return true; + }; + for (let index = lazyFunctions.length - 1; index >= 0; index--) sink = lazyFunctions[index].lazy(sink); + if (Array.isArray(data)) { + for (let index = 0; index < data.length; index++) if (sink(data[index]) === false) break; + } else { + const iterator = data[Symbol.iterator](); + let step = iterator.next(); + while (!step.done) { + if (sink(step.value) === false) break; + step = iterator.next(); + } + } + return result; +} +/** +* Whether `value` can be fed through the lazy path. A non-array iterable (a +* `Set`, a generator, ...) can only go through `lazyPipe`, since the eager path +* relies on array methods. Primitives and plain objects (no `Symbol.iterator`) +* fall through to the eager branch. +*/ +function isIterable(value) { + return typeof value === "object" && value !== null && Symbol.iterator in value; +} +//#endregion +export { pipe }; diff --git a/node_modules/es-toolkit/dist/function/after.d.mts b/node_modules/es-toolkit/dist/function/after.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..21bba76d18b05f6b605e66b5e910e3052735ae23 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/after.d.mts @@ -0,0 +1,32 @@ +//#region src/function/after.d.ts +/** + * Creates a function that only executes starting from the `n`-th call. + * The provided function will be invoked starting from the `n`-th call. + * + * This is particularly useful for scenarios involving events or asynchronous operations + * where an action should occur only after a certain number of invocations. + * + * @template F - The type of the function to be invoked. + * @param n - The number of calls required for `func` to execute. + * @param func - The function to be invoked. + * @returns A new function that: + * - Tracks the number of calls. + * - Invokes `func` starting from the `n`-th call. + * - Returns `undefined` if fewer than `n` calls have been made. + * @throws {Error} - Throws an error if `n` is negative. + * @example + * + * const afterFn = after(3, () => { + * console.log("called") + * }); + * + * // Will not log anything. + * afterFn() + * // Will not log anything. + * afterFn() + * // Will log 'called'. + * afterFn() + */ +declare function after any>(n: number, func: F): (...args: Parameters) => ReturnType | undefined; +//#endregion +export { after }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/after.d.ts b/node_modules/es-toolkit/dist/function/after.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..21bba76d18b05f6b605e66b5e910e3052735ae23 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/after.d.ts @@ -0,0 +1,32 @@ +//#region src/function/after.d.ts +/** + * Creates a function that only executes starting from the `n`-th call. + * The provided function will be invoked starting from the `n`-th call. + * + * This is particularly useful for scenarios involving events or asynchronous operations + * where an action should occur only after a certain number of invocations. + * + * @template F - The type of the function to be invoked. + * @param n - The number of calls required for `func` to execute. + * @param func - The function to be invoked. + * @returns A new function that: + * - Tracks the number of calls. + * - Invokes `func` starting from the `n`-th call. + * - Returns `undefined` if fewer than `n` calls have been made. + * @throws {Error} - Throws an error if `n` is negative. + * @example + * + * const afterFn = after(3, () => { + * console.log("called") + * }); + * + * // Will not log anything. + * afterFn() + * // Will not log anything. + * afterFn() + * // Will log 'called'. + * afterFn() + */ +declare function after any>(n: number, func: F): (...args: Parameters) => ReturnType | undefined; +//#endregion +export { after }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/after.js b/node_modules/es-toolkit/dist/function/after.js new file mode 100644 index 0000000000000000000000000000000000000000..871742628e98941a928a46f164b9af32ed45321f --- /dev/null +++ b/node_modules/es-toolkit/dist/function/after.js @@ -0,0 +1,38 @@ +//#region src/function/after.ts +/** +* Creates a function that only executes starting from the `n`-th call. +* The provided function will be invoked starting from the `n`-th call. +* +* This is particularly useful for scenarios involving events or asynchronous operations +* where an action should occur only after a certain number of invocations. +* +* @template F - The type of the function to be invoked. +* @param n - The number of calls required for `func` to execute. +* @param func - The function to be invoked. +* @returns A new function that: +* - Tracks the number of calls. +* - Invokes `func` starting from the `n`-th call. +* - Returns `undefined` if fewer than `n` calls have been made. +* @throws {Error} - Throws an error if `n` is negative. +* @example +* +* const afterFn = after(3, () => { +* console.log("called") +* }); +* +* // Will not log anything. +* afterFn() +* // Will not log anything. +* afterFn() +* // Will log 'called'. +* afterFn() +*/ +function after(n, func) { + if (!Number.isInteger(n) || n < 0) throw new Error(`n must be a non-negative integer.`); + let counter = 0; + return (...args) => { + if (++counter >= n) return func(...args); + }; +} +//#endregion +exports.after = after; diff --git a/node_modules/es-toolkit/dist/function/after.mjs b/node_modules/es-toolkit/dist/function/after.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b8c5a5ed602951fbf85ebd66b299c228a5475f86 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/after.mjs @@ -0,0 +1,38 @@ +//#region src/function/after.ts +/** +* Creates a function that only executes starting from the `n`-th call. +* The provided function will be invoked starting from the `n`-th call. +* +* This is particularly useful for scenarios involving events or asynchronous operations +* where an action should occur only after a certain number of invocations. +* +* @template F - The type of the function to be invoked. +* @param n - The number of calls required for `func` to execute. +* @param func - The function to be invoked. +* @returns A new function that: +* - Tracks the number of calls. +* - Invokes `func` starting from the `n`-th call. +* - Returns `undefined` if fewer than `n` calls have been made. +* @throws {Error} - Throws an error if `n` is negative. +* @example +* +* const afterFn = after(3, () => { +* console.log("called") +* }); +* +* // Will not log anything. +* afterFn() +* // Will not log anything. +* afterFn() +* // Will log 'called'. +* afterFn() +*/ +function after(n, func) { + if (!Number.isInteger(n) || n < 0) throw new Error(`n must be a non-negative integer.`); + let counter = 0; + return (...args) => { + if (++counter >= n) return func(...args); + }; +} +//#endregion +export { after }; diff --git a/node_modules/es-toolkit/dist/function/ary.d.mts b/node_modules/es-toolkit/dist/function/ary.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..67c11e42a17838f756d37fc4ac20857f5c3e5263 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/ary.d.mts @@ -0,0 +1,22 @@ +//#region src/function/ary.d.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. + * @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] + */ +declare function ary any>(func: F, n: number): (...args: any[]) => ReturnType; +//#endregion +export { ary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/ary.d.ts b/node_modules/es-toolkit/dist/function/ary.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..67c11e42a17838f756d37fc4ac20857f5c3e5263 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/ary.d.ts @@ -0,0 +1,22 @@ +//#region src/function/ary.d.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. + * @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] + */ +declare function ary any>(func: F, n: number): (...args: any[]) => ReturnType; +//#endregion +export { ary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/ary.js b/node_modules/es-toolkit/dist/function/ary.js new file mode 100644 index 0000000000000000000000000000000000000000..f1654d6677544accb11d7ae1a35cf080d09bc5e0 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/ary.js @@ -0,0 +1,26 @@ +//#region src/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. +* @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) { + return function(...args) { + return func.apply(this, args.slice(0, n)); + }; +} +//#endregion +exports.ary = ary; diff --git a/node_modules/es-toolkit/dist/function/ary.mjs b/node_modules/es-toolkit/dist/function/ary.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fd2401193db403c20006445735ad82b2a6b6d574 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/ary.mjs @@ -0,0 +1,26 @@ +//#region src/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. +* @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) { + return function(...args) { + return func.apply(this, args.slice(0, n)); + }; +} +//#endregion +export { ary }; diff --git a/node_modules/es-toolkit/dist/function/asyncNoop.d.mts b/node_modules/es-toolkit/dist/function/asyncNoop.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b7e4e6509bcae32a39f0c9ead00d8bbf010c3d86 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/asyncNoop.d.mts @@ -0,0 +1,13 @@ +//#region src/function/asyncNoop.d.ts +/** + * An asynchronous no-operation function that does nothing. + * This can be used as a placeholder or default function. + * + * @example + * asyncNoop(); // Does nothing + * + * @returns This function returns a Promise that resolves to undefined. + */ +declare function asyncNoop(): Promise; +//#endregion +export { asyncNoop }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/asyncNoop.d.ts b/node_modules/es-toolkit/dist/function/asyncNoop.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7e4e6509bcae32a39f0c9ead00d8bbf010c3d86 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/asyncNoop.d.ts @@ -0,0 +1,13 @@ +//#region src/function/asyncNoop.d.ts +/** + * An asynchronous no-operation function that does nothing. + * This can be used as a placeholder or default function. + * + * @example + * asyncNoop(); // Does nothing + * + * @returns This function returns a Promise that resolves to undefined. + */ +declare function asyncNoop(): Promise; +//#endregion +export { asyncNoop }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/asyncNoop.js b/node_modules/es-toolkit/dist/function/asyncNoop.js new file mode 100644 index 0000000000000000000000000000000000000000..f61683e88b9dc1b16e9df7d4264847b785925bd9 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/asyncNoop.js @@ -0,0 +1,13 @@ +//#region src/function/asyncNoop.ts +/** +* An asynchronous no-operation function that does nothing. +* This can be used as a placeholder or default function. +* +* @example +* asyncNoop(); // Does nothing +* +* @returns This function returns a Promise that resolves to undefined. +*/ +async function asyncNoop() {} +//#endregion +exports.asyncNoop = asyncNoop; diff --git a/node_modules/es-toolkit/dist/function/asyncNoop.mjs b/node_modules/es-toolkit/dist/function/asyncNoop.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ded287117d63e4559d9c0d381d2c647f4657c774 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/asyncNoop.mjs @@ -0,0 +1,13 @@ +//#region src/function/asyncNoop.ts +/** +* An asynchronous no-operation function that does nothing. +* This can be used as a placeholder or default function. +* +* @example +* asyncNoop(); // Does nothing +* +* @returns This function returns a Promise that resolves to undefined. +*/ +async function asyncNoop() {} +//#endregion +export { asyncNoop }; diff --git a/node_modules/es-toolkit/dist/function/before.d.mts b/node_modules/es-toolkit/dist/function/before.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..436d09277136e18aab73d32f7550803d48017496 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/before.d.mts @@ -0,0 +1,32 @@ +//#region src/function/before.d.ts +/** + * Creates a function that limits the number of times the given function (`func`) can be called. + * + * @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 `undefined` if the number of calls reaches or exceeds `n`, stopping further calls. + * @throws {Error} - Throw an error if `n` is negative. + * @example + * + * const beforeFn = before(3, () => { + * console.log("called"); + * }) + * + * // Will log 'called'. + * beforeFn(); + * + * // Will log 'called'. + * beforeFn(); + * + * // Will not log anything. + * beforeFn(); + */ +declare function before any>(n: number, func: F): (...args: Parameters) => ReturnType | undefined; +//#endregion +export { before }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/before.d.ts b/node_modules/es-toolkit/dist/function/before.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..436d09277136e18aab73d32f7550803d48017496 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/before.d.ts @@ -0,0 +1,32 @@ +//#region src/function/before.d.ts +/** + * Creates a function that limits the number of times the given function (`func`) can be called. + * + * @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 `undefined` if the number of calls reaches or exceeds `n`, stopping further calls. + * @throws {Error} - Throw an error if `n` is negative. + * @example + * + * const beforeFn = before(3, () => { + * console.log("called"); + * }) + * + * // Will log 'called'. + * beforeFn(); + * + * // Will log 'called'. + * beforeFn(); + * + * // Will not log anything. + * beforeFn(); + */ +declare function before any>(n: number, func: F): (...args: Parameters) => ReturnType | undefined; +//#endregion +export { before }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/before.js b/node_modules/es-toolkit/dist/function/before.js new file mode 100644 index 0000000000000000000000000000000000000000..d87e61215c59b7b19e3f62aaa85795d1bb21510e --- /dev/null +++ b/node_modules/es-toolkit/dist/function/before.js @@ -0,0 +1,38 @@ +//#region src/function/before.ts +/** +* Creates a function that limits the number of times the given function (`func`) can be called. +* +* @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 `undefined` if the number of calls reaches or exceeds `n`, stopping further calls. +* @throws {Error} - Throw an error if `n` is negative. +* @example +* +* const beforeFn = before(3, () => { +* console.log("called"); +* }) +* +* // Will log 'called'. +* beforeFn(); +* +* // Will log 'called'. +* beforeFn(); +* +* // Will not log anything. +* beforeFn(); +*/ +function before(n, func) { + if (!Number.isInteger(n) || n < 0) throw new Error("n must be a non-negative integer."); + let counter = 0; + return (...args) => { + if (++counter < n) return func(...args); + }; +} +//#endregion +exports.before = before; diff --git a/node_modules/es-toolkit/dist/function/before.mjs b/node_modules/es-toolkit/dist/function/before.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f72b507a63e5094e9e96a02605e357fc5a397eb8 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/before.mjs @@ -0,0 +1,38 @@ +//#region src/function/before.ts +/** +* Creates a function that limits the number of times the given function (`func`) can be called. +* +* @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 `undefined` if the number of calls reaches or exceeds `n`, stopping further calls. +* @throws {Error} - Throw an error if `n` is negative. +* @example +* +* const beforeFn = before(3, () => { +* console.log("called"); +* }) +* +* // Will log 'called'. +* beforeFn(); +* +* // Will log 'called'. +* beforeFn(); +* +* // Will not log anything. +* beforeFn(); +*/ +function before(n, func) { + if (!Number.isInteger(n) || n < 0) throw new Error("n must be a non-negative integer."); + let counter = 0; + return (...args) => { + if (++counter < n) return func(...args); + }; +} +//#endregion +export { before }; diff --git a/node_modules/es-toolkit/dist/function/curry.d.mts b/node_modules/es-toolkit/dist/function/curry.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d6c04003c57a0936f945abdc5890c6d632898b21 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/curry.d.mts @@ -0,0 +1,127 @@ +//#region src/function/curry.d.ts +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function noArgFunc() { + * return 42; + * } + * const curriedNoArgFunc = curry(noArgFunc); + * console.log(curriedNoArgFunc()); // 42 + */ +declare function curry(func: () => R): () => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function oneArgFunc(a: number) { + * return a * 2; + * } + * const curriedOneArgFunc = curry(oneArgFunc); + * console.log(curriedOneArgFunc(5)); // 10 + */ +declare function curry(func: (p: P) => R): (p: P) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function twoArgFunc(a: number, b: number) { + * return a + b; + * } + * const curriedTwoArgFunc = curry(twoArgFunc); + * const add5 = curriedTwoArgFunc(5); + * console.log(add5(10)); // 15 + */ +declare function curry(func: (p1: P1, p2: P2) => R): (p1: P1) => (p2: P2) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function threeArgFunc(a: number, b: number, c: number) { + * return a + b + c; + * } + * const curriedThreeArgFunc = curry(threeArgFunc); + * const add1 = curriedThreeArgFunc(1); + * const add3 = add1(2); + * console.log(add3(3)); // 6 + */ +declare function curry(func: (p1: P1, p2: P2, p3: P3) => R): (p1: P1) => (p2: P2) => (p3: P3) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function fourArgFunc(a: number, b: number, c: number, d: number) { + * return a + b + c + d; + * } + * const curriedFourArgFunc = curry(fourArgFunc); + * const add1 = curriedFourArgFunc(1); + * const add3 = add1(2); + * const add6 = add3(3); + * console.log(add6(4)); // 10 + */ +declare function curry(func: (p1: P1, p2: P2, p3: P3, p4: P4) => R): (p1: P1) => (p2: P2) => (p3: P3) => (p4: P4) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function fiveArgFunc(a: number, b: number, c: number, d: number, e: number) { + * return a + b + c + d + e; + * } + * const curriedFiveArgFunc = curry(fiveArgFunc); + * const add1 = curriedFiveArgFunc(1); + * const add3 = add1(2); + * const add6 = add3(3); + * const add10 = add6(4); + * console.log(add10(5)); // 15 + */ +declare function curry(func: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R): (p1: P1) => (p2: P2) => (p3: P3) => (p4: P4) => (p5: P5) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function that can be called with a single argument at a time. + * + * @example + * function sum(a: number, b: number, c: number) { + * return a + b + c; + * } + * + * const curriedSum = curry(sum); + * + * // The parameter `a` should be given the value `10`. + * const add10 = curriedSum(10); + * + * // The parameter `b` should be given the value `15`. + * const add25 = add10(15); + * + * // The parameter `c` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. + * const result = add25(5); + */ +declare function curry(func: (...args: any[]) => any): (...args: any[]) => any; +//#endregion +export { curry }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/curry.d.ts b/node_modules/es-toolkit/dist/function/curry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6c04003c57a0936f945abdc5890c6d632898b21 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/curry.d.ts @@ -0,0 +1,127 @@ +//#region src/function/curry.d.ts +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function noArgFunc() { + * return 42; + * } + * const curriedNoArgFunc = curry(noArgFunc); + * console.log(curriedNoArgFunc()); // 42 + */ +declare function curry(func: () => R): () => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function oneArgFunc(a: number) { + * return a * 2; + * } + * const curriedOneArgFunc = curry(oneArgFunc); + * console.log(curriedOneArgFunc(5)); // 10 + */ +declare function curry(func: (p: P) => R): (p: P) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function twoArgFunc(a: number, b: number) { + * return a + b; + * } + * const curriedTwoArgFunc = curry(twoArgFunc); + * const add5 = curriedTwoArgFunc(5); + * console.log(add5(10)); // 15 + */ +declare function curry(func: (p1: P1, p2: P2) => R): (p1: P1) => (p2: P2) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function threeArgFunc(a: number, b: number, c: number) { + * return a + b + c; + * } + * const curriedThreeArgFunc = curry(threeArgFunc); + * const add1 = curriedThreeArgFunc(1); + * const add3 = add1(2); + * console.log(add3(3)); // 6 + */ +declare function curry(func: (p1: P1, p2: P2, p3: P3) => R): (p1: P1) => (p2: P2) => (p3: P3) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function fourArgFunc(a: number, b: number, c: number, d: number) { + * return a + b + c + d; + * } + * const curriedFourArgFunc = curry(fourArgFunc); + * const add1 = curriedFourArgFunc(1); + * const add3 = add1(2); + * const add6 = add3(3); + * console.log(add6(4)); // 10 + */ +declare function curry(func: (p1: P1, p2: P2, p3: P3, p4: P4) => R): (p1: P1) => (p2: P2) => (p3: P3) => (p4: P4) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function fiveArgFunc(a: number, b: number, c: number, d: number, e: number) { + * return a + b + c + d + e; + * } + * const curriedFiveArgFunc = curry(fiveArgFunc); + * const add1 = curriedFiveArgFunc(1); + * const add3 = add1(2); + * const add6 = add3(3); + * const add10 = add6(4); + * console.log(add10(5)); // 15 + */ +declare function curry(func: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R): (p1: P1) => (p2: P2) => (p3: P3) => (p4: P4) => (p5: P5) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * @param func - The function to curry. + * @returns A curried function that can be called with a single argument at a time. + * + * @example + * function sum(a: number, b: number, c: number) { + * return a + b + c; + * } + * + * const curriedSum = curry(sum); + * + * // The parameter `a` should be given the value `10`. + * const add10 = curriedSum(10); + * + * // The parameter `b` should be given the value `15`. + * const add25 = add10(15); + * + * // The parameter `c` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. + * const result = add25(5); + */ +declare function curry(func: (...args: any[]) => any): (...args: any[]) => any; +//#endregion +export { curry }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/curry.js b/node_modules/es-toolkit/dist/function/curry.js new file mode 100644 index 0000000000000000000000000000000000000000..b27099098e2e9a96b4412b3c0ef5253cad9dd5ce --- /dev/null +++ b/node_modules/es-toolkit/dist/function/curry.js @@ -0,0 +1,41 @@ +//#region src/function/curry.ts +/** +* Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. +* This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. +* +* @param func - The function to curry. +* @returns A curried function that can be called with a single argument at a time. +* +* @example +* function sum(a: number, b: number, c: number) { +* return a + b + c; +* } +* +* const curriedSum = curry(sum); +* +* // The parameter `a` should be given the value `10`. +* const add10 = curriedSum(10); +* +* // The parameter `b` should be given the value `15`. +* const add25 = add10(15); +* +* // The parameter `c` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. +* const result = add25(5); +*/ +function curry(func) { + if (func.length === 0 || func.length === 1) return func; + return function(arg) { + return makeCurry(func, func.length, [arg]); + }; +} +function makeCurry(origin, argsLength, args) { + if (args.length === argsLength) return origin(...args); + else { + const next = function(arg) { + return makeCurry(origin, argsLength, [...args, arg]); + }; + return next; + } +} +//#endregion +exports.curry = curry; diff --git a/node_modules/es-toolkit/dist/function/curry.mjs b/node_modules/es-toolkit/dist/function/curry.mjs new file mode 100644 index 0000000000000000000000000000000000000000..32f08c7788400c14869428a3db8b465ec033a314 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/curry.mjs @@ -0,0 +1,41 @@ +//#region src/function/curry.ts +/** +* Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. +* This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. +* +* @param func - The function to curry. +* @returns A curried function that can be called with a single argument at a time. +* +* @example +* function sum(a: number, b: number, c: number) { +* return a + b + c; +* } +* +* const curriedSum = curry(sum); +* +* // The parameter `a` should be given the value `10`. +* const add10 = curriedSum(10); +* +* // The parameter `b` should be given the value `15`. +* const add25 = add10(15); +* +* // The parameter `c` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. +* const result = add25(5); +*/ +function curry(func) { + if (func.length === 0 || func.length === 1) return func; + return function(arg) { + return makeCurry(func, func.length, [arg]); + }; +} +function makeCurry(origin, argsLength, args) { + if (args.length === argsLength) return origin(...args); + else { + const next = function(arg) { + return makeCurry(origin, argsLength, [...args, arg]); + }; + return next; + } +} +//#endregion +export { curry }; diff --git a/node_modules/es-toolkit/dist/function/curryRight.d.mts b/node_modules/es-toolkit/dist/function/curryRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e266dcd9a36d6af5bff9acca2260f40c4c2860f4 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/curryRight.d.mts @@ -0,0 +1,141 @@ +//#region src/function/curryRight.d.ts +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function noArgFunc() { + * return 42; + * } + * const curriedNoArgFunc = curryRight(noArgFunc); + * console.log(curriedNoArgFunc()); // 42 + */ +declare function curryRight(func: () => R): () => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function oneArgFunc(a: number) { + * return a * 2; + * } + * const curriedOneArgFunc = curryRight(oneArgFunc); + * console.log(curriedOneArgFunc(5)); // 10 + */ +declare function curryRight(func: (p: P) => R): (p: P) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function twoArgFunc(a: number, b: number) { + * return [a, b]; + * } + * const curriedTwoArgFunc = curryRight(twoArgFunc); + * const func = curriedTwoArgFunc(1); + * console.log(func(2)); // [2, 1] + */ +declare function curryRight(func: (p1: P1, p2: P2) => R): (p2: P2) => (p1: P1) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function threeArgFunc(a: number, b: number, c: number) { + * return [a, b, c]; + * } + * const curriedThreeArgFunc = curryRight(threeArgFunc); + * const func = curriedThreeArgFunc(1); + * const func2 = func(2); + * console.log(func2(3)); // [3, 2, 1] + */ +declare function curryRight(func: (p1: P1, p2: P2, p3: P3) => R): (p3: P3) => (p2: P2) => (p1: P1) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function fourArgFunc(a: number, b: number, c: number, d: number) { + * return [a, b, c, d]; + * } + * const curriedFourArgFunc = curryRight(fourArgFunc); + * const func = curriedFourArgFunc(1); + * const func2 = func(2); + * const func3 = func2(3); + * console.log(func3(4)); // [4, 3, 2, 1] + */ +declare function curryRight(func: (p1: P1, p2: P2, p3: P3, p4: P4) => R): (p4: P4) => (p3: P3) => (p2: P2) => (p1: P1) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function fiveArgFunc(a: number, b: number, c: number, d: number, e: number) { + * return [a, b, c, d, e]; + * } + * const curriedFiveArgFunc = curryRight(fiveArgFunc); + * const func = curriedFiveArgFunc(1); + * const func2 = func(2); + * const func3 = func2(3); + * const func4 = func3(4); + * console.log(func4(5)); // [5, 4, 3, 2, 1] + */ +declare function curryRight(func: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R): (p5: P5) => (p4: P4) => (p3: P3) => (p2: P2) => (p1: P1) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function sum(a: number, b: number, c: number) { + * return a + b + c; + * } + * + * const curriedSum = curryRight(sum); + * + * // The parameter `c` should be given the value `10`. + * const add10 = curriedSum(10); + * + * // The parameter `b` should be given the value `15`. + * const add25 = add10(15); + * + * // The parameter `a` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. + * const result = add25(5); // 30 + */ +declare function curryRight(func: (...args: any[]) => any): (...args: any[]) => any; +//#endregion +export { curryRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/curryRight.d.ts b/node_modules/es-toolkit/dist/function/curryRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e266dcd9a36d6af5bff9acca2260f40c4c2860f4 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/curryRight.d.ts @@ -0,0 +1,141 @@ +//#region src/function/curryRight.d.ts +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function noArgFunc() { + * return 42; + * } + * const curriedNoArgFunc = curryRight(noArgFunc); + * console.log(curriedNoArgFunc()); // 42 + */ +declare function curryRight(func: () => R): () => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function oneArgFunc(a: number) { + * return a * 2; + * } + * const curriedOneArgFunc = curryRight(oneArgFunc); + * console.log(curriedOneArgFunc(5)); // 10 + */ +declare function curryRight(func: (p: P) => R): (p: P) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function twoArgFunc(a: number, b: number) { + * return [a, b]; + * } + * const curriedTwoArgFunc = curryRight(twoArgFunc); + * const func = curriedTwoArgFunc(1); + * console.log(func(2)); // [2, 1] + */ +declare function curryRight(func: (p1: P1, p2: P2) => R): (p2: P2) => (p1: P1) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function threeArgFunc(a: number, b: number, c: number) { + * return [a, b, c]; + * } + * const curriedThreeArgFunc = curryRight(threeArgFunc); + * const func = curriedThreeArgFunc(1); + * const func2 = func(2); + * console.log(func2(3)); // [3, 2, 1] + */ +declare function curryRight(func: (p1: P1, p2: P2, p3: P3) => R): (p3: P3) => (p2: P2) => (p1: P1) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function fourArgFunc(a: number, b: number, c: number, d: number) { + * return [a, b, c, d]; + * } + * const curriedFourArgFunc = curryRight(fourArgFunc); + * const func = curriedFourArgFunc(1); + * const func2 = func(2); + * const func3 = func2(3); + * console.log(func3(4)); // [4, 3, 2, 1] + */ +declare function curryRight(func: (p1: P1, p2: P2, p3: P3, p4: P4) => R): (p4: P4) => (p3: P3) => (p2: P2) => (p1: P1) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function fiveArgFunc(a: number, b: number, c: number, d: number, e: number) { + * return [a, b, c, d, e]; + * } + * const curriedFiveArgFunc = curryRight(fiveArgFunc); + * const func = curriedFiveArgFunc(1); + * const func2 = func(2); + * const func3 = func2(3); + * const func4 = func3(4); + * console.log(func4(5)); // [5, 4, 3, 2, 1] + */ +declare function curryRight(func: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R): (p5: P5) => (p4: P4) => (p3: P3) => (p2: P2) => (p1: P1) => R; +/** + * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. + * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. + * + * Unlike `curry`, this function curries the function from right to left. + * + * @param func - The function to curry. + * @returns A curried function. + * + * @example + * function sum(a: number, b: number, c: number) { + * return a + b + c; + * } + * + * const curriedSum = curryRight(sum); + * + * // The parameter `c` should be given the value `10`. + * const add10 = curriedSum(10); + * + * // The parameter `b` should be given the value `15`. + * const add25 = add10(15); + * + * // The parameter `a` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. + * const result = add25(5); // 30 + */ +declare function curryRight(func: (...args: any[]) => any): (...args: any[]) => any; +//#endregion +export { curryRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/curryRight.js b/node_modules/es-toolkit/dist/function/curryRight.js new file mode 100644 index 0000000000000000000000000000000000000000..f9eb9d69b3bb31e6cb66a0d8d281590fd18aa234 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/curryRight.js @@ -0,0 +1,43 @@ +//#region src/function/curryRight.ts +/** +* Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. +* This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. +* +* Unlike `curry`, this function curries the function from right to left. +* +* @param func - The function to curry. +* @returns A curried function. +* +* @example +* function sum(a: number, b: number, c: number) { +* return a + b + c; +* } +* +* const curriedSum = curryRight(sum); +* +* // The parameter `c` should be given the value `10`. +* const add10 = curriedSum(10); +* +* // The parameter `b` should be given the value `15`. +* const add25 = add10(15); +* +* // The parameter `a` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. +* const result = add25(5); // 30 +*/ +function curryRight(func) { + if (func.length === 0 || func.length === 1) return func; + return function(arg) { + return makeCurryRight(func, func.length, [arg]); + }; +} +function makeCurryRight(origin, argsLength, args) { + if (args.length === argsLength) return origin(...args); + else { + const next = function(arg) { + return makeCurryRight(origin, argsLength, [arg, ...args]); + }; + return next; + } +} +//#endregion +exports.curryRight = curryRight; diff --git a/node_modules/es-toolkit/dist/function/curryRight.mjs b/node_modules/es-toolkit/dist/function/curryRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d79bc7fab0629b9536f8a271809f06027d12864a --- /dev/null +++ b/node_modules/es-toolkit/dist/function/curryRight.mjs @@ -0,0 +1,43 @@ +//#region src/function/curryRight.ts +/** +* Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. +* This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. +* +* Unlike `curry`, this function curries the function from right to left. +* +* @param func - The function to curry. +* @returns A curried function. +* +* @example +* function sum(a: number, b: number, c: number) { +* return a + b + c; +* } +* +* const curriedSum = curryRight(sum); +* +* // The parameter `c` should be given the value `10`. +* const add10 = curriedSum(10); +* +* // The parameter `b` should be given the value `15`. +* const add25 = add10(15); +* +* // The parameter `a` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. +* const result = add25(5); // 30 +*/ +function curryRight(func) { + if (func.length === 0 || func.length === 1) return func; + return function(arg) { + return makeCurryRight(func, func.length, [arg]); + }; +} +function makeCurryRight(origin, argsLength, args) { + if (args.length === argsLength) return origin(...args); + else { + const next = function(arg) { + return makeCurryRight(origin, argsLength, [arg, ...args]); + }; + return next; + } +} +//#endregion +export { curryRight }; diff --git a/node_modules/es-toolkit/dist/function/debounce.d.mts b/node_modules/es-toolkit/dist/function/debounce.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4f4de556b61f38d41faae2be217b7dc647e7bf12 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/debounce.d.mts @@ -0,0 +1,77 @@ +//#region src/function/debounce.d.ts +interface DebounceOptions { + /** + * An optional AbortSignal to cancel the debounced function. + */ + signal?: AbortSignal; + /** + * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both. + * If `edges` includes "leading", the function will be invoked at the start of the delay period. + * If `edges` includes "trailing", the function will be invoked at the end of the delay period. + * If both "leading" and "trailing" are included, the function will be invoked at both the start and end of the delay period. + * @default ["trailing"] + */ + edges?: Array<'leading' | 'trailing'>; +} +interface DebouncedFunction void> { + (...args: Parameters): void; + /** + * Schedules the execution of the debounced function after the specified debounce delay. + * This method resets any existing timer, ensuring that the function is only invoked + * after the delay has elapsed since the last call to the debounced function. + * It is typically called internally whenever the debounced function is invoked. + */ + schedule: () => void; + /** + * Cancels any pending execution of the debounced function. + * This method clears the active timer and resets any stored context or arguments. + */ + cancel: () => void; + /** + * Immediately invokes the debounced function if there is a pending execution. + * This method executes the function right away if there is a pending execution. + */ + flush: () => void; +} +/** + * 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. + * + * @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.edges - An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both. + * @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 void>(func: F, debounceMs: number, { + signal, + edges +}?: DebounceOptions): DebouncedFunction; +//#endregion +export { DebounceOptions, DebouncedFunction, debounce }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/debounce.d.ts b/node_modules/es-toolkit/dist/function/debounce.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f4de556b61f38d41faae2be217b7dc647e7bf12 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/debounce.d.ts @@ -0,0 +1,77 @@ +//#region src/function/debounce.d.ts +interface DebounceOptions { + /** + * An optional AbortSignal to cancel the debounced function. + */ + signal?: AbortSignal; + /** + * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both. + * If `edges` includes "leading", the function will be invoked at the start of the delay period. + * If `edges` includes "trailing", the function will be invoked at the end of the delay period. + * If both "leading" and "trailing" are included, the function will be invoked at both the start and end of the delay period. + * @default ["trailing"] + */ + edges?: Array<'leading' | 'trailing'>; +} +interface DebouncedFunction void> { + (...args: Parameters): void; + /** + * Schedules the execution of the debounced function after the specified debounce delay. + * This method resets any existing timer, ensuring that the function is only invoked + * after the delay has elapsed since the last call to the debounced function. + * It is typically called internally whenever the debounced function is invoked. + */ + schedule: () => void; + /** + * Cancels any pending execution of the debounced function. + * This method clears the active timer and resets any stored context or arguments. + */ + cancel: () => void; + /** + * Immediately invokes the debounced function if there is a pending execution. + * This method executes the function right away if there is a pending execution. + */ + flush: () => void; +} +/** + * 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. + * + * @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.edges - An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both. + * @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 void>(func: F, debounceMs: number, { + signal, + edges +}?: DebounceOptions): DebouncedFunction; +//#endregion +export { DebounceOptions, DebouncedFunction, debounce }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/debounce.js b/node_modules/es-toolkit/dist/function/debounce.js new file mode 100644 index 0000000000000000000000000000000000000000..b4dc93dab3184549d9f9fc6fdee8ecb8afc84911 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/debounce.js @@ -0,0 +1,91 @@ +//#region src/function/debounce.ts +/** +* 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. +* +* @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.edges - An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both. +* @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(); +*/ +function debounce(func, debounceMs, { signal, edges } = {}) { + let pendingThis = void 0; + let pendingArgs = null; + const leading = edges != null && edges.includes("leading"); + const trailing = edges == null || edges.includes("trailing"); + const invoke = () => { + if (pendingArgs !== null) { + func.apply(pendingThis, pendingArgs); + pendingThis = void 0; + pendingArgs = null; + } + }; + const onTimerEnd = () => { + if (trailing) invoke(); + cancel(); + }; + let timeoutId = null; + const schedule = () => { + if (timeoutId != null) clearTimeout(timeoutId); + timeoutId = setTimeout(() => { + timeoutId = null; + onTimerEnd(); + }, debounceMs); + }; + const cancelTimer = () => { + if (timeoutId !== null) { + clearTimeout(timeoutId); + timeoutId = null; + } + }; + const cancel = () => { + cancelTimer(); + pendingThis = void 0; + pendingArgs = null; + }; + const flush = () => { + invoke(); + }; + const debounced = function(...args) { + if (signal?.aborted) return; + pendingThis = this; + pendingArgs = args; + const isFirstCall = timeoutId == null; + schedule(); + if (leading && isFirstCall) invoke(); + }; + debounced.schedule = schedule; + debounced.cancel = cancel; + debounced.flush = flush; + signal?.addEventListener("abort", cancel, { once: true }); + return debounced; +} +//#endregion +exports.debounce = debounce; diff --git a/node_modules/es-toolkit/dist/function/debounce.mjs b/node_modules/es-toolkit/dist/function/debounce.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3e5495612f892667f7f50889f281db703244a817 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/debounce.mjs @@ -0,0 +1,91 @@ +//#region src/function/debounce.ts +/** +* 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. +* +* @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.edges - An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both. +* @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(); +*/ +function debounce(func, debounceMs, { signal, edges } = {}) { + let pendingThis = void 0; + let pendingArgs = null; + const leading = edges != null && edges.includes("leading"); + const trailing = edges == null || edges.includes("trailing"); + const invoke = () => { + if (pendingArgs !== null) { + func.apply(pendingThis, pendingArgs); + pendingThis = void 0; + pendingArgs = null; + } + }; + const onTimerEnd = () => { + if (trailing) invoke(); + cancel(); + }; + let timeoutId = null; + const schedule = () => { + if (timeoutId != null) clearTimeout(timeoutId); + timeoutId = setTimeout(() => { + timeoutId = null; + onTimerEnd(); + }, debounceMs); + }; + const cancelTimer = () => { + if (timeoutId !== null) { + clearTimeout(timeoutId); + timeoutId = null; + } + }; + const cancel = () => { + cancelTimer(); + pendingThis = void 0; + pendingArgs = null; + }; + const flush = () => { + invoke(); + }; + const debounced = function(...args) { + if (signal?.aborted) return; + pendingThis = this; + pendingArgs = args; + const isFirstCall = timeoutId == null; + schedule(); + if (leading && isFirstCall) invoke(); + }; + debounced.schedule = schedule; + debounced.cancel = cancel; + debounced.flush = flush; + signal?.addEventListener("abort", cancel, { once: true }); + return debounced; +} +//#endregion +export { debounce }; diff --git a/node_modules/es-toolkit/dist/function/flow.d.mts b/node_modules/es-toolkit/dist/function/flow.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c4a1a8362fe898a5b52ef940675c3772a182be48 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/flow.d.mts @@ -0,0 +1,133 @@ +//#region src/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. + * + * The `this` context of the returned function is also passed to the functions provided as parameters. + * + * @param f The function to invoke. + * @returns Returns the new composite function. + * + * @example + * function noArgFunc() { + * return 42; + * } + * + * const combined = flow(noArgFunc); + * console.log(combined()); // 42 + */ +declare function flow(f: () => R): () => R; +/** + * 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 f1 The function to invoke. + * @returns Returns the new composite function. + * + * @example + * function oneArgFunc(a: number) { + * return a * 2; + * } + * + * const combined = flow(oneArgFunc); + * console.log(combined(5)); // 10 + */ +declare function flow(f1: (...args: A) => R): (...args: A) => R; +/** + * 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 f1 The function to invoke. + * @param f2 The function to invoke. + * @returns Returns the new composite function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * + * const combined = flow(add, square); + * console.log(combined(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 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 f1 The function to invoke. + * @param f2 The function to invoke. + * @param f3 The function 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 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3): (...args: A) => R3; +/** + * 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 f1 The function to invoke. + * @param f2 The function to invoke. + * @param f3 The function to invoke. + * @param f4 The function 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 toStr = (n: number) => n.toString(); + * + * const combined = flow(add, square, double, toStr); + * 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 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 f1 The function to invoke. + * @param f2 The function to invoke. + * @param f3 The function to invoke. + * @param f4 The function to invoke. + * @param f5 The function 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 toStr = (n: number) => n.toString(); + * const split = (s: string) => s.split(''); + * + * const combined = flow(add, square, double, toStr, split); + * console.log(combined(1, 2)); // ['1', '8'] + */ +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 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 combined = flow(add, square); + * console.log(combined(1, 2)); // 9 + */ +declare function flow(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any; +//#endregion +export { flow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/flow.d.ts b/node_modules/es-toolkit/dist/function/flow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c4a1a8362fe898a5b52ef940675c3772a182be48 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/flow.d.ts @@ -0,0 +1,133 @@ +//#region src/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. + * + * The `this` context of the returned function is also passed to the functions provided as parameters. + * + * @param f The function to invoke. + * @returns Returns the new composite function. + * + * @example + * function noArgFunc() { + * return 42; + * } + * + * const combined = flow(noArgFunc); + * console.log(combined()); // 42 + */ +declare function flow(f: () => R): () => R; +/** + * 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 f1 The function to invoke. + * @returns Returns the new composite function. + * + * @example + * function oneArgFunc(a: number) { + * return a * 2; + * } + * + * const combined = flow(oneArgFunc); + * console.log(combined(5)); // 10 + */ +declare function flow(f1: (...args: A) => R): (...args: A) => R; +/** + * 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 f1 The function to invoke. + * @param f2 The function to invoke. + * @returns Returns the new composite function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const square = (n: number) => n * n; + * + * const combined = flow(add, square); + * console.log(combined(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 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 f1 The function to invoke. + * @param f2 The function to invoke. + * @param f3 The function 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 + */ +declare function flow(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3): (...args: A) => R3; +/** + * 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 f1 The function to invoke. + * @param f2 The function to invoke. + * @param f3 The function to invoke. + * @param f4 The function 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 toStr = (n: number) => n.toString(); + * + * const combined = flow(add, square, double, toStr); + * 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 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 f1 The function to invoke. + * @param f2 The function to invoke. + * @param f3 The function to invoke. + * @param f4 The function to invoke. + * @param f5 The function 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 toStr = (n: number) => n.toString(); + * const split = (s: string) => s.split(''); + * + * const combined = flow(add, square, double, toStr, split); + * console.log(combined(1, 2)); // ['1', '8'] + */ +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 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 combined = flow(add, square); + * console.log(combined(1, 2)); // 9 + */ +declare function flow(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any; +//#endregion +export { flow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/flow.js b/node_modules/es-toolkit/dist/function/flow.js new file mode 100644 index 0000000000000000000000000000000000000000..fde91c0076dbaf346c6230d84d5107444abf2313 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/flow.js @@ -0,0 +1,25 @@ +//#region src/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 combined = flow(add, square); +* console.log(combined(1, 2)); // 9 +*/ +function flow(...funcs) { + return function(...args) { + let result = funcs.length ? funcs[0].apply(this, args) : args[0]; + for (let i = 1; i < funcs.length; i++) result = funcs[i].call(this, result); + return result; + }; +} +//#endregion +exports.flow = flow; diff --git a/node_modules/es-toolkit/dist/function/flow.mjs b/node_modules/es-toolkit/dist/function/flow.mjs new file mode 100644 index 0000000000000000000000000000000000000000..814fa378b306f5f0e3cf89c900a9134fd715fe2a --- /dev/null +++ b/node_modules/es-toolkit/dist/function/flow.mjs @@ -0,0 +1,25 @@ +//#region src/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 combined = flow(add, square); +* console.log(combined(1, 2)); // 9 +*/ +function flow(...funcs) { + return function(...args) { + let result = funcs.length ? funcs[0].apply(this, args) : args[0]; + for (let i = 1; i < funcs.length; i++) result = funcs[i].call(this, result); + return result; + }; +} +//#endregion +export { flow }; diff --git a/node_modules/es-toolkit/dist/function/flowRight.d.mts b/node_modules/es-toolkit/dist/function/flowRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d50e1a0680f7f3830ea645d03719257b9cfeb152 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/flowRight.d.mts @@ -0,0 +1,145 @@ +//#region src/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. + * + * 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 f The function to invoke. + * @returns Returns the new composite function. + * + * @example + * function noArgFunc() { + * return 42; + * } + * const combined = flowRight(noArgFunc); + * console.log(combined()); // 42 + */ +declare function flowRight(f: () => R): () => R; +/** + * 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 f1 The function to invoke. + * @returns Returns the new composite function. + * + * @example + * function oneArgFunc(a: number) { + * return a * 2; + * } + * const combined = flowRight(oneArgFunc); + * console.log(combined(5)); // 10 + */ +declare function flowRight(f1: (...args: A) => R): (...args: A) => R; +/** + * 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 f2 The function to invoke. + * @param f1 The function to invoke. + * @returns Returns the new composite 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 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 f3 The function to invoke. + * @param f2 The function to invoke. + * @param f1 The function 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 + */ +declare function flowRight(f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R3; +/** + * 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 f4 The function to invoke. + * @param f3 The function to invoke. + * @param f2 The function to invoke. + * @param f1 The function 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 toStr = (n: number) => n.toString(); + * + * const combined = flowRight(toStr, 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 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 f5 The function to invoke. + * @param f4 The function to invoke. + * @param f3 The function to invoke. + * @param f2 The function to invoke. + * @param f1 The function 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 toStr = (n: number) => n.toString(); + * const split = (s: string) => s.split(''); + * + * const combined = flowRight(split, toStr, double, square, add); + * console.log(combined(1, 2)); // ['1', '8'] + */ +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 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 combined = flowRight(square, add); + * console.log(combined(1, 2)); // 9 + */ +declare function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any; +//#endregion +export { flowRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/flowRight.d.ts b/node_modules/es-toolkit/dist/function/flowRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d50e1a0680f7f3830ea645d03719257b9cfeb152 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/flowRight.d.ts @@ -0,0 +1,145 @@ +//#region src/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. + * + * 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 f The function to invoke. + * @returns Returns the new composite function. + * + * @example + * function noArgFunc() { + * return 42; + * } + * const combined = flowRight(noArgFunc); + * console.log(combined()); // 42 + */ +declare function flowRight(f: () => R): () => R; +/** + * 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 f1 The function to invoke. + * @returns Returns the new composite function. + * + * @example + * function oneArgFunc(a: number) { + * return a * 2; + * } + * const combined = flowRight(oneArgFunc); + * console.log(combined(5)); // 10 + */ +declare function flowRight(f1: (...args: A) => R): (...args: A) => R; +/** + * 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 f2 The function to invoke. + * @param f1 The function to invoke. + * @returns Returns the new composite 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 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 f3 The function to invoke. + * @param f2 The function to invoke. + * @param f1 The function 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 + */ +declare function flowRight(f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R3; +/** + * 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 f4 The function to invoke. + * @param f3 The function to invoke. + * @param f2 The function to invoke. + * @param f1 The function 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 toStr = (n: number) => n.toString(); + * + * const combined = flowRight(toStr, 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 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 f5 The function to invoke. + * @param f4 The function to invoke. + * @param f3 The function to invoke. + * @param f2 The function to invoke. + * @param f1 The function 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 toStr = (n: number) => n.toString(); + * const split = (s: string) => s.split(''); + * + * const combined = flowRight(split, toStr, double, square, add); + * console.log(combined(1, 2)); // ['1', '8'] + */ +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 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 combined = flowRight(square, add); + * console.log(combined(1, 2)); // 9 + */ +declare function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any; +//#endregion +export { flowRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/flowRight.js b/node_modules/es-toolkit/dist/function/flowRight.js new file mode 100644 index 0000000000000000000000000000000000000000..45d2b81a9b769ba1f67da8f75e3fdea0f5f66033 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/flowRight.js @@ -0,0 +1,24 @@ +const require_flow = require("./flow.js"); +//#region src/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 combined = flowRight(square, add); +* console.log(combined(1, 2)); // 9 +*/ +function flowRight(...funcs) { + return require_flow.flow(...funcs.reverse()); +} +//#endregion +exports.flowRight = flowRight; diff --git a/node_modules/es-toolkit/dist/function/flowRight.mjs b/node_modules/es-toolkit/dist/function/flowRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..53c72ba8b32f716790ea63b7dcf32f1e09e620b5 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/flowRight.mjs @@ -0,0 +1,24 @@ +import { flow } from "./flow.mjs"; +//#region src/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 combined = flowRight(square, add); +* console.log(combined(1, 2)); // 9 +*/ +function flowRight(...funcs) { + return flow(...funcs.reverse()); +} +//#endregion +export { flowRight }; diff --git a/node_modules/es-toolkit/dist/function/identity.d.mts b/node_modules/es-toolkit/dist/function/identity.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c4c86d85a603b0cdf99f5b159ba9f0ce391e1659 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/identity.d.mts @@ -0,0 +1,23 @@ +//#region src/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(x: T): T; +//#endregion +export { identity }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/identity.d.ts b/node_modules/es-toolkit/dist/function/identity.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c4c86d85a603b0cdf99f5b159ba9f0ce391e1659 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/identity.d.ts @@ -0,0 +1,23 @@ +//#region src/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(x: T): T; +//#endregion +export { identity }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/identity.js b/node_modules/es-toolkit/dist/function/identity.js new file mode 100644 index 0000000000000000000000000000000000000000..dd21979771bab05f1a3dceef8aeae967247f63ed --- /dev/null +++ b/node_modules/es-toolkit/dist/function/identity.js @@ -0,0 +1,25 @@ +//#region src/function/identity.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' }); +*/ +function identity(x) { + return x; +} +//#endregion +exports.identity = identity; diff --git a/node_modules/es-toolkit/dist/function/identity.mjs b/node_modules/es-toolkit/dist/function/identity.mjs new file mode 100644 index 0000000000000000000000000000000000000000..28889ef32f6febecc6e0bf01789d3fe99526db97 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/identity.mjs @@ -0,0 +1,25 @@ +//#region src/function/identity.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' }); +*/ +function identity(x) { + return x; +} +//#endregion +export { identity }; diff --git a/node_modules/es-toolkit/dist/function/index.d.mts b/node_modules/es-toolkit/dist/function/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..44c5420fd4df99d79a0abba87651441f1d39ff12 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/index.d.mts @@ -0,0 +1,22 @@ +import { after } from "./after.mjs"; +import { ary } from "./ary.mjs"; +import { asyncNoop } from "./asyncNoop.mjs"; +import { before } from "./before.mjs"; +import { curry } from "./curry.mjs"; +import { curryRight } from "./curryRight.mjs"; +import { DebounceOptions, DebouncedFunction, debounce } from "./debounce.mjs"; +import { flow } from "./flow.mjs"; +import { flowRight } from "./flowRight.mjs"; +import { identity } from "./identity.mjs"; +import { MemoizeCache, memoize } from "./memoize.mjs"; +import { negate } from "./negate.mjs"; +import { noop } from "./noop.mjs"; +import { once } from "./once.mjs"; +import { partial } from "./partial.mjs"; +import { partialRight } from "./partialRight.mjs"; +import { rest } from "./rest.mjs"; +import { retry } from "./retry.mjs"; +import { spread } from "./spread.mjs"; +import { ThrottleOptions, ThrottledFunction, throttle } from "./throttle.mjs"; +import { unary } from "./unary.mjs"; +export { type DebounceOptions, type DebouncedFunction, type MemoizeCache, type ThrottleOptions, type ThrottledFunction, after, ary, asyncNoop, before, curry, curryRight, debounce, flow, flowRight, identity, memoize, negate, noop, once, partial, partialRight, rest, retry, spread, throttle, unary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/index.d.ts b/node_modules/es-toolkit/dist/function/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..07ffcc1f3814f0214bf17041374356117cad33d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/index.d.ts @@ -0,0 +1,22 @@ +import { after } from "./after.js"; +import { ary } from "./ary.js"; +import { asyncNoop } from "./asyncNoop.js"; +import { before } from "./before.js"; +import { curry } from "./curry.js"; +import { curryRight } from "./curryRight.js"; +import { DebounceOptions, DebouncedFunction, debounce } from "./debounce.js"; +import { flow } from "./flow.js"; +import { flowRight } from "./flowRight.js"; +import { identity } from "./identity.js"; +import { MemoizeCache, memoize } from "./memoize.js"; +import { negate } from "./negate.js"; +import { noop } from "./noop.js"; +import { once } from "./once.js"; +import { partial } from "./partial.js"; +import { partialRight } from "./partialRight.js"; +import { rest } from "./rest.js"; +import { retry } from "./retry.js"; +import { spread } from "./spread.js"; +import { ThrottleOptions, ThrottledFunction, throttle } from "./throttle.js"; +import { unary } from "./unary.js"; +export { type DebounceOptions, type DebouncedFunction, type MemoizeCache, type ThrottleOptions, type ThrottledFunction, after, ary, asyncNoop, before, curry, curryRight, debounce, flow, flowRight, identity, memoize, negate, noop, once, partial, partialRight, rest, retry, spread, throttle, unary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/index.js b/node_modules/es-toolkit/dist/function/index.js new file mode 100644 index 0000000000000000000000000000000000000000..2d2844e625b1da84e54570fe9c73ad4d2766efe9 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/index.js @@ -0,0 +1,43 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_after = require("./after.js"); +const require_ary = require("./ary.js"); +const require_asyncNoop = require("./asyncNoop.js"); +const require_before = require("./before.js"); +const require_curry = require("./curry.js"); +const require_curryRight = require("./curryRight.js"); +const require_debounce = require("./debounce.js"); +const require_flow = require("./flow.js"); +const require_flowRight = require("./flowRight.js"); +const require_identity = require("./identity.js"); +const require_memoize = require("./memoize.js"); +const require_negate = require("./negate.js"); +const require_noop = require("./noop.js"); +const require_once = require("./once.js"); +const require_partial = require("./partial.js"); +const require_partialRight = require("./partialRight.js"); +const require_rest = require("./rest.js"); +const require_retry = require("./retry.js"); +const require_spread = require("./spread.js"); +const require_throttle = require("./throttle.js"); +const require_unary = require("./unary.js"); +exports.after = require_after.after; +exports.ary = require_ary.ary; +exports.asyncNoop = require_asyncNoop.asyncNoop; +exports.before = require_before.before; +exports.curry = require_curry.curry; +exports.curryRight = require_curryRight.curryRight; +exports.debounce = require_debounce.debounce; +exports.flow = require_flow.flow; +exports.flowRight = require_flowRight.flowRight; +exports.identity = require_identity.identity; +exports.memoize = require_memoize.memoize; +exports.negate = require_negate.negate; +exports.noop = require_noop.noop; +exports.once = require_once.once; +exports.partial = require_partial.partial; +exports.partialRight = require_partialRight.partialRight; +exports.rest = require_rest.rest; +exports.retry = require_retry.retry; +exports.spread = require_spread.spread; +exports.throttle = require_throttle.throttle; +exports.unary = require_unary.unary; diff --git a/node_modules/es-toolkit/dist/function/index.mjs b/node_modules/es-toolkit/dist/function/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d36bd98f0ce255f524e588bfbd0be7d9eff99120 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/index.mjs @@ -0,0 +1,22 @@ +import { after } from "./after.mjs"; +import { ary } from "./ary.mjs"; +import { asyncNoop } from "./asyncNoop.mjs"; +import { before } from "./before.mjs"; +import { curry } from "./curry.mjs"; +import { curryRight } from "./curryRight.mjs"; +import { debounce } from "./debounce.mjs"; +import { flow } from "./flow.mjs"; +import { flowRight } from "./flowRight.mjs"; +import { identity } from "./identity.mjs"; +import { memoize } from "./memoize.mjs"; +import { negate } from "./negate.mjs"; +import { noop } from "./noop.mjs"; +import { once } from "./once.mjs"; +import { partial } from "./partial.mjs"; +import { partialRight } from "./partialRight.mjs"; +import { rest } from "./rest.mjs"; +import { retry } from "./retry.mjs"; +import { spread } from "./spread.mjs"; +import { throttle } from "./throttle.mjs"; +import { unary } from "./unary.mjs"; +export { after, ary, asyncNoop, before, curry, curryRight, debounce, flow, flowRight, identity, memoize, negate, noop, once, partial, partialRight, rest, retry, spread, throttle, unary }; diff --git a/node_modules/es-toolkit/dist/function/memoize.d.mts b/node_modules/es-toolkit/dist/function/memoize.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..894cb50121bd7a0d099b7630ee21cd93bf6c65ce --- /dev/null +++ b/node_modules/es-toolkit/dist/function/memoize.d.mts @@ -0,0 +1,125 @@ +//#region src/function/memoize.d.ts +/** + * Creates a memoized version of the provided function. The memoized function caches + * results based on the argument it receives, so if the same argument is passed again, + * it returns the cached result instead of recomputing it. + * + * This function works with functions that take zero or just one argument. If your function + * originally takes multiple arguments, you should refactor it to take a single object or array + * that combines those arguments. + * + * If the argument is not primitive (e.g., arrays or objects), provide a + * `getCacheKey` function to generate a unique cache key for proper caching. + * + * @template F - The type of the function to be memoized. + * @param fn - The function to be memoized. It should accept a single argument and return a value. + * @param [options={}] - Optional configuration for the memoization. + * @param [options.cache] - The cache object used to store results. Defaults to a new `Map`. + * @param [options.getCacheKey] - An optional function to generate a unique cache key for each argument. + * + * @returns The memoized function with an additional `cache` property that exposes the internal cache. + * + * @example + * // Example using the default cache + * const add = (x: number) => x + 10; + * const memoizedAdd = memoize(add); + * + * console.log(memoizedAdd(5)); // 15 + * console.log(memoizedAdd(5)); // 15 (cached result) + * console.log(memoizedAdd.cache.size); // 1 + * + * @example + * // Example using a custom resolver + * const sum = (arr: number[]) => arr.reduce((x, y) => x + y, 0); + * const memoizedSum = memoize(sum, { getCacheKey: (arr: number[]) => arr.join(',') }); + * console.log(memoizedSum([1, 2])); // 3 + * console.log(memoizedSum([1, 2])); // 3 (cached result) + * console.log(memoizedSum.cache.size); // 1 + * + * @example + * // Example using a custom cache implementation + * class CustomCache implements MemoizeCache { + * private cache = new Map(); + * + * set(key: K, value: T): void { + * this.cache.set(key, value); + * } + * + * get(key: K): T | undefined { + * return this.cache.get(key); + * } + * + * has(key: K): boolean { + * return this.cache.has(key); + * } + * + * delete(key: K): boolean { + * return this.cache.delete(key); + * } + * + * clear(): void { + * this.cache.clear(); + * } + * + * get size(): number { + * return this.cache.size; + * } + * } + * const customCache = new CustomCache(); + * const memoizedSumWithCustomCache = memoize(sum, { cache: customCache }); + * console.log(memoizedSumWithCustomCache([1, 2])); // 3 + * console.log(memoizedSumWithCustomCache([1, 2])); // 3 (cached result) + * console.log(memoizedSumWithCustomCache.cache.size); // 1 + */ +declare function memoize any>(fn: F, options?: { + cache?: MemoizeCache>; + getCacheKey?: (args: Parameters[0]) => unknown; +}): F & { + cache: MemoizeCache>; +}; +/** + * Represents a cache for memoization, allowing storage and retrieval of computed values. + * + * @template K - The type of keys used to store values in the cache. + * @template V - The type of values stored in the cache. + */ +interface MemoizeCache { + /** + * Stores a value in the cache with the specified key. + * + * @param key - The key to associate with the value. + * @param value - The value to store in the cache. + */ + set(key: K, value: V): void; + /** + * Retrieves a value from the cache by its key. + * + * @param key - The key of the value to retrieve. + * @returns The value associated with the key, or undefined if the key does not exist. + */ + get(key: K): V | undefined; + /** + * Checks if a value exists in the cache for the specified key. + * + * @param key - The key to check for existence in the cache. + * @returns True if the cache contains the key, false otherwise. + */ + has(key: K): boolean; + /** + * Deletes a value from the cache by its key. + * + * @param key - The key of the value to delete. + * @returns True if the value was successfully deleted, false otherwise. + */ + delete(key: K): boolean | void; + /** + * Clears all values from the cache. + */ + clear(): void; + /** + * The number of entries in the cache. + */ + size: number; +} +//#endregion +export { MemoizeCache, memoize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/memoize.d.ts b/node_modules/es-toolkit/dist/function/memoize.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..894cb50121bd7a0d099b7630ee21cd93bf6c65ce --- /dev/null +++ b/node_modules/es-toolkit/dist/function/memoize.d.ts @@ -0,0 +1,125 @@ +//#region src/function/memoize.d.ts +/** + * Creates a memoized version of the provided function. The memoized function caches + * results based on the argument it receives, so if the same argument is passed again, + * it returns the cached result instead of recomputing it. + * + * This function works with functions that take zero or just one argument. If your function + * originally takes multiple arguments, you should refactor it to take a single object or array + * that combines those arguments. + * + * If the argument is not primitive (e.g., arrays or objects), provide a + * `getCacheKey` function to generate a unique cache key for proper caching. + * + * @template F - The type of the function to be memoized. + * @param fn - The function to be memoized. It should accept a single argument and return a value. + * @param [options={}] - Optional configuration for the memoization. + * @param [options.cache] - The cache object used to store results. Defaults to a new `Map`. + * @param [options.getCacheKey] - An optional function to generate a unique cache key for each argument. + * + * @returns The memoized function with an additional `cache` property that exposes the internal cache. + * + * @example + * // Example using the default cache + * const add = (x: number) => x + 10; + * const memoizedAdd = memoize(add); + * + * console.log(memoizedAdd(5)); // 15 + * console.log(memoizedAdd(5)); // 15 (cached result) + * console.log(memoizedAdd.cache.size); // 1 + * + * @example + * // Example using a custom resolver + * const sum = (arr: number[]) => arr.reduce((x, y) => x + y, 0); + * const memoizedSum = memoize(sum, { getCacheKey: (arr: number[]) => arr.join(',') }); + * console.log(memoizedSum([1, 2])); // 3 + * console.log(memoizedSum([1, 2])); // 3 (cached result) + * console.log(memoizedSum.cache.size); // 1 + * + * @example + * // Example using a custom cache implementation + * class CustomCache implements MemoizeCache { + * private cache = new Map(); + * + * set(key: K, value: T): void { + * this.cache.set(key, value); + * } + * + * get(key: K): T | undefined { + * return this.cache.get(key); + * } + * + * has(key: K): boolean { + * return this.cache.has(key); + * } + * + * delete(key: K): boolean { + * return this.cache.delete(key); + * } + * + * clear(): void { + * this.cache.clear(); + * } + * + * get size(): number { + * return this.cache.size; + * } + * } + * const customCache = new CustomCache(); + * const memoizedSumWithCustomCache = memoize(sum, { cache: customCache }); + * console.log(memoizedSumWithCustomCache([1, 2])); // 3 + * console.log(memoizedSumWithCustomCache([1, 2])); // 3 (cached result) + * console.log(memoizedSumWithCustomCache.cache.size); // 1 + */ +declare function memoize any>(fn: F, options?: { + cache?: MemoizeCache>; + getCacheKey?: (args: Parameters[0]) => unknown; +}): F & { + cache: MemoizeCache>; +}; +/** + * Represents a cache for memoization, allowing storage and retrieval of computed values. + * + * @template K - The type of keys used to store values in the cache. + * @template V - The type of values stored in the cache. + */ +interface MemoizeCache { + /** + * Stores a value in the cache with the specified key. + * + * @param key - The key to associate with the value. + * @param value - The value to store in the cache. + */ + set(key: K, value: V): void; + /** + * Retrieves a value from the cache by its key. + * + * @param key - The key of the value to retrieve. + * @returns The value associated with the key, or undefined if the key does not exist. + */ + get(key: K): V | undefined; + /** + * Checks if a value exists in the cache for the specified key. + * + * @param key - The key to check for existence in the cache. + * @returns True if the cache contains the key, false otherwise. + */ + has(key: K): boolean; + /** + * Deletes a value from the cache by its key. + * + * @param key - The key of the value to delete. + * @returns True if the value was successfully deleted, false otherwise. + */ + delete(key: K): boolean | void; + /** + * Clears all values from the cache. + */ + clear(): void; + /** + * The number of entries in the cache. + */ + size: number; +} +//#endregion +export { MemoizeCache, memoize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/memoize.js b/node_modules/es-toolkit/dist/function/memoize.js new file mode 100644 index 0000000000000000000000000000000000000000..cbd71475a183c9f85a3245b9832ec4ab0f64523c --- /dev/null +++ b/node_modules/es-toolkit/dist/function/memoize.js @@ -0,0 +1,87 @@ +//#region src/function/memoize.ts +/** +* Creates a memoized version of the provided function. The memoized function caches +* results based on the argument it receives, so if the same argument is passed again, +* it returns the cached result instead of recomputing it. +* +* This function works with functions that take zero or just one argument. If your function +* originally takes multiple arguments, you should refactor it to take a single object or array +* that combines those arguments. +* +* If the argument is not primitive (e.g., arrays or objects), provide a +* `getCacheKey` function to generate a unique cache key for proper caching. +* +* @template F - The type of the function to be memoized. +* @param fn - The function to be memoized. It should accept a single argument and return a value. +* @param [options={}] - Optional configuration for the memoization. +* @param [options.cache] - The cache object used to store results. Defaults to a new `Map`. +* @param [options.getCacheKey] - An optional function to generate a unique cache key for each argument. +* +* @returns The memoized function with an additional `cache` property that exposes the internal cache. +* +* @example +* // Example using the default cache +* const add = (x: number) => x + 10; +* const memoizedAdd = memoize(add); +* +* console.log(memoizedAdd(5)); // 15 +* console.log(memoizedAdd(5)); // 15 (cached result) +* console.log(memoizedAdd.cache.size); // 1 +* +* @example +* // Example using a custom resolver +* const sum = (arr: number[]) => arr.reduce((x, y) => x + y, 0); +* const memoizedSum = memoize(sum, { getCacheKey: (arr: number[]) => arr.join(',') }); +* console.log(memoizedSum([1, 2])); // 3 +* console.log(memoizedSum([1, 2])); // 3 (cached result) +* console.log(memoizedSum.cache.size); // 1 +* +* @example +* // Example using a custom cache implementation +* class CustomCache implements MemoizeCache { +* private cache = new Map(); +* +* set(key: K, value: T): void { +* this.cache.set(key, value); +* } +* +* get(key: K): T | undefined { +* return this.cache.get(key); +* } +* +* has(key: K): boolean { +* return this.cache.has(key); +* } +* +* delete(key: K): boolean { +* return this.cache.delete(key); +* } +* +* clear(): void { +* this.cache.clear(); +* } +* +* get size(): number { +* return this.cache.size; +* } +* } +* const customCache = new CustomCache(); +* const memoizedSumWithCustomCache = memoize(sum, { cache: customCache }); +* console.log(memoizedSumWithCustomCache([1, 2])); // 3 +* console.log(memoizedSumWithCustomCache([1, 2])); // 3 (cached result) +* console.log(memoizedSumWithCustomCache.cache.size); // 1 +*/ +function memoize(fn, options = {}) { + const { cache = /* @__PURE__ */ new Map(), getCacheKey } = options; + const memoizedFn = function(arg) { + const key = getCacheKey ? getCacheKey(arg) : arg; + if (cache.has(key)) return cache.get(key); + const result = fn.call(this, arg); + cache.set(key, result); + return result; + }; + memoizedFn.cache = cache; + return memoizedFn; +} +//#endregion +exports.memoize = memoize; diff --git a/node_modules/es-toolkit/dist/function/memoize.mjs b/node_modules/es-toolkit/dist/function/memoize.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c7bda864658f21d8f315610a76bb0201c1f5d967 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/memoize.mjs @@ -0,0 +1,87 @@ +//#region src/function/memoize.ts +/** +* Creates a memoized version of the provided function. The memoized function caches +* results based on the argument it receives, so if the same argument is passed again, +* it returns the cached result instead of recomputing it. +* +* This function works with functions that take zero or just one argument. If your function +* originally takes multiple arguments, you should refactor it to take a single object or array +* that combines those arguments. +* +* If the argument is not primitive (e.g., arrays or objects), provide a +* `getCacheKey` function to generate a unique cache key for proper caching. +* +* @template F - The type of the function to be memoized. +* @param fn - The function to be memoized. It should accept a single argument and return a value. +* @param [options={}] - Optional configuration for the memoization. +* @param [options.cache] - The cache object used to store results. Defaults to a new `Map`. +* @param [options.getCacheKey] - An optional function to generate a unique cache key for each argument. +* +* @returns The memoized function with an additional `cache` property that exposes the internal cache. +* +* @example +* // Example using the default cache +* const add = (x: number) => x + 10; +* const memoizedAdd = memoize(add); +* +* console.log(memoizedAdd(5)); // 15 +* console.log(memoizedAdd(5)); // 15 (cached result) +* console.log(memoizedAdd.cache.size); // 1 +* +* @example +* // Example using a custom resolver +* const sum = (arr: number[]) => arr.reduce((x, y) => x + y, 0); +* const memoizedSum = memoize(sum, { getCacheKey: (arr: number[]) => arr.join(',') }); +* console.log(memoizedSum([1, 2])); // 3 +* console.log(memoizedSum([1, 2])); // 3 (cached result) +* console.log(memoizedSum.cache.size); // 1 +* +* @example +* // Example using a custom cache implementation +* class CustomCache implements MemoizeCache { +* private cache = new Map(); +* +* set(key: K, value: T): void { +* this.cache.set(key, value); +* } +* +* get(key: K): T | undefined { +* return this.cache.get(key); +* } +* +* has(key: K): boolean { +* return this.cache.has(key); +* } +* +* delete(key: K): boolean { +* return this.cache.delete(key); +* } +* +* clear(): void { +* this.cache.clear(); +* } +* +* get size(): number { +* return this.cache.size; +* } +* } +* const customCache = new CustomCache(); +* const memoizedSumWithCustomCache = memoize(sum, { cache: customCache }); +* console.log(memoizedSumWithCustomCache([1, 2])); // 3 +* console.log(memoizedSumWithCustomCache([1, 2])); // 3 (cached result) +* console.log(memoizedSumWithCustomCache.cache.size); // 1 +*/ +function memoize(fn, options = {}) { + const { cache = /* @__PURE__ */ new Map(), getCacheKey } = options; + const memoizedFn = function(arg) { + const key = getCacheKey ? getCacheKey(arg) : arg; + if (cache.has(key)) return cache.get(key); + const result = fn.call(this, arg); + cache.set(key, result); + return result; + }; + memoizedFn.cache = cache; + return memoizedFn; +} +//#endregion +export { memoize }; diff --git a/node_modules/es-toolkit/dist/function/negate.d.mts b/node_modules/es-toolkit/dist/function/negate.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7accd008aed72119cc991a67ed00c7114cf58319 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/negate.d.mts @@ -0,0 +1,17 @@ +//#region src/function/negate.d.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] + */ +declare function negate boolean>(func: F): F; +//#endregion +export { negate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/negate.d.ts b/node_modules/es-toolkit/dist/function/negate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7accd008aed72119cc991a67ed00c7114cf58319 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/negate.d.ts @@ -0,0 +1,17 @@ +//#region src/function/negate.d.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] + */ +declare function negate boolean>(func: F): F; +//#endregion +export { negate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/negate.js b/node_modules/es-toolkit/dist/function/negate.js new file mode 100644 index 0000000000000000000000000000000000000000..459acd297168b838d5e2b2ae7c32ec75e3eb37fd --- /dev/null +++ b/node_modules/es-toolkit/dist/function/negate.js @@ -0,0 +1,19 @@ +//#region src/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) { + return ((...args) => !func(...args)); +} +//#endregion +exports.negate = negate; diff --git a/node_modules/es-toolkit/dist/function/negate.mjs b/node_modules/es-toolkit/dist/function/negate.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5c75b8dee50e0e099031421714f25eae9ceff6bc --- /dev/null +++ b/node_modules/es-toolkit/dist/function/negate.mjs @@ -0,0 +1,19 @@ +//#region src/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) { + return ((...args) => !func(...args)); +} +//#endregion +export { negate }; diff --git a/node_modules/es-toolkit/dist/function/noop.d.mts b/node_modules/es-toolkit/dist/function/noop.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e91be3518c7d63e808ed9e51b0b4b0808835e172 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/noop.d.mts @@ -0,0 +1,13 @@ +//#region src/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(): void; +//#endregion +export { noop }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/noop.d.ts b/node_modules/es-toolkit/dist/function/noop.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e91be3518c7d63e808ed9e51b0b4b0808835e172 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/noop.d.ts @@ -0,0 +1,13 @@ +//#region src/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(): void; +//#endregion +export { noop }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/noop.js b/node_modules/es-toolkit/dist/function/noop.js new file mode 100644 index 0000000000000000000000000000000000000000..06abdbe64968967e843381b46d94741b97c055f4 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/noop.js @@ -0,0 +1,13 @@ +//#region src/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/function/noop.mjs b/node_modules/es-toolkit/dist/function/noop.mjs new file mode 100644 index 0000000000000000000000000000000000000000..070e87190c0523762e72302261cf36affd3409f0 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/noop.mjs @@ -0,0 +1,13 @@ +//#region src/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/function/once.d.mts b/node_modules/es-toolkit/dist/function/once.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4a7ad94da64d46fd727be7382412a268347b3c1e --- /dev/null +++ b/node_modules/es-toolkit/dist/function/once.d.mts @@ -0,0 +1,18 @@ +//#region src/function/once.d.ts +/** + * Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. + * + * @template F - The type of the function. + * @param func - The function to restrict. + * @returns Returns the new restricted function. + * + * @example + * const initialize = once(createApplication); + * + * initialize(); + * initialize(); + * // => `createApplication` is invoked once + */ +declare function once any>(func: F): F; +//#endregion +export { once }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/once.d.ts b/node_modules/es-toolkit/dist/function/once.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4a7ad94da64d46fd727be7382412a268347b3c1e --- /dev/null +++ b/node_modules/es-toolkit/dist/function/once.d.ts @@ -0,0 +1,18 @@ +//#region src/function/once.d.ts +/** + * Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. + * + * @template F - The type of the function. + * @param func - The function to restrict. + * @returns Returns the new restricted function. + * + * @example + * const initialize = once(createApplication); + * + * initialize(); + * initialize(); + * // => `createApplication` is invoked once + */ +declare function once any>(func: F): F; +//#endregion +export { once }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/once.js b/node_modules/es-toolkit/dist/function/once.js new file mode 100644 index 0000000000000000000000000000000000000000..1b6870204a03978bb157b47a406ea91ad127b7d6 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/once.js @@ -0,0 +1,31 @@ +//#region src/function/once.ts +/** +* Creates a function that is restricted to invoking the provided function `func` once. +* Repeated calls to the function will return the value from the first invocation. +* +* @template F - The type of function. +* @param func - The function to restrict. +* @returns A new function that invokes `func` once and caches the result. +* +* @example +* const initialize = once(() => { +* console.log('Initialized!'); +* return true; +* }); +* +* initialize(); // Logs: 'Initialized!' and returns true +* initialize(); // Returns true without logging +*/ +function once(func) { + let called = false; + let cache; + return function(...args) { + if (!called) { + called = true; + cache = func(...args); + } + return cache; + }; +} +//#endregion +exports.once = once; diff --git a/node_modules/es-toolkit/dist/function/once.mjs b/node_modules/es-toolkit/dist/function/once.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a620eaa2548d7081ea2788167a20dbc245a71cfe --- /dev/null +++ b/node_modules/es-toolkit/dist/function/once.mjs @@ -0,0 +1,31 @@ +//#region src/function/once.ts +/** +* Creates a function that is restricted to invoking the provided function `func` once. +* Repeated calls to the function will return the value from the first invocation. +* +* @template F - The type of function. +* @param func - The function to restrict. +* @returns A new function that invokes `func` once and caches the result. +* +* @example +* const initialize = once(() => { +* console.log('Initialized!'); +* return true; +* }); +* +* initialize(); // Logs: 'Initialized!' and returns true +* initialize(); // Returns true without logging +*/ +function once(func) { + let called = false; + let cache; + return function(...args) { + if (!called) { + called = true; + cache = func(...args); + } + return cache; + }; +} +//#endregion +export { once }; diff --git a/node_modules/es-toolkit/dist/function/partial.d.mts b/node_modules/es-toolkit/dist/function/partial.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4f5f56c200f30e9f2b8ebdafa1d72277e8c9fe7b --- /dev/null +++ b/node_modules/es-toolkit/dist/function/partial.d.mts @@ -0,0 +1,622 @@ +//#region src/function/partial.d.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 T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply. + * @param arg1 The first argument to apply. + * @returns A new function that takes no arguments and returns the result of the original function. + * + * @example + * const addOne = (x: number) => x + 1; + * const addOneToFive = partial(addOne, 5); + * console.log(addOneToFive()); // => 6 + */ +declare function partial(func: (arg1: T1) => R, arg1: 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. + * + * 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 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 apply. + * @returns A new function that takes the second argument and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number) => x * y; + * const double = partial(multiply, 2); + * console.log(double(5)); // => 10 + */ +declare function partial(func: (arg1: T1, arg2: T2) => R, arg1: T1): (arg2: 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. + * + * 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 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 placeholder The placeholder for the first argument. + * @param arg2 The second argument to apply. + * @returns A new function that takes the first argument and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const greetWithHello = partial(greet, partial.placeholder, 'John'); + * console.log(greetWithHello('Hello')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2) => R, placeholder: Placeholder, arg2: T2): (arg1: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @returns A new function that takes no arguments and returns the result of the original function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const addThree = partial(add, 1, 2); + * console.log(addThree()); // => 3 + */ +declare function partial(func: (arg1: T1, arg2: T2) => R, arg1: T1, arg2: 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. + * + * 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 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 apply. + * @returns A new function that takes the second and third arguments and returns the result of the original function. + * + * @example + * const sumThree = (a: number, b: number, c: number) => a + b + c; + * const addFive = partial(sumThree, 5); + * console.log(addFive(3, 2)); // => 10 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1): (arg2: T2, arg3: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The second argument to apply. + * @returns A new function that takes the first and third arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const greetWithPlaceholder = partial(greet, partial.placeholder, 'John'); + * console.log(greetWithPlaceholder('Hello')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: Placeholder, arg2: T2): (arg1: T1, arg3: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @returns A new function that takes the first and second arguments and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number) => x * y * z; + * const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2); + * console.log(multiplyWithPlaceholders(3, 4)); // => 24 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3): (arg1: T1, arg2: 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. + * + * 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 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 apply. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @returns A new function that takes the second argument and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder); + * console.log(greetWithPlaceholder('John')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: 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. + * + * 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 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 apply. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @returns A new function that takes the second argument and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder); + * console.log(greetWithPlaceholder('John')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, plc1: Placeholder, arg2: T2, arg3: T3): (arg1: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @returns A new function that takes no arguments and returns the result of the original function. + * + * @example + * const sum = (a: number, b: number, c: number) => a + b + c; + * const sumAll = partial(sum, 1, 2, 3); + * console.log(sumAll()); // => 6 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: 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. + * + * 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 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 apply. + * @returns A new function that takes the second argument and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w; + * const double = partial(multiply, 2); + * console.log(double(5, 4, 3)); // => 120 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1): (arg2: T2, arg3: T3, arg4: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first and second arguments and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w; + * const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2, 3); + * console.log(multiplyWithPlaceholders(4, 5)); // => 120 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3, arg4: T4): (arg1: T1, arg2: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @returns A new function that takes the third and fourth arguments and returns the result of the original function. + * + * @example + * const sumFour = (a: number, b: number, c: number, d: number) => a + b + c + d; + * const addOneAndTwo = partial(sumFour, 1, 2); + * console.log(addOneAndTwo(3, 4)); // => 10 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2): (arg3: T3, arg4: 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. + * + * 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 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 apply. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the second and fourth arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`; + * const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder, '!'); + * console.log(greetWithPlaceholder('John')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: T2, arg4: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first and third arguments and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w; + * const multiplyWithPlaceholder = partial(multiply, partial.placeholder, 2, 3); + * console.log(multiplyWithPlaceholder(4)); // => 24 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: T3): (arg1: T1, arg4: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The second argument to apply. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first and third arguments and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: Placeholder, arg4: T4): (arg1: T1, arg3: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first and second arguments and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w; + * const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2, 3); + * console.log(multiplyWithPlaceholders(4, 5)); // => 120 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3, arg4: T4): (arg1: T1, arg2: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @returns A new function that takes the fourth argument and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3): (arg4: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the third argument and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: Placeholder, arg4: T4): (arg3: 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. + * + * 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 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 apply. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the second argument and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3, arg4: T4): (arg2: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first argument and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: T3, arg4: T4): (arg1: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes no arguments and returns the result of the original function. + * + * @example + * const sumFour = (a: number, b: number, c: number, d: number) => a + b + c + d; + * const sumAll = partial(sumFour, 1, 2, 3, 4); + * console.log(sumAll()); // => 10 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3, arg4: 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. + * + * 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 TS The types of the arguments. + * @template R The return type of the function. + * @param func The function to partially apply. + * @returns A new function that takes the same arguments as the original function. + * + * @example + * const add = (...numbers: number[]) => numbers.reduce((sum, n) => sum + n, 0); + * const addFive = partial(add, 5); + * console.log(addFive(1, 2, 3)); // => 11 + */ +declare function partial(func: (...args: TS) => R): (...args: 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. + * + * 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 TS The types of the arguments. + * @template T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply. + * @param arg1 The first argument to apply. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, ...names: string[]) => `${greeting}, ${names.join(', ')}!`; + * const greetHello = partial(greet, 'Hello'); + * console.log(greetHello('Alice', 'Bob')); // => 'Hello, Alice, Bob!' + */ +declare function partial(func: (arg1: T1, ...args: TS) => R, arg1: T1): (...args: 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. + * + * 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 TS The types of the 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. + * @param arg1 The first argument to apply. + * @param arg2 The second argument to apply. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`; + * const greetWithHello = partial(greet, 'Hello', '!'); + * console.log(greetWithHello('John')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, ...args: TS) => R, t1: T1, arg2: T2): (...args: 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. + * + * 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 TS The types of the 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. + * @param t1 The first argument to apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`; + * const greetWithHello = partial(greet, 'Hello', 'John', '!'); + * console.log(greetWithHello()); // => 'Hello, John!' + */ +declare function partial(func: (t1: T1, arg2: T2, arg3: T3, ...args: TS) => R, t1: T1, arg2: T2, arg3: T3): (...args: 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. + * + * 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 TS The types of the 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. + * @param t1 The first argument to apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`; + * const greetWithHello = partial(greet, 'Hello', 'John', '!'); + * console.log(greetWithHello()); // => 'Hello, John!' + */ +declare function partial(func: (t1: T1, arg2: T2, arg3: T3, arg4: T4, ...args: TS) => R, t1: T1, arg2: T2, arg3: T3, arg4: T4): (...args: 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. + * + * 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. + * @param partialArgs The arguments to be partially applied. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const add = (...numbers: number[]) => numbers.reduce((sum, n) => sum + n, 0); + * const addFive = partial(add, 5); + * console.log(addFive(1, 2, 3)); // => 11 + */ +declare function partial any>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; +declare namespace partial { + var placeholder: typeof placeholderSymbol; +} +declare function partialImpl any, P>(func: F, placeholder: P, ...partialArgs: any[]): (...args: any[]) => ReturnType; +declare const placeholderSymbol: unique symbol; +type Placeholder = typeof placeholderSymbol; +//#endregion +export { partial }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/partial.d.ts b/node_modules/es-toolkit/dist/function/partial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f5f56c200f30e9f2b8ebdafa1d72277e8c9fe7b --- /dev/null +++ b/node_modules/es-toolkit/dist/function/partial.d.ts @@ -0,0 +1,622 @@ +//#region src/function/partial.d.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 T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply. + * @param arg1 The first argument to apply. + * @returns A new function that takes no arguments and returns the result of the original function. + * + * @example + * const addOne = (x: number) => x + 1; + * const addOneToFive = partial(addOne, 5); + * console.log(addOneToFive()); // => 6 + */ +declare function partial(func: (arg1: T1) => R, arg1: 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. + * + * 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 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 apply. + * @returns A new function that takes the second argument and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number) => x * y; + * const double = partial(multiply, 2); + * console.log(double(5)); // => 10 + */ +declare function partial(func: (arg1: T1, arg2: T2) => R, arg1: T1): (arg2: 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. + * + * 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 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 placeholder The placeholder for the first argument. + * @param arg2 The second argument to apply. + * @returns A new function that takes the first argument and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const greetWithHello = partial(greet, partial.placeholder, 'John'); + * console.log(greetWithHello('Hello')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2) => R, placeholder: Placeholder, arg2: T2): (arg1: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @returns A new function that takes no arguments and returns the result of the original function. + * + * @example + * const add = (x: number, y: number) => x + y; + * const addThree = partial(add, 1, 2); + * console.log(addThree()); // => 3 + */ +declare function partial(func: (arg1: T1, arg2: T2) => R, arg1: T1, arg2: 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. + * + * 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 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 apply. + * @returns A new function that takes the second and third arguments and returns the result of the original function. + * + * @example + * const sumThree = (a: number, b: number, c: number) => a + b + c; + * const addFive = partial(sumThree, 5); + * console.log(addFive(3, 2)); // => 10 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1): (arg2: T2, arg3: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The second argument to apply. + * @returns A new function that takes the first and third arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const greetWithPlaceholder = partial(greet, partial.placeholder, 'John'); + * console.log(greetWithPlaceholder('Hello')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: Placeholder, arg2: T2): (arg1: T1, arg3: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @returns A new function that takes the first and second arguments and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number) => x * y * z; + * const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2); + * console.log(multiplyWithPlaceholders(3, 4)); // => 24 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3): (arg1: T1, arg2: 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. + * + * 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 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 apply. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @returns A new function that takes the second argument and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder); + * console.log(greetWithPlaceholder('John')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: 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. + * + * 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 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 apply. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @returns A new function that takes the second argument and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`; + * const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder); + * console.log(greetWithPlaceholder('John')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, plc1: Placeholder, arg2: T2, arg3: T3): (arg1: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @returns A new function that takes no arguments and returns the result of the original function. + * + * @example + * const sum = (a: number, b: number, c: number) => a + b + c; + * const sumAll = partial(sum, 1, 2, 3); + * console.log(sumAll()); // => 6 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: 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. + * + * 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 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 apply. + * @returns A new function that takes the second argument and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w; + * const double = partial(multiply, 2); + * console.log(double(5, 4, 3)); // => 120 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1): (arg2: T2, arg3: T3, arg4: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first and second arguments and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w; + * const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2, 3); + * console.log(multiplyWithPlaceholders(4, 5)); // => 120 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3, arg4: T4): (arg1: T1, arg2: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @returns A new function that takes the third and fourth arguments and returns the result of the original function. + * + * @example + * const sumFour = (a: number, b: number, c: number, d: number) => a + b + c + d; + * const addOneAndTwo = partial(sumFour, 1, 2); + * console.log(addOneAndTwo(3, 4)); // => 10 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2): (arg3: T3, arg4: 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. + * + * 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 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 apply. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the second and fourth arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`; + * const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder, '!'); + * console.log(greetWithPlaceholder('John')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: T2, arg4: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first and third arguments and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w; + * const multiplyWithPlaceholder = partial(multiply, partial.placeholder, 2, 3); + * console.log(multiplyWithPlaceholder(4)); // => 24 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: T3): (arg1: T1, arg4: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The second argument to apply. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first and third arguments and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: Placeholder, arg4: T4): (arg1: T1, arg3: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first and second arguments and returns the result of the original function. + * + * @example + * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w; + * const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2, 3); + * console.log(multiplyWithPlaceholders(4, 5)); // => 120 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3, arg4: T4): (arg1: T1, arg2: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @returns A new function that takes the fourth argument and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3): (arg4: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the third argument and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: Placeholder, arg4: T4): (arg3: 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. + * + * 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 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 apply. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the second argument and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3, arg4: T4): (arg2: 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. + * + * 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 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 placeholder for the first argument. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the first argument and returns the result of the original function. + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: T3, arg4: T4): (arg1: 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. + * + * 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 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 apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes no arguments and returns the result of the original function. + * + * @example + * const sumFour = (a: number, b: number, c: number, d: number) => a + b + c + d; + * const sumAll = partial(sumFour, 1, 2, 3, 4); + * console.log(sumAll()); // => 10 + */ +declare function partial(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3, arg4: 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. + * + * 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 TS The types of the arguments. + * @template R The return type of the function. + * @param func The function to partially apply. + * @returns A new function that takes the same arguments as the original function. + * + * @example + * const add = (...numbers: number[]) => numbers.reduce((sum, n) => sum + n, 0); + * const addFive = partial(add, 5); + * console.log(addFive(1, 2, 3)); // => 11 + */ +declare function partial(func: (...args: TS) => R): (...args: 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. + * + * 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 TS The types of the arguments. + * @template T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply. + * @param arg1 The first argument to apply. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, ...names: string[]) => `${greeting}, ${names.join(', ')}!`; + * const greetHello = partial(greet, 'Hello'); + * console.log(greetHello('Alice', 'Bob')); // => 'Hello, Alice, Bob!' + */ +declare function partial(func: (arg1: T1, ...args: TS) => R, arg1: T1): (...args: 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. + * + * 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 TS The types of the 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. + * @param arg1 The first argument to apply. + * @param arg2 The second argument to apply. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`; + * const greetWithHello = partial(greet, 'Hello', '!'); + * console.log(greetWithHello('John')); // => 'Hello, John!' + */ +declare function partial(func: (arg1: T1, arg2: T2, ...args: TS) => R, t1: T1, arg2: T2): (...args: 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. + * + * 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 TS The types of the 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. + * @param t1 The first argument to apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`; + * const greetWithHello = partial(greet, 'Hello', 'John', '!'); + * console.log(greetWithHello()); // => 'Hello, John!' + */ +declare function partial(func: (t1: T1, arg2: T2, arg3: T3, ...args: TS) => R, t1: T1, arg2: T2, arg3: T3): (...args: 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. + * + * 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 TS The types of the 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. + * @param t1 The first argument to apply. + * @param arg2 The second argument to apply. + * @param arg3 The third argument to apply. + * @param arg4 The fourth argument to apply. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`; + * const greetWithHello = partial(greet, 'Hello', 'John', '!'); + * console.log(greetWithHello()); // => 'Hello, John!' + */ +declare function partial(func: (t1: T1, arg2: T2, arg3: T3, arg4: T4, ...args: TS) => R, t1: T1, arg2: T2, arg3: T3, arg4: T4): (...args: 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. + * + * 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. + * @param partialArgs The arguments to be partially applied. + * @returns A new function that takes the remaining arguments and returns the result of the original function. + * + * @example + * const add = (...numbers: number[]) => numbers.reduce((sum, n) => sum + n, 0); + * const addFive = partial(add, 5); + * console.log(addFive(1, 2, 3)); // => 11 + */ +declare function partial any>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType; +declare namespace partial { + var placeholder: typeof placeholderSymbol; +} +declare function partialImpl any, P>(func: F, placeholder: P, ...partialArgs: any[]): (...args: any[]) => ReturnType; +declare const placeholderSymbol: unique symbol; +type Placeholder = typeof placeholderSymbol; +//#endregion +export { partial }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/partial.js b/node_modules/es-toolkit/dist/function/partial.js new file mode 100644 index 0000000000000000000000000000000000000000..0a15eae9085b268a90a3b077ed6622e70fb61dd8 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/partial.js @@ -0,0 +1,45 @@ +//#region src/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, placeholderSymbol, ...partialArgs); +} +function partialImpl(func, placeholder, ...partialArgs) { + const partialed = function(...providedArgs) { + let providedArgsIndex = 0; + const substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg); + const remainingArgs = providedArgs.slice(providedArgsIndex); + return func.apply(this, substitutedArgs.concat(remainingArgs)); + }; + if (func.prototype) partialed.prototype = Object.create(func.prototype); + return partialed; +} +const placeholderSymbol = Symbol("partial.placeholder"); +partial.placeholder = placeholderSymbol; +//#endregion +exports.partial = partial; +exports.partialImpl = partialImpl; diff --git a/node_modules/es-toolkit/dist/function/partial.mjs b/node_modules/es-toolkit/dist/function/partial.mjs new file mode 100644 index 0000000000000000000000000000000000000000..284926a4c44b3ce087bfada3501e008632a85c90 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/partial.mjs @@ -0,0 +1,44 @@ +//#region src/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, placeholderSymbol, ...partialArgs); +} +function partialImpl(func, placeholder, ...partialArgs) { + const partialed = function(...providedArgs) { + let providedArgsIndex = 0; + const substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg); + const remainingArgs = providedArgs.slice(providedArgsIndex); + return func.apply(this, substitutedArgs.concat(remainingArgs)); + }; + if (func.prototype) partialed.prototype = Object.create(func.prototype); + return partialed; +} +const placeholderSymbol = Symbol("partial.placeholder"); +partial.placeholder = placeholderSymbol; +//#endregion +export { partial, partialImpl }; diff --git a/node_modules/es-toolkit/dist/function/partialRight.d.mts b/node_modules/es-toolkit/dist/function/partialRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..46bb0480a666861ee4a22d0f49245aa77c0b2f05 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/partialRight.d.mts @@ -0,0 +1,630 @@ +//#region src/function/partialRight.d.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 R The return type of the function. + * @param func The function to invoke. + * @returns Returns the new function. + * @example + * const getValue = () => 42; + * const getValueFunc = partialRight(getValue); + * console.log(getValueFunc()); // => 42 + */ +declare function partialRight(func: () => R): () => R; +/** + * 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 T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply arguments to. + * @param arg1 The first argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const addOne = (num: number) => num + 1; + * const addOneFunc = partialRight(addOne, 1); + * console.log(addOneFunc()); // => 2 + */ +declare function partialRight(func: (arg1: T1) => R, arg1: T1): () => R; +/** + * 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 T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply arguments to. + * @returns Returns the new partially applied function. + * @example + * const multiplyBy = (factor: number) => (num: number) => num * factor; + * const double = partialRight(multiplyBy(2)); + * console.log(double(5)); // => 10 + */ +declare function partialRight(func: (arg1: T1) => R): (arg1: T1) => R; +/** + * 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 T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply arguments to. + * @param arg1 The first argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const greet = (name: string) => `Hello, ${name}!`; + * const greetJohn = partialRight(greet, 'John'); + * console.log(greetJohn()); // => 'Hello, John!' + */ +declare function partialRight(func: (arg1: T1) => R, arg1: T1): () => R; +/** + * 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 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 arguments to. + * @returns Returns the new partially applied function. + * @example + * const subtract = (a: number, b: number) => a - b; + * const subtractFive = partialRight(subtract); + * console.log(subtractFive(10, 5)); // => 5 + */ +declare function partialRight(func: (arg1: T1, arg2: T2) => R): (arg1: T1, arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @returns Returns the new partially applied function. + * @example + * const concat = (a: string, b: string) => a + b; + * const concatWithHello = partialRight(concat, 'Hello', partialRight.placeholder); + * console.log(concatWithHello(' World!')); // => 'Hello World!' + */ +declare function partialRight(func: (arg1: T1, arg2: T2) => R, arg1: T1, arg2: Placeholder): (arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const divide = (a: number, b: number) => a / b; + * const divideByTwo = partialRight(divide, 2); + * console.log(divideByTwo(10)); // => 5 + */ +declare function partialRight(func: (arg1: T1, arg2: T2) => R, arg2: T2): (arg1: T1) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const multiply = (a: number, b: number) => a * b; + * const multiplyByThreeAndFour = partialRight(multiply, 3, 4); + * console.log(multiplyByThreeAndFour()); // => 12 + */ +declare function partialRight(func: (arg1: T1, arg2: T2) => R, arg1: T1, arg2: T2): () => R; +/** + * 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 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 arguments to. + * @returns Returns the new partially applied function. + * @example + * const sumThree = (a: number, b: number, c: number) => a + b + c; + * const sumWithFive = partialRight(sumThree); + * console.log(sumWithFive(1, 2, 5)); // => 8 + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R): (arg1: T1, arg2: T2, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The placeholder for the third argument. + * @returns Returns the new partially applied function. + * @example + * const formatDate = (day: number, month: number, year: number) => `${day}/${month}/${year}`; + * const formatDateWithDay = partialRight(formatDate, 1, partialRight.placeholder, partialRight.placeholder); + * console.log(formatDateWithDay(12, 2023)); // => '1/12/2023' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: Placeholder, arg3: Placeholder): (arg2: T2, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @returns Returns the new partially applied function. + * @example + * const createUser = (name: string, age: number, country: string) => `${name}, ${age} years old from ${country}`; + * const createUserFromUSA = partialRight(createUser, 'USA', partialRight.placeholder); + * console.log(createUserFromUSA('John', 30)); // => 'John, 30 years old from USA' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg2: T2, arg3: Placeholder): (arg1: T1, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @returns Returns the new partially applied function. + * @example + * const logMessage = (level: string, message: string, timestamp: string) => `[${level}] ${message} at ${timestamp}`; + * const logError = partialRight(logMessage, 'ERROR', '2023-10-01'); + * console.log(logError('Something went wrong!')); // => '[ERROR] Something went wrong! at 2023-10-01' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: Placeholder): (arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg3 The third argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const calculateArea = (length: number, width: number) => length * width; + * const calculateAreaWithWidth = partialRight(calculateArea, 5); + * console.log(calculateAreaWithWidth(10)); // => 50 + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg3: T3): (arg1: T1, arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const formatCurrency = (amount: number, currency: string) => `${amount} ${currency}`; + * const formatUSD = partialRight(formatCurrency, 100, partialRight.placeholder); + * console.log(formatUSD('USD')); // => '100 USD' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const createProfile = (name: string, age: number, country: string) => `${name}, ${age} from ${country}`; + * const createProfileFromCanada = partialRight(createProfile, 'Canada', 'John'); + * console.log(createProfileFromCanada(30)); // => 'John, 30 from Canada' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg2: T2, arg3: T3): (arg1: T1) => R; +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: T3): () => R; +/** + * 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 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 arguments to. + * @returns Returns a new function that takes four arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The placeholder for the third argument. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the second, third, and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: Placeholder, arg4: Placeholder): (arg2: T2, arg3: T3, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the first, third, and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg2: T2, arg3: Placeholder, arg4: Placeholder): (arg1: T1, arg3: T3, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the third and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: Placeholder, arg4: Placeholder): (arg3: T3, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg3 The third argument to be partially applied. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the first, second, and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg3: T3, arg4: Placeholder): (arg1: T1, arg2: T2, arg4: T4) => R; +/** + * Creates a function that invokes `func` with the first argument, a placeholder for the second argument, + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to be partially applied. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the second and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3, arg4: Placeholder): (arg2: T2, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the first and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg2: T2, arg3: T3, arg4: Placeholder): (arg1: T1, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the fourth argument. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3, arg4: Placeholder): (arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the first, second, and third arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg4: T4): (arg1: T1, arg2: T2, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the second and third arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: Placeholder, arg4: T4): (arg2: T2, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the first and third arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg2: T2, arg3: Placeholder, arg4: T4): (arg1: T1, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the third argument. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: Placeholder, arg4: T4): (arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg3 The third argument to be partially applied. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the first and second arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg3: T3, arg4: T4): (arg1: T1, arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to be partially applied. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the second argument. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3, arg4: T4): (arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the first argument. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg2: T2, arg3: T3, arg4: T4): (arg1: T1) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const concatenate = (a: string, b: string, c: string, d: string) => a + b + c + d; + * const concatenateHelloWorld = partialRight(concatenate, 'Hello', ' ', 'World', '!'); + * console.log(concatenateHelloWorld()); // => 'Hello World!' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3, arg4: T4): () => R; +/** + * 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 args The arguments to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const log = (...messages: string[]) => console.log(...messages); + * const logError = partialRight(log, 'Error:'); + * logError('Something went wrong!'); // => 'Error: Something went wrong!' + */ +declare function partialRight(func: (...args: any[]) => any, ...args: any[]): (...args: any[]) => any; +declare namespace partialRight { + var placeholder: typeof placeholderSymbol; +} +declare function partialRightImpl any, P>(func: F, placeholder: P, ...partialArgs: any[]): (...args: any[]) => ReturnType; +declare const placeholderSymbol: unique symbol; +type Placeholder = typeof placeholderSymbol; +//#endregion +export { partialRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/partialRight.d.ts b/node_modules/es-toolkit/dist/function/partialRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..46bb0480a666861ee4a22d0f49245aa77c0b2f05 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/partialRight.d.ts @@ -0,0 +1,630 @@ +//#region src/function/partialRight.d.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 R The return type of the function. + * @param func The function to invoke. + * @returns Returns the new function. + * @example + * const getValue = () => 42; + * const getValueFunc = partialRight(getValue); + * console.log(getValueFunc()); // => 42 + */ +declare function partialRight(func: () => R): () => R; +/** + * 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 T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply arguments to. + * @param arg1 The first argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const addOne = (num: number) => num + 1; + * const addOneFunc = partialRight(addOne, 1); + * console.log(addOneFunc()); // => 2 + */ +declare function partialRight(func: (arg1: T1) => R, arg1: T1): () => R; +/** + * 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 T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply arguments to. + * @returns Returns the new partially applied function. + * @example + * const multiplyBy = (factor: number) => (num: number) => num * factor; + * const double = partialRight(multiplyBy(2)); + * console.log(double(5)); // => 10 + */ +declare function partialRight(func: (arg1: T1) => R): (arg1: T1) => R; +/** + * 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 T1 The type of the first argument. + * @template R The return type of the function. + * @param func The function to partially apply arguments to. + * @param arg1 The first argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const greet = (name: string) => `Hello, ${name}!`; + * const greetJohn = partialRight(greet, 'John'); + * console.log(greetJohn()); // => 'Hello, John!' + */ +declare function partialRight(func: (arg1: T1) => R, arg1: T1): () => R; +/** + * 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 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 arguments to. + * @returns Returns the new partially applied function. + * @example + * const subtract = (a: number, b: number) => a - b; + * const subtractFive = partialRight(subtract); + * console.log(subtractFive(10, 5)); // => 5 + */ +declare function partialRight(func: (arg1: T1, arg2: T2) => R): (arg1: T1, arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @returns Returns the new partially applied function. + * @example + * const concat = (a: string, b: string) => a + b; + * const concatWithHello = partialRight(concat, 'Hello', partialRight.placeholder); + * console.log(concatWithHello(' World!')); // => 'Hello World!' + */ +declare function partialRight(func: (arg1: T1, arg2: T2) => R, arg1: T1, arg2: Placeholder): (arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const divide = (a: number, b: number) => a / b; + * const divideByTwo = partialRight(divide, 2); + * console.log(divideByTwo(10)); // => 5 + */ +declare function partialRight(func: (arg1: T1, arg2: T2) => R, arg2: T2): (arg1: T1) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const multiply = (a: number, b: number) => a * b; + * const multiplyByThreeAndFour = partialRight(multiply, 3, 4); + * console.log(multiplyByThreeAndFour()); // => 12 + */ +declare function partialRight(func: (arg1: T1, arg2: T2) => R, arg1: T1, arg2: T2): () => R; +/** + * 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 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 arguments to. + * @returns Returns the new partially applied function. + * @example + * const sumThree = (a: number, b: number, c: number) => a + b + c; + * const sumWithFive = partialRight(sumThree); + * console.log(sumWithFive(1, 2, 5)); // => 8 + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R): (arg1: T1, arg2: T2, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The placeholder for the third argument. + * @returns Returns the new partially applied function. + * @example + * const formatDate = (day: number, month: number, year: number) => `${day}/${month}/${year}`; + * const formatDateWithDay = partialRight(formatDate, 1, partialRight.placeholder, partialRight.placeholder); + * console.log(formatDateWithDay(12, 2023)); // => '1/12/2023' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: Placeholder, arg3: Placeholder): (arg2: T2, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @returns Returns the new partially applied function. + * @example + * const createUser = (name: string, age: number, country: string) => `${name}, ${age} years old from ${country}`; + * const createUserFromUSA = partialRight(createUser, 'USA', partialRight.placeholder); + * console.log(createUserFromUSA('John', 30)); // => 'John, 30 years old from USA' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg2: T2, arg3: Placeholder): (arg1: T1, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @returns Returns the new partially applied function. + * @example + * const logMessage = (level: string, message: string, timestamp: string) => `[${level}] ${message} at ${timestamp}`; + * const logError = partialRight(logMessage, 'ERROR', '2023-10-01'); + * console.log(logError('Something went wrong!')); // => '[ERROR] Something went wrong! at 2023-10-01' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: Placeholder): (arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg3 The third argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const calculateArea = (length: number, width: number) => length * width; + * const calculateAreaWithWidth = partialRight(calculateArea, 5); + * console.log(calculateAreaWithWidth(10)); // => 50 + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg3: T3): (arg1: T1, arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const formatCurrency = (amount: number, currency: string) => `${amount} ${currency}`; + * const formatUSD = partialRight(formatCurrency, 100, partialRight.placeholder); + * console.log(formatUSD('USD')); // => '100 USD' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const createProfile = (name: string, age: number, country: string) => `${name}, ${age} from ${country}`; + * const createProfileFromCanada = partialRight(createProfile, 'Canada', 'John'); + * console.log(createProfileFromCanada(30)); // => 'John, 30 from Canada' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg2: T2, arg3: T3): (arg1: T1) => R; +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: T3): () => R; +/** + * 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 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 arguments to. + * @returns Returns a new function that takes four arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The placeholder for the third argument. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the second, third, and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: Placeholder, arg4: Placeholder): (arg2: T2, arg3: T3, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the first, third, and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg2: T2, arg3: Placeholder, arg4: Placeholder): (arg1: T1, arg3: T3, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the third and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: Placeholder, arg4: Placeholder): (arg3: T3, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg3 The third argument to be partially applied. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the first, second, and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg3: T3, arg4: Placeholder): (arg1: T1, arg2: T2, arg4: T4) => R; +/** + * Creates a function that invokes `func` with the first argument, a placeholder for the second argument, + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to be partially applied. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the second and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3, arg4: Placeholder): (arg2: T2, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the first and fourth arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg2: T2, arg3: T3, arg4: Placeholder): (arg1: T1, arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @param arg4 The placeholder for the fourth argument. + * @returns Returns a new function that takes the fourth argument. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3, arg4: Placeholder): (arg4: T4) => R; +/** + * 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 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 arguments to. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the first, second, and third arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg4: T4): (arg1: T1, arg2: T2, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the second and third arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: Placeholder, arg4: T4): (arg2: T2, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the first and third arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg2: T2, arg3: Placeholder, arg4: T4): (arg1: T1, arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The placeholder for the third argument. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the third argument. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: Placeholder, arg4: T4): (arg3: T3) => R; +/** + * 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 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 arguments to. + * @param arg3 The third argument to be partially applied. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the first and second arguments. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg3: T3, arg4: T4): (arg1: T1, arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The placeholder for the second argument. + * @param arg3 The third argument to be partially applied. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the second argument. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3, arg4: T4): (arg2: T2) => R; +/** + * 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 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 arguments to. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns a new function that takes the first argument. + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg2: T2, arg3: T3, arg4: T4): (arg1: T1) => R; +/** + * 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 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 arguments to. + * @param arg1 The first argument to be partially applied. + * @param arg2 The second argument to be partially applied. + * @param arg3 The third argument to be partially applied. + * @param arg4 The fourth argument to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const concatenate = (a: string, b: string, c: string, d: string) => a + b + c + d; + * const concatenateHelloWorld = partialRight(concatenate, 'Hello', ' ', 'World', '!'); + * console.log(concatenateHelloWorld()); // => 'Hello World!' + */ +declare function partialRight(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3, arg4: T4): () => R; +/** + * 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 args The arguments to be partially applied. + * @returns Returns the new partially applied function. + * @example + * const log = (...messages: string[]) => console.log(...messages); + * const logError = partialRight(log, 'Error:'); + * logError('Something went wrong!'); // => 'Error: Something went wrong!' + */ +declare function partialRight(func: (...args: any[]) => any, ...args: any[]): (...args: any[]) => any; +declare namespace partialRight { + var placeholder: typeof placeholderSymbol; +} +declare function partialRightImpl any, P>(func: F, placeholder: P, ...partialArgs: any[]): (...args: any[]) => ReturnType; +declare const placeholderSymbol: unique symbol; +type Placeholder = typeof placeholderSymbol; +//#endregion +export { partialRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/partialRight.js b/node_modules/es-toolkit/dist/function/partialRight.js new file mode 100644 index 0000000000000000000000000000000000000000..0a5ef4916f212a15f5d6af93539f14e483d5179f --- /dev/null +++ b/node_modules/es-toolkit/dist/function/partialRight.js @@ -0,0 +1,47 @@ +//#region src/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, placeholderSymbol, ...partialArgs); +} +function partialRightImpl(func, placeholder, ...partialArgs) { + const partialedRight = function(...providedArgs) { + const placeholderLength = partialArgs.filter((arg) => arg === placeholder).length; + const rangeLength = Math.max(providedArgs.length - placeholderLength, 0); + const remainingArgs = providedArgs.slice(0, rangeLength); + let providedArgsIndex = rangeLength; + const substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg); + return func.apply(this, remainingArgs.concat(substitutedArgs)); + }; + if (func.prototype) partialedRight.prototype = Object.create(func.prototype); + return partialedRight; +} +const placeholderSymbol = Symbol("partialRight.placeholder"); +partialRight.placeholder = placeholderSymbol; +//#endregion +exports.partialRight = partialRight; +exports.partialRightImpl = partialRightImpl; diff --git a/node_modules/es-toolkit/dist/function/partialRight.mjs b/node_modules/es-toolkit/dist/function/partialRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..806de3a4a6c356fa4d1c50a8c0a275965b7effb9 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/partialRight.mjs @@ -0,0 +1,46 @@ +//#region src/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, placeholderSymbol, ...partialArgs); +} +function partialRightImpl(func, placeholder, ...partialArgs) { + const partialedRight = function(...providedArgs) { + const placeholderLength = partialArgs.filter((arg) => arg === placeholder).length; + const rangeLength = Math.max(providedArgs.length - placeholderLength, 0); + const remainingArgs = providedArgs.slice(0, rangeLength); + let providedArgsIndex = rangeLength; + const substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg); + return func.apply(this, remainingArgs.concat(substitutedArgs)); + }; + if (func.prototype) partialedRight.prototype = Object.create(func.prototype); + return partialedRight; +} +const placeholderSymbol = Symbol("partialRight.placeholder"); +partialRight.placeholder = placeholderSymbol; +//#endregion +export { partialRight, partialRightImpl }; diff --git a/node_modules/es-toolkit/dist/function/rest.d.mts b/node_modules/es-toolkit/dist/function/rest.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..dba4e8356a2c0b7a634ab76243eaf49af23addac --- /dev/null +++ b/node_modules/es-toolkit/dist/function/rest.d.mts @@ -0,0 +1,34 @@ +//#region src/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. + * + * @template F - The type of the function being transformed. + * @param func - The function whose arguments are to be transformed. + * @param [startIndex=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 any>(func: F, startIndex?: number): (...args: any[]) => ReturnType; +//#endregion +export { rest }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/rest.d.ts b/node_modules/es-toolkit/dist/function/rest.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dba4e8356a2c0b7a634ab76243eaf49af23addac --- /dev/null +++ b/node_modules/es-toolkit/dist/function/rest.d.ts @@ -0,0 +1,34 @@ +//#region src/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. + * + * @template F - The type of the function being transformed. + * @param func - The function whose arguments are to be transformed. + * @param [startIndex=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 any>(func: F, startIndex?: number): (...args: any[]) => ReturnType; +//#endregion +export { rest }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/rest.js b/node_modules/es-toolkit/dist/function/rest.js new file mode 100644 index 0000000000000000000000000000000000000000..751400e97784ed38afce512aa73ad17a080e2b89 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/rest.js @@ -0,0 +1,41 @@ +//#region src/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. +* +* @template F - The type of the function being transformed. +* @param func - The function whose arguments are to be transformed. +* @param [startIndex=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, startIndex = func.length - 1) { + return function(...args) { + const rest = args.slice(startIndex); + const params = args.slice(0, startIndex); + while (params.length < startIndex) params.push(void 0); + return func.apply(this, [...params, rest]); + }; +} +//#endregion +exports.rest = rest; diff --git a/node_modules/es-toolkit/dist/function/rest.mjs b/node_modules/es-toolkit/dist/function/rest.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0a24db6e9110fc131926dff08650144cd2f85c65 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/rest.mjs @@ -0,0 +1,41 @@ +//#region src/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. +* +* @template F - The type of the function being transformed. +* @param func - The function whose arguments are to be transformed. +* @param [startIndex=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, startIndex = func.length - 1) { + return function(...args) { + const rest = args.slice(startIndex); + const params = args.slice(0, startIndex); + while (params.length < startIndex) params.push(void 0); + return func.apply(this, [...params, rest]); + }; +} +//#endregion +export { rest }; diff --git a/node_modules/es-toolkit/dist/function/retry.d.mts b/node_modules/es-toolkit/dist/function/retry.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..121b7298cfb9fde0ce3873c44b77d36a30dcc15b --- /dev/null +++ b/node_modules/es-toolkit/dist/function/retry.d.mts @@ -0,0 +1,91 @@ +//#region src/function/retry.d.ts +interface RetryOptions { + /** + * Delay between retries. Can be a static number (milliseconds) or a function + * that computes delay dynamically based on the current attempt. + * + * @default 0 + * @example + * delay: (attempts) => attempt * 50 + */ + delay?: number | ((attempts: number) => number); + /** + * The number of retries to attempt. + * @default Number.POSITIVE_INFINITY + */ + retries?: number; + /** + * An AbortSignal to cancel the retry operation. + */ + signal?: AbortSignal; + /** + * A function that determines whether to retry based on the error and attempt number. + * If not provided, all errors will trigger a retry. + * + * @param error - The error that occurred. + * @param attempt - The current attempt number (0-indexed). + * @returns Whether to retry. + * + * @example + * shouldRetry: (error, attempt) => error.status >= 500 + */ + shouldRetry?: (error: unknown, attempt: number) => boolean; +} +/** + * Retries a function that returns a promise until it resolves successfully. + * + * @template T + * @param func - The function to retry. + * @returns A promise that resolves with the value of the successful function call. + * + * @example + * // Basic usage with default retry options + * retry(() => fetchData()).then(data => console.log(data)); + */ +declare function retry(func: () => Promise): Promise; +/** + * Retries a function that returns a promise a specified number of times. + * + * @template T + * @param func - The function to retry. It should return a promise. + * @param retries - The number of retries to attempt. Default is Infinity. + * @returns A promise that resolves with the value of the successful function call. + * + * @example + * // Retry a function up to 3 times + * retry(() => fetchData(), 3).then(data => console.log(data)); + */ +declare function retry(func: () => Promise, retries: number): Promise; +/** + * Retries a function that returns a promise with specified options. + * + * @template T + * @param func - The function to retry. It should return a promise. + * @param options - Options to configure the retry behavior. + * @param [options.delay=0] - Delay(milliseconds) between retries. + * @param [options.retries=Infinity] - The number of retries to attempt. + * @param [options.signal] - An AbortSignal to cancel the retry operation. + * @param [options.shouldRetry] - A function that determines whether to retry. + * @returns A promise that resolves with the value of the successful function call. + * + * @example + * // Retry a function with a delay of 1000ms between attempts + * retry(() => fetchData(), { delay: 1000, times: 5 }).then(data => console.log(data)); + * + * @example + * // Retry a function with a fixed delay + * retry(() => fetchData(), { delay: 1000, retries: 5 }); + * + * // Retry a function with a delay increasing linearly by 50ms per attempt + * retry(() => fetchData(), { delay: (attempts) => attempt * 50, retries: 5 }); + * + * @example + * // Retry a function with exponential backoff + jitter (max delay 10 seconds) + * retry(() => fetchData(), { + * delay: (attempts) => Math.min(Math.random() * 100 * 2 ** attempts, 10000), + * retries: 5 + * }); + */ +declare function retry(func: () => Promise, options: RetryOptions): Promise; +//#endregion +export { retry }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/retry.d.ts b/node_modules/es-toolkit/dist/function/retry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..121b7298cfb9fde0ce3873c44b77d36a30dcc15b --- /dev/null +++ b/node_modules/es-toolkit/dist/function/retry.d.ts @@ -0,0 +1,91 @@ +//#region src/function/retry.d.ts +interface RetryOptions { + /** + * Delay between retries. Can be a static number (milliseconds) or a function + * that computes delay dynamically based on the current attempt. + * + * @default 0 + * @example + * delay: (attempts) => attempt * 50 + */ + delay?: number | ((attempts: number) => number); + /** + * The number of retries to attempt. + * @default Number.POSITIVE_INFINITY + */ + retries?: number; + /** + * An AbortSignal to cancel the retry operation. + */ + signal?: AbortSignal; + /** + * A function that determines whether to retry based on the error and attempt number. + * If not provided, all errors will trigger a retry. + * + * @param error - The error that occurred. + * @param attempt - The current attempt number (0-indexed). + * @returns Whether to retry. + * + * @example + * shouldRetry: (error, attempt) => error.status >= 500 + */ + shouldRetry?: (error: unknown, attempt: number) => boolean; +} +/** + * Retries a function that returns a promise until it resolves successfully. + * + * @template T + * @param func - The function to retry. + * @returns A promise that resolves with the value of the successful function call. + * + * @example + * // Basic usage with default retry options + * retry(() => fetchData()).then(data => console.log(data)); + */ +declare function retry(func: () => Promise): Promise; +/** + * Retries a function that returns a promise a specified number of times. + * + * @template T + * @param func - The function to retry. It should return a promise. + * @param retries - The number of retries to attempt. Default is Infinity. + * @returns A promise that resolves with the value of the successful function call. + * + * @example + * // Retry a function up to 3 times + * retry(() => fetchData(), 3).then(data => console.log(data)); + */ +declare function retry(func: () => Promise, retries: number): Promise; +/** + * Retries a function that returns a promise with specified options. + * + * @template T + * @param func - The function to retry. It should return a promise. + * @param options - Options to configure the retry behavior. + * @param [options.delay=0] - Delay(milliseconds) between retries. + * @param [options.retries=Infinity] - The number of retries to attempt. + * @param [options.signal] - An AbortSignal to cancel the retry operation. + * @param [options.shouldRetry] - A function that determines whether to retry. + * @returns A promise that resolves with the value of the successful function call. + * + * @example + * // Retry a function with a delay of 1000ms between attempts + * retry(() => fetchData(), { delay: 1000, times: 5 }).then(data => console.log(data)); + * + * @example + * // Retry a function with a fixed delay + * retry(() => fetchData(), { delay: 1000, retries: 5 }); + * + * // Retry a function with a delay increasing linearly by 50ms per attempt + * retry(() => fetchData(), { delay: (attempts) => attempt * 50, retries: 5 }); + * + * @example + * // Retry a function with exponential backoff + jitter (max delay 10 seconds) + * retry(() => fetchData(), { + * delay: (attempts) => Math.min(Math.random() * 100 * 2 ** attempts, 10000), + * retries: 5 + * }); + */ +declare function retry(func: () => Promise, options: RetryOptions): Promise; +//#endregion +export { retry }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/retry.js b/node_modules/es-toolkit/dist/function/retry.js new file mode 100644 index 0000000000000000000000000000000000000000..be0d365a2a67dab7f3fc61b4bb6187ccf321a3b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/retry.js @@ -0,0 +1,45 @@ +const require_delay = require("../promise/delay.js"); +//#region src/function/retry.ts +const DEFAULT_DELAY = 0; +const DEFAULT_RETRIES = Number.POSITIVE_INFINITY; +const DEFAULT_SHOULD_RETRY = () => true; +/** +* Retries a function that returns a promise with specified options. +* +* @template T +* @param func - The function to retry. It should return a promise. +* @param [_options] - Either the number of retries or an options object. +* @returns A promise that resolves with the value of the successful function call. +*/ +async function retry(func, _options) { + let delay$1; + let retries; + let signal; + let shouldRetry; + if (typeof _options === "number") { + delay$1 = DEFAULT_DELAY; + retries = _options; + signal = void 0; + shouldRetry = DEFAULT_SHOULD_RETRY; + } else { + delay$1 = _options?.delay ?? DEFAULT_DELAY; + retries = _options?.retries ?? DEFAULT_RETRIES; + signal = _options?.signal; + shouldRetry = _options?.shouldRetry ?? DEFAULT_SHOULD_RETRY; + } + let error; + for (let attempts = 0; attempts <= retries; attempts++) { + if (signal?.aborted) throw error ?? /* @__PURE__ */ new Error(`The retry operation was aborted due to an abort signal.`); + try { + return await func(); + } catch (err) { + error = err; + if (!shouldRetry(err, attempts)) throw err; + const currentDelay = typeof delay$1 === "function" ? delay$1(attempts) : delay$1; + await require_delay.delay(currentDelay); + } + } + throw error; +} +//#endregion +exports.retry = retry; diff --git a/node_modules/es-toolkit/dist/function/retry.mjs b/node_modules/es-toolkit/dist/function/retry.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e0b4c41dd3aabf83faad98fb39b0255f37e67677 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/retry.mjs @@ -0,0 +1,44 @@ +import { delay } from "../promise/delay.mjs"; +//#region src/function/retry.ts +const DEFAULT_DELAY = 0; +const DEFAULT_RETRIES = Number.POSITIVE_INFINITY; +const DEFAULT_SHOULD_RETRY = () => true; +/** +* Retries a function that returns a promise with specified options. +* +* @template T +* @param func - The function to retry. It should return a promise. +* @param [_options] - Either the number of retries or an options object. +* @returns A promise that resolves with the value of the successful function call. +*/ +async function retry(func, _options) { + let delay$1; + let retries; + let signal; + let shouldRetry; + if (typeof _options === "number") { + delay$1 = DEFAULT_DELAY; + retries = _options; + signal = void 0; + shouldRetry = DEFAULT_SHOULD_RETRY; + } else { + delay$1 = _options?.delay ?? DEFAULT_DELAY; + retries = _options?.retries ?? DEFAULT_RETRIES; + signal = _options?.signal; + shouldRetry = _options?.shouldRetry ?? DEFAULT_SHOULD_RETRY; + } + let error; + for (let attempts = 0; attempts <= retries; attempts++) { + if (signal?.aborted) throw error ?? /* @__PURE__ */ new Error(`The retry operation was aborted due to an abort signal.`); + try { + return await func(); + } catch (err) { + error = err; + if (!shouldRetry(err, attempts)) throw err; + await delay(typeof delay$1 === "function" ? delay$1(attempts) : delay$1); + } + } + throw error; +} +//#endregion +export { retry }; diff --git a/node_modules/es-toolkit/dist/function/spread.d.mts b/node_modules/es-toolkit/dist/function/spread.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..499f0d1a850b22a60edfbe29383b8b32e2243757 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/spread.d.mts @@ -0,0 +1,20 @@ +//#region src/function/spread.d.ts +/** + * Creates a new function that spreads elements of an array argument into individual arguments + * for the original function. + * + * @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. + * @returns A new function that takes an array of arguments 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 + */ +declare function spread any>(func: F): (argsArr: Parameters) => ReturnType; +//#endregion +export { spread }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/spread.d.ts b/node_modules/es-toolkit/dist/function/spread.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..499f0d1a850b22a60edfbe29383b8b32e2243757 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/spread.d.ts @@ -0,0 +1,20 @@ +//#region src/function/spread.d.ts +/** + * Creates a new function that spreads elements of an array argument into individual arguments + * for the original function. + * + * @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. + * @returns A new function that takes an array of arguments 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 + */ +declare function spread any>(func: F): (argsArr: Parameters) => ReturnType; +//#endregion +export { spread }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/spread.js b/node_modules/es-toolkit/dist/function/spread.js new file mode 100644 index 0000000000000000000000000000000000000000..da5b44293c5bb7ee95e752e8030730a9cdc1b831 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/spread.js @@ -0,0 +1,24 @@ +//#region src/function/spread.ts +/** +* Creates a new function that spreads elements of an array argument into individual arguments +* for the original function. +* +* @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. +* @returns A new function that takes an array of arguments 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 +*/ +function spread(func) { + return function(argsArr) { + return func.apply(this, argsArr); + }; +} +//#endregion +exports.spread = spread; diff --git a/node_modules/es-toolkit/dist/function/spread.mjs b/node_modules/es-toolkit/dist/function/spread.mjs new file mode 100644 index 0000000000000000000000000000000000000000..561c1c73505dda757d89ab12aec61e8c3009d01a --- /dev/null +++ b/node_modules/es-toolkit/dist/function/spread.mjs @@ -0,0 +1,24 @@ +//#region src/function/spread.ts +/** +* Creates a new function that spreads elements of an array argument into individual arguments +* for the original function. +* +* @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. +* @returns A new function that takes an array of arguments 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 +*/ +function spread(func) { + return function(argsArr) { + return func.apply(this, argsArr); + }; +} +//#endregion +export { spread }; diff --git a/node_modules/es-toolkit/dist/function/throttle.d.mts b/node_modules/es-toolkit/dist/function/throttle.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6292eae66846bddedc9a8bc411dde8d2dbc9b48b --- /dev/null +++ b/node_modules/es-toolkit/dist/function/throttle.d.mts @@ -0,0 +1,52 @@ +//#region src/function/throttle.d.ts +interface ThrottleOptions { + /** + * An optional AbortSignal to cancel the throttled function. + */ + signal?: AbortSignal; + /** + * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both. + * If `edges` includes "leading", the function will be invoked at the start of the delay period. + * If `edges` includes "trailing", the function will be invoked at the end of the delay period. + * If both "leading" and "trailing" are included, the function will be invoked at both the start and end of the delay period. + * @default ["leading", "trailing"] + */ + edges?: Array<'leading' | 'trailing'>; +} +interface ThrottledFunction void> { + (...args: Parameters): void; + cancel: () => void; + flush: () => void; +} +/** + * 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. + * @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 void>(func: F, throttleMs: number, { + signal, + edges +}?: ThrottleOptions): ThrottledFunction; +//#endregion +export { ThrottleOptions, ThrottledFunction, throttle }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/throttle.d.ts b/node_modules/es-toolkit/dist/function/throttle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6292eae66846bddedc9a8bc411dde8d2dbc9b48b --- /dev/null +++ b/node_modules/es-toolkit/dist/function/throttle.d.ts @@ -0,0 +1,52 @@ +//#region src/function/throttle.d.ts +interface ThrottleOptions { + /** + * An optional AbortSignal to cancel the throttled function. + */ + signal?: AbortSignal; + /** + * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both. + * If `edges` includes "leading", the function will be invoked at the start of the delay period. + * If `edges` includes "trailing", the function will be invoked at the end of the delay period. + * If both "leading" and "trailing" are included, the function will be invoked at both the start and end of the delay period. + * @default ["leading", "trailing"] + */ + edges?: Array<'leading' | 'trailing'>; +} +interface ThrottledFunction void> { + (...args: Parameters): void; + cancel: () => void; + flush: () => void; +} +/** + * 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. + * @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 void>(func: F, throttleMs: number, { + signal, + edges +}?: ThrottleOptions): ThrottledFunction; +//#endregion +export { ThrottleOptions, ThrottledFunction, throttle }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/throttle.js b/node_modules/es-toolkit/dist/function/throttle.js new file mode 100644 index 0000000000000000000000000000000000000000..ce853b1d339fd21edc8aa6c96bb5201bc74bb396 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/throttle.js @@ -0,0 +1,54 @@ +const require_debounce = require("./debounce.js"); +//#region src/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. +* @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, { signal, edges = ["leading", "trailing"] } = {}) { + let pendingAt = null; + const debounced = require_debounce.debounce(function(...args) { + pendingAt = Date.now(); + func.apply(this, args); + }, throttleMs, { + signal, + edges + }); + const throttled = function(...args) { + if (pendingAt == null) pendingAt = Date.now(); + if (Date.now() - pendingAt >= throttleMs) { + pendingAt = Date.now(); + func.apply(this, args); + debounced.cancel(); + debounced.schedule(); + return; + } + debounced.apply(this, args); + }; + throttled.cancel = debounced.cancel; + throttled.flush = debounced.flush; + return throttled; +} +//#endregion +exports.throttle = throttle; diff --git a/node_modules/es-toolkit/dist/function/throttle.mjs b/node_modules/es-toolkit/dist/function/throttle.mjs new file mode 100644 index 0000000000000000000000000000000000000000..710a96658cea814201218a8fb0d82c7797f56c5f --- /dev/null +++ b/node_modules/es-toolkit/dist/function/throttle.mjs @@ -0,0 +1,54 @@ +import { debounce } from "./debounce.mjs"; +//#region src/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. +* @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, { signal, edges = ["leading", "trailing"] } = {}) { + let pendingAt = null; + const debounced = debounce(function(...args) { + pendingAt = Date.now(); + func.apply(this, args); + }, throttleMs, { + signal, + edges + }); + const throttled = function(...args) { + if (pendingAt == null) pendingAt = Date.now(); + if (Date.now() - pendingAt >= throttleMs) { + pendingAt = Date.now(); + func.apply(this, args); + debounced.cancel(); + debounced.schedule(); + return; + } + debounced.apply(this, args); + }; + throttled.cancel = debounced.cancel; + throttled.flush = debounced.flush; + return throttled; +} +//#endregion +export { throttle }; diff --git a/node_modules/es-toolkit/dist/function/unary.d.mts b/node_modules/es-toolkit/dist/function/unary.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..089f5c7e1a293a433d5937019475745b1e5e0282 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/unary.d.mts @@ -0,0 +1,18 @@ +//#region src/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 any>(func: F): (...args: any[]) => ReturnType; +//#endregion +export { unary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/unary.d.ts b/node_modules/es-toolkit/dist/function/unary.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..089f5c7e1a293a433d5937019475745b1e5e0282 --- /dev/null +++ b/node_modules/es-toolkit/dist/function/unary.d.ts @@ -0,0 +1,18 @@ +//#region src/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 any>(func: F): (...args: any[]) => ReturnType; +//#endregion +export { unary }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/function/unary.js b/node_modules/es-toolkit/dist/function/unary.js new file mode 100644 index 0000000000000000000000000000000000000000..79cbe5812a541ccc5ff5ac0a8d06855f354f6dcb --- /dev/null +++ b/node_modules/es-toolkit/dist/function/unary.js @@ -0,0 +1,21 @@ +const require_ary = require("./ary.js"); +//#region src/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/function/unary.mjs b/node_modules/es-toolkit/dist/function/unary.mjs new file mode 100644 index 0000000000000000000000000000000000000000..23a5be98db04565afcdd5cabc1daec8e36c5e80d --- /dev/null +++ b/node_modules/es-toolkit/dist/function/unary.mjs @@ -0,0 +1,21 @@ +import { ary } from "./ary.mjs"; +//#region src/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/index.d.mts b/node_modules/es-toolkit/dist/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b3e13cbd62d32c1bd14b80dcc2b57685c0639aeb --- /dev/null +++ b/node_modules/es-toolkit/dist/index.d.mts @@ -0,0 +1,188 @@ +import { at } from "./array/at.mjs"; +import { cartesianProduct } from "./array/cartesianProduct.mjs"; +import { chunk } from "./array/chunk.mjs"; +import { chunkBy } from "./array/chunkBy.mjs"; +import { combinations } from "./array/combinations.mjs"; +import { compact } from "./array/compact.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 { fill } from "./array/fill.mjs"; +import { filterAsync } from "./array/filterAsync.mjs"; +import { flatMap } from "./array/flatMap.mjs"; +import { flatMapAsync } from "./array/flatMapAsync.mjs"; +import { flattenDeep } from "./array/flattenDeep.mjs"; +import { flatMapDeep } from "./array/flatMapDeep.mjs"; +import { flatten } from "./array/flatten.mjs"; +import { forEachAsync } from "./array/forEachAsync.mjs"; +import { forEachRight } from "./array/forEachRight.mjs"; +import { groupBy } from "./array/groupBy.mjs"; +import { head } from "./array/head.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 { isSubset } from "./array/isSubset.mjs"; +import { isSubsetWith } from "./array/isSubsetWith.mjs"; +import { keyBy } from "./array/keyBy.mjs"; +import { last } from "./array/last.mjs"; +import { limitAsync } from "./array/limitAsync.mjs"; +import { mapAsync } from "./array/mapAsync.mjs"; +import { maxBy } from "./array/maxBy.mjs"; +import { minBy } from "./array/minBy.mjs"; +import { orderBy } from "./array/orderBy.mjs"; +import { partition } from "./array/partition.mjs"; +import { pull } from "./array/pull.mjs"; +import { pullAt } from "./array/pullAt.mjs"; +import { reduceAsync } from "./array/reduceAsync.mjs"; +import { remove } from "./array/remove.mjs"; +import { sample } from "./array/sample.mjs"; +import { sampleSize } from "./array/sampleSize.mjs"; +import { shuffle } from "./array/shuffle.mjs"; +import { sortBy } from "./array/sortBy.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 { toFilled } from "./array/toFilled.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 { windowed } from "./array/windowed.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 { zipWith } from "./array/zipWith.mjs"; +import { isEqual } from "./predicate/isEqual.mjs"; +import { AbortError } from "./error/AbortError.mjs"; +import { TimeoutError } from "./error/TimeoutError.mjs"; +import { after } from "./function/after.mjs"; +import { ary } from "./function/ary.mjs"; +import { asyncNoop } from "./function/asyncNoop.mjs"; +import { before } from "./function/before.mjs"; +import { curry } from "./function/curry.mjs"; +import { curryRight } from "./function/curryRight.mjs"; +import { DebounceOptions, DebouncedFunction, debounce } from "./function/debounce.mjs"; +import { flow } from "./function/flow.mjs"; +import { flowRight } from "./function/flowRight.mjs"; +import { identity } from "./function/identity.mjs"; +import { MemoizeCache, memoize } from "./function/memoize.mjs"; +import { negate } from "./function/negate.mjs"; +import { noop } from "./function/noop.mjs"; +import { once } from "./function/once.mjs"; +import { partial } from "./function/partial.mjs"; +import { partialRight } from "./function/partialRight.mjs"; +import { rest } from "./function/rest.mjs"; +import { retry } from "./function/retry.mjs"; +import { spread } from "./function/spread.mjs"; +import { ThrottleOptions, ThrottledFunction, throttle } from "./function/throttle.mjs"; +import { unary } from "./function/unary.mjs"; +import { clamp } from "./math/clamp.mjs"; +import { inRange } from "./math/inRange.mjs"; +import { mean } from "./math/mean.mjs"; +import { meanBy } from "./math/meanBy.mjs"; +import { median } from "./math/median.mjs"; +import { medianBy } from "./math/medianBy.mjs"; +import { percentile } from "./math/percentile.mjs"; +import { random } from "./math/random.mjs"; +import { randomInt } from "./math/randomInt.mjs"; +import { range } from "./math/range.mjs"; +import { rangeRight } from "./math/rangeRight.mjs"; +import { round } from "./math/round.mjs"; +import { sum } from "./math/sum.mjs"; +import { sumBy } from "./math/sumBy.mjs"; +import { clone } from "./object/clone.mjs"; +import { cloneDeep } from "./object/cloneDeep.mjs"; +import { cloneDeepWith } from "./object/cloneDeepWith.mjs"; +import { findKey } from "./object/findKey.mjs"; +import { flattenObject } from "./object/flattenObject.mjs"; +import { invert } from "./object/invert.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 { sortKeys } from "./object/sortKeys.mjs"; +import { toCamelCaseKeys } from "./object/toCamelCaseKeys.mjs"; +import { toMerged } from "./object/toMerged.mjs"; +import { toSnakeCaseKeys } from "./object/toSnakeCaseKeys.mjs"; +import { isArrayBuffer } from "./predicate/isArrayBuffer.mjs"; +import { isBlob } from "./predicate/isBlob.mjs"; +import { isBoolean } from "./predicate/isBoolean.mjs"; +import { isBrowser } from "./predicate/isBrowser.mjs"; +import { isBuffer } from "./predicate/isBuffer.mjs"; +import { isDate } from "./predicate/isDate.mjs"; +import { isEmptyObject } from "./predicate/isEmptyObject.mjs"; +import { isEqualWith } from "./predicate/isEqualWith.mjs"; +import { isError } from "./predicate/isError.mjs"; +import { isFile } from "./predicate/isFile.mjs"; +import { isFunction } from "./predicate/isFunction.mjs"; +import { isIterable } from "./predicate/isIterable.mjs"; +import { isJSON } from "./predicate/isJSON.mjs"; +import { isJSONArray, isJSONObject, isJSONValue } from "./predicate/isJSONValue.mjs"; +import { isLength } from "./predicate/isLength.mjs"; +import { isMap } from "./predicate/isMap.mjs"; +import { isNil } from "./predicate/isNil.mjs"; +import { isNode } from "./predicate/isNode.mjs"; +import { isNotNil } from "./predicate/isNotNil.mjs"; +import { isNull } from "./predicate/isNull.mjs"; +import { isNumber } from "./predicate/isNumber.mjs"; +import { isPlainObject } from "./predicate/isPlainObject.mjs"; +import { isPrimitive } from "./predicate/isPrimitive.mjs"; +import { isPromise } from "./predicate/isPromise.mjs"; +import { isRegExp } from "./predicate/isRegExp.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 { isUndefined } from "./predicate/isUndefined.mjs"; +import { isWeakMap } from "./predicate/isWeakMap.mjs"; +import { isWeakSet } from "./predicate/isWeakSet.mjs"; +import { allKeyed } from "./promise/allKeyed.mjs"; +import { delay } from "./promise/delay.mjs"; +import { Mutex } from "./promise/mutex.mjs"; +import { Semaphore } from "./promise/semaphore.mjs"; +import { timeout } from "./promise/timeout.mjs"; +import { withTimeout } from "./promise/withTimeout.mjs"; +import { camelCase } from "./string/camelCase.mjs"; +import { capitalize } from "./string/capitalize.mjs"; +import { constantCase } from "./string/constantCase.mjs"; +import { deburr } from "./string/deburr.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 { pascalCase } from "./string/pascalCase.mjs"; +import { reverseString } from "./string/reverseString.mjs"; +import { snakeCase } from "./string/snakeCase.mjs"; +import { startCase } from "./string/startCase.mjs"; +import { trim } from "./string/trim.mjs"; +import { trimEnd } from "./string/trimEnd.mjs"; +import { trimStart } from "./string/trimStart.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 { attempt } from "./util/attempt.mjs"; +import { attemptAsync } from "./util/attemptAsync.mjs"; +import { invariant } from "./util/invariant.mjs"; +export { AbortError, DebounceOptions, DebouncedFunction, MemoizeCache, Mutex, Semaphore, ThrottleOptions, ThrottledFunction, TimeoutError, after, allKeyed, ary, invariant as assert, asyncNoop, at, attempt, attemptAsync, before, camelCase, capitalize, cartesianProduct, chunk, chunkBy, clamp, clone, cloneDeep, cloneDeepWith, combinations, compact, constantCase, countBy, curry, curryRight, debounce, deburr, delay, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, escape, escapeRegExp, fill, filterAsync, findKey, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, flattenObject, flow, flowRight, forEachAsync, forEachRight, groupBy, head, identity, inRange, initial, intersection, intersectionBy, intersectionWith, invariant, invert, isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFunction, isIterable, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNil, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSubset, isSubsetWith, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, kebabCase, keyBy, last, limitAsync, lowerCase, lowerFirst, mapAsync, mapKeys, mapValues, maxBy, mean, meanBy, median, medianBy, memoize, merge, mergeWith, minBy, negate, noop, omit, omitBy, once, orderBy, pad, partial, partialRight, partition, pascalCase, percentile, pick, pickBy, pull, pullAt, random, randomInt, range, rangeRight, reduceAsync, remove, rest, retry, reverseString, round, sample, sampleSize, shuffle, snakeCase, sortBy, sortKeys, spread, startCase, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, throttle, timeout, toCamelCaseKeys, toFilled, toMerged, toSnakeCaseKeys, trim, trimEnd, trimStart, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, upperCase, upperFirst, windowed, withTimeout, without, words, xor, xorBy, xorWith, zip, zipObject, zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/index.d.ts b/node_modules/es-toolkit/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca9828f64eaaed8522857a68f2e2159fe1dc6a0a --- /dev/null +++ b/node_modules/es-toolkit/dist/index.d.ts @@ -0,0 +1,188 @@ +import { at } from "./array/at.js"; +import { cartesianProduct } from "./array/cartesianProduct.js"; +import { chunk } from "./array/chunk.js"; +import { chunkBy } from "./array/chunkBy.js"; +import { combinations } from "./array/combinations.js"; +import { compact } from "./array/compact.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 { fill } from "./array/fill.js"; +import { filterAsync } from "./array/filterAsync.js"; +import { flatMap } from "./array/flatMap.js"; +import { flatMapAsync } from "./array/flatMapAsync.js"; +import { flattenDeep } from "./array/flattenDeep.js"; +import { flatMapDeep } from "./array/flatMapDeep.js"; +import { flatten } from "./array/flatten.js"; +import { forEachAsync } from "./array/forEachAsync.js"; +import { forEachRight } from "./array/forEachRight.js"; +import { groupBy } from "./array/groupBy.js"; +import { head } from "./array/head.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 { isSubset } from "./array/isSubset.js"; +import { isSubsetWith } from "./array/isSubsetWith.js"; +import { keyBy } from "./array/keyBy.js"; +import { last } from "./array/last.js"; +import { limitAsync } from "./array/limitAsync.js"; +import { mapAsync } from "./array/mapAsync.js"; +import { maxBy } from "./array/maxBy.js"; +import { minBy } from "./array/minBy.js"; +import { orderBy } from "./array/orderBy.js"; +import { partition } from "./array/partition.js"; +import { pull } from "./array/pull.js"; +import { pullAt } from "./array/pullAt.js"; +import { reduceAsync } from "./array/reduceAsync.js"; +import { remove } from "./array/remove.js"; +import { sample } from "./array/sample.js"; +import { sampleSize } from "./array/sampleSize.js"; +import { shuffle } from "./array/shuffle.js"; +import { sortBy } from "./array/sortBy.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 { toFilled } from "./array/toFilled.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 { windowed } from "./array/windowed.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 { zipWith } from "./array/zipWith.js"; +import { isEqual } from "./predicate/isEqual.js"; +import { AbortError } from "./error/AbortError.js"; +import { TimeoutError } from "./error/TimeoutError.js"; +import { after } from "./function/after.js"; +import { ary } from "./function/ary.js"; +import { asyncNoop } from "./function/asyncNoop.js"; +import { before } from "./function/before.js"; +import { curry } from "./function/curry.js"; +import { curryRight } from "./function/curryRight.js"; +import { DebounceOptions, DebouncedFunction, debounce } from "./function/debounce.js"; +import { flow } from "./function/flow.js"; +import { flowRight } from "./function/flowRight.js"; +import { identity } from "./function/identity.js"; +import { MemoizeCache, memoize } from "./function/memoize.js"; +import { negate } from "./function/negate.js"; +import { noop } from "./function/noop.js"; +import { once } from "./function/once.js"; +import { partial } from "./function/partial.js"; +import { partialRight } from "./function/partialRight.js"; +import { rest } from "./function/rest.js"; +import { retry } from "./function/retry.js"; +import { spread } from "./function/spread.js"; +import { ThrottleOptions, ThrottledFunction, throttle } from "./function/throttle.js"; +import { unary } from "./function/unary.js"; +import { clamp } from "./math/clamp.js"; +import { inRange } from "./math/inRange.js"; +import { mean } from "./math/mean.js"; +import { meanBy } from "./math/meanBy.js"; +import { median } from "./math/median.js"; +import { medianBy } from "./math/medianBy.js"; +import { percentile } from "./math/percentile.js"; +import { random } from "./math/random.js"; +import { randomInt } from "./math/randomInt.js"; +import { range } from "./math/range.js"; +import { rangeRight } from "./math/rangeRight.js"; +import { round } from "./math/round.js"; +import { sum } from "./math/sum.js"; +import { sumBy } from "./math/sumBy.js"; +import { clone } from "./object/clone.js"; +import { cloneDeep } from "./object/cloneDeep.js"; +import { cloneDeepWith } from "./object/cloneDeepWith.js"; +import { findKey } from "./object/findKey.js"; +import { flattenObject } from "./object/flattenObject.js"; +import { invert } from "./object/invert.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 { sortKeys } from "./object/sortKeys.js"; +import { toCamelCaseKeys } from "./object/toCamelCaseKeys.js"; +import { toMerged } from "./object/toMerged.js"; +import { toSnakeCaseKeys } from "./object/toSnakeCaseKeys.js"; +import { isArrayBuffer } from "./predicate/isArrayBuffer.js"; +import { isBlob } from "./predicate/isBlob.js"; +import { isBoolean } from "./predicate/isBoolean.js"; +import { isBrowser } from "./predicate/isBrowser.js"; +import { isBuffer } from "./predicate/isBuffer.js"; +import { isDate } from "./predicate/isDate.js"; +import { isEmptyObject } from "./predicate/isEmptyObject.js"; +import { isEqualWith } from "./predicate/isEqualWith.js"; +import { isError } from "./predicate/isError.js"; +import { isFile } from "./predicate/isFile.js"; +import { isFunction } from "./predicate/isFunction.js"; +import { isIterable } from "./predicate/isIterable.js"; +import { isJSON } from "./predicate/isJSON.js"; +import { isJSONArray, isJSONObject, isJSONValue } from "./predicate/isJSONValue.js"; +import { isLength } from "./predicate/isLength.js"; +import { isMap } from "./predicate/isMap.js"; +import { isNil } from "./predicate/isNil.js"; +import { isNode } from "./predicate/isNode.js"; +import { isNotNil } from "./predicate/isNotNil.js"; +import { isNull } from "./predicate/isNull.js"; +import { isNumber } from "./predicate/isNumber.js"; +import { isPlainObject } from "./predicate/isPlainObject.js"; +import { isPrimitive } from "./predicate/isPrimitive.js"; +import { isPromise } from "./predicate/isPromise.js"; +import { isRegExp } from "./predicate/isRegExp.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 { isUndefined } from "./predicate/isUndefined.js"; +import { isWeakMap } from "./predicate/isWeakMap.js"; +import { isWeakSet } from "./predicate/isWeakSet.js"; +import { allKeyed } from "./promise/allKeyed.js"; +import { delay } from "./promise/delay.js"; +import { Mutex } from "./promise/mutex.js"; +import { Semaphore } from "./promise/semaphore.js"; +import { timeout } from "./promise/timeout.js"; +import { withTimeout } from "./promise/withTimeout.js"; +import { camelCase } from "./string/camelCase.js"; +import { capitalize } from "./string/capitalize.js"; +import { constantCase } from "./string/constantCase.js"; +import { deburr } from "./string/deburr.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 { pascalCase } from "./string/pascalCase.js"; +import { reverseString } from "./string/reverseString.js"; +import { snakeCase } from "./string/snakeCase.js"; +import { startCase } from "./string/startCase.js"; +import { trim } from "./string/trim.js"; +import { trimEnd } from "./string/trimEnd.js"; +import { trimStart } from "./string/trimStart.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 { attempt } from "./util/attempt.js"; +import { attemptAsync } from "./util/attemptAsync.js"; +import { invariant } from "./util/invariant.js"; +export { AbortError, DebounceOptions, DebouncedFunction, MemoizeCache, Mutex, Semaphore, ThrottleOptions, ThrottledFunction, TimeoutError, after, allKeyed, ary, invariant as assert, asyncNoop, at, attempt, attemptAsync, before, camelCase, capitalize, cartesianProduct, chunk, chunkBy, clamp, clone, cloneDeep, cloneDeepWith, combinations, compact, constantCase, countBy, curry, curryRight, debounce, deburr, delay, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, escape, escapeRegExp, fill, filterAsync, findKey, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, flattenObject, flow, flowRight, forEachAsync, forEachRight, groupBy, head, identity, inRange, initial, intersection, intersectionBy, intersectionWith, invariant, invert, isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFunction, isIterable, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNil, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSubset, isSubsetWith, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, kebabCase, keyBy, last, limitAsync, lowerCase, lowerFirst, mapAsync, mapKeys, mapValues, maxBy, mean, meanBy, median, medianBy, memoize, merge, mergeWith, minBy, negate, noop, omit, omitBy, once, orderBy, pad, partial, partialRight, partition, pascalCase, percentile, pick, pickBy, pull, pullAt, random, randomInt, range, rangeRight, reduceAsync, remove, rest, retry, reverseString, round, sample, sampleSize, shuffle, snakeCase, sortBy, sortKeys, spread, startCase, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, throttle, timeout, toCamelCaseKeys, toFilled, toMerged, toSnakeCaseKeys, trim, trimEnd, trimStart, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, upperCase, upperFirst, windowed, withTimeout, without, words, xor, xorBy, xorWith, zip, zipObject, zipWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/index.js b/node_modules/es-toolkit/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..aad84fac9e8b54c81364aef321fc5c208b199114 --- /dev/null +++ b/node_modules/es-toolkit/dist/index.js @@ -0,0 +1,387 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_at = require("./array/at.js"); +const require_cartesianProduct = require("./array/cartesianProduct.js"); +const require_chunk = require("./array/chunk.js"); +const require_chunkBy = require("./array/chunkBy.js"); +const require_combinations = require("./array/combinations.js"); +const require_compact = require("./array/compact.js"); +const require_countBy = require("./array/countBy.js"); +const require_difference = require("./array/difference.js"); +const require_differenceBy = require("./array/differenceBy.js"); +const require_differenceWith = require("./array/differenceWith.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_fill = require("./array/fill.js"); +const require_semaphore = require("./promise/semaphore.js"); +const require_limitAsync = require("./array/limitAsync.js"); +const require_filterAsync = require("./array/filterAsync.js"); +const require_flatten = require("./array/flatten.js"); +const require_flatMap = require("./array/flatMap.js"); +const require_flatMapAsync = require("./array/flatMapAsync.js"); +const require_flattenDeep = require("./array/flattenDeep.js"); +const require_flatMapDeep = require("./array/flatMapDeep.js"); +const require_forEachAsync = require("./array/forEachAsync.js"); +const require_forEachRight = require("./array/forEachRight.js"); +const require_groupBy = require("./array/groupBy.js"); +const require_head = require("./array/head.js"); +const require_initial = require("./array/initial.js"); +const require_intersection = require("./array/intersection.js"); +const require_intersectionBy = require("./array/intersectionBy.js"); +const require_intersectionWith = require("./array/intersectionWith.js"); +const require_isSubset = require("./array/isSubset.js"); +const require_isSubsetWith = require("./array/isSubsetWith.js"); +const require_keyBy = require("./array/keyBy.js"); +const require_last = require("./array/last.js"); +const require_mapAsync = require("./array/mapAsync.js"); +const require_maxBy = require("./array/maxBy.js"); +const require_minBy = require("./array/minBy.js"); +const require_orderBy = require("./array/orderBy.js"); +const require_partition = require("./array/partition.js"); +const require_pull = require("./array/pull.js"); +const require_pullAt = require("./array/pullAt.js"); +const require_reduceAsync = require("./array/reduceAsync.js"); +const require_remove = require("./array/remove.js"); +const require_sample = require("./array/sample.js"); +const require_random = require("./math/random.js"); +const require_randomInt = require("./math/randomInt.js"); +const require_sampleSize = require("./array/sampleSize.js"); +const require_shuffle = require("./array/shuffle.js"); +const require_sortBy = require("./array/sortBy.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_toFilled = require("./array/toFilled.js"); +const require_uniq = require("./array/uniq.js"); +const require_union = require("./array/union.js"); +const require_uniqBy = require("./array/uniqBy.js"); +const require_unionBy = require("./array/unionBy.js"); +const require_uniqWith = require("./array/uniqWith.js"); +const require_unionWith = require("./array/unionWith.js"); +const require_unzip = require("./array/unzip.js"); +const require_unzipWith = require("./array/unzipWith.js"); +const require_windowed = require("./array/windowed.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_zipWith = require("./array/zipWith.js"); +require("./array/index.js"); +const require_AbortError = require("./error/AbortError.js"); +const require_TimeoutError = require("./error/TimeoutError.js"); +require("./error/index.js"); +const require_after = require("./function/after.js"); +const require_ary = require("./function/ary.js"); +const require_asyncNoop = require("./function/asyncNoop.js"); +const require_before = require("./function/before.js"); +const require_curry = require("./function/curry.js"); +const require_curryRight = require("./function/curryRight.js"); +const require_debounce = require("./function/debounce.js"); +const require_flow = require("./function/flow.js"); +const require_flowRight = require("./function/flowRight.js"); +const require_identity = require("./function/identity.js"); +const require_memoize = require("./function/memoize.js"); +const require_negate = require("./function/negate.js"); +const require_noop = require("./function/noop.js"); +const require_once = require("./function/once.js"); +const require_partial = require("./function/partial.js"); +const require_partialRight = require("./function/partialRight.js"); +const require_rest = require("./function/rest.js"); +const require_delay = require("./promise/delay.js"); +const require_retry = require("./function/retry.js"); +const require_spread = require("./function/spread.js"); +const require_throttle = require("./function/throttle.js"); +const require_unary = require("./function/unary.js"); +require("./function/index.js"); +const require_clamp = require("./math/clamp.js"); +const require_inRange = require("./math/inRange.js"); +const require_sum = require("./math/sum.js"); +const require_mean = require("./math/mean.js"); +const require_sumBy = require("./math/sumBy.js"); +const require_meanBy = require("./math/meanBy.js"); +const require_median = require("./math/median.js"); +const require_medianBy = require("./math/medianBy.js"); +const require_percentile = require("./math/percentile.js"); +const require_range = require("./math/range.js"); +const require_rangeRight = require("./math/rangeRight.js"); +const require_round = require("./math/round.js"); +require("./math/index.js"); +const require_isPrimitive = require("./predicate/isPrimitive.js"); +const require_isTypedArray = require("./predicate/isTypedArray.js"); +const require_clone = require("./object/clone.js"); +const require_isBuffer = require("./predicate/isBuffer.js"); +const require_cloneDeepWith = require("./object/cloneDeepWith.js"); +const require_cloneDeep = require("./object/cloneDeep.js"); +const require_findKey = require("./object/findKey.js"); +const require_isPlainObject = require("./predicate/isPlainObject.js"); +const require_flattenObject = require("./object/flattenObject.js"); +const require_invert = require("./object/invert.js"); +const require_mapKeys = require("./object/mapKeys.js"); +const require_mapValues = require("./object/mapValues.js"); +const require_merge = require("./object/merge.js"); +const require_mergeWith = require("./object/mergeWith.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_sortKeys = require("./object/sortKeys.js"); +const require_capitalize = require("./string/capitalize.js"); +const require_words = require("./string/words.js"); +const require_camelCase = require("./string/camelCase.js"); +const require_toCamelCaseKeys = require("./object/toCamelCaseKeys.js"); +const require_toMerged = require("./object/toMerged.js"); +const require_snakeCase = require("./string/snakeCase.js"); +const require_toSnakeCaseKeys = require("./object/toSnakeCaseKeys.js"); +require("./object/index.js"); +const require_isArrayBuffer = require("./predicate/isArrayBuffer.js"); +const require_isBlob = require("./predicate/isBlob.js"); +const require_isBoolean = require("./predicate/isBoolean.js"); +const require_isBrowser = require("./predicate/isBrowser.js"); +const require_isDate = require("./predicate/isDate.js"); +const require_isEmptyObject = require("./predicate/isEmptyObject.js"); +const require_isEqualWith = require("./predicate/isEqualWith.js"); +const require_isEqual = require("./predicate/isEqual.js"); +const require_isError = require("./predicate/isError.js"); +const require_isFile = require("./predicate/isFile.js"); +const require_isFunction = require("./predicate/isFunction.js"); +const require_isIterable = require("./predicate/isIterable.js"); +const require_isJSON = require("./predicate/isJSON.js"); +const require_isJSONValue = require("./predicate/isJSONValue.js"); +const require_isLength = require("./predicate/isLength.js"); +const require_isMap = require("./predicate/isMap.js"); +const require_isNil = require("./predicate/isNil.js"); +const require_isNode = require("./predicate/isNode.js"); +const require_isNotNil = require("./predicate/isNotNil.js"); +const require_isNull = require("./predicate/isNull.js"); +const require_isNumber = require("./predicate/isNumber.js"); +const require_isPromise = require("./predicate/isPromise.js"); +const require_isRegExp = require("./predicate/isRegExp.js"); +const require_isSet = require("./predicate/isSet.js"); +const require_isString = require("./predicate/isString.js"); +const require_isSymbol = require("./predicate/isSymbol.js"); +const require_isUndefined = require("./predicate/isUndefined.js"); +const require_isWeakMap = require("./predicate/isWeakMap.js"); +const require_isWeakSet = require("./predicate/isWeakSet.js"); +require("./predicate/index.js"); +const require_allKeyed = require("./promise/allKeyed.js"); +const require_mutex = require("./promise/mutex.js"); +const require_timeout = require("./promise/timeout.js"); +const require_withTimeout = require("./promise/withTimeout.js"); +require("./promise/index.js"); +const require_constantCase = require("./string/constantCase.js"); +const require_deburr = require("./string/deburr.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_pascalCase = require("./string/pascalCase.js"); +const require_reverseString = require("./string/reverseString.js"); +const require_startCase = require("./string/startCase.js"); +const require_trimEnd = require("./string/trimEnd.js"); +const require_trimStart = require("./string/trimStart.js"); +const require_trim = require("./string/trim.js"); +const require_unescape = require("./string/unescape.js"); +const require_upperCase = require("./string/upperCase.js"); +const require_upperFirst = require("./string/upperFirst.js"); +require("./string/index.js"); +const require_attempt = require("./util/attempt.js"); +const require_attemptAsync = require("./util/attemptAsync.js"); +const require_invariant = require("./util/invariant.js"); +require("./util/index.js"); +exports.AbortError = require_AbortError.AbortError; +exports.Mutex = require_mutex.Mutex; +exports.Semaphore = require_semaphore.Semaphore; +exports.TimeoutError = require_TimeoutError.TimeoutError; +exports.after = require_after.after; +exports.allKeyed = require_allKeyed.allKeyed; +exports.ary = require_ary.ary; +exports.assert = require_invariant.invariant; +exports.asyncNoop = require_asyncNoop.asyncNoop; +exports.at = require_at.at; +exports.attempt = require_attempt.attempt; +exports.attemptAsync = require_attemptAsync.attemptAsync; +exports.before = require_before.before; +exports.camelCase = require_camelCase.camelCase; +exports.capitalize = require_capitalize.capitalize; +exports.cartesianProduct = require_cartesianProduct.cartesianProduct; +exports.chunk = require_chunk.chunk; +exports.chunkBy = require_chunkBy.chunkBy; +exports.clamp = require_clamp.clamp; +exports.clone = require_clone.clone; +exports.cloneDeep = require_cloneDeep.cloneDeep; +exports.cloneDeepWith = require_cloneDeepWith.cloneDeepWith; +exports.combinations = require_combinations.combinations; +exports.compact = require_compact.compact; +exports.constantCase = require_constantCase.constantCase; +exports.countBy = require_countBy.countBy; +exports.curry = require_curry.curry; +exports.curryRight = require_curryRight.curryRight; +exports.debounce = require_debounce.debounce; +exports.deburr = require_deburr.deburr; +exports.delay = require_delay.delay; +exports.difference = require_difference.difference; +exports.differenceBy = require_differenceBy.differenceBy; +exports.differenceWith = require_differenceWith.differenceWith; +exports.drop = require_drop.drop; +exports.dropRight = require_dropRight.dropRight; +exports.dropRightWhile = require_dropRightWhile.dropRightWhile; +exports.dropWhile = require_dropWhile.dropWhile; +exports.escape = require_escape.escape; +exports.escapeRegExp = require_escapeRegExp.escapeRegExp; +exports.fill = require_fill.fill; +exports.filterAsync = require_filterAsync.filterAsync; +exports.findKey = require_findKey.findKey; +exports.flatMap = require_flatMap.flatMap; +exports.flatMapAsync = require_flatMapAsync.flatMapAsync; +exports.flatMapDeep = require_flatMapDeep.flatMapDeep; +exports.flatten = require_flatten.flatten; +exports.flattenDeep = require_flattenDeep.flattenDeep; +exports.flattenObject = require_flattenObject.flattenObject; +exports.flow = require_flow.flow; +exports.flowRight = require_flowRight.flowRight; +exports.forEachAsync = require_forEachAsync.forEachAsync; +exports.forEachRight = require_forEachRight.forEachRight; +exports.groupBy = require_groupBy.groupBy; +exports.head = require_head.head; +exports.identity = require_identity.identity; +exports.inRange = require_inRange.inRange; +exports.initial = require_initial.initial; +exports.intersection = require_intersection.intersection; +exports.intersectionBy = require_intersectionBy.intersectionBy; +exports.intersectionWith = require_intersectionWith.intersectionWith; +exports.invariant = require_invariant.invariant; +exports.invert = require_invert.invert; +exports.isArrayBuffer = require_isArrayBuffer.isArrayBuffer; +exports.isBlob = require_isBlob.isBlob; +exports.isBoolean = require_isBoolean.isBoolean; +exports.isBrowser = require_isBrowser.isBrowser; +exports.isBuffer = require_isBuffer.isBuffer; +exports.isDate = require_isDate.isDate; +exports.isEmptyObject = require_isEmptyObject.isEmptyObject; +exports.isEqual = require_isEqual.isEqual; +exports.isEqualWith = require_isEqualWith.isEqualWith; +exports.isError = require_isError.isError; +exports.isFile = require_isFile.isFile; +exports.isFunction = require_isFunction.isFunction; +exports.isIterable = require_isIterable.isIterable; +exports.isJSON = require_isJSON.isJSON; +exports.isJSONArray = require_isJSONValue.isJSONArray; +exports.isJSONObject = require_isJSONValue.isJSONObject; +exports.isJSONValue = require_isJSONValue.isJSONValue; +exports.isLength = require_isLength.isLength; +exports.isMap = require_isMap.isMap; +exports.isNil = require_isNil.isNil; +exports.isNode = require_isNode.isNode; +exports.isNotNil = require_isNotNil.isNotNil; +exports.isNull = require_isNull.isNull; +exports.isNumber = require_isNumber.isNumber; +exports.isPlainObject = require_isPlainObject.isPlainObject; +exports.isPrimitive = require_isPrimitive.isPrimitive; +exports.isPromise = require_isPromise.isPromise; +exports.isRegExp = require_isRegExp.isRegExp; +exports.isSet = require_isSet.isSet; +exports.isString = require_isString.isString; +exports.isSubset = require_isSubset.isSubset; +exports.isSubsetWith = require_isSubsetWith.isSubsetWith; +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.kebabCase = require_kebabCase.kebabCase; +exports.keyBy = require_keyBy.keyBy; +exports.last = require_last.last; +exports.limitAsync = require_limitAsync.limitAsync; +exports.lowerCase = require_lowerCase.lowerCase; +exports.lowerFirst = require_lowerFirst.lowerFirst; +exports.mapAsync = require_mapAsync.mapAsync; +exports.mapKeys = require_mapKeys.mapKeys; +exports.mapValues = require_mapValues.mapValues; +exports.maxBy = require_maxBy.maxBy; +exports.mean = require_mean.mean; +exports.meanBy = require_meanBy.meanBy; +exports.median = require_median.median; +exports.medianBy = require_medianBy.medianBy; +exports.memoize = require_memoize.memoize; +exports.merge = require_merge.merge; +exports.mergeWith = require_mergeWith.mergeWith; +exports.minBy = require_minBy.minBy; +exports.negate = require_negate.negate; +exports.noop = require_noop.noop; +exports.omit = require_omit.omit; +exports.omitBy = require_omitBy.omitBy; +exports.once = require_once.once; +exports.orderBy = require_orderBy.orderBy; +exports.pad = require_pad.pad; +exports.partial = require_partial.partial; +exports.partialRight = require_partialRight.partialRight; +exports.partition = require_partition.partition; +exports.pascalCase = require_pascalCase.pascalCase; +exports.percentile = require_percentile.percentile; +exports.pick = require_pick.pick; +exports.pickBy = require_pickBy.pickBy; +exports.pull = require_pull.pull; +exports.pullAt = require_pullAt.pullAt; +exports.random = require_random.random; +exports.randomInt = require_randomInt.randomInt; +exports.range = require_range.range; +exports.rangeRight = require_rangeRight.rangeRight; +exports.reduceAsync = require_reduceAsync.reduceAsync; +exports.remove = require_remove.remove; +exports.rest = require_rest.rest; +exports.retry = require_retry.retry; +exports.reverseString = require_reverseString.reverseString; +exports.round = require_round.round; +exports.sample = require_sample.sample; +exports.sampleSize = require_sampleSize.sampleSize; +exports.shuffle = require_shuffle.shuffle; +exports.snakeCase = require_snakeCase.snakeCase; +exports.sortBy = require_sortBy.sortBy; +exports.sortKeys = require_sortKeys.sortKeys; +exports.spread = require_spread.spread; +exports.startCase = require_startCase.startCase; +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.throttle = require_throttle.throttle; +exports.timeout = require_timeout.timeout; +exports.toCamelCaseKeys = require_toCamelCaseKeys.toCamelCaseKeys; +exports.toFilled = require_toFilled.toFilled; +exports.toMerged = require_toMerged.toMerged; +exports.toSnakeCaseKeys = require_toSnakeCaseKeys.toSnakeCaseKeys; +exports.trim = require_trim.trim; +exports.trimEnd = require_trimEnd.trimEnd; +exports.trimStart = require_trimStart.trimStart; +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.unzip = require_unzip.unzip; +exports.unzipWith = require_unzipWith.unzipWith; +exports.upperCase = require_upperCase.upperCase; +exports.upperFirst = require_upperFirst.upperFirst; +exports.windowed = require_windowed.windowed; +exports.withTimeout = require_withTimeout.withTimeout; +exports.without = require_without.without; +exports.words = require_words.words; +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.zipWith = require_zipWith.zipWith; diff --git a/node_modules/es-toolkit/dist/index.mjs b/node_modules/es-toolkit/dist/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9d9ee418853a2a4f6b1684d5dc39a2d419d8c652 --- /dev/null +++ b/node_modules/es-toolkit/dist/index.mjs @@ -0,0 +1,197 @@ +import { at } from "./array/at.mjs"; +import { cartesianProduct } from "./array/cartesianProduct.mjs"; +import { chunk } from "./array/chunk.mjs"; +import { chunkBy } from "./array/chunkBy.mjs"; +import { combinations } from "./array/combinations.mjs"; +import { compact } from "./array/compact.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 { fill } from "./array/fill.mjs"; +import { Semaphore } from "./promise/semaphore.mjs"; +import { limitAsync } from "./array/limitAsync.mjs"; +import { filterAsync } from "./array/filterAsync.mjs"; +import { flatten } from "./array/flatten.mjs"; +import { flatMap } from "./array/flatMap.mjs"; +import { flatMapAsync } from "./array/flatMapAsync.mjs"; +import { flattenDeep } from "./array/flattenDeep.mjs"; +import { flatMapDeep } from "./array/flatMapDeep.mjs"; +import { forEachAsync } from "./array/forEachAsync.mjs"; +import { forEachRight } from "./array/forEachRight.mjs"; +import { groupBy } from "./array/groupBy.mjs"; +import { head } from "./array/head.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 { isSubset } from "./array/isSubset.mjs"; +import { isSubsetWith } from "./array/isSubsetWith.mjs"; +import { keyBy } from "./array/keyBy.mjs"; +import { last } from "./array/last.mjs"; +import { mapAsync } from "./array/mapAsync.mjs"; +import { maxBy } from "./array/maxBy.mjs"; +import { minBy } from "./array/minBy.mjs"; +import { orderBy } from "./array/orderBy.mjs"; +import { partition } from "./array/partition.mjs"; +import { pull } from "./array/pull.mjs"; +import { pullAt } from "./array/pullAt.mjs"; +import { reduceAsync } from "./array/reduceAsync.mjs"; +import { remove } from "./array/remove.mjs"; +import { sample } from "./array/sample.mjs"; +import { random } from "./math/random.mjs"; +import { randomInt } from "./math/randomInt.mjs"; +import { sampleSize } from "./array/sampleSize.mjs"; +import { shuffle } from "./array/shuffle.mjs"; +import { sortBy } from "./array/sortBy.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 { toFilled } from "./array/toFilled.mjs"; +import { uniq } from "./array/uniq.mjs"; +import { union } from "./array/union.mjs"; +import { uniqBy } from "./array/uniqBy.mjs"; +import { unionBy } from "./array/unionBy.mjs"; +import { uniqWith } from "./array/uniqWith.mjs"; +import { unionWith } from "./array/unionWith.mjs"; +import { unzip } from "./array/unzip.mjs"; +import { unzipWith } from "./array/unzipWith.mjs"; +import { windowed } from "./array/windowed.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 { zipWith } from "./array/zipWith.mjs"; +import "./array/index.mjs"; +import { AbortError } from "./error/AbortError.mjs"; +import { TimeoutError } from "./error/TimeoutError.mjs"; +import "./error/index.mjs"; +import { after } from "./function/after.mjs"; +import { ary } from "./function/ary.mjs"; +import { asyncNoop } from "./function/asyncNoop.mjs"; +import { before } from "./function/before.mjs"; +import { curry } from "./function/curry.mjs"; +import { curryRight } from "./function/curryRight.mjs"; +import { debounce } from "./function/debounce.mjs"; +import { flow } from "./function/flow.mjs"; +import { flowRight } from "./function/flowRight.mjs"; +import { identity } from "./function/identity.mjs"; +import { memoize } from "./function/memoize.mjs"; +import { negate } from "./function/negate.mjs"; +import { noop } from "./function/noop.mjs"; +import { once } from "./function/once.mjs"; +import { partial } from "./function/partial.mjs"; +import { partialRight } from "./function/partialRight.mjs"; +import { rest } from "./function/rest.mjs"; +import { delay } from "./promise/delay.mjs"; +import { retry } from "./function/retry.mjs"; +import { spread } from "./function/spread.mjs"; +import { throttle } from "./function/throttle.mjs"; +import { unary } from "./function/unary.mjs"; +import "./function/index.mjs"; +import { clamp } from "./math/clamp.mjs"; +import { inRange } from "./math/inRange.mjs"; +import { sum } from "./math/sum.mjs"; +import { mean } from "./math/mean.mjs"; +import { sumBy } from "./math/sumBy.mjs"; +import { meanBy } from "./math/meanBy.mjs"; +import { median } from "./math/median.mjs"; +import { medianBy } from "./math/medianBy.mjs"; +import { percentile } from "./math/percentile.mjs"; +import { range } from "./math/range.mjs"; +import { rangeRight } from "./math/rangeRight.mjs"; +import { round } from "./math/round.mjs"; +import "./math/index.mjs"; +import { isPrimitive } from "./predicate/isPrimitive.mjs"; +import { isTypedArray } from "./predicate/isTypedArray.mjs"; +import { clone } from "./object/clone.mjs"; +import { isBuffer } from "./predicate/isBuffer.mjs"; +import { cloneDeepWith } from "./object/cloneDeepWith.mjs"; +import { cloneDeep } from "./object/cloneDeep.mjs"; +import { findKey } from "./object/findKey.mjs"; +import { isPlainObject } from "./predicate/isPlainObject.mjs"; +import { flattenObject } from "./object/flattenObject.mjs"; +import { invert } from "./object/invert.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 { sortKeys } from "./object/sortKeys.mjs"; +import { capitalize } from "./string/capitalize.mjs"; +import { words } from "./string/words.mjs"; +import { camelCase } from "./string/camelCase.mjs"; +import { toCamelCaseKeys } from "./object/toCamelCaseKeys.mjs"; +import { toMerged } from "./object/toMerged.mjs"; +import { snakeCase } from "./string/snakeCase.mjs"; +import { toSnakeCaseKeys } from "./object/toSnakeCaseKeys.mjs"; +import "./object/index.mjs"; +import { isArrayBuffer } from "./predicate/isArrayBuffer.mjs"; +import { isBlob } from "./predicate/isBlob.mjs"; +import { isBoolean } from "./predicate/isBoolean.mjs"; +import { isBrowser } from "./predicate/isBrowser.mjs"; +import { isDate } from "./predicate/isDate.mjs"; +import { isEmptyObject } from "./predicate/isEmptyObject.mjs"; +import { isEqualWith } from "./predicate/isEqualWith.mjs"; +import { isEqual } from "./predicate/isEqual.mjs"; +import { isError } from "./predicate/isError.mjs"; +import { isFile } from "./predicate/isFile.mjs"; +import { isFunction } from "./predicate/isFunction.mjs"; +import { isIterable } from "./predicate/isIterable.mjs"; +import { isJSON } from "./predicate/isJSON.mjs"; +import { isJSONArray, isJSONObject, isJSONValue } from "./predicate/isJSONValue.mjs"; +import { isLength } from "./predicate/isLength.mjs"; +import { isMap } from "./predicate/isMap.mjs"; +import { isNil } from "./predicate/isNil.mjs"; +import { isNode } from "./predicate/isNode.mjs"; +import { isNotNil } from "./predicate/isNotNil.mjs"; +import { isNull } from "./predicate/isNull.mjs"; +import { isNumber } from "./predicate/isNumber.mjs"; +import { isPromise } from "./predicate/isPromise.mjs"; +import { isRegExp } from "./predicate/isRegExp.mjs"; +import { isSet } from "./predicate/isSet.mjs"; +import { isString } from "./predicate/isString.mjs"; +import { isSymbol } from "./predicate/isSymbol.mjs"; +import { isUndefined } from "./predicate/isUndefined.mjs"; +import { isWeakMap } from "./predicate/isWeakMap.mjs"; +import { isWeakSet } from "./predicate/isWeakSet.mjs"; +import "./predicate/index.mjs"; +import { allKeyed } from "./promise/allKeyed.mjs"; +import { Mutex } from "./promise/mutex.mjs"; +import { timeout } from "./promise/timeout.mjs"; +import { withTimeout } from "./promise/withTimeout.mjs"; +import "./promise/index.mjs"; +import { constantCase } from "./string/constantCase.mjs"; +import { deburr } from "./string/deburr.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 { pascalCase } from "./string/pascalCase.mjs"; +import { reverseString } from "./string/reverseString.mjs"; +import { startCase } from "./string/startCase.mjs"; +import { trimEnd } from "./string/trimEnd.mjs"; +import { trimStart } from "./string/trimStart.mjs"; +import { trim } from "./string/trim.mjs"; +import { unescape } from "./string/unescape.mjs"; +import { upperCase } from "./string/upperCase.mjs"; +import { upperFirst } from "./string/upperFirst.mjs"; +import "./string/index.mjs"; +import { attempt } from "./util/attempt.mjs"; +import { attemptAsync } from "./util/attemptAsync.mjs"; +import { invariant } from "./util/invariant.mjs"; +import "./util/index.mjs"; +export { AbortError, Mutex, Semaphore, TimeoutError, after, allKeyed, ary, invariant as assert, asyncNoop, at, attempt, attemptAsync, before, camelCase, capitalize, cartesianProduct, chunk, chunkBy, clamp, clone, cloneDeep, cloneDeepWith, combinations, compact, constantCase, countBy, curry, curryRight, debounce, deburr, delay, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, escape, escapeRegExp, fill, filterAsync, findKey, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, flattenObject, flow, flowRight, forEachAsync, forEachRight, groupBy, head, identity, inRange, initial, intersection, intersectionBy, intersectionWith, invariant, invert, isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFunction, isIterable, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNil, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSubset, isSubsetWith, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, kebabCase, keyBy, last, limitAsync, lowerCase, lowerFirst, mapAsync, mapKeys, mapValues, maxBy, mean, meanBy, median, medianBy, memoize, merge, mergeWith, minBy, negate, noop, omit, omitBy, once, orderBy, pad, partial, partialRight, partition, pascalCase, percentile, pick, pickBy, pull, pullAt, random, randomInt, range, rangeRight, reduceAsync, remove, rest, retry, reverseString, round, sample, sampleSize, shuffle, snakeCase, sortBy, sortKeys, spread, startCase, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, throttle, timeout, toCamelCaseKeys, toFilled, toMerged, toSnakeCaseKeys, trim, trimEnd, trimStart, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, upperCase, upperFirst, windowed, withTimeout, without, words, xor, xorBy, xorWith, zip, zipObject, zipWith }; diff --git a/node_modules/es-toolkit/dist/map/countBy.d.mts b/node_modules/es-toolkit/dist/map/countBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..49206383a7a770d3c86e9828e54c4e10fd3529a8 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/countBy.d.mts @@ -0,0 +1,36 @@ +//#region src/map/countBy.d.ts +/** + * Counts the occurrences of items in a Map based on a transformation function. + * + * This function takes a Map and a function that generates a key from each value-key pair. + * It returns an object with the generated keys as properties and their counts as values. + * The count is incremented for each entry for which the transformation produces the same key. + * + * @template K - The type of the Map's keys. + * @template V - The type of the Map's values. + * @template K2 - The type of keys produced by the transformation function. + * @param map - The Map to count occurrences from. + * @param mapper - The function to produce a key for counting. + * @returns An object containing the mapped keys and their counts. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 1] + * ]); + * const result = countBy(map, (value) => value); + * // result will be { 1: 2, 2: 1 } + * + * @example + * const map = new Map([ + * ['alice', 20], + * ['bob', 30], + * ['carol', 20] + * ]); + * const result = countBy(map, (value, key) => key[0]); + * // result will be { a: 1, b: 1, c: 1 } + */ +declare function countBy(map: Map, mapper: (value: V, key: K, object: Map) => K2): Map; +//#endregion +export { countBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/countBy.d.ts b/node_modules/es-toolkit/dist/map/countBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..49206383a7a770d3c86e9828e54c4e10fd3529a8 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/countBy.d.ts @@ -0,0 +1,36 @@ +//#region src/map/countBy.d.ts +/** + * Counts the occurrences of items in a Map based on a transformation function. + * + * This function takes a Map and a function that generates a key from each value-key pair. + * It returns an object with the generated keys as properties and their counts as values. + * The count is incremented for each entry for which the transformation produces the same key. + * + * @template K - The type of the Map's keys. + * @template V - The type of the Map's values. + * @template K2 - The type of keys produced by the transformation function. + * @param map - The Map to count occurrences from. + * @param mapper - The function to produce a key for counting. + * @returns An object containing the mapped keys and their counts. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 1] + * ]); + * const result = countBy(map, (value) => value); + * // result will be { 1: 2, 2: 1 } + * + * @example + * const map = new Map([ + * ['alice', 20], + * ['bob', 30], + * ['carol', 20] + * ]); + * const result = countBy(map, (value, key) => key[0]); + * // result will be { a: 1, b: 1, c: 1 } + */ +declare function countBy(map: Map, mapper: (value: V, key: K, object: Map) => K2): Map; +//#endregion +export { countBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/countBy.js b/node_modules/es-toolkit/dist/map/countBy.js new file mode 100644 index 0000000000000000000000000000000000000000..f8f9a55e198347a099d23ab2f2d8ab98b969bd3a --- /dev/null +++ b/node_modules/es-toolkit/dist/map/countBy.js @@ -0,0 +1,43 @@ +//#region src/map/countBy.ts +/** +* Counts the occurrences of items in a Map based on a transformation function. +* +* This function takes a Map and a function that generates a key from each value-key pair. +* It returns an object with the generated keys as properties and their counts as values. +* The count is incremented for each entry for which the transformation produces the same key. +* +* @template K - The type of the Map's keys. +* @template V - The type of the Map's values. +* @template K2 - The type of keys produced by the transformation function. +* @param map - The Map to count occurrences from. +* @param mapper - The function to produce a key for counting. +* @returns An object containing the mapped keys and their counts. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 1] +* ]); +* const result = countBy(map, (value) => value); +* // result will be { 1: 2, 2: 1 } +* +* @example +* const map = new Map([ +* ['alice', 20], +* ['bob', 30], +* ['carol', 20] +* ]); +* const result = countBy(map, (value, key) => key[0]); +* // result will be { a: 1, b: 1, c: 1 } +*/ +function countBy(map, mapper) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) { + const mappedKey = mapper(value, key, map); + result.set(mappedKey, (result.get(mappedKey) ?? 0) + 1); + } + return result; +} +//#endregion +exports.countBy = countBy; diff --git a/node_modules/es-toolkit/dist/map/countBy.mjs b/node_modules/es-toolkit/dist/map/countBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1254e27f272ea4e3cd9f3ba290f1ecbad21dad3d --- /dev/null +++ b/node_modules/es-toolkit/dist/map/countBy.mjs @@ -0,0 +1,43 @@ +//#region src/map/countBy.ts +/** +* Counts the occurrences of items in a Map based on a transformation function. +* +* This function takes a Map and a function that generates a key from each value-key pair. +* It returns an object with the generated keys as properties and their counts as values. +* The count is incremented for each entry for which the transformation produces the same key. +* +* @template K - The type of the Map's keys. +* @template V - The type of the Map's values. +* @template K2 - The type of keys produced by the transformation function. +* @param map - The Map to count occurrences from. +* @param mapper - The function to produce a key for counting. +* @returns An object containing the mapped keys and their counts. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 1] +* ]); +* const result = countBy(map, (value) => value); +* // result will be { 1: 2, 2: 1 } +* +* @example +* const map = new Map([ +* ['alice', 20], +* ['bob', 30], +* ['carol', 20] +* ]); +* const result = countBy(map, (value, key) => key[0]); +* // result will be { a: 1, b: 1, c: 1 } +*/ +function countBy(map, mapper) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) { + const mappedKey = mapper(value, key, map); + result.set(mappedKey, (result.get(mappedKey) ?? 0) + 1); + } + return result; +} +//#endregion +export { countBy }; diff --git a/node_modules/es-toolkit/dist/map/every.d.mts b/node_modules/es-toolkit/dist/map/every.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..35b17a32dc264dd4d0ce0c22dad2dc3a6d7f5470 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/every.d.mts @@ -0,0 +1,29 @@ +//#region src/map/every.d.ts +/** + * Tests whether all entries in a Map satisfy the provided predicate function. + * + * This function iterates through all entries of the Map and checks if the predicate function + * returns true for every entry. It returns true if the predicate is satisfied for all entries, + * and false otherwise. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to test. + * @param doesMatch - A predicate function that tests each entry. + * @returns true if all entries satisfy the predicate, false otherwise. + * + * @example + * const map = new Map([ + * ['a', 10], + * ['b', 20], + * ['c', 30] + * ]); + * const result = every(map, (value) => value > 5); + * // result will be: true + * + * const result2 = every(map, (value) => value > 15); + * // result2 will be: false + */ +declare function every(map: Map, doesMatch: (value: V, key: K, map: Map) => boolean): boolean; +//#endregion +export { every }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/every.d.ts b/node_modules/es-toolkit/dist/map/every.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..35b17a32dc264dd4d0ce0c22dad2dc3a6d7f5470 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/every.d.ts @@ -0,0 +1,29 @@ +//#region src/map/every.d.ts +/** + * Tests whether all entries in a Map satisfy the provided predicate function. + * + * This function iterates through all entries of the Map and checks if the predicate function + * returns true for every entry. It returns true if the predicate is satisfied for all entries, + * and false otherwise. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to test. + * @param doesMatch - A predicate function that tests each entry. + * @returns true if all entries satisfy the predicate, false otherwise. + * + * @example + * const map = new Map([ + * ['a', 10], + * ['b', 20], + * ['c', 30] + * ]); + * const result = every(map, (value) => value > 5); + * // result will be: true + * + * const result2 = every(map, (value) => value > 15); + * // result2 will be: false + */ +declare function every(map: Map, doesMatch: (value: V, key: K, map: Map) => boolean): boolean; +//#endregion +export { every }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/every.js b/node_modules/es-toolkit/dist/map/every.js new file mode 100644 index 0000000000000000000000000000000000000000..8987cbd1c29f185c42e78a5ed8709ba1759b9228 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/every.js @@ -0,0 +1,32 @@ +//#region src/map/every.ts +/** +* Tests whether all entries in a Map satisfy the provided predicate function. +* +* This function iterates through all entries of the Map and checks if the predicate function +* returns true for every entry. It returns true if the predicate is satisfied for all entries, +* and false otherwise. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to test. +* @param doesMatch - A predicate function that tests each entry. +* @returns true if all entries satisfy the predicate, false otherwise. +* +* @example +* const map = new Map([ +* ['a', 10], +* ['b', 20], +* ['c', 30] +* ]); +* const result = every(map, (value) => value > 5); +* // result will be: true +* +* const result2 = every(map, (value) => value > 15); +* // result2 will be: false +*/ +function every(map, doesMatch) { + for (const [key, value] of map) if (!doesMatch(value, key, map)) return false; + return true; +} +//#endregion +exports.every = every; diff --git a/node_modules/es-toolkit/dist/map/every.mjs b/node_modules/es-toolkit/dist/map/every.mjs new file mode 100644 index 0000000000000000000000000000000000000000..aa80ca09a5082bf3b5e214762b3a3805d886b570 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/every.mjs @@ -0,0 +1,32 @@ +//#region src/map/every.ts +/** +* Tests whether all entries in a Map satisfy the provided predicate function. +* +* This function iterates through all entries of the Map and checks if the predicate function +* returns true for every entry. It returns true if the predicate is satisfied for all entries, +* and false otherwise. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to test. +* @param doesMatch - A predicate function that tests each entry. +* @returns true if all entries satisfy the predicate, false otherwise. +* +* @example +* const map = new Map([ +* ['a', 10], +* ['b', 20], +* ['c', 30] +* ]); +* const result = every(map, (value) => value > 5); +* // result will be: true +* +* const result2 = every(map, (value) => value > 15); +* // result2 will be: false +*/ +function every(map, doesMatch) { + for (const [key, value] of map) if (!doesMatch(value, key, map)) return false; + return true; +} +//#endregion +export { every }; diff --git a/node_modules/es-toolkit/dist/map/filter.d.mts b/node_modules/es-toolkit/dist/map/filter.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e3752ee5877282a2eb5b7d760f47f17efc1fc880 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/filter.d.mts @@ -0,0 +1,30 @@ +//#region src/map/filter.d.ts +/** + * Filters a Map based on a predicate function. + * + * This function takes a Map and a predicate function, and returns a new Map containing + * only the entries for which the predicate function returns true. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to filter. + * @param callback - A predicate function that tests each entry. + * @returns A new Map containing only the entries that satisfy the predicate. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3], + * ['d', 4] + * ]); + * const result = filter(map, (value) => value > 2); + * // result will be: + * // Map(2) { + * // 'c' => 3, + * // 'd' => 4 + * // } + */ +declare function filter(map: Map, callback: (value: V, key: K, map: Map) => boolean): Map; +//#endregion +export { filter }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/filter.d.ts b/node_modules/es-toolkit/dist/map/filter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3752ee5877282a2eb5b7d760f47f17efc1fc880 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/filter.d.ts @@ -0,0 +1,30 @@ +//#region src/map/filter.d.ts +/** + * Filters a Map based on a predicate function. + * + * This function takes a Map and a predicate function, and returns a new Map containing + * only the entries for which the predicate function returns true. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to filter. + * @param callback - A predicate function that tests each entry. + * @returns A new Map containing only the entries that satisfy the predicate. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3], + * ['d', 4] + * ]); + * const result = filter(map, (value) => value > 2); + * // result will be: + * // Map(2) { + * // 'c' => 3, + * // 'd' => 4 + * // } + */ +declare function filter(map: Map, callback: (value: V, key: K, map: Map) => boolean): Map; +//#endregion +export { filter }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/filter.js b/node_modules/es-toolkit/dist/map/filter.js new file mode 100644 index 0000000000000000000000000000000000000000..49cbf3d0882ba0f4d7997f7a6ac1547be6f26ce8 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/filter.js @@ -0,0 +1,34 @@ +//#region src/map/filter.ts +/** +* Filters a Map based on a predicate function. +* +* This function takes a Map and a predicate function, and returns a new Map containing +* only the entries for which the predicate function returns true. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to filter. +* @param callback - A predicate function that tests each entry. +* @returns A new Map containing only the entries that satisfy the predicate. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3], +* ['d', 4] +* ]); +* const result = filter(map, (value) => value > 2); +* // result will be: +* // Map(2) { +* // 'c' => 3, +* // 'd' => 4 +* // } +*/ +function filter(map, callback) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) if (callback(value, key, map)) result.set(key, value); + return result; +} +//#endregion +exports.filter = filter; diff --git a/node_modules/es-toolkit/dist/map/filter.mjs b/node_modules/es-toolkit/dist/map/filter.mjs new file mode 100644 index 0000000000000000000000000000000000000000..485bb71b369dae4355656d8d439489bef0687d09 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/filter.mjs @@ -0,0 +1,34 @@ +//#region src/map/filter.ts +/** +* Filters a Map based on a predicate function. +* +* This function takes a Map and a predicate function, and returns a new Map containing +* only the entries for which the predicate function returns true. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to filter. +* @param callback - A predicate function that tests each entry. +* @returns A new Map containing only the entries that satisfy the predicate. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3], +* ['d', 4] +* ]); +* const result = filter(map, (value) => value > 2); +* // result will be: +* // Map(2) { +* // 'c' => 3, +* // 'd' => 4 +* // } +*/ +function filter(map, callback) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) if (callback(value, key, map)) result.set(key, value); + return result; +} +//#endregion +export { filter }; diff --git a/node_modules/es-toolkit/dist/map/findKey.d.mts b/node_modules/es-toolkit/dist/map/findKey.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3c30455b34cd1e42a8d32d8a2eb81b537f4c4110 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/findKey.d.mts @@ -0,0 +1,26 @@ +//#region src/map/findKey.d.ts +/** + * Finds the first key in a Map for which the predicate function returns true. + * + * This function iterates through the entries of the Map and returns the key of the first + * entry for which the predicate function returns true. If no entry satisfies the predicate, + * it returns undefined. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to search. + * @param doesMatch - A predicate function that tests each entry. + * @returns The key of the first entry that satisfies the predicate, or undefined if none found. + * + * @example + * const map = new Map([ + * ['apple', { color: 'red', quantity: 10 }], + * ['banana', { color: 'yellow', quantity: 5 }], + * ['grape', { color: 'purple', quantity: 15 }] + * ]); + * const result = findKey(map, (value) => value.quantity > 10); + * // result will be: 'grape' + */ +declare function findKey(map: Map, doesMatch: (value: V, key: K, map: Map) => boolean): K | undefined; +//#endregion +export { findKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/findKey.d.ts b/node_modules/es-toolkit/dist/map/findKey.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c30455b34cd1e42a8d32d8a2eb81b537f4c4110 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/findKey.d.ts @@ -0,0 +1,26 @@ +//#region src/map/findKey.d.ts +/** + * Finds the first key in a Map for which the predicate function returns true. + * + * This function iterates through the entries of the Map and returns the key of the first + * entry for which the predicate function returns true. If no entry satisfies the predicate, + * it returns undefined. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to search. + * @param doesMatch - A predicate function that tests each entry. + * @returns The key of the first entry that satisfies the predicate, or undefined if none found. + * + * @example + * const map = new Map([ + * ['apple', { color: 'red', quantity: 10 }], + * ['banana', { color: 'yellow', quantity: 5 }], + * ['grape', { color: 'purple', quantity: 15 }] + * ]); + * const result = findKey(map, (value) => value.quantity > 10); + * // result will be: 'grape' + */ +declare function findKey(map: Map, doesMatch: (value: V, key: K, map: Map) => boolean): K | undefined; +//#endregion +export { findKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/findKey.js b/node_modules/es-toolkit/dist/map/findKey.js new file mode 100644 index 0000000000000000000000000000000000000000..6878f84798198f7ffcf243002ab6f52b1a77e85d --- /dev/null +++ b/node_modules/es-toolkit/dist/map/findKey.js @@ -0,0 +1,33 @@ +//#region src/map/findKey.ts +/** +* Finds the first key in a Map for which the predicate function returns true. +* +* This function iterates through the entries of the Map and returns the key of the first +* entry for which the predicate function returns true. If no entry satisfies the predicate, +* it returns undefined. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to search. +* @param doesMatch - A predicate function that tests each entry. +* @returns The key of the first entry that satisfies the predicate, or undefined if none found. +* +* @example +* const map = new Map([ +* ['apple', { color: 'red', quantity: 10 }], +* ['banana', { color: 'yellow', quantity: 5 }], +* ['grape', { color: 'purple', quantity: 15 }] +* ]); +* const result = findKey(map, (value) => value.quantity > 10); +* // result will be: 'grape' +*/ +function findKey(map, doesMatch) { + let result = void 0; + for (const [key, value] of map) if (doesMatch(value, key, map)) { + result = key; + break; + } + return result; +} +//#endregion +exports.findKey = findKey; diff --git a/node_modules/es-toolkit/dist/map/findKey.mjs b/node_modules/es-toolkit/dist/map/findKey.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fb485c7417dab3074374e7785e9fdef67e9ad87d --- /dev/null +++ b/node_modules/es-toolkit/dist/map/findKey.mjs @@ -0,0 +1,33 @@ +//#region src/map/findKey.ts +/** +* Finds the first key in a Map for which the predicate function returns true. +* +* This function iterates through the entries of the Map and returns the key of the first +* entry for which the predicate function returns true. If no entry satisfies the predicate, +* it returns undefined. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to search. +* @param doesMatch - A predicate function that tests each entry. +* @returns The key of the first entry that satisfies the predicate, or undefined if none found. +* +* @example +* const map = new Map([ +* ['apple', { color: 'red', quantity: 10 }], +* ['banana', { color: 'yellow', quantity: 5 }], +* ['grape', { color: 'purple', quantity: 15 }] +* ]); +* const result = findKey(map, (value) => value.quantity > 10); +* // result will be: 'grape' +*/ +function findKey(map, doesMatch) { + let result = void 0; + for (const [key, value] of map) if (doesMatch(value, key, map)) { + result = key; + break; + } + return result; +} +//#endregion +export { findKey }; diff --git a/node_modules/es-toolkit/dist/map/findValue.d.mts b/node_modules/es-toolkit/dist/map/findValue.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..cbbd00a630ad18145d8a12a7b10859c8d36d9bb6 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/findValue.d.mts @@ -0,0 +1,26 @@ +//#region src/map/findValue.d.ts +/** + * Finds the first value in a Map for which the predicate function returns true. + * + * This function iterates through the entries of the Map and returns the value of the first + * entry for which the predicate function returns true. If no entry satisfies the predicate, + * it returns undefined. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to search. + * @param doesMatch - A predicate function that tests each entry. + * @returns The value of the first entry that satisfies the predicate, or undefined if none found. + * + * @example + * const map = new Map([ + * ['apple', { color: 'red', quantity: 10 }], + * ['banana', { color: 'yellow', quantity: 5 }], + * ['grape', { color: 'purple', quantity: 15 }] + * ]); + * const result = findValue(map, (value) => value.quantity > 10); + * // result will be: { color: 'purple', quantity: 15 } + */ +declare function findValue(map: Map, doesMatch: (value: V, key: K, map: Map) => boolean): V | undefined; +//#endregion +export { findValue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/findValue.d.ts b/node_modules/es-toolkit/dist/map/findValue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbbd00a630ad18145d8a12a7b10859c8d36d9bb6 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/findValue.d.ts @@ -0,0 +1,26 @@ +//#region src/map/findValue.d.ts +/** + * Finds the first value in a Map for which the predicate function returns true. + * + * This function iterates through the entries of the Map and returns the value of the first + * entry for which the predicate function returns true. If no entry satisfies the predicate, + * it returns undefined. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to search. + * @param doesMatch - A predicate function that tests each entry. + * @returns The value of the first entry that satisfies the predicate, or undefined if none found. + * + * @example + * const map = new Map([ + * ['apple', { color: 'red', quantity: 10 }], + * ['banana', { color: 'yellow', quantity: 5 }], + * ['grape', { color: 'purple', quantity: 15 }] + * ]); + * const result = findValue(map, (value) => value.quantity > 10); + * // result will be: { color: 'purple', quantity: 15 } + */ +declare function findValue(map: Map, doesMatch: (value: V, key: K, map: Map) => boolean): V | undefined; +//#endregion +export { findValue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/findValue.js b/node_modules/es-toolkit/dist/map/findValue.js new file mode 100644 index 0000000000000000000000000000000000000000..873d943a8d5f6e00b767569d91529d72aa822b5a --- /dev/null +++ b/node_modules/es-toolkit/dist/map/findValue.js @@ -0,0 +1,33 @@ +//#region src/map/findValue.ts +/** +* Finds the first value in a Map for which the predicate function returns true. +* +* This function iterates through the entries of the Map and returns the value of the first +* entry for which the predicate function returns true. If no entry satisfies the predicate, +* it returns undefined. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to search. +* @param doesMatch - A predicate function that tests each entry. +* @returns The value of the first entry that satisfies the predicate, or undefined if none found. +* +* @example +* const map = new Map([ +* ['apple', { color: 'red', quantity: 10 }], +* ['banana', { color: 'yellow', quantity: 5 }], +* ['grape', { color: 'purple', quantity: 15 }] +* ]); +* const result = findValue(map, (value) => value.quantity > 10); +* // result will be: { color: 'purple', quantity: 15 } +*/ +function findValue(map, doesMatch) { + let result = void 0; + for (const [key, value] of map) if (doesMatch(value, key, map)) { + result = value; + break; + } + return result; +} +//#endregion +exports.findValue = findValue; diff --git a/node_modules/es-toolkit/dist/map/findValue.mjs b/node_modules/es-toolkit/dist/map/findValue.mjs new file mode 100644 index 0000000000000000000000000000000000000000..145f0bb48ea5e2cda6b55e272f0e4153df7c0f30 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/findValue.mjs @@ -0,0 +1,33 @@ +//#region src/map/findValue.ts +/** +* Finds the first value in a Map for which the predicate function returns true. +* +* This function iterates through the entries of the Map and returns the value of the first +* entry for which the predicate function returns true. If no entry satisfies the predicate, +* it returns undefined. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to search. +* @param doesMatch - A predicate function that tests each entry. +* @returns The value of the first entry that satisfies the predicate, or undefined if none found. +* +* @example +* const map = new Map([ +* ['apple', { color: 'red', quantity: 10 }], +* ['banana', { color: 'yellow', quantity: 5 }], +* ['grape', { color: 'purple', quantity: 15 }] +* ]); +* const result = findValue(map, (value) => value.quantity > 10); +* // result will be: { color: 'purple', quantity: 15 } +*/ +function findValue(map, doesMatch) { + let result = void 0; + for (const [key, value] of map) if (doesMatch(value, key, map)) { + result = value; + break; + } + return result; +} +//#endregion +export { findValue }; diff --git a/node_modules/es-toolkit/dist/map/forEach.d.mts b/node_modules/es-toolkit/dist/map/forEach.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f485e6173843cabac372e5fffcdfc55e8da2eeb3 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/forEach.d.mts @@ -0,0 +1,29 @@ +//#region src/map/forEach.d.ts +/** + * Executes a provided function once for each entry in a Map. + * + * This function iterates through all entries of the Map and executes the callback function + * for each entry. The callback receives the value, key, and the Map itself as arguments. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to iterate over. + * @param callback - A function to execute for each entry. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * forEach(map, (value, key) => { + * console.log(`${key}: ${value}`); + * }); + * // Output: + * // a: 1 + * // b: 2 + * // c: 3 + */ +declare function forEach(map: Map, callback: (value: V, key: K, map: Map) => void): void; +//#endregion +export { forEach }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/forEach.d.ts b/node_modules/es-toolkit/dist/map/forEach.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f485e6173843cabac372e5fffcdfc55e8da2eeb3 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/forEach.d.ts @@ -0,0 +1,29 @@ +//#region src/map/forEach.d.ts +/** + * Executes a provided function once for each entry in a Map. + * + * This function iterates through all entries of the Map and executes the callback function + * for each entry. The callback receives the value, key, and the Map itself as arguments. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to iterate over. + * @param callback - A function to execute for each entry. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * forEach(map, (value, key) => { + * console.log(`${key}: ${value}`); + * }); + * // Output: + * // a: 1 + * // b: 2 + * // c: 3 + */ +declare function forEach(map: Map, callback: (value: V, key: K, map: Map) => void): void; +//#endregion +export { forEach }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/forEach.js b/node_modules/es-toolkit/dist/map/forEach.js new file mode 100644 index 0000000000000000000000000000000000000000..7d3a169f93f4df69b0a21dc9edec2d04320f2a78 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/forEach.js @@ -0,0 +1,31 @@ +//#region src/map/forEach.ts +/** +* Executes a provided function once for each entry in a Map. +* +* This function iterates through all entries of the Map and executes the callback function +* for each entry. The callback receives the value, key, and the Map itself as arguments. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to iterate over. +* @param callback - A function to execute for each entry. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* forEach(map, (value, key) => { +* console.log(`${key}: ${value}`); +* }); +* // Output: +* // a: 1 +* // b: 2 +* // c: 3 +*/ +function forEach(map, callback) { + for (const [key, value] of map) callback(value, key, map); +} +//#endregion +exports.forEach = forEach; diff --git a/node_modules/es-toolkit/dist/map/forEach.mjs b/node_modules/es-toolkit/dist/map/forEach.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3e07e71d2fffc5e9f9950c191ec8dcfaf04f5708 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/forEach.mjs @@ -0,0 +1,31 @@ +//#region src/map/forEach.ts +/** +* Executes a provided function once for each entry in a Map. +* +* This function iterates through all entries of the Map and executes the callback function +* for each entry. The callback receives the value, key, and the Map itself as arguments. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to iterate over. +* @param callback - A function to execute for each entry. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* forEach(map, (value, key) => { +* console.log(`${key}: ${value}`); +* }); +* // Output: +* // a: 1 +* // b: 2 +* // c: 3 +*/ +function forEach(map, callback) { + for (const [key, value] of map) callback(value, key, map); +} +//#endregion +export { forEach }; diff --git a/node_modules/es-toolkit/dist/map/hasValue.d.mts b/node_modules/es-toolkit/dist/map/hasValue.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..df1c79b502f44ab71351bf01d1ad5023d995a45d --- /dev/null +++ b/node_modules/es-toolkit/dist/map/hasValue.d.mts @@ -0,0 +1,29 @@ +//#region src/map/hasValue.d.ts +/** + * Checks if a Map contains a specific value. + * + * This function iterates through all values in the Map and checks if any value + * is equal to the search element using SameValueZero comparison (similar to + * Array.prototype.includes). This means that NaN is considered equal to NaN. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to search. + * @param searchElement - The value to search for. + * @returns true if the Map contains the value, false otherwise. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = hasValue(map, 2); + * // result will be: true + * + * const result2 = hasValue(map, 5); + * // result2 will be: false + */ +declare function hasValue(map: Map, searchElement: V): boolean; +//#endregion +export { hasValue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/hasValue.d.ts b/node_modules/es-toolkit/dist/map/hasValue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df1c79b502f44ab71351bf01d1ad5023d995a45d --- /dev/null +++ b/node_modules/es-toolkit/dist/map/hasValue.d.ts @@ -0,0 +1,29 @@ +//#region src/map/hasValue.d.ts +/** + * Checks if a Map contains a specific value. + * + * This function iterates through all values in the Map and checks if any value + * is equal to the search element using SameValueZero comparison (similar to + * Array.prototype.includes). This means that NaN is considered equal to NaN. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to search. + * @param searchElement - The value to search for. + * @returns true if the Map contains the value, false otherwise. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = hasValue(map, 2); + * // result will be: true + * + * const result2 = hasValue(map, 5); + * // result2 will be: false + */ +declare function hasValue(map: Map, searchElement: V): boolean; +//#endregion +export { hasValue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/hasValue.js b/node_modules/es-toolkit/dist/map/hasValue.js new file mode 100644 index 0000000000000000000000000000000000000000..26e5c3ad67987044ca1fc39a258ca316f3ae3e9f --- /dev/null +++ b/node_modules/es-toolkit/dist/map/hasValue.js @@ -0,0 +1,33 @@ +const require_eq = require("../compat/util/eq.js"); +//#region src/map/hasValue.ts +/** +* Checks if a Map contains a specific value. +* +* This function iterates through all values in the Map and checks if any value +* is equal to the search element using SameValueZero comparison (similar to +* Array.prototype.includes). This means that NaN is considered equal to NaN. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to search. +* @param searchElement - The value to search for. +* @returns true if the Map contains the value, false otherwise. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = hasValue(map, 2); +* // result will be: true +* +* const result2 = hasValue(map, 5); +* // result2 will be: false +*/ +function hasValue(map, searchElement) { + for (const value of map.values()) if (require_eq.eq(value, searchElement)) return true; + return false; +} +//#endregion +exports.hasValue = hasValue; diff --git a/node_modules/es-toolkit/dist/map/hasValue.mjs b/node_modules/es-toolkit/dist/map/hasValue.mjs new file mode 100644 index 0000000000000000000000000000000000000000..389b0d6a8bc80c7436d81c0790125c3cabc51234 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/hasValue.mjs @@ -0,0 +1,33 @@ +import { eq } from "../compat/util/eq.mjs"; +//#region src/map/hasValue.ts +/** +* Checks if a Map contains a specific value. +* +* This function iterates through all values in the Map and checks if any value +* is equal to the search element using SameValueZero comparison (similar to +* Array.prototype.includes). This means that NaN is considered equal to NaN. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to search. +* @param searchElement - The value to search for. +* @returns true if the Map contains the value, false otherwise. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = hasValue(map, 2); +* // result will be: true +* +* const result2 = hasValue(map, 5); +* // result2 will be: false +*/ +function hasValue(map, searchElement) { + for (const value of map.values()) if (eq(value, searchElement)) return true; + return false; +} +//#endregion +export { hasValue }; diff --git a/node_modules/es-toolkit/dist/map/index.d.mts b/node_modules/es-toolkit/dist/map/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b37e33bcceb7dca49c81b8d2c73dda8767d6ceab --- /dev/null +++ b/node_modules/es-toolkit/dist/map/index.d.mts @@ -0,0 +1,13 @@ +import { countBy } from "./countBy.mjs"; +import { every } from "./every.mjs"; +import { filter } from "./filter.mjs"; +import { findKey } from "./findKey.mjs"; +import { findValue } from "./findValue.mjs"; +import { forEach } from "./forEach.mjs"; +import { hasValue } from "./hasValue.mjs"; +import { keyBy } from "./keyBy.mjs"; +import { mapKeys } from "./mapKeys.mjs"; +import { mapValues } from "./mapValues.mjs"; +import { reduce } from "./reduce.mjs"; +import { some } from "./some.mjs"; +export { countBy, every, filter, findKey, findValue, forEach, hasValue, keyBy, mapKeys, mapValues, reduce, some }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/index.d.ts b/node_modules/es-toolkit/dist/map/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..34df790462ce93454d0146961c70864489fbaf73 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/index.d.ts @@ -0,0 +1,13 @@ +import { countBy } from "./countBy.js"; +import { every } from "./every.js"; +import { filter } from "./filter.js"; +import { findKey } from "./findKey.js"; +import { findValue } from "./findValue.js"; +import { forEach } from "./forEach.js"; +import { hasValue } from "./hasValue.js"; +import { keyBy } from "./keyBy.js"; +import { mapKeys } from "./mapKeys.js"; +import { mapValues } from "./mapValues.js"; +import { reduce } from "./reduce.js"; +import { some } from "./some.js"; +export { countBy, every, filter, findKey, findValue, forEach, hasValue, keyBy, mapKeys, mapValues, reduce, some }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/index.js b/node_modules/es-toolkit/dist/map/index.js new file mode 100644 index 0000000000000000000000000000000000000000..28139c8b840765076fb06d81836c791222b72d7e --- /dev/null +++ b/node_modules/es-toolkit/dist/map/index.js @@ -0,0 +1,25 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_countBy = require("./countBy.js"); +const require_every = require("./every.js"); +const require_filter = require("./filter.js"); +const require_findKey = require("./findKey.js"); +const require_findValue = require("./findValue.js"); +const require_forEach = require("./forEach.js"); +const require_hasValue = require("./hasValue.js"); +const require_keyBy = require("./keyBy.js"); +const require_mapKeys = require("./mapKeys.js"); +const require_mapValues = require("./mapValues.js"); +const require_reduce = require("./reduce.js"); +const require_some = require("./some.js"); +exports.countBy = require_countBy.countBy; +exports.every = require_every.every; +exports.filter = require_filter.filter; +exports.findKey = require_findKey.findKey; +exports.findValue = require_findValue.findValue; +exports.forEach = require_forEach.forEach; +exports.hasValue = require_hasValue.hasValue; +exports.keyBy = require_keyBy.keyBy; +exports.mapKeys = require_mapKeys.mapKeys; +exports.mapValues = require_mapValues.mapValues; +exports.reduce = require_reduce.reduce; +exports.some = require_some.some; diff --git a/node_modules/es-toolkit/dist/map/index.mjs b/node_modules/es-toolkit/dist/map/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..354c85c635203b1498d0442471dacd2a8cde7ff6 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/index.mjs @@ -0,0 +1,13 @@ +import { countBy } from "./countBy.mjs"; +import { every } from "./every.mjs"; +import { filter } from "./filter.mjs"; +import { findKey } from "./findKey.mjs"; +import { findValue } from "./findValue.mjs"; +import { forEach } from "./forEach.mjs"; +import { hasValue } from "./hasValue.mjs"; +import { keyBy } from "./keyBy.mjs"; +import { mapKeys } from "./mapKeys.mjs"; +import { mapValues } from "./mapValues.mjs"; +import { reduce } from "./reduce.mjs"; +import { some } from "./some.mjs"; +export { countBy, every, filter, findKey, findValue, forEach, hasValue, keyBy, mapKeys, mapValues, reduce, some }; diff --git a/node_modules/es-toolkit/dist/map/keyBy.d.mts b/node_modules/es-toolkit/dist/map/keyBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..15d7c5d15d121ce5cf192b46eb8e6e17af274fdb --- /dev/null +++ b/node_modules/es-toolkit/dist/map/keyBy.d.mts @@ -0,0 +1,32 @@ +//#region src/map/keyBy.d.ts +/** + * Maps each entry of a Map based on a provided key-generating function. + * + * This function takes a Map and a function that generates a key from each value-key pair. + * It returns a new Map where the keys are generated by the key function and the values are + * the corresponding values from the original map. If multiple entries produce the same key, + * the last value encountered will be used. + * + * @template K - The type of keys in the original Map. + * @template V - The type of values in the original Map. + * @template K2 - The type of keys to produce in the returned Map. + * @param map - The map of entries to be mapped. + * @param getKeyFromEntry - A function that generates a key from a value-key pair. + * @returns A Map where the generated keys are mapped to each entry's value. + * + * @example + * const map = new Map([ + * ['x', { type: 'fruit', name: 'apple' }], + * ['y', { type: 'fruit', name: 'banana' }], + * ['z', { type: 'vegetable', name: 'carrot' }] + * ]); + * const result = keyBy(map, item => item.type); + * // result will be: + * // Map(2) { + * // 'fruit' => { type: 'fruit', name: 'banana' }, + * // 'vegetable' => { type: 'vegetable', name: 'carrot' } + * // } + */ +declare function keyBy(map: Map, getKeyFromEntry: (value: V, key: K, object: Map) => K2): Map; +//#endregion +export { keyBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/keyBy.d.ts b/node_modules/es-toolkit/dist/map/keyBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..15d7c5d15d121ce5cf192b46eb8e6e17af274fdb --- /dev/null +++ b/node_modules/es-toolkit/dist/map/keyBy.d.ts @@ -0,0 +1,32 @@ +//#region src/map/keyBy.d.ts +/** + * Maps each entry of a Map based on a provided key-generating function. + * + * This function takes a Map and a function that generates a key from each value-key pair. + * It returns a new Map where the keys are generated by the key function and the values are + * the corresponding values from the original map. If multiple entries produce the same key, + * the last value encountered will be used. + * + * @template K - The type of keys in the original Map. + * @template V - The type of values in the original Map. + * @template K2 - The type of keys to produce in the returned Map. + * @param map - The map of entries to be mapped. + * @param getKeyFromEntry - A function that generates a key from a value-key pair. + * @returns A Map where the generated keys are mapped to each entry's value. + * + * @example + * const map = new Map([ + * ['x', { type: 'fruit', name: 'apple' }], + * ['y', { type: 'fruit', name: 'banana' }], + * ['z', { type: 'vegetable', name: 'carrot' }] + * ]); + * const result = keyBy(map, item => item.type); + * // result will be: + * // Map(2) { + * // 'fruit' => { type: 'fruit', name: 'banana' }, + * // 'vegetable' => { type: 'vegetable', name: 'carrot' } + * // } + */ +declare function keyBy(map: Map, getKeyFromEntry: (value: V, key: K, object: Map) => K2): Map; +//#endregion +export { keyBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/keyBy.js b/node_modules/es-toolkit/dist/map/keyBy.js new file mode 100644 index 0000000000000000000000000000000000000000..ebb432e256466cd1625b9bbc935b64889a02e3dd --- /dev/null +++ b/node_modules/es-toolkit/dist/map/keyBy.js @@ -0,0 +1,39 @@ +//#region src/map/keyBy.ts +/** +* Maps each entry of a Map based on a provided key-generating function. +* +* This function takes a Map and a function that generates a key from each value-key pair. +* It returns a new Map where the keys are generated by the key function and the values are +* the corresponding values from the original map. If multiple entries produce the same key, +* the last value encountered will be used. +* +* @template K - The type of keys in the original Map. +* @template V - The type of values in the original Map. +* @template K2 - The type of keys to produce in the returned Map. +* @param map - The map of entries to be mapped. +* @param getKeyFromEntry - A function that generates a key from a value-key pair. +* @returns A Map where the generated keys are mapped to each entry's value. +* +* @example +* const map = new Map([ +* ['x', { type: 'fruit', name: 'apple' }], +* ['y', { type: 'fruit', name: 'banana' }], +* ['z', { type: 'vegetable', name: 'carrot' }] +* ]); +* const result = keyBy(map, item => item.type); +* // result will be: +* // Map(2) { +* // 'fruit' => { type: 'fruit', name: 'banana' }, +* // 'vegetable' => { type: 'vegetable', name: 'carrot' } +* // } +*/ +function keyBy(map, getKeyFromEntry) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) { + const newKey = getKeyFromEntry(value, key, map); + result.set(newKey, value); + } + return result; +} +//#endregion +exports.keyBy = keyBy; diff --git a/node_modules/es-toolkit/dist/map/keyBy.mjs b/node_modules/es-toolkit/dist/map/keyBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1cdef8c8fd2e8151d0237163b1e61ce5881bb4e1 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/keyBy.mjs @@ -0,0 +1,39 @@ +//#region src/map/keyBy.ts +/** +* Maps each entry of a Map based on a provided key-generating function. +* +* This function takes a Map and a function that generates a key from each value-key pair. +* It returns a new Map where the keys are generated by the key function and the values are +* the corresponding values from the original map. If multiple entries produce the same key, +* the last value encountered will be used. +* +* @template K - The type of keys in the original Map. +* @template V - The type of values in the original Map. +* @template K2 - The type of keys to produce in the returned Map. +* @param map - The map of entries to be mapped. +* @param getKeyFromEntry - A function that generates a key from a value-key pair. +* @returns A Map where the generated keys are mapped to each entry's value. +* +* @example +* const map = new Map([ +* ['x', { type: 'fruit', name: 'apple' }], +* ['y', { type: 'fruit', name: 'banana' }], +* ['z', { type: 'vegetable', name: 'carrot' }] +* ]); +* const result = keyBy(map, item => item.type); +* // result will be: +* // Map(2) { +* // 'fruit' => { type: 'fruit', name: 'banana' }, +* // 'vegetable' => { type: 'vegetable', name: 'carrot' } +* // } +*/ +function keyBy(map, getKeyFromEntry) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) { + const newKey = getKeyFromEntry(value, key, map); + result.set(newKey, value); + } + return result; +} +//#endregion +export { keyBy }; diff --git a/node_modules/es-toolkit/dist/map/mapKeys.d.mts b/node_modules/es-toolkit/dist/map/mapKeys.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f2ffeeeeff38cee3387080d6b1015892d539467e --- /dev/null +++ b/node_modules/es-toolkit/dist/map/mapKeys.d.mts @@ -0,0 +1,31 @@ +//#region src/map/mapKeys.d.ts +/** + * Creates a new Map with the same values but with keys transformed by the provided function. + * + * This function takes a Map and a function that generates a new key from each value-key pair. + * It returns a new Map where the keys are the result of applying the function to each entry, + * while the values remain the same. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to transform. + * @param getNewKey - A function that generates a new key from a value-key pair. + * @returns A new Map with transformed keys and the same values. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = mapKeys(map, (value, key) => key.toUpperCase()); + * // result will be: + * // Map(3) { + * // 'A' => 1, + * // 'B' => 2, + * // 'C' => 3 + * // } + */ +declare function mapKeys(map: Map, getNewKey: (value: V, key: K, object: Map) => K): Map; +//#endregion +export { mapKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/mapKeys.d.ts b/node_modules/es-toolkit/dist/map/mapKeys.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f2ffeeeeff38cee3387080d6b1015892d539467e --- /dev/null +++ b/node_modules/es-toolkit/dist/map/mapKeys.d.ts @@ -0,0 +1,31 @@ +//#region src/map/mapKeys.d.ts +/** + * Creates a new Map with the same values but with keys transformed by the provided function. + * + * This function takes a Map and a function that generates a new key from each value-key pair. + * It returns a new Map where the keys are the result of applying the function to each entry, + * while the values remain the same. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to transform. + * @param getNewKey - A function that generates a new key from a value-key pair. + * @returns A new Map with transformed keys and the same values. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = mapKeys(map, (value, key) => key.toUpperCase()); + * // result will be: + * // Map(3) { + * // 'A' => 1, + * // 'B' => 2, + * // 'C' => 3 + * // } + */ +declare function mapKeys(map: Map, getNewKey: (value: V, key: K, object: Map) => K): Map; +//#endregion +export { mapKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/mapKeys.js b/node_modules/es-toolkit/dist/map/mapKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..78340f491f514d0c8aeea80ac68c7ac7a5e010ad --- /dev/null +++ b/node_modules/es-toolkit/dist/map/mapKeys.js @@ -0,0 +1,38 @@ +//#region src/map/mapKeys.ts +/** +* Creates a new Map with the same values but with keys transformed by the provided function. +* +* This function takes a Map and a function that generates a new key from each value-key pair. +* It returns a new Map where the keys are the result of applying the function to each entry, +* while the values remain the same. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to transform. +* @param getNewKey - A function that generates a new key from a value-key pair. +* @returns A new Map with transformed keys and the same values. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = mapKeys(map, (value, key) => key.toUpperCase()); +* // result will be: +* // Map(3) { +* // 'A' => 1, +* // 'B' => 2, +* // 'C' => 3 +* // } +*/ +function mapKeys(map, getNewKey) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) { + const newKey = getNewKey(value, key, map); + result.set(newKey, value); + } + return result; +} +//#endregion +exports.mapKeys = mapKeys; diff --git a/node_modules/es-toolkit/dist/map/mapKeys.mjs b/node_modules/es-toolkit/dist/map/mapKeys.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7c319825fc887cddc756d287869e827e7dbd605a --- /dev/null +++ b/node_modules/es-toolkit/dist/map/mapKeys.mjs @@ -0,0 +1,38 @@ +//#region src/map/mapKeys.ts +/** +* Creates a new Map with the same values but with keys transformed by the provided function. +* +* This function takes a Map and a function that generates a new key from each value-key pair. +* It returns a new Map where the keys are the result of applying the function to each entry, +* while the values remain the same. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to transform. +* @param getNewKey - A function that generates a new key from a value-key pair. +* @returns A new Map with transformed keys and the same values. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = mapKeys(map, (value, key) => key.toUpperCase()); +* // result will be: +* // Map(3) { +* // 'A' => 1, +* // 'B' => 2, +* // 'C' => 3 +* // } +*/ +function mapKeys(map, getNewKey) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) { + const newKey = getNewKey(value, key, map); + result.set(newKey, value); + } + return result; +} +//#endregion +export { mapKeys }; diff --git a/node_modules/es-toolkit/dist/map/mapValues.d.mts b/node_modules/es-toolkit/dist/map/mapValues.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..796a4db9c29eb786a7227752ab8be1aa6193c7c1 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/mapValues.d.mts @@ -0,0 +1,31 @@ +//#region src/map/mapValues.d.ts +/** + * Creates a new Map with the same keys but with values transformed by the provided function. + * + * This function takes a Map and a function that generates a new value from each value-key pair. + * It returns a new Map where the values are the result of applying the function to each entry, + * while the keys remain the same. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to transform. + * @param getNewValue - A function that generates a new value from a value-key pair. + * @returns A new Map with the same keys and transformed values. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = mapValues(map, (value) => value * 2); + * // result will be: + * // Map(3) { + * // 'a' => 2, + * // 'b' => 4, + * // 'c' => 6 + * // } + */ +declare function mapValues(map: Map, getNewValue: (value: V, key: K, object: Map) => R): Map; +//#endregion +export { mapValues }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/mapValues.d.ts b/node_modules/es-toolkit/dist/map/mapValues.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..796a4db9c29eb786a7227752ab8be1aa6193c7c1 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/mapValues.d.ts @@ -0,0 +1,31 @@ +//#region src/map/mapValues.d.ts +/** + * Creates a new Map with the same keys but with values transformed by the provided function. + * + * This function takes a Map and a function that generates a new value from each value-key pair. + * It returns a new Map where the values are the result of applying the function to each entry, + * while the keys remain the same. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to transform. + * @param getNewValue - A function that generates a new value from a value-key pair. + * @returns A new Map with the same keys and transformed values. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = mapValues(map, (value) => value * 2); + * // result will be: + * // Map(3) { + * // 'a' => 2, + * // 'b' => 4, + * // 'c' => 6 + * // } + */ +declare function mapValues(map: Map, getNewValue: (value: V, key: K, object: Map) => R): Map; +//#endregion +export { mapValues }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/mapValues.js b/node_modules/es-toolkit/dist/map/mapValues.js new file mode 100644 index 0000000000000000000000000000000000000000..f1e9015ea47c61757b50a9a309e9e352e0870103 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/mapValues.js @@ -0,0 +1,38 @@ +//#region src/map/mapValues.ts +/** +* Creates a new Map with the same keys but with values transformed by the provided function. +* +* This function takes a Map and a function that generates a new value from each value-key pair. +* It returns a new Map where the values are the result of applying the function to each entry, +* while the keys remain the same. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to transform. +* @param getNewValue - A function that generates a new value from a value-key pair. +* @returns A new Map with the same keys and transformed values. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = mapValues(map, (value) => value * 2); +* // result will be: +* // Map(3) { +* // 'a' => 2, +* // 'b' => 4, +* // 'c' => 6 +* // } +*/ +function mapValues(map, getNewValue) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) { + const newValue = getNewValue(value, key, map); + result.set(key, newValue); + } + return result; +} +//#endregion +exports.mapValues = mapValues; diff --git a/node_modules/es-toolkit/dist/map/mapValues.mjs b/node_modules/es-toolkit/dist/map/mapValues.mjs new file mode 100644 index 0000000000000000000000000000000000000000..61c84bde89f8272f6f257bf5342f20397cd70537 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/mapValues.mjs @@ -0,0 +1,38 @@ +//#region src/map/mapValues.ts +/** +* Creates a new Map with the same keys but with values transformed by the provided function. +* +* This function takes a Map and a function that generates a new value from each value-key pair. +* It returns a new Map where the values are the result of applying the function to each entry, +* while the keys remain the same. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to transform. +* @param getNewValue - A function that generates a new value from a value-key pair. +* @returns A new Map with the same keys and transformed values. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = mapValues(map, (value) => value * 2); +* // result will be: +* // Map(3) { +* // 'a' => 2, +* // 'b' => 4, +* // 'c' => 6 +* // } +*/ +function mapValues(map, getNewValue) { + const result = /* @__PURE__ */ new Map(); + for (const [key, value] of map) { + const newValue = getNewValue(value, key, map); + result.set(key, newValue); + } + return result; +} +//#endregion +export { mapValues }; diff --git a/node_modules/es-toolkit/dist/map/reduce.d.mts b/node_modules/es-toolkit/dist/map/reduce.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0f780d1c3638b7a087969506bca4245fa0886e46 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/reduce.d.mts @@ -0,0 +1,36 @@ +//#region src/map/reduce.d.ts +/** + * Reduces a Map to a single value by iterating through its entries and applying a callback function. + * + * This function iterates through all entries of the Map and applies the callback function to each entry, + * accumulating the result. If an initial value is provided, it is used as the starting accumulator value. + * If no initial value is provided and the Map is empty, a TypeError is thrown. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to reduce. + * @param callback - A function that processes each entry and updates the accumulator. + * @param [initialValue] - The initial value for the accumulator. If not provided, the first value in the Map is used. + * @returns The final accumulated value. + * @throws {TypeError} If the Map is empty and no initial value is provided. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = reduce(map, (acc, value) => acc + value, 0); + * // result will be: 6 + * + * @example + * const map = new Map([ + * ['a', 10], + * ['b', 20] + * ]); + * const result = reduce(map, (acc, value) => acc + value); + * // result will be: 30 (starts with first value 10) + */ +declare function reduce(map: Map, callback: (accumulator: A, value: V, key: K, map: Map) => A, initialValue?: A): A; +//#endregion +export { reduce }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/reduce.d.ts b/node_modules/es-toolkit/dist/map/reduce.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0f780d1c3638b7a087969506bca4245fa0886e46 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/reduce.d.ts @@ -0,0 +1,36 @@ +//#region src/map/reduce.d.ts +/** + * Reduces a Map to a single value by iterating through its entries and applying a callback function. + * + * This function iterates through all entries of the Map and applies the callback function to each entry, + * accumulating the result. If an initial value is provided, it is used as the starting accumulator value. + * If no initial value is provided and the Map is empty, a TypeError is thrown. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to reduce. + * @param callback - A function that processes each entry and updates the accumulator. + * @param [initialValue] - The initial value for the accumulator. If not provided, the first value in the Map is used. + * @returns The final accumulated value. + * @throws {TypeError} If the Map is empty and no initial value is provided. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = reduce(map, (acc, value) => acc + value, 0); + * // result will be: 6 + * + * @example + * const map = new Map([ + * ['a', 10], + * ['b', 20] + * ]); + * const result = reduce(map, (acc, value) => acc + value); + * // result will be: 30 (starts with first value 10) + */ +declare function reduce(map: Map, callback: (accumulator: A, value: V, key: K, map: Map) => A, initialValue?: A): A; +//#endregion +export { reduce }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/reduce.js b/node_modules/es-toolkit/dist/map/reduce.js new file mode 100644 index 0000000000000000000000000000000000000000..6c41c907ca4c5890ccb4463f2128106c20a69cce --- /dev/null +++ b/node_modules/es-toolkit/dist/map/reduce.js @@ -0,0 +1,42 @@ +//#region src/map/reduce.ts +/** +* Reduces a Map to a single value by iterating through its entries and applying a callback function. +* +* This function iterates through all entries of the Map and applies the callback function to each entry, +* accumulating the result. If an initial value is provided, it is used as the starting accumulator value. +* If no initial value is provided and the Map is empty, a TypeError is thrown. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to reduce. +* @param callback - A function that processes each entry and updates the accumulator. +* @param [initialValue] - The initial value for the accumulator. If not provided, the first value in the Map is used. +* @returns The final accumulated value. +* @throws {TypeError} If the Map is empty and no initial value is provided. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = reduce(map, (acc, value) => acc + value, 0); +* // result will be: 6 +* +* @example +* const map = new Map([ +* ['a', 10], +* ['b', 20] +* ]); +* const result = reduce(map, (acc, value) => acc + value); +* // result will be: 30 (starts with first value 10) +*/ +function reduce(map, callback, initialValue) { + if (initialValue == null && map.size === 0) throw new TypeError("Reduce of empty map with no initial value"); + let accumulator = initialValue; + for (const [key, value] of map) if (accumulator == null) accumulator = value; + else accumulator = callback(accumulator, value, key, map); + return accumulator; +} +//#endregion +exports.reduce = reduce; diff --git a/node_modules/es-toolkit/dist/map/reduce.mjs b/node_modules/es-toolkit/dist/map/reduce.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b70c74e9cebe48b98827220d1321790ea74f41ff --- /dev/null +++ b/node_modules/es-toolkit/dist/map/reduce.mjs @@ -0,0 +1,42 @@ +//#region src/map/reduce.ts +/** +* Reduces a Map to a single value by iterating through its entries and applying a callback function. +* +* This function iterates through all entries of the Map and applies the callback function to each entry, +* accumulating the result. If an initial value is provided, it is used as the starting accumulator value. +* If no initial value is provided and the Map is empty, a TypeError is thrown. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to reduce. +* @param callback - A function that processes each entry and updates the accumulator. +* @param [initialValue] - The initial value for the accumulator. If not provided, the first value in the Map is used. +* @returns The final accumulated value. +* @throws {TypeError} If the Map is empty and no initial value is provided. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = reduce(map, (acc, value) => acc + value, 0); +* // result will be: 6 +* +* @example +* const map = new Map([ +* ['a', 10], +* ['b', 20] +* ]); +* const result = reduce(map, (acc, value) => acc + value); +* // result will be: 30 (starts with first value 10) +*/ +function reduce(map, callback, initialValue) { + if (initialValue == null && map.size === 0) throw new TypeError("Reduce of empty map with no initial value"); + let accumulator = initialValue; + for (const [key, value] of map) if (accumulator == null) accumulator = value; + else accumulator = callback(accumulator, value, key, map); + return accumulator; +} +//#endregion +export { reduce }; diff --git a/node_modules/es-toolkit/dist/map/some.d.mts b/node_modules/es-toolkit/dist/map/some.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bc4692284051155e14fe4e518ac8dd84d399a236 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/some.d.mts @@ -0,0 +1,29 @@ +//#region src/map/some.d.ts +/** + * Tests whether at least one entry in a Map satisfies the provided predicate function. + * + * This function iterates through the entries of the Map and checks if the predicate function + * returns true for at least one entry. It returns true if any entry satisfies the predicate, + * and false otherwise. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to test. + * @param doesMatch - A predicate function that tests each entry. + * @returns true if at least one entry satisfies the predicate, false otherwise. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = some(map, (value) => value > 2); + * // result will be: true + * + * const result2 = some(map, (value) => value > 5); + * // result2 will be: false + */ +declare function some(map: Map, doesMatch: (value: V, key: K, map: Map) => boolean): boolean; +//#endregion +export { some }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/some.d.ts b/node_modules/es-toolkit/dist/map/some.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bc4692284051155e14fe4e518ac8dd84d399a236 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/some.d.ts @@ -0,0 +1,29 @@ +//#region src/map/some.d.ts +/** + * Tests whether at least one entry in a Map satisfies the provided predicate function. + * + * This function iterates through the entries of the Map and checks if the predicate function + * returns true for at least one entry. It returns true if any entry satisfies the predicate, + * and false otherwise. + * + * @template K - The type of keys in the Map. + * @template V - The type of values in the Map. + * @param map - The Map to test. + * @param doesMatch - A predicate function that tests each entry. + * @returns true if at least one entry satisfies the predicate, false otherwise. + * + * @example + * const map = new Map([ + * ['a', 1], + * ['b', 2], + * ['c', 3] + * ]); + * const result = some(map, (value) => value > 2); + * // result will be: true + * + * const result2 = some(map, (value) => value > 5); + * // result2 will be: false + */ +declare function some(map: Map, doesMatch: (value: V, key: K, map: Map) => boolean): boolean; +//#endregion +export { some }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/map/some.js b/node_modules/es-toolkit/dist/map/some.js new file mode 100644 index 0000000000000000000000000000000000000000..1c9d6a8f9b5d23c9229412c5f81e73d62f6c4188 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/some.js @@ -0,0 +1,32 @@ +//#region src/map/some.ts +/** +* Tests whether at least one entry in a Map satisfies the provided predicate function. +* +* This function iterates through the entries of the Map and checks if the predicate function +* returns true for at least one entry. It returns true if any entry satisfies the predicate, +* and false otherwise. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to test. +* @param doesMatch - A predicate function that tests each entry. +* @returns true if at least one entry satisfies the predicate, false otherwise. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = some(map, (value) => value > 2); +* // result will be: true +* +* const result2 = some(map, (value) => value > 5); +* // result2 will be: false +*/ +function some(map, doesMatch) { + for (const [key, value] of map) if (doesMatch(value, key, map)) return true; + return false; +} +//#endregion +exports.some = some; diff --git a/node_modules/es-toolkit/dist/map/some.mjs b/node_modules/es-toolkit/dist/map/some.mjs new file mode 100644 index 0000000000000000000000000000000000000000..53bf393b2a8d065300573aa8c03c8d72040f8c79 --- /dev/null +++ b/node_modules/es-toolkit/dist/map/some.mjs @@ -0,0 +1,32 @@ +//#region src/map/some.ts +/** +* Tests whether at least one entry in a Map satisfies the provided predicate function. +* +* This function iterates through the entries of the Map and checks if the predicate function +* returns true for at least one entry. It returns true if any entry satisfies the predicate, +* and false otherwise. +* +* @template K - The type of keys in the Map. +* @template V - The type of values in the Map. +* @param map - The Map to test. +* @param doesMatch - A predicate function that tests each entry. +* @returns true if at least one entry satisfies the predicate, false otherwise. +* +* @example +* const map = new Map([ +* ['a', 1], +* ['b', 2], +* ['c', 3] +* ]); +* const result = some(map, (value) => value > 2); +* // result will be: true +* +* const result2 = some(map, (value) => value > 5); +* // result2 will be: false +*/ +function some(map, doesMatch) { + for (const [key, value] of map) if (doesMatch(value, key, map)) return true; + return false; +} +//#endregion +export { some }; diff --git a/node_modules/es-toolkit/dist/math/clamp.d.mts b/node_modules/es-toolkit/dist/math/clamp.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f70e9f9b2915f7027e7ac11e77b75890e4129035 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/clamp.d.mts @@ -0,0 +1,33 @@ +//#region src/math/clamp.d.ts +/** + * Clamps a number within the inclusive upper bound. + * + * This function takes a number and a maximum bound, and returns the number clamped within the specified upper bound. + * If only one bound is provided, it returns the minimum of the value and the bound. + * + * @param value - The number to clamp. + * @param maximum - The maximum bound to clamp the number. + * @returns The clamped number within the specified upper bound. + * + * @example + * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5 + */ +declare function clamp(value: number, maximum: number): number; +/** + * Clamps a number within the inclusive lower and upper bounds. + * + * This function takes a number and two bounds, and returns the number clamped within the specified bounds. + * + * @param value - The number to clamp. + * @param minimum - The minimum bound to clamp the number. + * @param maximum - The maximum bound to clamp the number. + * @returns The clamped number within the specified bounds. + * + * @example + * 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 + */ +declare function clamp(value: number, minimum: number, maximum: number): number; +//#endregion +export { clamp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/clamp.d.ts b/node_modules/es-toolkit/dist/math/clamp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f70e9f9b2915f7027e7ac11e77b75890e4129035 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/clamp.d.ts @@ -0,0 +1,33 @@ +//#region src/math/clamp.d.ts +/** + * Clamps a number within the inclusive upper bound. + * + * This function takes a number and a maximum bound, and returns the number clamped within the specified upper bound. + * If only one bound is provided, it returns the minimum of the value and the bound. + * + * @param value - The number to clamp. + * @param maximum - The maximum bound to clamp the number. + * @returns The clamped number within the specified upper bound. + * + * @example + * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5 + */ +declare function clamp(value: number, maximum: number): number; +/** + * Clamps a number within the inclusive lower and upper bounds. + * + * This function takes a number and two bounds, and returns the number clamped within the specified bounds. + * + * @param value - The number to clamp. + * @param minimum - The minimum bound to clamp the number. + * @param maximum - The maximum bound to clamp the number. + * @returns The clamped number within the specified bounds. + * + * @example + * 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 + */ +declare function clamp(value: number, minimum: number, maximum: number): number; +//#endregion +export { clamp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/clamp.js b/node_modules/es-toolkit/dist/math/clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..a6184fece4685188082485192c96751d7ecb6de4 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/clamp.js @@ -0,0 +1,24 @@ +//#region src/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 == null) return Math.min(value, bound1); + return Math.min(Math.max(value, bound1), bound2); +} +//#endregion +exports.clamp = clamp; diff --git a/node_modules/es-toolkit/dist/math/clamp.mjs b/node_modules/es-toolkit/dist/math/clamp.mjs new file mode 100644 index 0000000000000000000000000000000000000000..12216efa9d5684c2ee45d46a1aa58a03fde84468 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/clamp.mjs @@ -0,0 +1,24 @@ +//#region src/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 == null) return Math.min(value, bound1); + return Math.min(Math.max(value, bound1), bound2); +} +//#endregion +export { clamp }; diff --git a/node_modules/es-toolkit/dist/math/inRange.d.mts b/node_modules/es-toolkit/dist/math/inRange.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ae799a2707fe364c733a063958d9e5c8779abf96 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/inRange.d.mts @@ -0,0 +1,28 @@ +//#region src/math/inRange.d.ts +/** + * Checks if the value is less than the maximum. + * + * @param value The value to check. + * @param maximum The upper bound of the range (exclusive). + * @returns `true` if the value is less than the maximum, otherwise `false`. + * + * @example + * const result = inRange(3, 5); // result will be true. + * const result2 = inRange(5, 5); // result2 will be false. + */ +declare function inRange(value: number, maximum: number): boolean; +/** + * Checks if the value is within the range defined by minimum (inclusive) and maximum (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 result = inRange(3, 2, 5); // result will be true. + * const result2 = inRange(1, 2, 5); // result2 will be false. + */ +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/math/inRange.d.ts b/node_modules/es-toolkit/dist/math/inRange.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae799a2707fe364c733a063958d9e5c8779abf96 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/inRange.d.ts @@ -0,0 +1,28 @@ +//#region src/math/inRange.d.ts +/** + * Checks if the value is less than the maximum. + * + * @param value The value to check. + * @param maximum The upper bound of the range (exclusive). + * @returns `true` if the value is less than the maximum, otherwise `false`. + * + * @example + * const result = inRange(3, 5); // result will be true. + * const result2 = inRange(5, 5); // result2 will be false. + */ +declare function inRange(value: number, maximum: number): boolean; +/** + * Checks if the value is within the range defined by minimum (inclusive) and maximum (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 result = inRange(3, 2, 5); // result will be true. + * const result2 = inRange(1, 2, 5); // result2 will be false. + */ +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/math/inRange.js b/node_modules/es-toolkit/dist/math/inRange.js new file mode 100644 index 0000000000000000000000000000000000000000..d7f0b8aa29e8a5c13d341b8d8029e6cf8c9d6f3b --- /dev/null +++ b/node_modules/es-toolkit/dist/math/inRange.js @@ -0,0 +1,25 @@ +//#region src/math/inRange.ts +/** +* Checks if the value is within a specified range. +* +* @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`. +* @throws {Error} Throws an error if the `minimum` is greater or equal than the `maximum`. +* +* @example +* const result1 = inRange(3, 5); // result1 will be true. +* const result2 = inRange(1, 2, 5); // result2 will be false. +* const result3 = inRange(1, 5, 2); // If the minimum is greater or equal than the maximum, an error is thrown. +*/ +function inRange(value, minimum, maximum) { + if (maximum == null) { + maximum = minimum; + minimum = 0; + } + if (minimum >= maximum) throw new Error("The maximum value must be greater than the minimum value."); + return minimum <= value && value < maximum; +} +//#endregion +exports.inRange = inRange; diff --git a/node_modules/es-toolkit/dist/math/inRange.mjs b/node_modules/es-toolkit/dist/math/inRange.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a54da1df0e0db19a48f90b6548f10a6f5adea13c --- /dev/null +++ b/node_modules/es-toolkit/dist/math/inRange.mjs @@ -0,0 +1,25 @@ +//#region src/math/inRange.ts +/** +* Checks if the value is within a specified range. +* +* @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`. +* @throws {Error} Throws an error if the `minimum` is greater or equal than the `maximum`. +* +* @example +* const result1 = inRange(3, 5); // result1 will be true. +* const result2 = inRange(1, 2, 5); // result2 will be false. +* const result3 = inRange(1, 5, 2); // If the minimum is greater or equal than the maximum, an error is thrown. +*/ +function inRange(value, minimum, maximum) { + if (maximum == null) { + maximum = minimum; + minimum = 0; + } + if (minimum >= maximum) throw new Error("The maximum value must be greater than the minimum value."); + return minimum <= value && value < maximum; +} +//#endregion +export { inRange }; diff --git a/node_modules/es-toolkit/dist/math/index.d.mts b/node_modules/es-toolkit/dist/math/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ee33b40fae949e498a62b1b41b63aa0ac0d9b652 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/index.d.mts @@ -0,0 +1,15 @@ +import { clamp } from "./clamp.mjs"; +import { inRange } from "./inRange.mjs"; +import { mean } from "./mean.mjs"; +import { meanBy } from "./meanBy.mjs"; +import { median } from "./median.mjs"; +import { medianBy } from "./medianBy.mjs"; +import { percentile } from "./percentile.mjs"; +import { random } from "./random.mjs"; +import { randomInt } from "./randomInt.mjs"; +import { range } from "./range.mjs"; +import { rangeRight } from "./rangeRight.mjs"; +import { round } from "./round.mjs"; +import { sum } from "./sum.mjs"; +import { sumBy } from "./sumBy.mjs"; +export { clamp, inRange, mean, meanBy, median, medianBy, percentile, random, randomInt, range, rangeRight, round, sum, sumBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/index.d.ts b/node_modules/es-toolkit/dist/math/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6fac392cb40c46ac455d3f8bb6e0e886a9927a16 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/index.d.ts @@ -0,0 +1,15 @@ +import { clamp } from "./clamp.js"; +import { inRange } from "./inRange.js"; +import { mean } from "./mean.js"; +import { meanBy } from "./meanBy.js"; +import { median } from "./median.js"; +import { medianBy } from "./medianBy.js"; +import { percentile } from "./percentile.js"; +import { random } from "./random.js"; +import { randomInt } from "./randomInt.js"; +import { range } from "./range.js"; +import { rangeRight } from "./rangeRight.js"; +import { round } from "./round.js"; +import { sum } from "./sum.js"; +import { sumBy } from "./sumBy.js"; +export { clamp, inRange, mean, meanBy, median, medianBy, percentile, random, randomInt, range, rangeRight, round, sum, sumBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/index.js b/node_modules/es-toolkit/dist/math/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8b5df29f34d7ae780b2902d654b9ee3f0d226c74 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/index.js @@ -0,0 +1,29 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_random = require("./random.js"); +const require_randomInt = require("./randomInt.js"); +const require_clamp = require("./clamp.js"); +const require_inRange = require("./inRange.js"); +const require_sum = require("./sum.js"); +const require_mean = require("./mean.js"); +const require_sumBy = require("./sumBy.js"); +const require_meanBy = require("./meanBy.js"); +const require_median = require("./median.js"); +const require_medianBy = require("./medianBy.js"); +const require_percentile = require("./percentile.js"); +const require_range = require("./range.js"); +const require_rangeRight = require("./rangeRight.js"); +const require_round = require("./round.js"); +exports.clamp = require_clamp.clamp; +exports.inRange = require_inRange.inRange; +exports.mean = require_mean.mean; +exports.meanBy = require_meanBy.meanBy; +exports.median = require_median.median; +exports.medianBy = require_medianBy.medianBy; +exports.percentile = require_percentile.percentile; +exports.random = require_random.random; +exports.randomInt = require_randomInt.randomInt; +exports.range = require_range.range; +exports.rangeRight = require_rangeRight.rangeRight; +exports.round = require_round.round; +exports.sum = require_sum.sum; +exports.sumBy = require_sumBy.sumBy; diff --git a/node_modules/es-toolkit/dist/math/index.mjs b/node_modules/es-toolkit/dist/math/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e3b92f2f933a1ab6bcb9fc5187ce13d9f5e2b32d --- /dev/null +++ b/node_modules/es-toolkit/dist/math/index.mjs @@ -0,0 +1,15 @@ +import { random } from "./random.mjs"; +import { randomInt } from "./randomInt.mjs"; +import { clamp } from "./clamp.mjs"; +import { inRange } from "./inRange.mjs"; +import { sum } from "./sum.mjs"; +import { mean } from "./mean.mjs"; +import { sumBy } from "./sumBy.mjs"; +import { meanBy } from "./meanBy.mjs"; +import { median } from "./median.mjs"; +import { medianBy } from "./medianBy.mjs"; +import { percentile } from "./percentile.mjs"; +import { range } from "./range.mjs"; +import { rangeRight } from "./rangeRight.mjs"; +import { round } from "./round.mjs"; +export { clamp, inRange, mean, meanBy, median, medianBy, percentile, random, randomInt, range, rangeRight, round, sum, sumBy }; diff --git a/node_modules/es-toolkit/dist/math/mean.d.mts b/node_modules/es-toolkit/dist/math/mean.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..851911ced16bf38bc970e7433c355b7ac936246f --- /dev/null +++ b/node_modules/es-toolkit/dist/math/mean.d.mts @@ -0,0 +1,17 @@ +//#region src/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: readonly number[]): number; +//#endregion +export { mean }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/mean.d.ts b/node_modules/es-toolkit/dist/math/mean.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..851911ced16bf38bc970e7433c355b7ac936246f --- /dev/null +++ b/node_modules/es-toolkit/dist/math/mean.d.ts @@ -0,0 +1,17 @@ +//#region src/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: readonly number[]): number; +//#endregion +export { mean }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/mean.js b/node_modules/es-toolkit/dist/math/mean.js new file mode 100644 index 0000000000000000000000000000000000000000..4ad2244854d48e6900d0e2fd2a8d92bef554310d --- /dev/null +++ b/node_modules/es-toolkit/dist/math/mean.js @@ -0,0 +1,20 @@ +const require_sum = require("./sum.js"); +//#region src/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) { + return require_sum.sum(nums) / nums.length; +} +//#endregion +exports.mean = mean; diff --git a/node_modules/es-toolkit/dist/math/mean.mjs b/node_modules/es-toolkit/dist/math/mean.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e010e7aa0ee4b0b1ccee01e62cb56babd75fe3cc --- /dev/null +++ b/node_modules/es-toolkit/dist/math/mean.mjs @@ -0,0 +1,20 @@ +import { sum } from "./sum.mjs"; +//#region src/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) { + return sum(nums) / nums.length; +} +//#endregion +export { mean }; diff --git a/node_modules/es-toolkit/dist/math/meanBy.d.mts b/node_modules/es-toolkit/dist/math/meanBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2da6fcd56450e2b29996dbd0d0add729d7efe423 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/meanBy.d.mts @@ -0,0 +1,19 @@ +//#region src/math/meanBy.d.ts +/** + * Calculates the average of an array of numbers when applying + * the `getValue` 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 getValue A function that selects a numeric value from each element. + * @returns The average of all the numbers as determined by the `getValue` function. + * + * @example + * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2 + * meanBy([], x => x.a); // Returns: NaN + */ +declare function meanBy(items: readonly T[], getValue: (element: T) => number): number; +//#endregion +export { meanBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/meanBy.d.ts b/node_modules/es-toolkit/dist/math/meanBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2da6fcd56450e2b29996dbd0d0add729d7efe423 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/meanBy.d.ts @@ -0,0 +1,19 @@ +//#region src/math/meanBy.d.ts +/** + * Calculates the average of an array of numbers when applying + * the `getValue` 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 getValue A function that selects a numeric value from each element. + * @returns The average of all the numbers as determined by the `getValue` function. + * + * @example + * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2 + * meanBy([], x => x.a); // Returns: NaN + */ +declare function meanBy(items: readonly T[], getValue: (element: T) => number): number; +//#endregion +export { meanBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/meanBy.js b/node_modules/es-toolkit/dist/math/meanBy.js new file mode 100644 index 0000000000000000000000000000000000000000..2538f01ea6a66b0fc3d61dc4254d2a595406a3e4 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/meanBy.js @@ -0,0 +1,22 @@ +const require_sumBy = require("./sumBy.js"); +//#region src/math/meanBy.ts +/** +* Calculates the average of an array of numbers when applying +* the `getValue` 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 getValue A function that selects a numeric value from each element. +* @returns The average of all the numbers as determined by the `getValue` function. +* +* @example +* meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2 +* meanBy([], x => x.a); // Returns: NaN +*/ +function meanBy(items, getValue) { + return require_sumBy.sumBy(items, (item) => getValue(item)) / items.length; +} +//#endregion +exports.meanBy = meanBy; diff --git a/node_modules/es-toolkit/dist/math/meanBy.mjs b/node_modules/es-toolkit/dist/math/meanBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4e18ba7708779549ad342ebea7295ed81a985edf --- /dev/null +++ b/node_modules/es-toolkit/dist/math/meanBy.mjs @@ -0,0 +1,22 @@ +import { sumBy } from "./sumBy.mjs"; +//#region src/math/meanBy.ts +/** +* Calculates the average of an array of numbers when applying +* the `getValue` 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 getValue A function that selects a numeric value from each element. +* @returns The average of all the numbers as determined by the `getValue` function. +* +* @example +* meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2 +* meanBy([], x => x.a); // Returns: NaN +*/ +function meanBy(items, getValue) { + return sumBy(items, (item) => getValue(item)) / items.length; +} +//#endregion +export { meanBy }; diff --git a/node_modules/es-toolkit/dist/math/median.d.mts b/node_modules/es-toolkit/dist/math/median.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..54755da7a6ee217b21f94d13ef0a5fd535ddeded --- /dev/null +++ b/node_modules/es-toolkit/dist/math/median.d.mts @@ -0,0 +1,26 @@ +//#region src/math/median.d.ts +/** + * Calculates the median of an array of numbers. + * + * The median is the middle value of a sorted array. + * If the array has an odd number of elements, the median is the middle value. + * If the array has an even number of elements, it returns the average of the two middle values. + * + * If the array is empty, this function returns `NaN`. + * + * @param nums - An array of numbers to calculate the median. + * @returns The median of all the numbers in the array. + * + * @example + * const arrayWithOddNumberOfElements = [1, 2, 3, 4, 5]; + * const result = median(arrayWithOddNumberOfElements); + * // result will be 3 + * + * @example + * const arrayWithEvenNumberOfElements = [1, 2, 3, 4]; + * const result = median(arrayWithEvenNumberOfElements); + * // result will be 2.5 + */ +declare function median(nums: readonly number[]): number; +//#endregion +export { median }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/median.d.ts b/node_modules/es-toolkit/dist/math/median.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..54755da7a6ee217b21f94d13ef0a5fd535ddeded --- /dev/null +++ b/node_modules/es-toolkit/dist/math/median.d.ts @@ -0,0 +1,26 @@ +//#region src/math/median.d.ts +/** + * Calculates the median of an array of numbers. + * + * The median is the middle value of a sorted array. + * If the array has an odd number of elements, the median is the middle value. + * If the array has an even number of elements, it returns the average of the two middle values. + * + * If the array is empty, this function returns `NaN`. + * + * @param nums - An array of numbers to calculate the median. + * @returns The median of all the numbers in the array. + * + * @example + * const arrayWithOddNumberOfElements = [1, 2, 3, 4, 5]; + * const result = median(arrayWithOddNumberOfElements); + * // result will be 3 + * + * @example + * const arrayWithEvenNumberOfElements = [1, 2, 3, 4]; + * const result = median(arrayWithEvenNumberOfElements); + * // result will be 2.5 + */ +declare function median(nums: readonly number[]): number; +//#endregion +export { median }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/median.js b/node_modules/es-toolkit/dist/math/median.js new file mode 100644 index 0000000000000000000000000000000000000000..84cec33a6c07bbc81bda0e3c3dd5a58b6e83cb7e --- /dev/null +++ b/node_modules/es-toolkit/dist/math/median.js @@ -0,0 +1,32 @@ +//#region src/math/median.ts +/** +* Calculates the median of an array of numbers. +* +* The median is the middle value of a sorted array. +* If the array has an odd number of elements, the median is the middle value. +* If the array has an even number of elements, it returns the average of the two middle values. +* +* If the array is empty, this function returns `NaN`. +* +* @param nums - An array of numbers to calculate the median. +* @returns The median of all the numbers in the array. +* +* @example +* const arrayWithOddNumberOfElements = [1, 2, 3, 4, 5]; +* const result = median(arrayWithOddNumberOfElements); +* // result will be 3 +* +* @example +* const arrayWithEvenNumberOfElements = [1, 2, 3, 4]; +* const result = median(arrayWithEvenNumberOfElements); +* // result will be 2.5 +*/ +function median(nums) { + if (nums.length === 0) return NaN; + const sorted = nums.slice().sort((a, b) => a - b); + const middleIndex = Math.floor(sorted.length / 2); + if (sorted.length % 2 === 0) return (sorted[middleIndex - 1] + sorted[middleIndex]) / 2; + else return sorted[middleIndex]; +} +//#endregion +exports.median = median; diff --git a/node_modules/es-toolkit/dist/math/median.mjs b/node_modules/es-toolkit/dist/math/median.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3c9dd64a99c79904f61d001171f3341d7abc3afc --- /dev/null +++ b/node_modules/es-toolkit/dist/math/median.mjs @@ -0,0 +1,32 @@ +//#region src/math/median.ts +/** +* Calculates the median of an array of numbers. +* +* The median is the middle value of a sorted array. +* If the array has an odd number of elements, the median is the middle value. +* If the array has an even number of elements, it returns the average of the two middle values. +* +* If the array is empty, this function returns `NaN`. +* +* @param nums - An array of numbers to calculate the median. +* @returns The median of all the numbers in the array. +* +* @example +* const arrayWithOddNumberOfElements = [1, 2, 3, 4, 5]; +* const result = median(arrayWithOddNumberOfElements); +* // result will be 3 +* +* @example +* const arrayWithEvenNumberOfElements = [1, 2, 3, 4]; +* const result = median(arrayWithEvenNumberOfElements); +* // result will be 2.5 +*/ +function median(nums) { + if (nums.length === 0) return NaN; + const sorted = nums.slice().sort((a, b) => a - b); + const middleIndex = Math.floor(sorted.length / 2); + if (sorted.length % 2 === 0) return (sorted[middleIndex - 1] + sorted[middleIndex]) / 2; + else return sorted[middleIndex]; +} +//#endregion +export { median }; diff --git a/node_modules/es-toolkit/dist/math/medianBy.d.mts b/node_modules/es-toolkit/dist/math/medianBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0ad031c665c80faa3a1db9750ad538b128baf0fa --- /dev/null +++ b/node_modules/es-toolkit/dist/math/medianBy.d.mts @@ -0,0 +1,24 @@ +//#region src/math/medianBy.d.ts +/** + * Calculates the median of an array of elements when applying + * the `getValue` function to each element. + * + * The median is the middle value of a sorted array. + * If the array has an odd number of elements, the median is the middle value. + * If the array has an even number of elements, it returns the average of the two middle values. + * + * 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 median. + * @param getValue A function that selects a numeric value from each element. + * @returns The median of all the numbers as determined by the `getValue` function. + * + * @example + * medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }], x => x.a); // Returns: 3 + * medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }], x => x.a); // Returns: 2.5 + * medianBy([], x => x.a); // Returns: NaN + */ +declare function medianBy(items: readonly T[], getValue: (element: T) => number): number; +//#endregion +export { medianBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/medianBy.d.ts b/node_modules/es-toolkit/dist/math/medianBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0ad031c665c80faa3a1db9750ad538b128baf0fa --- /dev/null +++ b/node_modules/es-toolkit/dist/math/medianBy.d.ts @@ -0,0 +1,24 @@ +//#region src/math/medianBy.d.ts +/** + * Calculates the median of an array of elements when applying + * the `getValue` function to each element. + * + * The median is the middle value of a sorted array. + * If the array has an odd number of elements, the median is the middle value. + * If the array has an even number of elements, it returns the average of the two middle values. + * + * 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 median. + * @param getValue A function that selects a numeric value from each element. + * @returns The median of all the numbers as determined by the `getValue` function. + * + * @example + * medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }], x => x.a); // Returns: 3 + * medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }], x => x.a); // Returns: 2.5 + * medianBy([], x => x.a); // Returns: NaN + */ +declare function medianBy(items: readonly T[], getValue: (element: T) => number): number; +//#endregion +export { medianBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/medianBy.js b/node_modules/es-toolkit/dist/math/medianBy.js new file mode 100644 index 0000000000000000000000000000000000000000..79699eb57ee85a8691d76dc0f4f0bed00586a6aa --- /dev/null +++ b/node_modules/es-toolkit/dist/math/medianBy.js @@ -0,0 +1,28 @@ +const require_median = require("./median.js"); +//#region src/math/medianBy.ts +/** +* Calculates the median of an array of elements when applying +* the `getValue` function to each element. +* +* The median is the middle value of a sorted array. +* If the array has an odd number of elements, the median is the middle value. +* If the array has an even number of elements, it returns the average of the two middle values. +* +* 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 median. +* @param getValue A function that selects a numeric value from each element. +* @returns The median of all the numbers as determined by the `getValue` function. +* +* @example +* medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }], x => x.a); // Returns: 3 +* medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }], x => x.a); // Returns: 2.5 +* medianBy([], x => x.a); // Returns: NaN +*/ +function medianBy(items, getValue) { + const nums = items.map((x) => getValue(x)); + return require_median.median(nums); +} +//#endregion +exports.medianBy = medianBy; diff --git a/node_modules/es-toolkit/dist/math/medianBy.mjs b/node_modules/es-toolkit/dist/math/medianBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bff544e6a429a350536bf6be90c4217ffeeb97c8 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/medianBy.mjs @@ -0,0 +1,27 @@ +import { median } from "./median.mjs"; +//#region src/math/medianBy.ts +/** +* Calculates the median of an array of elements when applying +* the `getValue` function to each element. +* +* The median is the middle value of a sorted array. +* If the array has an odd number of elements, the median is the middle value. +* If the array has an even number of elements, it returns the average of the two middle values. +* +* 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 median. +* @param getValue A function that selects a numeric value from each element. +* @returns The median of all the numbers as determined by the `getValue` function. +* +* @example +* medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }], x => x.a); // Returns: 3 +* medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }], x => x.a); // Returns: 2.5 +* medianBy([], x => x.a); // Returns: NaN +*/ +function medianBy(items, getValue) { + return median(items.map((x) => getValue(x))); +} +//#endregion +export { medianBy }; diff --git a/node_modules/es-toolkit/dist/math/percentile.d.mts b/node_modules/es-toolkit/dist/math/percentile.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..885c3e3a2b63ceacd9f0996c65bd28bf21cb10c7 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/percentile.d.mts @@ -0,0 +1,29 @@ +//#region src/math/percentile.d.ts +/** + * Calculates the value at the given percentile of an array of numbers. + * + * Sorts the array in ascending order and returns the element at the nearest rank. + * See {@link https://en.wikipedia.org/wiki/Percentile#The_nearest-rank_method | Nearest rank method}. + * + * `NaN` values are sorted as the smallest values. Returns `NaN` if the array is empty. + * + * @param arr - An array of numbers to calculate the percentile. + * @param percentile - The percentile to compute, in the range `[0, 100]`. + * @returns The value at the given percentile. + * @throws {Error} Throws an error if `percentile` is not a number, less than `0`, or greater than `100`. + * + * @example + * percentile([1, 2, 3, 4, 5], 50); + * // Returns 3 + * + * @example + * percentile([1, 2, 3, 4, 5], 75); + * // Returns 4 + * + * @example + * percentile([5, 1, 4, 2, 3], 0); + * // Returns 1 + */ +declare function percentile(arr: readonly number[], percentile: number): number; +//#endregion +export { percentile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/percentile.d.ts b/node_modules/es-toolkit/dist/math/percentile.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..885c3e3a2b63ceacd9f0996c65bd28bf21cb10c7 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/percentile.d.ts @@ -0,0 +1,29 @@ +//#region src/math/percentile.d.ts +/** + * Calculates the value at the given percentile of an array of numbers. + * + * Sorts the array in ascending order and returns the element at the nearest rank. + * See {@link https://en.wikipedia.org/wiki/Percentile#The_nearest-rank_method | Nearest rank method}. + * + * `NaN` values are sorted as the smallest values. Returns `NaN` if the array is empty. + * + * @param arr - An array of numbers to calculate the percentile. + * @param percentile - The percentile to compute, in the range `[0, 100]`. + * @returns The value at the given percentile. + * @throws {Error} Throws an error if `percentile` is not a number, less than `0`, or greater than `100`. + * + * @example + * percentile([1, 2, 3, 4, 5], 50); + * // Returns 3 + * + * @example + * percentile([1, 2, 3, 4, 5], 75); + * // Returns 4 + * + * @example + * percentile([5, 1, 4, 2, 3], 0); + * // Returns 1 + */ +declare function percentile(arr: readonly number[], percentile: number): number; +//#endregion +export { percentile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/percentile.js b/node_modules/es-toolkit/dist/math/percentile.js new file mode 100644 index 0000000000000000000000000000000000000000..ebe28d9baa82b8a302199408d0ae48c920adaec9 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/percentile.js @@ -0,0 +1,39 @@ +//#region src/math/percentile.ts +/** +* Calculates the value at the given percentile of an array of numbers. +* +* Sorts the array in ascending order and returns the element at the nearest rank. +* See {@link https://en.wikipedia.org/wiki/Percentile#The_nearest-rank_method | Nearest rank method}. +* +* `NaN` values are sorted as the smallest values. Returns `NaN` if the array is empty. +* +* @param arr - An array of numbers to calculate the percentile. +* @param percentile - The percentile to compute, in the range `[0, 100]`. +* @returns The value at the given percentile. +* @throws {Error} Throws an error if `percentile` is not a number, less than `0`, or greater than `100`. +* +* @example +* percentile([1, 2, 3, 4, 5], 50); +* // Returns 3 +* +* @example +* percentile([1, 2, 3, 4, 5], 75); +* // Returns 4 +* +* @example +* percentile([5, 1, 4, 2, 3], 0); +* // Returns 1 +*/ +function percentile(arr, percentile) { + if (Number.isNaN(Number(percentile))) throw new Error(`Expected percentile to be a number but got "${percentile}".`); + if (percentile < 0) throw new Error(`Expected percentile to be >= 0 but got "${percentile}".`); + if (percentile > 100) throw new Error(`Expected percentile to be <= 100 but got "${percentile}".`); + if (arr.length === 0) return NaN; + const sorted = arr.slice().sort((a, b) => { + return (Number.isNaN(a) ? Number.NEGATIVE_INFINITY : a) - (Number.isNaN(b) ? Number.NEGATIVE_INFINITY : b); + }); + if (percentile === 0) return sorted[0]; + return sorted[Math.ceil(sorted.length * (percentile / 100)) - 1]; +} +//#endregion +exports.percentile = percentile; diff --git a/node_modules/es-toolkit/dist/math/percentile.mjs b/node_modules/es-toolkit/dist/math/percentile.mjs new file mode 100644 index 0000000000000000000000000000000000000000..84c62e148d22b24ac3ba673d87b4fa47f9621e0d --- /dev/null +++ b/node_modules/es-toolkit/dist/math/percentile.mjs @@ -0,0 +1,39 @@ +//#region src/math/percentile.ts +/** +* Calculates the value at the given percentile of an array of numbers. +* +* Sorts the array in ascending order and returns the element at the nearest rank. +* See {@link https://en.wikipedia.org/wiki/Percentile#The_nearest-rank_method | Nearest rank method}. +* +* `NaN` values are sorted as the smallest values. Returns `NaN` if the array is empty. +* +* @param arr - An array of numbers to calculate the percentile. +* @param percentile - The percentile to compute, in the range `[0, 100]`. +* @returns The value at the given percentile. +* @throws {Error} Throws an error if `percentile` is not a number, less than `0`, or greater than `100`. +* +* @example +* percentile([1, 2, 3, 4, 5], 50); +* // Returns 3 +* +* @example +* percentile([1, 2, 3, 4, 5], 75); +* // Returns 4 +* +* @example +* percentile([5, 1, 4, 2, 3], 0); +* // Returns 1 +*/ +function percentile(arr, percentile) { + if (Number.isNaN(Number(percentile))) throw new Error(`Expected percentile to be a number but got "${percentile}".`); + if (percentile < 0) throw new Error(`Expected percentile to be >= 0 but got "${percentile}".`); + if (percentile > 100) throw new Error(`Expected percentile to be <= 100 but got "${percentile}".`); + if (arr.length === 0) return NaN; + const sorted = arr.slice().sort((a, b) => { + return (Number.isNaN(a) ? Number.NEGATIVE_INFINITY : a) - (Number.isNaN(b) ? Number.NEGATIVE_INFINITY : b); + }); + if (percentile === 0) return sorted[0]; + return sorted[Math.ceil(sorted.length * (percentile / 100)) - 1]; +} +//#endregion +export { percentile }; diff --git a/node_modules/es-toolkit/dist/math/random.d.mts b/node_modules/es-toolkit/dist/math/random.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ded4a3f83517225e1350a182a39c047ac0c63c59 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/random.d.mts @@ -0,0 +1,31 @@ +//#region src/math/random.d.ts +/** + * Generate a random number within the given range. + * + * If only one argument is provided, a number between `0` and the given number is returned. + * + * @param maximum - The upper bound (exclusive). + * @returns A random number between 0 (inclusive) and maximum (exclusive). The number can be an integer or a decimal. + * @throws {Error} Throws an error if `maximum` is not greater than `0`. + * + * @example + * const result1 = random(5); // Returns a random number between 0 and 5. + * const result2 = random(0); // If the `maximum` is less than or equal to 0, an error is thrown. + */ +declare function random(maximum: number): number; +/** + * 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. + */ +declare function random(minimum: number, maximum: number): number; +//#endregion +export { random }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/random.d.ts b/node_modules/es-toolkit/dist/math/random.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ded4a3f83517225e1350a182a39c047ac0c63c59 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/random.d.ts @@ -0,0 +1,31 @@ +//#region src/math/random.d.ts +/** + * Generate a random number within the given range. + * + * If only one argument is provided, a number between `0` and the given number is returned. + * + * @param maximum - The upper bound (exclusive). + * @returns A random number between 0 (inclusive) and maximum (exclusive). The number can be an integer or a decimal. + * @throws {Error} Throws an error if `maximum` is not greater than `0`. + * + * @example + * const result1 = random(5); // Returns a random number between 0 and 5. + * const result2 = random(0); // If the `maximum` is less than or equal to 0, an error is thrown. + */ +declare function random(maximum: number): number; +/** + * 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. + */ +declare function random(minimum: number, maximum: number): number; +//#endregion +export { random }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/random.js b/node_modules/es-toolkit/dist/math/random.js new file mode 100644 index 0000000000000000000000000000000000000000..fca9810ef527ea66c63016dd0c28160a43e068b0 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/random.js @@ -0,0 +1,24 @@ +//#region src/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(minimum, maximum) { + if (maximum == null) { + maximum = minimum; + minimum = 0; + } + if (minimum >= maximum) throw new Error("Invalid input: The maximum value must be greater than the minimum value."); + return Math.random() * (maximum - minimum) + minimum; +} +//#endregion +exports.random = random; diff --git a/node_modules/es-toolkit/dist/math/random.mjs b/node_modules/es-toolkit/dist/math/random.mjs new file mode 100644 index 0000000000000000000000000000000000000000..62450622ac8030a7712d4ea2dc9d021306d53d14 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/random.mjs @@ -0,0 +1,24 @@ +//#region src/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(minimum, maximum) { + if (maximum == null) { + maximum = minimum; + minimum = 0; + } + if (minimum >= maximum) throw new Error("Invalid input: The maximum value must be greater than the minimum value."); + return Math.random() * (maximum - minimum) + minimum; +} +//#endregion +export { random }; diff --git a/node_modules/es-toolkit/dist/math/randomInt.d.mts b/node_modules/es-toolkit/dist/math/randomInt.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e4f6f0b5dab5ef7c5a72113136ddb4b78744940e --- /dev/null +++ b/node_modules/es-toolkit/dist/math/randomInt.d.mts @@ -0,0 +1,27 @@ +//#region src/math/randomInt.d.ts +/** + * Generates a random integer between 0 (inclusive) and the given maximum (exclusive). + * + * @param maximum - The upper bound (exclusive). + * @returns A random integer between 0 (inclusive) and maximum (exclusive). + * @throws {Error} Throws an error if `maximum` is not greater than `0`. + * + * @example + * const result = randomInt(5); // result will be a random integer between 0 (inclusive) and 5 (exclusive) + */ +declare function randomInt(maximum: number): number; +/** + * Generates a random integer between minimum (inclusive) and maximum (exclusive). + * + * @param minimum - The lower bound (inclusive). + * @param maximum - The upper bound (exclusive). + * @returns A random integer between minimum (inclusive) and maximum (exclusive). + * @throws {Error} Throws an error if `maximum` is not greater than `minimum`. + * + * @example + * const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive) + * const result2 = randomInt(5, 0); // This will throw an error + */ +declare function randomInt(minimum: number, maximum: number): number; +//#endregion +export { randomInt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/randomInt.d.ts b/node_modules/es-toolkit/dist/math/randomInt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4f6f0b5dab5ef7c5a72113136ddb4b78744940e --- /dev/null +++ b/node_modules/es-toolkit/dist/math/randomInt.d.ts @@ -0,0 +1,27 @@ +//#region src/math/randomInt.d.ts +/** + * Generates a random integer between 0 (inclusive) and the given maximum (exclusive). + * + * @param maximum - The upper bound (exclusive). + * @returns A random integer between 0 (inclusive) and maximum (exclusive). + * @throws {Error} Throws an error if `maximum` is not greater than `0`. + * + * @example + * const result = randomInt(5); // result will be a random integer between 0 (inclusive) and 5 (exclusive) + */ +declare function randomInt(maximum: number): number; +/** + * Generates a random integer between minimum (inclusive) and maximum (exclusive). + * + * @param minimum - The lower bound (inclusive). + * @param maximum - The upper bound (exclusive). + * @returns A random integer between minimum (inclusive) and maximum (exclusive). + * @throws {Error} Throws an error if `maximum` is not greater than `minimum`. + * + * @example + * const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive) + * const result2 = randomInt(5, 0); // This will throw an error + */ +declare function randomInt(minimum: number, maximum: number): number; +//#endregion +export { randomInt }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/randomInt.js b/node_modules/es-toolkit/dist/math/randomInt.js new file mode 100644 index 0000000000000000000000000000000000000000..f1fa712907a15d76e05f00dff18eb54cc29f821d --- /dev/null +++ b/node_modules/es-toolkit/dist/math/randomInt.js @@ -0,0 +1,21 @@ +const require_random = require("./random.js"); +//#region src/math/randomInt.ts +/** +* Generates a random integer between minimum (inclusive) and maximum (exclusive). +* +* If only one argument is provided, a number between `0` and the given number is returned. +* +* @param minimum - The lower bound (inclusive). +* @param maximum - The upper bound (exclusive). +* @returns A random integer between minimum (inclusive) and maximum (exclusive). +* @throws {Error} Throws an error if `maximum` is not greater than `minimum`. +* +* @example +* const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive) +* const result2 = randomInt(5, 0); // This will throw an error +*/ +function randomInt(minimum, maximum) { + return Math.floor(require_random.random(minimum, maximum)); +} +//#endregion +exports.randomInt = randomInt; diff --git a/node_modules/es-toolkit/dist/math/randomInt.mjs b/node_modules/es-toolkit/dist/math/randomInt.mjs new file mode 100644 index 0000000000000000000000000000000000000000..42f4e9fbbdac80fb99e994ebfb2bdf87680c368b --- /dev/null +++ b/node_modules/es-toolkit/dist/math/randomInt.mjs @@ -0,0 +1,21 @@ +import { random } from "./random.mjs"; +//#region src/math/randomInt.ts +/** +* Generates a random integer between minimum (inclusive) and maximum (exclusive). +* +* If only one argument is provided, a number between `0` and the given number is returned. +* +* @param minimum - The lower bound (inclusive). +* @param maximum - The upper bound (exclusive). +* @returns A random integer between minimum (inclusive) and maximum (exclusive). +* @throws {Error} Throws an error if `maximum` is not greater than `minimum`. +* +* @example +* const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive) +* const result2 = randomInt(5, 0); // This will throw an error +*/ +function randomInt(minimum, maximum) { + return Math.floor(random(minimum, maximum)); +} +//#endregion +export { randomInt }; diff --git a/node_modules/es-toolkit/dist/math/range.d.mts b/node_modules/es-toolkit/dist/math/range.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..22b23d30b0328a79b362f4a1e379db9e9a52a290 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/range.d.mts @@ -0,0 +1,39 @@ +//#region src/math/range.d.ts +/** + * Returns an array of numbers from `0` (inclusive) to `end` (exclusive), incrementing by `1`. + * + * @param end - The end number of the range (exclusive). + * @returns An array of numbers from `0` (inclusive) to `end` (exclusive) with a step of `1`. + * + * @example + * // Returns [0, 1, 2, 3] + * range(4); + */ +declare function range(end: number): number[]; +/** + * Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `1`. + * + * @param start - The starting number of the range (inclusive). + * @param end - The end number of the range (exclusive). + * @returns An array of numbers from `start` (inclusive) to `end` (exclusive) with a step of `1`. + * + * @example + * // Returns [1, 2, 3] + * range(1, 4); + */ +declare function range(start: number, end: number): number[]; +/** + * 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, 5, 10, 15] + * range(0, 20, 5); + */ +declare function range(start: number, end: number, step: number): number[]; +//#endregion +export { range }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/range.d.ts b/node_modules/es-toolkit/dist/math/range.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..22b23d30b0328a79b362f4a1e379db9e9a52a290 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/range.d.ts @@ -0,0 +1,39 @@ +//#region src/math/range.d.ts +/** + * Returns an array of numbers from `0` (inclusive) to `end` (exclusive), incrementing by `1`. + * + * @param end - The end number of the range (exclusive). + * @returns An array of numbers from `0` (inclusive) to `end` (exclusive) with a step of `1`. + * + * @example + * // Returns [0, 1, 2, 3] + * range(4); + */ +declare function range(end: number): number[]; +/** + * Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `1`. + * + * @param start - The starting number of the range (inclusive). + * @param end - The end number of the range (exclusive). + * @returns An array of numbers from `start` (inclusive) to `end` (exclusive) with a step of `1`. + * + * @example + * // Returns [1, 2, 3] + * range(1, 4); + */ +declare function range(start: number, end: number): number[]; +/** + * 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, 5, 10, 15] + * range(0, 20, 5); + */ +declare function range(start: number, end: number, step: number): number[]; +//#endregion +export { range }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/range.js b/node_modules/es-toolkit/dist/math/range.js new file mode 100644 index 0000000000000000000000000000000000000000..035cf1aecc1335b119fb11fb0a22665e39bcbabe --- /dev/null +++ b/node_modules/es-toolkit/dist/math/range.js @@ -0,0 +1,31 @@ +//#region src/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`. +* @throws {Error} Throws an error if the step value is not a non-zero integer. +* +* @example +* // Returns [0, 1, 2, 3] +* range(4); +* +* @example +* // Returns [0, -1, -2, -3] +* range(0, -4, -1); +*/ +function range(start, end, step = 1) { + if (end == null) { + end = start; + start = 0; + } + if (!Number.isInteger(step) || step === 0) throw new Error(`The step value must be a non-zero integer.`); + const length = Math.max(Math.ceil((end - start) / step), 0); + const result = new Array(length); + for (let i = 0; i < length; i++) result[i] = start + i * step; + return result; +} +//#endregion +exports.range = range; diff --git a/node_modules/es-toolkit/dist/math/range.mjs b/node_modules/es-toolkit/dist/math/range.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1a72af969e61674d3c65c10f74088e86827aa9f4 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/range.mjs @@ -0,0 +1,31 @@ +//#region src/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`. +* @throws {Error} Throws an error if the step value is not a non-zero integer. +* +* @example +* // Returns [0, 1, 2, 3] +* range(4); +* +* @example +* // Returns [0, -1, -2, -3] +* range(0, -4, -1); +*/ +function range(start, end, step = 1) { + if (end == null) { + end = start; + start = 0; + } + if (!Number.isInteger(step) || step === 0) throw new Error(`The step value must be a non-zero integer.`); + const length = Math.max(Math.ceil((end - start) / step), 0); + const result = new Array(length); + for (let i = 0; i < length; i++) result[i] = start + i * step; + return result; +} +//#endregion +export { range }; diff --git a/node_modules/es-toolkit/dist/math/rangeRight.d.mts b/node_modules/es-toolkit/dist/math/rangeRight.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3851b0a4807d2ebc16dec6df252185daba80e75e --- /dev/null +++ b/node_modules/es-toolkit/dist/math/rangeRight.d.mts @@ -0,0 +1,39 @@ +//#region src/math/rangeRight.d.ts +/** + * Returns an array of numbers from `end` (exclusive) to `0` (inclusive), decrementing by `1`. + * + * @param end - The end number of the range (exclusive). + * @returns An array of numbers from `end` (exclusive) to `0` (inclusive) with a step of `1`. + * + * @example + * // Returns [3, 2, 1, 0] + * rangeRight(4); + */ +declare function rangeRight(end: number): number[]; +/** + * Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `1`. + * + * @param start - The starting number of the range (inclusive). + * @param end - The end number of the range (exclusive). + * @returns An array of numbers from `end` (exclusive) to `start` (inclusive) with a step of `1`. + * + * @example + * // Returns [3, 2, 1] + * rangeRight(1, 4); + */ +declare function rangeRight(start: number, end: number): number[]; +/** + * 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`. + * + * @example + * // Returns [15, 10, 5, 0] + * rangeRight(0, 20, 5); + */ +declare function rangeRight(start: number, end: number, step: number): number[]; +//#endregion +export { rangeRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/rangeRight.d.ts b/node_modules/es-toolkit/dist/math/rangeRight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3851b0a4807d2ebc16dec6df252185daba80e75e --- /dev/null +++ b/node_modules/es-toolkit/dist/math/rangeRight.d.ts @@ -0,0 +1,39 @@ +//#region src/math/rangeRight.d.ts +/** + * Returns an array of numbers from `end` (exclusive) to `0` (inclusive), decrementing by `1`. + * + * @param end - The end number of the range (exclusive). + * @returns An array of numbers from `end` (exclusive) to `0` (inclusive) with a step of `1`. + * + * @example + * // Returns [3, 2, 1, 0] + * rangeRight(4); + */ +declare function rangeRight(end: number): number[]; +/** + * Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `1`. + * + * @param start - The starting number of the range (inclusive). + * @param end - The end number of the range (exclusive). + * @returns An array of numbers from `end` (exclusive) to `start` (inclusive) with a step of `1`. + * + * @example + * // Returns [3, 2, 1] + * rangeRight(1, 4); + */ +declare function rangeRight(start: number, end: number): number[]; +/** + * 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`. + * + * @example + * // Returns [15, 10, 5, 0] + * rangeRight(0, 20, 5); + */ +declare function rangeRight(start: number, end: number, step: number): number[]; +//#endregion +export { rangeRight }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/rangeRight.js b/node_modules/es-toolkit/dist/math/rangeRight.js new file mode 100644 index 0000000000000000000000000000000000000000..43b6d35788f0c2ee69a5077a2161f90d0764b848 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/rangeRight.js @@ -0,0 +1,31 @@ +//#region src/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 = 1) { + if (end == null) { + end = start; + start = 0; + } + if (!Number.isInteger(step) || step === 0) throw new Error(`The step value must be a non-zero integer.`); + const length = Math.max(Math.ceil((end - start) / step), 0); + const result = new Array(length); + for (let i = 0; i < length; i++) result[i] = start + (length - i - 1) * step; + return result; +} +//#endregion +exports.rangeRight = rangeRight; diff --git a/node_modules/es-toolkit/dist/math/rangeRight.mjs b/node_modules/es-toolkit/dist/math/rangeRight.mjs new file mode 100644 index 0000000000000000000000000000000000000000..95b3482d14e70230a40d7c52cf3cafe93f0e51f4 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/rangeRight.mjs @@ -0,0 +1,31 @@ +//#region src/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 = 1) { + if (end == null) { + end = start; + start = 0; + } + if (!Number.isInteger(step) || step === 0) throw new Error(`The step value must be a non-zero integer.`); + const length = Math.max(Math.ceil((end - start) / step), 0); + const result = new Array(length); + for (let i = 0; i < length; i++) result[i] = start + (length - i - 1) * step; + return result; +} +//#endregion +export { rangeRight }; diff --git a/node_modules/es-toolkit/dist/math/round.d.mts b/node_modules/es-toolkit/dist/math/round.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b3389aa36e1d69794691a02d7a94a6eded76ec11 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/round.d.mts @@ -0,0 +1,21 @@ +//#region src/math/round.d.ts +/** + * Rounds a number to a specified precision. + * + * This function takes a number and an optional precision value, and returns the number rounded + * to the specified number of decimal places. + * + * @param value - The number to round. + * @param [precision=0] - The number of decimal places to round to. Defaults to 0. + * @returns The rounded number. + * @throws {Error} Throws an error if `Precision` is not integer. + * + * @example + * const result1 = round(1.2345); // result1 will be 1 + * const result2 = round(1.2345, 2); // result2 will be 1.23 + * const result3 = round(1.2345, 3); // result3 will be 1.235 + * const result4 = round(1.2345, 3.1); // This will throw an error + */ +declare function round(value: number, precision?: number): number; +//#endregion +export { round }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/round.d.ts b/node_modules/es-toolkit/dist/math/round.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3389aa36e1d69794691a02d7a94a6eded76ec11 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/round.d.ts @@ -0,0 +1,21 @@ +//#region src/math/round.d.ts +/** + * Rounds a number to a specified precision. + * + * This function takes a number and an optional precision value, and returns the number rounded + * to the specified number of decimal places. + * + * @param value - The number to round. + * @param [precision=0] - The number of decimal places to round to. Defaults to 0. + * @returns The rounded number. + * @throws {Error} Throws an error if `Precision` is not integer. + * + * @example + * const result1 = round(1.2345); // result1 will be 1 + * const result2 = round(1.2345, 2); // result2 will be 1.23 + * const result3 = round(1.2345, 3); // result3 will be 1.235 + * const result4 = round(1.2345, 3.1); // This will throw an error + */ +declare function round(value: number, precision?: number): number; +//#endregion +export { round }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/round.js b/node_modules/es-toolkit/dist/math/round.js new file mode 100644 index 0000000000000000000000000000000000000000..f271f58e874b1412b07b86ecf496dc1e6860d89b --- /dev/null +++ b/node_modules/es-toolkit/dist/math/round.js @@ -0,0 +1,25 @@ +//#region src/math/round.ts +/** +* Rounds a number to a specified precision. +* +* This function takes a number and an optional precision value, and returns the number rounded +* to the specified number of decimal places. +* +* @param value - The number to round. +* @param [precision=0] - The number of decimal places to round to. Defaults to 0. +* @returns The rounded number. +* @throws {Error} Throws an error if `Precision` is not integer. +* +* @example +* const result1 = round(1.2345); // result1 will be 1 +* const result2 = round(1.2345, 2); // result2 will be 1.23 +* const result3 = round(1.2345, 3); // result3 will be 1.235 +* const result4 = round(1.2345, 3.1); // This will throw an error +*/ +function round(value, precision = 0) { + if (!Number.isInteger(precision)) throw new Error("Precision must be an integer."); + const multiplier = Math.pow(10, precision); + return Math.round(value * multiplier) / multiplier; +} +//#endregion +exports.round = round; diff --git a/node_modules/es-toolkit/dist/math/round.mjs b/node_modules/es-toolkit/dist/math/round.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6e9c107ade36d51fc9f0d1bf55818d2b3707e39e --- /dev/null +++ b/node_modules/es-toolkit/dist/math/round.mjs @@ -0,0 +1,25 @@ +//#region src/math/round.ts +/** +* Rounds a number to a specified precision. +* +* This function takes a number and an optional precision value, and returns the number rounded +* to the specified number of decimal places. +* +* @param value - The number to round. +* @param [precision=0] - The number of decimal places to round to. Defaults to 0. +* @returns The rounded number. +* @throws {Error} Throws an error if `Precision` is not integer. +* +* @example +* const result1 = round(1.2345); // result1 will be 1 +* const result2 = round(1.2345, 2); // result2 will be 1.23 +* const result3 = round(1.2345, 3); // result3 will be 1.235 +* const result4 = round(1.2345, 3.1); // This will throw an error +*/ +function round(value, precision = 0) { + if (!Number.isInteger(precision)) throw new Error("Precision must be an integer."); + const multiplier = Math.pow(10, precision); + return Math.round(value * multiplier) / multiplier; +} +//#endregion +export { round }; diff --git a/node_modules/es-toolkit/dist/math/sum.d.mts b/node_modules/es-toolkit/dist/math/sum.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9870bb9e255b5ef7567b559ffbaaa3f54c501354 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/sum.d.mts @@ -0,0 +1,17 @@ +//#region src/math/sum.d.ts +/** + * Calculates the sum of an array of numbers. + * + * This function takes an array of numbers and returns the sum of all the elements in the array. + * + * @param nums - An array of numbers to be summed. + * @returns The sum of all the numbers in the array. + * + * @example + * const numbers = [1, 2, 3, 4, 5]; + * const result = sum(numbers); + * // result will be 15 + */ +declare function sum(nums: readonly number[]): number; +//#endregion +export { sum }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/sum.d.ts b/node_modules/es-toolkit/dist/math/sum.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9870bb9e255b5ef7567b559ffbaaa3f54c501354 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/sum.d.ts @@ -0,0 +1,17 @@ +//#region src/math/sum.d.ts +/** + * Calculates the sum of an array of numbers. + * + * This function takes an array of numbers and returns the sum of all the elements in the array. + * + * @param nums - An array of numbers to be summed. + * @returns The sum of all the numbers in the array. + * + * @example + * const numbers = [1, 2, 3, 4, 5]; + * const result = sum(numbers); + * // result will be 15 + */ +declare function sum(nums: readonly number[]): number; +//#endregion +export { sum }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/sum.js b/node_modules/es-toolkit/dist/math/sum.js new file mode 100644 index 0000000000000000000000000000000000000000..42a6006df0d7a4c2447c9f9070ce7615ee4848b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/sum.js @@ -0,0 +1,21 @@ +//#region src/math/sum.ts +/** +* Calculates the sum of an array of numbers. +* +* This function takes an array of numbers and returns the sum of all the elements in the array. +* +* @param nums - An array of numbers to be summed. +* @returns The sum of all the numbers in the array. +* +* @example +* const numbers = [1, 2, 3, 4, 5]; +* const result = sum(numbers); +* // result will be 15 +*/ +function sum(nums) { + let result = 0; + for (let i = 0; i < nums.length; i++) result += nums[i]; + return result; +} +//#endregion +exports.sum = sum; diff --git a/node_modules/es-toolkit/dist/math/sum.mjs b/node_modules/es-toolkit/dist/math/sum.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5d3e6db101efc093fc3a06b7b11f91d4f6facf1c --- /dev/null +++ b/node_modules/es-toolkit/dist/math/sum.mjs @@ -0,0 +1,21 @@ +//#region src/math/sum.ts +/** +* Calculates the sum of an array of numbers. +* +* This function takes an array of numbers and returns the sum of all the elements in the array. +* +* @param nums - An array of numbers to be summed. +* @returns The sum of all the numbers in the array. +* +* @example +* const numbers = [1, 2, 3, 4, 5]; +* const result = sum(numbers); +* // result will be 15 +*/ +function sum(nums) { + let result = 0; + for (let i = 0; i < nums.length; i++) result += nums[i]; + return result; +} +//#endregion +export { sum }; diff --git a/node_modules/es-toolkit/dist/math/sumBy.d.mts b/node_modules/es-toolkit/dist/math/sumBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7dbcf2a7171bf1b8265b387c3cbdd78f4fe922e8 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/sumBy.d.mts @@ -0,0 +1,20 @@ +//#region src/math/sumBy.d.ts +/** + * Calculates the sum of an array of numbers when applying + * the `getValue` function to each element. + * + * If the array is empty, this function returns `0`. + * + * @template T - The type of elements in the array. + * @param items - An array to calculate the sum. + * @param getValue - A function that selects a numeric value from each element. + * It receives the element and its zero‑based index in the array. + * @returns The sum of all the numbers as determined by the `getValue` function. + * + * @example + * sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], (x, i) => x.a * i); // Returns: 8 + * sumBy([], () => 1); // Returns: 0 + */ +declare function sumBy(items: readonly T[], getValue: (element: T, index: number) => number): number; +//#endregion +export { sumBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/sumBy.d.ts b/node_modules/es-toolkit/dist/math/sumBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7dbcf2a7171bf1b8265b387c3cbdd78f4fe922e8 --- /dev/null +++ b/node_modules/es-toolkit/dist/math/sumBy.d.ts @@ -0,0 +1,20 @@ +//#region src/math/sumBy.d.ts +/** + * Calculates the sum of an array of numbers when applying + * the `getValue` function to each element. + * + * If the array is empty, this function returns `0`. + * + * @template T - The type of elements in the array. + * @param items - An array to calculate the sum. + * @param getValue - A function that selects a numeric value from each element. + * It receives the element and its zero‑based index in the array. + * @returns The sum of all the numbers as determined by the `getValue` function. + * + * @example + * sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], (x, i) => x.a * i); // Returns: 8 + * sumBy([], () => 1); // Returns: 0 + */ +declare function sumBy(items: readonly T[], getValue: (element: T, index: number) => number): number; +//#endregion +export { sumBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/math/sumBy.js b/node_modules/es-toolkit/dist/math/sumBy.js new file mode 100644 index 0000000000000000000000000000000000000000..ad340dde002d013424532cb485589b53c0b2c64a --- /dev/null +++ b/node_modules/es-toolkit/dist/math/sumBy.js @@ -0,0 +1,24 @@ +//#region src/math/sumBy.ts +/** +* Calculates the sum of an array of numbers when applying +* the `getValue` function to each element. +* +* If the array is empty, this function returns `0`. +* +* @template T - The type of elements in the array. +* @param items - An array to calculate the sum. +* @param getValue - A function that selects a numeric value from each element. +* It receives the element and its zero‑based index in the array. +* @returns The sum of all the numbers as determined by the `getValue` function. +* +* @example +* sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], (x, i) => x.a * i); // Returns: 8 +* sumBy([], () => 1); // Returns: 0 +*/ +function sumBy(items, getValue) { + let result = 0; + for (let i = 0; i < items.length; i++) result += getValue(items[i], i); + return result; +} +//#endregion +exports.sumBy = sumBy; diff --git a/node_modules/es-toolkit/dist/math/sumBy.mjs b/node_modules/es-toolkit/dist/math/sumBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..006e3cc4fafa765c4dd8f04471f4fdb86b648dbe --- /dev/null +++ b/node_modules/es-toolkit/dist/math/sumBy.mjs @@ -0,0 +1,24 @@ +//#region src/math/sumBy.ts +/** +* Calculates the sum of an array of numbers when applying +* the `getValue` function to each element. +* +* If the array is empty, this function returns `0`. +* +* @template T - The type of elements in the array. +* @param items - An array to calculate the sum. +* @param getValue - A function that selects a numeric value from each element. +* It receives the element and its zero‑based index in the array. +* @returns The sum of all the numbers as determined by the `getValue` function. +* +* @example +* sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], (x, i) => x.a * i); // Returns: 8 +* sumBy([], () => 1); // Returns: 0 +*/ +function sumBy(items, getValue) { + let result = 0; + for (let i = 0; i < items.length; i++) result += getValue(items[i], i); + return result; +} +//#endregion +export { sumBy }; diff --git a/node_modules/es-toolkit/dist/object/clone.d.mts b/node_modules/es-toolkit/dist/object/clone.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..682edea592d7ecce7bc77f0b3dfe671aa425ac12 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/clone.d.mts @@ -0,0 +1,32 @@ +//#region src/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 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 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/object/clone.d.ts b/node_modules/es-toolkit/dist/object/clone.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..682edea592d7ecce7bc77f0b3dfe671aa425ac12 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/clone.d.ts @@ -0,0 +1,32 @@ +//#region src/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 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 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/object/clone.js b/node_modules/es-toolkit/dist/object/clone.js new file mode 100644 index 0000000000000000000000000000000000000000..2363291a3c8122f10958a997fada88b8bb8a9291 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/clone.js @@ -0,0 +1,61 @@ +const require_isPrimitive = require("../predicate/isPrimitive.js"); +const require_isTypedArray = require("../predicate/isTypedArray.js"); +//#region src/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 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 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; + if (Array.isArray(obj) || require_isTypedArray.isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && obj instanceof SharedArrayBuffer) return obj.slice(0); + const prototype = Object.getPrototypeOf(obj); + if (prototype == null) return Object.assign(Object.create(prototype), obj); + const Constructor = prototype.constructor; + if (obj instanceof Date || obj instanceof Map || obj instanceof Set) return new Constructor(obj); + if (obj instanceof RegExp) { + const newRegExp = new Constructor(obj); + newRegExp.lastIndex = obj.lastIndex; + return newRegExp; + } + if (obj instanceof DataView) return new Constructor(obj.buffer.slice(0)); + if (obj instanceof Error) { + let newError; + if (obj instanceof AggregateError) newError = new Constructor(obj.errors, obj.message, { cause: obj.cause }); + else newError = new Constructor(obj.message, { cause: obj.cause }); + newError.stack = obj.stack; + Object.assign(newError, obj); + return newError; + } + if (typeof File !== "undefined" && obj instanceof File) return new Constructor([obj], obj.name, { + type: obj.type, + lastModified: obj.lastModified + }); + if (typeof obj === "object") return Object.assign(Object.create(prototype), obj); + return obj; +} +//#endregion +exports.clone = clone; diff --git a/node_modules/es-toolkit/dist/object/clone.mjs b/node_modules/es-toolkit/dist/object/clone.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8f83659233f5fdcf833b20f8ca8ef1accb8a1333 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/clone.mjs @@ -0,0 +1,61 @@ +import { isPrimitive } from "../predicate/isPrimitive.mjs"; +import { isTypedArray } from "../predicate/isTypedArray.mjs"; +//#region src/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 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 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; + if (Array.isArray(obj) || isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && obj instanceof SharedArrayBuffer) return obj.slice(0); + const prototype = Object.getPrototypeOf(obj); + if (prototype == null) return Object.assign(Object.create(prototype), obj); + const Constructor = prototype.constructor; + if (obj instanceof Date || obj instanceof Map || obj instanceof Set) return new Constructor(obj); + if (obj instanceof RegExp) { + const newRegExp = new Constructor(obj); + newRegExp.lastIndex = obj.lastIndex; + return newRegExp; + } + if (obj instanceof DataView) return new Constructor(obj.buffer.slice(0)); + if (obj instanceof Error) { + let newError; + if (obj instanceof AggregateError) newError = new Constructor(obj.errors, obj.message, { cause: obj.cause }); + else newError = new Constructor(obj.message, { cause: obj.cause }); + newError.stack = obj.stack; + Object.assign(newError, obj); + return newError; + } + if (typeof File !== "undefined" && obj instanceof File) return new Constructor([obj], obj.name, { + type: obj.type, + lastModified: obj.lastModified + }); + if (typeof obj === "object") return Object.assign(Object.create(prototype), obj); + return obj; +} +//#endregion +export { clone }; diff --git a/node_modules/es-toolkit/dist/object/cloneDeep.d.mts b/node_modules/es-toolkit/dist/object/cloneDeep.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..319c948f64658c744e66211fbb9644ad3d7c2d7d --- /dev/null +++ b/node_modules/es-toolkit/dist/object/cloneDeep.d.mts @@ -0,0 +1,50 @@ +//#region src/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 = cloneDeep(num); + * console.log(clonedNum); // 29 + * console.log(clonedNum === num); // true + * + * @example + * // Clone an array + * const arr = [1, 2, 3]; + * const clonedArr = cloneDeep(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 = cloneDeep(arr); + * arr[1].a = 2; + * console.log(arr); // [1, { 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 = cloneDeep(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 = cloneDeep(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/object/cloneDeep.d.ts b/node_modules/es-toolkit/dist/object/cloneDeep.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..319c948f64658c744e66211fbb9644ad3d7c2d7d --- /dev/null +++ b/node_modules/es-toolkit/dist/object/cloneDeep.d.ts @@ -0,0 +1,50 @@ +//#region src/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 = cloneDeep(num); + * console.log(clonedNum); // 29 + * console.log(clonedNum === num); // true + * + * @example + * // Clone an array + * const arr = [1, 2, 3]; + * const clonedArr = cloneDeep(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 = cloneDeep(arr); + * arr[1].a = 2; + * console.log(arr); // [1, { 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 = cloneDeep(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 = cloneDeep(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/object/cloneDeep.js b/node_modules/es-toolkit/dist/object/cloneDeep.js new file mode 100644 index 0000000000000000000000000000000000000000..93dc9ec177ebdd0a25bf8abc340f855a419732ca --- /dev/null +++ b/node_modules/es-toolkit/dist/object/cloneDeep.js @@ -0,0 +1,53 @@ +const require_cloneDeepWith = require("./cloneDeepWith.js"); +//#region src/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 = cloneDeep(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an array +* const arr = [1, 2, 3]; +* const clonedArr = cloneDeep(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 = cloneDeep(arr); +* arr[1].a = 2; +* console.log(arr); // [1, { 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 = cloneDeep(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 = cloneDeep(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.cloneDeepWithImpl(obj, void 0, obj, /* @__PURE__ */ new Map(), void 0); +} +//#endregion +exports.cloneDeep = cloneDeep; diff --git a/node_modules/es-toolkit/dist/object/cloneDeep.mjs b/node_modules/es-toolkit/dist/object/cloneDeep.mjs new file mode 100644 index 0000000000000000000000000000000000000000..dbdcfba766815d7cbd4fcc6aba742150cff72c77 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/cloneDeep.mjs @@ -0,0 +1,53 @@ +import { cloneDeepWithImpl } from "./cloneDeepWith.mjs"; +//#region src/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 = cloneDeep(num); +* console.log(clonedNum); // 29 +* console.log(clonedNum === num); // true +* +* @example +* // Clone an array +* const arr = [1, 2, 3]; +* const clonedArr = cloneDeep(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 = cloneDeep(arr); +* arr[1].a = 2; +* console.log(arr); // [1, { 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 = cloneDeep(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 = cloneDeep(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 cloneDeepWithImpl(obj, void 0, obj, /* @__PURE__ */ new Map(), void 0); +} +//#endregion +export { cloneDeep }; diff --git a/node_modules/es-toolkit/dist/object/cloneDeepWith.d.mts b/node_modules/es-toolkit/dist/object/cloneDeepWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..87231924e0042e78d591a61732ba3d819a8358d5 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/cloneDeepWith.d.mts @@ -0,0 +1,46 @@ +//#region src/object/cloneDeepWith.d.ts +/** + * Deeply clones the given object. + * + * You can customize the deep cloning process using the `cloneValue` function. + * The function takes the current value `value`, the property name `key`, and the entire object `obj` as arguments. + * If the function returns a value, that value is used; + * if it returns `undefined`, the default cloning method is used. + * + * @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 + */ +declare function cloneDeepWith(obj: T, cloneValue: (value: any, key: PropertyKey | undefined, obj: T, stack: Map) => any): T; +declare function cloneDeepWithImpl(valueToClone: any, keyToClone: PropertyKey | undefined, objectToClone: T, stack?: Map, cloneValue?: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map) => any) | undefined): T; +declare function copyProperties(target: any, source: any, objectToClone?: T, stack?: Map | undefined, cloneValue?: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map) => any) | undefined): void; +//#endregion +export { cloneDeepWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/cloneDeepWith.d.ts b/node_modules/es-toolkit/dist/object/cloneDeepWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..87231924e0042e78d591a61732ba3d819a8358d5 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/cloneDeepWith.d.ts @@ -0,0 +1,46 @@ +//#region src/object/cloneDeepWith.d.ts +/** + * Deeply clones the given object. + * + * You can customize the deep cloning process using the `cloneValue` function. + * The function takes the current value `value`, the property name `key`, and the entire object `obj` as arguments. + * If the function returns a value, that value is used; + * if it returns `undefined`, the default cloning method is used. + * + * @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 + */ +declare function cloneDeepWith(obj: T, cloneValue: (value: any, key: PropertyKey | undefined, obj: T, stack: Map) => any): T; +declare function cloneDeepWithImpl(valueToClone: any, keyToClone: PropertyKey | undefined, objectToClone: T, stack?: Map, cloneValue?: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map) => any) | undefined): T; +declare function copyProperties(target: any, source: any, objectToClone?: T, stack?: Map | undefined, cloneValue?: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map) => any) | undefined): void; +//#endregion +export { cloneDeepWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/cloneDeepWith.js b/node_modules/es-toolkit/dist/object/cloneDeepWith.js new file mode 100644 index 0000000000000000000000000000000000000000..0ca6a2bb1c0d095bf2b280d7ab1bb3dbf62c7b29 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/cloneDeepWith.js @@ -0,0 +1,183 @@ +const require_isPrimitive = require("../predicate/isPrimitive.js"); +const require_isTypedArray = require("../predicate/isTypedArray.js"); +const require_getSymbols = require("../compat/_internal/getSymbols.js"); +const require_getTag = require("../compat/_internal/getTag.js"); +const require_tags = require("../compat/_internal/tags.js"); +const require_isBuffer = require("../predicate/isBuffer.js"); +//#region src/object/cloneDeepWith.ts +/** +* Deeply clones the given object. +* +* You can customize the deep cloning process using the `cloneValue` function. +* The function takes the current value `value`, the property name `key`, and the entire object `obj` as arguments. +* If the function returns a value, that value is used; +* if it returns `undefined`, the default cloning method is used. +* +* @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, cloneValue) { + return cloneDeepWithImpl(obj, void 0, obj, /* @__PURE__ */ new Map(), cloneValue); +} +function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = /* @__PURE__ */ new Map(), cloneValue = void 0) { + const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack); + if (cloned !== void 0) return cloned; + if (require_isPrimitive.isPrimitive(valueToClone)) return valueToClone; + if (stack.has(valueToClone)) return stack.get(valueToClone); + if (Array.isArray(valueToClone)) { + const result = new Array(valueToClone.length); + stack.set(valueToClone, result); + for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue); + if (Object.hasOwn(valueToClone, "index")) result.index = valueToClone.index; + if (Object.hasOwn(valueToClone, "input")) result.input = valueToClone.input; + return result; + } + if (valueToClone instanceof Date) return new Date(valueToClone.getTime()); + if (valueToClone instanceof RegExp) { + const result = new RegExp(valueToClone.source, valueToClone.flags); + result.lastIndex = valueToClone.lastIndex; + return result; + } + if (valueToClone instanceof Map) { + const result = /* @__PURE__ */ new Map(); + stack.set(valueToClone, result); + for (const [key, value] of valueToClone) result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue)); + return result; + } + if (valueToClone instanceof Set) { + const result = /* @__PURE__ */ new Set(); + stack.set(valueToClone, result); + for (const value of valueToClone) result.add(cloneDeepWithImpl(value, void 0, objectToClone, stack, cloneValue)); + return result; + } + if (require_isBuffer.isBuffer(valueToClone)) return valueToClone.subarray(); + if (require_isTypedArray.isTypedArray(valueToClone)) { + const result = new (Object.getPrototypeOf(valueToClone)).constructor(valueToClone.length); + stack.set(valueToClone, result); + for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && valueToClone instanceof SharedArrayBuffer) return valueToClone.slice(0); + if (valueToClone instanceof DataView) { + const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (typeof File !== "undefined" && valueToClone instanceof File) { + const result = new File([valueToClone], valueToClone.name, { type: valueToClone.type }); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (typeof Blob !== "undefined" && valueToClone instanceof Blob) { + const result = new Blob([valueToClone], { type: valueToClone.type }); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof Error) { + const result = structuredClone(valueToClone); + stack.set(valueToClone, result); + result.message = valueToClone.message; + result.name = valueToClone.name; + result.stack = valueToClone.stack; + result.cause = valueToClone.cause; + result.constructor = valueToClone.constructor; + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof Boolean) { + const result = new Boolean(valueToClone.valueOf()); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof Number) { + const result = new Number(valueToClone.valueOf()); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof String) { + const result = new String(valueToClone.valueOf()); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (typeof valueToClone === "object" && isCloneableObject(valueToClone)) { + const result = Object.create(Object.getPrototypeOf(valueToClone)); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + return valueToClone; +} +function copyProperties(target, source, objectToClone = target, stack, cloneValue) { + const keys = [...Object.keys(source), ...require_getSymbols.getSymbols(source)]; + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const descriptor = Object.getOwnPropertyDescriptor(target, key); + if (descriptor == null || descriptor.writable) target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue); + } +} +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; + } +} +//#endregion +exports.cloneDeepWith = cloneDeepWith; +exports.cloneDeepWithImpl = cloneDeepWithImpl; +exports.copyProperties = copyProperties; diff --git a/node_modules/es-toolkit/dist/object/cloneDeepWith.mjs b/node_modules/es-toolkit/dist/object/cloneDeepWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9d5ffb532bf5a63611cd8f507921ea9627d7a5d8 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/cloneDeepWith.mjs @@ -0,0 +1,181 @@ +import { isPrimitive } from "../predicate/isPrimitive.mjs"; +import { isTypedArray } from "../predicate/isTypedArray.mjs"; +import { getSymbols } from "../compat/_internal/getSymbols.mjs"; +import { getTag } from "../compat/_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 "../compat/_internal/tags.mjs"; +import { isBuffer } from "../predicate/isBuffer.mjs"; +//#region src/object/cloneDeepWith.ts +/** +* Deeply clones the given object. +* +* You can customize the deep cloning process using the `cloneValue` function. +* The function takes the current value `value`, the property name `key`, and the entire object `obj` as arguments. +* If the function returns a value, that value is used; +* if it returns `undefined`, the default cloning method is used. +* +* @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, cloneValue) { + return cloneDeepWithImpl(obj, void 0, obj, /* @__PURE__ */ new Map(), cloneValue); +} +function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = /* @__PURE__ */ new Map(), cloneValue = void 0) { + const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack); + if (cloned !== void 0) return cloned; + if (isPrimitive(valueToClone)) return valueToClone; + if (stack.has(valueToClone)) return stack.get(valueToClone); + if (Array.isArray(valueToClone)) { + const result = new Array(valueToClone.length); + stack.set(valueToClone, result); + for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue); + if (Object.hasOwn(valueToClone, "index")) result.index = valueToClone.index; + if (Object.hasOwn(valueToClone, "input")) result.input = valueToClone.input; + return result; + } + if (valueToClone instanceof Date) return new Date(valueToClone.getTime()); + if (valueToClone instanceof RegExp) { + const result = new RegExp(valueToClone.source, valueToClone.flags); + result.lastIndex = valueToClone.lastIndex; + return result; + } + if (valueToClone instanceof Map) { + const result = /* @__PURE__ */ new Map(); + stack.set(valueToClone, result); + for (const [key, value] of valueToClone) result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue)); + return result; + } + if (valueToClone instanceof Set) { + const result = /* @__PURE__ */ new Set(); + stack.set(valueToClone, result); + for (const value of valueToClone) result.add(cloneDeepWithImpl(value, void 0, objectToClone, stack, cloneValue)); + return result; + } + if (isBuffer(valueToClone)) return valueToClone.subarray(); + if (isTypedArray(valueToClone)) { + const result = new (Object.getPrototypeOf(valueToClone)).constructor(valueToClone.length); + stack.set(valueToClone, result); + for (let i = 0; i < valueToClone.length; i++) result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && valueToClone instanceof SharedArrayBuffer) return valueToClone.slice(0); + if (valueToClone instanceof DataView) { + const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (typeof File !== "undefined" && valueToClone instanceof File) { + const result = new File([valueToClone], valueToClone.name, { type: valueToClone.type }); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (typeof Blob !== "undefined" && valueToClone instanceof Blob) { + const result = new Blob([valueToClone], { type: valueToClone.type }); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof Error) { + const result = structuredClone(valueToClone); + stack.set(valueToClone, result); + result.message = valueToClone.message; + result.name = valueToClone.name; + result.stack = valueToClone.stack; + result.cause = valueToClone.cause; + result.constructor = valueToClone.constructor; + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof Boolean) { + const result = new Boolean(valueToClone.valueOf()); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof Number) { + const result = new Number(valueToClone.valueOf()); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (valueToClone instanceof String) { + const result = new String(valueToClone.valueOf()); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + if (typeof valueToClone === "object" && isCloneableObject(valueToClone)) { + const result = Object.create(Object.getPrototypeOf(valueToClone)); + stack.set(valueToClone, result); + copyProperties(result, valueToClone, objectToClone, stack, cloneValue); + return result; + } + return valueToClone; +} +function copyProperties(target, source, objectToClone = target, stack, cloneValue) { + const keys = [...Object.keys(source), ...getSymbols(source)]; + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const descriptor = Object.getOwnPropertyDescriptor(target, key); + if (descriptor == null || descriptor.writable) target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue); + } +} +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; + } +} +//#endregion +export { cloneDeepWith, cloneDeepWithImpl, copyProperties }; diff --git a/node_modules/es-toolkit/dist/object/findKey.d.mts b/node_modules/es-toolkit/dist/object/findKey.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bca86cfdf587dd3b4c55c28bf18cb81e44d8e644 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/findKey.d.mts @@ -0,0 +1,22 @@ +//#region src/object/findKey.d.ts +/** + * Finds the key of the first element in the object that satisfies the provided testing function. + * + * @param obj - The object to search. + * @param predicate - The function to execute on each value in the object. It takes three arguments: + * - value: The current value being processed in the object. + * - key: The key of the current value being processed in the object. + * - obj: The object that findKey was called upon. + * @returns The key of the first element in the object that passes the test, or undefined if no element passes. + * + * @example + * const users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * findKey(users, function(o) { return o.age < 40; }); => 'barney' + */ +declare function findKey>(obj: T, predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean): keyof T | undefined; +//#endregion +export { findKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/findKey.d.ts b/node_modules/es-toolkit/dist/object/findKey.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bca86cfdf587dd3b4c55c28bf18cb81e44d8e644 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/findKey.d.ts @@ -0,0 +1,22 @@ +//#region src/object/findKey.d.ts +/** + * Finds the key of the first element in the object that satisfies the provided testing function. + * + * @param obj - The object to search. + * @param predicate - The function to execute on each value in the object. It takes three arguments: + * - value: The current value being processed in the object. + * - key: The key of the current value being processed in the object. + * - obj: The object that findKey was called upon. + * @returns The key of the first element in the object that passes the test, or undefined if no element passes. + * + * @example + * const users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * findKey(users, function(o) { return o.age < 40; }); => 'barney' + */ +declare function findKey>(obj: T, predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean): keyof T | undefined; +//#endregion +export { findKey }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/findKey.js b/node_modules/es-toolkit/dist/object/findKey.js new file mode 100644 index 0000000000000000000000000000000000000000..f84b5a8b3618fca1e248e80e1b5c9364a985ac6e --- /dev/null +++ b/node_modules/es-toolkit/dist/object/findKey.js @@ -0,0 +1,24 @@ +//#region src/object/findKey.ts +/** +* Finds the key of the first element in the object that satisfies the provided testing function. +* +* @param obj - The object to search. +* @param predicate - The function to execute on each value in the object. It takes three arguments: +* - value: The current value being processed in the object. +* - key: The key of the current value being processed in the object. +* - obj: The object that findKey was called upon. +* @returns The key of the first element in the object that passes the test, or undefined if no element passes. +* +* @example +* const users = { +* 'barney': { 'age': 36, 'active': true }, +* 'fred': { 'age': 40, 'active': false }, +* 'pebbles': { 'age': 1, 'active': true } +* }; +* findKey(users, function(o) { return o.age < 40; }); => 'barney' +*/ +function findKey(obj, predicate) { + return Object.keys(obj).find((key) => predicate(obj[key], key, obj)); +} +//#endregion +exports.findKey = findKey; diff --git a/node_modules/es-toolkit/dist/object/findKey.mjs b/node_modules/es-toolkit/dist/object/findKey.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bfb1f6366dbf26d9fa80eb7c9e6474af669b0102 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/findKey.mjs @@ -0,0 +1,24 @@ +//#region src/object/findKey.ts +/** +* Finds the key of the first element in the object that satisfies the provided testing function. +* +* @param obj - The object to search. +* @param predicate - The function to execute on each value in the object. It takes three arguments: +* - value: The current value being processed in the object. +* - key: The key of the current value being processed in the object. +* - obj: The object that findKey was called upon. +* @returns The key of the first element in the object that passes the test, or undefined if no element passes. +* +* @example +* const users = { +* 'barney': { 'age': 36, 'active': true }, +* 'fred': { 'age': 40, 'active': false }, +* 'pebbles': { 'age': 1, 'active': true } +* }; +* findKey(users, function(o) { return o.age < 40; }); => 'barney' +*/ +function findKey(obj, predicate) { + return Object.keys(obj).find((key) => predicate(obj[key], key, obj)); +} +//#endregion +export { findKey }; diff --git a/node_modules/es-toolkit/dist/object/flattenObject.d.mts b/node_modules/es-toolkit/dist/object/flattenObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d04de7818f2e857b69a18ab606d62179d8ff5d0f --- /dev/null +++ b/node_modules/es-toolkit/dist/object/flattenObject.d.mts @@ -0,0 +1,39 @@ +//#region src/object/flattenObject.d.ts +interface FlattenObjectOptions { + /** + * The delimiter to use between nested keys. + * @default '.' + */ + delimiter?: string; +} +/** + * Flattens a nested object into a single level object with delimiter-separated keys. + * + * @param object - The object to flatten. + * @param [options.delimiter='.'] - The delimiter to use between nested keys. + * @returns The flattened object. + * + * @example + * const nestedObject = { + * a: { + * b: { + * c: 1 + * } + * }, + * d: [2, 3] + * }; + * + * const flattened = flattenObject(nestedObject); + * console.log(flattened); + * // Output: + * // { + * // 'a.b.c': 1, + * // 'd.0': 2, + * // 'd.1': 3 + * // } + */ +declare function flattenObject(object: object, { + delimiter +}?: FlattenObjectOptions): Record; +//#endregion +export { flattenObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/flattenObject.d.ts b/node_modules/es-toolkit/dist/object/flattenObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d04de7818f2e857b69a18ab606d62179d8ff5d0f --- /dev/null +++ b/node_modules/es-toolkit/dist/object/flattenObject.d.ts @@ -0,0 +1,39 @@ +//#region src/object/flattenObject.d.ts +interface FlattenObjectOptions { + /** + * The delimiter to use between nested keys. + * @default '.' + */ + delimiter?: string; +} +/** + * Flattens a nested object into a single level object with delimiter-separated keys. + * + * @param object - The object to flatten. + * @param [options.delimiter='.'] - The delimiter to use between nested keys. + * @returns The flattened object. + * + * @example + * const nestedObject = { + * a: { + * b: { + * c: 1 + * } + * }, + * d: [2, 3] + * }; + * + * const flattened = flattenObject(nestedObject); + * console.log(flattened); + * // Output: + * // { + * // 'a.b.c': 1, + * // 'd.0': 2, + * // 'd.1': 3 + * // } + */ +declare function flattenObject(object: object, { + delimiter +}?: FlattenObjectOptions): Record; +//#endregion +export { flattenObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/flattenObject.js b/node_modules/es-toolkit/dist/object/flattenObject.js new file mode 100644 index 0000000000000000000000000000000000000000..376e1c4c15e4e027d69211ad0bb0aca3cb1cff7f --- /dev/null +++ b/node_modules/es-toolkit/dist/object/flattenObject.js @@ -0,0 +1,52 @@ +const require_isPlainObject = require("../predicate/isPlainObject.js"); +//#region src/object/flattenObject.ts +/** +* Flattens a nested object into a single level object with delimiter-separated keys. +* +* @param object - The object to flatten. +* @param [options.delimiter='.'] - The delimiter to use between nested keys. +* @returns The flattened object. +* +* @example +* const nestedObject = { +* a: { +* b: { +* c: 1 +* } +* }, +* d: [2, 3] +* }; +* +* const flattened = flattenObject(nestedObject); +* console.log(flattened); +* // Output: +* // { +* // 'a.b.c': 1, +* // 'd.0': 2, +* // 'd.1': 3 +* // } +*/ +function flattenObject(object, { delimiter = "." } = {}) { + return flattenObjectImpl(object, "", delimiter); +} +function flattenObjectImpl(object, prefix, delimiter) { + const result = {}; + const keys = Object.keys(object); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = object[key]; + const prefixedKey = prefix ? `${prefix}${delimiter}${key}` : key; + if (require_isPlainObject.isPlainObject(value) && Object.keys(value).length > 0) { + Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter)); + continue; + } + if (Array.isArray(value) && value.length > 0) { + Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter)); + continue; + } + result[prefixedKey] = value; + } + return result; +} +//#endregion +exports.flattenObject = flattenObject; diff --git a/node_modules/es-toolkit/dist/object/flattenObject.mjs b/node_modules/es-toolkit/dist/object/flattenObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..afb4addc0c5c6839279ecfacdf677d053816b0db --- /dev/null +++ b/node_modules/es-toolkit/dist/object/flattenObject.mjs @@ -0,0 +1,52 @@ +import { isPlainObject } from "../predicate/isPlainObject.mjs"; +//#region src/object/flattenObject.ts +/** +* Flattens a nested object into a single level object with delimiter-separated keys. +* +* @param object - The object to flatten. +* @param [options.delimiter='.'] - The delimiter to use between nested keys. +* @returns The flattened object. +* +* @example +* const nestedObject = { +* a: { +* b: { +* c: 1 +* } +* }, +* d: [2, 3] +* }; +* +* const flattened = flattenObject(nestedObject); +* console.log(flattened); +* // Output: +* // { +* // 'a.b.c': 1, +* // 'd.0': 2, +* // 'd.1': 3 +* // } +*/ +function flattenObject(object, { delimiter = "." } = {}) { + return flattenObjectImpl(object, "", delimiter); +} +function flattenObjectImpl(object, prefix, delimiter) { + const result = {}; + const keys = Object.keys(object); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = object[key]; + const prefixedKey = prefix ? `${prefix}${delimiter}${key}` : key; + if (isPlainObject(value) && Object.keys(value).length > 0) { + Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter)); + continue; + } + if (Array.isArray(value) && value.length > 0) { + Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter)); + continue; + } + result[prefixedKey] = value; + } + return result; +} +//#endregion +export { flattenObject }; diff --git a/node_modules/es-toolkit/dist/object/index.d.mts b/node_modules/es-toolkit/dist/object/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7fbdfda360b63fd31af27a5f5b9225f178f998d8 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/index.d.mts @@ -0,0 +1,19 @@ +import { clone } from "./clone.mjs"; +import { cloneDeep } from "./cloneDeep.mjs"; +import { cloneDeepWith } from "./cloneDeepWith.mjs"; +import { findKey } from "./findKey.mjs"; +import { flattenObject } from "./flattenObject.mjs"; +import { invert } from "./invert.mjs"; +import { mapKeys } from "./mapKeys.mjs"; +import { mapValues } from "./mapValues.mjs"; +import { merge } from "./merge.mjs"; +import { mergeWith } from "./mergeWith.mjs"; +import { omit } from "./omit.mjs"; +import { omitBy } from "./omitBy.mjs"; +import { pick } from "./pick.mjs"; +import { pickBy } from "./pickBy.mjs"; +import { sortKeys } from "./sortKeys.mjs"; +import { toCamelCaseKeys } from "./toCamelCaseKeys.mjs"; +import { toMerged } from "./toMerged.mjs"; +import { toSnakeCaseKeys } from "./toSnakeCaseKeys.mjs"; +export { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toMerged, toSnakeCaseKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/index.d.ts b/node_modules/es-toolkit/dist/object/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5e28289c74502f9c2c5a2cafa28a93bfc1b8739 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/index.d.ts @@ -0,0 +1,19 @@ +import { clone } from "./clone.js"; +import { cloneDeep } from "./cloneDeep.js"; +import { cloneDeepWith } from "./cloneDeepWith.js"; +import { findKey } from "./findKey.js"; +import { flattenObject } from "./flattenObject.js"; +import { invert } from "./invert.js"; +import { mapKeys } from "./mapKeys.js"; +import { mapValues } from "./mapValues.js"; +import { merge } from "./merge.js"; +import { mergeWith } from "./mergeWith.js"; +import { omit } from "./omit.js"; +import { omitBy } from "./omitBy.js"; +import { pick } from "./pick.js"; +import { pickBy } from "./pickBy.js"; +import { sortKeys } from "./sortKeys.js"; +import { toCamelCaseKeys } from "./toCamelCaseKeys.js"; +import { toMerged } from "./toMerged.js"; +import { toSnakeCaseKeys } from "./toSnakeCaseKeys.js"; +export { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toMerged, toSnakeCaseKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/index.js b/node_modules/es-toolkit/dist/object/index.js new file mode 100644 index 0000000000000000000000000000000000000000..32aa6f336bd821db084463c4c655e75b77edb53e --- /dev/null +++ b/node_modules/es-toolkit/dist/object/index.js @@ -0,0 +1,37 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_clone = require("./clone.js"); +const require_cloneDeepWith = require("./cloneDeepWith.js"); +const require_cloneDeep = require("./cloneDeep.js"); +const require_findKey = require("./findKey.js"); +const require_flattenObject = require("./flattenObject.js"); +const require_invert = require("./invert.js"); +const require_mapKeys = require("./mapKeys.js"); +const require_mapValues = require("./mapValues.js"); +const require_merge = require("./merge.js"); +const require_mergeWith = require("./mergeWith.js"); +const require_omit = require("./omit.js"); +const require_omitBy = require("./omitBy.js"); +const require_pick = require("./pick.js"); +const require_pickBy = require("./pickBy.js"); +const require_sortKeys = require("./sortKeys.js"); +const require_toCamelCaseKeys = require("./toCamelCaseKeys.js"); +const require_toMerged = require("./toMerged.js"); +const require_toSnakeCaseKeys = require("./toSnakeCaseKeys.js"); +exports.clone = require_clone.clone; +exports.cloneDeep = require_cloneDeep.cloneDeep; +exports.cloneDeepWith = require_cloneDeepWith.cloneDeepWith; +exports.findKey = require_findKey.findKey; +exports.flattenObject = require_flattenObject.flattenObject; +exports.invert = require_invert.invert; +exports.mapKeys = require_mapKeys.mapKeys; +exports.mapValues = require_mapValues.mapValues; +exports.merge = require_merge.merge; +exports.mergeWith = require_mergeWith.mergeWith; +exports.omit = require_omit.omit; +exports.omitBy = require_omitBy.omitBy; +exports.pick = require_pick.pick; +exports.pickBy = require_pickBy.pickBy; +exports.sortKeys = require_sortKeys.sortKeys; +exports.toCamelCaseKeys = require_toCamelCaseKeys.toCamelCaseKeys; +exports.toMerged = require_toMerged.toMerged; +exports.toSnakeCaseKeys = require_toSnakeCaseKeys.toSnakeCaseKeys; diff --git a/node_modules/es-toolkit/dist/object/index.mjs b/node_modules/es-toolkit/dist/object/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f6bd6523bf38c5dfa4608b71a1f5993b4e3f12e3 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/index.mjs @@ -0,0 +1,19 @@ +import { clone } from "./clone.mjs"; +import { cloneDeepWith } from "./cloneDeepWith.mjs"; +import { cloneDeep } from "./cloneDeep.mjs"; +import { findKey } from "./findKey.mjs"; +import { flattenObject } from "./flattenObject.mjs"; +import { invert } from "./invert.mjs"; +import { mapKeys } from "./mapKeys.mjs"; +import { mapValues } from "./mapValues.mjs"; +import { merge } from "./merge.mjs"; +import { mergeWith } from "./mergeWith.mjs"; +import { omit } from "./omit.mjs"; +import { omitBy } from "./omitBy.mjs"; +import { pick } from "./pick.mjs"; +import { pickBy } from "./pickBy.mjs"; +import { sortKeys } from "./sortKeys.mjs"; +import { toCamelCaseKeys } from "./toCamelCaseKeys.mjs"; +import { toMerged } from "./toMerged.mjs"; +import { toSnakeCaseKeys } from "./toSnakeCaseKeys.mjs"; +export { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toMerged, toSnakeCaseKeys }; diff --git a/node_modules/es-toolkit/dist/object/invert.d.mts b/node_modules/es-toolkit/dist/object/invert.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ae4855f150c752be42316628eaf0f9939cf54845 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/invert.d.mts @@ -0,0 +1,22 @@ +//#region src/object/invert.d.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' } + */ +declare function invert(obj: Record): Record; +//#endregion +export { invert }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/invert.d.ts b/node_modules/es-toolkit/dist/object/invert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae4855f150c752be42316628eaf0f9939cf54845 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/invert.d.ts @@ -0,0 +1,22 @@ +//#region src/object/invert.d.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' } + */ +declare function invert(obj: Record): Record; +//#endregion +export { invert }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/invert.js b/node_modules/es-toolkit/dist/object/invert.js new file mode 100644 index 0000000000000000000000000000000000000000..1daa3f1872ba4bebe43162dff2c3b26d64a41dee --- /dev/null +++ b/node_modules/es-toolkit/dist/object/invert.js @@ -0,0 +1,31 @@ +//#region src/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) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = obj[key]; + result[value] = key; + } + return result; +} +//#endregion +exports.invert = invert; diff --git a/node_modules/es-toolkit/dist/object/invert.mjs b/node_modules/es-toolkit/dist/object/invert.mjs new file mode 100644 index 0000000000000000000000000000000000000000..46992c7df934e3c1cfdb18b8bb32888c3a4f1b00 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/invert.mjs @@ -0,0 +1,31 @@ +//#region src/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) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = obj[key]; + result[value] = key; + } + return result; +} +//#endregion +export { invert }; diff --git a/node_modules/es-toolkit/dist/object/mapKeys.d.mts b/node_modules/es-toolkit/dist/object/mapKeys.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b2105733471d675b233853cd1e683469652e6623 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mapKeys.d.mts @@ -0,0 +1,21 @@ +//#region src/object/mapKeys.d.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 K - 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. + * @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 } + */ +declare function mapKeys, K extends PropertyKey>(object: T, getNewKey: (value: T[keyof T], key: keyof T, object: T) => K): Record; +//#endregion +export { mapKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/mapKeys.d.ts b/node_modules/es-toolkit/dist/object/mapKeys.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b2105733471d675b233853cd1e683469652e6623 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mapKeys.d.ts @@ -0,0 +1,21 @@ +//#region src/object/mapKeys.d.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 K - 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. + * @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 } + */ +declare function mapKeys, K extends PropertyKey>(object: T, getNewKey: (value: T[keyof T], key: keyof T, object: T) => K): Record; +//#endregion +export { mapKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/mapKeys.js b/node_modules/es-toolkit/dist/object/mapKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..673b3be918153d4889479851951c58415fcb1948 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mapKeys.js @@ -0,0 +1,30 @@ +//#region src/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 K - 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. +* @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) { + const result = {}; + const keys = Object.keys(object); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = object[key]; + result[getNewKey(value, key, object)] = value; + } + return result; +} +//#endregion +exports.mapKeys = mapKeys; diff --git a/node_modules/es-toolkit/dist/object/mapKeys.mjs b/node_modules/es-toolkit/dist/object/mapKeys.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a97bba2b4612ffe0e571a73bfd003537f4d6283f --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mapKeys.mjs @@ -0,0 +1,30 @@ +//#region src/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 K - 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. +* @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) { + const result = {}; + const keys = Object.keys(object); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = object[key]; + result[getNewKey(value, key, object)] = value; + } + return result; +} +//#endregion +export { mapKeys }; diff --git a/node_modules/es-toolkit/dist/object/mapValues.d.mts b/node_modules/es-toolkit/dist/object/mapValues.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..af3bd64fe72d3b17812dd5994e81846be39f35b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mapValues.d.mts @@ -0,0 +1,22 @@ +//#region src/object/mapValues.d.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. + * @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 } + */ +declare function mapValues(object: T, getNewValue: (value: T[K], key: K, object: T) => V): Record; +//#endregion +export { mapValues }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/mapValues.d.ts b/node_modules/es-toolkit/dist/object/mapValues.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..af3bd64fe72d3b17812dd5994e81846be39f35b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mapValues.d.ts @@ -0,0 +1,22 @@ +//#region src/object/mapValues.d.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. + * @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 } + */ +declare function mapValues(object: T, getNewValue: (value: T[K], key: K, object: T) => V): Record; +//#endregion +export { mapValues }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/mapValues.js b/node_modules/es-toolkit/dist/object/mapValues.js new file mode 100644 index 0000000000000000000000000000000000000000..b4ff21cb6e52f68f9eebc5b8949fa6b3fe7d3703 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mapValues.js @@ -0,0 +1,31 @@ +//#region src/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. +* @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) { + const result = {}; + const keys = Object.keys(object); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = object[key]; + result[key] = getNewValue(value, key, object); + } + return result; +} +//#endregion +exports.mapValues = mapValues; diff --git a/node_modules/es-toolkit/dist/object/mapValues.mjs b/node_modules/es-toolkit/dist/object/mapValues.mjs new file mode 100644 index 0000000000000000000000000000000000000000..eab4bb605ecb56cadc96f4d2b96e6a21697a0a5f --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mapValues.mjs @@ -0,0 +1,31 @@ +//#region src/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. +* @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) { + const result = {}; + const keys = Object.keys(object); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = object[key]; + result[key] = getNewValue(value, key, object); + } + return result; +} +//#endregion +export { mapValues }; diff --git a/node_modules/es-toolkit/dist/object/merge.d.mts b/node_modules/es-toolkit/dist/object/merge.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..300547f988e72c1deb5f4edbf39777e5885e15db --- /dev/null +++ b/node_modules/es-toolkit/dist/object/merge.d.mts @@ -0,0 +1,44 @@ +//#region src/object/merge.d.ts +/** + * Merges the properties of the source object into the target object. + * + * This function performs a deep merge, meaning nested objects and arrays are merged recursively. + * If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged. + * If a property in the source object is undefined, it will not overwrite a defined property in the target object. + * + * Note that this function mutates the target object. + * + * @param target - The target object into which the source object properties will be merged. This object is modified in place. + * @param source - The source object whose properties will be merged into the target object. + * @returns The updated target object with properties from the source object merged in. + * + * @template T - Type of the target object. + * @template S - Type of the source object. + * + * @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, 2], 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] } + */ +declare function merge, S extends Record>(target: T, source: S): T & S; +//#endregion +export { merge }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/merge.d.ts b/node_modules/es-toolkit/dist/object/merge.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..300547f988e72c1deb5f4edbf39777e5885e15db --- /dev/null +++ b/node_modules/es-toolkit/dist/object/merge.d.ts @@ -0,0 +1,44 @@ +//#region src/object/merge.d.ts +/** + * Merges the properties of the source object into the target object. + * + * This function performs a deep merge, meaning nested objects and arrays are merged recursively. + * If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged. + * If a property in the source object is undefined, it will not overwrite a defined property in the target object. + * + * Note that this function mutates the target object. + * + * @param target - The target object into which the source object properties will be merged. This object is modified in place. + * @param source - The source object whose properties will be merged into the target object. + * @returns The updated target object with properties from the source object merged in. + * + * @template T - Type of the target object. + * @template S - Type of the source object. + * + * @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, 2], 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] } + */ +declare function merge, S extends Record>(target: T, source: S): T & S; +//#endregion +export { merge }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/merge.js b/node_modules/es-toolkit/dist/object/merge.js new file mode 100644 index 0000000000000000000000000000000000000000..6d670ce6cd8f5d84c0588ba8cb7742ea3c380b9b --- /dev/null +++ b/node_modules/es-toolkit/dist/object/merge.js @@ -0,0 +1,62 @@ +const require_isPlainObject = require("../predicate/isPlainObject.js"); +const require_isUnsafeProperty = require("../_internal/isUnsafeProperty.js"); +//#region src/object/merge.ts +/** +* Merges the properties of the source object into the target object. +* +* This function performs a deep merge, meaning nested objects and arrays are merged recursively. +* If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged. +* If a property in the source object is undefined, it will not overwrite a defined property in the target object. +* +* Note that this function mutates the target object. +* +* @param target - The target object into which the source object properties will be merged. This object is modified in place. +* @param source - The source object whose properties will be merged into the target object. +* @returns The updated target object with properties from the source object merged in. +* +* @template T - Type of the target object. +* @template S - Type of the source object. +* +* @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, 2], 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(target, source) { + const sourceKeys = Object.keys(source); + for (let i = 0; i < sourceKeys.length; i++) { + const key = sourceKeys[i]; + if (require_isUnsafeProperty.isUnsafeProperty(key)) continue; + const sourceValue = source[key]; + const targetValue = target[key]; + if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue); + else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue); + else if (require_isPlainObject.isPlainObject(sourceValue)) target[key] = merge({}, sourceValue); + else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue; + } + return target; +} +function isMergeableValue(value) { + return require_isPlainObject.isPlainObject(value) || Array.isArray(value); +} +//#endregion +exports.merge = merge; diff --git a/node_modules/es-toolkit/dist/object/merge.mjs b/node_modules/es-toolkit/dist/object/merge.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a69fa03ce361a42964879fa9bf06a6930e26ee20 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/merge.mjs @@ -0,0 +1,62 @@ +import { isPlainObject } from "../predicate/isPlainObject.mjs"; +import { isUnsafeProperty } from "../_internal/isUnsafeProperty.mjs"; +//#region src/object/merge.ts +/** +* Merges the properties of the source object into the target object. +* +* This function performs a deep merge, meaning nested objects and arrays are merged recursively. +* If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged. +* If a property in the source object is undefined, it will not overwrite a defined property in the target object. +* +* Note that this function mutates the target object. +* +* @param target - The target object into which the source object properties will be merged. This object is modified in place. +* @param source - The source object whose properties will be merged into the target object. +* @returns The updated target object with properties from the source object merged in. +* +* @template T - Type of the target object. +* @template S - Type of the source object. +* +* @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, 2], 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(target, source) { + const sourceKeys = Object.keys(source); + for (let i = 0; i < sourceKeys.length; i++) { + const key = sourceKeys[i]; + if (isUnsafeProperty(key)) continue; + const sourceValue = source[key]; + const targetValue = target[key]; + if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue); + else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue); + else if (isPlainObject(sourceValue)) target[key] = merge({}, sourceValue); + else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue; + } + return target; +} +function isMergeableValue(value) { + return isPlainObject(value) || Array.isArray(value); +} +//#endregion +export { merge }; diff --git a/node_modules/es-toolkit/dist/object/mergeWith.d.mts b/node_modules/es-toolkit/dist/object/mergeWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..61cdff95c0023379ad241fd8b6ed78cb4ca9f6d5 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mergeWith.d.mts @@ -0,0 +1,52 @@ +//#region src/object/mergeWith.d.ts +/** + * Merges the properties of the source object into the target object. + * + * You can provide a custom `merge` function to control how properties are merged. It 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: + * + * - If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged. + * - If a property in the source object is undefined, it will not overwrite a defined property in the target object. + * + * Note that this function mutates the target object. + * + * @param target - The target object into which the source object properties will be merged. This object is modified in place. + * @param source - The source object whose properties will be merged into the target object. + * @param merge - A custom merge function that defines how properties should be combined. It 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. + * + * @returns The updated target object with properties from the source object merged in. + * + * @template T - Type of the target object. + * @template S - Type of the source object. + * + * @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] }); + */ +declare function mergeWith, S extends Record>(target: T, source: S, merge: (targetValue: any, sourceValue: any, key: string, target: T, source: S) => any): T & S; +//#endregion +export { mergeWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/mergeWith.d.ts b/node_modules/es-toolkit/dist/object/mergeWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..61cdff95c0023379ad241fd8b6ed78cb4ca9f6d5 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mergeWith.d.ts @@ -0,0 +1,52 @@ +//#region src/object/mergeWith.d.ts +/** + * Merges the properties of the source object into the target object. + * + * You can provide a custom `merge` function to control how properties are merged. It 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: + * + * - If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged. + * - If a property in the source object is undefined, it will not overwrite a defined property in the target object. + * + * Note that this function mutates the target object. + * + * @param target - The target object into which the source object properties will be merged. This object is modified in place. + * @param source - The source object whose properties will be merged into the target object. + * @param merge - A custom merge function that defines how properties should be combined. It 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. + * + * @returns The updated target object with properties from the source object merged in. + * + * @template T - Type of the target object. + * @template S - Type of the source object. + * + * @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] }); + */ +declare function mergeWith, S extends Record>(target: T, source: S, merge: (targetValue: any, sourceValue: any, key: string, target: T, source: S) => any): T & S; +//#endregion +export { mergeWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/mergeWith.js b/node_modules/es-toolkit/dist/object/mergeWith.js new file mode 100644 index 0000000000000000000000000000000000000000..e26e30d3cd6954ca3be0667a20e80d5ceff72562 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mergeWith.js @@ -0,0 +1,70 @@ +const require_isPlainObject = require("../predicate/isPlainObject.js"); +const require_isUnsafeProperty = require("../_internal/isUnsafeProperty.js"); +//#region src/object/mergeWith.ts +/** +* Merges the properties of the source object into the target object. +* +* You can provide a custom `merge` function to control how properties are merged. It 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: +* +* - If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged. +* - If a property in the source object is undefined, it will not overwrite a defined property in the target object. +* +* Note that this function mutates the target object. +* +* @param target - The target object into which the source object properties will be merged. This object is modified in place. +* @param source - The source object whose properties will be merged into the target object. +* @param merge - A custom merge function that defines how properties should be combined. It 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. +* +* @returns The updated target object with properties from the source object merged in. +* +* @template T - Type of the target object. +* @template S - Type of the source object. +* +* @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(target, source, merge) { + const sourceKeys = Object.keys(source); + for (let i = 0; i < sourceKeys.length; i++) { + const key = sourceKeys[i]; + if (require_isUnsafeProperty.isUnsafeProperty(key)) continue; + const sourceValue = source[key]; + const targetValue = target[key]; + const merged = merge(targetValue, sourceValue, key, target, source); + if (merged !== void 0) target[key] = merged; + else if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge); + else target[key] = mergeWith([], sourceValue, merge); + else if (require_isPlainObject.isPlainObject(sourceValue)) if (require_isPlainObject.isPlainObject(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge); + else target[key] = mergeWith({}, sourceValue, merge); + 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/object/mergeWith.mjs b/node_modules/es-toolkit/dist/object/mergeWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..242c6b4e557b656f68c95d0d347298abc0cdc056 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/mergeWith.mjs @@ -0,0 +1,70 @@ +import { isPlainObject } from "../predicate/isPlainObject.mjs"; +import { isUnsafeProperty } from "../_internal/isUnsafeProperty.mjs"; +//#region src/object/mergeWith.ts +/** +* Merges the properties of the source object into the target object. +* +* You can provide a custom `merge` function to control how properties are merged. It 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: +* +* - If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged. +* - If a property in the source object is undefined, it will not overwrite a defined property in the target object. +* +* Note that this function mutates the target object. +* +* @param target - The target object into which the source object properties will be merged. This object is modified in place. +* @param source - The source object whose properties will be merged into the target object. +* @param merge - A custom merge function that defines how properties should be combined. It 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. +* +* @returns The updated target object with properties from the source object merged in. +* +* @template T - Type of the target object. +* @template S - Type of the source object. +* +* @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(target, source, merge) { + const sourceKeys = Object.keys(source); + for (let i = 0; i < sourceKeys.length; i++) { + const key = sourceKeys[i]; + if (isUnsafeProperty(key)) continue; + const sourceValue = source[key]; + const targetValue = target[key]; + const merged = merge(targetValue, sourceValue, key, target, source); + if (merged !== void 0) target[key] = merged; + else if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge); + else target[key] = mergeWith([], sourceValue, merge); + else if (isPlainObject(sourceValue)) if (isPlainObject(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge); + else target[key] = mergeWith({}, sourceValue, merge); + else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue; + } + return target; +} +//#endregion +export { mergeWith }; diff --git a/node_modules/es-toolkit/dist/object/omit.d.mts b/node_modules/es-toolkit/dist/object/omit.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d398c9f2cc0c8a97e2b7dcf6ec38616e30e67716 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/omit.d.mts @@ -0,0 +1,21 @@ +//#region src/object/omit.d.ts +/** + * Creates a new object with specified keys omitted. + * + * This function takes an object and an array of keys, and returns a new object that + * excludes the properties corresponding to the specified keys. + * + * @template T - The type of object. + * @template K - The type of keys in object. + * @param obj - The object to omit keys from. + * @param keys - An array of keys to be omitted from the object. + * @returns A new object with the specified keys omitted. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * const result = omit(obj, ['b', 'c']); + * // result will be { a: 1 } + */ +declare function omit, K extends keyof T>(obj: T, keys: readonly K[]): Omit; +//#endregion +export { omit }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/omit.d.ts b/node_modules/es-toolkit/dist/object/omit.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d398c9f2cc0c8a97e2b7dcf6ec38616e30e67716 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/omit.d.ts @@ -0,0 +1,21 @@ +//#region src/object/omit.d.ts +/** + * Creates a new object with specified keys omitted. + * + * This function takes an object and an array of keys, and returns a new object that + * excludes the properties corresponding to the specified keys. + * + * @template T - The type of object. + * @template K - The type of keys in object. + * @param obj - The object to omit keys from. + * @param keys - An array of keys to be omitted from the object. + * @returns A new object with the specified keys omitted. + * + * @example + * const obj = { a: 1, b: 2, c: 3 }; + * const result = omit(obj, ['b', 'c']); + * // result will be { a: 1 } + */ +declare function omit, K extends keyof T>(obj: T, keys: readonly K[]): Omit; +//#endregion +export { omit }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/omit.js b/node_modules/es-toolkit/dist/object/omit.js new file mode 100644 index 0000000000000000000000000000000000000000..ffa15ace5cae92c198237c512b565c8da61b8ebd --- /dev/null +++ b/node_modules/es-toolkit/dist/object/omit.js @@ -0,0 +1,28 @@ +//#region src/object/omit.ts +/** +* Creates a new object with specified keys omitted. +* +* This function takes an object and an array of keys, and returns a new object that +* excludes the properties corresponding to the specified keys. +* +* @template T - The type of object. +* @template K - The type of keys in object. +* @param obj - The object to omit keys from. +* @param keys - An array of keys to be omitted from the object. +* @returns A new object with the specified keys omitted. +* +* @example +* const obj = { a: 1, b: 2, c: 3 }; +* const result = omit(obj, ['b', 'c']); +* // result will be { a: 1 } +*/ +function omit(obj, keys) { + const result = { ...obj }; + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + delete result[key]; + } + return result; +} +//#endregion +exports.omit = omit; diff --git a/node_modules/es-toolkit/dist/object/omit.mjs b/node_modules/es-toolkit/dist/object/omit.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4468d4f7bd589a28bbe50a5addf3f4abf385c967 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/omit.mjs @@ -0,0 +1,28 @@ +//#region src/object/omit.ts +/** +* Creates a new object with specified keys omitted. +* +* This function takes an object and an array of keys, and returns a new object that +* excludes the properties corresponding to the specified keys. +* +* @template T - The type of object. +* @template K - The type of keys in object. +* @param obj - The object to omit keys from. +* @param keys - An array of keys to be omitted from the object. +* @returns A new object with the specified keys omitted. +* +* @example +* const obj = { a: 1, b: 2, c: 3 }; +* const result = omit(obj, ['b', 'c']); +* // result will be { a: 1 } +*/ +function omit(obj, keys) { + const result = { ...obj }; + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + delete result[key]; + } + return result; +} +//#endregion +export { omit }; diff --git a/node_modules/es-toolkit/dist/object/omitBy.d.mts b/node_modules/es-toolkit/dist/object/omitBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..07d63550e7d31abac84d91fcc5916a441a7fa6b5 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/omitBy.d.mts @@ -0,0 +1,23 @@ +//#region src/object/omitBy.d.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 key and value as arguments and returns `true` + * if the property should be omitted, and `false` otherwise. + * @returns A new object with the properties that do not satisfy the predicate function. + * + * @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 } + */ +declare function omitBy>(obj: T, shouldOmit: (value: T[keyof T], key: keyof T) => boolean): Partial; +//#endregion +export { omitBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/omitBy.d.ts b/node_modules/es-toolkit/dist/object/omitBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..07d63550e7d31abac84d91fcc5916a441a7fa6b5 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/omitBy.d.ts @@ -0,0 +1,23 @@ +//#region src/object/omitBy.d.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 key and value as arguments and returns `true` + * if the property should be omitted, and `false` otherwise. + * @returns A new object with the properties that do not satisfy the predicate function. + * + * @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 } + */ +declare function omitBy>(obj: T, shouldOmit: (value: T[keyof T], key: keyof T) => boolean): Partial; +//#endregion +export { omitBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/omitBy.js b/node_modules/es-toolkit/dist/object/omitBy.js new file mode 100644 index 0000000000000000000000000000000000000000..c6d563940d15909805ddf3ec3fa0bdcfec66b990 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/omitBy.js @@ -0,0 +1,32 @@ +//#region src/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 key and value as arguments and returns `true` +* if the property should be omitted, and `false` otherwise. +* @returns A new object with the properties that do not satisfy the predicate function. +* +* @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(obj, shouldOmit) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = obj[key]; + if (!shouldOmit(value, key)) result[key] = value; + } + return result; +} +//#endregion +exports.omitBy = omitBy; diff --git a/node_modules/es-toolkit/dist/object/omitBy.mjs b/node_modules/es-toolkit/dist/object/omitBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e51f46a849f6204690278d6cf6bb10014b9b0b93 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/omitBy.mjs @@ -0,0 +1,32 @@ +//#region src/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 key and value as arguments and returns `true` +* if the property should be omitted, and `false` otherwise. +* @returns A new object with the properties that do not satisfy the predicate function. +* +* @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(obj, shouldOmit) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = obj[key]; + if (!shouldOmit(value, key)) result[key] = value; + } + return result; +} +//#endregion +export { omitBy }; diff --git a/node_modules/es-toolkit/dist/object/pick.d.mts b/node_modules/es-toolkit/dist/object/pick.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c28f7c9776297206d271d9b1a2c181343d29b4eb --- /dev/null +++ b/node_modules/es-toolkit/dist/object/pick.d.mts @@ -0,0 +1,21 @@ +//#region src/object/pick.d.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 K - The type of keys in object. + * @param obj - The object to pick keys from. + * @param keys - 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, K extends keyof T>(obj: T, keys: readonly K[]): Pick; +//#endregion +export { pick }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/pick.d.ts b/node_modules/es-toolkit/dist/object/pick.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c28f7c9776297206d271d9b1a2c181343d29b4eb --- /dev/null +++ b/node_modules/es-toolkit/dist/object/pick.d.ts @@ -0,0 +1,21 @@ +//#region src/object/pick.d.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 K - The type of keys in object. + * @param obj - The object to pick keys from. + * @param keys - 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, K extends keyof T>(obj: T, keys: readonly K[]): Pick; +//#endregion +export { pick }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/pick.js b/node_modules/es-toolkit/dist/object/pick.js new file mode 100644 index 0000000000000000000000000000000000000000..f3581e7a3ce07e84ea3e72fcaaa58bda6f9a6243 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/pick.js @@ -0,0 +1,28 @@ +//#region src/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 K - The type of keys in object. +* @param obj - The object to pick keys from. +* @param keys - 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 } +*/ +function pick(obj, keys) { + const result = {}; + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (Object.hasOwn(obj, key)) result[key] = obj[key]; + } + return result; +} +//#endregion +exports.pick = pick; diff --git a/node_modules/es-toolkit/dist/object/pick.mjs b/node_modules/es-toolkit/dist/object/pick.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e3cbc0f97e98aced53fdd1ec522f9b58bd577b5c --- /dev/null +++ b/node_modules/es-toolkit/dist/object/pick.mjs @@ -0,0 +1,28 @@ +//#region src/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 K - The type of keys in object. +* @param obj - The object to pick keys from. +* @param keys - 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 } +*/ +function pick(obj, keys) { + const result = {}; + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (Object.hasOwn(obj, key)) result[key] = obj[key]; + } + return result; +} +//#endregion +export { pick }; diff --git a/node_modules/es-toolkit/dist/object/pickBy.d.mts b/node_modules/es-toolkit/dist/object/pickBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e315f302d57d8bc4969aafb1dbe97feca2551cad --- /dev/null +++ b/node_modules/es-toolkit/dist/object/pickBy.d.mts @@ -0,0 +1,23 @@ +//#region src/object/pickBy.d.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' } + */ +declare function pickBy>(obj: T, shouldPick: (value: T[keyof T], key: keyof T) => boolean): Partial; +//#endregion +export { pickBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/pickBy.d.ts b/node_modules/es-toolkit/dist/object/pickBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e315f302d57d8bc4969aafb1dbe97feca2551cad --- /dev/null +++ b/node_modules/es-toolkit/dist/object/pickBy.d.ts @@ -0,0 +1,23 @@ +//#region src/object/pickBy.d.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' } + */ +declare function pickBy>(obj: T, shouldPick: (value: T[keyof T], key: keyof T) => boolean): Partial; +//#endregion +export { pickBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/pickBy.js b/node_modules/es-toolkit/dist/object/pickBy.js new file mode 100644 index 0000000000000000000000000000000000000000..0aeb8c489b33a15499b033995f56f1ee2533173c --- /dev/null +++ b/node_modules/es-toolkit/dist/object/pickBy.js @@ -0,0 +1,32 @@ +//#region src/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) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = obj[key]; + if (shouldPick(value, key)) result[key] = value; + } + return result; +} +//#endregion +exports.pickBy = pickBy; diff --git a/node_modules/es-toolkit/dist/object/pickBy.mjs b/node_modules/es-toolkit/dist/object/pickBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1248204d0cee943bd51d9bc1ef148ffcf44946fe --- /dev/null +++ b/node_modules/es-toolkit/dist/object/pickBy.mjs @@ -0,0 +1,32 @@ +//#region src/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) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = obj[key]; + if (shouldPick(value, key)) result[key] = value; + } + return result; +} +//#endregion +export { pickBy }; diff --git a/node_modules/es-toolkit/dist/object/sortKeys.d.mts b/node_modules/es-toolkit/dist/object/sortKeys.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b0ddc1c830ebd4ffac912aadfba28a1c53b7e353 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/sortKeys.d.mts @@ -0,0 +1,22 @@ +//#region src/object/sortKeys.d.ts +/** + * Creates a new object with the keys sorted. + * + * The keys are sorted alphabetically by default, but a custom compare function can be provided. + * + * @template T - The type of the object. + * @param object - The object to sort keys from. + * @param [compareKeys] - A custom compare function for sorting keys. + * @returns A new object with the keys sorted. + * + * @example + * sortKeys({ b: 2, a: 1, c: 3 }); + * // => { a: 1, b: 2, c: 3 } + * + * @example + * sortKeys({ b: 2, a: 1, c: 3 }, (a, b) => b.localeCompare(a)); + * // => { c: 3, b: 2, a: 1 } + */ +declare function sortKeys>(object: T, compareKeys?: (a: string, b: string) => number): T; +//#endregion +export { sortKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/sortKeys.d.ts b/node_modules/es-toolkit/dist/object/sortKeys.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0ddc1c830ebd4ffac912aadfba28a1c53b7e353 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/sortKeys.d.ts @@ -0,0 +1,22 @@ +//#region src/object/sortKeys.d.ts +/** + * Creates a new object with the keys sorted. + * + * The keys are sorted alphabetically by default, but a custom compare function can be provided. + * + * @template T - The type of the object. + * @param object - The object to sort keys from. + * @param [compareKeys] - A custom compare function for sorting keys. + * @returns A new object with the keys sorted. + * + * @example + * sortKeys({ b: 2, a: 1, c: 3 }); + * // => { a: 1, b: 2, c: 3 } + * + * @example + * sortKeys({ b: 2, a: 1, c: 3 }, (a, b) => b.localeCompare(a)); + * // => { c: 3, b: 2, a: 1 } + */ +declare function sortKeys>(object: T, compareKeys?: (a: string, b: string) => number): T; +//#endregion +export { sortKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/sortKeys.js b/node_modules/es-toolkit/dist/object/sortKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..14fc455cf0fdff636eac49c48ca311614088a129 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/sortKeys.js @@ -0,0 +1,30 @@ +//#region src/object/sortKeys.ts +/** +* Creates a new object with the keys sorted. +* +* The keys are sorted alphabetically by default, but a custom compare function can be provided. +* +* @template T - The type of the object. +* @param object - The object to sort keys from. +* @param [compareKeys] - A custom compare function for sorting keys. +* @returns A new object with the keys sorted. +* +* @example +* sortKeys({ b: 2, a: 1, c: 3 }); +* // => { a: 1, b: 2, c: 3 } +* +* @example +* sortKeys({ b: 2, a: 1, c: 3 }, (a, b) => b.localeCompare(a)); +* // => { c: 3, b: 2, a: 1 } +*/ +function sortKeys(object, compareKeys) { + const sortedKeys = Object.keys(object).sort(compareKeys); + const result = {}; + for (let i = 0; i < sortedKeys.length; i++) { + const key = sortedKeys[i]; + result[key] = object[key]; + } + return result; +} +//#endregion +exports.sortKeys = sortKeys; diff --git a/node_modules/es-toolkit/dist/object/sortKeys.mjs b/node_modules/es-toolkit/dist/object/sortKeys.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f352a741b0d8c36cbbdba1f8c7708e032adfe928 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/sortKeys.mjs @@ -0,0 +1,30 @@ +//#region src/object/sortKeys.ts +/** +* Creates a new object with the keys sorted. +* +* The keys are sorted alphabetically by default, but a custom compare function can be provided. +* +* @template T - The type of the object. +* @param object - The object to sort keys from. +* @param [compareKeys] - A custom compare function for sorting keys. +* @returns A new object with the keys sorted. +* +* @example +* sortKeys({ b: 2, a: 1, c: 3 }); +* // => { a: 1, b: 2, c: 3 } +* +* @example +* sortKeys({ b: 2, a: 1, c: 3 }, (a, b) => b.localeCompare(a)); +* // => { c: 3, b: 2, a: 1 } +*/ +function sortKeys(object, compareKeys) { + const sortedKeys = Object.keys(object).sort(compareKeys); + const result = {}; + for (let i = 0; i < sortedKeys.length; i++) { + const key = sortedKeys[i]; + result[key] = object[key]; + } + return result; +} +//#endregion +export { sortKeys }; diff --git a/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.mts b/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d3181d6692d83e97e4dc7070c5f49121d50892bb --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.mts @@ -0,0 +1,56 @@ +//#region src/object/toCamelCaseKeys.d.ts +type SnakeToCamel = S extends `${infer H}_${infer T}` ? `${Lowercase}${Capitalize>}` : Lowercase; +type PascalToCamel = S extends `${infer F}${infer R}` ? `${Lowercase}${R}` : S; +/** If it's snake_case, apply the snake_case rule; for uppercase keys, lowercase the entire string; otherwise, just lowercase the first letter (including PascalCase → camelCase). */ +type AnyToCamel = S extends `${string}_${string}` ? SnakeToCamel : S extends Uppercase ? Lowercase : PascalToCamel; +type NonPlainObject = Date | RegExp | Map | Set | WeakMap | WeakSet | Promise | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis; +type ToCamelCaseKeys = T extends NonPlainObject ? T : T extends any[] ? Array> : T extends Record ? { [K in keyof T as AnyToCamel>]: ToCamelCaseKeys } : T; +/** + * Creates a new object composed of the properties with keys converted to camelCase. + * + * This function takes an object and returns a new object that includes the same properties, + * but with all keys converted to camelCase format. + * + * @template T - The type of object. + * @param obj - The object to convert keys from. + * @returns A new object with all keys converted to camelCase. + * + * @example + * // Example with objects + * const obj = { user_id: 1, first_name: 'John' }; + * const result = toCamelCaseKeys(obj); + * // result will be { userId: 1, firstName: 'John' } + * + * // Example with arrays of objects + * const arr = [ + * { user_id: 1, first_name: 'John' }, + * { user_id: 2, first_name: 'Jane' } + * ]; + * const arrResult = toCamelCaseKeys(arr); + * // arrResult will be [{ userId: 1, firstName: 'John' }, { userId: 2, firstName: 'Jane' }] + * + * // Example with nested objects + * const nested = { + * user_data: { + * user_id: 1, + * user_address: { + * street_name: 'Main St', + * zip_code: '12345' + * } + * } + * }; + * const nestedResult = toCamelCaseKeys(nested); + * // nestedResult will be: + * // { + * // userData: { + * // userId: 1, + * // userAddress: { + * // streetName: 'Main St', + * // zipCode: '12345' + * // } + * // } + * // } + */ +declare function toCamelCaseKeys(obj: T): ToCamelCaseKeys; +//#endregion +export { toCamelCaseKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.ts b/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3181d6692d83e97e4dc7070c5f49121d50892bb --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toCamelCaseKeys.d.ts @@ -0,0 +1,56 @@ +//#region src/object/toCamelCaseKeys.d.ts +type SnakeToCamel = S extends `${infer H}_${infer T}` ? `${Lowercase}${Capitalize>}` : Lowercase; +type PascalToCamel = S extends `${infer F}${infer R}` ? `${Lowercase}${R}` : S; +/** If it's snake_case, apply the snake_case rule; for uppercase keys, lowercase the entire string; otherwise, just lowercase the first letter (including PascalCase → camelCase). */ +type AnyToCamel = S extends `${string}_${string}` ? SnakeToCamel : S extends Uppercase ? Lowercase : PascalToCamel; +type NonPlainObject = Date | RegExp | Map | Set | WeakMap | WeakSet | Promise | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis; +type ToCamelCaseKeys = T extends NonPlainObject ? T : T extends any[] ? Array> : T extends Record ? { [K in keyof T as AnyToCamel>]: ToCamelCaseKeys } : T; +/** + * Creates a new object composed of the properties with keys converted to camelCase. + * + * This function takes an object and returns a new object that includes the same properties, + * but with all keys converted to camelCase format. + * + * @template T - The type of object. + * @param obj - The object to convert keys from. + * @returns A new object with all keys converted to camelCase. + * + * @example + * // Example with objects + * const obj = { user_id: 1, first_name: 'John' }; + * const result = toCamelCaseKeys(obj); + * // result will be { userId: 1, firstName: 'John' } + * + * // Example with arrays of objects + * const arr = [ + * { user_id: 1, first_name: 'John' }, + * { user_id: 2, first_name: 'Jane' } + * ]; + * const arrResult = toCamelCaseKeys(arr); + * // arrResult will be [{ userId: 1, firstName: 'John' }, { userId: 2, firstName: 'Jane' }] + * + * // Example with nested objects + * const nested = { + * user_data: { + * user_id: 1, + * user_address: { + * street_name: 'Main St', + * zip_code: '12345' + * } + * } + * }; + * const nestedResult = toCamelCaseKeys(nested); + * // nestedResult will be: + * // { + * // userData: { + * // userId: 1, + * // userAddress: { + * // streetName: 'Main St', + * // zipCode: '12345' + * // } + * // } + * // } + */ +declare function toCamelCaseKeys(obj: T): ToCamelCaseKeys; +//#endregion +export { toCamelCaseKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/toCamelCaseKeys.js b/node_modules/es-toolkit/dist/object/toCamelCaseKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..538b0cbaa9d88aec77aceedc52dfb885b3dff800 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toCamelCaseKeys.js @@ -0,0 +1,66 @@ +const require_isPlainObject = require("../predicate/isPlainObject.js"); +const require_isArray = require("../compat/predicate/isArray.js"); +const require_camelCase = require("../string/camelCase.js"); +//#region src/object/toCamelCaseKeys.ts +/** +* Creates a new object composed of the properties with keys converted to camelCase. +* +* This function takes an object and returns a new object that includes the same properties, +* but with all keys converted to camelCase format. +* +* @template T - The type of object. +* @param obj - The object to convert keys from. +* @returns A new object with all keys converted to camelCase. +* +* @example +* // Example with objects +* const obj = { user_id: 1, first_name: 'John' }; +* const result = toCamelCaseKeys(obj); +* // result will be { userId: 1, firstName: 'John' } +* +* // Example with arrays of objects +* const arr = [ +* { user_id: 1, first_name: 'John' }, +* { user_id: 2, first_name: 'Jane' } +* ]; +* const arrResult = toCamelCaseKeys(arr); +* // arrResult will be [{ userId: 1, firstName: 'John' }, { userId: 2, firstName: 'Jane' }] +* +* // Example with nested objects +* const nested = { +* user_data: { +* user_id: 1, +* user_address: { +* street_name: 'Main St', +* zip_code: '12345' +* } +* } +* }; +* const nestedResult = toCamelCaseKeys(nested); +* // nestedResult will be: +* // { +* // userData: { +* // userId: 1, +* // userAddress: { +* // streetName: 'Main St', +* // zipCode: '12345' +* // } +* // } +* // } +*/ +function toCamelCaseKeys(obj) { + if (require_isArray.isArray(obj)) return obj.map((item) => toCamelCaseKeys(item)); + if (require_isPlainObject.isPlainObject(obj)) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const camelKey = require_camelCase.camelCase(key); + result[camelKey] = toCamelCaseKeys(obj[key]); + } + return result; + } + return obj; +} +//#endregion +exports.toCamelCaseKeys = toCamelCaseKeys; diff --git a/node_modules/es-toolkit/dist/object/toCamelCaseKeys.mjs b/node_modules/es-toolkit/dist/object/toCamelCaseKeys.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c820c06bc2d4e7d5d6c5df58642cd085522b626e --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toCamelCaseKeys.mjs @@ -0,0 +1,66 @@ +import { isPlainObject } from "../predicate/isPlainObject.mjs"; +import { isArray } from "../compat/predicate/isArray.mjs"; +import { camelCase } from "../string/camelCase.mjs"; +//#region src/object/toCamelCaseKeys.ts +/** +* Creates a new object composed of the properties with keys converted to camelCase. +* +* This function takes an object and returns a new object that includes the same properties, +* but with all keys converted to camelCase format. +* +* @template T - The type of object. +* @param obj - The object to convert keys from. +* @returns A new object with all keys converted to camelCase. +* +* @example +* // Example with objects +* const obj = { user_id: 1, first_name: 'John' }; +* const result = toCamelCaseKeys(obj); +* // result will be { userId: 1, firstName: 'John' } +* +* // Example with arrays of objects +* const arr = [ +* { user_id: 1, first_name: 'John' }, +* { user_id: 2, first_name: 'Jane' } +* ]; +* const arrResult = toCamelCaseKeys(arr); +* // arrResult will be [{ userId: 1, firstName: 'John' }, { userId: 2, firstName: 'Jane' }] +* +* // Example with nested objects +* const nested = { +* user_data: { +* user_id: 1, +* user_address: { +* street_name: 'Main St', +* zip_code: '12345' +* } +* } +* }; +* const nestedResult = toCamelCaseKeys(nested); +* // nestedResult will be: +* // { +* // userData: { +* // userId: 1, +* // userAddress: { +* // streetName: 'Main St', +* // zipCode: '12345' +* // } +* // } +* // } +*/ +function toCamelCaseKeys(obj) { + if (isArray(obj)) return obj.map((item) => toCamelCaseKeys(item)); + if (isPlainObject(obj)) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const camelKey = camelCase(key); + result[camelKey] = toCamelCaseKeys(obj[key]); + } + return result; + } + return obj; +} +//#endregion +export { toCamelCaseKeys }; diff --git a/node_modules/es-toolkit/dist/object/toMerged.d.mts b/node_modules/es-toolkit/dist/object/toMerged.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..48b25129471fa58a6864904d68f48f3bc86cae42 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toMerged.d.mts @@ -0,0 +1,46 @@ +//#region src/object/toMerged.d.ts +/** + * Merges the properties of the source object into a deep clone of the target object. + * Unlike `merge`, This function does not modify the original target object. + * + * This function performs a deep merge, meaning nested objects and arrays are merged recursively. + * + * - 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. + * + * Note that this function does not mutate the target object. + * + * @param target - The target object to be cloned and merged into. This object is not modified directly. + * @param source - The source object whose properties will be merged into the cloned target object. + * @returns A new object with properties from the source object merged into a deep clone of the target object. + * + * @template T - Type of the target object. + * @template S - Type of the source object. + * + * @example + * const target = { a: 1, b: { x: 1, y: 2 } }; + * const source = { b: { y: 3, z: 4 }, c: 5 }; + * + * const result = toMerged(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 = toMerged(target, source); + * console.log(result); + * // Output: { a: [3, 2], b: { x: 1, y: 2 } } + * + * @example + * const target = { a: null }; + * const source = { a: [1, 2, 3] }; + * + * const result = toMerged(target, source); + * console.log(result); + * // Output: { a: [1, 2, 3] } + */ +declare function toMerged, S extends Record>(target: T, source: S): T & S; +//#endregion +export { toMerged }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/toMerged.d.ts b/node_modules/es-toolkit/dist/object/toMerged.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..48b25129471fa58a6864904d68f48f3bc86cae42 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toMerged.d.ts @@ -0,0 +1,46 @@ +//#region src/object/toMerged.d.ts +/** + * Merges the properties of the source object into a deep clone of the target object. + * Unlike `merge`, This function does not modify the original target object. + * + * This function performs a deep merge, meaning nested objects and arrays are merged recursively. + * + * - 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. + * + * Note that this function does not mutate the target object. + * + * @param target - The target object to be cloned and merged into. This object is not modified directly. + * @param source - The source object whose properties will be merged into the cloned target object. + * @returns A new object with properties from the source object merged into a deep clone of the target object. + * + * @template T - Type of the target object. + * @template S - Type of the source object. + * + * @example + * const target = { a: 1, b: { x: 1, y: 2 } }; + * const source = { b: { y: 3, z: 4 }, c: 5 }; + * + * const result = toMerged(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 = toMerged(target, source); + * console.log(result); + * // Output: { a: [3, 2], b: { x: 1, y: 2 } } + * + * @example + * const target = { a: null }; + * const source = { a: [1, 2, 3] }; + * + * const result = toMerged(target, source); + * console.log(result); + * // Output: { a: [1, 2, 3] } + */ +declare function toMerged, S extends Record>(target: T, source: S): T & S; +//#endregion +export { toMerged }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/toMerged.js b/node_modules/es-toolkit/dist/object/toMerged.js new file mode 100644 index 0000000000000000000000000000000000000000..2de299a00fb4769ac5ab60bfa7faf96a0a723c7a --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toMerged.js @@ -0,0 +1,57 @@ +const require_clone = require("./clone.js"); +const require_cloneDeep = require("./cloneDeep.js"); +const require_isPlainObject = require("../predicate/isPlainObject.js"); +const require_mergeWith = require("./mergeWith.js"); +//#region src/object/toMerged.ts +/** +* Merges the properties of the source object into a deep clone of the target object. +* Unlike `merge`, This function does not modify the original target object. +* +* This function performs a deep merge, meaning nested objects and arrays are merged recursively. +* +* - 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. +* +* Note that this function does not mutate the target object. +* +* @param target - The target object to be cloned and merged into. This object is not modified directly. +* @param source - The source object whose properties will be merged into the cloned target object. +* @returns A new object with properties from the source object merged into a deep clone of the target object. +* +* @template T - Type of the target object. +* @template S - Type of the source object. +* +* @example +* const target = { a: 1, b: { x: 1, y: 2 } }; +* const source = { b: { y: 3, z: 4 }, c: 5 }; +* +* const result = toMerged(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 = toMerged(target, source); +* console.log(result); +* // Output: { a: [3, 2], b: { x: 1, y: 2 } } +* +* @example +* const target = { a: null }; +* const source = { a: [1, 2, 3] }; +* +* const result = toMerged(target, source); +* console.log(result); +* // Output: { a: [1, 2, 3] } +*/ +function toMerged(target, source) { + return require_mergeWith.mergeWith(require_cloneDeep.cloneDeep(target), source, function mergeRecursively(targetValue, sourceValue) { + if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) return require_mergeWith.mergeWith(require_clone.clone(targetValue), sourceValue, mergeRecursively); + else return require_mergeWith.mergeWith([], sourceValue, mergeRecursively); + else if (require_isPlainObject.isPlainObject(sourceValue)) if (require_isPlainObject.isPlainObject(targetValue)) return require_mergeWith.mergeWith(require_clone.clone(targetValue), sourceValue, mergeRecursively); + else return require_mergeWith.mergeWith({}, sourceValue, mergeRecursively); + }); +} +//#endregion +exports.toMerged = toMerged; diff --git a/node_modules/es-toolkit/dist/object/toMerged.mjs b/node_modules/es-toolkit/dist/object/toMerged.mjs new file mode 100644 index 0000000000000000000000000000000000000000..12443b33dc119698d99483c8017fb313344e80d5 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toMerged.mjs @@ -0,0 +1,57 @@ +import { clone } from "./clone.mjs"; +import { cloneDeep } from "./cloneDeep.mjs"; +import { isPlainObject } from "../predicate/isPlainObject.mjs"; +import { mergeWith } from "./mergeWith.mjs"; +//#region src/object/toMerged.ts +/** +* Merges the properties of the source object into a deep clone of the target object. +* Unlike `merge`, This function does not modify the original target object. +* +* This function performs a deep merge, meaning nested objects and arrays are merged recursively. +* +* - 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. +* +* Note that this function does not mutate the target object. +* +* @param target - The target object to be cloned and merged into. This object is not modified directly. +* @param source - The source object whose properties will be merged into the cloned target object. +* @returns A new object with properties from the source object merged into a deep clone of the target object. +* +* @template T - Type of the target object. +* @template S - Type of the source object. +* +* @example +* const target = { a: 1, b: { x: 1, y: 2 } }; +* const source = { b: { y: 3, z: 4 }, c: 5 }; +* +* const result = toMerged(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 = toMerged(target, source); +* console.log(result); +* // Output: { a: [3, 2], b: { x: 1, y: 2 } } +* +* @example +* const target = { a: null }; +* const source = { a: [1, 2, 3] }; +* +* const result = toMerged(target, source); +* console.log(result); +* // Output: { a: [1, 2, 3] } +*/ +function toMerged(target, source) { + return mergeWith(cloneDeep(target), source, function mergeRecursively(targetValue, sourceValue) { + if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) return mergeWith(clone(targetValue), sourceValue, mergeRecursively); + else return mergeWith([], sourceValue, mergeRecursively); + else if (isPlainObject(sourceValue)) if (isPlainObject(targetValue)) return mergeWith(clone(targetValue), sourceValue, mergeRecursively); + else return mergeWith({}, sourceValue, mergeRecursively); + }); +} +//#endregion +export { toMerged }; diff --git a/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.mts b/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..68f6a1b0b9db6c8b5bf29dcc598f92509579a8d8 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.mts @@ -0,0 +1,53 @@ +//#region src/object/toSnakeCaseKeys.d.ts +type SnakeCase = S extends Uppercase ? Lowercase : S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize ? `${Lowercase}${SnakeCase}` : `${Lowercase}_${SnakeCase>}` : Lowercase; +type NonPlainObject = Date | RegExp | Map | Set | WeakMap | WeakSet | Promise | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis; +type ToSnakeCaseKeys = T extends NonPlainObject ? T : T extends any[] ? Array> : T extends Record ? { [K in keyof T as SnakeCase]: ToSnakeCaseKeys } : T; +/** + * Creates a new object composed of the properties with keys converted to snake_case. + * + * This function takes an object and returns a new object that includes the same properties, + * but with all keys converted to snake_case format. + * + * @template T - The type of object. + * @param obj - The object to convert keys from. + * @returns A new object with all keys converted to snake_case. + * + * @example + * // Example with objects + * const obj = { userId: 1, firstName: 'John' }; + * const result = toSnakeCaseKeys(obj); + * // result will be { user_id: 1, first_name: 'John' } + * + * // Example with arrays of objects + * const arr = [ + * { userId: 1, firstName: 'John' }, + * { userId: 2, firstName: 'Jane' } + * ]; + * const arrResult = toSnakeCaseKeys(arr); + * // arrResult will be [{ user_id: 1, first_name: 'John' }, { user_id: 2, first_name: 'Jane' }] + * + * // Example with nested objects + * const nested = { + * userData: { + * userId: 1, + * userAddress: { + * streetName: 'Main St', + * zipCode: '12345' + * } + * } + * }; + * const nestedResult = toSnakeCaseKeys(nested); + * // nestedResult will be: + * // { + * // user_data: { + * // user_id: 1, + * // user_address: { + * // street_name: 'Main St', + * // zip_code: '12345' + * // } + * // } + * // } + */ +declare function toSnakeCaseKeys(obj: T): ToSnakeCaseKeys; +//#endregion +export { toSnakeCaseKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.ts b/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..68f6a1b0b9db6c8b5bf29dcc598f92509579a8d8 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.d.ts @@ -0,0 +1,53 @@ +//#region src/object/toSnakeCaseKeys.d.ts +type SnakeCase = S extends Uppercase ? Lowercase : S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize ? `${Lowercase}${SnakeCase}` : `${Lowercase}_${SnakeCase>}` : Lowercase; +type NonPlainObject = Date | RegExp | Map | Set | WeakMap | WeakSet | Promise | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis; +type ToSnakeCaseKeys = T extends NonPlainObject ? T : T extends any[] ? Array> : T extends Record ? { [K in keyof T as SnakeCase]: ToSnakeCaseKeys } : T; +/** + * Creates a new object composed of the properties with keys converted to snake_case. + * + * This function takes an object and returns a new object that includes the same properties, + * but with all keys converted to snake_case format. + * + * @template T - The type of object. + * @param obj - The object to convert keys from. + * @returns A new object with all keys converted to snake_case. + * + * @example + * // Example with objects + * const obj = { userId: 1, firstName: 'John' }; + * const result = toSnakeCaseKeys(obj); + * // result will be { user_id: 1, first_name: 'John' } + * + * // Example with arrays of objects + * const arr = [ + * { userId: 1, firstName: 'John' }, + * { userId: 2, firstName: 'Jane' } + * ]; + * const arrResult = toSnakeCaseKeys(arr); + * // arrResult will be [{ user_id: 1, first_name: 'John' }, { user_id: 2, first_name: 'Jane' }] + * + * // Example with nested objects + * const nested = { + * userData: { + * userId: 1, + * userAddress: { + * streetName: 'Main St', + * zipCode: '12345' + * } + * } + * }; + * const nestedResult = toSnakeCaseKeys(nested); + * // nestedResult will be: + * // { + * // user_data: { + * // user_id: 1, + * // user_address: { + * // street_name: 'Main St', + * // zip_code: '12345' + * // } + * // } + * // } + */ +declare function toSnakeCaseKeys(obj: T): ToSnakeCaseKeys; +//#endregion +export { toSnakeCaseKeys }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.js b/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..6e57a66be234b6f381908a9f6de7d3d30b8fd639 --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.js @@ -0,0 +1,66 @@ +const require_isArray = require("../compat/predicate/isArray.js"); +const require_isPlainObject = require("../compat/predicate/isPlainObject.js"); +const require_snakeCase = require("../string/snakeCase.js"); +//#region src/object/toSnakeCaseKeys.ts +/** +* Creates a new object composed of the properties with keys converted to snake_case. +* +* This function takes an object and returns a new object that includes the same properties, +* but with all keys converted to snake_case format. +* +* @template T - The type of object. +* @param obj - The object to convert keys from. +* @returns A new object with all keys converted to snake_case. +* +* @example +* // Example with objects +* const obj = { userId: 1, firstName: 'John' }; +* const result = toSnakeCaseKeys(obj); +* // result will be { user_id: 1, first_name: 'John' } +* +* // Example with arrays of objects +* const arr = [ +* { userId: 1, firstName: 'John' }, +* { userId: 2, firstName: 'Jane' } +* ]; +* const arrResult = toSnakeCaseKeys(arr); +* // arrResult will be [{ user_id: 1, first_name: 'John' }, { user_id: 2, first_name: 'Jane' }] +* +* // Example with nested objects +* const nested = { +* userData: { +* userId: 1, +* userAddress: { +* streetName: 'Main St', +* zipCode: '12345' +* } +* } +* }; +* const nestedResult = toSnakeCaseKeys(nested); +* // nestedResult will be: +* // { +* // user_data: { +* // user_id: 1, +* // user_address: { +* // street_name: 'Main St', +* // zip_code: '12345' +* // } +* // } +* // } +*/ +function toSnakeCaseKeys(obj) { + if (require_isArray.isArray(obj)) return obj.map((item) => toSnakeCaseKeys(item)); + if (require_isPlainObject.isPlainObject(obj)) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const snakeKey = require_snakeCase.snakeCase(key); + result[snakeKey] = toSnakeCaseKeys(obj[key]); + } + return result; + } + return obj; +} +//#endregion +exports.toSnakeCaseKeys = toSnakeCaseKeys; diff --git a/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.mjs b/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.mjs new file mode 100644 index 0000000000000000000000000000000000000000..494d47d2ecf4dfb6088ddbfe56884a71123fa2bc --- /dev/null +++ b/node_modules/es-toolkit/dist/object/toSnakeCaseKeys.mjs @@ -0,0 +1,66 @@ +import { isArray } from "../compat/predicate/isArray.mjs"; +import { isPlainObject } from "../compat/predicate/isPlainObject.mjs"; +import { snakeCase } from "../string/snakeCase.mjs"; +//#region src/object/toSnakeCaseKeys.ts +/** +* Creates a new object composed of the properties with keys converted to snake_case. +* +* This function takes an object and returns a new object that includes the same properties, +* but with all keys converted to snake_case format. +* +* @template T - The type of object. +* @param obj - The object to convert keys from. +* @returns A new object with all keys converted to snake_case. +* +* @example +* // Example with objects +* const obj = { userId: 1, firstName: 'John' }; +* const result = toSnakeCaseKeys(obj); +* // result will be { user_id: 1, first_name: 'John' } +* +* // Example with arrays of objects +* const arr = [ +* { userId: 1, firstName: 'John' }, +* { userId: 2, firstName: 'Jane' } +* ]; +* const arrResult = toSnakeCaseKeys(arr); +* // arrResult will be [{ user_id: 1, first_name: 'John' }, { user_id: 2, first_name: 'Jane' }] +* +* // Example with nested objects +* const nested = { +* userData: { +* userId: 1, +* userAddress: { +* streetName: 'Main St', +* zipCode: '12345' +* } +* } +* }; +* const nestedResult = toSnakeCaseKeys(nested); +* // nestedResult will be: +* // { +* // user_data: { +* // user_id: 1, +* // user_address: { +* // street_name: 'Main St', +* // zip_code: '12345' +* // } +* // } +* // } +*/ +function toSnakeCaseKeys(obj) { + if (isArray(obj)) return obj.map((item) => toSnakeCaseKeys(item)); + if (isPlainObject(obj)) { + const result = {}; + const keys = Object.keys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const snakeKey = snakeCase(key); + result[snakeKey] = toSnakeCaseKeys(obj[key]); + } + return result; + } + return obj; +} +//#endregion +export { toSnakeCaseKeys }; diff --git a/node_modules/es-toolkit/dist/predicate/index.d.mts b/node_modules/es-toolkit/dist/predicate/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..eaa28cf7d7be8da261b4364781fc6aa655f4718d --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/index.d.mts @@ -0,0 +1,34 @@ +import { isEqual } from "./isEqual.mjs"; +import { isArrayBuffer } from "./isArrayBuffer.mjs"; +import { isBlob } from "./isBlob.mjs"; +import { isBoolean } from "./isBoolean.mjs"; +import { isBrowser } from "./isBrowser.mjs"; +import { isBuffer } from "./isBuffer.mjs"; +import { isDate } from "./isDate.mjs"; +import { isEmptyObject } from "./isEmptyObject.mjs"; +import { isEqualWith } from "./isEqualWith.mjs"; +import { isError } from "./isError.mjs"; +import { isFile } from "./isFile.mjs"; +import { isFunction } from "./isFunction.mjs"; +import { isIterable } from "./isIterable.mjs"; +import { isJSON } from "./isJSON.mjs"; +import { isJSONArray, isJSONObject, isJSONValue } from "./isJSONValue.mjs"; +import { isLength } from "./isLength.mjs"; +import { isMap } from "./isMap.mjs"; +import { isNil } from "./isNil.mjs"; +import { isNode } from "./isNode.mjs"; +import { isNotNil } from "./isNotNil.mjs"; +import { isNull } from "./isNull.mjs"; +import { isNumber } from "./isNumber.mjs"; +import { isPlainObject } from "./isPlainObject.mjs"; +import { isPrimitive } from "./isPrimitive.mjs"; +import { isPromise } from "./isPromise.mjs"; +import { isRegExp } from "./isRegExp.mjs"; +import { isSet } from "./isSet.mjs"; +import { isString } from "./isString.mjs"; +import { isSymbol } from "./isSymbol.mjs"; +import { isTypedArray } from "./isTypedArray.mjs"; +import { isUndefined } from "./isUndefined.mjs"; +import { isWeakMap } from "./isWeakMap.mjs"; +import { isWeakSet } from "./isWeakSet.mjs"; +export { isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFunction, isIterable, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNil, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/index.d.ts b/node_modules/es-toolkit/dist/predicate/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6bcafbec4ae059d36e0fbf5e35ee9fd67cc792d1 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/index.d.ts @@ -0,0 +1,34 @@ +import { isEqual } from "./isEqual.js"; +import { isArrayBuffer } from "./isArrayBuffer.js"; +import { isBlob } from "./isBlob.js"; +import { isBoolean } from "./isBoolean.js"; +import { isBrowser } from "./isBrowser.js"; +import { isBuffer } from "./isBuffer.js"; +import { isDate } from "./isDate.js"; +import { isEmptyObject } from "./isEmptyObject.js"; +import { isEqualWith } from "./isEqualWith.js"; +import { isError } from "./isError.js"; +import { isFile } from "./isFile.js"; +import { isFunction } from "./isFunction.js"; +import { isIterable } from "./isIterable.js"; +import { isJSON } from "./isJSON.js"; +import { isJSONArray, isJSONObject, isJSONValue } from "./isJSONValue.js"; +import { isLength } from "./isLength.js"; +import { isMap } from "./isMap.js"; +import { isNil } from "./isNil.js"; +import { isNode } from "./isNode.js"; +import { isNotNil } from "./isNotNil.js"; +import { isNull } from "./isNull.js"; +import { isNumber } from "./isNumber.js"; +import { isPlainObject } from "./isPlainObject.js"; +import { isPrimitive } from "./isPrimitive.js"; +import { isPromise } from "./isPromise.js"; +import { isRegExp } from "./isRegExp.js"; +import { isSet } from "./isSet.js"; +import { isString } from "./isString.js"; +import { isSymbol } from "./isSymbol.js"; +import { isTypedArray } from "./isTypedArray.js"; +import { isUndefined } from "./isUndefined.js"; +import { isWeakMap } from "./isWeakMap.js"; +import { isWeakSet } from "./isWeakSet.js"; +export { isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFunction, isIterable, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNil, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/index.js b/node_modules/es-toolkit/dist/predicate/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a77c1ab2da1d8a1ad74545eae8bb1193eb3574eb --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/index.js @@ -0,0 +1,69 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_isPrimitive = require("./isPrimitive.js"); +const require_isTypedArray = require("./isTypedArray.js"); +const require_isBuffer = require("./isBuffer.js"); +const require_isPlainObject = require("./isPlainObject.js"); +const require_isArrayBuffer = require("./isArrayBuffer.js"); +const require_isBlob = require("./isBlob.js"); +const require_isBoolean = require("./isBoolean.js"); +const require_isBrowser = require("./isBrowser.js"); +const require_isDate = require("./isDate.js"); +const require_isEmptyObject = require("./isEmptyObject.js"); +const require_isEqualWith = require("./isEqualWith.js"); +const require_isEqual = require("./isEqual.js"); +const require_isError = require("./isError.js"); +const require_isFile = require("./isFile.js"); +const require_isFunction = require("./isFunction.js"); +const require_isIterable = require("./isIterable.js"); +const require_isJSON = require("./isJSON.js"); +const require_isJSONValue = require("./isJSONValue.js"); +const require_isLength = require("./isLength.js"); +const require_isMap = require("./isMap.js"); +const require_isNil = require("./isNil.js"); +const require_isNode = require("./isNode.js"); +const require_isNotNil = require("./isNotNil.js"); +const require_isNull = require("./isNull.js"); +const require_isNumber = require("./isNumber.js"); +const require_isPromise = require("./isPromise.js"); +const require_isRegExp = require("./isRegExp.js"); +const require_isSet = require("./isSet.js"); +const require_isString = require("./isString.js"); +const require_isSymbol = require("./isSymbol.js"); +const require_isUndefined = require("./isUndefined.js"); +const require_isWeakMap = require("./isWeakMap.js"); +const require_isWeakSet = require("./isWeakSet.js"); +exports.isArrayBuffer = require_isArrayBuffer.isArrayBuffer; +exports.isBlob = require_isBlob.isBlob; +exports.isBoolean = require_isBoolean.isBoolean; +exports.isBrowser = require_isBrowser.isBrowser; +exports.isBuffer = require_isBuffer.isBuffer; +exports.isDate = require_isDate.isDate; +exports.isEmptyObject = require_isEmptyObject.isEmptyObject; +exports.isEqual = require_isEqual.isEqual; +exports.isEqualWith = require_isEqualWith.isEqualWith; +exports.isError = require_isError.isError; +exports.isFile = require_isFile.isFile; +exports.isFunction = require_isFunction.isFunction; +exports.isIterable = require_isIterable.isIterable; +exports.isJSON = require_isJSON.isJSON; +exports.isJSONArray = require_isJSONValue.isJSONArray; +exports.isJSONObject = require_isJSONValue.isJSONObject; +exports.isJSONValue = require_isJSONValue.isJSONValue; +exports.isLength = require_isLength.isLength; +exports.isMap = require_isMap.isMap; +exports.isNil = require_isNil.isNil; +exports.isNode = require_isNode.isNode; +exports.isNotNil = require_isNotNil.isNotNil; +exports.isNull = require_isNull.isNull; +exports.isNumber = require_isNumber.isNumber; +exports.isPlainObject = require_isPlainObject.isPlainObject; +exports.isPrimitive = require_isPrimitive.isPrimitive; +exports.isPromise = require_isPromise.isPromise; +exports.isRegExp = require_isRegExp.isRegExp; +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; diff --git a/node_modules/es-toolkit/dist/predicate/index.mjs b/node_modules/es-toolkit/dist/predicate/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e888cf3c598cc60ca37a20349b87b486c77b2617 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/index.mjs @@ -0,0 +1,34 @@ +import { isPrimitive } from "./isPrimitive.mjs"; +import { isTypedArray } from "./isTypedArray.mjs"; +import { isBuffer } from "./isBuffer.mjs"; +import { isPlainObject } from "./isPlainObject.mjs"; +import { isArrayBuffer } from "./isArrayBuffer.mjs"; +import { isBlob } from "./isBlob.mjs"; +import { isBoolean } from "./isBoolean.mjs"; +import { isBrowser } from "./isBrowser.mjs"; +import { isDate } from "./isDate.mjs"; +import { isEmptyObject } from "./isEmptyObject.mjs"; +import { isEqualWith } from "./isEqualWith.mjs"; +import { isEqual } from "./isEqual.mjs"; +import { isError } from "./isError.mjs"; +import { isFile } from "./isFile.mjs"; +import { isFunction } from "./isFunction.mjs"; +import { isIterable } from "./isIterable.mjs"; +import { isJSON } from "./isJSON.mjs"; +import { isJSONArray, isJSONObject, isJSONValue } from "./isJSONValue.mjs"; +import { isLength } from "./isLength.mjs"; +import { isMap } from "./isMap.mjs"; +import { isNil } from "./isNil.mjs"; +import { isNode } from "./isNode.mjs"; +import { isNotNil } from "./isNotNil.mjs"; +import { isNull } from "./isNull.mjs"; +import { isNumber } from "./isNumber.mjs"; +import { isPromise } from "./isPromise.mjs"; +import { isRegExp } from "./isRegExp.mjs"; +import { isSet } from "./isSet.mjs"; +import { isString } from "./isString.mjs"; +import { isSymbol } from "./isSymbol.mjs"; +import { isUndefined } from "./isUndefined.mjs"; +import { isWeakMap } from "./isWeakMap.mjs"; +import { isWeakSet } from "./isWeakSet.mjs"; +export { isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFunction, isIterable, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNil, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet }; diff --git a/node_modules/es-toolkit/dist/predicate/isArrayBuffer.d.mts b/node_modules/es-toolkit/dist/predicate/isArrayBuffer.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3c6ac1cac4383ce1a376eb6c9804d6935e009f7d --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isArrayBuffer.d.mts @@ -0,0 +1,21 @@ +//#region src/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: unknown): value is ArrayBuffer; +//#endregion +export { isArrayBuffer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isArrayBuffer.d.ts b/node_modules/es-toolkit/dist/predicate/isArrayBuffer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c6ac1cac4383ce1a376eb6c9804d6935e009f7d --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isArrayBuffer.d.ts @@ -0,0 +1,21 @@ +//#region src/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: unknown): value is ArrayBuffer; +//#endregion +export { isArrayBuffer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isArrayBuffer.js b/node_modules/es-toolkit/dist/predicate/isArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..2fd269f0339816a3f961217b4eb547deb8de1107 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isArrayBuffer.js @@ -0,0 +1,23 @@ +//#region src/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 value instanceof ArrayBuffer; +} +//#endregion +exports.isArrayBuffer = isArrayBuffer; diff --git a/node_modules/es-toolkit/dist/predicate/isArrayBuffer.mjs b/node_modules/es-toolkit/dist/predicate/isArrayBuffer.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bba7b4db5675aa2e082909930e6ef62ca12f965b --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isArrayBuffer.mjs @@ -0,0 +1,23 @@ +//#region src/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 value instanceof ArrayBuffer; +} +//#endregion +export { isArrayBuffer }; diff --git a/node_modules/es-toolkit/dist/predicate/isBlob.d.mts b/node_modules/es-toolkit/dist/predicate/isBlob.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..501edca13eb2a7fb2d492e68fc4a196ca2bc4303 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBlob.d.mts @@ -0,0 +1,20 @@ +//#region src/predicate/isBlob.d.ts +/** + * Checks if the given value is a Blob. + * + * This function tests whether the provided value is an instance of `Blob`. + * It returns `true` if the value is an instance of `Blob`, and `false` otherwise. + * + * @param x - The value to test if it is a Blob. + * @returns True if the value is a Blob, false otherwise. + * + * @example + * const value1 = new Blob(); + * const value2 = {}; + * + * console.log(isBlob(value1)); // true + * console.log(isBlob(value2)); // false + */ +declare function isBlob(x: unknown): x is Blob; +//#endregion +export { isBlob }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isBlob.d.ts b/node_modules/es-toolkit/dist/predicate/isBlob.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..501edca13eb2a7fb2d492e68fc4a196ca2bc4303 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBlob.d.ts @@ -0,0 +1,20 @@ +//#region src/predicate/isBlob.d.ts +/** + * Checks if the given value is a Blob. + * + * This function tests whether the provided value is an instance of `Blob`. + * It returns `true` if the value is an instance of `Blob`, and `false` otherwise. + * + * @param x - The value to test if it is a Blob. + * @returns True if the value is a Blob, false otherwise. + * + * @example + * const value1 = new Blob(); + * const value2 = {}; + * + * console.log(isBlob(value1)); // true + * console.log(isBlob(value2)); // false + */ +declare function isBlob(x: unknown): x is Blob; +//#endregion +export { isBlob }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isBlob.js b/node_modules/es-toolkit/dist/predicate/isBlob.js new file mode 100644 index 0000000000000000000000000000000000000000..46273be3287bb497d4165bdac8b96c9ec8e5aa52 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBlob.js @@ -0,0 +1,23 @@ +//#region src/predicate/isBlob.ts +/** +* Checks if the given value is a Blob. +* +* This function tests whether the provided value is an instance of `Blob`. +* It returns `true` if the value is an instance of `Blob`, and `false` otherwise. +* +* @param x - The value to test if it is a Blob. +* @returns True if the value is a Blob, false otherwise. +* +* @example +* const value1 = new Blob(); +* const value2 = {}; +* +* console.log(isBlob(value1)); // true +* console.log(isBlob(value2)); // false +*/ +function isBlob(x) { + if (typeof Blob === "undefined") return false; + return x instanceof Blob; +} +//#endregion +exports.isBlob = isBlob; diff --git a/node_modules/es-toolkit/dist/predicate/isBlob.mjs b/node_modules/es-toolkit/dist/predicate/isBlob.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c1aaba6cb461c00705dabd80fd4b954e81b52919 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBlob.mjs @@ -0,0 +1,23 @@ +//#region src/predicate/isBlob.ts +/** +* Checks if the given value is a Blob. +* +* This function tests whether the provided value is an instance of `Blob`. +* It returns `true` if the value is an instance of `Blob`, and `false` otherwise. +* +* @param x - The value to test if it is a Blob. +* @returns True if the value is a Blob, false otherwise. +* +* @example +* const value1 = new Blob(); +* const value2 = {}; +* +* console.log(isBlob(value1)); // true +* console.log(isBlob(value2)); // false +*/ +function isBlob(x) { + if (typeof Blob === "undefined") return false; + return x instanceof Blob; +} +//#endregion +export { isBlob }; diff --git a/node_modules/es-toolkit/dist/predicate/isBoolean.d.mts b/node_modules/es-toolkit/dist/predicate/isBoolean.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..72ad04f2b980c365d318c6abb24371d1564ed09f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBoolean.d.mts @@ -0,0 +1,26 @@ +//#region src/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 x - 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(x: unknown): x is boolean; +//#endregion +export { isBoolean }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isBoolean.d.ts b/node_modules/es-toolkit/dist/predicate/isBoolean.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..72ad04f2b980c365d318c6abb24371d1564ed09f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBoolean.d.ts @@ -0,0 +1,26 @@ +//#region src/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 x - 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(x: unknown): x is boolean; +//#endregion +export { isBoolean }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isBoolean.js b/node_modules/es-toolkit/dist/predicate/isBoolean.js new file mode 100644 index 0000000000000000000000000000000000000000..00ba1e387f5f56917dfa95beea20717e4fc2df10 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBoolean.js @@ -0,0 +1,28 @@ +//#region src/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 x - 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(x) { + return typeof x === "boolean"; +} +//#endregion +exports.isBoolean = isBoolean; diff --git a/node_modules/es-toolkit/dist/predicate/isBoolean.mjs b/node_modules/es-toolkit/dist/predicate/isBoolean.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d32084d3567ce242e291d752226c932ba038f7ea --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBoolean.mjs @@ -0,0 +1,28 @@ +//#region src/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 x - 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(x) { + return typeof x === "boolean"; +} +//#endregion +export { isBoolean }; diff --git a/node_modules/es-toolkit/dist/predicate/isBrowser.d.mts b/node_modules/es-toolkit/dist/predicate/isBrowser.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b3a8a5851dfd4cdac46f8acf383fd418d9204915 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBrowser.d.mts @@ -0,0 +1,18 @@ +//#region src/predicate/isBrowser.d.ts +/** + * Checks if the current environment is a browser. + * + * This function checks for the existence of the `window.document` property, + * which only exists in browser environments. + * + * @returns `true` if the current environment is a browser, otherwise `false`. + * + * @example + * if (isBrowser()) { + * console.log("This is running in a browser"); + * document.getElementById('app').innerHTML = 'Hello World'; + * } + */ +declare function isBrowser(): boolean; +//#endregion +export { isBrowser }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isBrowser.d.ts b/node_modules/es-toolkit/dist/predicate/isBrowser.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3a8a5851dfd4cdac46f8acf383fd418d9204915 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBrowser.d.ts @@ -0,0 +1,18 @@ +//#region src/predicate/isBrowser.d.ts +/** + * Checks if the current environment is a browser. + * + * This function checks for the existence of the `window.document` property, + * which only exists in browser environments. + * + * @returns `true` if the current environment is a browser, otherwise `false`. + * + * @example + * if (isBrowser()) { + * console.log("This is running in a browser"); + * document.getElementById('app').innerHTML = 'Hello World'; + * } + */ +declare function isBrowser(): boolean; +//#endregion +export { isBrowser }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isBrowser.js b/node_modules/es-toolkit/dist/predicate/isBrowser.js new file mode 100644 index 0000000000000000000000000000000000000000..c68adca7ea5cf81ea6e932e7efa62a50af1caa8e --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBrowser.js @@ -0,0 +1,20 @@ +//#region src/predicate/isBrowser.ts +/** +* Checks if the current environment is a browser. +* +* This function checks for the existence of the `window.document` property, +* which only exists in browser environments. +* +* @returns `true` if the current environment is a browser, otherwise `false`. +* +* @example +* if (isBrowser()) { +* console.log("This is running in a browser"); +* document.getElementById('app').innerHTML = 'Hello World'; +* } +*/ +function isBrowser() { + return typeof window !== "undefined" && window?.document != null; +} +//#endregion +exports.isBrowser = isBrowser; diff --git a/node_modules/es-toolkit/dist/predicate/isBrowser.mjs b/node_modules/es-toolkit/dist/predicate/isBrowser.mjs new file mode 100644 index 0000000000000000000000000000000000000000..da9e29f4d2a7dae6bf30695d82ad9cf9fb3eb64a --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBrowser.mjs @@ -0,0 +1,20 @@ +//#region src/predicate/isBrowser.ts +/** +* Checks if the current environment is a browser. +* +* This function checks for the existence of the `window.document` property, +* which only exists in browser environments. +* +* @returns `true` if the current environment is a browser, otherwise `false`. +* +* @example +* if (isBrowser()) { +* console.log("This is running in a browser"); +* document.getElementById('app').innerHTML = 'Hello World'; +* } +*/ +function isBrowser() { + return typeof window !== "undefined" && window?.document != null; +} +//#endregion +export { isBrowser }; diff --git a/node_modules/es-toolkit/dist/predicate/isBuffer.d.mts b/node_modules/es-toolkit/dist/predicate/isBuffer.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0fb4140e4dd4ac26ef26ee2a1f56223bc9f8c226 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBuffer.d.mts @@ -0,0 +1,22 @@ +//#region src/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: unknown): boolean; +//#endregion +export { isBuffer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isBuffer.d.ts b/node_modules/es-toolkit/dist/predicate/isBuffer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0fb4140e4dd4ac26ef26ee2a1f56223bc9f8c226 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBuffer.d.ts @@ -0,0 +1,22 @@ +//#region src/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: unknown): boolean; +//#endregion +export { isBuffer }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isBuffer.js b/node_modules/es-toolkit/dist/predicate/isBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..d5400f3cf9209d2dc2ef31663845eb23be1161e3 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBuffer.js @@ -0,0 +1,25 @@ +const require_globalThis = require("../_internal/globalThis.js"); +//#region src/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 typeof require_globalThis.globalThis_.Buffer !== "undefined" && require_globalThis.globalThis_.Buffer.isBuffer(x); +} +//#endregion +exports.isBuffer = isBuffer; diff --git a/node_modules/es-toolkit/dist/predicate/isBuffer.mjs b/node_modules/es-toolkit/dist/predicate/isBuffer.mjs new file mode 100644 index 0000000000000000000000000000000000000000..daeffb3a423756a0a7c91bf633f9cc267a7ea8d3 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isBuffer.mjs @@ -0,0 +1,25 @@ +import { globalThis_ } from "../_internal/globalThis.mjs"; +//#region src/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 typeof globalThis_.Buffer !== "undefined" && globalThis_.Buffer.isBuffer(x); +} +//#endregion +export { isBuffer }; diff --git a/node_modules/es-toolkit/dist/predicate/isDate.d.mts b/node_modules/es-toolkit/dist/predicate/isDate.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..913e47dd0a2b8512168cd01a562456d0f9c51580 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isDate.d.mts @@ -0,0 +1,17 @@ +//#region src/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: unknown): value is Date; +//#endregion +export { isDate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isDate.d.ts b/node_modules/es-toolkit/dist/predicate/isDate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..913e47dd0a2b8512168cd01a562456d0f9c51580 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isDate.d.ts @@ -0,0 +1,17 @@ +//#region src/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: unknown): value is Date; +//#endregion +export { isDate }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isDate.js b/node_modules/es-toolkit/dist/predicate/isDate.js new file mode 100644 index 0000000000000000000000000000000000000000..7fc8ca108d1bd318ff67af045ff15ee0a9b29ca1 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isDate.js @@ -0,0 +1,19 @@ +//#region src/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 value instanceof Date; +} +//#endregion +exports.isDate = isDate; diff --git a/node_modules/es-toolkit/dist/predicate/isDate.mjs b/node_modules/es-toolkit/dist/predicate/isDate.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ab943f3e631da8d4fc3a4d9362731a429d08cef1 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isDate.mjs @@ -0,0 +1,19 @@ +//#region src/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 value instanceof Date; +} +//#endregion +export { isDate }; diff --git a/node_modules/es-toolkit/dist/predicate/isEmptyObject.d.mts b/node_modules/es-toolkit/dist/predicate/isEmptyObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e3733048a4337344c44d8406449ca37f2f7d204f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEmptyObject.d.mts @@ -0,0 +1,16 @@ +//#region src/predicate/isEmptyObject.d.ts +/** + * Checks if a value is an empty plain object. + * + * @param value - The value to check. + * @returns True if the value is an empty plain object, otherwise false. + * + * @example + * isEmptyObject({}); // true + * isEmptyObject({ a: 1 }); // false + * isEmptyObject([]); // false + * isEmptyObject(null); // false + */ +declare function isEmptyObject(value: unknown): value is Record; +//#endregion +export { isEmptyObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isEmptyObject.d.ts b/node_modules/es-toolkit/dist/predicate/isEmptyObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3733048a4337344c44d8406449ca37f2f7d204f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEmptyObject.d.ts @@ -0,0 +1,16 @@ +//#region src/predicate/isEmptyObject.d.ts +/** + * Checks if a value is an empty plain object. + * + * @param value - The value to check. + * @returns True if the value is an empty plain object, otherwise false. + * + * @example + * isEmptyObject({}); // true + * isEmptyObject({ a: 1 }); // false + * isEmptyObject([]); // false + * isEmptyObject(null); // false + */ +declare function isEmptyObject(value: unknown): value is Record; +//#endregion +export { isEmptyObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isEmptyObject.js b/node_modules/es-toolkit/dist/predicate/isEmptyObject.js new file mode 100644 index 0000000000000000000000000000000000000000..b366c1d0ec21663a77f5992302a540545bef9958 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEmptyObject.js @@ -0,0 +1,19 @@ +const require_isPlainObject = require("./isPlainObject.js"); +//#region src/predicate/isEmptyObject.ts +/** +* Checks if a value is an empty plain object. +* +* @param value - The value to check. +* @returns True if the value is an empty plain object, otherwise false. +* +* @example +* isEmptyObject({}); // true +* isEmptyObject({ a: 1 }); // false +* isEmptyObject([]); // false +* isEmptyObject(null); // false +*/ +function isEmptyObject(value) { + return require_isPlainObject.isPlainObject(value) && Object.keys(value).length === 0; +} +//#endregion +exports.isEmptyObject = isEmptyObject; diff --git a/node_modules/es-toolkit/dist/predicate/isEmptyObject.mjs b/node_modules/es-toolkit/dist/predicate/isEmptyObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4435e953ddc193f5f7507372d046499ca8cbb1fb --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEmptyObject.mjs @@ -0,0 +1,19 @@ +import { isPlainObject } from "./isPlainObject.mjs"; +//#region src/predicate/isEmptyObject.ts +/** +* Checks if a value is an empty plain object. +* +* @param value - The value to check. +* @returns True if the value is an empty plain object, otherwise false. +* +* @example +* isEmptyObject({}); // true +* isEmptyObject({ a: 1 }); // false +* isEmptyObject([]); // false +* isEmptyObject(null); // false +*/ +function isEmptyObject(value) { + return isPlainObject(value) && Object.keys(value).length === 0; +} +//#endregion +export { isEmptyObject }; diff --git a/node_modules/es-toolkit/dist/predicate/isEqual.d.mts b/node_modules/es-toolkit/dist/predicate/isEqual.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..215c1191b003a9d53be0174128a0bb6f800ef790 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEqual.d.mts @@ -0,0 +1,18 @@ +//#region src/predicate/isEqual.d.ts +/** + * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison. + * + * @param a - The first value to compare. + * @param b - The second value to compare. + * @returns `true` if the values are equal, otherwise `false`. + * + * @example + * isEqual(1, 1); // true + * isEqual({ a: 1 }, { a: 1 }); // true + * isEqual(/abc/g, /abc/g); // true + * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true + * isEqual([1, 2, 3], [1, 2, 3]); // true + */ +declare function isEqual(a: any, b: any): boolean; +//#endregion +export { isEqual }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isEqual.d.ts b/node_modules/es-toolkit/dist/predicate/isEqual.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..215c1191b003a9d53be0174128a0bb6f800ef790 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEqual.d.ts @@ -0,0 +1,18 @@ +//#region src/predicate/isEqual.d.ts +/** + * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison. + * + * @param a - The first value to compare. + * @param b - The second value to compare. + * @returns `true` if the values are equal, otherwise `false`. + * + * @example + * isEqual(1, 1); // true + * isEqual({ a: 1 }, { a: 1 }); // true + * isEqual(/abc/g, /abc/g); // true + * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true + * isEqual([1, 2, 3], [1, 2, 3]); // true + */ +declare function isEqual(a: any, b: any): boolean; +//#endregion +export { isEqual }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isEqual.js b/node_modules/es-toolkit/dist/predicate/isEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..d8242baedfce4f61ebdb69f4bb8f6f7571ba5d12 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEqual.js @@ -0,0 +1,22 @@ +const require_noop = require("../function/noop.js"); +const require_isEqualWith = require("./isEqualWith.js"); +//#region src/predicate/isEqual.ts +/** +* Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison. +* +* @param a - The first value to compare. +* @param b - The second value to compare. +* @returns `true` if the values are equal, otherwise `false`. +* +* @example +* isEqual(1, 1); // true +* isEqual({ a: 1 }, { a: 1 }); // true +* isEqual(/abc/g, /abc/g); // true +* isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true +* isEqual([1, 2, 3], [1, 2, 3]); // true +*/ +function isEqual(a, b) { + return require_isEqualWith.isEqualWith(a, b, require_noop.noop); +} +//#endregion +exports.isEqual = isEqual; diff --git a/node_modules/es-toolkit/dist/predicate/isEqual.mjs b/node_modules/es-toolkit/dist/predicate/isEqual.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d93532b398a1f33b9b869f3e4122819b01610ca1 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEqual.mjs @@ -0,0 +1,22 @@ +import { noop } from "../function/noop.mjs"; +import { isEqualWith } from "./isEqualWith.mjs"; +//#region src/predicate/isEqual.ts +/** +* Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison. +* +* @param a - The first value to compare. +* @param b - The second value to compare. +* @returns `true` if the values are equal, otherwise `false`. +* +* @example +* isEqual(1, 1); // true +* isEqual({ a: 1 }, { a: 1 }); // true +* isEqual(/abc/g, /abc/g); // true +* isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true +* isEqual([1, 2, 3], [1, 2, 3]); // true +*/ +function isEqual(a, b) { + return isEqualWith(a, b, noop); +} +//#endregion +export { isEqual }; diff --git a/node_modules/es-toolkit/dist/predicate/isEqualWith.d.mts b/node_modules/es-toolkit/dist/predicate/isEqualWith.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3c4fa0821226cf9080f436cc0437f87407e5c2a0 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEqualWith.d.mts @@ -0,0 +1,39 @@ +//#region src/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 - 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: (x: any, y: any, property?: PropertyKey, xParent?: any, yParent?: any, stack?: Map) => boolean | void): boolean; +//#endregion +export { isEqualWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isEqualWith.d.ts b/node_modules/es-toolkit/dist/predicate/isEqualWith.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c4fa0821226cf9080f436cc0437f87407e5c2a0 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEqualWith.d.ts @@ -0,0 +1,39 @@ +//#region src/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 - 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: (x: any, y: any, property?: PropertyKey, xParent?: any, yParent?: any, stack?: Map) => boolean | void): boolean; +//#endregion +export { isEqualWith }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isEqualWith.js b/node_modules/es-toolkit/dist/predicate/isEqualWith.js new file mode 100644 index 0000000000000000000000000000000000000000..c101d78c024326def396857715972a3cf5a2b3e0 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEqualWith.js @@ -0,0 +1,152 @@ +const require_getSymbols = require("../compat/_internal/getSymbols.js"); +const require_getTag = require("../compat/_internal/getTag.js"); +const require_tags = require("../compat/_internal/tags.js"); +const require_isBuffer = require("./isBuffer.js"); +const require_isPlainObject = require("./isPlainObject.js"); +const require_eq = require("../compat/util/eq.js"); +//#region src/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 - 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) { + return isEqualWithImpl(a, b, void 0, void 0, void 0, void 0, areValuesEqual); +} +function isEqualWithImpl(a, b, property, aParent, bParent, stack, areValuesEqual) { + const result = areValuesEqual(a, b, property, aParent, bParent, stack); + if (result !== void 0) return result; + if (typeof a === typeof b) switch (typeof a) { + case "bigint": + case "string": + case "boolean": + case "symbol": + case "undefined": return a === b; + case "number": return a === b || Object.is(a, b); + case "function": return a === b; + case "object": return areObjectsEqual(a, b, stack, areValuesEqual); + } + return areObjectsEqual(a, b, stack, areValuesEqual); +} +function areObjectsEqual(a, b, stack, areValuesEqual) { + if (Object.is(a, b)) return true; + let aTag = require_getTag.getTag(a); + let bTag = require_getTag.getTag(b); + if (aTag === "[object Arguments]") aTag = require_tags.objectTag; + if (bTag === "[object Arguments]") bTag = require_tags.objectTag; + if (aTag !== bTag) return false; + switch (aTag) { + case require_tags.stringTag: return a.toString() === b.toString(); + case require_tags.numberTag: { + const x = a.valueOf(); + const y = b.valueOf(); + return require_eq.eq(x, y); + } + case require_tags.booleanTag: + case require_tags.dateTag: + case require_tags.symbolTag: return Object.is(a.valueOf(), b.valueOf()); + case require_tags.regexpTag: return a.source === b.source && a.flags === b.flags; + case require_tags.functionTag: return a === b; + } + stack = stack ?? /* @__PURE__ */ new Map(); + const aStack = stack.get(a); + const bStack = stack.get(b); + if (aStack != null && bStack != null) return aStack === b; + stack.set(a, b); + stack.set(b, a); + try { + switch (aTag) { + case require_tags.mapTag: + if (a.size !== b.size) return false; + for (const [key, value] of a.entries()) if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual)) return false; + return true; + case require_tags.setTag: { + if (a.size !== b.size) return false; + const aValues = Array.from(a.values()); + const bValues = Array.from(b.values()); + for (let i = 0; i < aValues.length; i++) { + const aValue = aValues[i]; + const index = bValues.findIndex((bValue) => { + return isEqualWithImpl(aValue, bValue, void 0, a, b, stack, areValuesEqual); + }); + if (index === -1) return false; + bValues.splice(index, 1); + } + return true; + } + case require_tags.arrayTag: + case require_tags.uint8ArrayTag: + case require_tags.uint8ClampedArrayTag: + case require_tags.uint16ArrayTag: + case require_tags.uint32ArrayTag: + case require_tags.bigUint64ArrayTag: + case require_tags.int8ArrayTag: + case require_tags.int16ArrayTag: + case require_tags.int32ArrayTag: + case require_tags.bigInt64ArrayTag: + case require_tags.float32ArrayTag: + case require_tags.float64ArrayTag: + if (require_isBuffer.isBuffer(a) !== require_isBuffer.isBuffer(b)) return false; + if (a.length !== b.length) return false; + for (let i = 0; i < a.length; i++) if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) return false; + return true; + case require_tags.arrayBufferTag: + if (a.byteLength !== b.byteLength) return false; + return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual); + case require_tags.dataViewTag: + if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) return false; + return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual); + case require_tags.errorTag: return a.name === b.name && a.message === b.message; + case require_tags.objectTag: { + if (!(areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) || require_isPlainObject.isPlainObject(a) && require_isPlainObject.isPlainObject(b))) return false; + const aKeys = [...Object.keys(a), ...require_getSymbols.getSymbols(a)]; + const bKeys = [...Object.keys(b), ...require_getSymbols.getSymbols(b)]; + if (aKeys.length !== bKeys.length) return false; + for (let i = 0; i < aKeys.length; i++) { + const propKey = aKeys[i]; + const aProp = a[propKey]; + if (!Object.hasOwn(b, propKey)) return false; + const bProp = b[propKey]; + if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) return false; + } + return true; + } + default: return false; + } + } finally { + stack.delete(a); + stack.delete(b); + } +} +//#endregion +exports.isEqualWith = isEqualWith; diff --git a/node_modules/es-toolkit/dist/predicate/isEqualWith.mjs b/node_modules/es-toolkit/dist/predicate/isEqualWith.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2116957f5ad766af35c2865a1d60bc117f00666c --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isEqualWith.mjs @@ -0,0 +1,148 @@ +import { getSymbols } from "../compat/_internal/getSymbols.mjs"; +import { getTag } from "../compat/_internal/getTag.mjs"; +import { arrayBufferTag, arrayTag, bigInt64ArrayTag, bigUint64ArrayTag, booleanTag, dataViewTag, dateTag, errorTag, float32ArrayTag, float64ArrayTag, functionTag, int16ArrayTag, int32ArrayTag, int8ArrayTag, mapTag, numberTag, objectTag, regexpTag, setTag, stringTag, symbolTag, uint16ArrayTag, uint32ArrayTag, uint8ArrayTag, uint8ClampedArrayTag } from "../compat/_internal/tags.mjs"; +import { isBuffer } from "./isBuffer.mjs"; +import { isPlainObject } from "./isPlainObject.mjs"; +import { eq } from "../compat/util/eq.mjs"; +//#region src/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 - 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) { + return isEqualWithImpl(a, b, void 0, void 0, void 0, void 0, areValuesEqual); +} +function isEqualWithImpl(a, b, property, aParent, bParent, stack, areValuesEqual) { + const result = areValuesEqual(a, b, property, aParent, bParent, stack); + if (result !== void 0) return result; + if (typeof a === typeof b) switch (typeof a) { + case "bigint": + case "string": + case "boolean": + case "symbol": + case "undefined": return a === b; + case "number": return a === b || Object.is(a, b); + case "function": return a === b; + case "object": return areObjectsEqual(a, b, stack, areValuesEqual); + } + return areObjectsEqual(a, b, stack, areValuesEqual); +} +function areObjectsEqual(a, b, stack, areValuesEqual) { + if (Object.is(a, b)) return true; + let aTag = getTag(a); + let bTag = getTag(b); + if (aTag === "[object Arguments]") aTag = objectTag; + if (bTag === "[object Arguments]") bTag = objectTag; + if (aTag !== bTag) return false; + switch (aTag) { + case stringTag: return a.toString() === b.toString(); + case numberTag: return eq(a.valueOf(), b.valueOf()); + case booleanTag: + case dateTag: + case symbolTag: return Object.is(a.valueOf(), b.valueOf()); + case regexpTag: return a.source === b.source && a.flags === b.flags; + case functionTag: return a === b; + } + stack = stack ?? /* @__PURE__ */ new Map(); + const aStack = stack.get(a); + const bStack = stack.get(b); + if (aStack != null && bStack != null) return aStack === b; + stack.set(a, b); + stack.set(b, a); + try { + switch (aTag) { + case mapTag: + if (a.size !== b.size) return false; + for (const [key, value] of a.entries()) if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual)) return false; + return true; + case setTag: { + if (a.size !== b.size) return false; + const aValues = Array.from(a.values()); + const bValues = Array.from(b.values()); + for (let i = 0; i < aValues.length; i++) { + const aValue = aValues[i]; + const index = bValues.findIndex((bValue) => { + return isEqualWithImpl(aValue, bValue, void 0, a, b, stack, areValuesEqual); + }); + if (index === -1) return false; + bValues.splice(index, 1); + } + return true; + } + case arrayTag: + case uint8ArrayTag: + case uint8ClampedArrayTag: + case uint16ArrayTag: + case uint32ArrayTag: + case bigUint64ArrayTag: + case int8ArrayTag: + case int16ArrayTag: + case int32ArrayTag: + case bigInt64ArrayTag: + case float32ArrayTag: + case float64ArrayTag: + if (isBuffer(a) !== isBuffer(b)) return false; + if (a.length !== b.length) return false; + for (let i = 0; i < a.length; i++) if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) return false; + return true; + case arrayBufferTag: + if (a.byteLength !== b.byteLength) return false; + return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual); + case dataViewTag: + if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) return false; + return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual); + case errorTag: return a.name === b.name && a.message === b.message; + case objectTag: { + if (!(areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) || isPlainObject(a) && isPlainObject(b))) return false; + const aKeys = [...Object.keys(a), ...getSymbols(a)]; + const bKeys = [...Object.keys(b), ...getSymbols(b)]; + if (aKeys.length !== bKeys.length) return false; + for (let i = 0; i < aKeys.length; i++) { + const propKey = aKeys[i]; + const aProp = a[propKey]; + if (!Object.hasOwn(b, propKey)) return false; + const bProp = b[propKey]; + if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) return false; + } + return true; + } + default: return false; + } + } finally { + stack.delete(a); + stack.delete(b); + } +} +//#endregion +export { isEqualWith }; diff --git a/node_modules/es-toolkit/dist/predicate/isError.d.mts b/node_modules/es-toolkit/dist/predicate/isError.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fa20d57d03dda2b1377b199fd35397fa0d21047a --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isError.d.mts @@ -0,0 +1,17 @@ +//#region src/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: unknown): value is Error; +//#endregion +export { isError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isError.d.ts b/node_modules/es-toolkit/dist/predicate/isError.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa20d57d03dda2b1377b199fd35397fa0d21047a --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isError.d.ts @@ -0,0 +1,17 @@ +//#region src/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: unknown): value is Error; +//#endregion +export { isError }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isError.js b/node_modules/es-toolkit/dist/predicate/isError.js new file mode 100644 index 0000000000000000000000000000000000000000..2dbc888a85525dd39df48f8ea48f43cd0d71853e --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isError.js @@ -0,0 +1,19 @@ +//#region src/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 value instanceof Error; +} +//#endregion +exports.isError = isError; diff --git a/node_modules/es-toolkit/dist/predicate/isError.mjs b/node_modules/es-toolkit/dist/predicate/isError.mjs new file mode 100644 index 0000000000000000000000000000000000000000..16e05a7bdc5190679afe037b13ce6279d04fcdf4 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isError.mjs @@ -0,0 +1,19 @@ +//#region src/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 value instanceof Error; +} +//#endregion +export { isError }; diff --git a/node_modules/es-toolkit/dist/predicate/isFile.d.mts b/node_modules/es-toolkit/dist/predicate/isFile.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4f068f9fa6c0451a905f68a0c569703faaacb627 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isFile.d.mts @@ -0,0 +1,22 @@ +//#region src/predicate/isFile.d.ts +/** + * Checks if the given value is a File. + * + * This function tests whether the provided value is an instance of `File`. + * It returns `true` if the value is an instance of `File`, and `false` otherwise. + * + * @param x - The value to test if it is a File. + * @returns True if the value is a File, false otherwise. + * + * @example + * const value1 = new File(["content"], "example.txt"); + * const value2 = {}; + * const value3 = new Blob(["content"], { type: "text/plain" }); + * + * console.log(isFile(value1)); // true + * console.log(isFile(value2)); // false + * console.log(isFile(value3)); // false + */ +declare function isFile(x: unknown): x is File; +//#endregion +export { isFile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isFile.d.ts b/node_modules/es-toolkit/dist/predicate/isFile.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f068f9fa6c0451a905f68a0c569703faaacb627 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isFile.d.ts @@ -0,0 +1,22 @@ +//#region src/predicate/isFile.d.ts +/** + * Checks if the given value is a File. + * + * This function tests whether the provided value is an instance of `File`. + * It returns `true` if the value is an instance of `File`, and `false` otherwise. + * + * @param x - The value to test if it is a File. + * @returns True if the value is a File, false otherwise. + * + * @example + * const value1 = new File(["content"], "example.txt"); + * const value2 = {}; + * const value3 = new Blob(["content"], { type: "text/plain" }); + * + * console.log(isFile(value1)); // true + * console.log(isFile(value2)); // false + * console.log(isFile(value3)); // false + */ +declare function isFile(x: unknown): x is File; +//#endregion +export { isFile }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isFile.js b/node_modules/es-toolkit/dist/predicate/isFile.js new file mode 100644 index 0000000000000000000000000000000000000000..0cd3136358c14b41a91726aac8926d9c1e1ee13c --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isFile.js @@ -0,0 +1,26 @@ +const require_isBlob = require("./isBlob.js"); +//#region src/predicate/isFile.ts +/** +* Checks if the given value is a File. +* +* This function tests whether the provided value is an instance of `File`. +* It returns `true` if the value is an instance of `File`, and `false` otherwise. +* +* @param x - The value to test if it is a File. +* @returns True if the value is a File, false otherwise. +* +* @example +* const value1 = new File(["content"], "example.txt"); +* const value2 = {}; +* const value3 = new Blob(["content"], { type: "text/plain" }); +* +* console.log(isFile(value1)); // true +* console.log(isFile(value2)); // false +* console.log(isFile(value3)); // false +*/ +function isFile(x) { + if (typeof File === "undefined") return false; + return require_isBlob.isBlob(x) && x instanceof File; +} +//#endregion +exports.isFile = isFile; diff --git a/node_modules/es-toolkit/dist/predicate/isFile.mjs b/node_modules/es-toolkit/dist/predicate/isFile.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2aef810ed35a9cbf89061271ef25fd0103eff495 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isFile.mjs @@ -0,0 +1,26 @@ +import { isBlob } from "./isBlob.mjs"; +//#region src/predicate/isFile.ts +/** +* Checks if the given value is a File. +* +* This function tests whether the provided value is an instance of `File`. +* It returns `true` if the value is an instance of `File`, and `false` otherwise. +* +* @param x - The value to test if it is a File. +* @returns True if the value is a File, false otherwise. +* +* @example +* const value1 = new File(["content"], "example.txt"); +* const value2 = {}; +* const value3 = new Blob(["content"], { type: "text/plain" }); +* +* console.log(isFile(value1)); // true +* console.log(isFile(value2)); // false +* console.log(isFile(value3)); // false +*/ +function isFile(x) { + if (typeof File === "undefined") return false; + return isBlob(x) && x instanceof File; +} +//#endregion +export { isFile }; diff --git a/node_modules/es-toolkit/dist/predicate/isFunction.d.mts b/node_modules/es-toolkit/dist/predicate/isFunction.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7b88ea73fd076f19a3216453da3a5dc9b05da5f9 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isFunction.d.mts @@ -0,0 +1,17 @@ +//#region src/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/predicate/isFunction.d.ts b/node_modules/es-toolkit/dist/predicate/isFunction.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7b88ea73fd076f19a3216453da3a5dc9b05da5f9 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isFunction.d.ts @@ -0,0 +1,17 @@ +//#region src/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/predicate/isFunction.js b/node_modules/es-toolkit/dist/predicate/isFunction.js new file mode 100644 index 0000000000000000000000000000000000000000..8a96e36d33bd2461e68b1ac821d356f0f81d7676 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isFunction.js @@ -0,0 +1,19 @@ +//#region src/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/predicate/isFunction.mjs b/node_modules/es-toolkit/dist/predicate/isFunction.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d31b610242cb6c973021d339fce4c93c0e068948 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isFunction.mjs @@ -0,0 +1,19 @@ +//#region src/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/predicate/isIterable.d.mts b/node_modules/es-toolkit/dist/predicate/isIterable.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..95953579fa33b9950cc89cef9be7ea5cdadbaad3 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isIterable.d.mts @@ -0,0 +1,26 @@ +//#region src/predicate/isIterable.d.ts +/** + * Checks if a value is iterable, i.e. it implements the iterable protocol by + * providing a `Symbol.iterator` method. + * + * Arrays, strings, `Set`, `Map`, typed arrays, and generators are iterable; + * plain objects, `null`, and `undefined` are not. + * + * This function can be used as a TypeScript type predicate to narrow the type of + * `value` to `Iterable`. + * + * @param value - The value to check. + * @returns `true` if `value` is iterable, `false` otherwise. + * + * @example + * isIterable([1, 2, 3]); // true + * isIterable('abc'); // true + * isIterable(new Set([1, 2, 3])); // true + * isIterable(new Map()); // true + * isIterable({ a: 1 }); // false + * isIterable(123); // false + * isIterable(null); // false + */ +declare function isIterable(value: unknown): value is Iterable; +//#endregion +export { isIterable }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isIterable.d.ts b/node_modules/es-toolkit/dist/predicate/isIterable.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..95953579fa33b9950cc89cef9be7ea5cdadbaad3 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isIterable.d.ts @@ -0,0 +1,26 @@ +//#region src/predicate/isIterable.d.ts +/** + * Checks if a value is iterable, i.e. it implements the iterable protocol by + * providing a `Symbol.iterator` method. + * + * Arrays, strings, `Set`, `Map`, typed arrays, and generators are iterable; + * plain objects, `null`, and `undefined` are not. + * + * This function can be used as a TypeScript type predicate to narrow the type of + * `value` to `Iterable`. + * + * @param value - The value to check. + * @returns `true` if `value` is iterable, `false` otherwise. + * + * @example + * isIterable([1, 2, 3]); // true + * isIterable('abc'); // true + * isIterable(new Set([1, 2, 3])); // true + * isIterable(new Map()); // true + * isIterable({ a: 1 }); // false + * isIterable(123); // false + * isIterable(null); // false + */ +declare function isIterable(value: unknown): value is Iterable; +//#endregion +export { isIterable }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isIterable.js b/node_modules/es-toolkit/dist/predicate/isIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..bd493a7a253c0d9b60d68f1c7c2086b2f31908d1 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isIterable.js @@ -0,0 +1,28 @@ +//#region src/predicate/isIterable.ts +/** +* Checks if a value is iterable, i.e. it implements the iterable protocol by +* providing a `Symbol.iterator` method. +* +* Arrays, strings, `Set`, `Map`, typed arrays, and generators are iterable; +* plain objects, `null`, and `undefined` are not. +* +* This function can be used as a TypeScript type predicate to narrow the type of +* `value` to `Iterable`. +* +* @param value - The value to check. +* @returns `true` if `value` is iterable, `false` otherwise. +* +* @example +* isIterable([1, 2, 3]); // true +* isIterable('abc'); // true +* isIterable(new Set([1, 2, 3])); // true +* isIterable(new Map()); // true +* isIterable({ a: 1 }); // false +* isIterable(123); // false +* isIterable(null); // false +*/ +function isIterable(value) { + return value != null && typeof value[Symbol.iterator] === "function"; +} +//#endregion +exports.isIterable = isIterable; diff --git a/node_modules/es-toolkit/dist/predicate/isIterable.mjs b/node_modules/es-toolkit/dist/predicate/isIterable.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4ffc4a0dcb5923c2e22fcbf75091de9f5c41d8b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isIterable.mjs @@ -0,0 +1,28 @@ +//#region src/predicate/isIterable.ts +/** +* Checks if a value is iterable, i.e. it implements the iterable protocol by +* providing a `Symbol.iterator` method. +* +* Arrays, strings, `Set`, `Map`, typed arrays, and generators are iterable; +* plain objects, `null`, and `undefined` are not. +* +* This function can be used as a TypeScript type predicate to narrow the type of +* `value` to `Iterable`. +* +* @param value - The value to check. +* @returns `true` if `value` is iterable, `false` otherwise. +* +* @example +* isIterable([1, 2, 3]); // true +* isIterable('abc'); // true +* isIterable(new Set([1, 2, 3])); // true +* isIterable(new Map()); // true +* isIterable({ a: 1 }); // false +* isIterable(123); // false +* isIterable(null); // false +*/ +function isIterable(value) { + return value != null && typeof value[Symbol.iterator] === "function"; +} +//#endregion +export { isIterable }; diff --git a/node_modules/es-toolkit/dist/predicate/isJSON.d.mts b/node_modules/es-toolkit/dist/predicate/isJSON.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a47c3d2ebe96c7db4016a888edc286adae85343b --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isJSON.d.mts @@ -0,0 +1,32 @@ +//#region src/predicate/isJSON.d.ts +/** + * Checks if a given value is a valid JSON string. + * + * A valid JSON string is one that can be successfully parsed using `JSON.parse()`. According to JSON + * specifications, valid JSON can represent: + * - Objects (with string keys and valid JSON values) + * - Arrays (containing valid JSON values) + * - Strings + * - Numbers + * - Booleans + * - null + * + * String values like `"null"`, `"true"`, `"false"`, and numeric strings (e.g., `"42"`) are considered + * valid JSON and will return true. + * + * This function serves as a type guard in TypeScript, narrowing the type of the argument to `string`. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a valid JSON string, else `false`. + * + * @example + * isJSON('{"name":"John","age":30}'); // true + * isJSON('[1,2,3]'); // true + * isJSON('true'); // true + * isJSON('invalid json'); // false + * isJSON({ name: 'John' }); // false (not a string) + * isJSON(null); // false (not a string) + */ +declare function isJSON(value: unknown): value is string; +//#endregion +export { isJSON }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isJSON.d.ts b/node_modules/es-toolkit/dist/predicate/isJSON.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a47c3d2ebe96c7db4016a888edc286adae85343b --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isJSON.d.ts @@ -0,0 +1,32 @@ +//#region src/predicate/isJSON.d.ts +/** + * Checks if a given value is a valid JSON string. + * + * A valid JSON string is one that can be successfully parsed using `JSON.parse()`. According to JSON + * specifications, valid JSON can represent: + * - Objects (with string keys and valid JSON values) + * - Arrays (containing valid JSON values) + * - Strings + * - Numbers + * - Booleans + * - null + * + * String values like `"null"`, `"true"`, `"false"`, and numeric strings (e.g., `"42"`) are considered + * valid JSON and will return true. + * + * This function serves as a type guard in TypeScript, narrowing the type of the argument to `string`. + * + * @param value The value to check. + * @returns Returns `true` if `value` is a valid JSON string, else `false`. + * + * @example + * isJSON('{"name":"John","age":30}'); // true + * isJSON('[1,2,3]'); // true + * isJSON('true'); // true + * isJSON('invalid json'); // false + * isJSON({ name: 'John' }); // false (not a string) + * isJSON(null); // false (not a string) + */ +declare function isJSON(value: unknown): value is string; +//#endregion +export { isJSON }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isJSON.js b/node_modules/es-toolkit/dist/predicate/isJSON.js new file mode 100644 index 0000000000000000000000000000000000000000..b8df028a0d9485320ce6574a3828cda1b0e3acd5 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isJSON.js @@ -0,0 +1,40 @@ +//#region src/predicate/isJSON.ts +/** +* Checks if a given value is a valid JSON string. +* +* A valid JSON string is one that can be successfully parsed using `JSON.parse()`. According to JSON +* specifications, valid JSON can represent: +* - Objects (with string keys and valid JSON values) +* - Arrays (containing valid JSON values) +* - Strings +* - Numbers +* - Booleans +* - null +* +* String values like `"null"`, `"true"`, `"false"`, and numeric strings (e.g., `"42"`) are considered +* valid JSON and will return true. +* +* This function serves as a type guard in TypeScript, narrowing the type of the argument to `string`. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a valid JSON string, else `false`. +* +* @example +* isJSON('{"name":"John","age":30}'); // true +* isJSON('[1,2,3]'); // true +* isJSON('true'); // true +* isJSON('invalid json'); // false +* isJSON({ name: 'John' }); // false (not a string) +* isJSON(null); // false (not a string) +*/ +function isJSON(value) { + if (typeof value !== "string") return false; + try { + JSON.parse(value); + return true; + } catch { + return false; + } +} +//#endregion +exports.isJSON = isJSON; diff --git a/node_modules/es-toolkit/dist/predicate/isJSON.mjs b/node_modules/es-toolkit/dist/predicate/isJSON.mjs new file mode 100644 index 0000000000000000000000000000000000000000..412949eed83044d3580282188f48b36935cbcebc --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isJSON.mjs @@ -0,0 +1,40 @@ +//#region src/predicate/isJSON.ts +/** +* Checks if a given value is a valid JSON string. +* +* A valid JSON string is one that can be successfully parsed using `JSON.parse()`. According to JSON +* specifications, valid JSON can represent: +* - Objects (with string keys and valid JSON values) +* - Arrays (containing valid JSON values) +* - Strings +* - Numbers +* - Booleans +* - null +* +* String values like `"null"`, `"true"`, `"false"`, and numeric strings (e.g., `"42"`) are considered +* valid JSON and will return true. +* +* This function serves as a type guard in TypeScript, narrowing the type of the argument to `string`. +* +* @param value The value to check. +* @returns Returns `true` if `value` is a valid JSON string, else `false`. +* +* @example +* isJSON('{"name":"John","age":30}'); // true +* isJSON('[1,2,3]'); // true +* isJSON('true'); // true +* isJSON('invalid json'); // false +* isJSON({ name: 'John' }); // false (not a string) +* isJSON(null); // false (not a string) +*/ +function isJSON(value) { + if (typeof value !== "string") return false; + try { + JSON.parse(value); + return true; + } catch { + return false; + } +} +//#endregion +export { isJSON }; diff --git a/node_modules/es-toolkit/dist/predicate/isJSONValue.d.mts b/node_modules/es-toolkit/dist/predicate/isJSONValue.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..11a6efe6a7219331b1c9359c82a80e995aca5c4f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isJSONValue.d.mts @@ -0,0 +1,57 @@ +//#region src/predicate/isJSONValue.d.ts +/** + * Checks if a given value is a valid JSON value. + * + * A valid JSON value can be: + * - null + * - a JSON object (an object with string keys and valid JSON values) + * - a JSON array (an array of valid JSON values) + * - a string + * - a number + * - a boolean + * + * @param value - The value to check. + * @returns True if the value is a valid JSON value, otherwise false. + * + * @example + * console.log(isJSONValue(null)); // true + * console.log(isJSONValue({ key: "value" })); // true + * console.log(isJSONValue([1, 2, 3])); // true + * console.log(isJSONValue("Hello")); // true + * console.log(isJSONValue(42)); // true + * console.log(isJSONValue(true)); // true + * console.log(isJSONValue(undefined)); // false + * console.log(isJSONValue(() => {})); // false + */ +declare function isJSONValue(value: unknown): value is Record | any[] | string | number | boolean | null; +/** + * Checks if a given value is a valid JSON array. + * + * A valid JSON array is defined as an array where all items are valid JSON values. + * + * @param value - The value to check. + * @returns True if the value is a valid JSON array, otherwise false. + * + * @example + * console.log(isJSONArray([1, 2, 3])); // true + * console.log(isJSONArray(["string", null, true])); // true + * console.log(isJSONArray([1, 2, () => {}])); // false + * console.log(isJSONArray("not an array")); // false + */ +declare function isJSONArray(value: unknown): value is any[]; +/** + * Checks if a value is a JSON object. + * + * A valid JSON object is defined as an object with string keys and valid JSON values. + * + * @param obj The value to check. + * @returns True if `obj` is a JSON object, false otherwise. + * + * @example + * isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', null: null } }); // true + * isJSONObject({ regexp: /test/ }); // false + * isJSONObject(123); // false + */ +declare function isJSONObject(obj: unknown): obj is Record; +//#endregion +export { isJSONArray, isJSONObject, isJSONValue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isJSONValue.d.ts b/node_modules/es-toolkit/dist/predicate/isJSONValue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..11a6efe6a7219331b1c9359c82a80e995aca5c4f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isJSONValue.d.ts @@ -0,0 +1,57 @@ +//#region src/predicate/isJSONValue.d.ts +/** + * Checks if a given value is a valid JSON value. + * + * A valid JSON value can be: + * - null + * - a JSON object (an object with string keys and valid JSON values) + * - a JSON array (an array of valid JSON values) + * - a string + * - a number + * - a boolean + * + * @param value - The value to check. + * @returns True if the value is a valid JSON value, otherwise false. + * + * @example + * console.log(isJSONValue(null)); // true + * console.log(isJSONValue({ key: "value" })); // true + * console.log(isJSONValue([1, 2, 3])); // true + * console.log(isJSONValue("Hello")); // true + * console.log(isJSONValue(42)); // true + * console.log(isJSONValue(true)); // true + * console.log(isJSONValue(undefined)); // false + * console.log(isJSONValue(() => {})); // false + */ +declare function isJSONValue(value: unknown): value is Record | any[] | string | number | boolean | null; +/** + * Checks if a given value is a valid JSON array. + * + * A valid JSON array is defined as an array where all items are valid JSON values. + * + * @param value - The value to check. + * @returns True if the value is a valid JSON array, otherwise false. + * + * @example + * console.log(isJSONArray([1, 2, 3])); // true + * console.log(isJSONArray(["string", null, true])); // true + * console.log(isJSONArray([1, 2, () => {}])); // false + * console.log(isJSONArray("not an array")); // false + */ +declare function isJSONArray(value: unknown): value is any[]; +/** + * Checks if a value is a JSON object. + * + * A valid JSON object is defined as an object with string keys and valid JSON values. + * + * @param obj The value to check. + * @returns True if `obj` is a JSON object, false otherwise. + * + * @example + * isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', null: null } }); // true + * isJSONObject({ regexp: /test/ }); // false + * isJSONObject(123); // false + */ +declare function isJSONObject(obj: unknown): obj is Record; +//#endregion +export { isJSONArray, isJSONObject, isJSONValue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isJSONValue.js b/node_modules/es-toolkit/dist/predicate/isJSONValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e2f2c65fe355963dd1b8c519d3148597117b8005 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isJSONValue.js @@ -0,0 +1,85 @@ +const require_isPlainObject = require("./isPlainObject.js"); +//#region src/predicate/isJSONValue.ts +/** +* The functions isJSONValue, isJSONArray, and isJSONObject are grouped in this file +* to prevent any circular dependency issues. +*/ +/** +* Checks if a given value is a valid JSON value. +* +* A valid JSON value can be: +* - null +* - a JSON object (an object with string keys and valid JSON values) +* - a JSON array (an array of valid JSON values) +* - a string +* - a number +* - a boolean +* +* @param value - The value to check. +* @returns True if the value is a valid JSON value, otherwise false. +* +* @example +* console.log(isJSONValue(null)); // true +* console.log(isJSONValue({ key: "value" })); // true +* console.log(isJSONValue([1, 2, 3])); // true +* console.log(isJSONValue("Hello")); // true +* console.log(isJSONValue(42)); // true +* console.log(isJSONValue(true)); // true +* console.log(isJSONValue(undefined)); // false +* console.log(isJSONValue(() => {})); // false +*/ +function isJSONValue(value) { + switch (typeof value) { + case "object": return value === null || isJSONArray(value) || isJSONObject(value); + case "string": + case "number": + case "boolean": return true; + default: return false; + } +} +/** +* Checks if a given value is a valid JSON array. +* +* A valid JSON array is defined as an array where all items are valid JSON values. +* +* @param value - The value to check. +* @returns True if the value is a valid JSON array, otherwise false. +* +* @example +* console.log(isJSONArray([1, 2, 3])); // true +* console.log(isJSONArray(["string", null, true])); // true +* console.log(isJSONArray([1, 2, () => {}])); // false +* console.log(isJSONArray("not an array")); // false +*/ +function isJSONArray(value) { + if (!Array.isArray(value)) return false; + return value.every((item) => isJSONValue(item)); +} +/** +* Checks if a value is a JSON object. +* +* A valid JSON object is defined as an object with string keys and valid JSON values. +* +* @param obj The value to check. +* @returns True if `obj` is a JSON object, false otherwise. +* +* @example +* isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', null: null } }); // true +* isJSONObject({ regexp: /test/ }); // false +* isJSONObject(123); // false +*/ +function isJSONObject(obj) { + if (!require_isPlainObject.isPlainObject(obj)) return false; + const keys = Reflect.ownKeys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = obj[key]; + if (typeof key !== "string") return false; + if (!isJSONValue(value)) return false; + } + return true; +} +//#endregion +exports.isJSONArray = isJSONArray; +exports.isJSONObject = isJSONObject; +exports.isJSONValue = isJSONValue; diff --git a/node_modules/es-toolkit/dist/predicate/isJSONValue.mjs b/node_modules/es-toolkit/dist/predicate/isJSONValue.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1a11f8afa5b0109997ee77a67893ed375e106a37 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isJSONValue.mjs @@ -0,0 +1,83 @@ +import { isPlainObject } from "./isPlainObject.mjs"; +//#region src/predicate/isJSONValue.ts +/** +* The functions isJSONValue, isJSONArray, and isJSONObject are grouped in this file +* to prevent any circular dependency issues. +*/ +/** +* Checks if a given value is a valid JSON value. +* +* A valid JSON value can be: +* - null +* - a JSON object (an object with string keys and valid JSON values) +* - a JSON array (an array of valid JSON values) +* - a string +* - a number +* - a boolean +* +* @param value - The value to check. +* @returns True if the value is a valid JSON value, otherwise false. +* +* @example +* console.log(isJSONValue(null)); // true +* console.log(isJSONValue({ key: "value" })); // true +* console.log(isJSONValue([1, 2, 3])); // true +* console.log(isJSONValue("Hello")); // true +* console.log(isJSONValue(42)); // true +* console.log(isJSONValue(true)); // true +* console.log(isJSONValue(undefined)); // false +* console.log(isJSONValue(() => {})); // false +*/ +function isJSONValue(value) { + switch (typeof value) { + case "object": return value === null || isJSONArray(value) || isJSONObject(value); + case "string": + case "number": + case "boolean": return true; + default: return false; + } +} +/** +* Checks if a given value is a valid JSON array. +* +* A valid JSON array is defined as an array where all items are valid JSON values. +* +* @param value - The value to check. +* @returns True if the value is a valid JSON array, otherwise false. +* +* @example +* console.log(isJSONArray([1, 2, 3])); // true +* console.log(isJSONArray(["string", null, true])); // true +* console.log(isJSONArray([1, 2, () => {}])); // false +* console.log(isJSONArray("not an array")); // false +*/ +function isJSONArray(value) { + if (!Array.isArray(value)) return false; + return value.every((item) => isJSONValue(item)); +} +/** +* Checks if a value is a JSON object. +* +* A valid JSON object is defined as an object with string keys and valid JSON values. +* +* @param obj The value to check. +* @returns True if `obj` is a JSON object, false otherwise. +* +* @example +* isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', null: null } }); // true +* isJSONObject({ regexp: /test/ }); // false +* isJSONObject(123); // false +*/ +function isJSONObject(obj) { + if (!isPlainObject(obj)) return false; + const keys = Reflect.ownKeys(obj); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const value = obj[key]; + if (typeof key !== "string") return false; + if (!isJSONValue(value)) return false; + } + return true; +} +//#endregion +export { isJSONArray, isJSONObject, isJSONValue }; diff --git a/node_modules/es-toolkit/dist/predicate/isLength.d.mts b/node_modules/es-toolkit/dist/predicate/isLength.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..812d0dc5a79f5087412ba0cc2b989e8815d7516f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isLength.d.mts @@ -0,0 +1,25 @@ +//#region src/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/predicate/isLength.d.ts b/node_modules/es-toolkit/dist/predicate/isLength.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..812d0dc5a79f5087412ba0cc2b989e8815d7516f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isLength.d.ts @@ -0,0 +1,25 @@ +//#region src/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/predicate/isLength.js b/node_modules/es-toolkit/dist/predicate/isLength.js new file mode 100644 index 0000000000000000000000000000000000000000..6d14c10a7bebe8f7cb7d0d5020911a3de41444c4 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isLength.js @@ -0,0 +1,27 @@ +//#region src/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/predicate/isLength.mjs b/node_modules/es-toolkit/dist/predicate/isLength.mjs new file mode 100644 index 0000000000000000000000000000000000000000..76d539196bd9275d3fedb67341521b8c6cd7083b --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isLength.mjs @@ -0,0 +1,27 @@ +//#region src/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/predicate/isMap.d.mts b/node_modules/es-toolkit/dist/predicate/isMap.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1aa4b18e71a4294d6bce488876ec9cc076f548d2 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isMap.d.mts @@ -0,0 +1,21 @@ +//#region src/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: unknown): value is Map; +//#endregion +export { isMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isMap.d.ts b/node_modules/es-toolkit/dist/predicate/isMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1aa4b18e71a4294d6bce488876ec9cc076f548d2 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isMap.d.ts @@ -0,0 +1,21 @@ +//#region src/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: unknown): value is Map; +//#endregion +export { isMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isMap.js b/node_modules/es-toolkit/dist/predicate/isMap.js new file mode 100644 index 0000000000000000000000000000000000000000..260c551f3ded8fcc1e8207d539d13d5ecbd47102 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isMap.js @@ -0,0 +1,23 @@ +//#region src/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 value instanceof Map; +} +//#endregion +exports.isMap = isMap; diff --git a/node_modules/es-toolkit/dist/predicate/isMap.mjs b/node_modules/es-toolkit/dist/predicate/isMap.mjs new file mode 100644 index 0000000000000000000000000000000000000000..532d25c9099be77ab81acdbaae604d800693a003 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isMap.mjs @@ -0,0 +1,23 @@ +//#region src/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 value instanceof Map; +} +//#endregion +export { isMap }; diff --git a/node_modules/es-toolkit/dist/predicate/isNil.d.mts b/node_modules/es-toolkit/dist/predicate/isNil.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9b1ea56e0ffa5f006ee05590a58ee28526e90d3e --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNil.d.mts @@ -0,0 +1,23 @@ +//#region src/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: unknown): x is null | undefined; +//#endregion +export { isNil }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNil.d.ts b/node_modules/es-toolkit/dist/predicate/isNil.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b1ea56e0ffa5f006ee05590a58ee28526e90d3e --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNil.d.ts @@ -0,0 +1,23 @@ +//#region src/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: unknown): x is null | undefined; +//#endregion +export { isNil }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNil.js b/node_modules/es-toolkit/dist/predicate/isNil.js new file mode 100644 index 0000000000000000000000000000000000000000..b765d138fa08b09ca0d4e5684f4ba82df2795f38 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNil.js @@ -0,0 +1,25 @@ +//#region src/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/predicate/isNil.mjs b/node_modules/es-toolkit/dist/predicate/isNil.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4b1aaed175bccccaffca3bb23a6236c0de15aa4a --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNil.mjs @@ -0,0 +1,25 @@ +//#region src/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/predicate/isNode.d.mts b/node_modules/es-toolkit/dist/predicate/isNode.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..61d9eb343292261c63788d2996145103ef228f7b --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNode.d.mts @@ -0,0 +1,18 @@ +//#region src/predicate/isNode.d.ts +/** + * Checks if the current environment is Node.js. + * + * This function checks for the existence of the `process.versions.node` property, + * which only exists in Node.js environments. + * + * @returns `true` if the current environment is Node.js, otherwise `false`. + * + * @example + * if (isNode()) { + * console.log('This is running in Node.js'); + * const fs = import('node:fs'); + * } + */ +declare function isNode(): boolean; +//#endregion +export { isNode }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNode.d.ts b/node_modules/es-toolkit/dist/predicate/isNode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..61d9eb343292261c63788d2996145103ef228f7b --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNode.d.ts @@ -0,0 +1,18 @@ +//#region src/predicate/isNode.d.ts +/** + * Checks if the current environment is Node.js. + * + * This function checks for the existence of the `process.versions.node` property, + * which only exists in Node.js environments. + * + * @returns `true` if the current environment is Node.js, otherwise `false`. + * + * @example + * if (isNode()) { + * console.log('This is running in Node.js'); + * const fs = import('node:fs'); + * } + */ +declare function isNode(): boolean; +//#endregion +export { isNode }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNode.js b/node_modules/es-toolkit/dist/predicate/isNode.js new file mode 100644 index 0000000000000000000000000000000000000000..4be82268918cd4e730e7f3cec9a56c8651764a99 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNode.js @@ -0,0 +1,20 @@ +//#region src/predicate/isNode.ts +/** +* Checks if the current environment is Node.js. +* +* This function checks for the existence of the `process.versions.node` property, +* which only exists in Node.js environments. +* +* @returns `true` if the current environment is Node.js, otherwise `false`. +* +* @example +* if (isNode()) { +* console.log('This is running in Node.js'); +* const fs = import('node:fs'); +* } +*/ +function isNode() { + return typeof process !== "undefined" && process?.versions?.node != null; +} +//#endregion +exports.isNode = isNode; diff --git a/node_modules/es-toolkit/dist/predicate/isNode.mjs b/node_modules/es-toolkit/dist/predicate/isNode.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bc9f76f7f81f481d6d028f3fb9223eae18336d2d --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNode.mjs @@ -0,0 +1,20 @@ +//#region src/predicate/isNode.ts +/** +* Checks if the current environment is Node.js. +* +* This function checks for the existence of the `process.versions.node` property, +* which only exists in Node.js environments. +* +* @returns `true` if the current environment is Node.js, otherwise `false`. +* +* @example +* if (isNode()) { +* console.log('This is running in Node.js'); +* const fs = import('node:fs'); +* } +*/ +function isNode() { + return typeof process !== "undefined" && process?.versions?.node != null; +} +//#endregion +export { isNode }; diff --git a/node_modules/es-toolkit/dist/predicate/isNotNil.d.mts b/node_modules/es-toolkit/dist/predicate/isNotNil.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..49d04a1eaac3d145917120fc829e228209462f76 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNotNil.d.mts @@ -0,0 +1,20 @@ +//#region src/predicate/isNotNil.d.ts +/** + * Checks if the given value is not null nor undefined. + * + * The main use of this function is to be used with TypeScript as a type predicate. + * + * @template T - The type of value. + * @param x - The value to test if it is not null nor undefined. + * @returns True if the value is not null nor undefined, false otherwise. + * + * @example + * // Here the type of `arr` is (number | undefined)[] + * const arr = [1, undefined, 3]; + * // Here the type of `result` is number[] + * const result = arr.filter(isNotNil); + * // result will be [1, 3] + */ +declare function isNotNil(x: T | null | undefined): x is T; +//#endregion +export { isNotNil }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNotNil.d.ts b/node_modules/es-toolkit/dist/predicate/isNotNil.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..49d04a1eaac3d145917120fc829e228209462f76 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNotNil.d.ts @@ -0,0 +1,20 @@ +//#region src/predicate/isNotNil.d.ts +/** + * Checks if the given value is not null nor undefined. + * + * The main use of this function is to be used with TypeScript as a type predicate. + * + * @template T - The type of value. + * @param x - The value to test if it is not null nor undefined. + * @returns True if the value is not null nor undefined, false otherwise. + * + * @example + * // Here the type of `arr` is (number | undefined)[] + * const arr = [1, undefined, 3]; + * // Here the type of `result` is number[] + * const result = arr.filter(isNotNil); + * // result will be [1, 3] + */ +declare function isNotNil(x: T | null | undefined): x is T; +//#endregion +export { isNotNil }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNotNil.js b/node_modules/es-toolkit/dist/predicate/isNotNil.js new file mode 100644 index 0000000000000000000000000000000000000000..d894c593e58eef72473b3135975fb70570d21461 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNotNil.js @@ -0,0 +1,22 @@ +//#region src/predicate/isNotNil.ts +/** +* Checks if the given value is not null nor undefined. +* +* The main use of this function is to be used with TypeScript as a type predicate. +* +* @template T - The type of value. +* @param x - The value to test if it is not null nor undefined. +* @returns True if the value is not null nor undefined, false otherwise. +* +* @example +* // Here the type of `arr` is (number | undefined)[] +* const arr = [1, undefined, 3]; +* // Here the type of `result` is number[] +* const result = arr.filter(isNotNil); +* // result will be [1, 3] +*/ +function isNotNil(x) { + return x != null; +} +//#endregion +exports.isNotNil = isNotNil; diff --git a/node_modules/es-toolkit/dist/predicate/isNotNil.mjs b/node_modules/es-toolkit/dist/predicate/isNotNil.mjs new file mode 100644 index 0000000000000000000000000000000000000000..21e0d983c1f27e122569f4f4af5881b1738e2fbb --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNotNil.mjs @@ -0,0 +1,22 @@ +//#region src/predicate/isNotNil.ts +/** +* Checks if the given value is not null nor undefined. +* +* The main use of this function is to be used with TypeScript as a type predicate. +* +* @template T - The type of value. +* @param x - The value to test if it is not null nor undefined. +* @returns True if the value is not null nor undefined, false otherwise. +* +* @example +* // Here the type of `arr` is (number | undefined)[] +* const arr = [1, undefined, 3]; +* // Here the type of `result` is number[] +* const result = arr.filter(isNotNil); +* // result will be [1, 3] +*/ +function isNotNil(x) { + return x != null; +} +//#endregion +export { isNotNil }; diff --git a/node_modules/es-toolkit/dist/predicate/isNull.d.mts b/node_modules/es-toolkit/dist/predicate/isNull.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a960126a665b966cbe8814eb992241e3b1c2154f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNull.d.mts @@ -0,0 +1,24 @@ +//#region src/predicate/isNull.d.ts +/** + * Checks if the given value is null. + * + * This function tests whether the provided value is strictly equal to `null`. + * It returns `true` if the value is `null`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`. + * + * @param x - The value to test if it is null. + * @returns True if the value is null, false otherwise. + * + * @example + * const value1 = null; + * const value2 = undefined; + * const value3 = 42; + * + * console.log(isNull(value1)); // true + * console.log(isNull(value2)); // false + * console.log(isNull(value3)); // false + */ +declare function isNull(x: unknown): x is null; +//#endregion +export { isNull }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNull.d.ts b/node_modules/es-toolkit/dist/predicate/isNull.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a960126a665b966cbe8814eb992241e3b1c2154f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNull.d.ts @@ -0,0 +1,24 @@ +//#region src/predicate/isNull.d.ts +/** + * Checks if the given value is null. + * + * This function tests whether the provided value is strictly equal to `null`. + * It returns `true` if the value is `null`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`. + * + * @param x - The value to test if it is null. + * @returns True if the value is null, false otherwise. + * + * @example + * const value1 = null; + * const value2 = undefined; + * const value3 = 42; + * + * console.log(isNull(value1)); // true + * console.log(isNull(value2)); // false + * console.log(isNull(value3)); // false + */ +declare function isNull(x: unknown): x is null; +//#endregion +export { isNull }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNull.js b/node_modules/es-toolkit/dist/predicate/isNull.js new file mode 100644 index 0000000000000000000000000000000000000000..fc34393a53c91d0598c82c6cd9f5830f2519bfaa --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNull.js @@ -0,0 +1,26 @@ +//#region src/predicate/isNull.ts +/** +* Checks if the given value is null. +* +* This function tests whether the provided value is strictly equal to `null`. +* It returns `true` if the value is `null`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`. +* +* @param x - The value to test if it is null. +* @returns True if the value is null, false otherwise. +* +* @example +* const value1 = null; +* const value2 = undefined; +* const value3 = 42; +* +* console.log(isNull(value1)); // true +* console.log(isNull(value2)); // false +* console.log(isNull(value3)); // false +*/ +function isNull(x) { + return x === null; +} +//#endregion +exports.isNull = isNull; diff --git a/node_modules/es-toolkit/dist/predicate/isNull.mjs b/node_modules/es-toolkit/dist/predicate/isNull.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bc29ee8007ed33c16e7ae0cdd2fde45e1d4e4c1d --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNull.mjs @@ -0,0 +1,26 @@ +//#region src/predicate/isNull.ts +/** +* Checks if the given value is null. +* +* This function tests whether the provided value is strictly equal to `null`. +* It returns `true` if the value is `null`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`. +* +* @param x - The value to test if it is null. +* @returns True if the value is null, false otherwise. +* +* @example +* const value1 = null; +* const value2 = undefined; +* const value3 = 42; +* +* console.log(isNull(value1)); // true +* console.log(isNull(value2)); // false +* console.log(isNull(value3)); // false +*/ +function isNull(x) { + return x === null; +} +//#endregion +export { isNull }; diff --git a/node_modules/es-toolkit/dist/predicate/isNumber.d.mts b/node_modules/es-toolkit/dist/predicate/isNumber.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c54b10b0ec4d6cfad8e57b90bb0e8f550bbbbedb --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNumber.d.mts @@ -0,0 +1,28 @@ +//#region src/predicate/isNumber.d.ts +/** + * Checks if the given value is a number. + * + * This function tests whether the provided value is strictly a `number`. + * It returns `true` if the value is a `number`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. + * + * @param x - The value to test if it is a number. + * @returns True if the value is a number, false otherwise. + * + * @example + * + * const value1 = 123; + * const value2 = 'abc'; + * const value3 = true; + * const value4 = new Number(42); + * + * console.log(isNumber(value1)); // true + * console.log(isNumber(value2)); // false + * console.log(isNumber(value3)); // false + * console.log(isNumber(value4)); // false + * + */ +declare function isNumber(x: unknown): x is number; +//#endregion +export { isNumber }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNumber.d.ts b/node_modules/es-toolkit/dist/predicate/isNumber.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c54b10b0ec4d6cfad8e57b90bb0e8f550bbbbedb --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNumber.d.ts @@ -0,0 +1,28 @@ +//#region src/predicate/isNumber.d.ts +/** + * Checks if the given value is a number. + * + * This function tests whether the provided value is strictly a `number`. + * It returns `true` if the value is a `number`, and `false` otherwise. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. + * + * @param x - The value to test if it is a number. + * @returns True if the value is a number, false otherwise. + * + * @example + * + * const value1 = 123; + * const value2 = 'abc'; + * const value3 = true; + * const value4 = new Number(42); + * + * console.log(isNumber(value1)); // true + * console.log(isNumber(value2)); // false + * console.log(isNumber(value3)); // false + * console.log(isNumber(value4)); // false + * + */ +declare function isNumber(x: unknown): x is number; +//#endregion +export { isNumber }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isNumber.js b/node_modules/es-toolkit/dist/predicate/isNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..db517a60d1cf86d26dc24556487ecc6c26c8e217 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNumber.js @@ -0,0 +1,30 @@ +//#region src/predicate/isNumber.ts +/** +* Checks if the given value is a number. +* +* This function tests whether the provided value is strictly a `number`. +* It returns `true` if the value is a `number`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. +* +* @param x - The value to test if it is a number. +* @returns True if the value is a number, false otherwise. +* +* @example +* +* const value1 = 123; +* const value2 = 'abc'; +* const value3 = true; +* const value4 = new Number(42); +* +* console.log(isNumber(value1)); // true +* console.log(isNumber(value2)); // false +* console.log(isNumber(value3)); // false +* console.log(isNumber(value4)); // false +* +*/ +function isNumber(x) { + return typeof x === "number"; +} +//#endregion +exports.isNumber = isNumber; diff --git a/node_modules/es-toolkit/dist/predicate/isNumber.mjs b/node_modules/es-toolkit/dist/predicate/isNumber.mjs new file mode 100644 index 0000000000000000000000000000000000000000..782c33243f0f5c15b137626a09122f76c42c5ac6 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isNumber.mjs @@ -0,0 +1,30 @@ +//#region src/predicate/isNumber.ts +/** +* Checks if the given value is a number. +* +* This function tests whether the provided value is strictly a `number`. +* It returns `true` if the value is a `number`, and `false` otherwise. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`. +* +* @param x - The value to test if it is a number. +* @returns True if the value is a number, false otherwise. +* +* @example +* +* const value1 = 123; +* const value2 = 'abc'; +* const value3 = true; +* const value4 = new Number(42); +* +* console.log(isNumber(value1)); // true +* console.log(isNumber(value2)); // false +* console.log(isNumber(value3)); // false +* console.log(isNumber(value4)); // false +* +*/ +function isNumber(x) { + return typeof x === "number"; +} +//#endregion +export { isNumber }; diff --git a/node_modules/es-toolkit/dist/predicate/isPlainObject.d.mts b/node_modules/es-toolkit/dist/predicate/isPlainObject.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..82a1273ef98cad871c88b540f0760628e84265fe --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPlainObject.d.mts @@ -0,0 +1,46 @@ +//#region src/predicate/isPlainObject.d.ts +/** + * Checks if a given value is a plain object. + * + * @param value - The value to check. + * @returns True if the value is a plain object, otherwise false. + * + * @example + * ```typescript + * // ✅👇 True + * + * isPlainObject({ }); // ✅ + * isPlainObject({ key: 'value' }); // ✅ + * isPlainObject({ key: new Date() }); // ✅ + * isPlainObject(new Object()); // ✅ + * isPlainObject(Object.create(null)); // ✅ + * isPlainObject({ nested: { key: true} }); // ✅ + * isPlainObject(new Proxy({}, {})); // ✅ + * isPlainObject({ [Symbol('tag')]: 'A' }); // ✅ + * + * // ✅👇 (cross-realms, node context, workers, ...) + * const runInNewContext = await import('node:vm').then( + * (mod) => mod.runInNewContext + * ); + * isPlainObject(runInNewContext('({})')); // ✅ + * + * // ❌👇 False + * + * class Test { }; + * isPlainObject(new Test()) // ❌ + * isPlainObject(10); // ❌ + * isPlainObject(null); // ❌ + * isPlainObject('hello'); // ❌ + * isPlainObject([]); // ❌ + * isPlainObject(new Date()); // ❌ + * isPlainObject(new Uint8Array([1])); // ❌ + * isPlainObject(Buffer.from('ABC')); // ❌ + * isPlainObject(Promise.resolve({})); // ❌ + * isPlainObject(Object.create({})); // ❌ + * isPlainObject(new (class Cls {})); // ❌ + * isPlainObject(globalThis); // ❌, + * ``` + */ +declare function isPlainObject(value: unknown): value is Record; +//#endregion +export { isPlainObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isPlainObject.d.ts b/node_modules/es-toolkit/dist/predicate/isPlainObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..82a1273ef98cad871c88b540f0760628e84265fe --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPlainObject.d.ts @@ -0,0 +1,46 @@ +//#region src/predicate/isPlainObject.d.ts +/** + * Checks if a given value is a plain object. + * + * @param value - The value to check. + * @returns True if the value is a plain object, otherwise false. + * + * @example + * ```typescript + * // ✅👇 True + * + * isPlainObject({ }); // ✅ + * isPlainObject({ key: 'value' }); // ✅ + * isPlainObject({ key: new Date() }); // ✅ + * isPlainObject(new Object()); // ✅ + * isPlainObject(Object.create(null)); // ✅ + * isPlainObject({ nested: { key: true} }); // ✅ + * isPlainObject(new Proxy({}, {})); // ✅ + * isPlainObject({ [Symbol('tag')]: 'A' }); // ✅ + * + * // ✅👇 (cross-realms, node context, workers, ...) + * const runInNewContext = await import('node:vm').then( + * (mod) => mod.runInNewContext + * ); + * isPlainObject(runInNewContext('({})')); // ✅ + * + * // ❌👇 False + * + * class Test { }; + * isPlainObject(new Test()) // ❌ + * isPlainObject(10); // ❌ + * isPlainObject(null); // ❌ + * isPlainObject('hello'); // ❌ + * isPlainObject([]); // ❌ + * isPlainObject(new Date()); // ❌ + * isPlainObject(new Uint8Array([1])); // ❌ + * isPlainObject(Buffer.from('ABC')); // ❌ + * isPlainObject(Promise.resolve({})); // ❌ + * isPlainObject(Object.create({})); // ❌ + * isPlainObject(new (class Cls {})); // ❌ + * isPlainObject(globalThis); // ❌, + * ``` + */ +declare function isPlainObject(value: unknown): value is Record; +//#endregion +export { isPlainObject }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isPlainObject.js b/node_modules/es-toolkit/dist/predicate/isPlainObject.js new file mode 100644 index 0000000000000000000000000000000000000000..80e29a8a6dcc26bea9fa88d4a062798628bd7a23 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPlainObject.js @@ -0,0 +1,51 @@ +//#region src/predicate/isPlainObject.ts +/** +* Checks if a given value is a plain object. +* +* @param value - The value to check. +* @returns True if the value is a plain object, otherwise false. +* +* @example +* ```typescript +* // ✅👇 True +* +* isPlainObject({ }); // ✅ +* isPlainObject({ key: 'value' }); // ✅ +* isPlainObject({ key: new Date() }); // ✅ +* isPlainObject(new Object()); // ✅ +* isPlainObject(Object.create(null)); // ✅ +* isPlainObject({ nested: { key: true} }); // ✅ +* isPlainObject(new Proxy({}, {})); // ✅ +* isPlainObject({ [Symbol('tag')]: 'A' }); // ✅ +* +* // ✅👇 (cross-realms, node context, workers, ...) +* const runInNewContext = await import('node:vm').then( +* (mod) => mod.runInNewContext +* ); +* isPlainObject(runInNewContext('({})')); // ✅ +* +* // ❌👇 False +* +* class Test { }; +* isPlainObject(new Test()) // ❌ +* isPlainObject(10); // ❌ +* isPlainObject(null); // ❌ +* isPlainObject('hello'); // ❌ +* isPlainObject([]); // ❌ +* isPlainObject(new Date()); // ❌ +* isPlainObject(new Uint8Array([1])); // ❌ +* isPlainObject(Buffer.from('ABC')); // ❌ +* isPlainObject(Promise.resolve({})); // ❌ +* isPlainObject(Object.create({})); // ❌ +* isPlainObject(new (class Cls {})); // ❌ +* isPlainObject(globalThis); // ❌, +* ``` +*/ +function isPlainObject(value) { + if (!value || typeof value !== "object") return false; + const proto = Object.getPrototypeOf(value); + if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false; + return Object.prototype.toString.call(value) === "[object Object]"; +} +//#endregion +exports.isPlainObject = isPlainObject; diff --git a/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs b/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs new file mode 100644 index 0000000000000000000000000000000000000000..88956643259a4e67d89b12d8f76164ee65d85582 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs @@ -0,0 +1,51 @@ +//#region src/predicate/isPlainObject.ts +/** +* Checks if a given value is a plain object. +* +* @param value - The value to check. +* @returns True if the value is a plain object, otherwise false. +* +* @example +* ```typescript +* // ✅👇 True +* +* isPlainObject({ }); // ✅ +* isPlainObject({ key: 'value' }); // ✅ +* isPlainObject({ key: new Date() }); // ✅ +* isPlainObject(new Object()); // ✅ +* isPlainObject(Object.create(null)); // ✅ +* isPlainObject({ nested: { key: true} }); // ✅ +* isPlainObject(new Proxy({}, {})); // ✅ +* isPlainObject({ [Symbol('tag')]: 'A' }); // ✅ +* +* // ✅👇 (cross-realms, node context, workers, ...) +* const runInNewContext = await import('node:vm').then( +* (mod) => mod.runInNewContext +* ); +* isPlainObject(runInNewContext('({})')); // ✅ +* +* // ❌👇 False +* +* class Test { }; +* isPlainObject(new Test()) // ❌ +* isPlainObject(10); // ❌ +* isPlainObject(null); // ❌ +* isPlainObject('hello'); // ❌ +* isPlainObject([]); // ❌ +* isPlainObject(new Date()); // ❌ +* isPlainObject(new Uint8Array([1])); // ❌ +* isPlainObject(Buffer.from('ABC')); // ❌ +* isPlainObject(Promise.resolve({})); // ❌ +* isPlainObject(Object.create({})); // ❌ +* isPlainObject(new (class Cls {})); // ❌ +* isPlainObject(globalThis); // ❌, +* ``` +*/ +function isPlainObject(value) { + if (!value || typeof value !== "object") return false; + const proto = Object.getPrototypeOf(value); + if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false; + return Object.prototype.toString.call(value) === "[object Object]"; +} +//#endregion +export { isPlainObject }; diff --git a/node_modules/es-toolkit/dist/predicate/isPrimitive.d.mts b/node_modules/es-toolkit/dist/predicate/isPrimitive.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1377535981d081be3d66d4b49cffd04fe4db2f81 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPrimitive.d.mts @@ -0,0 +1,25 @@ +//#region src/predicate/isPrimitive.d.ts +/** + * Checks whether a value is a JavaScript primitive. + * JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints. + * + * @param value The value to check. + * @returns Returns true if `value` is a primitive, false otherwise. + * + * @example + * isPrimitive(null); // true + * isPrimitive(undefined); // true + * isPrimitive('123'); // true + * isPrimitive(false); // true + * isPrimitive(true); // true + * isPrimitive(Symbol('a')); // true + * isPrimitive(123n); // true + * isPrimitive({}); // false + * isPrimitive(new Date()); // false + * isPrimitive(new Map()); // false + * isPrimitive(new Set()); // false + * isPrimitive([1, 2, 3]); // false + */ +declare function isPrimitive(value: unknown): value is null | undefined | string | number | boolean | symbol | bigint; +//#endregion +export { isPrimitive }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isPrimitive.d.ts b/node_modules/es-toolkit/dist/predicate/isPrimitive.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1377535981d081be3d66d4b49cffd04fe4db2f81 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPrimitive.d.ts @@ -0,0 +1,25 @@ +//#region src/predicate/isPrimitive.d.ts +/** + * Checks whether a value is a JavaScript primitive. + * JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints. + * + * @param value The value to check. + * @returns Returns true if `value` is a primitive, false otherwise. + * + * @example + * isPrimitive(null); // true + * isPrimitive(undefined); // true + * isPrimitive('123'); // true + * isPrimitive(false); // true + * isPrimitive(true); // true + * isPrimitive(Symbol('a')); // true + * isPrimitive(123n); // true + * isPrimitive({}); // false + * isPrimitive(new Date()); // false + * isPrimitive(new Map()); // false + * isPrimitive(new Set()); // false + * isPrimitive([1, 2, 3]); // false + */ +declare function isPrimitive(value: unknown): value is null | undefined | string | number | boolean | symbol | bigint; +//#endregion +export { isPrimitive }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isPrimitive.js b/node_modules/es-toolkit/dist/predicate/isPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..ffeb60342d4cdaa6ad954b05833e959a154db6f6 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPrimitive.js @@ -0,0 +1,27 @@ +//#region src/predicate/isPrimitive.ts +/** +* Checks whether a value is a JavaScript primitive. +* JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints. +* +* @param value The value to check. +* @returns Returns true if `value` is a primitive, false otherwise. +* +* @example +* isPrimitive(null); // true +* isPrimitive(undefined); // true +* isPrimitive('123'); // true +* isPrimitive(false); // true +* isPrimitive(true); // true +* isPrimitive(Symbol('a')); // true +* isPrimitive(123n); // true +* isPrimitive({}); // false +* isPrimitive(new Date()); // false +* isPrimitive(new Map()); // false +* isPrimitive(new Set()); // false +* isPrimitive([1, 2, 3]); // false +*/ +function isPrimitive(value) { + return value == null || typeof value !== "object" && typeof value !== "function"; +} +//#endregion +exports.isPrimitive = isPrimitive; diff --git a/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs b/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a3998dc33305a203b2d6bf9638295f9b477b6434 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs @@ -0,0 +1,27 @@ +//#region src/predicate/isPrimitive.ts +/** +* Checks whether a value is a JavaScript primitive. +* JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints. +* +* @param value The value to check. +* @returns Returns true if `value` is a primitive, false otherwise. +* +* @example +* isPrimitive(null); // true +* isPrimitive(undefined); // true +* isPrimitive('123'); // true +* isPrimitive(false); // true +* isPrimitive(true); // true +* isPrimitive(Symbol('a')); // true +* isPrimitive(123n); // true +* isPrimitive({}); // false +* isPrimitive(new Date()); // false +* isPrimitive(new Map()); // false +* isPrimitive(new Set()); // false +* isPrimitive([1, 2, 3]); // false +*/ +function isPrimitive(value) { + return value == null || typeof value !== "object" && typeof value !== "function"; +} +//#endregion +export { isPrimitive }; diff --git a/node_modules/es-toolkit/dist/predicate/isPromise.d.mts b/node_modules/es-toolkit/dist/predicate/isPromise.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8f952df9ace4fe4976fb96ec4ca23060d383903d --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPromise.d.mts @@ -0,0 +1,21 @@ +//#region src/predicate/isPromise.d.ts +/** + * Checks if a given value is `Promise`. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Promise`. + * + * @param value The value to check if it is a `Promise`. + * @returns Returns `true` if `value` is a `Promise`, else `false`. + * + * @example + * const value1 = new Promise((resolve) => resolve()); + * const value2 = {}; + * const value3 = 123; + * + * console.log(isPromise(value1)); // true + * console.log(isPromise(value2)); // false + * console.log(isPromise(value3)); // false + */ +declare function isPromise(value: unknown): value is Promise; +//#endregion +export { isPromise }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isPromise.d.ts b/node_modules/es-toolkit/dist/predicate/isPromise.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f952df9ace4fe4976fb96ec4ca23060d383903d --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPromise.d.ts @@ -0,0 +1,21 @@ +//#region src/predicate/isPromise.d.ts +/** + * Checks if a given value is `Promise`. + * + * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Promise`. + * + * @param value The value to check if it is a `Promise`. + * @returns Returns `true` if `value` is a `Promise`, else `false`. + * + * @example + * const value1 = new Promise((resolve) => resolve()); + * const value2 = {}; + * const value3 = 123; + * + * console.log(isPromise(value1)); // true + * console.log(isPromise(value2)); // false + * console.log(isPromise(value3)); // false + */ +declare function isPromise(value: unknown): value is Promise; +//#endregion +export { isPromise }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isPromise.js b/node_modules/es-toolkit/dist/predicate/isPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..3500b7eb8593a24d164bdea8dab1c9dab9945611 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPromise.js @@ -0,0 +1,23 @@ +//#region src/predicate/isPromise.ts +/** +* Checks if a given value is `Promise`. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Promise`. +* +* @param value The value to check if it is a `Promise`. +* @returns Returns `true` if `value` is a `Promise`, else `false`. +* +* @example +* const value1 = new Promise((resolve) => resolve()); +* const value2 = {}; +* const value3 = 123; +* +* console.log(isPromise(value1)); // true +* console.log(isPromise(value2)); // false +* console.log(isPromise(value3)); // false +*/ +function isPromise(value) { + return value instanceof Promise; +} +//#endregion +exports.isPromise = isPromise; diff --git a/node_modules/es-toolkit/dist/predicate/isPromise.mjs b/node_modules/es-toolkit/dist/predicate/isPromise.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ef15f11508243e04aab68f3eff97b576b4918d5f --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isPromise.mjs @@ -0,0 +1,23 @@ +//#region src/predicate/isPromise.ts +/** +* Checks if a given value is `Promise`. +* +* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Promise`. +* +* @param value The value to check if it is a `Promise`. +* @returns Returns `true` if `value` is a `Promise`, else `false`. +* +* @example +* const value1 = new Promise((resolve) => resolve()); +* const value2 = {}; +* const value3 = 123; +* +* console.log(isPromise(value1)); // true +* console.log(isPromise(value2)); // false +* console.log(isPromise(value3)); // false +*/ +function isPromise(value) { + return value instanceof Promise; +} +//#endregion +export { isPromise }; diff --git a/node_modules/es-toolkit/dist/predicate/isRegExp.d.mts b/node_modules/es-toolkit/dist/predicate/isRegExp.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8371987e525060558e8d8295e342c84aced5db00 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isRegExp.d.mts @@ -0,0 +1,17 @@ +//#region src/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: unknown): value is RegExp; +//#endregion +export { isRegExp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isRegExp.d.ts b/node_modules/es-toolkit/dist/predicate/isRegExp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8371987e525060558e8d8295e342c84aced5db00 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isRegExp.d.ts @@ -0,0 +1,17 @@ +//#region src/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: unknown): value is RegExp; +//#endregion +export { isRegExp }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isRegExp.js b/node_modules/es-toolkit/dist/predicate/isRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..becc2cd7c41bd4d9a9f3bd57233ca5819acbdd4a --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isRegExp.js @@ -0,0 +1,19 @@ +//#region src/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 value instanceof RegExp; +} +//#endregion +exports.isRegExp = isRegExp; diff --git a/node_modules/es-toolkit/dist/predicate/isRegExp.mjs b/node_modules/es-toolkit/dist/predicate/isRegExp.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4c5c81d31e97052d8239096ca3bd6a1596b57c05 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isRegExp.mjs @@ -0,0 +1,19 @@ +//#region src/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 value instanceof RegExp; +} +//#endregion +export { isRegExp }; diff --git a/node_modules/es-toolkit/dist/predicate/isSet.d.mts b/node_modules/es-toolkit/dist/predicate/isSet.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..954f2bd92a2a82848315cd4b8101dd0aa8cdeffb --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isSet.d.mts @@ -0,0 +1,21 @@ +//#region src/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: unknown): value is Set; +//#endregion +export { isSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isSet.d.ts b/node_modules/es-toolkit/dist/predicate/isSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..954f2bd92a2a82848315cd4b8101dd0aa8cdeffb --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isSet.d.ts @@ -0,0 +1,21 @@ +//#region src/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: unknown): value is Set; +//#endregion +export { isSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isSet.js b/node_modules/es-toolkit/dist/predicate/isSet.js new file mode 100644 index 0000000000000000000000000000000000000000..cf47cdedb5b7dcdfed5cfe16a4fc26ad35d7596e --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isSet.js @@ -0,0 +1,23 @@ +//#region src/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 value instanceof Set; +} +//#endregion +exports.isSet = isSet; diff --git a/node_modules/es-toolkit/dist/predicate/isSet.mjs b/node_modules/es-toolkit/dist/predicate/isSet.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5695499dd7272bca9f74eb290f92b410f8044c90 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isSet.mjs @@ -0,0 +1,23 @@ +//#region src/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 value instanceof Set; +} +//#endregion +export { isSet }; diff --git a/node_modules/es-toolkit/dist/predicate/isString.d.mts b/node_modules/es-toolkit/dist/predicate/isString.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8f3f687a31440309c6fd9150c6f748b1b7a4df40 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isString.d.mts @@ -0,0 +1,21 @@ +//#region src/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: unknown): value is string; +//#endregion +export { isString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isString.d.ts b/node_modules/es-toolkit/dist/predicate/isString.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f3f687a31440309c6fd9150c6f748b1b7a4df40 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isString.d.ts @@ -0,0 +1,21 @@ +//#region src/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: unknown): value is string; +//#endregion +export { isString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isString.js b/node_modules/es-toolkit/dist/predicate/isString.js new file mode 100644 index 0000000000000000000000000000000000000000..5291d5663d9b1ed5aadf9462544dd3753d0f4968 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isString.js @@ -0,0 +1,23 @@ +//#region src/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"; +} +//#endregion +exports.isString = isString; diff --git a/node_modules/es-toolkit/dist/predicate/isString.mjs b/node_modules/es-toolkit/dist/predicate/isString.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3359e60947217d1b58e6742094697f910d2e48aa --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isString.mjs @@ -0,0 +1,23 @@ +//#region src/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"; +} +//#endregion +export { isString }; diff --git a/node_modules/es-toolkit/dist/predicate/isSymbol.d.mts b/node_modules/es-toolkit/dist/predicate/isSymbol.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..63003a136a0170d90dab4e3cfbbfa5bb422d5870 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isSymbol.d.mts @@ -0,0 +1,27 @@ +//#region src/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 + * import { isSymbol } from 'es-toolkit/predicate'; + * + * isSymbol(Symbol('a')); // true + * isSymbol(Symbol.for('a')); // true + * isSymbol(Symbol.iterator); // true + * + * isSymbol(null); // false + * isSymbol(undefined); // false + * isSymbol('123'); // false + * isSymbol(false); // false + * isSymbol(123n); // false + * isSymbol({}); // false + * isSymbol([1, 2, 3]); // false + */ +declare function isSymbol(value: unknown): value is symbol; +//#endregion +export { isSymbol }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isSymbol.d.ts b/node_modules/es-toolkit/dist/predicate/isSymbol.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..63003a136a0170d90dab4e3cfbbfa5bb422d5870 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isSymbol.d.ts @@ -0,0 +1,27 @@ +//#region src/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 + * import { isSymbol } from 'es-toolkit/predicate'; + * + * isSymbol(Symbol('a')); // true + * isSymbol(Symbol.for('a')); // true + * isSymbol(Symbol.iterator); // true + * + * isSymbol(null); // false + * isSymbol(undefined); // false + * isSymbol('123'); // false + * isSymbol(false); // false + * isSymbol(123n); // false + * isSymbol({}); // false + * isSymbol([1, 2, 3]); // false + */ +declare function isSymbol(value: unknown): value is symbol; +//#endregion +export { isSymbol }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isSymbol.js b/node_modules/es-toolkit/dist/predicate/isSymbol.js new file mode 100644 index 0000000000000000000000000000000000000000..35ade28df99a55eb4ea77c6da5c28211fb14b621 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isSymbol.js @@ -0,0 +1,29 @@ +//#region src/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 +* import { isSymbol } from 'es-toolkit/predicate'; +* +* isSymbol(Symbol('a')); // true +* isSymbol(Symbol.for('a')); // true +* isSymbol(Symbol.iterator); // true +* +* isSymbol(null); // false +* isSymbol(undefined); // false +* isSymbol('123'); // false +* isSymbol(false); // false +* isSymbol(123n); // false +* isSymbol({}); // false +* isSymbol([1, 2, 3]); // false +*/ +function isSymbol(value) { + return typeof value === "symbol"; +} +//#endregion +exports.isSymbol = isSymbol; diff --git a/node_modules/es-toolkit/dist/predicate/isSymbol.mjs b/node_modules/es-toolkit/dist/predicate/isSymbol.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cf7f0f6cb0d79a3bcdf8af7fe2cd85fe6babbf25 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isSymbol.mjs @@ -0,0 +1,29 @@ +//#region src/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 +* import { isSymbol } from 'es-toolkit/predicate'; +* +* isSymbol(Symbol('a')); // true +* isSymbol(Symbol.for('a')); // true +* isSymbol(Symbol.iterator); // true +* +* isSymbol(null); // false +* isSymbol(undefined); // false +* isSymbol('123'); // false +* isSymbol(false); // false +* isSymbol(123n); // false +* isSymbol({}); // false +* isSymbol([1, 2, 3]); // false +*/ +function isSymbol(value) { + return typeof value === "symbol"; +} +//#endregion +export { isSymbol }; diff --git a/node_modules/es-toolkit/dist/predicate/isTypedArray.d.mts b/node_modules/es-toolkit/dist/predicate/isTypedArray.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ae7285d8ac31f6738879ebc0946b7b617674e896 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isTypedArray.d.mts @@ -0,0 +1,19 @@ +//#region src/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: unknown): x is Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array; +//#endregion +export { isTypedArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isTypedArray.d.ts b/node_modules/es-toolkit/dist/predicate/isTypedArray.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae7285d8ac31f6738879ebc0946b7b617674e896 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isTypedArray.d.ts @@ -0,0 +1,19 @@ +//#region src/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: unknown): x is Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array; +//#endregion +export { isTypedArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isTypedArray.js b/node_modules/es-toolkit/dist/predicate/isTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..3984930aa51843ab0ec66300da6ce0ce7522befa --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isTypedArray.js @@ -0,0 +1,21 @@ +//#region src/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 ArrayBuffer.isView(x) && !(x instanceof DataView); +} +//#endregion +exports.isTypedArray = isTypedArray; diff --git a/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs b/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2a68de943bfdb43aaacc29af9bd914ce291c2ae1 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs @@ -0,0 +1,21 @@ +//#region src/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 ArrayBuffer.isView(x) && !(x instanceof DataView); +} +//#endregion +export { isTypedArray }; diff --git a/node_modules/es-toolkit/dist/predicate/isUndefined.d.mts b/node_modules/es-toolkit/dist/predicate/isUndefined.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a7be2fc097f8b0ed1a28e0c428748f74a63d9252 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isUndefined.d.mts @@ -0,0 +1,24 @@ +//#region src/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/predicate/isUndefined.d.ts b/node_modules/es-toolkit/dist/predicate/isUndefined.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a7be2fc097f8b0ed1a28e0c428748f74a63d9252 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isUndefined.d.ts @@ -0,0 +1,24 @@ +//#region src/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/predicate/isUndefined.js b/node_modules/es-toolkit/dist/predicate/isUndefined.js new file mode 100644 index 0000000000000000000000000000000000000000..1d3cca383cf5a484e614a69e567d1d5a39b63f4a --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isUndefined.js @@ -0,0 +1,26 @@ +//#region src/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 x === void 0; +} +//#endregion +exports.isUndefined = isUndefined; diff --git a/node_modules/es-toolkit/dist/predicate/isUndefined.mjs b/node_modules/es-toolkit/dist/predicate/isUndefined.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0aa6dd6dfd4d1c74a03395050ac90a754ce7e71c --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isUndefined.mjs @@ -0,0 +1,26 @@ +//#region src/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 x === void 0; +} +//#endregion +export { isUndefined }; diff --git a/node_modules/es-toolkit/dist/predicate/isWeakMap.d.mts b/node_modules/es-toolkit/dist/predicate/isWeakMap.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..546b9cf0012e8aa65da441b03bf2bc148183e791 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isWeakMap.d.mts @@ -0,0 +1,24 @@ +//#region src/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: unknown): value is WeakMap; +//#endregion +export { isWeakMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isWeakMap.d.ts b/node_modules/es-toolkit/dist/predicate/isWeakMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..546b9cf0012e8aa65da441b03bf2bc148183e791 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isWeakMap.d.ts @@ -0,0 +1,24 @@ +//#region src/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: unknown): value is WeakMap; +//#endregion +export { isWeakMap }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isWeakMap.js b/node_modules/es-toolkit/dist/predicate/isWeakMap.js new file mode 100644 index 0000000000000000000000000000000000000000..efe8742d080f294e77b9fa0518bc44d38ee3e75a --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isWeakMap.js @@ -0,0 +1,26 @@ +//#region src/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 value instanceof WeakMap; +} +//#endregion +exports.isWeakMap = isWeakMap; diff --git a/node_modules/es-toolkit/dist/predicate/isWeakMap.mjs b/node_modules/es-toolkit/dist/predicate/isWeakMap.mjs new file mode 100644 index 0000000000000000000000000000000000000000..11567fd62178e271665f6aaae408e855bd999c11 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isWeakMap.mjs @@ -0,0 +1,26 @@ +//#region src/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 value instanceof WeakMap; +} +//#endregion +export { isWeakMap }; diff --git a/node_modules/es-toolkit/dist/predicate/isWeakSet.d.mts b/node_modules/es-toolkit/dist/predicate/isWeakSet.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c6c204d8dfeabc69bb1deba2aabe631b000beb4d --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isWeakSet.d.mts @@ -0,0 +1,24 @@ +//#region src/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: unknown): value is WeakSet; +//#endregion +export { isWeakSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isWeakSet.d.ts b/node_modules/es-toolkit/dist/predicate/isWeakSet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6c204d8dfeabc69bb1deba2aabe631b000beb4d --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isWeakSet.d.ts @@ -0,0 +1,24 @@ +//#region src/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: unknown): value is WeakSet; +//#endregion +export { isWeakSet }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/predicate/isWeakSet.js b/node_modules/es-toolkit/dist/predicate/isWeakSet.js new file mode 100644 index 0000000000000000000000000000000000000000..769e82a3efb6bc1a0ff3bbc196eb3a926d3df220 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isWeakSet.js @@ -0,0 +1,26 @@ +//#region src/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 value instanceof WeakSet; +} +//#endregion +exports.isWeakSet = isWeakSet; diff --git a/node_modules/es-toolkit/dist/predicate/isWeakSet.mjs b/node_modules/es-toolkit/dist/predicate/isWeakSet.mjs new file mode 100644 index 0000000000000000000000000000000000000000..86b479973dce0ba5cf1ef6500bcb7e621e0f3b95 --- /dev/null +++ b/node_modules/es-toolkit/dist/predicate/isWeakSet.mjs @@ -0,0 +1,26 @@ +//#region src/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 value instanceof WeakSet; +} +//#endregion +export { isWeakSet }; diff --git a/node_modules/es-toolkit/dist/promise/allKeyed.d.mts b/node_modules/es-toolkit/dist/promise/allKeyed.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6bc8c745c393755448550c6669ebe0697e6fe064 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/allKeyed.d.mts @@ -0,0 +1,31 @@ +//#region src/promise/allKeyed.d.ts +/** + * Resolves an object of promises concurrently, returning an object with the same keys and resolved values. + * + * Similar to `Promise.all`, but accepts an object of promises instead of an array, + * preserving the keys in the result. This makes it easy to destructure the resolved values + * by name instead of relying on positional indices. + * + * Based on the [TC39 `Promise.allKeyed` proposal](https://github.com/tc39/proposal-await-dictionary). + * + * @template T - A record type where each value is a promise or a value. + * @param tasks - An object whose values are promises (or plain values) to resolve concurrently. + * @returns>} A promise that resolves to an object with the same keys and resolved values. + * + * @example + * const { user, posts } = await allKeyed({ + * user: fetchUser(), + * posts: fetchPosts(), + * }); + * + * @example + * // Plain values are also supported + * const result = await allKeyed({ + * a: Promise.resolve(1), + * b: 2, + * }); + * // { a: 1, b: 2 } + */ +declare function allKeyed>(tasks: T): Promise<{ [K in keyof T]: Awaited }>; +//#endregion +export { allKeyed }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/allKeyed.d.ts b/node_modules/es-toolkit/dist/promise/allKeyed.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6bc8c745c393755448550c6669ebe0697e6fe064 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/allKeyed.d.ts @@ -0,0 +1,31 @@ +//#region src/promise/allKeyed.d.ts +/** + * Resolves an object of promises concurrently, returning an object with the same keys and resolved values. + * + * Similar to `Promise.all`, but accepts an object of promises instead of an array, + * preserving the keys in the result. This makes it easy to destructure the resolved values + * by name instead of relying on positional indices. + * + * Based on the [TC39 `Promise.allKeyed` proposal](https://github.com/tc39/proposal-await-dictionary). + * + * @template T - A record type where each value is a promise or a value. + * @param tasks - An object whose values are promises (or plain values) to resolve concurrently. + * @returns>} A promise that resolves to an object with the same keys and resolved values. + * + * @example + * const { user, posts } = await allKeyed({ + * user: fetchUser(), + * posts: fetchPosts(), + * }); + * + * @example + * // Plain values are also supported + * const result = await allKeyed({ + * a: Promise.resolve(1), + * b: 2, + * }); + * // { a: 1, b: 2 } + */ +declare function allKeyed>(tasks: T): Promise<{ [K in keyof T]: Awaited }>; +//#endregion +export { allKeyed }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/allKeyed.js b/node_modules/es-toolkit/dist/promise/allKeyed.js new file mode 100644 index 0000000000000000000000000000000000000000..a3939fbf6cee7cd1f429968108e8be7e3670bd59 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/allKeyed.js @@ -0,0 +1,37 @@ +//#region src/promise/allKeyed.ts +/** +* Resolves an object of promises concurrently, returning an object with the same keys and resolved values. +* +* Similar to `Promise.all`, but accepts an object of promises instead of an array, +* preserving the keys in the result. This makes it easy to destructure the resolved values +* by name instead of relying on positional indices. +* +* Based on the [TC39 `Promise.allKeyed` proposal](https://github.com/tc39/proposal-await-dictionary). +* +* @template T - A record type where each value is a promise or a value. +* @param tasks - An object whose values are promises (or plain values) to resolve concurrently. +* @returns>} A promise that resolves to an object with the same keys and resolved values. +* +* @example +* const { user, posts } = await allKeyed({ +* user: fetchUser(), +* posts: fetchPosts(), +* }); +* +* @example +* // Plain values are also supported +* const result = await allKeyed({ +* a: Promise.resolve(1), +* b: 2, +* }); +* // { a: 1, b: 2 } +*/ +async function allKeyed(tasks) { + const keys = Object.keys(tasks); + const values = await Promise.all(keys.map((key) => tasks[key])); + const result = {}; + for (let i = 0; i < keys.length; i++) result[keys[i]] = values[i]; + return result; +} +//#endregion +exports.allKeyed = allKeyed; diff --git a/node_modules/es-toolkit/dist/promise/allKeyed.mjs b/node_modules/es-toolkit/dist/promise/allKeyed.mjs new file mode 100644 index 0000000000000000000000000000000000000000..397796fada540cf82c7a8c48d65f8843a80b8475 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/allKeyed.mjs @@ -0,0 +1,37 @@ +//#region src/promise/allKeyed.ts +/** +* Resolves an object of promises concurrently, returning an object with the same keys and resolved values. +* +* Similar to `Promise.all`, but accepts an object of promises instead of an array, +* preserving the keys in the result. This makes it easy to destructure the resolved values +* by name instead of relying on positional indices. +* +* Based on the [TC39 `Promise.allKeyed` proposal](https://github.com/tc39/proposal-await-dictionary). +* +* @template T - A record type where each value is a promise or a value. +* @param tasks - An object whose values are promises (or plain values) to resolve concurrently. +* @returns>} A promise that resolves to an object with the same keys and resolved values. +* +* @example +* const { user, posts } = await allKeyed({ +* user: fetchUser(), +* posts: fetchPosts(), +* }); +* +* @example +* // Plain values are also supported +* const result = await allKeyed({ +* a: Promise.resolve(1), +* b: 2, +* }); +* // { a: 1, b: 2 } +*/ +async function allKeyed(tasks) { + const keys = Object.keys(tasks); + const values = await Promise.all(keys.map((key) => tasks[key])); + const result = {}; + for (let i = 0; i < keys.length; i++) result[keys[i]] = values[i]; + return result; +} +//#endregion +export { allKeyed }; diff --git a/node_modules/es-toolkit/dist/promise/delay.d.mts b/node_modules/es-toolkit/dist/promise/delay.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e6c8f1bbe05f0c849074c733e5f36c78e56dabb7 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/delay.d.mts @@ -0,0 +1,41 @@ +//#region src/promise/delay.d.ts +interface DelayOptions { + signal?: AbortSignal; +} +/** + * Delays the execution of code for a specified number of milliseconds. + * + * This function returns a Promise that resolves after the specified delay, allowing you to use it + * with async/await to pause execution. + * + * @param ms - The number of milliseconds to delay. + * @param options - The options object. + * @param options.signal - An optional AbortSignal to cancel the delay. + * @returns A Promise that resolves after the specified delay. + * + * @example + * async function foo() { + * console.log('Start'); + * await delay(1000); // Delays execution for 1 second + * console.log('End'); + * } + * + * foo(); + * + * // With AbortSignal + * const controller = new AbortController(); + * const { signal } = controller; + * + * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms + * try { + * await delay(100, { signal }); + * } catch (error) { + * console.error(error); // Will log 'AbortError' + * } + * } + */ +declare function delay(ms: number, { + signal +}?: DelayOptions): Promise; +//#endregion +export { delay }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/delay.d.ts b/node_modules/es-toolkit/dist/promise/delay.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e6c8f1bbe05f0c849074c733e5f36c78e56dabb7 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/delay.d.ts @@ -0,0 +1,41 @@ +//#region src/promise/delay.d.ts +interface DelayOptions { + signal?: AbortSignal; +} +/** + * Delays the execution of code for a specified number of milliseconds. + * + * This function returns a Promise that resolves after the specified delay, allowing you to use it + * with async/await to pause execution. + * + * @param ms - The number of milliseconds to delay. + * @param options - The options object. + * @param options.signal - An optional AbortSignal to cancel the delay. + * @returns A Promise that resolves after the specified delay. + * + * @example + * async function foo() { + * console.log('Start'); + * await delay(1000); // Delays execution for 1 second + * console.log('End'); + * } + * + * foo(); + * + * // With AbortSignal + * const controller = new AbortController(); + * const { signal } = controller; + * + * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms + * try { + * await delay(100, { signal }); + * } catch (error) { + * console.error(error); // Will log 'AbortError' + * } + * } + */ +declare function delay(ms: number, { + signal +}?: DelayOptions): Promise; +//#endregion +export { delay }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/delay.js b/node_modules/es-toolkit/dist/promise/delay.js new file mode 100644 index 0000000000000000000000000000000000000000..3d834357a9f2e5738d55ba67dbf6b80d23929ea4 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/delay.js @@ -0,0 +1,53 @@ +const require_AbortError = require("../error/AbortError.js"); +//#region src/promise/delay.ts +/** +* Delays the execution of code for a specified number of milliseconds. +* +* This function returns a Promise that resolves after the specified delay, allowing you to use it +* with async/await to pause execution. +* +* @param ms - The number of milliseconds to delay. +* @param options - The options object. +* @param options.signal - An optional AbortSignal to cancel the delay. +* @returns A Promise that resolves after the specified delay. +* +* @example +* async function foo() { +* console.log('Start'); +* await delay(1000); // Delays execution for 1 second +* console.log('End'); +* } +* +* foo(); +* +* // With AbortSignal +* const controller = new AbortController(); +* const { signal } = controller; +* +* setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms +* try { +* await delay(100, { signal }); +* } catch (error) { +* console.error(error); // Will log 'AbortError' +* } +* } +*/ +function delay(ms, { signal } = {}) { + return new Promise((resolve, reject) => { + const abortError = () => { + reject(new require_AbortError.AbortError()); + }; + const abortHandler = () => { + clearTimeout(timeoutId); + abortError(); + }; + if (signal?.aborted) return abortError(); + const timeoutId = setTimeout(() => { + signal?.removeEventListener("abort", abortHandler); + resolve(); + }, ms); + signal?.addEventListener("abort", abortHandler, { once: true }); + }); +} +//#endregion +exports.delay = delay; diff --git a/node_modules/es-toolkit/dist/promise/delay.mjs b/node_modules/es-toolkit/dist/promise/delay.mjs new file mode 100644 index 0000000000000000000000000000000000000000..47c6714c0a26674f8d9195a4784aab6c94945979 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/delay.mjs @@ -0,0 +1,53 @@ +import { AbortError } from "../error/AbortError.mjs"; +//#region src/promise/delay.ts +/** +* Delays the execution of code for a specified number of milliseconds. +* +* This function returns a Promise that resolves after the specified delay, allowing you to use it +* with async/await to pause execution. +* +* @param ms - The number of milliseconds to delay. +* @param options - The options object. +* @param options.signal - An optional AbortSignal to cancel the delay. +* @returns A Promise that resolves after the specified delay. +* +* @example +* async function foo() { +* console.log('Start'); +* await delay(1000); // Delays execution for 1 second +* console.log('End'); +* } +* +* foo(); +* +* // With AbortSignal +* const controller = new AbortController(); +* const { signal } = controller; +* +* setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms +* try { +* await delay(100, { signal }); +* } catch (error) { +* console.error(error); // Will log 'AbortError' +* } +* } +*/ +function delay(ms, { signal } = {}) { + return new Promise((resolve, reject) => { + const abortError = () => { + reject(new AbortError()); + }; + const abortHandler = () => { + clearTimeout(timeoutId); + abortError(); + }; + if (signal?.aborted) return abortError(); + const timeoutId = setTimeout(() => { + signal?.removeEventListener("abort", abortHandler); + resolve(); + }, ms); + signal?.addEventListener("abort", abortHandler, { once: true }); + }); +} +//#endregion +export { delay }; diff --git a/node_modules/es-toolkit/dist/promise/index.d.mts b/node_modules/es-toolkit/dist/promise/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2bf76258f8df9fe17475f9f5985215c323bff0e6 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/index.d.mts @@ -0,0 +1,7 @@ +import { allKeyed } from "./allKeyed.mjs"; +import { delay } from "./delay.mjs"; +import { Mutex } from "./mutex.mjs"; +import { Semaphore } from "./semaphore.mjs"; +import { timeout } from "./timeout.mjs"; +import { withTimeout } from "./withTimeout.mjs"; +export { Mutex, Semaphore, allKeyed, delay, timeout, withTimeout }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/index.d.ts b/node_modules/es-toolkit/dist/promise/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..489d776f85f115ac105fc746d21124ac25e2fa49 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/index.d.ts @@ -0,0 +1,7 @@ +import { allKeyed } from "./allKeyed.js"; +import { delay } from "./delay.js"; +import { Mutex } from "./mutex.js"; +import { Semaphore } from "./semaphore.js"; +import { timeout } from "./timeout.js"; +import { withTimeout } from "./withTimeout.js"; +export { Mutex, Semaphore, allKeyed, delay, timeout, withTimeout }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/index.js b/node_modules/es-toolkit/dist/promise/index.js new file mode 100644 index 0000000000000000000000000000000000000000..be9545087d647bd4b8eb01548024a4b8c2c60f3f --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/index.js @@ -0,0 +1,13 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_semaphore = require("./semaphore.js"); +const require_delay = require("./delay.js"); +const require_allKeyed = require("./allKeyed.js"); +const require_mutex = require("./mutex.js"); +const require_timeout = require("./timeout.js"); +const require_withTimeout = require("./withTimeout.js"); +exports.Mutex = require_mutex.Mutex; +exports.Semaphore = require_semaphore.Semaphore; +exports.allKeyed = require_allKeyed.allKeyed; +exports.delay = require_delay.delay; +exports.timeout = require_timeout.timeout; +exports.withTimeout = require_withTimeout.withTimeout; diff --git a/node_modules/es-toolkit/dist/promise/index.mjs b/node_modules/es-toolkit/dist/promise/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..512061bff72abbdfb62e70e4bbf386f10daaa3e6 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/index.mjs @@ -0,0 +1,7 @@ +import { Semaphore } from "./semaphore.mjs"; +import { delay } from "./delay.mjs"; +import { allKeyed } from "./allKeyed.mjs"; +import { Mutex } from "./mutex.mjs"; +import { timeout } from "./timeout.mjs"; +import { withTimeout } from "./withTimeout.mjs"; +export { Mutex, Semaphore, allKeyed, delay, timeout, withTimeout }; diff --git a/node_modules/es-toolkit/dist/promise/mutex.d.mts b/node_modules/es-toolkit/dist/promise/mutex.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9d5b6934b1b54177ed5f7abfd6169eb11400d7fc --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/mutex.d.mts @@ -0,0 +1,65 @@ +//#region src/promise/mutex.d.ts +/** + * A Mutex (mutual exclusion lock) for async functions. + * It allows only one async task to access a critical section at a time. + * + * @example + * const mutex = new Mutex(); + * + * async function criticalSection() { + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); + * } + * } + * + * criticalSection(); + * criticalSection(); // This call will wait until the first call releases the mutex. + */ +declare class Mutex { + private semaphore; + /** + * Checks if the mutex is currently locked. + * @returns True if the mutex is locked, false otherwise. + * + * @example + * const mutex = new Mutex(); + * console.log(mutex.isLocked); // false + * await mutex.acquire(); + * console.log(mutex.isLocked); // true + * mutex.release(); + * console.log(mutex.isLocked); // false + */ + get isLocked(): boolean; + /** + * Acquires the mutex, blocking if necessary until it is available. + * @returns A promise that resolves when the mutex is acquired. + * + * @example + * const mutex = new Mutex(); + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); + * } + */ + acquire(): Promise; + /** + * Releases the mutex, allowing another waiting task to proceed. + * + * @example + * const mutex = new Mutex(); + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); // Allows another waiting task to proceed. + * } + */ + release(): void; +} +//#endregion +export { Mutex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/mutex.d.ts b/node_modules/es-toolkit/dist/promise/mutex.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d5b6934b1b54177ed5f7abfd6169eb11400d7fc --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/mutex.d.ts @@ -0,0 +1,65 @@ +//#region src/promise/mutex.d.ts +/** + * A Mutex (mutual exclusion lock) for async functions. + * It allows only one async task to access a critical section at a time. + * + * @example + * const mutex = new Mutex(); + * + * async function criticalSection() { + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); + * } + * } + * + * criticalSection(); + * criticalSection(); // This call will wait until the first call releases the mutex. + */ +declare class Mutex { + private semaphore; + /** + * Checks if the mutex is currently locked. + * @returns True if the mutex is locked, false otherwise. + * + * @example + * const mutex = new Mutex(); + * console.log(mutex.isLocked); // false + * await mutex.acquire(); + * console.log(mutex.isLocked); // true + * mutex.release(); + * console.log(mutex.isLocked); // false + */ + get isLocked(): boolean; + /** + * Acquires the mutex, blocking if necessary until it is available. + * @returns A promise that resolves when the mutex is acquired. + * + * @example + * const mutex = new Mutex(); + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); + * } + */ + acquire(): Promise; + /** + * Releases the mutex, allowing another waiting task to proceed. + * + * @example + * const mutex = new Mutex(); + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); // Allows another waiting task to proceed. + * } + */ + release(): void; +} +//#endregion +export { Mutex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/mutex.js b/node_modules/es-toolkit/dist/promise/mutex.js new file mode 100644 index 0000000000000000000000000000000000000000..6cd1de063aaccba3e07151df413efd2cbe51364e --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/mutex.js @@ -0,0 +1,72 @@ +const require_semaphore = require("./semaphore.js"); +//#region src/promise/mutex.ts +/** +* A Mutex (mutual exclusion lock) for async functions. +* It allows only one async task to access a critical section at a time. +* +* @example +* const mutex = new Mutex(); +* +* async function criticalSection() { +* await mutex.acquire(); +* try { +* // This code section cannot be executed simultaneously +* } finally { +* mutex.release(); +* } +* } +* +* criticalSection(); +* criticalSection(); // This call will wait until the first call releases the mutex. +*/ +var Mutex = class { + semaphore = new require_semaphore.Semaphore(1); + /** + * Checks if the mutex is currently locked. + * @returns True if the mutex is locked, false otherwise. + * + * @example + * const mutex = new Mutex(); + * console.log(mutex.isLocked); // false + * await mutex.acquire(); + * console.log(mutex.isLocked); // true + * mutex.release(); + * console.log(mutex.isLocked); // false + */ + get isLocked() { + return this.semaphore.available === 0; + } + /** + * Acquires the mutex, blocking if necessary until it is available. + * @returns A promise that resolves when the mutex is acquired. + * + * @example + * const mutex = new Mutex(); + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); + * } + */ + async acquire() { + return this.semaphore.acquire(); + } + /** + * Releases the mutex, allowing another waiting task to proceed. + * + * @example + * const mutex = new Mutex(); + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); // Allows another waiting task to proceed. + * } + */ + release() { + this.semaphore.release(); + } +}; +//#endregion +exports.Mutex = Mutex; diff --git a/node_modules/es-toolkit/dist/promise/mutex.mjs b/node_modules/es-toolkit/dist/promise/mutex.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f9fcf61e9d09b50f5e68cd6e6bc81ba4f59eab2d --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/mutex.mjs @@ -0,0 +1,72 @@ +import { Semaphore } from "./semaphore.mjs"; +//#region src/promise/mutex.ts +/** +* A Mutex (mutual exclusion lock) for async functions. +* It allows only one async task to access a critical section at a time. +* +* @example +* const mutex = new Mutex(); +* +* async function criticalSection() { +* await mutex.acquire(); +* try { +* // This code section cannot be executed simultaneously +* } finally { +* mutex.release(); +* } +* } +* +* criticalSection(); +* criticalSection(); // This call will wait until the first call releases the mutex. +*/ +var Mutex = class { + semaphore = new Semaphore(1); + /** + * Checks if the mutex is currently locked. + * @returns True if the mutex is locked, false otherwise. + * + * @example + * const mutex = new Mutex(); + * console.log(mutex.isLocked); // false + * await mutex.acquire(); + * console.log(mutex.isLocked); // true + * mutex.release(); + * console.log(mutex.isLocked); // false + */ + get isLocked() { + return this.semaphore.available === 0; + } + /** + * Acquires the mutex, blocking if necessary until it is available. + * @returns A promise that resolves when the mutex is acquired. + * + * @example + * const mutex = new Mutex(); + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); + * } + */ + async acquire() { + return this.semaphore.acquire(); + } + /** + * Releases the mutex, allowing another waiting task to proceed. + * + * @example + * const mutex = new Mutex(); + * await mutex.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * mutex.release(); // Allows another waiting task to proceed. + * } + */ + release() { + this.semaphore.release(); + } +}; +//#endregion +export { Mutex }; diff --git a/node_modules/es-toolkit/dist/promise/semaphore.d.mts b/node_modules/es-toolkit/dist/promise/semaphore.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..81d12158d84972f88c127502a1ac51f89e35d087 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/semaphore.d.mts @@ -0,0 +1,82 @@ +//#region src/promise/semaphore.d.ts +/** + * A counting semaphore for async functions that manages available permits. + * Semaphores are mainly used to limit the number of concurrent async tasks. + * + * Each `acquire` operation takes a permit or waits until one is available. + * Each `release` operation adds a permit, potentially allowing a waiting task to proceed. + * + * The semaphore ensures fairness by maintaining a FIFO (First In, First Out) order for acquirers. + * + * @example + * const sema = new Semaphore(2); + * + * async function task() { + * await sema.acquire(); + * try { + * // This code can only be executed by two tasks at the same time + * } finally { + * sema.release(); + * } + * } + * + * task(); + * task(); + * task(); // This task will wait until one of the previous tasks releases the semaphore. + */ +declare class Semaphore { + /** + * The maximum number of concurrent operations allowed. + * @type {number} + */ + capacity: number; + /** + * The number of available permits. + * @type {number} + */ + available: number; + private deferredTasks; + /** + * Creates an instance of Semaphore. + * @param capacity - The maximum number of concurrent operations allowed. + * + * @example + * const sema = new Semaphore(3); // Allows up to 3 concurrent operations. + */ + constructor(capacity: number); + /** + * Acquires a semaphore, blocking if necessary until one is available. + * @returns A promise that resolves when the semaphore is acquired. + * + * @example + * const sema = new Semaphore(1); + * + * async function criticalSection() { + * await sema.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * sema.release(); + * } + * } + */ + acquire(): Promise; + /** + * Releases a semaphore, allowing one more operation to proceed. + * + * @example + * const sema = new Semaphore(1); + * + * async function task() { + * await sema.acquire(); + * try { + * // This code can only be executed by two tasks at the same time + * } finally { + * sema.release(); // Allows another waiting task to proceed. + * } + * } + */ + release(): void; +} +//#endregion +export { Semaphore }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/semaphore.d.ts b/node_modules/es-toolkit/dist/promise/semaphore.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..81d12158d84972f88c127502a1ac51f89e35d087 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/semaphore.d.ts @@ -0,0 +1,82 @@ +//#region src/promise/semaphore.d.ts +/** + * A counting semaphore for async functions that manages available permits. + * Semaphores are mainly used to limit the number of concurrent async tasks. + * + * Each `acquire` operation takes a permit or waits until one is available. + * Each `release` operation adds a permit, potentially allowing a waiting task to proceed. + * + * The semaphore ensures fairness by maintaining a FIFO (First In, First Out) order for acquirers. + * + * @example + * const sema = new Semaphore(2); + * + * async function task() { + * await sema.acquire(); + * try { + * // This code can only be executed by two tasks at the same time + * } finally { + * sema.release(); + * } + * } + * + * task(); + * task(); + * task(); // This task will wait until one of the previous tasks releases the semaphore. + */ +declare class Semaphore { + /** + * The maximum number of concurrent operations allowed. + * @type {number} + */ + capacity: number; + /** + * The number of available permits. + * @type {number} + */ + available: number; + private deferredTasks; + /** + * Creates an instance of Semaphore. + * @param capacity - The maximum number of concurrent operations allowed. + * + * @example + * const sema = new Semaphore(3); // Allows up to 3 concurrent operations. + */ + constructor(capacity: number); + /** + * Acquires a semaphore, blocking if necessary until one is available. + * @returns A promise that resolves when the semaphore is acquired. + * + * @example + * const sema = new Semaphore(1); + * + * async function criticalSection() { + * await sema.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * sema.release(); + * } + * } + */ + acquire(): Promise; + /** + * Releases a semaphore, allowing one more operation to proceed. + * + * @example + * const sema = new Semaphore(1); + * + * async function task() { + * await sema.acquire(); + * try { + * // This code can only be executed by two tasks at the same time + * } finally { + * sema.release(); // Allows another waiting task to proceed. + * } + * } + */ + release(): void; +} +//#endregion +export { Semaphore }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/semaphore.js b/node_modules/es-toolkit/dist/promise/semaphore.js new file mode 100644 index 0000000000000000000000000000000000000000..edb1688d4ae443e2da5a1cc868450eb0bc2a5f95 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/semaphore.js @@ -0,0 +1,100 @@ +//#region src/promise/semaphore.ts +/** +* A counting semaphore for async functions that manages available permits. +* Semaphores are mainly used to limit the number of concurrent async tasks. +* +* Each `acquire` operation takes a permit or waits until one is available. +* Each `release` operation adds a permit, potentially allowing a waiting task to proceed. +* +* The semaphore ensures fairness by maintaining a FIFO (First In, First Out) order for acquirers. +* +* @example +* const sema = new Semaphore(2); +* +* async function task() { +* await sema.acquire(); +* try { +* // This code can only be executed by two tasks at the same time +* } finally { +* sema.release(); +* } +* } +* +* task(); +* task(); +* task(); // This task will wait until one of the previous tasks releases the semaphore. +*/ +var Semaphore = class { + /** + * The maximum number of concurrent operations allowed. + * @type {number} + */ + capacity; + /** + * The number of available permits. + * @type {number} + */ + available; + deferredTasks = []; + /** + * Creates an instance of Semaphore. + * @param capacity - The maximum number of concurrent operations allowed. + * + * @example + * const sema = new Semaphore(3); // Allows up to 3 concurrent operations. + */ + constructor(capacity) { + this.capacity = capacity; + this.available = capacity; + } + /** + * Acquires a semaphore, blocking if necessary until one is available. + * @returns A promise that resolves when the semaphore is acquired. + * + * @example + * const sema = new Semaphore(1); + * + * async function criticalSection() { + * await sema.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * sema.release(); + * } + * } + */ + async acquire() { + if (this.available > 0) { + this.available--; + return; + } + return new Promise((resolve) => { + this.deferredTasks.push(resolve); + }); + } + /** + * Releases a semaphore, allowing one more operation to proceed. + * + * @example + * const sema = new Semaphore(1); + * + * async function task() { + * await sema.acquire(); + * try { + * // This code can only be executed by two tasks at the same time + * } finally { + * sema.release(); // Allows another waiting task to proceed. + * } + * } + */ + release() { + const deferredTask = this.deferredTasks.shift(); + if (deferredTask != null) { + deferredTask(); + return; + } + if (this.available < this.capacity) this.available++; + } +}; +//#endregion +exports.Semaphore = Semaphore; diff --git a/node_modules/es-toolkit/dist/promise/semaphore.mjs b/node_modules/es-toolkit/dist/promise/semaphore.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f4b63405f5020025aa438af1a24cf2bb56998eef --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/semaphore.mjs @@ -0,0 +1,100 @@ +//#region src/promise/semaphore.ts +/** +* A counting semaphore for async functions that manages available permits. +* Semaphores are mainly used to limit the number of concurrent async tasks. +* +* Each `acquire` operation takes a permit or waits until one is available. +* Each `release` operation adds a permit, potentially allowing a waiting task to proceed. +* +* The semaphore ensures fairness by maintaining a FIFO (First In, First Out) order for acquirers. +* +* @example +* const sema = new Semaphore(2); +* +* async function task() { +* await sema.acquire(); +* try { +* // This code can only be executed by two tasks at the same time +* } finally { +* sema.release(); +* } +* } +* +* task(); +* task(); +* task(); // This task will wait until one of the previous tasks releases the semaphore. +*/ +var Semaphore = class { + /** + * The maximum number of concurrent operations allowed. + * @type {number} + */ + capacity; + /** + * The number of available permits. + * @type {number} + */ + available; + deferredTasks = []; + /** + * Creates an instance of Semaphore. + * @param capacity - The maximum number of concurrent operations allowed. + * + * @example + * const sema = new Semaphore(3); // Allows up to 3 concurrent operations. + */ + constructor(capacity) { + this.capacity = capacity; + this.available = capacity; + } + /** + * Acquires a semaphore, blocking if necessary until one is available. + * @returns A promise that resolves when the semaphore is acquired. + * + * @example + * const sema = new Semaphore(1); + * + * async function criticalSection() { + * await sema.acquire(); + * try { + * // This code section cannot be executed simultaneously + * } finally { + * sema.release(); + * } + * } + */ + async acquire() { + if (this.available > 0) { + this.available--; + return; + } + return new Promise((resolve) => { + this.deferredTasks.push(resolve); + }); + } + /** + * Releases a semaphore, allowing one more operation to proceed. + * + * @example + * const sema = new Semaphore(1); + * + * async function task() { + * await sema.acquire(); + * try { + * // This code can only be executed by two tasks at the same time + * } finally { + * sema.release(); // Allows another waiting task to proceed. + * } + * } + */ + release() { + const deferredTask = this.deferredTasks.shift(); + if (deferredTask != null) { + deferredTask(); + return; + } + if (this.available < this.capacity) this.available++; + } +}; +//#endregion +export { Semaphore }; diff --git a/node_modules/es-toolkit/dist/promise/timeout.d.mts b/node_modules/es-toolkit/dist/promise/timeout.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..05ebbb09b2ca96fe36c258f9b25a91c20c8d9dda --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/timeout.d.mts @@ -0,0 +1,41 @@ +//#region src/promise/timeout.d.ts +interface TimeoutOptions { + signal?: AbortSignal; +} +/** + * Returns a promise that rejects with a `TimeoutError` after a specified delay. + * + * You can pass an `AbortSignal` to cancel the timeout. Unlike most `AbortSignal`-aware + * APIs, aborting does **not** reject the promise. A `timeout` only exists to lose a + * `Promise.race`, so cancelling it leaves the promise pending forever, allowing the + * operation it guards to settle on its own. The underlying timer and abort listener + * are cleared on abort, so nothing is leaked. + * + * @param ms - The delay duration in milliseconds. + * @param options - The options object. + * @param options.signal - An optional AbortSignal to cancel the timeout. When aborted, the returned promise never settles. + * @returns A promise that rejects with a `TimeoutError` after the specified delay, or never settles if aborted. + * @throws {TimeoutError} Throws a `TimeoutError` after the specified delay. + * + * @example + * try { + * await timeout(1000); // Timeout exception after 1 second + * } catch (error) { + * console.error(error); // Will log 'The operation was timed out' + * } + * + * @example + * // Cancelling the timeout lifts the time limit instead of throwing. + * const controller = new AbortController(); + * setTimeout(() => controller.abort(), 50); + * + * const result = await Promise.race([ + * doWork(), + * timeout(1000, { signal: controller.signal }), // never rejects once aborted + * ]); + */ +declare function timeout(ms: number, { + signal +}?: TimeoutOptions): Promise; +//#endregion +export { timeout }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/timeout.d.ts b/node_modules/es-toolkit/dist/promise/timeout.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..05ebbb09b2ca96fe36c258f9b25a91c20c8d9dda --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/timeout.d.ts @@ -0,0 +1,41 @@ +//#region src/promise/timeout.d.ts +interface TimeoutOptions { + signal?: AbortSignal; +} +/** + * Returns a promise that rejects with a `TimeoutError` after a specified delay. + * + * You can pass an `AbortSignal` to cancel the timeout. Unlike most `AbortSignal`-aware + * APIs, aborting does **not** reject the promise. A `timeout` only exists to lose a + * `Promise.race`, so cancelling it leaves the promise pending forever, allowing the + * operation it guards to settle on its own. The underlying timer and abort listener + * are cleared on abort, so nothing is leaked. + * + * @param ms - The delay duration in milliseconds. + * @param options - The options object. + * @param options.signal - An optional AbortSignal to cancel the timeout. When aborted, the returned promise never settles. + * @returns A promise that rejects with a `TimeoutError` after the specified delay, or never settles if aborted. + * @throws {TimeoutError} Throws a `TimeoutError` after the specified delay. + * + * @example + * try { + * await timeout(1000); // Timeout exception after 1 second + * } catch (error) { + * console.error(error); // Will log 'The operation was timed out' + * } + * + * @example + * // Cancelling the timeout lifts the time limit instead of throwing. + * const controller = new AbortController(); + * setTimeout(() => controller.abort(), 50); + * + * const result = await Promise.race([ + * doWork(), + * timeout(1000, { signal: controller.signal }), // never rejects once aborted + * ]); + */ +declare function timeout(ms: number, { + signal +}?: TimeoutOptions): Promise; +//#endregion +export { timeout }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/timeout.js b/node_modules/es-toolkit/dist/promise/timeout.js new file mode 100644 index 0000000000000000000000000000000000000000..6e646ab6ef5d093875c38b796dc7531810d36ade --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/timeout.js @@ -0,0 +1,49 @@ +const require_TimeoutError = require("../error/TimeoutError.js"); +//#region src/promise/timeout.ts +/** +* Returns a promise that rejects with a `TimeoutError` after a specified delay. +* +* You can pass an `AbortSignal` to cancel the timeout. Unlike most `AbortSignal`-aware +* APIs, aborting does **not** reject the promise. A `timeout` only exists to lose a +* `Promise.race`, so cancelling it leaves the promise pending forever, allowing the +* operation it guards to settle on its own. The underlying timer and abort listener +* are cleared on abort, so nothing is leaked. +* +* @param ms - The delay duration in milliseconds. +* @param options - The options object. +* @param options.signal - An optional AbortSignal to cancel the timeout. When aborted, the returned promise never settles. +* @returns A promise that rejects with a `TimeoutError` after the specified delay, or never settles if aborted. +* @throws {TimeoutError} Throws a `TimeoutError` after the specified delay. +* +* @example +* try { +* await timeout(1000); // Timeout exception after 1 second +* } catch (error) { +* console.error(error); // Will log 'The operation was timed out' +* } +* +* @example +* // Cancelling the timeout lifts the time limit instead of throwing. +* const controller = new AbortController(); +* setTimeout(() => controller.abort(), 50); +* +* const result = await Promise.race([ +* doWork(), +* timeout(1000, { signal: controller.signal }), // never rejects once aborted +* ]); +*/ +function timeout(ms, { signal } = {}) { + return new Promise((_resolve, reject) => { + const abortHandler = () => { + clearTimeout(timeoutId); + }; + if (signal?.aborted) return; + const timeoutId = setTimeout(() => { + signal?.removeEventListener("abort", abortHandler); + reject(new require_TimeoutError.TimeoutError()); + }, ms); + signal?.addEventListener("abort", abortHandler, { once: true }); + }); +} +//#endregion +exports.timeout = timeout; diff --git a/node_modules/es-toolkit/dist/promise/timeout.mjs b/node_modules/es-toolkit/dist/promise/timeout.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b03aac281181ca7e8a035f7e82334b78febc275c --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/timeout.mjs @@ -0,0 +1,49 @@ +import { TimeoutError } from "../error/TimeoutError.mjs"; +//#region src/promise/timeout.ts +/** +* Returns a promise that rejects with a `TimeoutError` after a specified delay. +* +* You can pass an `AbortSignal` to cancel the timeout. Unlike most `AbortSignal`-aware +* APIs, aborting does **not** reject the promise. A `timeout` only exists to lose a +* `Promise.race`, so cancelling it leaves the promise pending forever, allowing the +* operation it guards to settle on its own. The underlying timer and abort listener +* are cleared on abort, so nothing is leaked. +* +* @param ms - The delay duration in milliseconds. +* @param options - The options object. +* @param options.signal - An optional AbortSignal to cancel the timeout. When aborted, the returned promise never settles. +* @returns A promise that rejects with a `TimeoutError` after the specified delay, or never settles if aborted. +* @throws {TimeoutError} Throws a `TimeoutError` after the specified delay. +* +* @example +* try { +* await timeout(1000); // Timeout exception after 1 second +* } catch (error) { +* console.error(error); // Will log 'The operation was timed out' +* } +* +* @example +* // Cancelling the timeout lifts the time limit instead of throwing. +* const controller = new AbortController(); +* setTimeout(() => controller.abort(), 50); +* +* const result = await Promise.race([ +* doWork(), +* timeout(1000, { signal: controller.signal }), // never rejects once aborted +* ]); +*/ +function timeout(ms, { signal } = {}) { + return new Promise((_resolve, reject) => { + const abortHandler = () => { + clearTimeout(timeoutId); + }; + if (signal?.aborted) return; + const timeoutId = setTimeout(() => { + signal?.removeEventListener("abort", abortHandler); + reject(new TimeoutError()); + }, ms); + signal?.addEventListener("abort", abortHandler, { once: true }); + }); +} +//#endregion +export { timeout }; diff --git a/node_modules/es-toolkit/dist/promise/withTimeout.d.mts b/node_modules/es-toolkit/dist/promise/withTimeout.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9b526d9bf57b7abcdd8bc7a621752da4c6b52a13 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/withTimeout.d.mts @@ -0,0 +1,47 @@ +//#region src/promise/withTimeout.d.ts +interface WithTimeoutOptions { + signal?: AbortSignal; +} +/** + * Executes an async function and enforces a timeout. + * + * If the promise does not resolve within the specified time, + * the timeout will trigger and the returned promise will be rejected. + * + * You can pass an `AbortSignal` to cancel the timeout. Aborting the signal lifts the + * time limit: the timeout stops counting and `run`'s promise is awaited without a + * deadline. It does not reject the returned promise or abort `run` itself — pass the + * same signal into `run` if you also want to cancel the underlying work. + * + * @template T + * @param run - A function that returns a promise to be executed. + * @param ms - The timeout duration in milliseconds. + * @param options - The options object. + * @param options.signal - An optional AbortSignal to cancel the timeout. When aborted, the time limit is lifted. + * @returns A promise that resolves with the result of the `run` function or rejects if the timeout is reached. + * + * @example + * async function fetchData() { + * const response = await fetch('https://example.com/data'); + * return response.json(); + * } + * + * try { + * const data = await withTimeout(fetchData, 1000); + * console.log(data); // Logs the fetched data if `fetchData` is resolved within 1 second. + * } catch (error) { + * console.error(error); // Will log 'TimeoutError' if `fetchData` is not resolved within 1 second. + * } + * + * @example + * // Lift the time limit when the user opts to keep waiting. + * const controller = new AbortController(); + * keepWaitingButton.onclick = () => controller.abort(); + * + * const data = await withTimeout(fetchData, 1000, { signal: controller.signal }); + */ +declare function withTimeout(run: () => Promise, ms: number, { + signal +}?: WithTimeoutOptions): Promise; +//#endregion +export { withTimeout }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/withTimeout.d.ts b/node_modules/es-toolkit/dist/promise/withTimeout.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b526d9bf57b7abcdd8bc7a621752da4c6b52a13 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/withTimeout.d.ts @@ -0,0 +1,47 @@ +//#region src/promise/withTimeout.d.ts +interface WithTimeoutOptions { + signal?: AbortSignal; +} +/** + * Executes an async function and enforces a timeout. + * + * If the promise does not resolve within the specified time, + * the timeout will trigger and the returned promise will be rejected. + * + * You can pass an `AbortSignal` to cancel the timeout. Aborting the signal lifts the + * time limit: the timeout stops counting and `run`'s promise is awaited without a + * deadline. It does not reject the returned promise or abort `run` itself — pass the + * same signal into `run` if you also want to cancel the underlying work. + * + * @template T + * @param run - A function that returns a promise to be executed. + * @param ms - The timeout duration in milliseconds. + * @param options - The options object. + * @param options.signal - An optional AbortSignal to cancel the timeout. When aborted, the time limit is lifted. + * @returns A promise that resolves with the result of the `run` function or rejects if the timeout is reached. + * + * @example + * async function fetchData() { + * const response = await fetch('https://example.com/data'); + * return response.json(); + * } + * + * try { + * const data = await withTimeout(fetchData, 1000); + * console.log(data); // Logs the fetched data if `fetchData` is resolved within 1 second. + * } catch (error) { + * console.error(error); // Will log 'TimeoutError' if `fetchData` is not resolved within 1 second. + * } + * + * @example + * // Lift the time limit when the user opts to keep waiting. + * const controller = new AbortController(); + * keepWaitingButton.onclick = () => controller.abort(); + * + * const data = await withTimeout(fetchData, 1000, { signal: controller.signal }); + */ +declare function withTimeout(run: () => Promise, ms: number, { + signal +}?: WithTimeoutOptions): Promise; +//#endregion +export { withTimeout }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/promise/withTimeout.js b/node_modules/es-toolkit/dist/promise/withTimeout.js new file mode 100644 index 0000000000000000000000000000000000000000..1f4fcf6f99b7925c1f8b800adb1621e3b4c9f2b2 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/withTimeout.js @@ -0,0 +1,45 @@ +const require_timeout = require("./timeout.js"); +//#region src/promise/withTimeout.ts +/** +* Executes an async function and enforces a timeout. +* +* If the promise does not resolve within the specified time, +* the timeout will trigger and the returned promise will be rejected. +* +* You can pass an `AbortSignal` to cancel the timeout. Aborting the signal lifts the +* time limit: the timeout stops counting and `run`'s promise is awaited without a +* deadline. It does not reject the returned promise or abort `run` itself — pass the +* same signal into `run` if you also want to cancel the underlying work. +* +* @template T +* @param run - A function that returns a promise to be executed. +* @param ms - The timeout duration in milliseconds. +* @param options - The options object. +* @param options.signal - An optional AbortSignal to cancel the timeout. When aborted, the time limit is lifted. +* @returns A promise that resolves with the result of the `run` function or rejects if the timeout is reached. +* +* @example +* async function fetchData() { +* const response = await fetch('https://example.com/data'); +* return response.json(); +* } +* +* try { +* const data = await withTimeout(fetchData, 1000); +* console.log(data); // Logs the fetched data if `fetchData` is resolved within 1 second. +* } catch (error) { +* console.error(error); // Will log 'TimeoutError' if `fetchData` is not resolved within 1 second. +* } +* +* @example +* // Lift the time limit when the user opts to keep waiting. +* const controller = new AbortController(); +* keepWaitingButton.onclick = () => controller.abort(); +* +* const data = await withTimeout(fetchData, 1000, { signal: controller.signal }); +*/ +async function withTimeout(run, ms, { signal } = {}) { + return Promise.race([run(), require_timeout.timeout(ms, { signal })]); +} +//#endregion +exports.withTimeout = withTimeout; diff --git a/node_modules/es-toolkit/dist/promise/withTimeout.mjs b/node_modules/es-toolkit/dist/promise/withTimeout.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4e2eba918ebde315969b7feec91e5e175d1f4fd2 --- /dev/null +++ b/node_modules/es-toolkit/dist/promise/withTimeout.mjs @@ -0,0 +1,45 @@ +import { timeout } from "./timeout.mjs"; +//#region src/promise/withTimeout.ts +/** +* Executes an async function and enforces a timeout. +* +* If the promise does not resolve within the specified time, +* the timeout will trigger and the returned promise will be rejected. +* +* You can pass an `AbortSignal` to cancel the timeout. Aborting the signal lifts the +* time limit: the timeout stops counting and `run`'s promise is awaited without a +* deadline. It does not reject the returned promise or abort `run` itself — pass the +* same signal into `run` if you also want to cancel the underlying work. +* +* @template T +* @param run - A function that returns a promise to be executed. +* @param ms - The timeout duration in milliseconds. +* @param options - The options object. +* @param options.signal - An optional AbortSignal to cancel the timeout. When aborted, the time limit is lifted. +* @returns A promise that resolves with the result of the `run` function or rejects if the timeout is reached. +* +* @example +* async function fetchData() { +* const response = await fetch('https://example.com/data'); +* return response.json(); +* } +* +* try { +* const data = await withTimeout(fetchData, 1000); +* console.log(data); // Logs the fetched data if `fetchData` is resolved within 1 second. +* } catch (error) { +* console.error(error); // Will log 'TimeoutError' if `fetchData` is not resolved within 1 second. +* } +* +* @example +* // Lift the time limit when the user opts to keep waiting. +* const controller = new AbortController(); +* keepWaitingButton.onclick = () => controller.abort(); +* +* const data = await withTimeout(fetchData, 1000, { signal: controller.signal }); +*/ +async function withTimeout(run, ms, { signal } = {}) { + return Promise.race([run(), timeout(ms, { signal })]); +} +//#endregion +export { withTimeout }; diff --git a/node_modules/es-toolkit/dist/server/colors/_internal/parseHex.js b/node_modules/es-toolkit/dist/server/colors/_internal/parseHex.js new file mode 100644 index 0000000000000000000000000000000000000000..ebcd1b587ab7bb9df1ac9973ac73df3d9a842984 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/_internal/parseHex.js @@ -0,0 +1,32 @@ +//#region src/server/colors/_internal/parseHex.ts +const BLACK = [ + 0, + 0, + 0 +]; +const HEX_COLOR_REGEX = /^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/; +/** +* Parses a hex color string (e.g. "#ff0000", "#f00", "ff0000") into +* an [r, g, b] tuple. Used by `hex()` and `bgHex()` to convert +* user-provided hex values into RGB components for ANSI escape codes. +* +* Only #RGB and #RRGGBB formats are supported. #RGBA and #RRGGBBAA +* are not accepted because ANSI terminals do not support alpha channels. +* Returns [0, 0, 0] (black) for invalid input. +* +* @param hex - A hex color string, with or without the leading `#`. +* @returns An `[r, g, b]` tuple with each component in the 0–255 range. +*/ +function parseHex(hex) { + const raw = hex.startsWith("#") ? hex.slice(1) : hex; + if (!HEX_COLOR_REGEX.test(raw)) return BLACK; + const full = raw.length === 3 ? raw[0] + raw[0] + raw[1] + raw[1] + raw[2] + raw[2] : raw; + const colorValue = parseInt(full, 16); + return [ + colorValue >> 16 & 255, + colorValue >> 8 & 255, + colorValue & 255 + ]; +} +//#endregion +exports.parseHex = parseHex; diff --git a/node_modules/es-toolkit/dist/server/colors/_internal/parseHex.mjs b/node_modules/es-toolkit/dist/server/colors/_internal/parseHex.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3ea613035d87016afea70367d4aafc716258e8d5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/_internal/parseHex.mjs @@ -0,0 +1,32 @@ +//#region src/server/colors/_internal/parseHex.ts +const BLACK = [ + 0, + 0, + 0 +]; +const HEX_COLOR_REGEX = /^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/; +/** +* Parses a hex color string (e.g. "#ff0000", "#f00", "ff0000") into +* an [r, g, b] tuple. Used by `hex()` and `bgHex()` to convert +* user-provided hex values into RGB components for ANSI escape codes. +* +* Only #RGB and #RRGGBB formats are supported. #RGBA and #RRGGBBAA +* are not accepted because ANSI terminals do not support alpha channels. +* Returns [0, 0, 0] (black) for invalid input. +* +* @param hex - A hex color string, with or without the leading `#`. +* @returns An `[r, g, b]` tuple with each component in the 0–255 range. +*/ +function parseHex(hex) { + const raw = hex.startsWith("#") ? hex.slice(1) : hex; + if (!HEX_COLOR_REGEX.test(raw)) return BLACK; + const full = raw.length === 3 ? raw[0] + raw[0] + raw[1] + raw[1] + raw[2] + raw[2] : raw; + const colorValue = parseInt(full, 16); + return [ + colorValue >> 16 & 255, + colorValue >> 8 & 255, + colorValue & 255 + ]; +} +//#endregion +export { parseHex }; diff --git a/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsi.js b/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsi.js new file mode 100644 index 0000000000000000000000000000000000000000..857f7601c08cdb411c057a2af85e83210da543d1 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsi.js @@ -0,0 +1,21 @@ +//#region src/server/colors/_internal/wrapAnsi.ts +/** +* Wraps text with ANSI open/close codes for foreground colors and modifiers. +* +* If `text` already contains `close` (typically from a nested style that +* shares the same close code, e.g. `red(green('x'))` where both end with +* `\x1b[39m`), re-opens the outer style after each occurrence so the rest +* of the text keeps its color. For background colors use `wrapAnsiBg` +* instead — it adds the newline handling that backgrounds need. +* +* @param open - The ANSI open code (e.g. `\x1b[31m`). +* @param close - The ANSI close code (e.g. `\x1b[39m`). +* @param text - The text to wrap. +* @returns The wrapped text. +*/ +function wrapAnsi(open, close, text) { + if (text.includes(close)) text = text.replaceAll(close, close + open); + return open + text + close; +} +//#endregion +exports.wrapAnsi = wrapAnsi; diff --git a/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsi.mjs b/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsi.mjs new file mode 100644 index 0000000000000000000000000000000000000000..52ed5fc3fdfc3994f72a0b5afcb049b396aaa4b5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsi.mjs @@ -0,0 +1,21 @@ +//#region src/server/colors/_internal/wrapAnsi.ts +/** +* Wraps text with ANSI open/close codes for foreground colors and modifiers. +* +* If `text` already contains `close` (typically from a nested style that +* shares the same close code, e.g. `red(green('x'))` where both end with +* `\x1b[39m`), re-opens the outer style after each occurrence so the rest +* of the text keeps its color. For background colors use `wrapAnsiBg` +* instead — it adds the newline handling that backgrounds need. +* +* @param open - The ANSI open code (e.g. `\x1b[31m`). +* @param close - The ANSI close code (e.g. `\x1b[39m`). +* @param text - The text to wrap. +* @returns The wrapped text. +*/ +function wrapAnsi(open, close, text) { + if (text.includes(close)) text = text.replaceAll(close, close + open); + return open + text + close; +} +//#endregion +export { wrapAnsi }; diff --git a/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsiBg.js b/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsiBg.js new file mode 100644 index 0000000000000000000000000000000000000000..41b10fea01322f4987a0cadf07aeb0fe65f2e008 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsiBg.js @@ -0,0 +1,30 @@ +//#region src/server/colors/_internal/wrapAnsiBg.ts +/** +* Wraps text with ANSI open/close codes for background colors. +* +* On top of the basic wrap, handles two cases: +* +* 1. **Nested style sharing the same close.** If `text` already contains +* `close` (e.g. `bgRed(bgGreen('x'))` where both end with `\x1b[49m`), +* re-opens the outer style after each occurrence so the rest keeps its +* color. This step runs first. +* 2. **Multi-line text.** Terminals reset the background color at line +* boundaries, so the bg disappears after `\n` if not re-opened. Insert +* `close + open` around every newline. CRLF is treated as a single unit +* so the close sits outside both characters. +* +* Step 2 must run after step 1 — otherwise the close codes that step 2 +* inserts would also trigger step 1's re-open and leak duplicate codes. +* +* @param open - The ANSI background open code (e.g. `\x1b[41m`). +* @param close - The ANSI background close code (e.g. `\x1b[49m`). +* @param text - The text to wrap. +* @returns The wrapped text. +*/ +function wrapAnsiBg(open, close, text) { + if (text.includes(close)) text = text.replaceAll(close, close + open); + if (text.includes("\n")) text = text.replaceAll(/\r?\n/g, (match) => close + match + open); + return open + text + close; +} +//#endregion +exports.wrapAnsiBg = wrapAnsiBg; diff --git a/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsiBg.mjs b/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsiBg.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0aaeaa9c19d291b9b17d8343ad81fc4337900339 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/_internal/wrapAnsiBg.mjs @@ -0,0 +1,30 @@ +//#region src/server/colors/_internal/wrapAnsiBg.ts +/** +* Wraps text with ANSI open/close codes for background colors. +* +* On top of the basic wrap, handles two cases: +* +* 1. **Nested style sharing the same close.** If `text` already contains +* `close` (e.g. `bgRed(bgGreen('x'))` where both end with `\x1b[49m`), +* re-opens the outer style after each occurrence so the rest keeps its +* color. This step runs first. +* 2. **Multi-line text.** Terminals reset the background color at line +* boundaries, so the bg disappears after `\n` if not re-opened. Insert +* `close + open` around every newline. CRLF is treated as a single unit +* so the close sits outside both characters. +* +* Step 2 must run after step 1 — otherwise the close codes that step 2 +* inserts would also trigger step 1's re-open and leak duplicate codes. +* +* @param open - The ANSI background open code (e.g. `\x1b[41m`). +* @param close - The ANSI background close code (e.g. `\x1b[49m`). +* @param text - The text to wrap. +* @returns The wrapped text. +*/ +function wrapAnsiBg(open, close, text) { + if (text.includes(close)) text = text.replaceAll(close, close + open); + if (text.includes("\n")) text = text.replaceAll(/\r?\n/g, (match) => close + match + open); + return open + text + close; +} +//#endregion +export { wrapAnsiBg }; diff --git a/node_modules/es-toolkit/dist/server/colors/ansi256.d.mts b/node_modules/es-toolkit/dist/server/colors/ansi256.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..dc886f41c3ace2b122d468184263ea26c2467e48 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/ansi256.d.mts @@ -0,0 +1,18 @@ +import { ColorFunction } from "./types.mjs"; + +//#region src/server/colors/ansi256.d.ts +/** + * Returns a function that wraps text with the given 8-bit (256-color) foreground. + * + * @param code - The 8-bit color code (0–255). + * @returns A color function that wraps text with the chosen ANSI 256 foreground. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * const orange = colors.ansi256(208); + * console.log(orange('hello')); + */ +declare function ansi256(code: number): ColorFunction; +//#endregion +export { ansi256 }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/ansi256.d.ts b/node_modules/es-toolkit/dist/server/colors/ansi256.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..11555dd60e3a9473e359f87badac9837b331dd8f --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/ansi256.d.ts @@ -0,0 +1,18 @@ +import { ColorFunction } from "./types.js"; + +//#region src/server/colors/ansi256.d.ts +/** + * Returns a function that wraps text with the given 8-bit (256-color) foreground. + * + * @param code - The 8-bit color code (0–255). + * @returns A color function that wraps text with the chosen ANSI 256 foreground. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * const orange = colors.ansi256(208); + * console.log(orange('hello')); + */ +declare function ansi256(code: number): ColorFunction; +//#endregion +export { ansi256 }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/ansi256.js b/node_modules/es-toolkit/dist/server/colors/ansi256.js new file mode 100644 index 0000000000000000000000000000000000000000..983d6ec076421180108abeb34e17fd80a4bb356d --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/ansi256.js @@ -0,0 +1,19 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/ansi256.ts +/** +* Returns a function that wraps text with the given 8-bit (256-color) foreground. +* +* @param code - The 8-bit color code (0–255). +* @returns A color function that wraps text with the chosen ANSI 256 foreground. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* const orange = colors.ansi256(208); +* console.log(orange('hello')); +*/ +function ansi256(code) { + return (text) => require_wrapAnsi.wrapAnsi(`\x1b[38;5;${code}m`, "\x1B[39m", text); +} +//#endregion +exports.ansi256 = ansi256; diff --git a/node_modules/es-toolkit/dist/server/colors/ansi256.mjs b/node_modules/es-toolkit/dist/server/colors/ansi256.mjs new file mode 100644 index 0000000000000000000000000000000000000000..38743db3b7296e584262a8eddc873f15dcd07555 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/ansi256.mjs @@ -0,0 +1,19 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/ansi256.ts +/** +* Returns a function that wraps text with the given 8-bit (256-color) foreground. +* +* @param code - The 8-bit color code (0–255). +* @returns A color function that wraps text with the chosen ANSI 256 foreground. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* const orange = colors.ansi256(208); +* console.log(orange('hello')); +*/ +function ansi256(code) { + return (text) => wrapAnsi(`\x1b[38;5;${code}m`, "\x1B[39m", text); +} +//#endregion +export { ansi256 }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgAnsi256.d.mts b/node_modules/es-toolkit/dist/server/colors/bgAnsi256.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b4ce8cedee74d0435d71bdb10457099b46f97791 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgAnsi256.d.mts @@ -0,0 +1,18 @@ +import { ColorFunction } from "./types.mjs"; + +//#region src/server/colors/bgAnsi256.d.ts +/** + * Returns a function that wraps text with the given 8-bit (256-color) background. + * + * @param code - The 8-bit color code (0–255). + * @returns A color function that wraps text with the chosen ANSI 256 background. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * const warn = colors.bgAnsi256(208); + * console.log(warn('hello')); + */ +declare function bgAnsi256(code: number): ColorFunction; +//#endregion +export { bgAnsi256 }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgAnsi256.d.ts b/node_modules/es-toolkit/dist/server/colors/bgAnsi256.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..69a5c79998eba0eb922991f83d086aa76bda86cd --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgAnsi256.d.ts @@ -0,0 +1,18 @@ +import { ColorFunction } from "./types.js"; + +//#region src/server/colors/bgAnsi256.d.ts +/** + * Returns a function that wraps text with the given 8-bit (256-color) background. + * + * @param code - The 8-bit color code (0–255). + * @returns A color function that wraps text with the chosen ANSI 256 background. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * const warn = colors.bgAnsi256(208); + * console.log(warn('hello')); + */ +declare function bgAnsi256(code: number): ColorFunction; +//#endregion +export { bgAnsi256 }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgAnsi256.js b/node_modules/es-toolkit/dist/server/colors/bgAnsi256.js new file mode 100644 index 0000000000000000000000000000000000000000..af9dea8b0934182c51630735bea6ef7e04b0a08f --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgAnsi256.js @@ -0,0 +1,19 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgAnsi256.ts +/** +* Returns a function that wraps text with the given 8-bit (256-color) background. +* +* @param code - The 8-bit color code (0–255). +* @returns A color function that wraps text with the chosen ANSI 256 background. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* const warn = colors.bgAnsi256(208); +* console.log(warn('hello')); +*/ +function bgAnsi256(code) { + return (text) => require_wrapAnsiBg.wrapAnsiBg(`\x1b[48;5;${code}m`, "\x1B[49m", text); +} +//#endregion +exports.bgAnsi256 = bgAnsi256; diff --git a/node_modules/es-toolkit/dist/server/colors/bgAnsi256.mjs b/node_modules/es-toolkit/dist/server/colors/bgAnsi256.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ef3372e7e6c05cbf47151e735dd8bf33cd27cc24 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgAnsi256.mjs @@ -0,0 +1,19 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgAnsi256.ts +/** +* Returns a function that wraps text with the given 8-bit (256-color) background. +* +* @param code - The 8-bit color code (0–255). +* @returns A color function that wraps text with the chosen ANSI 256 background. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* const warn = colors.bgAnsi256(208); +* console.log(warn('hello')); +*/ +function bgAnsi256(code) { + return (text) => wrapAnsiBg(`\x1b[48;5;${code}m`, "\x1B[49m", text); +} +//#endregion +export { bgAnsi256 }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlack.d.mts b/node_modules/es-toolkit/dist/server/colors/bgBlack.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..32b0ed8d692efbf10f45dddd7fa4cd5ca909ec57 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlack.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgBlack.d.ts +/** + * Black background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgBlack('hello')); + */ +declare function bgBlack(text: string): string; +//#endregion +export { bgBlack }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlack.d.ts b/node_modules/es-toolkit/dist/server/colors/bgBlack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..32b0ed8d692efbf10f45dddd7fa4cd5ca909ec57 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlack.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgBlack.d.ts +/** + * Black background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgBlack('hello')); + */ +declare function bgBlack(text: string): string; +//#endregion +export { bgBlack }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlack.js b/node_modules/es-toolkit/dist/server/colors/bgBlack.js new file mode 100644 index 0000000000000000000000000000000000000000..45476ece1ef0e3a97f38ae78ebe9d0cc38b433d7 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlack.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgBlack.ts +/** +* Black background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgBlack('hello')); +*/ +function bgBlack(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[40m", "\x1B[49m", text); +} +//#endregion +exports.bgBlack = bgBlack; diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlack.mjs b/node_modules/es-toolkit/dist/server/colors/bgBlack.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b540ddc8f68a2479cb53cbc10a23bbcc907d3273 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlack.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgBlack.ts +/** +* Black background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgBlack('hello')); +*/ +function bgBlack(text) { + return wrapAnsiBg("\x1B[40m", "\x1B[49m", text); +} +//#endregion +export { bgBlack }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlackBright.d.mts b/node_modules/es-toolkit/dist/server/colors/bgBlackBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..b362d2844a389a915dfe3931acbe77c351c52358 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlackBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgBlackBright.d.ts +/** + * Bright black (gray) background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgBlackBright('hello')); + */ +declare function bgBlackBright(text: string): string; +//#endregion +export { bgBlackBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlackBright.d.ts b/node_modules/es-toolkit/dist/server/colors/bgBlackBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b362d2844a389a915dfe3931acbe77c351c52358 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlackBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgBlackBright.d.ts +/** + * Bright black (gray) background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgBlackBright('hello')); + */ +declare function bgBlackBright(text: string): string; +//#endregion +export { bgBlackBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlackBright.js b/node_modules/es-toolkit/dist/server/colors/bgBlackBright.js new file mode 100644 index 0000000000000000000000000000000000000000..06c785dc3ed7bea9ac539b6dc2ba5135e3bda627 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlackBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgBlackBright.ts +/** +* Bright black (gray) background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgBlackBright('hello')); +*/ +function bgBlackBright(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[100m", "\x1B[49m", text); +} +//#endregion +exports.bgBlackBright = bgBlackBright; diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlackBright.mjs b/node_modules/es-toolkit/dist/server/colors/bgBlackBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b60b70e53df6fe060af1a7918322808a5fcb230c --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlackBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgBlackBright.ts +/** +* Bright black (gray) background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgBlackBright('hello')); +*/ +function bgBlackBright(text) { + return wrapAnsiBg("\x1B[100m", "\x1B[49m", text); +} +//#endregion +export { bgBlackBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlue.d.mts b/node_modules/es-toolkit/dist/server/colors/bgBlue.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3c35f05fde5d44d9b9f9961c01bd6ebb2a2bb74b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlue.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgBlue.d.ts +/** + * Blue background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgBlue('hello')); + */ +declare function bgBlue(text: string): string; +//#endregion +export { bgBlue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlue.d.ts b/node_modules/es-toolkit/dist/server/colors/bgBlue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c35f05fde5d44d9b9f9961c01bd6ebb2a2bb74b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlue.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgBlue.d.ts +/** + * Blue background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgBlue('hello')); + */ +declare function bgBlue(text: string): string; +//#endregion +export { bgBlue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlue.js b/node_modules/es-toolkit/dist/server/colors/bgBlue.js new file mode 100644 index 0000000000000000000000000000000000000000..3d8f23f63369ff2ecc67e28cf6c253849c3b6d4b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlue.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgBlue.ts +/** +* Blue background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgBlue('hello')); +*/ +function bgBlue(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[44m", "\x1B[49m", text); +} +//#endregion +exports.bgBlue = bgBlue; diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlue.mjs b/node_modules/es-toolkit/dist/server/colors/bgBlue.mjs new file mode 100644 index 0000000000000000000000000000000000000000..46eddcbcfd89048f12b201fa3897265cc1eb1512 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlue.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgBlue.ts +/** +* Blue background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgBlue('hello')); +*/ +function bgBlue(text) { + return wrapAnsiBg("\x1B[44m", "\x1B[49m", text); +} +//#endregion +export { bgBlue }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlueBright.d.mts b/node_modules/es-toolkit/dist/server/colors/bgBlueBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a6cee4bdbe6ad56712312a48a13d72fb34c403a5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlueBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgBlueBright.d.ts +/** + * Bright blue background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgBlueBright('hello')); + */ +declare function bgBlueBright(text: string): string; +//#endregion +export { bgBlueBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlueBright.d.ts b/node_modules/es-toolkit/dist/server/colors/bgBlueBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a6cee4bdbe6ad56712312a48a13d72fb34c403a5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlueBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgBlueBright.d.ts +/** + * Bright blue background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgBlueBright('hello')); + */ +declare function bgBlueBright(text: string): string; +//#endregion +export { bgBlueBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlueBright.js b/node_modules/es-toolkit/dist/server/colors/bgBlueBright.js new file mode 100644 index 0000000000000000000000000000000000000000..3913fa27684a73c2e2e6a01c7baf1b00739bc62d --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlueBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgBlueBright.ts +/** +* Bright blue background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgBlueBright('hello')); +*/ +function bgBlueBright(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[104m", "\x1B[49m", text); +} +//#endregion +exports.bgBlueBright = bgBlueBright; diff --git a/node_modules/es-toolkit/dist/server/colors/bgBlueBright.mjs b/node_modules/es-toolkit/dist/server/colors/bgBlueBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9086809c8349f3b5daed2c4f22d00d5392982e6b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgBlueBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgBlueBright.ts +/** +* Bright blue background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgBlueBright('hello')); +*/ +function bgBlueBright(text) { + return wrapAnsiBg("\x1B[104m", "\x1B[49m", text); +} +//#endregion +export { bgBlueBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgCyan.d.mts b/node_modules/es-toolkit/dist/server/colors/bgCyan.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d1d145ebf7663a04fe8c094923766f41fa3c8cf5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgCyan.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgCyan.d.ts +/** + * Cyan background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgCyan('hello')); + */ +declare function bgCyan(text: string): string; +//#endregion +export { bgCyan }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgCyan.d.ts b/node_modules/es-toolkit/dist/server/colors/bgCyan.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1d145ebf7663a04fe8c094923766f41fa3c8cf5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgCyan.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgCyan.d.ts +/** + * Cyan background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgCyan('hello')); + */ +declare function bgCyan(text: string): string; +//#endregion +export { bgCyan }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgCyan.js b/node_modules/es-toolkit/dist/server/colors/bgCyan.js new file mode 100644 index 0000000000000000000000000000000000000000..7fb0b0d9b07d42f06ff1d20bd8a87ebafcdeb0cf --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgCyan.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgCyan.ts +/** +* Cyan background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgCyan('hello')); +*/ +function bgCyan(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[46m", "\x1B[49m", text); +} +//#endregion +exports.bgCyan = bgCyan; diff --git a/node_modules/es-toolkit/dist/server/colors/bgCyan.mjs b/node_modules/es-toolkit/dist/server/colors/bgCyan.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b998bd2625fbd1ce971f3a0b14b8c3d786414f1d --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgCyan.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgCyan.ts +/** +* Cyan background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgCyan('hello')); +*/ +function bgCyan(text) { + return wrapAnsiBg("\x1B[46m", "\x1B[49m", text); +} +//#endregion +export { bgCyan }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgCyanBright.d.mts b/node_modules/es-toolkit/dist/server/colors/bgCyanBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d06bd8ec62c63fae1461a13cb0549be237de8273 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgCyanBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgCyanBright.d.ts +/** + * Bright cyan background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgCyanBright('hello')); + */ +declare function bgCyanBright(text: string): string; +//#endregion +export { bgCyanBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgCyanBright.d.ts b/node_modules/es-toolkit/dist/server/colors/bgCyanBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d06bd8ec62c63fae1461a13cb0549be237de8273 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgCyanBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgCyanBright.d.ts +/** + * Bright cyan background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgCyanBright('hello')); + */ +declare function bgCyanBright(text: string): string; +//#endregion +export { bgCyanBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgCyanBright.js b/node_modules/es-toolkit/dist/server/colors/bgCyanBright.js new file mode 100644 index 0000000000000000000000000000000000000000..c75d6257cdf807dff6efbf3c5d772f6f45768d90 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgCyanBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgCyanBright.ts +/** +* Bright cyan background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgCyanBright('hello')); +*/ +function bgCyanBright(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[106m", "\x1B[49m", text); +} +//#endregion +exports.bgCyanBright = bgCyanBright; diff --git a/node_modules/es-toolkit/dist/server/colors/bgCyanBright.mjs b/node_modules/es-toolkit/dist/server/colors/bgCyanBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..49b832b751292717370facc871ac60c13532d2aa --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgCyanBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgCyanBright.ts +/** +* Bright cyan background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgCyanBright('hello')); +*/ +function bgCyanBright(text) { + return wrapAnsiBg("\x1B[106m", "\x1B[49m", text); +} +//#endregion +export { bgCyanBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgGreen.d.mts b/node_modules/es-toolkit/dist/server/colors/bgGreen.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4c19110d738a9a28a8749dc977c470d1ba63bdcd --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgGreen.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgGreen.d.ts +/** + * Green background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgGreen('hello')); + */ +declare function bgGreen(text: string): string; +//#endregion +export { bgGreen }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgGreen.d.ts b/node_modules/es-toolkit/dist/server/colors/bgGreen.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c19110d738a9a28a8749dc977c470d1ba63bdcd --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgGreen.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgGreen.d.ts +/** + * Green background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgGreen('hello')); + */ +declare function bgGreen(text: string): string; +//#endregion +export { bgGreen }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgGreen.js b/node_modules/es-toolkit/dist/server/colors/bgGreen.js new file mode 100644 index 0000000000000000000000000000000000000000..265f7c9c3944e9ac582f5fd710cf99bd0c18e862 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgGreen.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgGreen.ts +/** +* Green background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgGreen('hello')); +*/ +function bgGreen(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[42m", "\x1B[49m", text); +} +//#endregion +exports.bgGreen = bgGreen; diff --git a/node_modules/es-toolkit/dist/server/colors/bgGreen.mjs b/node_modules/es-toolkit/dist/server/colors/bgGreen.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2fd0da18c4f6364aaea7cec5ef7c92884bc4e7c8 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgGreen.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgGreen.ts +/** +* Green background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgGreen('hello')); +*/ +function bgGreen(text) { + return wrapAnsiBg("\x1B[42m", "\x1B[49m", text); +} +//#endregion +export { bgGreen }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgGreenBright.d.mts b/node_modules/es-toolkit/dist/server/colors/bgGreenBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..edb68e310e3dafb30ba53d0d6249019bcc184869 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgGreenBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgGreenBright.d.ts +/** + * Bright green background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgGreenBright('hello')); + */ +declare function bgGreenBright(text: string): string; +//#endregion +export { bgGreenBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgGreenBright.d.ts b/node_modules/es-toolkit/dist/server/colors/bgGreenBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..edb68e310e3dafb30ba53d0d6249019bcc184869 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgGreenBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgGreenBright.d.ts +/** + * Bright green background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgGreenBright('hello')); + */ +declare function bgGreenBright(text: string): string; +//#endregion +export { bgGreenBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgGreenBright.js b/node_modules/es-toolkit/dist/server/colors/bgGreenBright.js new file mode 100644 index 0000000000000000000000000000000000000000..d9b7cdae2b7efbb09656899542b0ccd3f02f311c --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgGreenBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgGreenBright.ts +/** +* Bright green background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgGreenBright('hello')); +*/ +function bgGreenBright(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[102m", "\x1B[49m", text); +} +//#endregion +exports.bgGreenBright = bgGreenBright; diff --git a/node_modules/es-toolkit/dist/server/colors/bgGreenBright.mjs b/node_modules/es-toolkit/dist/server/colors/bgGreenBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6a8e49201b52bb3886a6f08da45e79a7543f6f2d --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgGreenBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgGreenBright.ts +/** +* Bright green background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgGreenBright('hello')); +*/ +function bgGreenBright(text) { + return wrapAnsiBg("\x1B[102m", "\x1B[49m", text); +} +//#endregion +export { bgGreenBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgHex.d.mts b/node_modules/es-toolkit/dist/server/colors/bgHex.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e90e63409e280f3873d41cd0378f217185beb765 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgHex.d.mts @@ -0,0 +1,18 @@ +import { ColorFunction } from "./types.mjs"; + +//#region src/server/colors/bgHex.d.ts +/** + * Returns a function that wraps text with a 24-bit background color parsed from a hex string. + * Accepts `#RGB`, `#RRGGBB`, or the same without `#`. + * + * @param color - A hex color string (e.g. `"#ff6347"`, `"#f00"`). + * @returns A color function that wraps text with the parsed RGB background. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgHex('#ff6347')('hello')); + */ +declare function bgHex(color: string): ColorFunction; +//#endregion +export { bgHex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgHex.d.ts b/node_modules/es-toolkit/dist/server/colors/bgHex.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e4cb523efa3345fdc53c4fc63c83e3f77c595d3 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgHex.d.ts @@ -0,0 +1,18 @@ +import { ColorFunction } from "./types.js"; + +//#region src/server/colors/bgHex.d.ts +/** + * Returns a function that wraps text with a 24-bit background color parsed from a hex string. + * Accepts `#RGB`, `#RRGGBB`, or the same without `#`. + * + * @param color - A hex color string (e.g. `"#ff6347"`, `"#f00"`). + * @returns A color function that wraps text with the parsed RGB background. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgHex('#ff6347')('hello')); + */ +declare function bgHex(color: string): ColorFunction; +//#endregion +export { bgHex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgHex.js b/node_modules/es-toolkit/dist/server/colors/bgHex.js new file mode 100644 index 0000000000000000000000000000000000000000..c209265f3026f75b87168e8df45d0e13d2035c43 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgHex.js @@ -0,0 +1,21 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +const require_parseHex = require("./_internal/parseHex.js"); +//#region src/server/colors/bgHex.ts +/** +* Returns a function that wraps text with a 24-bit background color parsed from a hex string. +* Accepts `#RGB`, `#RRGGBB`, or the same without `#`. +* +* @param color - A hex color string (e.g. `"#ff6347"`, `"#f00"`). +* @returns A color function that wraps text with the parsed RGB background. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgHex('#ff6347')('hello')); +*/ +function bgHex(color) { + const [r, g, b] = require_parseHex.parseHex(color); + return (text) => require_wrapAnsiBg.wrapAnsiBg(`\x1b[48;2;${r};${g};${b}m`, "\x1B[49m", text); +} +//#endregion +exports.bgHex = bgHex; diff --git a/node_modules/es-toolkit/dist/server/colors/bgHex.mjs b/node_modules/es-toolkit/dist/server/colors/bgHex.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4f14257a2817487c5f374e8eb58aa97b57c1ce4b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgHex.mjs @@ -0,0 +1,21 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +import { parseHex } from "./_internal/parseHex.mjs"; +//#region src/server/colors/bgHex.ts +/** +* Returns a function that wraps text with a 24-bit background color parsed from a hex string. +* Accepts `#RGB`, `#RRGGBB`, or the same without `#`. +* +* @param color - A hex color string (e.g. `"#ff6347"`, `"#f00"`). +* @returns A color function that wraps text with the parsed RGB background. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgHex('#ff6347')('hello')); +*/ +function bgHex(color) { + const [r, g, b] = parseHex(color); + return (text) => wrapAnsiBg(`\x1b[48;2;${r};${g};${b}m`, "\x1B[49m", text); +} +//#endregion +export { bgHex }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgMagenta.d.mts b/node_modules/es-toolkit/dist/server/colors/bgMagenta.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6bbabca8598b242d7441495b46082d55e5b424d5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgMagenta.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgMagenta.d.ts +/** + * Magenta background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgMagenta('hello')); + */ +declare function bgMagenta(text: string): string; +//#endregion +export { bgMagenta }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgMagenta.d.ts b/node_modules/es-toolkit/dist/server/colors/bgMagenta.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6bbabca8598b242d7441495b46082d55e5b424d5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgMagenta.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgMagenta.d.ts +/** + * Magenta background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgMagenta('hello')); + */ +declare function bgMagenta(text: string): string; +//#endregion +export { bgMagenta }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgMagenta.js b/node_modules/es-toolkit/dist/server/colors/bgMagenta.js new file mode 100644 index 0000000000000000000000000000000000000000..47ab5ff4b57395ddab4630fc3694c2bfca48b933 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgMagenta.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgMagenta.ts +/** +* Magenta background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgMagenta('hello')); +*/ +function bgMagenta(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[45m", "\x1B[49m", text); +} +//#endregion +exports.bgMagenta = bgMagenta; diff --git a/node_modules/es-toolkit/dist/server/colors/bgMagenta.mjs b/node_modules/es-toolkit/dist/server/colors/bgMagenta.mjs new file mode 100644 index 0000000000000000000000000000000000000000..876f98feb025cfc4c855a20176f681883a1fb245 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgMagenta.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgMagenta.ts +/** +* Magenta background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgMagenta('hello')); +*/ +function bgMagenta(text) { + return wrapAnsiBg("\x1B[45m", "\x1B[49m", text); +} +//#endregion +export { bgMagenta }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.d.mts b/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a8cb9910658092792324550a7c58159033ee1b5b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgMagentaBright.d.ts +/** + * Bright magenta background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgMagentaBright('hello')); + */ +declare function bgMagentaBright(text: string): string; +//#endregion +export { bgMagentaBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.d.ts b/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8cb9910658092792324550a7c58159033ee1b5b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgMagentaBright.d.ts +/** + * Bright magenta background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgMagentaBright('hello')); + */ +declare function bgMagentaBright(text: string): string; +//#endregion +export { bgMagentaBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.js b/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.js new file mode 100644 index 0000000000000000000000000000000000000000..655834b15e10efa3cdc58c937ef82f82bc6cd398 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgMagentaBright.ts +/** +* Bright magenta background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgMagentaBright('hello')); +*/ +function bgMagentaBright(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[105m", "\x1B[49m", text); +} +//#endregion +exports.bgMagentaBright = bgMagentaBright; diff --git a/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.mjs b/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c8bff2e26d93f0bb14bee0282631443c1902ea24 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgMagentaBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgMagentaBright.ts +/** +* Bright magenta background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgMagentaBright('hello')); +*/ +function bgMagentaBright(text) { + return wrapAnsiBg("\x1B[105m", "\x1B[49m", text); +} +//#endregion +export { bgMagentaBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgRed.d.mts b/node_modules/es-toolkit/dist/server/colors/bgRed.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..78a2dd7a22cc17a47122675f580261d43f004cef --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRed.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgRed.d.ts +/** + * Red background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgRed('hello')); + */ +declare function bgRed(text: string): string; +//#endregion +export { bgRed }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgRed.d.ts b/node_modules/es-toolkit/dist/server/colors/bgRed.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..78a2dd7a22cc17a47122675f580261d43f004cef --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRed.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgRed.d.ts +/** + * Red background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgRed('hello')); + */ +declare function bgRed(text: string): string; +//#endregion +export { bgRed }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgRed.js b/node_modules/es-toolkit/dist/server/colors/bgRed.js new file mode 100644 index 0000000000000000000000000000000000000000..54450c3ce6615cfd053736d6b221578eb63f7be0 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRed.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgRed.ts +/** +* Red background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgRed('hello')); +*/ +function bgRed(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[41m", "\x1B[49m", text); +} +//#endregion +exports.bgRed = bgRed; diff --git a/node_modules/es-toolkit/dist/server/colors/bgRed.mjs b/node_modules/es-toolkit/dist/server/colors/bgRed.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5a05aa9ace0b94c5fefc05182833e424c27b3589 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRed.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgRed.ts +/** +* Red background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgRed('hello')); +*/ +function bgRed(text) { + return wrapAnsiBg("\x1B[41m", "\x1B[49m", text); +} +//#endregion +export { bgRed }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgRedBright.d.mts b/node_modules/es-toolkit/dist/server/colors/bgRedBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..bf6ff14b570c759084a4aca6b652b8debdec6651 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRedBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgRedBright.d.ts +/** + * Bright red background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgRedBright('hello')); + */ +declare function bgRedBright(text: string): string; +//#endregion +export { bgRedBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgRedBright.d.ts b/node_modules/es-toolkit/dist/server/colors/bgRedBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bf6ff14b570c759084a4aca6b652b8debdec6651 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRedBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgRedBright.d.ts +/** + * Bright red background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgRedBright('hello')); + */ +declare function bgRedBright(text: string): string; +//#endregion +export { bgRedBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgRedBright.js b/node_modules/es-toolkit/dist/server/colors/bgRedBright.js new file mode 100644 index 0000000000000000000000000000000000000000..ac35f163d275917c7ec4a9270128da4eb4da1a7b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRedBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgRedBright.ts +/** +* Bright red background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgRedBright('hello')); +*/ +function bgRedBright(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[101m", "\x1B[49m", text); +} +//#endregion +exports.bgRedBright = bgRedBright; diff --git a/node_modules/es-toolkit/dist/server/colors/bgRedBright.mjs b/node_modules/es-toolkit/dist/server/colors/bgRedBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..27e9ef8108e7770a16685caad41477d3bc470376 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRedBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgRedBright.ts +/** +* Bright red background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgRedBright('hello')); +*/ +function bgRedBright(text) { + return wrapAnsiBg("\x1B[101m", "\x1B[49m", text); +} +//#endregion +export { bgRedBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgRgb.d.mts b/node_modules/es-toolkit/dist/server/colors/bgRgb.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..85b23e5b0890384a982971b6def3c1a09e59606b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRgb.d.mts @@ -0,0 +1,20 @@ +import { ColorFunction } from "./types.mjs"; + +//#region src/server/colors/bgRgb.d.ts +/** + * Returns a function that wraps text with the given 24-bit (truecolor) background. + * + * @param r - Red component (0–255). + * @param g - Green component (0–255). + * @param b - Blue component (0–255). + * @returns A color function that wraps text with the chosen RGB background. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * const highlight = colors.bgRgb(255, 99, 71); + * console.log(highlight('hello')); + */ +declare function bgRgb(r: number, g: number, b: number): ColorFunction; +//#endregion +export { bgRgb }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgRgb.d.ts b/node_modules/es-toolkit/dist/server/colors/bgRgb.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..92ddd2fc021d418296e922762c9ccbbf5dca31c5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRgb.d.ts @@ -0,0 +1,20 @@ +import { ColorFunction } from "./types.js"; + +//#region src/server/colors/bgRgb.d.ts +/** + * Returns a function that wraps text with the given 24-bit (truecolor) background. + * + * @param r - Red component (0–255). + * @param g - Green component (0–255). + * @param b - Blue component (0–255). + * @returns A color function that wraps text with the chosen RGB background. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * const highlight = colors.bgRgb(255, 99, 71); + * console.log(highlight('hello')); + */ +declare function bgRgb(r: number, g: number, b: number): ColorFunction; +//#endregion +export { bgRgb }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgRgb.js b/node_modules/es-toolkit/dist/server/colors/bgRgb.js new file mode 100644 index 0000000000000000000000000000000000000000..853086eb59070284fe3478d109089a45a088b978 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRgb.js @@ -0,0 +1,21 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgRgb.ts +/** +* Returns a function that wraps text with the given 24-bit (truecolor) background. +* +* @param r - Red component (0–255). +* @param g - Green component (0–255). +* @param b - Blue component (0–255). +* @returns A color function that wraps text with the chosen RGB background. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* const highlight = colors.bgRgb(255, 99, 71); +* console.log(highlight('hello')); +*/ +function bgRgb(r, g, b) { + return (text) => require_wrapAnsiBg.wrapAnsiBg(`\x1b[48;2;${r};${g};${b}m`, "\x1B[49m", text); +} +//#endregion +exports.bgRgb = bgRgb; diff --git a/node_modules/es-toolkit/dist/server/colors/bgRgb.mjs b/node_modules/es-toolkit/dist/server/colors/bgRgb.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1c6dc17b6ab43b223a64e781a2b8d16f8fdb19b0 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgRgb.mjs @@ -0,0 +1,21 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgRgb.ts +/** +* Returns a function that wraps text with the given 24-bit (truecolor) background. +* +* @param r - Red component (0–255). +* @param g - Green component (0–255). +* @param b - Blue component (0–255). +* @returns A color function that wraps text with the chosen RGB background. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* const highlight = colors.bgRgb(255, 99, 71); +* console.log(highlight('hello')); +*/ +function bgRgb(r, g, b) { + return (text) => wrapAnsiBg(`\x1b[48;2;${r};${g};${b}m`, "\x1B[49m", text); +} +//#endregion +export { bgRgb }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgWhite.d.mts b/node_modules/es-toolkit/dist/server/colors/bgWhite.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6542892645a1380af8b4af9efb928f619dd7e36e --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgWhite.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgWhite.d.ts +/** + * White background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgWhite('hello')); + */ +declare function bgWhite(text: string): string; +//#endregion +export { bgWhite }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgWhite.d.ts b/node_modules/es-toolkit/dist/server/colors/bgWhite.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6542892645a1380af8b4af9efb928f619dd7e36e --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgWhite.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgWhite.d.ts +/** + * White background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgWhite('hello')); + */ +declare function bgWhite(text: string): string; +//#endregion +export { bgWhite }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgWhite.js b/node_modules/es-toolkit/dist/server/colors/bgWhite.js new file mode 100644 index 0000000000000000000000000000000000000000..1028bd622daa6daf7a1b78925f713084a5a6dced --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgWhite.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgWhite.ts +/** +* White background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgWhite('hello')); +*/ +function bgWhite(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[47m", "\x1B[49m", text); +} +//#endregion +exports.bgWhite = bgWhite; diff --git a/node_modules/es-toolkit/dist/server/colors/bgWhite.mjs b/node_modules/es-toolkit/dist/server/colors/bgWhite.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8371e6e91ed8aa14e3885b6cde560d28219ac16f --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgWhite.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgWhite.ts +/** +* White background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgWhite('hello')); +*/ +function bgWhite(text) { + return wrapAnsiBg("\x1B[47m", "\x1B[49m", text); +} +//#endregion +export { bgWhite }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.d.mts b/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..60f37b2ded2aa1d8f9404f1f05fe470d64738044 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgWhiteBright.d.ts +/** + * Bright white background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgWhiteBright('hello')); + */ +declare function bgWhiteBright(text: string): string; +//#endregion +export { bgWhiteBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.d.ts b/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..60f37b2ded2aa1d8f9404f1f05fe470d64738044 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgWhiteBright.d.ts +/** + * Bright white background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgWhiteBright('hello')); + */ +declare function bgWhiteBright(text: string): string; +//#endregion +export { bgWhiteBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.js b/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.js new file mode 100644 index 0000000000000000000000000000000000000000..652820263e2b70cb30bd656303eeb1a25d4814bd --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgWhiteBright.ts +/** +* Bright white background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgWhiteBright('hello')); +*/ +function bgWhiteBright(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[107m", "\x1B[49m", text); +} +//#endregion +exports.bgWhiteBright = bgWhiteBright; diff --git a/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.mjs b/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5cc2ab1ff92fe2dee6d4f0534613ccc002e6ccba --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgWhiteBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgWhiteBright.ts +/** +* Bright white background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgWhiteBright('hello')); +*/ +function bgWhiteBright(text) { + return wrapAnsiBg("\x1B[107m", "\x1B[49m", text); +} +//#endregion +export { bgWhiteBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgYellow.d.mts b/node_modules/es-toolkit/dist/server/colors/bgYellow.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1d91f3f608748fce025b71877d82681aecbcaeda --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgYellow.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgYellow.d.ts +/** + * Yellow background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgYellow('hello')); + */ +declare function bgYellow(text: string): string; +//#endregion +export { bgYellow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgYellow.d.ts b/node_modules/es-toolkit/dist/server/colors/bgYellow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d91f3f608748fce025b71877d82681aecbcaeda --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgYellow.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgYellow.d.ts +/** + * Yellow background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgYellow('hello')); + */ +declare function bgYellow(text: string): string; +//#endregion +export { bgYellow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgYellow.js b/node_modules/es-toolkit/dist/server/colors/bgYellow.js new file mode 100644 index 0000000000000000000000000000000000000000..6a84d8c6aaf11f4d316442e291ef44caf36a24e6 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgYellow.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgYellow.ts +/** +* Yellow background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgYellow('hello')); +*/ +function bgYellow(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[43m", "\x1B[49m", text); +} +//#endregion +exports.bgYellow = bgYellow; diff --git a/node_modules/es-toolkit/dist/server/colors/bgYellow.mjs b/node_modules/es-toolkit/dist/server/colors/bgYellow.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2ffb6c2665f1cfeab7855a8cac16e0725fefaea3 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgYellow.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgYellow.ts +/** +* Yellow background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgYellow('hello')); +*/ +function bgYellow(text) { + return wrapAnsiBg("\x1B[43m", "\x1B[49m", text); +} +//#endregion +export { bgYellow }; diff --git a/node_modules/es-toolkit/dist/server/colors/bgYellowBright.d.mts b/node_modules/es-toolkit/dist/server/colors/bgYellowBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d08f6792996d04ca9579521b7040602535d95619 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgYellowBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgYellowBright.d.ts +/** + * Bright yellow background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgYellowBright('hello')); + */ +declare function bgYellowBright(text: string): string; +//#endregion +export { bgYellowBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgYellowBright.d.ts b/node_modules/es-toolkit/dist/server/colors/bgYellowBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d08f6792996d04ca9579521b7040602535d95619 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgYellowBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bgYellowBright.d.ts +/** + * Bright yellow background. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bgYellowBright('hello')); + */ +declare function bgYellowBright(text: string): string; +//#endregion +export { bgYellowBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bgYellowBright.js b/node_modules/es-toolkit/dist/server/colors/bgYellowBright.js new file mode 100644 index 0000000000000000000000000000000000000000..334c2743d76b41001300eb7e4b0ac8f209b4c079 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgYellowBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsiBg = require("./_internal/wrapAnsiBg.js"); +//#region src/server/colors/bgYellowBright.ts +/** +* Bright yellow background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgYellowBright('hello')); +*/ +function bgYellowBright(text) { + return require_wrapAnsiBg.wrapAnsiBg("\x1B[103m", "\x1B[49m", text); +} +//#endregion +exports.bgYellowBright = bgYellowBright; diff --git a/node_modules/es-toolkit/dist/server/colors/bgYellowBright.mjs b/node_modules/es-toolkit/dist/server/colors/bgYellowBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..78c77aee750834716bd19483a28dc0ac52a09b03 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bgYellowBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsiBg } from "./_internal/wrapAnsiBg.mjs"; +//#region src/server/colors/bgYellowBright.ts +/** +* Bright yellow background. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bgYellowBright('hello')); +*/ +function bgYellowBright(text) { + return wrapAnsiBg("\x1B[103m", "\x1B[49m", text); +} +//#endregion +export { bgYellowBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/black.d.mts b/node_modules/es-toolkit/dist/server/colors/black.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1b03a3f69c5bdee30aab1013a743bb45126585ac --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/black.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/black.d.ts +/** + * Black foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.black('hello')); + */ +declare function black(text: string): string; +//#endregion +export { black }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/black.d.ts b/node_modules/es-toolkit/dist/server/colors/black.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b03a3f69c5bdee30aab1013a743bb45126585ac --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/black.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/black.d.ts +/** + * Black foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.black('hello')); + */ +declare function black(text: string): string; +//#endregion +export { black }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/black.js b/node_modules/es-toolkit/dist/server/colors/black.js new file mode 100644 index 0000000000000000000000000000000000000000..697a8447919f15a87e2372c1f4de86ea9d4b3345 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/black.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/black.ts +/** +* Black foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.black('hello')); +*/ +function black(text) { + return require_wrapAnsi.wrapAnsi("\x1B[30m", "\x1B[39m", text); +} +//#endregion +exports.black = black; diff --git a/node_modules/es-toolkit/dist/server/colors/black.mjs b/node_modules/es-toolkit/dist/server/colors/black.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7265507e523089b22de949ef15c338a25beb1c82 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/black.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/black.ts +/** +* Black foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.black('hello')); +*/ +function black(text) { + return wrapAnsi("\x1B[30m", "\x1B[39m", text); +} +//#endregion +export { black }; diff --git a/node_modules/es-toolkit/dist/server/colors/blackBright.d.mts b/node_modules/es-toolkit/dist/server/colors/blackBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..76560617d7002322bce86a894306ad3d02635bd7 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blackBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/blackBright.d.ts +/** + * Bright black (gray) foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.blackBright('hello')); + */ +declare function blackBright(text: string): string; +//#endregion +export { blackBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/blackBright.d.ts b/node_modules/es-toolkit/dist/server/colors/blackBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..76560617d7002322bce86a894306ad3d02635bd7 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blackBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/blackBright.d.ts +/** + * Bright black (gray) foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.blackBright('hello')); + */ +declare function blackBright(text: string): string; +//#endregion +export { blackBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/blackBright.js b/node_modules/es-toolkit/dist/server/colors/blackBright.js new file mode 100644 index 0000000000000000000000000000000000000000..2f1b244e02ababa5f2e6487c4d471f51796f2d63 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blackBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/blackBright.ts +/** +* Bright black (gray) foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.blackBright('hello')); +*/ +function blackBright(text) { + return require_wrapAnsi.wrapAnsi("\x1B[90m", "\x1B[39m", text); +} +//#endregion +exports.blackBright = blackBright; diff --git a/node_modules/es-toolkit/dist/server/colors/blackBright.mjs b/node_modules/es-toolkit/dist/server/colors/blackBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6f97b28e4e193f00415a95a4f1cdbba31aed9fba --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blackBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/blackBright.ts +/** +* Bright black (gray) foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.blackBright('hello')); +*/ +function blackBright(text) { + return wrapAnsi("\x1B[90m", "\x1B[39m", text); +} +//#endregion +export { blackBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/blue.d.mts b/node_modules/es-toolkit/dist/server/colors/blue.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c5b1588e12df32412275c61daccbb1d2920d97bc --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blue.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/blue.d.ts +/** + * Blue foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.blue('hello')); + */ +declare function blue(text: string): string; +//#endregion +export { blue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/blue.d.ts b/node_modules/es-toolkit/dist/server/colors/blue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5b1588e12df32412275c61daccbb1d2920d97bc --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blue.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/blue.d.ts +/** + * Blue foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.blue('hello')); + */ +declare function blue(text: string): string; +//#endregion +export { blue }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/blue.js b/node_modules/es-toolkit/dist/server/colors/blue.js new file mode 100644 index 0000000000000000000000000000000000000000..aea6d179f8e1a2aa86e2906fea2a74bd2321dc1b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blue.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/blue.ts +/** +* Blue foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.blue('hello')); +*/ +function blue(text) { + return require_wrapAnsi.wrapAnsi("\x1B[34m", "\x1B[39m", text); +} +//#endregion +exports.blue = blue; diff --git a/node_modules/es-toolkit/dist/server/colors/blue.mjs b/node_modules/es-toolkit/dist/server/colors/blue.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e480fdd32eedb875139104dfb1fcc422ae82064f --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blue.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/blue.ts +/** +* Blue foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.blue('hello')); +*/ +function blue(text) { + return wrapAnsi("\x1B[34m", "\x1B[39m", text); +} +//#endregion +export { blue }; diff --git a/node_modules/es-toolkit/dist/server/colors/blueBright.d.mts b/node_modules/es-toolkit/dist/server/colors/blueBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e3e9538aa29b5e9d69016945411d08e2097d7d90 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blueBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/blueBright.d.ts +/** + * Bright blue foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.blueBright('hello')); + */ +declare function blueBright(text: string): string; +//#endregion +export { blueBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/blueBright.d.ts b/node_modules/es-toolkit/dist/server/colors/blueBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3e9538aa29b5e9d69016945411d08e2097d7d90 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blueBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/blueBright.d.ts +/** + * Bright blue foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.blueBright('hello')); + */ +declare function blueBright(text: string): string; +//#endregion +export { blueBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/blueBright.js b/node_modules/es-toolkit/dist/server/colors/blueBright.js new file mode 100644 index 0000000000000000000000000000000000000000..f9d8ac3a2747c430053d6c42476c700290f7d119 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blueBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/blueBright.ts +/** +* Bright blue foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.blueBright('hello')); +*/ +function blueBright(text) { + return require_wrapAnsi.wrapAnsi("\x1B[94m", "\x1B[39m", text); +} +//#endregion +exports.blueBright = blueBright; diff --git a/node_modules/es-toolkit/dist/server/colors/blueBright.mjs b/node_modules/es-toolkit/dist/server/colors/blueBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7f69dd293bef5a559c45a0151f16ae10bf20b39f --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/blueBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/blueBright.ts +/** +* Bright blue foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.blueBright('hello')); +*/ +function blueBright(text) { + return wrapAnsi("\x1B[94m", "\x1B[39m", text); +} +//#endregion +export { blueBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/bold.d.mts b/node_modules/es-toolkit/dist/server/colors/bold.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..70652a7f93151c461c9bdc60e6ba859595550865 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bold.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/bold.d.ts +/** + * Bold text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bold('hello')); + */ +declare function bold(text: string): string; +//#endregion +export { bold }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bold.d.ts b/node_modules/es-toolkit/dist/server/colors/bold.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..70652a7f93151c461c9bdc60e6ba859595550865 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bold.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/bold.d.ts +/** + * Bold text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.bold('hello')); + */ +declare function bold(text: string): string; +//#endregion +export { bold }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/bold.js b/node_modules/es-toolkit/dist/server/colors/bold.js new file mode 100644 index 0000000000000000000000000000000000000000..f16e29b61058367306c0690f41576ea6d4f0ba82 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bold.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/bold.ts +/** +* Bold text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bold('hello')); +*/ +function bold(text) { + return require_wrapAnsi.wrapAnsi("\x1B[1m", "\x1B[22m", text); +} +//#endregion +exports.bold = bold; diff --git a/node_modules/es-toolkit/dist/server/colors/bold.mjs b/node_modules/es-toolkit/dist/server/colors/bold.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3c89815ccfa8ccbec2765c4f70a87ef47e54ff25 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/bold.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/bold.ts +/** +* Bold text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.bold('hello')); +*/ +function bold(text) { + return wrapAnsi("\x1B[1m", "\x1B[22m", text); +} +//#endregion +export { bold }; diff --git a/node_modules/es-toolkit/dist/server/colors/cyan.d.mts b/node_modules/es-toolkit/dist/server/colors/cyan.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c9b61ad637ddda4ba1346517317775b4a23cd28d --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/cyan.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/cyan.d.ts +/** + * Cyan foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.cyan('hello')); + */ +declare function cyan(text: string): string; +//#endregion +export { cyan }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/cyan.d.ts b/node_modules/es-toolkit/dist/server/colors/cyan.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c9b61ad637ddda4ba1346517317775b4a23cd28d --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/cyan.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/cyan.d.ts +/** + * Cyan foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.cyan('hello')); + */ +declare function cyan(text: string): string; +//#endregion +export { cyan }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/cyan.js b/node_modules/es-toolkit/dist/server/colors/cyan.js new file mode 100644 index 0000000000000000000000000000000000000000..1b67e4afe04cc9848ae711cce26eb6a5f247f6ec --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/cyan.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/cyan.ts +/** +* Cyan foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.cyan('hello')); +*/ +function cyan(text) { + return require_wrapAnsi.wrapAnsi("\x1B[36m", "\x1B[39m", text); +} +//#endregion +exports.cyan = cyan; diff --git a/node_modules/es-toolkit/dist/server/colors/cyan.mjs b/node_modules/es-toolkit/dist/server/colors/cyan.mjs new file mode 100644 index 0000000000000000000000000000000000000000..212cdd30d85c9b468e9913539009d73448e0a943 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/cyan.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/cyan.ts +/** +* Cyan foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.cyan('hello')); +*/ +function cyan(text) { + return wrapAnsi("\x1B[36m", "\x1B[39m", text); +} +//#endregion +export { cyan }; diff --git a/node_modules/es-toolkit/dist/server/colors/cyanBright.d.mts b/node_modules/es-toolkit/dist/server/colors/cyanBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fcba8369bd8a73bd27cbf9fefcb458bbefc5c1e3 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/cyanBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/cyanBright.d.ts +/** + * Bright cyan foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.cyanBright('hello')); + */ +declare function cyanBright(text: string): string; +//#endregion +export { cyanBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/cyanBright.d.ts b/node_modules/es-toolkit/dist/server/colors/cyanBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fcba8369bd8a73bd27cbf9fefcb458bbefc5c1e3 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/cyanBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/cyanBright.d.ts +/** + * Bright cyan foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.cyanBright('hello')); + */ +declare function cyanBright(text: string): string; +//#endregion +export { cyanBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/cyanBright.js b/node_modules/es-toolkit/dist/server/colors/cyanBright.js new file mode 100644 index 0000000000000000000000000000000000000000..4db3fa717c78688d3322df80a088be1810b0d6ea --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/cyanBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/cyanBright.ts +/** +* Bright cyan foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.cyanBright('hello')); +*/ +function cyanBright(text) { + return require_wrapAnsi.wrapAnsi("\x1B[96m", "\x1B[39m", text); +} +//#endregion +exports.cyanBright = cyanBright; diff --git a/node_modules/es-toolkit/dist/server/colors/cyanBright.mjs b/node_modules/es-toolkit/dist/server/colors/cyanBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..227c154726a8e0c782abf0fda498ead2a444e1d0 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/cyanBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/cyanBright.ts +/** +* Bright cyan foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.cyanBright('hello')); +*/ +function cyanBright(text) { + return wrapAnsi("\x1B[96m", "\x1B[39m", text); +} +//#endregion +export { cyanBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/dim.d.mts b/node_modules/es-toolkit/dist/server/colors/dim.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1f8d0687cb456865baf889a9e080018be32eba54 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/dim.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/dim.d.ts +/** + * Dim (faint) text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.dim('hello')); + */ +declare function dim(text: string): string; +//#endregion +export { dim }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/dim.d.ts b/node_modules/es-toolkit/dist/server/colors/dim.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f8d0687cb456865baf889a9e080018be32eba54 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/dim.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/dim.d.ts +/** + * Dim (faint) text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.dim('hello')); + */ +declare function dim(text: string): string; +//#endregion +export { dim }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/dim.js b/node_modules/es-toolkit/dist/server/colors/dim.js new file mode 100644 index 0000000000000000000000000000000000000000..f9ee7d6904b510bbf3824cd8ad0578fea473118a --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/dim.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/dim.ts +/** +* Dim (faint) text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.dim('hello')); +*/ +function dim(text) { + return require_wrapAnsi.wrapAnsi("\x1B[2m", "\x1B[22m", text); +} +//#endregion +exports.dim = dim; diff --git a/node_modules/es-toolkit/dist/server/colors/dim.mjs b/node_modules/es-toolkit/dist/server/colors/dim.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ee9a5abaefb019612d617ff6e8f2ddb33b991178 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/dim.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/dim.ts +/** +* Dim (faint) text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.dim('hello')); +*/ +function dim(text) { + return wrapAnsi("\x1B[2m", "\x1B[22m", text); +} +//#endregion +export { dim }; diff --git a/node_modules/es-toolkit/dist/server/colors/gray.js b/node_modules/es-toolkit/dist/server/colors/gray.js new file mode 100644 index 0000000000000000000000000000000000000000..c75aef87111a6e2ff3628268b65426e7cf2a29b3 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/gray.js @@ -0,0 +1,18 @@ +//#region src/server/colors/gray.ts +/** +* Gray foreground — alias of `blackBright`. Wraps text with ANSI codes. +* +* "Gray" and "bright black" map to the same SGR code (`\x1b[90m`); this export +* exists so callers can use the friendlier name. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.gray('muted')); +*/ +const gray = require("./blackBright.js").blackBright; +//#endregion +exports.gray = gray; diff --git a/node_modules/es-toolkit/dist/server/colors/gray.mjs b/node_modules/es-toolkit/dist/server/colors/gray.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fd1a9df0610e7543e7aefc4e4e3089ba480cfafa --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/gray.mjs @@ -0,0 +1,19 @@ +import { blackBright } from "./blackBright.mjs"; +//#region src/server/colors/gray.ts +/** +* Gray foreground — alias of `blackBright`. Wraps text with ANSI codes. +* +* "Gray" and "bright black" map to the same SGR code (`\x1b[90m`); this export +* exists so callers can use the friendlier name. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.gray('muted')); +*/ +const gray = blackBright; +//#endregion +export { gray }; diff --git a/node_modules/es-toolkit/dist/server/colors/green.d.mts b/node_modules/es-toolkit/dist/server/colors/green.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0745426a3a95517747b10975145dfda627f9a956 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/green.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/green.d.ts +/** + * Green foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.green('hello')); + */ +declare function green(text: string): string; +//#endregion +export { green }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/green.d.ts b/node_modules/es-toolkit/dist/server/colors/green.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0745426a3a95517747b10975145dfda627f9a956 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/green.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/green.d.ts +/** + * Green foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.green('hello')); + */ +declare function green(text: string): string; +//#endregion +export { green }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/green.js b/node_modules/es-toolkit/dist/server/colors/green.js new file mode 100644 index 0000000000000000000000000000000000000000..c942ba93e66bdddfe27d88d50b3a530b968e9999 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/green.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/green.ts +/** +* Green foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.green('hello')); +*/ +function green(text) { + return require_wrapAnsi.wrapAnsi("\x1B[32m", "\x1B[39m", text); +} +//#endregion +exports.green = green; diff --git a/node_modules/es-toolkit/dist/server/colors/green.mjs b/node_modules/es-toolkit/dist/server/colors/green.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4cecea700533ed44b9858f92c1baee57aa7ee3ea --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/green.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/green.ts +/** +* Green foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.green('hello')); +*/ +function green(text) { + return wrapAnsi("\x1B[32m", "\x1B[39m", text); +} +//#endregion +export { green }; diff --git a/node_modules/es-toolkit/dist/server/colors/greenBright.d.mts b/node_modules/es-toolkit/dist/server/colors/greenBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0400726c71a4bbf2480d72e29cfcc57456a8fe2b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/greenBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/greenBright.d.ts +/** + * Bright green foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.greenBright('hello')); + */ +declare function greenBright(text: string): string; +//#endregion +export { greenBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/greenBright.d.ts b/node_modules/es-toolkit/dist/server/colors/greenBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0400726c71a4bbf2480d72e29cfcc57456a8fe2b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/greenBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/greenBright.d.ts +/** + * Bright green foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.greenBright('hello')); + */ +declare function greenBright(text: string): string; +//#endregion +export { greenBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/greenBright.js b/node_modules/es-toolkit/dist/server/colors/greenBright.js new file mode 100644 index 0000000000000000000000000000000000000000..e6c0080ba30c63cb563727abfb26ec683e436935 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/greenBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/greenBright.ts +/** +* Bright green foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.greenBright('hello')); +*/ +function greenBright(text) { + return require_wrapAnsi.wrapAnsi("\x1B[92m", "\x1B[39m", text); +} +//#endregion +exports.greenBright = greenBright; diff --git a/node_modules/es-toolkit/dist/server/colors/greenBright.mjs b/node_modules/es-toolkit/dist/server/colors/greenBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7b2b76ab79a231a48f19b58a43f5f294559399a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/greenBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/greenBright.ts +/** +* Bright green foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.greenBright('hello')); +*/ +function greenBright(text) { + return wrapAnsi("\x1B[92m", "\x1B[39m", text); +} +//#endregion +export { greenBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/hex.d.mts b/node_modules/es-toolkit/dist/server/colors/hex.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..50268e4e0783cc0a42b17c25a5179acf2d81f7ba --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/hex.d.mts @@ -0,0 +1,18 @@ +import { ColorFunction } from "./types.mjs"; + +//#region src/server/colors/hex.d.ts +/** + * Returns a function that wraps text with a 24-bit foreground color parsed from a hex string. + * Accepts `#RGB`, `#RRGGBB`, or the same without `#`. + * + * @param color - A hex color string (e.g. `"#ff6347"`, `"#f00"`). + * @returns A color function that wraps text with the parsed RGB foreground. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.hex('#ff6347')('hello')); + */ +declare function hex(color: string): ColorFunction; +//#endregion +export { hex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/hex.d.ts b/node_modules/es-toolkit/dist/server/colors/hex.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b5eaa26db3f07cddaf1798deefe521ab88def58 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/hex.d.ts @@ -0,0 +1,18 @@ +import { ColorFunction } from "./types.js"; + +//#region src/server/colors/hex.d.ts +/** + * Returns a function that wraps text with a 24-bit foreground color parsed from a hex string. + * Accepts `#RGB`, `#RRGGBB`, or the same without `#`. + * + * @param color - A hex color string (e.g. `"#ff6347"`, `"#f00"`). + * @returns A color function that wraps text with the parsed RGB foreground. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.hex('#ff6347')('hello')); + */ +declare function hex(color: string): ColorFunction; +//#endregion +export { hex }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/hex.js b/node_modules/es-toolkit/dist/server/colors/hex.js new file mode 100644 index 0000000000000000000000000000000000000000..980e28fa460f9208d5802b2ab47f95807499444e --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/hex.js @@ -0,0 +1,21 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +const require_parseHex = require("./_internal/parseHex.js"); +//#region src/server/colors/hex.ts +/** +* Returns a function that wraps text with a 24-bit foreground color parsed from a hex string. +* Accepts `#RGB`, `#RRGGBB`, or the same without `#`. +* +* @param color - A hex color string (e.g. `"#ff6347"`, `"#f00"`). +* @returns A color function that wraps text with the parsed RGB foreground. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.hex('#ff6347')('hello')); +*/ +function hex(color) { + const [r, g, b] = require_parseHex.parseHex(color); + return (text) => require_wrapAnsi.wrapAnsi(`\x1b[38;2;${r};${g};${b}m`, "\x1B[39m", text); +} +//#endregion +exports.hex = hex; diff --git a/node_modules/es-toolkit/dist/server/colors/hex.mjs b/node_modules/es-toolkit/dist/server/colors/hex.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1d1103acc33ff8406e5297e09fd08ee44c8b162b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/hex.mjs @@ -0,0 +1,21 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +import { parseHex } from "./_internal/parseHex.mjs"; +//#region src/server/colors/hex.ts +/** +* Returns a function that wraps text with a 24-bit foreground color parsed from a hex string. +* Accepts `#RGB`, `#RRGGBB`, or the same without `#`. +* +* @param color - A hex color string (e.g. `"#ff6347"`, `"#f00"`). +* @returns A color function that wraps text with the parsed RGB foreground. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.hex('#ff6347')('hello')); +*/ +function hex(color) { + const [r, g, b] = parseHex(color); + return (text) => wrapAnsi(`\x1b[38;2;${r};${g};${b}m`, "\x1B[39m", text); +} +//#endregion +export { hex }; diff --git a/node_modules/es-toolkit/dist/server/colors/hidden.d.mts b/node_modules/es-toolkit/dist/server/colors/hidden.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..4ff3c3036001f4ed0f246c923eda96b993ac451b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/hidden.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/hidden.d.ts +/** + * Hides text from rendering while keeping it selectable. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.hidden('hello')); + */ +declare function hidden(text: string): string; +//#endregion +export { hidden }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/hidden.d.ts b/node_modules/es-toolkit/dist/server/colors/hidden.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4ff3c3036001f4ed0f246c923eda96b993ac451b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/hidden.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/hidden.d.ts +/** + * Hides text from rendering while keeping it selectable. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.hidden('hello')); + */ +declare function hidden(text: string): string; +//#endregion +export { hidden }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/hidden.js b/node_modules/es-toolkit/dist/server/colors/hidden.js new file mode 100644 index 0000000000000000000000000000000000000000..acaad67dae2d7275d9f9e7c031b78ced0d9f6ed5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/hidden.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/hidden.ts +/** +* Hides text from rendering while keeping it selectable. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.hidden('hello')); +*/ +function hidden(text) { + return require_wrapAnsi.wrapAnsi("\x1B[8m", "\x1B[28m", text); +} +//#endregion +exports.hidden = hidden; diff --git a/node_modules/es-toolkit/dist/server/colors/hidden.mjs b/node_modules/es-toolkit/dist/server/colors/hidden.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9103d4578979c37319550bf756c04da952448688 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/hidden.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/hidden.ts +/** +* Hides text from rendering while keeping it selectable. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.hidden('hello')); +*/ +function hidden(text) { + return wrapAnsi("\x1B[8m", "\x1B[28m", text); +} +//#endregion +export { hidden }; diff --git a/node_modules/es-toolkit/dist/server/colors/index.d.mts b/node_modules/es-toolkit/dist/server/colors/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..31368219ad3bf11a4115741af340c8422a39a4b1 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/index.d.mts @@ -0,0 +1,99 @@ +import { ansi256 } from "./ansi256.mjs"; +import { bgAnsi256 } from "./bgAnsi256.mjs"; +import { bgBlack } from "./bgBlack.mjs"; +import { bgBlackBright } from "./bgBlackBright.mjs"; +import { bgBlue } from "./bgBlue.mjs"; +import { bgBlueBright } from "./bgBlueBright.mjs"; +import { bgCyan } from "./bgCyan.mjs"; +import { bgCyanBright } from "./bgCyanBright.mjs"; +import { bgGreen } from "./bgGreen.mjs"; +import { bgGreenBright } from "./bgGreenBright.mjs"; +import { bgHex } from "./bgHex.mjs"; +import { bgMagenta } from "./bgMagenta.mjs"; +import { bgMagentaBright } from "./bgMagentaBright.mjs"; +import { bgRed } from "./bgRed.mjs"; +import { bgRedBright } from "./bgRedBright.mjs"; +import { bgRgb } from "./bgRgb.mjs"; +import { bgWhite } from "./bgWhite.mjs"; +import { bgWhiteBright } from "./bgWhiteBright.mjs"; +import { bgYellow } from "./bgYellow.mjs"; +import { bgYellowBright } from "./bgYellowBright.mjs"; +import { black } from "./black.mjs"; +import { blackBright } from "./blackBright.mjs"; +import { blue } from "./blue.mjs"; +import { blueBright } from "./blueBright.mjs"; +import { bold } from "./bold.mjs"; +import { cyan } from "./cyan.mjs"; +import { cyanBright } from "./cyanBright.mjs"; +import { dim } from "./dim.mjs"; +import { green } from "./green.mjs"; +import { greenBright } from "./greenBright.mjs"; +import { hex } from "./hex.mjs"; +import { hidden } from "./hidden.mjs"; +import { inverse } from "./inverse.mjs"; +import { italic } from "./italic.mjs"; +import { magenta } from "./magenta.mjs"; +import { magentaBright } from "./magentaBright.mjs"; +import { red } from "./red.mjs"; +import { redBright } from "./redBright.mjs"; +import { reset } from "./reset.mjs"; +import { rgb } from "./rgb.mjs"; +import { strikethrough } from "./strikethrough.mjs"; +import { underline } from "./underline.mjs"; +import { white } from "./white.mjs"; +import { whiteBright } from "./whiteBright.mjs"; +import { yellow } from "./yellow.mjs"; +import { yellowBright } from "./yellowBright.mjs"; + +//#region src/server/colors/index.d.ts +declare const colors: Readonly<{ + reset: typeof reset; + bold: typeof bold; + dim: typeof dim; + italic: typeof italic; + underline: typeof underline; + inverse: typeof inverse; + hidden: typeof hidden; + strikethrough: typeof strikethrough; + black: typeof black; + red: typeof red; + green: typeof green; + yellow: typeof yellow; + blue: typeof blue; + magenta: typeof magenta; + cyan: typeof cyan; + white: typeof white; + gray: typeof blackBright; + blackBright: typeof blackBright; + redBright: typeof redBright; + greenBright: typeof greenBright; + yellowBright: typeof yellowBright; + blueBright: typeof blueBright; + magentaBright: typeof magentaBright; + cyanBright: typeof cyanBright; + whiteBright: typeof whiteBright; + bgBlack: typeof bgBlack; + bgRed: typeof bgRed; + bgGreen: typeof bgGreen; + bgYellow: typeof bgYellow; + bgBlue: typeof bgBlue; + bgMagenta: typeof bgMagenta; + bgCyan: typeof bgCyan; + bgWhite: typeof bgWhite; + bgBlackBright: typeof bgBlackBright; + bgRedBright: typeof bgRedBright; + bgGreenBright: typeof bgGreenBright; + bgYellowBright: typeof bgYellowBright; + bgBlueBright: typeof bgBlueBright; + bgMagentaBright: typeof bgMagentaBright; + bgCyanBright: typeof bgCyanBright; + bgWhiteBright: typeof bgWhiteBright; + ansi256: typeof ansi256; + bgAnsi256: typeof bgAnsi256; + rgb: typeof rgb; + bgRgb: typeof bgRgb; + hex: typeof hex; + bgHex: typeof bgHex; +}>; +//#endregion +export { colors }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/index.d.ts b/node_modules/es-toolkit/dist/server/colors/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..049014fbbba91e921eccd2f7a50528e25197d566 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/index.d.ts @@ -0,0 +1,99 @@ +import { ansi256 } from "./ansi256.js"; +import { bgAnsi256 } from "./bgAnsi256.js"; +import { bgBlack } from "./bgBlack.js"; +import { bgBlackBright } from "./bgBlackBright.js"; +import { bgBlue } from "./bgBlue.js"; +import { bgBlueBright } from "./bgBlueBright.js"; +import { bgCyan } from "./bgCyan.js"; +import { bgCyanBright } from "./bgCyanBright.js"; +import { bgGreen } from "./bgGreen.js"; +import { bgGreenBright } from "./bgGreenBright.js"; +import { bgHex } from "./bgHex.js"; +import { bgMagenta } from "./bgMagenta.js"; +import { bgMagentaBright } from "./bgMagentaBright.js"; +import { bgRed } from "./bgRed.js"; +import { bgRedBright } from "./bgRedBright.js"; +import { bgRgb } from "./bgRgb.js"; +import { bgWhite } from "./bgWhite.js"; +import { bgWhiteBright } from "./bgWhiteBright.js"; +import { bgYellow } from "./bgYellow.js"; +import { bgYellowBright } from "./bgYellowBright.js"; +import { black } from "./black.js"; +import { blackBright } from "./blackBright.js"; +import { blue } from "./blue.js"; +import { blueBright } from "./blueBright.js"; +import { bold } from "./bold.js"; +import { cyan } from "./cyan.js"; +import { cyanBright } from "./cyanBright.js"; +import { dim } from "./dim.js"; +import { green } from "./green.js"; +import { greenBright } from "./greenBright.js"; +import { hex } from "./hex.js"; +import { hidden } from "./hidden.js"; +import { inverse } from "./inverse.js"; +import { italic } from "./italic.js"; +import { magenta } from "./magenta.js"; +import { magentaBright } from "./magentaBright.js"; +import { red } from "./red.js"; +import { redBright } from "./redBright.js"; +import { reset } from "./reset.js"; +import { rgb } from "./rgb.js"; +import { strikethrough } from "./strikethrough.js"; +import { underline } from "./underline.js"; +import { white } from "./white.js"; +import { whiteBright } from "./whiteBright.js"; +import { yellow } from "./yellow.js"; +import { yellowBright } from "./yellowBright.js"; + +//#region src/server/colors/index.d.ts +declare const colors: Readonly<{ + reset: typeof reset; + bold: typeof bold; + dim: typeof dim; + italic: typeof italic; + underline: typeof underline; + inverse: typeof inverse; + hidden: typeof hidden; + strikethrough: typeof strikethrough; + black: typeof black; + red: typeof red; + green: typeof green; + yellow: typeof yellow; + blue: typeof blue; + magenta: typeof magenta; + cyan: typeof cyan; + white: typeof white; + gray: typeof blackBright; + blackBright: typeof blackBright; + redBright: typeof redBright; + greenBright: typeof greenBright; + yellowBright: typeof yellowBright; + blueBright: typeof blueBright; + magentaBright: typeof magentaBright; + cyanBright: typeof cyanBright; + whiteBright: typeof whiteBright; + bgBlack: typeof bgBlack; + bgRed: typeof bgRed; + bgGreen: typeof bgGreen; + bgYellow: typeof bgYellow; + bgBlue: typeof bgBlue; + bgMagenta: typeof bgMagenta; + bgCyan: typeof bgCyan; + bgWhite: typeof bgWhite; + bgBlackBright: typeof bgBlackBright; + bgRedBright: typeof bgRedBright; + bgGreenBright: typeof bgGreenBright; + bgYellowBright: typeof bgYellowBright; + bgBlueBright: typeof bgBlueBright; + bgMagentaBright: typeof bgMagentaBright; + bgCyanBright: typeof bgCyanBright; + bgWhiteBright: typeof bgWhiteBright; + ansi256: typeof ansi256; + bgAnsi256: typeof bgAnsi256; + rgb: typeof rgb; + bgRgb: typeof bgRgb; + hex: typeof hex; + bgHex: typeof bgHex; +}>; +//#endregion +export { colors }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/index.js b/node_modules/es-toolkit/dist/server/colors/index.js new file mode 100644 index 0000000000000000000000000000000000000000..57e0d1957e6fcb06e76e4b2ea759a7796e8ca694 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/index.js @@ -0,0 +1,99 @@ +const require_ansi256 = require("./ansi256.js"); +const require_bgAnsi256 = require("./bgAnsi256.js"); +const require_bgBlack = require("./bgBlack.js"); +const require_bgBlackBright = require("./bgBlackBright.js"); +const require_bgBlue = require("./bgBlue.js"); +const require_bgBlueBright = require("./bgBlueBright.js"); +const require_bgCyan = require("./bgCyan.js"); +const require_bgCyanBright = require("./bgCyanBright.js"); +const require_bgGreen = require("./bgGreen.js"); +const require_bgGreenBright = require("./bgGreenBright.js"); +const require_bgHex = require("./bgHex.js"); +const require_bgMagenta = require("./bgMagenta.js"); +const require_bgMagentaBright = require("./bgMagentaBright.js"); +const require_bgRed = require("./bgRed.js"); +const require_bgRedBright = require("./bgRedBright.js"); +const require_bgRgb = require("./bgRgb.js"); +const require_bgWhite = require("./bgWhite.js"); +const require_bgWhiteBright = require("./bgWhiteBright.js"); +const require_bgYellow = require("./bgYellow.js"); +const require_bgYellowBright = require("./bgYellowBright.js"); +const require_black = require("./black.js"); +const require_blackBright = require("./blackBright.js"); +const require_blue = require("./blue.js"); +const require_blueBright = require("./blueBright.js"); +const require_bold = require("./bold.js"); +const require_cyan = require("./cyan.js"); +const require_cyanBright = require("./cyanBright.js"); +const require_dim = require("./dim.js"); +const require_gray = require("./gray.js"); +const require_green = require("./green.js"); +const require_greenBright = require("./greenBright.js"); +const require_hex = require("./hex.js"); +const require_hidden = require("./hidden.js"); +const require_inverse = require("./inverse.js"); +const require_italic = require("./italic.js"); +const require_magenta = require("./magenta.js"); +const require_magentaBright = require("./magentaBright.js"); +const require_red = require("./red.js"); +const require_redBright = require("./redBright.js"); +const require_reset = require("./reset.js"); +const require_rgb = require("./rgb.js"); +const require_strikethrough = require("./strikethrough.js"); +const require_underline = require("./underline.js"); +const require_white = require("./white.js"); +const require_whiteBright = require("./whiteBright.js"); +const require_yellow = require("./yellow.js"); +const require_yellowBright = require("./yellowBright.js"); +//#region src/server/colors/index.ts +const colors = /* @__PURE__ */ Object.freeze({ + reset: require_reset.reset, + bold: require_bold.bold, + dim: require_dim.dim, + italic: require_italic.italic, + underline: require_underline.underline, + inverse: require_inverse.inverse, + hidden: require_hidden.hidden, + strikethrough: require_strikethrough.strikethrough, + black: require_black.black, + red: require_red.red, + green: require_green.green, + yellow: require_yellow.yellow, + blue: require_blue.blue, + magenta: require_magenta.magenta, + cyan: require_cyan.cyan, + white: require_white.white, + gray: require_gray.gray, + blackBright: require_blackBright.blackBright, + redBright: require_redBright.redBright, + greenBright: require_greenBright.greenBright, + yellowBright: require_yellowBright.yellowBright, + blueBright: require_blueBright.blueBright, + magentaBright: require_magentaBright.magentaBright, + cyanBright: require_cyanBright.cyanBright, + whiteBright: require_whiteBright.whiteBright, + bgBlack: require_bgBlack.bgBlack, + bgRed: require_bgRed.bgRed, + bgGreen: require_bgGreen.bgGreen, + bgYellow: require_bgYellow.bgYellow, + bgBlue: require_bgBlue.bgBlue, + bgMagenta: require_bgMagenta.bgMagenta, + bgCyan: require_bgCyan.bgCyan, + bgWhite: require_bgWhite.bgWhite, + bgBlackBright: require_bgBlackBright.bgBlackBright, + bgRedBright: require_bgRedBright.bgRedBright, + bgGreenBright: require_bgGreenBright.bgGreenBright, + bgYellowBright: require_bgYellowBright.bgYellowBright, + bgBlueBright: require_bgBlueBright.bgBlueBright, + bgMagentaBright: require_bgMagentaBright.bgMagentaBright, + bgCyanBright: require_bgCyanBright.bgCyanBright, + bgWhiteBright: require_bgWhiteBright.bgWhiteBright, + ansi256: require_ansi256.ansi256, + bgAnsi256: require_bgAnsi256.bgAnsi256, + rgb: require_rgb.rgb, + bgRgb: require_bgRgb.bgRgb, + hex: require_hex.hex, + bgHex: require_bgHex.bgHex +}); +//#endregion +exports.colors = colors; diff --git a/node_modules/es-toolkit/dist/server/colors/index.mjs b/node_modules/es-toolkit/dist/server/colors/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0de3b6335185d941da557b59ca36042dd1e9d030 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/index.mjs @@ -0,0 +1,99 @@ +import { ansi256 } from "./ansi256.mjs"; +import { bgAnsi256 } from "./bgAnsi256.mjs"; +import { bgBlack } from "./bgBlack.mjs"; +import { bgBlackBright } from "./bgBlackBright.mjs"; +import { bgBlue } from "./bgBlue.mjs"; +import { bgBlueBright } from "./bgBlueBright.mjs"; +import { bgCyan } from "./bgCyan.mjs"; +import { bgCyanBright } from "./bgCyanBright.mjs"; +import { bgGreen } from "./bgGreen.mjs"; +import { bgGreenBright } from "./bgGreenBright.mjs"; +import { bgHex } from "./bgHex.mjs"; +import { bgMagenta } from "./bgMagenta.mjs"; +import { bgMagentaBright } from "./bgMagentaBright.mjs"; +import { bgRed } from "./bgRed.mjs"; +import { bgRedBright } from "./bgRedBright.mjs"; +import { bgRgb } from "./bgRgb.mjs"; +import { bgWhite } from "./bgWhite.mjs"; +import { bgWhiteBright } from "./bgWhiteBright.mjs"; +import { bgYellow } from "./bgYellow.mjs"; +import { bgYellowBright } from "./bgYellowBright.mjs"; +import { black } from "./black.mjs"; +import { blackBright } from "./blackBright.mjs"; +import { blue } from "./blue.mjs"; +import { blueBright } from "./blueBright.mjs"; +import { bold } from "./bold.mjs"; +import { cyan } from "./cyan.mjs"; +import { cyanBright } from "./cyanBright.mjs"; +import { dim } from "./dim.mjs"; +import { gray } from "./gray.mjs"; +import { green } from "./green.mjs"; +import { greenBright } from "./greenBright.mjs"; +import { hex } from "./hex.mjs"; +import { hidden } from "./hidden.mjs"; +import { inverse } from "./inverse.mjs"; +import { italic } from "./italic.mjs"; +import { magenta } from "./magenta.mjs"; +import { magentaBright } from "./magentaBright.mjs"; +import { red } from "./red.mjs"; +import { redBright } from "./redBright.mjs"; +import { reset } from "./reset.mjs"; +import { rgb } from "./rgb.mjs"; +import { strikethrough } from "./strikethrough.mjs"; +import { underline } from "./underline.mjs"; +import { white } from "./white.mjs"; +import { whiteBright } from "./whiteBright.mjs"; +import { yellow } from "./yellow.mjs"; +import { yellowBright } from "./yellowBright.mjs"; +//#region src/server/colors/index.ts +const colors = /* @__PURE__ */ Object.freeze({ + reset, + bold, + dim, + italic, + underline, + inverse, + hidden, + strikethrough, + black, + red, + green, + yellow, + blue, + magenta, + cyan, + white, + gray, + blackBright, + redBright, + greenBright, + yellowBright, + blueBright, + magentaBright, + cyanBright, + whiteBright, + bgBlack, + bgRed, + bgGreen, + bgYellow, + bgBlue, + bgMagenta, + bgCyan, + bgWhite, + bgBlackBright, + bgRedBright, + bgGreenBright, + bgYellowBright, + bgBlueBright, + bgMagentaBright, + bgCyanBright, + bgWhiteBright, + ansi256, + bgAnsi256, + rgb, + bgRgb, + hex, + bgHex +}); +//#endregion +export { colors }; diff --git a/node_modules/es-toolkit/dist/server/colors/inverse.d.mts b/node_modules/es-toolkit/dist/server/colors/inverse.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1c3cfe623195b8147755abbd114792349dfa5e01 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/inverse.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/inverse.d.ts +/** + * Swaps the foreground and background colors. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.inverse('hello')); + */ +declare function inverse(text: string): string; +//#endregion +export { inverse }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/inverse.d.ts b/node_modules/es-toolkit/dist/server/colors/inverse.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c3cfe623195b8147755abbd114792349dfa5e01 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/inverse.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/inverse.d.ts +/** + * Swaps the foreground and background colors. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.inverse('hello')); + */ +declare function inverse(text: string): string; +//#endregion +export { inverse }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/inverse.js b/node_modules/es-toolkit/dist/server/colors/inverse.js new file mode 100644 index 0000000000000000000000000000000000000000..377a745b3ae22d8f58689a840f0925d8accd32a4 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/inverse.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/inverse.ts +/** +* Swaps the foreground and background colors. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.inverse('hello')); +*/ +function inverse(text) { + return require_wrapAnsi.wrapAnsi("\x1B[7m", "\x1B[27m", text); +} +//#endregion +exports.inverse = inverse; diff --git a/node_modules/es-toolkit/dist/server/colors/inverse.mjs b/node_modules/es-toolkit/dist/server/colors/inverse.mjs new file mode 100644 index 0000000000000000000000000000000000000000..63fdb999e644b7be83c287146412191207fdcf78 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/inverse.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/inverse.ts +/** +* Swaps the foreground and background colors. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.inverse('hello')); +*/ +function inverse(text) { + return wrapAnsi("\x1B[7m", "\x1B[27m", text); +} +//#endregion +export { inverse }; diff --git a/node_modules/es-toolkit/dist/server/colors/italic.d.mts b/node_modules/es-toolkit/dist/server/colors/italic.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..84c5a173b8f062af2456632a66907696ee856c27 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/italic.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/italic.d.ts +/** + * Italic text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.italic('hello')); + */ +declare function italic(text: string): string; +//#endregion +export { italic }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/italic.d.ts b/node_modules/es-toolkit/dist/server/colors/italic.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..84c5a173b8f062af2456632a66907696ee856c27 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/italic.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/italic.d.ts +/** + * Italic text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.italic('hello')); + */ +declare function italic(text: string): string; +//#endregion +export { italic }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/italic.js b/node_modules/es-toolkit/dist/server/colors/italic.js new file mode 100644 index 0000000000000000000000000000000000000000..39638cd68e10997451418943930b4d1ac3e1c1f2 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/italic.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/italic.ts +/** +* Italic text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.italic('hello')); +*/ +function italic(text) { + return require_wrapAnsi.wrapAnsi("\x1B[3m", "\x1B[23m", text); +} +//#endregion +exports.italic = italic; diff --git a/node_modules/es-toolkit/dist/server/colors/italic.mjs b/node_modules/es-toolkit/dist/server/colors/italic.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b886d94937e89ba692b429c6af5d90137210c7e7 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/italic.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/italic.ts +/** +* Italic text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.italic('hello')); +*/ +function italic(text) { + return wrapAnsi("\x1B[3m", "\x1B[23m", text); +} +//#endregion +export { italic }; diff --git a/node_modules/es-toolkit/dist/server/colors/magenta.d.mts b/node_modules/es-toolkit/dist/server/colors/magenta.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2570e93fb3aa830cef656f505d8d4520d0d9b31c --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/magenta.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/magenta.d.ts +/** + * Magenta foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.magenta('hello')); + */ +declare function magenta(text: string): string; +//#endregion +export { magenta }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/magenta.d.ts b/node_modules/es-toolkit/dist/server/colors/magenta.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2570e93fb3aa830cef656f505d8d4520d0d9b31c --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/magenta.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/magenta.d.ts +/** + * Magenta foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.magenta('hello')); + */ +declare function magenta(text: string): string; +//#endregion +export { magenta }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/magenta.js b/node_modules/es-toolkit/dist/server/colors/magenta.js new file mode 100644 index 0000000000000000000000000000000000000000..fbf19f85a93803e155222be989a2707e68dae4cf --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/magenta.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/magenta.ts +/** +* Magenta foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.magenta('hello')); +*/ +function magenta(text) { + return require_wrapAnsi.wrapAnsi("\x1B[35m", "\x1B[39m", text); +} +//#endregion +exports.magenta = magenta; diff --git a/node_modules/es-toolkit/dist/server/colors/magenta.mjs b/node_modules/es-toolkit/dist/server/colors/magenta.mjs new file mode 100644 index 0000000000000000000000000000000000000000..461e8c73510accd6f9df681ee60f8a2f1fb40472 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/magenta.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/magenta.ts +/** +* Magenta foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.magenta('hello')); +*/ +function magenta(text) { + return wrapAnsi("\x1B[35m", "\x1B[39m", text); +} +//#endregion +export { magenta }; diff --git a/node_modules/es-toolkit/dist/server/colors/magentaBright.d.mts b/node_modules/es-toolkit/dist/server/colors/magentaBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8e698371abe8e4c1b43d2d607522ec6efa808f83 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/magentaBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/magentaBright.d.ts +/** + * Bright magenta foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.magentaBright('hello')); + */ +declare function magentaBright(text: string): string; +//#endregion +export { magentaBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/magentaBright.d.ts b/node_modules/es-toolkit/dist/server/colors/magentaBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e698371abe8e4c1b43d2d607522ec6efa808f83 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/magentaBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/magentaBright.d.ts +/** + * Bright magenta foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.magentaBright('hello')); + */ +declare function magentaBright(text: string): string; +//#endregion +export { magentaBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/magentaBright.js b/node_modules/es-toolkit/dist/server/colors/magentaBright.js new file mode 100644 index 0000000000000000000000000000000000000000..bde01bcf45f93360c36afc51f8690e096e2d7e8e --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/magentaBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/magentaBright.ts +/** +* Bright magenta foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.magentaBright('hello')); +*/ +function magentaBright(text) { + return require_wrapAnsi.wrapAnsi("\x1B[95m", "\x1B[39m", text); +} +//#endregion +exports.magentaBright = magentaBright; diff --git a/node_modules/es-toolkit/dist/server/colors/magentaBright.mjs b/node_modules/es-toolkit/dist/server/colors/magentaBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..db14d235b92e290907db716c15e9eed472027f4f --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/magentaBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/magentaBright.ts +/** +* Bright magenta foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.magentaBright('hello')); +*/ +function magentaBright(text) { + return wrapAnsi("\x1B[95m", "\x1B[39m", text); +} +//#endregion +export { magentaBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/red.d.mts b/node_modules/es-toolkit/dist/server/colors/red.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1e2395b1e94c63022483e20334a2bf61b1bb26ab --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/red.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/red.d.ts +/** + * Red foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.red('error')); + */ +declare function red(text: string): string; +//#endregion +export { red }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/red.d.ts b/node_modules/es-toolkit/dist/server/colors/red.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e2395b1e94c63022483e20334a2bf61b1bb26ab --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/red.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/red.d.ts +/** + * Red foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.red('error')); + */ +declare function red(text: string): string; +//#endregion +export { red }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/red.js b/node_modules/es-toolkit/dist/server/colors/red.js new file mode 100644 index 0000000000000000000000000000000000000000..abca1e4b90c6fb7f1483aba92a5772dbd0e9e793 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/red.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/red.ts +/** +* Red foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.red('error')); +*/ +function red(text) { + return require_wrapAnsi.wrapAnsi("\x1B[31m", "\x1B[39m", text); +} +//#endregion +exports.red = red; diff --git a/node_modules/es-toolkit/dist/server/colors/red.mjs b/node_modules/es-toolkit/dist/server/colors/red.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ca88d09e848c50d5e2a313a4da6e3f5202f11faa --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/red.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/red.ts +/** +* Red foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.red('error')); +*/ +function red(text) { + return wrapAnsi("\x1B[31m", "\x1B[39m", text); +} +//#endregion +export { red }; diff --git a/node_modules/es-toolkit/dist/server/colors/redBright.d.mts b/node_modules/es-toolkit/dist/server/colors/redBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..73fdb5a8f5d1effe4636e35bed91c16c39187049 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/redBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/redBright.d.ts +/** + * Bright red foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.redBright('hello')); + */ +declare function redBright(text: string): string; +//#endregion +export { redBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/redBright.d.ts b/node_modules/es-toolkit/dist/server/colors/redBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..73fdb5a8f5d1effe4636e35bed91c16c39187049 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/redBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/redBright.d.ts +/** + * Bright red foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.redBright('hello')); + */ +declare function redBright(text: string): string; +//#endregion +export { redBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/redBright.js b/node_modules/es-toolkit/dist/server/colors/redBright.js new file mode 100644 index 0000000000000000000000000000000000000000..282fe5fe39e544fcd69170641ef13d63c1ef4663 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/redBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/redBright.ts +/** +* Bright red foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.redBright('hello')); +*/ +function redBright(text) { + return require_wrapAnsi.wrapAnsi("\x1B[91m", "\x1B[39m", text); +} +//#endregion +exports.redBright = redBright; diff --git a/node_modules/es-toolkit/dist/server/colors/redBright.mjs b/node_modules/es-toolkit/dist/server/colors/redBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3bb0957a0079d130e60402526bf1e71ca2104c16 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/redBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/redBright.ts +/** +* Bright red foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.redBright('hello')); +*/ +function redBright(text) { + return wrapAnsi("\x1B[91m", "\x1B[39m", text); +} +//#endregion +export { redBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/reset.d.mts b/node_modules/es-toolkit/dist/server/colors/reset.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..a66cfcb9065eb74f78e0be24c010e5350cfe4ef5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/reset.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/reset.d.ts +/** + * Resets every style and color set up to this point. Wraps text with the ANSI reset code. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.reset('hello')); + */ +declare function reset(text: string): string; +//#endregion +export { reset }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/reset.d.ts b/node_modules/es-toolkit/dist/server/colors/reset.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a66cfcb9065eb74f78e0be24c010e5350cfe4ef5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/reset.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/reset.d.ts +/** + * Resets every style and color set up to this point. Wraps text with the ANSI reset code. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.reset('hello')); + */ +declare function reset(text: string): string; +//#endregion +export { reset }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/reset.js b/node_modules/es-toolkit/dist/server/colors/reset.js new file mode 100644 index 0000000000000000000000000000000000000000..78ed60622f409717ab3598e8955bb080f18bed11 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/reset.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/reset.ts +/** +* Resets every style and color set up to this point. Wraps text with the ANSI reset code. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.reset('hello')); +*/ +function reset(text) { + return require_wrapAnsi.wrapAnsi("\x1B[0m", "\x1B[0m", text); +} +//#endregion +exports.reset = reset; diff --git a/node_modules/es-toolkit/dist/server/colors/reset.mjs b/node_modules/es-toolkit/dist/server/colors/reset.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4b7a536b7c87c580e4230e6fc3fede3e32a9a777 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/reset.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/reset.ts +/** +* Resets every style and color set up to this point. Wraps text with the ANSI reset code. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.reset('hello')); +*/ +function reset(text) { + return wrapAnsi("\x1B[0m", "\x1B[0m", text); +} +//#endregion +export { reset }; diff --git a/node_modules/es-toolkit/dist/server/colors/rgb.d.mts b/node_modules/es-toolkit/dist/server/colors/rgb.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6b238feaf5fe98a6ea0724c60c852a9edc156971 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/rgb.d.mts @@ -0,0 +1,20 @@ +import { ColorFunction } from "./types.mjs"; + +//#region src/server/colors/rgb.d.ts +/** + * Returns a function that wraps text with the given 24-bit (truecolor) foreground. + * + * @param r - Red component (0–255). + * @param g - Green component (0–255). + * @param b - Blue component (0–255). + * @returns A color function that wraps text with the chosen RGB foreground. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * const brand = colors.rgb(255, 99, 71); + * console.log(brand('hello')); + */ +declare function rgb(r: number, g: number, b: number): ColorFunction; +//#endregion +export { rgb }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/rgb.d.ts b/node_modules/es-toolkit/dist/server/colors/rgb.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6950003923648257097efe6030d979ce53a0918d --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/rgb.d.ts @@ -0,0 +1,20 @@ +import { ColorFunction } from "./types.js"; + +//#region src/server/colors/rgb.d.ts +/** + * Returns a function that wraps text with the given 24-bit (truecolor) foreground. + * + * @param r - Red component (0–255). + * @param g - Green component (0–255). + * @param b - Blue component (0–255). + * @returns A color function that wraps text with the chosen RGB foreground. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * const brand = colors.rgb(255, 99, 71); + * console.log(brand('hello')); + */ +declare function rgb(r: number, g: number, b: number): ColorFunction; +//#endregion +export { rgb }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/rgb.js b/node_modules/es-toolkit/dist/server/colors/rgb.js new file mode 100644 index 0000000000000000000000000000000000000000..cfbf7f8f49686efcb5305fbd0bdefe503f2f8b06 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/rgb.js @@ -0,0 +1,21 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/rgb.ts +/** +* Returns a function that wraps text with the given 24-bit (truecolor) foreground. +* +* @param r - Red component (0–255). +* @param g - Green component (0–255). +* @param b - Blue component (0–255). +* @returns A color function that wraps text with the chosen RGB foreground. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* const brand = colors.rgb(255, 99, 71); +* console.log(brand('hello')); +*/ +function rgb(r, g, b) { + return (text) => require_wrapAnsi.wrapAnsi(`\x1b[38;2;${r};${g};${b}m`, "\x1B[39m", text); +} +//#endregion +exports.rgb = rgb; diff --git a/node_modules/es-toolkit/dist/server/colors/rgb.mjs b/node_modules/es-toolkit/dist/server/colors/rgb.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e601e58c7430788631acd9ed41e70fd9e77ac3d1 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/rgb.mjs @@ -0,0 +1,21 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/rgb.ts +/** +* Returns a function that wraps text with the given 24-bit (truecolor) foreground. +* +* @param r - Red component (0–255). +* @param g - Green component (0–255). +* @param b - Blue component (0–255). +* @returns A color function that wraps text with the chosen RGB foreground. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* const brand = colors.rgb(255, 99, 71); +* console.log(brand('hello')); +*/ +function rgb(r, g, b) { + return (text) => wrapAnsi(`\x1b[38;2;${r};${g};${b}m`, "\x1B[39m", text); +} +//#endregion +export { rgb }; diff --git a/node_modules/es-toolkit/dist/server/colors/strikethrough.d.mts b/node_modules/es-toolkit/dist/server/colors/strikethrough.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c26b890934e6d6c49c5fccd28ce55b69e9de827f --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/strikethrough.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/strikethrough.d.ts +/** + * Strikethrough text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.strikethrough('hello')); + */ +declare function strikethrough(text: string): string; +//#endregion +export { strikethrough }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/strikethrough.d.ts b/node_modules/es-toolkit/dist/server/colors/strikethrough.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c26b890934e6d6c49c5fccd28ce55b69e9de827f --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/strikethrough.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/strikethrough.d.ts +/** + * Strikethrough text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.strikethrough('hello')); + */ +declare function strikethrough(text: string): string; +//#endregion +export { strikethrough }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/strikethrough.js b/node_modules/es-toolkit/dist/server/colors/strikethrough.js new file mode 100644 index 0000000000000000000000000000000000000000..e195bf111bf8a31d5a22347bc70d8614c90d25b2 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/strikethrough.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/strikethrough.ts +/** +* Strikethrough text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.strikethrough('hello')); +*/ +function strikethrough(text) { + return require_wrapAnsi.wrapAnsi("\x1B[9m", "\x1B[29m", text); +} +//#endregion +exports.strikethrough = strikethrough; diff --git a/node_modules/es-toolkit/dist/server/colors/strikethrough.mjs b/node_modules/es-toolkit/dist/server/colors/strikethrough.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ccdabc01242df2189bf12b57223258a2c08c0f09 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/strikethrough.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/strikethrough.ts +/** +* Strikethrough text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.strikethrough('hello')); +*/ +function strikethrough(text) { + return wrapAnsi("\x1B[9m", "\x1B[29m", text); +} +//#endregion +export { strikethrough }; diff --git a/node_modules/es-toolkit/dist/server/colors/types.d.mts b/node_modules/es-toolkit/dist/server/colors/types.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..960e540a027d24f377b54dfa3db960023e545c62 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/types.d.mts @@ -0,0 +1,4 @@ +//#region src/server/colors/types.d.ts +type ColorFunction = (text: string) => string; +//#endregion +export { ColorFunction }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/types.d.ts b/node_modules/es-toolkit/dist/server/colors/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..960e540a027d24f377b54dfa3db960023e545c62 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/types.d.ts @@ -0,0 +1,4 @@ +//#region src/server/colors/types.d.ts +type ColorFunction = (text: string) => string; +//#endregion +export { ColorFunction }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/underline.d.mts b/node_modules/es-toolkit/dist/server/colors/underline.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..87b33fb1700e6ff4f2fa1651ddc239fc8f68ed52 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/underline.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/underline.d.ts +/** + * Underlined text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.underline('hello')); + */ +declare function underline(text: string): string; +//#endregion +export { underline }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/underline.d.ts b/node_modules/es-toolkit/dist/server/colors/underline.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..87b33fb1700e6ff4f2fa1651ddc239fc8f68ed52 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/underline.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/underline.d.ts +/** + * Underlined text. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.underline('hello')); + */ +declare function underline(text: string): string; +//#endregion +export { underline }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/underline.js b/node_modules/es-toolkit/dist/server/colors/underline.js new file mode 100644 index 0000000000000000000000000000000000000000..2e817929848b99bbfe8d54e6a718d273b2d9192a --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/underline.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/underline.ts +/** +* Underlined text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.underline('hello')); +*/ +function underline(text) { + return require_wrapAnsi.wrapAnsi("\x1B[4m", "\x1B[24m", text); +} +//#endregion +exports.underline = underline; diff --git a/node_modules/es-toolkit/dist/server/colors/underline.mjs b/node_modules/es-toolkit/dist/server/colors/underline.mjs new file mode 100644 index 0000000000000000000000000000000000000000..eb93c69da80e4c42e25e69fd3797a72987496a3c --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/underline.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/underline.ts +/** +* Underlined text. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.underline('hello')); +*/ +function underline(text) { + return wrapAnsi("\x1B[4m", "\x1B[24m", text); +} +//#endregion +export { underline }; diff --git a/node_modules/es-toolkit/dist/server/colors/white.d.mts b/node_modules/es-toolkit/dist/server/colors/white.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ad1b521e61fc72a9723707b918c0922271f69dcc --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/white.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/white.d.ts +/** + * White foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.white('hello')); + */ +declare function white(text: string): string; +//#endregion +export { white }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/white.d.ts b/node_modules/es-toolkit/dist/server/colors/white.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad1b521e61fc72a9723707b918c0922271f69dcc --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/white.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/white.d.ts +/** + * White foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.white('hello')); + */ +declare function white(text: string): string; +//#endregion +export { white }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/white.js b/node_modules/es-toolkit/dist/server/colors/white.js new file mode 100644 index 0000000000000000000000000000000000000000..1f7f2467c2eed5c97499e58fb9343194062666aa --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/white.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/white.ts +/** +* White foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.white('hello')); +*/ +function white(text) { + return require_wrapAnsi.wrapAnsi("\x1B[37m", "\x1B[39m", text); +} +//#endregion +exports.white = white; diff --git a/node_modules/es-toolkit/dist/server/colors/white.mjs b/node_modules/es-toolkit/dist/server/colors/white.mjs new file mode 100644 index 0000000000000000000000000000000000000000..1708b952d7d75d5d9b5af40a0622d24e888364ad --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/white.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/white.ts +/** +* White foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.white('hello')); +*/ +function white(text) { + return wrapAnsi("\x1B[37m", "\x1B[39m", text); +} +//#endregion +export { white }; diff --git a/node_modules/es-toolkit/dist/server/colors/whiteBright.d.mts b/node_modules/es-toolkit/dist/server/colors/whiteBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d8b0ea01dc4ae57e4ebb313edcf3acac70724364 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/whiteBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/whiteBright.d.ts +/** + * Bright white foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.whiteBright('hello')); + */ +declare function whiteBright(text: string): string; +//#endregion +export { whiteBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/whiteBright.d.ts b/node_modules/es-toolkit/dist/server/colors/whiteBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8b0ea01dc4ae57e4ebb313edcf3acac70724364 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/whiteBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/whiteBright.d.ts +/** + * Bright white foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.whiteBright('hello')); + */ +declare function whiteBright(text: string): string; +//#endregion +export { whiteBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/whiteBright.js b/node_modules/es-toolkit/dist/server/colors/whiteBright.js new file mode 100644 index 0000000000000000000000000000000000000000..f95e5b261f2178d10fa1d73b798f083c025050c7 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/whiteBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/whiteBright.ts +/** +* Bright white foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.whiteBright('hello')); +*/ +function whiteBright(text) { + return require_wrapAnsi.wrapAnsi("\x1B[97m", "\x1B[39m", text); +} +//#endregion +exports.whiteBright = whiteBright; diff --git a/node_modules/es-toolkit/dist/server/colors/whiteBright.mjs b/node_modules/es-toolkit/dist/server/colors/whiteBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cd5dfecd3fb2a9fa200baba0d53aca63b39127e2 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/whiteBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/whiteBright.ts +/** +* Bright white foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.whiteBright('hello')); +*/ +function whiteBright(text) { + return wrapAnsi("\x1B[97m", "\x1B[39m", text); +} +//#endregion +export { whiteBright }; diff --git a/node_modules/es-toolkit/dist/server/colors/yellow.d.mts b/node_modules/es-toolkit/dist/server/colors/yellow.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..345d1d444845e71f9ba9e6f18606659690d646f4 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/yellow.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/yellow.d.ts +/** + * Yellow foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.yellow('hello')); + */ +declare function yellow(text: string): string; +//#endregion +export { yellow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/yellow.d.ts b/node_modules/es-toolkit/dist/server/colors/yellow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..345d1d444845e71f9ba9e6f18606659690d646f4 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/yellow.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/yellow.d.ts +/** + * Yellow foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.yellow('hello')); + */ +declare function yellow(text: string): string; +//#endregion +export { yellow }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/yellow.js b/node_modules/es-toolkit/dist/server/colors/yellow.js new file mode 100644 index 0000000000000000000000000000000000000000..5188bb20608ea1679bb1cde438dcaa533d2ed6bc --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/yellow.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/yellow.ts +/** +* Yellow foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.yellow('hello')); +*/ +function yellow(text) { + return require_wrapAnsi.wrapAnsi("\x1B[33m", "\x1B[39m", text); +} +//#endregion +exports.yellow = yellow; diff --git a/node_modules/es-toolkit/dist/server/colors/yellow.mjs b/node_modules/es-toolkit/dist/server/colors/yellow.mjs new file mode 100644 index 0000000000000000000000000000000000000000..ec3b92c86eb1476217c27bb24f2624723ff9bc61 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/yellow.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/yellow.ts +/** +* Yellow foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.yellow('hello')); +*/ +function yellow(text) { + return wrapAnsi("\x1B[33m", "\x1B[39m", text); +} +//#endregion +export { yellow }; diff --git a/node_modules/es-toolkit/dist/server/colors/yellowBright.d.mts b/node_modules/es-toolkit/dist/server/colors/yellowBright.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8b7a4a9b28c10665e36362ef9408dbc17c33d497 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/yellowBright.d.mts @@ -0,0 +1,15 @@ +//#region src/server/colors/yellowBright.d.ts +/** + * Bright yellow foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.yellowBright('hello')); + */ +declare function yellowBright(text: string): string; +//#endregion +export { yellowBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/yellowBright.d.ts b/node_modules/es-toolkit/dist/server/colors/yellowBright.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b7a4a9b28c10665e36362ef9408dbc17c33d497 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/yellowBright.d.ts @@ -0,0 +1,15 @@ +//#region src/server/colors/yellowBright.d.ts +/** + * Bright yellow foreground. Wraps text with ANSI codes. + * + * @param text - The text to style. + * @returns The styled text. + * + * @example + * import { colors } from 'es-toolkit/server'; + * + * console.log(colors.yellowBright('hello')); + */ +declare function yellowBright(text: string): string; +//#endregion +export { yellowBright }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/colors/yellowBright.js b/node_modules/es-toolkit/dist/server/colors/yellowBright.js new file mode 100644 index 0000000000000000000000000000000000000000..fadd80ebf8e08a2d53664c6bfcba58703c405a57 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/yellowBright.js @@ -0,0 +1,18 @@ +const require_wrapAnsi = require("./_internal/wrapAnsi.js"); +//#region src/server/colors/yellowBright.ts +/** +* Bright yellow foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.yellowBright('hello')); +*/ +function yellowBright(text) { + return require_wrapAnsi.wrapAnsi("\x1B[93m", "\x1B[39m", text); +} +//#endregion +exports.yellowBright = yellowBright; diff --git a/node_modules/es-toolkit/dist/server/colors/yellowBright.mjs b/node_modules/es-toolkit/dist/server/colors/yellowBright.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fe45d326f0ecd6ad58684014fcfcc060571671e5 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/colors/yellowBright.mjs @@ -0,0 +1,18 @@ +import { wrapAnsi } from "./_internal/wrapAnsi.mjs"; +//#region src/server/colors/yellowBright.ts +/** +* Bright yellow foreground. Wraps text with ANSI codes. +* +* @param text - The text to style. +* @returns The styled text. +* +* @example +* import { colors } from 'es-toolkit/server'; +* +* console.log(colors.yellowBright('hello')); +*/ +function yellowBright(text) { + return wrapAnsi("\x1B[93m", "\x1B[39m", text); +} +//#endregion +export { yellowBright }; diff --git a/node_modules/es-toolkit/dist/server/exec.d.mts b/node_modules/es-toolkit/dist/server/exec.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..520ef5ed5d258673ee00ead67c99a8b22673d4cf --- /dev/null +++ b/node_modules/es-toolkit/dist/server/exec.d.mts @@ -0,0 +1,63 @@ +import { SpawnOptions } from "node:child_process"; + +//#region src/server/exec.d.ts +interface ExecOptions { + signal?: AbortSignal; + timeout?: number; + stdin?: string; + spawnOptions?: SpawnOptions; + throwOnNonZeroExitCode?: boolean; +} +interface ExecResult { + pid: number | undefined; + stderr: string; + stdout: string; + exitCode: number | null; +} +/** + * Executes a command and captures its output. + * + * This function spawns a child process, collects its stdout and stderr, and resolves with the + * process result when execution finishes. By default, it throws an {@link ExecError} when the + * process exits with a non-zero exit code. + * + * @param _command - The command to execute. + * @param args - The arguments passed to the command. + * @param options - The options object. + * @param options.signal - An optional AbortSignal used to abort the process. + * @param options.timeout - An optional timeout in milliseconds. When provided, the + * process is aborted after the timeout expires. + * @param options.stdin - An optional string written to the process stdin. + * @param options.spawnOptions - Additional options forwarded to `child_process.spawn`. + * @param options.throwOnNonZeroExitCode - Whether to throw an {@link ExecError} when the + * process exits with a non-zero exit code. Defaults to `true`. + * @returns A promise that resolves with the process result. + * @throws {ExecError} Throws when `throwOnNonZeroExitCode` is enabled and the process exits with a + * non-zero exit code. + * + * @example + * const result = await exec('echo', ['hello']); + * + * console.log(result.stdout.trim()); + * // => 'hello' + * + * @example + * const result = await exec('git', ['diff', '--quiet'], { + * throwOnNonZeroExitCode: false, + * }); + * + * console.log(result.exitCode); + * // => 1 when there are changes + */ +declare function exec(_command: string, args?: string[], options?: ExecOptions): Promise; +/** + * Represents an error thrown when a process exits with a non-zero exit code. + * + * @param result - The captured process result. + */ +declare class ExecError extends Error { + readonly result: ExecResult; + constructor(result: ExecResult); +} +//#endregion +export { ExecError, exec }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/exec.d.ts b/node_modules/es-toolkit/dist/server/exec.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..520ef5ed5d258673ee00ead67c99a8b22673d4cf --- /dev/null +++ b/node_modules/es-toolkit/dist/server/exec.d.ts @@ -0,0 +1,63 @@ +import { SpawnOptions } from "node:child_process"; + +//#region src/server/exec.d.ts +interface ExecOptions { + signal?: AbortSignal; + timeout?: number; + stdin?: string; + spawnOptions?: SpawnOptions; + throwOnNonZeroExitCode?: boolean; +} +interface ExecResult { + pid: number | undefined; + stderr: string; + stdout: string; + exitCode: number | null; +} +/** + * Executes a command and captures its output. + * + * This function spawns a child process, collects its stdout and stderr, and resolves with the + * process result when execution finishes. By default, it throws an {@link ExecError} when the + * process exits with a non-zero exit code. + * + * @param _command - The command to execute. + * @param args - The arguments passed to the command. + * @param options - The options object. + * @param options.signal - An optional AbortSignal used to abort the process. + * @param options.timeout - An optional timeout in milliseconds. When provided, the + * process is aborted after the timeout expires. + * @param options.stdin - An optional string written to the process stdin. + * @param options.spawnOptions - Additional options forwarded to `child_process.spawn`. + * @param options.throwOnNonZeroExitCode - Whether to throw an {@link ExecError} when the + * process exits with a non-zero exit code. Defaults to `true`. + * @returns A promise that resolves with the process result. + * @throws {ExecError} Throws when `throwOnNonZeroExitCode` is enabled and the process exits with a + * non-zero exit code. + * + * @example + * const result = await exec('echo', ['hello']); + * + * console.log(result.stdout.trim()); + * // => 'hello' + * + * @example + * const result = await exec('git', ['diff', '--quiet'], { + * throwOnNonZeroExitCode: false, + * }); + * + * console.log(result.exitCode); + * // => 1 when there are changes + */ +declare function exec(_command: string, args?: string[], options?: ExecOptions): Promise; +/** + * Represents an error thrown when a process exits with a non-zero exit code. + * + * @param result - The captured process result. + */ +declare class ExecError extends Error { + readonly result: ExecResult; + constructor(result: ExecResult); +} +//#endregion +export { ExecError, exec }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/exec.js b/node_modules/es-toolkit/dist/server/exec.js new file mode 100644 index 0000000000000000000000000000000000000000..503b0546e9ec2ef7a1d5b8b93c20b3a0e543b3a1 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/exec.js @@ -0,0 +1,103 @@ +let node_child_process = require("node:child_process"); +let node_path = require("node:path"); +//#region src/server/exec.ts +/** +* Executes a command and captures its output. +* +* This function spawns a child process, collects its stdout and stderr, and resolves with the +* process result when execution finishes. By default, it throws an {@link ExecError} when the +* process exits with a non-zero exit code. +* +* @param _command - The command to execute. +* @param args - The arguments passed to the command. +* @param options - The options object. +* @param options.signal - An optional AbortSignal used to abort the process. +* @param options.timeout - An optional timeout in milliseconds. When provided, the +* process is aborted after the timeout expires. +* @param options.stdin - An optional string written to the process stdin. +* @param options.spawnOptions - Additional options forwarded to `child_process.spawn`. +* @param options.throwOnNonZeroExitCode - Whether to throw an {@link ExecError} when the +* process exits with a non-zero exit code. Defaults to `true`. +* @returns A promise that resolves with the process result. +* @throws {ExecError} Throws when `throwOnNonZeroExitCode` is enabled and the process exits with a +* non-zero exit code. +* +* @example +* const result = await exec('echo', ['hello']); +* +* console.log(result.stdout.trim()); +* // => 'hello' +* +* @example +* const result = await exec('git', ['diff', '--quiet'], { +* throwOnNonZeroExitCode: false, +* }); +* +* console.log(result.exitCode); +* // => 1 when there are changes +*/ +async function exec(_command, args = [], options = {}) { + const command = (0, node_path.normalize)(_command); + const signal = parseAbortSignal(options); + const resolver = Promise.withResolvers(); + const process = (0, node_child_process.spawn)(command, args, { + windowsHide: true, + ...options.spawnOptions, + signal + }); + handleStdin(process, options); + process.once("close", () => { + resolver.resolve(); + }); + process.once("error", (error) => { + resolver.reject(error); + }); + const stdoutPromise = process.stdout != null ? streamToString(process.stdout) : Promise.resolve(""); + const stderrPromise = process.stderr != null ? streamToString(process.stderr) : Promise.resolve(""); + await resolver.promise; + const stdout = await stdoutPromise; + const stderr = await stderrPromise; + if ((options.throwOnNonZeroExitCode ?? true) && process.exitCode !== 0) throw new ExecError({ + pid: process.pid, + stdout, + stderr, + exitCode: process.exitCode + }); + return { + pid: process.pid, + stdout, + stderr, + exitCode: process.exitCode + }; +} +/** +* Represents an error thrown when a process exits with a non-zero exit code. +* +* @param result - The captured process result. +*/ +var ExecError = class extends Error { + result; + constructor(result) { + super(`Process exited with non-zero exit code (${result.exitCode})`); + this.result = result; + this.name = "ExecError"; + } +}; +async function streamToString(stream) { + return Buffer.concat(await stream.toArray()).toString("utf-8"); +} +function handleStdin(process, options) { + if (options.stdin == null) return; + if (typeof options.stdin === "string") process.stdin?.end(options.stdin); +} +function parseAbortSignal(options) { + const signals = []; + if (options.signal != null) signals.push(options.signal); + if (options.timeout != null) signals.push(AbortSignal.timeout(options.timeout)); + if (options.spawnOptions?.signal != null) signals.push(options.spawnOptions.signal); + if (signals.length === 0) return; + return AbortSignal.any(signals); +} +//#endregion +exports.ExecError = ExecError; +exports.exec = exec; diff --git a/node_modules/es-toolkit/dist/server/exec.mjs b/node_modules/es-toolkit/dist/server/exec.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5598b0285c033cd7e55f71d7d1c37c680453972c --- /dev/null +++ b/node_modules/es-toolkit/dist/server/exec.mjs @@ -0,0 +1,102 @@ +import { spawn } from "node:child_process"; +import { normalize } from "node:path"; +//#region src/server/exec.ts +/** +* Executes a command and captures its output. +* +* This function spawns a child process, collects its stdout and stderr, and resolves with the +* process result when execution finishes. By default, it throws an {@link ExecError} when the +* process exits with a non-zero exit code. +* +* @param _command - The command to execute. +* @param args - The arguments passed to the command. +* @param options - The options object. +* @param options.signal - An optional AbortSignal used to abort the process. +* @param options.timeout - An optional timeout in milliseconds. When provided, the +* process is aborted after the timeout expires. +* @param options.stdin - An optional string written to the process stdin. +* @param options.spawnOptions - Additional options forwarded to `child_process.spawn`. +* @param options.throwOnNonZeroExitCode - Whether to throw an {@link ExecError} when the +* process exits with a non-zero exit code. Defaults to `true`. +* @returns A promise that resolves with the process result. +* @throws {ExecError} Throws when `throwOnNonZeroExitCode` is enabled and the process exits with a +* non-zero exit code. +* +* @example +* const result = await exec('echo', ['hello']); +* +* console.log(result.stdout.trim()); +* // => 'hello' +* +* @example +* const result = await exec('git', ['diff', '--quiet'], { +* throwOnNonZeroExitCode: false, +* }); +* +* console.log(result.exitCode); +* // => 1 when there are changes +*/ +async function exec(_command, args = [], options = {}) { + const command = normalize(_command); + const signal = parseAbortSignal(options); + const resolver = Promise.withResolvers(); + const process = spawn(command, args, { + windowsHide: true, + ...options.spawnOptions, + signal + }); + handleStdin(process, options); + process.once("close", () => { + resolver.resolve(); + }); + process.once("error", (error) => { + resolver.reject(error); + }); + const stdoutPromise = process.stdout != null ? streamToString(process.stdout) : Promise.resolve(""); + const stderrPromise = process.stderr != null ? streamToString(process.stderr) : Promise.resolve(""); + await resolver.promise; + const stdout = await stdoutPromise; + const stderr = await stderrPromise; + if ((options.throwOnNonZeroExitCode ?? true) && process.exitCode !== 0) throw new ExecError({ + pid: process.pid, + stdout, + stderr, + exitCode: process.exitCode + }); + return { + pid: process.pid, + stdout, + stderr, + exitCode: process.exitCode + }; +} +/** +* Represents an error thrown when a process exits with a non-zero exit code. +* +* @param result - The captured process result. +*/ +var ExecError = class extends Error { + result; + constructor(result) { + super(`Process exited with non-zero exit code (${result.exitCode})`); + this.result = result; + this.name = "ExecError"; + } +}; +async function streamToString(stream) { + return Buffer.concat(await stream.toArray()).toString("utf-8"); +} +function handleStdin(process, options) { + if (options.stdin == null) return; + if (typeof options.stdin === "string") process.stdin?.end(options.stdin); +} +function parseAbortSignal(options) { + const signals = []; + if (options.signal != null) signals.push(options.signal); + if (options.timeout != null) signals.push(AbortSignal.timeout(options.timeout)); + if (options.spawnOptions?.signal != null) signals.push(options.spawnOptions.signal); + if (signals.length === 0) return; + return AbortSignal.any(signals); +} +//#endregion +export { ExecError, exec }; diff --git a/node_modules/es-toolkit/dist/server/index.d.mts b/node_modules/es-toolkit/dist/server/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c5cca478317bba3b04867b71a0a9ad51d3856468 --- /dev/null +++ b/node_modules/es-toolkit/dist/server/index.d.mts @@ -0,0 +1,4 @@ +import { ColorFunction } from "./colors/types.mjs"; +import { colors } from "./colors/index.mjs"; +import { ExecError, exec } from "./exec.mjs"; +export { type ColorFunction, ExecError, colors, exec }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/index.d.ts b/node_modules/es-toolkit/dist/server/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e714e6afb5e204aaa4d977991ec77b1c8fa240b --- /dev/null +++ b/node_modules/es-toolkit/dist/server/index.d.ts @@ -0,0 +1,4 @@ +import { ColorFunction } from "./colors/types.js"; +import { colors } from "./colors/index.js"; +import { ExecError, exec } from "./exec.js"; +export { type ColorFunction, ExecError, colors, exec }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/server/index.js b/node_modules/es-toolkit/dist/server/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d67feeb79074210530b1c52802847792138bd0db --- /dev/null +++ b/node_modules/es-toolkit/dist/server/index.js @@ -0,0 +1,6 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_index = require("./colors/index.js"); +const require_exec = require("./exec.js"); +exports.ExecError = require_exec.ExecError; +exports.colors = require_index.colors; +exports.exec = require_exec.exec; diff --git a/node_modules/es-toolkit/dist/server/index.mjs b/node_modules/es-toolkit/dist/server/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..151a52c6857e0d6a637129f214f7a0e187fbbc8e --- /dev/null +++ b/node_modules/es-toolkit/dist/server/index.mjs @@ -0,0 +1,3 @@ +import { colors } from "./colors/index.mjs"; +import { ExecError, exec } from "./exec.mjs"; +export { ExecError, colors, exec }; diff --git a/node_modules/es-toolkit/dist/set/countBy.d.mts b/node_modules/es-toolkit/dist/set/countBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0499ab2ed5cbb19c1594ea536b0280cbfa644cc1 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/countBy.d.mts @@ -0,0 +1,27 @@ +//#region src/set/countBy.d.ts +/** + * Counts the occurrences of items in a Set based on a transformation function. + * + * This function takes a Set and a function that generates a key from each value. + * It returns a Map with the generated keys and their counts as values. + * The count is incremented for each element for which the transformation produces the same key. + * + * @template T - The type of elements in the Set. + * @template K - The type of keys produced by the transformation function. + * @param set - The Set to count occurrences from. + * @param mapper - The function to produce a key for counting. + * @returns A Map containing the mapped keys and their counts. + * + * @example + * const set = new Set([1, 2, 3, 4, 5]); + * const result = countBy(set, (value) => value % 2 === 0 ? 'even' : 'odd'); + * // result will be Map(2) { 'odd' => 3, 'even' => 2 } + * + * @example + * const set = new Set(['apple', 'banana', 'cherry']); + * const result = countBy(set, (value) => value.length); + * // result will be Map(2) { 5 => 1, 6 => 2 } + */ +declare function countBy(set: Set, mapper: (value: T, value2: T, set: Set) => K): Map; +//#endregion +export { countBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/countBy.d.ts b/node_modules/es-toolkit/dist/set/countBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0499ab2ed5cbb19c1594ea536b0280cbfa644cc1 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/countBy.d.ts @@ -0,0 +1,27 @@ +//#region src/set/countBy.d.ts +/** + * Counts the occurrences of items in a Set based on a transformation function. + * + * This function takes a Set and a function that generates a key from each value. + * It returns a Map with the generated keys and their counts as values. + * The count is incremented for each element for which the transformation produces the same key. + * + * @template T - The type of elements in the Set. + * @template K - The type of keys produced by the transformation function. + * @param set - The Set to count occurrences from. + * @param mapper - The function to produce a key for counting. + * @returns A Map containing the mapped keys and their counts. + * + * @example + * const set = new Set([1, 2, 3, 4, 5]); + * const result = countBy(set, (value) => value % 2 === 0 ? 'even' : 'odd'); + * // result will be Map(2) { 'odd' => 3, 'even' => 2 } + * + * @example + * const set = new Set(['apple', 'banana', 'cherry']); + * const result = countBy(set, (value) => value.length); + * // result will be Map(2) { 5 => 1, 6 => 2 } + */ +declare function countBy(set: Set, mapper: (value: T, value2: T, set: Set) => K): Map; +//#endregion +export { countBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/countBy.js b/node_modules/es-toolkit/dist/set/countBy.js new file mode 100644 index 0000000000000000000000000000000000000000..934f1d129a08f55debfeff195c1fa71bb4f9c836 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/countBy.js @@ -0,0 +1,34 @@ +//#region src/set/countBy.ts +/** +* Counts the occurrences of items in a Set based on a transformation function. +* +* This function takes a Set and a function that generates a key from each value. +* It returns a Map with the generated keys and their counts as values. +* The count is incremented for each element for which the transformation produces the same key. +* +* @template T - The type of elements in the Set. +* @template K - The type of keys produced by the transformation function. +* @param set - The Set to count occurrences from. +* @param mapper - The function to produce a key for counting. +* @returns A Map containing the mapped keys and their counts. +* +* @example +* const set = new Set([1, 2, 3, 4, 5]); +* const result = countBy(set, (value) => value % 2 === 0 ? 'even' : 'odd'); +* // result will be Map(2) { 'odd' => 3, 'even' => 2 } +* +* @example +* const set = new Set(['apple', 'banana', 'cherry']); +* const result = countBy(set, (value) => value.length); +* // result will be Map(2) { 5 => 1, 6 => 2 } +*/ +function countBy(set, mapper) { + const result = /* @__PURE__ */ new Map(); + for (const value of set) { + const mappedKey = mapper(value, value, set); + result.set(mappedKey, (result.get(mappedKey) ?? 0) + 1); + } + return result; +} +//#endregion +exports.countBy = countBy; diff --git a/node_modules/es-toolkit/dist/set/countBy.mjs b/node_modules/es-toolkit/dist/set/countBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d76c23079392c5cdaa2600dafe9e81b5ec37684b --- /dev/null +++ b/node_modules/es-toolkit/dist/set/countBy.mjs @@ -0,0 +1,34 @@ +//#region src/set/countBy.ts +/** +* Counts the occurrences of items in a Set based on a transformation function. +* +* This function takes a Set and a function that generates a key from each value. +* It returns a Map with the generated keys and their counts as values. +* The count is incremented for each element for which the transformation produces the same key. +* +* @template T - The type of elements in the Set. +* @template K - The type of keys produced by the transformation function. +* @param set - The Set to count occurrences from. +* @param mapper - The function to produce a key for counting. +* @returns A Map containing the mapped keys and their counts. +* +* @example +* const set = new Set([1, 2, 3, 4, 5]); +* const result = countBy(set, (value) => value % 2 === 0 ? 'even' : 'odd'); +* // result will be Map(2) { 'odd' => 3, 'even' => 2 } +* +* @example +* const set = new Set(['apple', 'banana', 'cherry']); +* const result = countBy(set, (value) => value.length); +* // result will be Map(2) { 5 => 1, 6 => 2 } +*/ +function countBy(set, mapper) { + const result = /* @__PURE__ */ new Map(); + for (const value of set) { + const mappedKey = mapper(value, value, set); + result.set(mappedKey, (result.get(mappedKey) ?? 0) + 1); + } + return result; +} +//#endregion +export { countBy }; diff --git a/node_modules/es-toolkit/dist/set/every.d.mts b/node_modules/es-toolkit/dist/set/every.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f48aa26e8c771efa850e5d8d7dd179171f311f09 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/every.d.mts @@ -0,0 +1,24 @@ +//#region src/set/every.d.ts +/** + * Tests whether all elements in a Set satisfy the provided predicate function. + * + * This function iterates through all elements of the Set and checks if the predicate function + * returns true for every element. It returns true if the predicate is satisfied for all elements, + * and false otherwise. + * + * @template T - The type of elements in the Set. + * @param set - The Set to test. + * @param doesMatch - A predicate function that tests each element. + * @returns true if all elements satisfy the predicate, false otherwise. + * + * @example + * const set = new Set([10, 20, 30]); + * const result = every(set, (value) => value > 5); + * // result will be: true + * + * const result2 = every(set, (value) => value > 15); + * // result2 will be: false + */ +declare function every(set: Set, doesMatch: (value: T, value2: T, set: Set) => boolean): boolean; +//#endregion +export { every }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/every.d.ts b/node_modules/es-toolkit/dist/set/every.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f48aa26e8c771efa850e5d8d7dd179171f311f09 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/every.d.ts @@ -0,0 +1,24 @@ +//#region src/set/every.d.ts +/** + * Tests whether all elements in a Set satisfy the provided predicate function. + * + * This function iterates through all elements of the Set and checks if the predicate function + * returns true for every element. It returns true if the predicate is satisfied for all elements, + * and false otherwise. + * + * @template T - The type of elements in the Set. + * @param set - The Set to test. + * @param doesMatch - A predicate function that tests each element. + * @returns true if all elements satisfy the predicate, false otherwise. + * + * @example + * const set = new Set([10, 20, 30]); + * const result = every(set, (value) => value > 5); + * // result will be: true + * + * const result2 = every(set, (value) => value > 15); + * // result2 will be: false + */ +declare function every(set: Set, doesMatch: (value: T, value2: T, set: Set) => boolean): boolean; +//#endregion +export { every }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/every.js b/node_modules/es-toolkit/dist/set/every.js new file mode 100644 index 0000000000000000000000000000000000000000..c2ea3039f481371aaa703e1aea0671e9101b03a3 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/every.js @@ -0,0 +1,27 @@ +//#region src/set/every.ts +/** +* Tests whether all elements in a Set satisfy the provided predicate function. +* +* This function iterates through all elements of the Set and checks if the predicate function +* returns true for every element. It returns true if the predicate is satisfied for all elements, +* and false otherwise. +* +* @template T - The type of elements in the Set. +* @param set - The Set to test. +* @param doesMatch - A predicate function that tests each element. +* @returns true if all elements satisfy the predicate, false otherwise. +* +* @example +* const set = new Set([10, 20, 30]); +* const result = every(set, (value) => value > 5); +* // result will be: true +* +* const result2 = every(set, (value) => value > 15); +* // result2 will be: false +*/ +function every(set, doesMatch) { + for (const value of set) if (!doesMatch(value, value, set)) return false; + return true; +} +//#endregion +exports.every = every; diff --git a/node_modules/es-toolkit/dist/set/every.mjs b/node_modules/es-toolkit/dist/set/every.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f6996f2bef9cba7d952f4aaf1accbfe7c873a039 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/every.mjs @@ -0,0 +1,27 @@ +//#region src/set/every.ts +/** +* Tests whether all elements in a Set satisfy the provided predicate function. +* +* This function iterates through all elements of the Set and checks if the predicate function +* returns true for every element. It returns true if the predicate is satisfied for all elements, +* and false otherwise. +* +* @template T - The type of elements in the Set. +* @param set - The Set to test. +* @param doesMatch - A predicate function that tests each element. +* @returns true if all elements satisfy the predicate, false otherwise. +* +* @example +* const set = new Set([10, 20, 30]); +* const result = every(set, (value) => value > 5); +* // result will be: true +* +* const result2 = every(set, (value) => value > 15); +* // result2 will be: false +*/ +function every(set, doesMatch) { + for (const value of set) if (!doesMatch(value, value, set)) return false; + return true; +} +//#endregion +export { every }; diff --git a/node_modules/es-toolkit/dist/set/filter.d.mts b/node_modules/es-toolkit/dist/set/filter.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..75dc1218572cd889f59a341c959c1730ef7ca418 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/filter.d.mts @@ -0,0 +1,21 @@ +//#region src/set/filter.d.ts +/** + * Filters a Set based on a predicate function. + * + * This function takes a Set and a predicate function, and returns a new Set containing + * only the elements for which the predicate function returns true. + * + * @template T - The type of elements in the Set. + * @param set - The Set to filter. + * @param callback - A predicate function that tests each element. + * @returns A new Set containing only the elements that satisfy the predicate. + * + * @example + * const set = new Set([1, 2, 3, 4, 5]); + * const result = filter(set, (value) => value > 2); + * // result will be: + * // Set(3) { 3, 4, 5 } + */ +declare function filter(set: Set, callback: (value: T, value2: T, set: Set) => boolean): Set; +//#endregion +export { filter }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/filter.d.ts b/node_modules/es-toolkit/dist/set/filter.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..75dc1218572cd889f59a341c959c1730ef7ca418 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/filter.d.ts @@ -0,0 +1,21 @@ +//#region src/set/filter.d.ts +/** + * Filters a Set based on a predicate function. + * + * This function takes a Set and a predicate function, and returns a new Set containing + * only the elements for which the predicate function returns true. + * + * @template T - The type of elements in the Set. + * @param set - The Set to filter. + * @param callback - A predicate function that tests each element. + * @returns A new Set containing only the elements that satisfy the predicate. + * + * @example + * const set = new Set([1, 2, 3, 4, 5]); + * const result = filter(set, (value) => value > 2); + * // result will be: + * // Set(3) { 3, 4, 5 } + */ +declare function filter(set: Set, callback: (value: T, value2: T, set: Set) => boolean): Set; +//#endregion +export { filter }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/filter.js b/node_modules/es-toolkit/dist/set/filter.js new file mode 100644 index 0000000000000000000000000000000000000000..47b92d79fa678a6b619d6b3a1c06807ce17e9a61 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/filter.js @@ -0,0 +1,25 @@ +//#region src/set/filter.ts +/** +* Filters a Set based on a predicate function. +* +* This function takes a Set and a predicate function, and returns a new Set containing +* only the elements for which the predicate function returns true. +* +* @template T - The type of elements in the Set. +* @param set - The Set to filter. +* @param callback - A predicate function that tests each element. +* @returns A new Set containing only the elements that satisfy the predicate. +* +* @example +* const set = new Set([1, 2, 3, 4, 5]); +* const result = filter(set, (value) => value > 2); +* // result will be: +* // Set(3) { 3, 4, 5 } +*/ +function filter(set, callback) { + const result = /* @__PURE__ */ new Set(); + for (const value of set) if (callback(value, value, set)) result.add(value); + return result; +} +//#endregion +exports.filter = filter; diff --git a/node_modules/es-toolkit/dist/set/filter.mjs b/node_modules/es-toolkit/dist/set/filter.mjs new file mode 100644 index 0000000000000000000000000000000000000000..278f6f0c7744f83f236eaf332f863f39a8b71519 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/filter.mjs @@ -0,0 +1,25 @@ +//#region src/set/filter.ts +/** +* Filters a Set based on a predicate function. +* +* This function takes a Set and a predicate function, and returns a new Set containing +* only the elements for which the predicate function returns true. +* +* @template T - The type of elements in the Set. +* @param set - The Set to filter. +* @param callback - A predicate function that tests each element. +* @returns A new Set containing only the elements that satisfy the predicate. +* +* @example +* const set = new Set([1, 2, 3, 4, 5]); +* const result = filter(set, (value) => value > 2); +* // result will be: +* // Set(3) { 3, 4, 5 } +*/ +function filter(set, callback) { + const result = /* @__PURE__ */ new Set(); + for (const value of set) if (callback(value, value, set)) result.add(value); + return result; +} +//#endregion +export { filter }; diff --git a/node_modules/es-toolkit/dist/set/find.d.mts b/node_modules/es-toolkit/dist/set/find.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..63dbbb7a8ecfa74f99da8a5ec14d35507ea1a3bb --- /dev/null +++ b/node_modules/es-toolkit/dist/set/find.d.mts @@ -0,0 +1,25 @@ +//#region src/set/find.d.ts +/** + * Finds the first element in a Set for which the predicate function returns true. + * + * This function iterates through the elements of the Set and returns the first + * element for which the predicate function returns true. If no element satisfies the predicate, + * it returns undefined. + * + * @template T - The type of elements in the Set. + * @param set - The Set to search. + * @param doesMatch - A predicate function that tests each element. + * @returns The first element that satisfies the predicate, or undefined if none found. + * + * @example + * const set = new Set([ + * { name: 'apple', quantity: 10 }, + * { name: 'banana', quantity: 5 }, + * { name: 'grape', quantity: 15 } + * ]); + * const result = find(set, (value) => value.quantity > 10); + * // result will be: { name: 'grape', quantity: 15 } + */ +declare function find(set: Set, doesMatch: (value: T, value2: T, set: Set) => boolean): T | undefined; +//#endregion +export { find }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/find.d.ts b/node_modules/es-toolkit/dist/set/find.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..63dbbb7a8ecfa74f99da8a5ec14d35507ea1a3bb --- /dev/null +++ b/node_modules/es-toolkit/dist/set/find.d.ts @@ -0,0 +1,25 @@ +//#region src/set/find.d.ts +/** + * Finds the first element in a Set for which the predicate function returns true. + * + * This function iterates through the elements of the Set and returns the first + * element for which the predicate function returns true. If no element satisfies the predicate, + * it returns undefined. + * + * @template T - The type of elements in the Set. + * @param set - The Set to search. + * @param doesMatch - A predicate function that tests each element. + * @returns The first element that satisfies the predicate, or undefined if none found. + * + * @example + * const set = new Set([ + * { name: 'apple', quantity: 10 }, + * { name: 'banana', quantity: 5 }, + * { name: 'grape', quantity: 15 } + * ]); + * const result = find(set, (value) => value.quantity > 10); + * // result will be: { name: 'grape', quantity: 15 } + */ +declare function find(set: Set, doesMatch: (value: T, value2: T, set: Set) => boolean): T | undefined; +//#endregion +export { find }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/find.js b/node_modules/es-toolkit/dist/set/find.js new file mode 100644 index 0000000000000000000000000000000000000000..d092e8f1f5878dd603a1483700ed73f0a123ba59 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/find.js @@ -0,0 +1,27 @@ +//#region src/set/find.ts +/** +* Finds the first element in a Set for which the predicate function returns true. +* +* This function iterates through the elements of the Set and returns the first +* element for which the predicate function returns true. If no element satisfies the predicate, +* it returns undefined. +* +* @template T - The type of elements in the Set. +* @param set - The Set to search. +* @param doesMatch - A predicate function that tests each element. +* @returns The first element that satisfies the predicate, or undefined if none found. +* +* @example +* const set = new Set([ +* { name: 'apple', quantity: 10 }, +* { name: 'banana', quantity: 5 }, +* { name: 'grape', quantity: 15 } +* ]); +* const result = find(set, (value) => value.quantity > 10); +* // result will be: { name: 'grape', quantity: 15 } +*/ +function find(set, doesMatch) { + for (const value of set) if (doesMatch(value, value, set)) return value; +} +//#endregion +exports.find = find; diff --git a/node_modules/es-toolkit/dist/set/find.mjs b/node_modules/es-toolkit/dist/set/find.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8b4d65b47687596d24891e47a2d879bbbac18e1e --- /dev/null +++ b/node_modules/es-toolkit/dist/set/find.mjs @@ -0,0 +1,27 @@ +//#region src/set/find.ts +/** +* Finds the first element in a Set for which the predicate function returns true. +* +* This function iterates through the elements of the Set and returns the first +* element for which the predicate function returns true. If no element satisfies the predicate, +* it returns undefined. +* +* @template T - The type of elements in the Set. +* @param set - The Set to search. +* @param doesMatch - A predicate function that tests each element. +* @returns The first element that satisfies the predicate, or undefined if none found. +* +* @example +* const set = new Set([ +* { name: 'apple', quantity: 10 }, +* { name: 'banana', quantity: 5 }, +* { name: 'grape', quantity: 15 } +* ]); +* const result = find(set, (value) => value.quantity > 10); +* // result will be: { name: 'grape', quantity: 15 } +*/ +function find(set, doesMatch) { + for (const value of set) if (doesMatch(value, value, set)) return value; +} +//#endregion +export { find }; diff --git a/node_modules/es-toolkit/dist/set/forEach.d.mts b/node_modules/es-toolkit/dist/set/forEach.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..7e61cfa612e7dae9ecc1d3c8584edd2e38545b62 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/forEach.d.mts @@ -0,0 +1,25 @@ +//#region src/set/forEach.d.ts +/** + * Executes a provided function once for each element in a Set. + * + * This function iterates through all elements of the Set and executes the callback function + * for each element. The callback receives the value twice (for consistency with Map.forEach) + * and the Set itself as arguments. + * + * @template T - The type of elements in the Set. + * @param set - The Set to iterate over. + * @param callback - A function to execute for each element. + * + * @example + * const set = new Set([1, 2, 3]); + * forEach(set, (value) => { + * console.log(value * 2); + * }); + * // Output: + * // 2 + * // 4 + * // 6 + */ +declare function forEach(set: Set, callback: (value: T, value2: T, set: Set) => void): void; +//#endregion +export { forEach }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/forEach.d.ts b/node_modules/es-toolkit/dist/set/forEach.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e61cfa612e7dae9ecc1d3c8584edd2e38545b62 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/forEach.d.ts @@ -0,0 +1,25 @@ +//#region src/set/forEach.d.ts +/** + * Executes a provided function once for each element in a Set. + * + * This function iterates through all elements of the Set and executes the callback function + * for each element. The callback receives the value twice (for consistency with Map.forEach) + * and the Set itself as arguments. + * + * @template T - The type of elements in the Set. + * @param set - The Set to iterate over. + * @param callback - A function to execute for each element. + * + * @example + * const set = new Set([1, 2, 3]); + * forEach(set, (value) => { + * console.log(value * 2); + * }); + * // Output: + * // 2 + * // 4 + * // 6 + */ +declare function forEach(set: Set, callback: (value: T, value2: T, set: Set) => void): void; +//#endregion +export { forEach }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/forEach.js b/node_modules/es-toolkit/dist/set/forEach.js new file mode 100644 index 0000000000000000000000000000000000000000..44021bc5e02e444ca7f8c057b546adc509e7abc9 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/forEach.js @@ -0,0 +1,27 @@ +//#region src/set/forEach.ts +/** +* Executes a provided function once for each element in a Set. +* +* This function iterates through all elements of the Set and executes the callback function +* for each element. The callback receives the value twice (for consistency with Map.forEach) +* and the Set itself as arguments. +* +* @template T - The type of elements in the Set. +* @param set - The Set to iterate over. +* @param callback - A function to execute for each element. +* +* @example +* const set = new Set([1, 2, 3]); +* forEach(set, (value) => { +* console.log(value * 2); +* }); +* // Output: +* // 2 +* // 4 +* // 6 +*/ +function forEach(set, callback) { + for (const value of set) callback(value, value, set); +} +//#endregion +exports.forEach = forEach; diff --git a/node_modules/es-toolkit/dist/set/forEach.mjs b/node_modules/es-toolkit/dist/set/forEach.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f0c65a1ff6db5b954eb9c18d4fc651774d66df7e --- /dev/null +++ b/node_modules/es-toolkit/dist/set/forEach.mjs @@ -0,0 +1,27 @@ +//#region src/set/forEach.ts +/** +* Executes a provided function once for each element in a Set. +* +* This function iterates through all elements of the Set and executes the callback function +* for each element. The callback receives the value twice (for consistency with Map.forEach) +* and the Set itself as arguments. +* +* @template T - The type of elements in the Set. +* @param set - The Set to iterate over. +* @param callback - A function to execute for each element. +* +* @example +* const set = new Set([1, 2, 3]); +* forEach(set, (value) => { +* console.log(value * 2); +* }); +* // Output: +* // 2 +* // 4 +* // 6 +*/ +function forEach(set, callback) { + for (const value of set) callback(value, value, set); +} +//#endregion +export { forEach }; diff --git a/node_modules/es-toolkit/dist/set/index.d.mts b/node_modules/es-toolkit/dist/set/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9a6c71d0f7ee4d9d39119311b9fe344688fe2c85 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/index.d.mts @@ -0,0 +1,10 @@ +import { countBy } from "./countBy.mjs"; +import { every } from "./every.mjs"; +import { filter } from "./filter.mjs"; +import { find } from "./find.mjs"; +import { forEach } from "./forEach.mjs"; +import { keyBy } from "./keyBy.mjs"; +import { map } from "./map.mjs"; +import { reduce } from "./reduce.mjs"; +import { some } from "./some.mjs"; +export { countBy, every, filter, find, forEach, keyBy, map, reduce, some }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/index.d.ts b/node_modules/es-toolkit/dist/set/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..34d18980f6c48339a6173199ae2c23eadc7baadf --- /dev/null +++ b/node_modules/es-toolkit/dist/set/index.d.ts @@ -0,0 +1,10 @@ +import { countBy } from "./countBy.js"; +import { every } from "./every.js"; +import { filter } from "./filter.js"; +import { find } from "./find.js"; +import { forEach } from "./forEach.js"; +import { keyBy } from "./keyBy.js"; +import { map } from "./map.js"; +import { reduce } from "./reduce.js"; +import { some } from "./some.js"; +export { countBy, every, filter, find, forEach, keyBy, map, reduce, some }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/index.js b/node_modules/es-toolkit/dist/set/index.js new file mode 100644 index 0000000000000000000000000000000000000000..fce6dd763f0ad0a0f73c0d5982ea85a2798e5c0f --- /dev/null +++ b/node_modules/es-toolkit/dist/set/index.js @@ -0,0 +1,19 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_countBy = require("./countBy.js"); +const require_every = require("./every.js"); +const require_filter = require("./filter.js"); +const require_find = require("./find.js"); +const require_forEach = require("./forEach.js"); +const require_keyBy = require("./keyBy.js"); +const require_map = require("./map.js"); +const require_reduce = require("./reduce.js"); +const require_some = require("./some.js"); +exports.countBy = require_countBy.countBy; +exports.every = require_every.every; +exports.filter = require_filter.filter; +exports.find = require_find.find; +exports.forEach = require_forEach.forEach; +exports.keyBy = require_keyBy.keyBy; +exports.map = require_map.map; +exports.reduce = require_reduce.reduce; +exports.some = require_some.some; diff --git a/node_modules/es-toolkit/dist/set/index.mjs b/node_modules/es-toolkit/dist/set/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b2054f4842d17f3543f767a425f1125c84f702c6 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/index.mjs @@ -0,0 +1,10 @@ +import { countBy } from "./countBy.mjs"; +import { every } from "./every.mjs"; +import { filter } from "./filter.mjs"; +import { find } from "./find.mjs"; +import { forEach } from "./forEach.mjs"; +import { keyBy } from "./keyBy.mjs"; +import { map } from "./map.mjs"; +import { reduce } from "./reduce.mjs"; +import { some } from "./some.mjs"; +export { countBy, every, filter, find, forEach, keyBy, map, reduce, some }; diff --git a/node_modules/es-toolkit/dist/set/keyBy.d.mts b/node_modules/es-toolkit/dist/set/keyBy.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d16416387ebb64e768c2da788f077f4a770b6388 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/keyBy.d.mts @@ -0,0 +1,31 @@ +//#region src/set/keyBy.d.ts +/** + * Maps each element of a Set based on a provided key-generating function. + * + * This function takes a Set and a function that generates a key from each value. + * It returns a new Map where the keys are generated by the key function and the values are + * the corresponding values from the original set. If multiple elements produce the same key, + * the last value encountered will be used. + * + * @template T - The type of elements in the Set. + * @template K - The type of keys to produce in the returned Map. + * @param set - The set of elements to be mapped. + * @param getKeyFromValue - A function that generates a key from a value. + * @returns A Map where the generated keys are mapped to each element's value. + * + * @example + * const set = new Set([ + * { type: 'fruit', name: 'apple' }, + * { type: 'fruit', name: 'banana' }, + * { type: 'vegetable', name: 'carrot' } + * ]); + * const result = keyBy(set, item => item.type); + * // result will be: + * // Map(2) { + * // 'fruit' => { type: 'fruit', name: 'banana' }, + * // 'vegetable' => { type: 'vegetable', name: 'carrot' } + * // } + */ +declare function keyBy(set: Set, getKeyFromValue: (value: T, value2: T, set: Set) => K): Map; +//#endregion +export { keyBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/keyBy.d.ts b/node_modules/es-toolkit/dist/set/keyBy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d16416387ebb64e768c2da788f077f4a770b6388 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/keyBy.d.ts @@ -0,0 +1,31 @@ +//#region src/set/keyBy.d.ts +/** + * Maps each element of a Set based on a provided key-generating function. + * + * This function takes a Set and a function that generates a key from each value. + * It returns a new Map where the keys are generated by the key function and the values are + * the corresponding values from the original set. If multiple elements produce the same key, + * the last value encountered will be used. + * + * @template T - The type of elements in the Set. + * @template K - The type of keys to produce in the returned Map. + * @param set - The set of elements to be mapped. + * @param getKeyFromValue - A function that generates a key from a value. + * @returns A Map where the generated keys are mapped to each element's value. + * + * @example + * const set = new Set([ + * { type: 'fruit', name: 'apple' }, + * { type: 'fruit', name: 'banana' }, + * { type: 'vegetable', name: 'carrot' } + * ]); + * const result = keyBy(set, item => item.type); + * // result will be: + * // Map(2) { + * // 'fruit' => { type: 'fruit', name: 'banana' }, + * // 'vegetable' => { type: 'vegetable', name: 'carrot' } + * // } + */ +declare function keyBy(set: Set, getKeyFromValue: (value: T, value2: T, set: Set) => K): Map; +//#endregion +export { keyBy }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/keyBy.js b/node_modules/es-toolkit/dist/set/keyBy.js new file mode 100644 index 0000000000000000000000000000000000000000..345e6929f16710e104dabfb57b77053be72d21c7 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/keyBy.js @@ -0,0 +1,38 @@ +//#region src/set/keyBy.ts +/** +* Maps each element of a Set based on a provided key-generating function. +* +* This function takes a Set and a function that generates a key from each value. +* It returns a new Map where the keys are generated by the key function and the values are +* the corresponding values from the original set. If multiple elements produce the same key, +* the last value encountered will be used. +* +* @template T - The type of elements in the Set. +* @template K - The type of keys to produce in the returned Map. +* @param set - The set of elements to be mapped. +* @param getKeyFromValue - A function that generates a key from a value. +* @returns A Map where the generated keys are mapped to each element's value. +* +* @example +* const set = new Set([ +* { type: 'fruit', name: 'apple' }, +* { type: 'fruit', name: 'banana' }, +* { type: 'vegetable', name: 'carrot' } +* ]); +* const result = keyBy(set, item => item.type); +* // result will be: +* // Map(2) { +* // 'fruit' => { type: 'fruit', name: 'banana' }, +* // 'vegetable' => { type: 'vegetable', name: 'carrot' } +* // } +*/ +function keyBy(set, getKeyFromValue) { + const result = /* @__PURE__ */ new Map(); + for (const value of set) { + const newKey = getKeyFromValue(value, value, set); + result.set(newKey, value); + } + return result; +} +//#endregion +exports.keyBy = keyBy; diff --git a/node_modules/es-toolkit/dist/set/keyBy.mjs b/node_modules/es-toolkit/dist/set/keyBy.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0b742dbbdcac3550e4d9984fa5b82fa7ee9bd693 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/keyBy.mjs @@ -0,0 +1,38 @@ +//#region src/set/keyBy.ts +/** +* Maps each element of a Set based on a provided key-generating function. +* +* This function takes a Set and a function that generates a key from each value. +* It returns a new Map where the keys are generated by the key function and the values are +* the corresponding values from the original set. If multiple elements produce the same key, +* the last value encountered will be used. +* +* @template T - The type of elements in the Set. +* @template K - The type of keys to produce in the returned Map. +* @param set - The set of elements to be mapped. +* @param getKeyFromValue - A function that generates a key from a value. +* @returns A Map where the generated keys are mapped to each element's value. +* +* @example +* const set = new Set([ +* { type: 'fruit', name: 'apple' }, +* { type: 'fruit', name: 'banana' }, +* { type: 'vegetable', name: 'carrot' } +* ]); +* const result = keyBy(set, item => item.type); +* // result will be: +* // Map(2) { +* // 'fruit' => { type: 'fruit', name: 'banana' }, +* // 'vegetable' => { type: 'vegetable', name: 'carrot' } +* // } +*/ +function keyBy(set, getKeyFromValue) { + const result = /* @__PURE__ */ new Map(); + for (const value of set) { + const newKey = getKeyFromValue(value, value, set); + result.set(newKey, value); + } + return result; +} +//#endregion +export { keyBy }; diff --git a/node_modules/es-toolkit/dist/set/map.d.mts b/node_modules/es-toolkit/dist/set/map.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..e5e49cfa2cd93c54d0e9e525163addaca827dd8e --- /dev/null +++ b/node_modules/es-toolkit/dist/set/map.d.mts @@ -0,0 +1,22 @@ +//#region src/set/map.d.ts +/** + * Creates a new Set with elements transformed by the provided function. + * + * This function takes a Set and a function that generates a new value from each element. + * It returns a new Set where the elements are the result of applying the function to each element. + * + * @template T - The type of elements in the input Set. + * @template U - The type of elements in the output Set. + * @param set - The Set to transform. + * @param getNewValue - A function that generates a new value from an element. + * @returns A new Set with transformed elements. + * + * @example + * const set = new Set([1, 2, 3]); + * const result = map(set, (value) => value * 2); + * // result will be: + * // Set(3) { 2, 4, 6 } + */ +declare function map(set: Set, getNewValue: (value: T, value2: T, set: Set) => U): Set; +//#endregion +export { map }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/map.d.ts b/node_modules/es-toolkit/dist/set/map.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5e49cfa2cd93c54d0e9e525163addaca827dd8e --- /dev/null +++ b/node_modules/es-toolkit/dist/set/map.d.ts @@ -0,0 +1,22 @@ +//#region src/set/map.d.ts +/** + * Creates a new Set with elements transformed by the provided function. + * + * This function takes a Set and a function that generates a new value from each element. + * It returns a new Set where the elements are the result of applying the function to each element. + * + * @template T - The type of elements in the input Set. + * @template U - The type of elements in the output Set. + * @param set - The Set to transform. + * @param getNewValue - A function that generates a new value from an element. + * @returns A new Set with transformed elements. + * + * @example + * const set = new Set([1, 2, 3]); + * const result = map(set, (value) => value * 2); + * // result will be: + * // Set(3) { 2, 4, 6 } + */ +declare function map(set: Set, getNewValue: (value: T, value2: T, set: Set) => U): Set; +//#endregion +export { map }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/map.js b/node_modules/es-toolkit/dist/set/map.js new file mode 100644 index 0000000000000000000000000000000000000000..5c184b5de72df89f72c0d38e1a6f4d3a7f9d1744 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/map.js @@ -0,0 +1,29 @@ +//#region src/set/map.ts +/** +* Creates a new Set with elements transformed by the provided function. +* +* This function takes a Set and a function that generates a new value from each element. +* It returns a new Set where the elements are the result of applying the function to each element. +* +* @template T - The type of elements in the input Set. +* @template U - The type of elements in the output Set. +* @param set - The Set to transform. +* @param getNewValue - A function that generates a new value from an element. +* @returns A new Set with transformed elements. +* +* @example +* const set = new Set([1, 2, 3]); +* const result = map(set, (value) => value * 2); +* // result will be: +* // Set(3) { 2, 4, 6 } +*/ +function map(set, getNewValue) { + const result = /* @__PURE__ */ new Set(); + for (const value of set) { + const newValue = getNewValue(value, value, set); + result.add(newValue); + } + return result; +} +//#endregion +exports.map = map; diff --git a/node_modules/es-toolkit/dist/set/map.mjs b/node_modules/es-toolkit/dist/set/map.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c7f486aa3a554397a31c1494b95714ea87e8e4cb --- /dev/null +++ b/node_modules/es-toolkit/dist/set/map.mjs @@ -0,0 +1,29 @@ +//#region src/set/map.ts +/** +* Creates a new Set with elements transformed by the provided function. +* +* This function takes a Set and a function that generates a new value from each element. +* It returns a new Set where the elements are the result of applying the function to each element. +* +* @template T - The type of elements in the input Set. +* @template U - The type of elements in the output Set. +* @param set - The Set to transform. +* @param getNewValue - A function that generates a new value from an element. +* @returns A new Set with transformed elements. +* +* @example +* const set = new Set([1, 2, 3]); +* const result = map(set, (value) => value * 2); +* // result will be: +* // Set(3) { 2, 4, 6 } +*/ +function map(set, getNewValue) { + const result = /* @__PURE__ */ new Set(); + for (const value of set) { + const newValue = getNewValue(value, value, set); + result.add(newValue); + } + return result; +} +//#endregion +export { map }; diff --git a/node_modules/es-toolkit/dist/set/reduce.d.mts b/node_modules/es-toolkit/dist/set/reduce.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..67241e0f085aa0a275a6b86d802ae1990c578cf4 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/reduce.d.mts @@ -0,0 +1,29 @@ +//#region src/set/reduce.d.ts +/** + * Reduces a Set to a single value by iterating through its elements and applying a callback function. + * + * This function iterates through all elements of the Set and applies the callback function to each element, + * accumulating the result. If an initial value is provided, it is used as the starting accumulator value. + * If no initial value is provided and the Set is empty, a TypeError is thrown. + * + * @template T - The type of elements in the Set. + * @template A - The type of the accumulator. + * @param set - The Set to reduce. + * @param callback - A function that processes each element and updates the accumulator. + * @param [initialValue] - The initial value for the accumulator. If not provided, the first element in the Set is used. + * @returns The final accumulated value. + * @throws {TypeError} If the Set is empty and no initial value is provided. + * + * @example + * const set = new Set([1, 2, 3]); + * const result = reduce(set, (acc, value) => acc + value, 0); + * // result will be: 6 + * + * @example + * const set = new Set([10, 20]); + * const result = reduce(set, (acc, value) => acc + value); + * // result will be: 30 (starts with first value 10) + */ +declare function reduce(set: Set, callback: (accumulator: A, value: T, value2: T, set: Set) => A, initialValue?: A): A; +//#endregion +export { reduce }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/reduce.d.ts b/node_modules/es-toolkit/dist/set/reduce.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..67241e0f085aa0a275a6b86d802ae1990c578cf4 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/reduce.d.ts @@ -0,0 +1,29 @@ +//#region src/set/reduce.d.ts +/** + * Reduces a Set to a single value by iterating through its elements and applying a callback function. + * + * This function iterates through all elements of the Set and applies the callback function to each element, + * accumulating the result. If an initial value is provided, it is used as the starting accumulator value. + * If no initial value is provided and the Set is empty, a TypeError is thrown. + * + * @template T - The type of elements in the Set. + * @template A - The type of the accumulator. + * @param set - The Set to reduce. + * @param callback - A function that processes each element and updates the accumulator. + * @param [initialValue] - The initial value for the accumulator. If not provided, the first element in the Set is used. + * @returns The final accumulated value. + * @throws {TypeError} If the Set is empty and no initial value is provided. + * + * @example + * const set = new Set([1, 2, 3]); + * const result = reduce(set, (acc, value) => acc + value, 0); + * // result will be: 6 + * + * @example + * const set = new Set([10, 20]); + * const result = reduce(set, (acc, value) => acc + value); + * // result will be: 30 (starts with first value 10) + */ +declare function reduce(set: Set, callback: (accumulator: A, value: T, value2: T, set: Set) => A, initialValue?: A): A; +//#endregion +export { reduce }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/reduce.js b/node_modules/es-toolkit/dist/set/reduce.js new file mode 100644 index 0000000000000000000000000000000000000000..95fc5f7b3b8831990e7f848e2ca229137b9b6f75 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/reduce.js @@ -0,0 +1,35 @@ +//#region src/set/reduce.ts +/** +* Reduces a Set to a single value by iterating through its elements and applying a callback function. +* +* This function iterates through all elements of the Set and applies the callback function to each element, +* accumulating the result. If an initial value is provided, it is used as the starting accumulator value. +* If no initial value is provided and the Set is empty, a TypeError is thrown. +* +* @template T - The type of elements in the Set. +* @template A - The type of the accumulator. +* @param set - The Set to reduce. +* @param callback - A function that processes each element and updates the accumulator. +* @param [initialValue] - The initial value for the accumulator. If not provided, the first element in the Set is used. +* @returns The final accumulated value. +* @throws {TypeError} If the Set is empty and no initial value is provided. +* +* @example +* const set = new Set([1, 2, 3]); +* const result = reduce(set, (acc, value) => acc + value, 0); +* // result will be: 6 +* +* @example +* const set = new Set([10, 20]); +* const result = reduce(set, (acc, value) => acc + value); +* // result will be: 30 (starts with first value 10) +*/ +function reduce(set, callback, initialValue) { + if (initialValue == null && set.size === 0) throw new TypeError("Reduce of empty set with no initial value"); + let accumulator = initialValue; + for (const value of set) if (accumulator == null) accumulator = value; + else accumulator = callback(accumulator, value, value, set); + return accumulator; +} +//#endregion +exports.reduce = reduce; diff --git a/node_modules/es-toolkit/dist/set/reduce.mjs b/node_modules/es-toolkit/dist/set/reduce.mjs new file mode 100644 index 0000000000000000000000000000000000000000..611ad87be55f1e04e7d9b6ce1ff39ea48c5cce83 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/reduce.mjs @@ -0,0 +1,35 @@ +//#region src/set/reduce.ts +/** +* Reduces a Set to a single value by iterating through its elements and applying a callback function. +* +* This function iterates through all elements of the Set and applies the callback function to each element, +* accumulating the result. If an initial value is provided, it is used as the starting accumulator value. +* If no initial value is provided and the Set is empty, a TypeError is thrown. +* +* @template T - The type of elements in the Set. +* @template A - The type of the accumulator. +* @param set - The Set to reduce. +* @param callback - A function that processes each element and updates the accumulator. +* @param [initialValue] - The initial value for the accumulator. If not provided, the first element in the Set is used. +* @returns The final accumulated value. +* @throws {TypeError} If the Set is empty and no initial value is provided. +* +* @example +* const set = new Set([1, 2, 3]); +* const result = reduce(set, (acc, value) => acc + value, 0); +* // result will be: 6 +* +* @example +* const set = new Set([10, 20]); +* const result = reduce(set, (acc, value) => acc + value); +* // result will be: 30 (starts with first value 10) +*/ +function reduce(set, callback, initialValue) { + if (initialValue == null && set.size === 0) throw new TypeError("Reduce of empty set with no initial value"); + let accumulator = initialValue; + for (const value of set) if (accumulator == null) accumulator = value; + else accumulator = callback(accumulator, value, value, set); + return accumulator; +} +//#endregion +export { reduce }; diff --git a/node_modules/es-toolkit/dist/set/some.d.mts b/node_modules/es-toolkit/dist/set/some.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..f3f9bda9f2bcf1ffe709e0eb7611a77d302186b8 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/some.d.mts @@ -0,0 +1,24 @@ +//#region src/set/some.d.ts +/** + * Tests whether at least one element in a Set satisfies the provided predicate function. + * + * This function iterates through the elements of the Set and checks if the predicate function + * returns true for at least one element. It returns true if any element satisfies the predicate, + * and false otherwise. + * + * @template T - The type of elements in the Set. + * @param set - The Set to test. + * @param doesMatch - A predicate function that tests each element. + * @returns true if at least one element satisfies the predicate, false otherwise. + * + * @example + * const set = new Set([1, 2, 3]); + * const result = some(set, (value) => value > 2); + * // result will be: true + * + * const result2 = some(set, (value) => value > 5); + * // result2 will be: false + */ +declare function some(set: Set, doesMatch: (value: T, value2: T, set: Set) => boolean): boolean; +//#endregion +export { some }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/some.d.ts b/node_modules/es-toolkit/dist/set/some.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3f9bda9f2bcf1ffe709e0eb7611a77d302186b8 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/some.d.ts @@ -0,0 +1,24 @@ +//#region src/set/some.d.ts +/** + * Tests whether at least one element in a Set satisfies the provided predicate function. + * + * This function iterates through the elements of the Set and checks if the predicate function + * returns true for at least one element. It returns true if any element satisfies the predicate, + * and false otherwise. + * + * @template T - The type of elements in the Set. + * @param set - The Set to test. + * @param doesMatch - A predicate function that tests each element. + * @returns true if at least one element satisfies the predicate, false otherwise. + * + * @example + * const set = new Set([1, 2, 3]); + * const result = some(set, (value) => value > 2); + * // result will be: true + * + * const result2 = some(set, (value) => value > 5); + * // result2 will be: false + */ +declare function some(set: Set, doesMatch: (value: T, value2: T, set: Set) => boolean): boolean; +//#endregion +export { some }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/set/some.js b/node_modules/es-toolkit/dist/set/some.js new file mode 100644 index 0000000000000000000000000000000000000000..e3f0a467c0958422cca00ff3c9eef40e14f595bc --- /dev/null +++ b/node_modules/es-toolkit/dist/set/some.js @@ -0,0 +1,27 @@ +//#region src/set/some.ts +/** +* Tests whether at least one element in a Set satisfies the provided predicate function. +* +* This function iterates through the elements of the Set and checks if the predicate function +* returns true for at least one element. It returns true if any element satisfies the predicate, +* and false otherwise. +* +* @template T - The type of elements in the Set. +* @param set - The Set to test. +* @param doesMatch - A predicate function that tests each element. +* @returns true if at least one element satisfies the predicate, false otherwise. +* +* @example +* const set = new Set([1, 2, 3]); +* const result = some(set, (value) => value > 2); +* // result will be: true +* +* const result2 = some(set, (value) => value > 5); +* // result2 will be: false +*/ +function some(set, doesMatch) { + for (const value of set) if (doesMatch(value, value, set)) return true; + return false; +} +//#endregion +exports.some = some; diff --git a/node_modules/es-toolkit/dist/set/some.mjs b/node_modules/es-toolkit/dist/set/some.mjs new file mode 100644 index 0000000000000000000000000000000000000000..edf4a8f2f45c02e2b33d390d717daa368c5b74b6 --- /dev/null +++ b/node_modules/es-toolkit/dist/set/some.mjs @@ -0,0 +1,27 @@ +//#region src/set/some.ts +/** +* Tests whether at least one element in a Set satisfies the provided predicate function. +* +* This function iterates through the elements of the Set and checks if the predicate function +* returns true for at least one element. It returns true if any element satisfies the predicate, +* and false otherwise. +* +* @template T - The type of elements in the Set. +* @param set - The Set to test. +* @param doesMatch - A predicate function that tests each element. +* @returns true if at least one element satisfies the predicate, false otherwise. +* +* @example +* const set = new Set([1, 2, 3]); +* const result = some(set, (value) => value > 2); +* // result will be: true +* +* const result2 = some(set, (value) => value > 5); +* // result2 will be: false +*/ +function some(set, doesMatch) { + for (const value of set) if (doesMatch(value, value, set)) return true; + return false; +} +//#endregion +export { some }; diff --git a/node_modules/es-toolkit/dist/string/camelCase.d.mts b/node_modules/es-toolkit/dist/string/camelCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c88cdef9e0c8c683bc70e0875f3c2e8bac7cfd23 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/camelCase.d.mts @@ -0,0 +1,20 @@ +//#region src/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' + * const convertedStr5 = camelCase('Keep unicode 😅') // returns 'keepUnicode😅' + */ +declare function camelCase(str: string): string; +//#endregion +export { camelCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/camelCase.d.ts b/node_modules/es-toolkit/dist/string/camelCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c88cdef9e0c8c683bc70e0875f3c2e8bac7cfd23 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/camelCase.d.ts @@ -0,0 +1,20 @@ +//#region src/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' + * const convertedStr5 = camelCase('Keep unicode 😅') // returns 'keepUnicode😅' + */ +declare function camelCase(str: string): string; +//#endregion +export { camelCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/camelCase.js b/node_modules/es-toolkit/dist/string/camelCase.js new file mode 100644 index 0000000000000000000000000000000000000000..24a151ccfdf1d3506a1f7bc4505f1ea26918cd10 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/camelCase.js @@ -0,0 +1,27 @@ +const require_capitalize = require("./capitalize.js"); +const require_words = require("./words.js"); +//#region src/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' +* const convertedStr5 = camelCase('Keep unicode 😅') // returns 'keepUnicode😅' +*/ +function camelCase(str) { + const words$1 = require_words.words(str); + if (words$1.length === 0) return ""; + const [first, ...rest] = words$1; + return `${first.toLowerCase()}${rest.map((word) => require_capitalize.capitalize(word)).join("")}`; +} +//#endregion +exports.camelCase = camelCase; diff --git a/node_modules/es-toolkit/dist/string/camelCase.mjs b/node_modules/es-toolkit/dist/string/camelCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6fab388613f4325a6ddcee36adb6e8baab53cc7e --- /dev/null +++ b/node_modules/es-toolkit/dist/string/camelCase.mjs @@ -0,0 +1,27 @@ +import { capitalize } from "./capitalize.mjs"; +import { words } from "./words.mjs"; +//#region src/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' +* const convertedStr5 = camelCase('Keep unicode 😅') // returns 'keepUnicode😅' +*/ +function camelCase(str) { + const words$1 = words(str); + if (words$1.length === 0) return ""; + const [first, ...rest] = words$1; + return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join("")}`; +} +//#endregion +export { camelCase }; diff --git a/node_modules/es-toolkit/dist/string/capitalize.d.mts b/node_modules/es-toolkit/dist/string/capitalize.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8200e2c961616c6d723e6e367550baddebd440b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/capitalize.d.mts @@ -0,0 +1,16 @@ +//#region src/string/capitalize.d.ts +/** + * Converts the first character of string to upper case and the remaining to lower case. + * + * @template T - Literal type of the string. + * @param str - The string to be converted to uppercase. + * @returns The capitalized string. + * + * @example + * const result = capitalize('fred') // returns 'Fred' + * const result2 = capitalize('FRED') // returns 'Fred' + */ +declare function capitalize(str: T): Capitalize; +type Capitalize = T extends `${infer F}${infer R}` ? `${Uppercase}${Lowercase}` : T; +//#endregion +export { capitalize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/capitalize.d.ts b/node_modules/es-toolkit/dist/string/capitalize.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8200e2c961616c6d723e6e367550baddebd440b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/capitalize.d.ts @@ -0,0 +1,16 @@ +//#region src/string/capitalize.d.ts +/** + * Converts the first character of string to upper case and the remaining to lower case. + * + * @template T - Literal type of the string. + * @param str - The string to be converted to uppercase. + * @returns The capitalized string. + * + * @example + * const result = capitalize('fred') // returns 'Fred' + * const result2 = capitalize('FRED') // returns 'Fred' + */ +declare function capitalize(str: T): Capitalize; +type Capitalize = T extends `${infer F}${infer R}` ? `${Uppercase}${Lowercase}` : T; +//#endregion +export { capitalize }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/capitalize.js b/node_modules/es-toolkit/dist/string/capitalize.js new file mode 100644 index 0000000000000000000000000000000000000000..ba6381d0e59ed9d885260c2c410188d6057458fe --- /dev/null +++ b/node_modules/es-toolkit/dist/string/capitalize.js @@ -0,0 +1,17 @@ +//#region src/string/capitalize.ts +/** +* Converts the first character of string to upper case and the remaining to lower case. +* +* @template T - Literal type of the string. +* @param str - The string to be converted to uppercase. +* @returns The capitalized string. +* +* @example +* const result = capitalize('fred') // returns 'Fred' +* const result2 = capitalize('FRED') // returns 'Fred' +*/ +function capitalize(str) { + return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); +} +//#endregion +exports.capitalize = capitalize; diff --git a/node_modules/es-toolkit/dist/string/capitalize.mjs b/node_modules/es-toolkit/dist/string/capitalize.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c61e70093fbd584b765501738d1e576f47edd05e --- /dev/null +++ b/node_modules/es-toolkit/dist/string/capitalize.mjs @@ -0,0 +1,17 @@ +//#region src/string/capitalize.ts +/** +* Converts the first character of string to upper case and the remaining to lower case. +* +* @template T - Literal type of the string. +* @param str - The string to be converted to uppercase. +* @returns The capitalized string. +* +* @example +* const result = capitalize('fred') // returns 'Fred' +* const result2 = capitalize('FRED') // returns 'Fred' +*/ +function capitalize(str) { + return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); +} +//#endregion +export { capitalize }; diff --git a/node_modules/es-toolkit/dist/string/constantCase.d.mts b/node_modules/es-toolkit/dist/string/constantCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1e669ef73ec851df22c66e298393d24e1490542d --- /dev/null +++ b/node_modules/es-toolkit/dist/string/constantCase.d.mts @@ -0,0 +1,18 @@ +//#region src/string/constantCase.d.ts +/** + * Converts a string to constant case. + * + * Constant case is a naming convention where each word is written in uppercase letters and separated by an underscore (`_`). For example, `CONSTANT_CASE`. + * + * @param str - The string that is to be changed to constant case. + * @returns The converted string to constant case. + * + * @example + * const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE' + * const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE' + * const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT' + * const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST' + */ +declare function constantCase(str: string): string; +//#endregion +export { constantCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/constantCase.d.ts b/node_modules/es-toolkit/dist/string/constantCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e669ef73ec851df22c66e298393d24e1490542d --- /dev/null +++ b/node_modules/es-toolkit/dist/string/constantCase.d.ts @@ -0,0 +1,18 @@ +//#region src/string/constantCase.d.ts +/** + * Converts a string to constant case. + * + * Constant case is a naming convention where each word is written in uppercase letters and separated by an underscore (`_`). For example, `CONSTANT_CASE`. + * + * @param str - The string that is to be changed to constant case. + * @returns The converted string to constant case. + * + * @example + * const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE' + * const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE' + * const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT' + * const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST' + */ +declare function constantCase(str: string): string; +//#endregion +export { constantCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/constantCase.js b/node_modules/es-toolkit/dist/string/constantCase.js new file mode 100644 index 0000000000000000000000000000000000000000..12f85bd77c17a813d9ffa9d9a9387f614aa64e6e --- /dev/null +++ b/node_modules/es-toolkit/dist/string/constantCase.js @@ -0,0 +1,21 @@ +const require_words = require("./words.js"); +//#region src/string/constantCase.ts +/** +* Converts a string to constant case. +* +* Constant case is a naming convention where each word is written in uppercase letters and separated by an underscore (`_`). For example, `CONSTANT_CASE`. +* +* @param str - The string that is to be changed to constant case. +* @returns The converted string to constant case. +* +* @example +* const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE' +* const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE' +* const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT' +* const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST' +*/ +function constantCase(str) { + return require_words.words(str).map((word) => word.toUpperCase()).join("_"); +} +//#endregion +exports.constantCase = constantCase; diff --git a/node_modules/es-toolkit/dist/string/constantCase.mjs b/node_modules/es-toolkit/dist/string/constantCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..3d0ad19e82ca7e345f9e2a777ded0447c11af940 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/constantCase.mjs @@ -0,0 +1,21 @@ +import { words } from "./words.mjs"; +//#region src/string/constantCase.ts +/** +* Converts a string to constant case. +* +* Constant case is a naming convention where each word is written in uppercase letters and separated by an underscore (`_`). For example, `CONSTANT_CASE`. +* +* @param str - The string that is to be changed to constant case. +* @returns The converted string to constant case. +* +* @example +* const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE' +* const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE' +* const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT' +* const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST' +*/ +function constantCase(str) { + return words(str).map((word) => word.toUpperCase()).join("_"); +} +//#endregion +export { constantCase }; diff --git a/node_modules/es-toolkit/dist/string/deburr.d.mts b/node_modules/es-toolkit/dist/string/deburr.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8b03e8409851cbbc31255c7999b87f679bc46ceb --- /dev/null +++ b/node_modules/es-toolkit/dist/string/deburr.d.mts @@ -0,0 +1,23 @@ +//#region src/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/string/deburr.d.ts b/node_modules/es-toolkit/dist/string/deburr.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b03e8409851cbbc31255c7999b87f679bc46ceb --- /dev/null +++ b/node_modules/es-toolkit/dist/string/deburr.d.ts @@ -0,0 +1,23 @@ +//#region src/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/string/deburr.js b/node_modules/es-toolkit/dist/string/deburr.js new file mode 100644 index 0000000000000000000000000000000000000000..b8e5181ef223a6060e20f746fa639e9fce6c63c8 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/deburr.js @@ -0,0 +1,63 @@ +//#region src/string/deburr.ts +const deburrMap = new Map([ + ["Æ", "Ae"], + ["Ð", "D"], + ["Ø", "O"], + ["Þ", "Th"], + ["ß", "ss"], + ["æ", "ae"], + ["ð", "d"], + ["ø", "o"], + ["þ", "th"], + ["Đ", "D"], + ["đ", "d"], + ["Ħ", "H"], + ["ħ", "h"], + ["ı", "i"], + ["IJ", "IJ"], + ["ij", "ij"], + ["ĸ", "k"], + ["Ŀ", "L"], + ["ŀ", "l"], + ["Ł", "L"], + ["ł", "l"], + ["ʼn", "'n"], + ["Ŋ", "N"], + ["ŋ", "n"], + ["Œ", "Oe"], + ["œ", "oe"], + ["Ŧ", "T"], + ["ŧ", "t"], + ["ſ", "s"] +]); +/** +* 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) { + str = str.normalize("NFD"); + let result = ""; + for (let i = 0; i < str.length; i++) { + const char = str[i]; + if (char >= "̀" && char <= "ͯ" || char >= "⃐" && char <= "⃿" || char >= "︠" && char <= "︯") continue; + result += deburrMap.get(char) ?? char; + } + return result; +} +//#endregion +exports.deburr = deburr; diff --git a/node_modules/es-toolkit/dist/string/deburr.mjs b/node_modules/es-toolkit/dist/string/deburr.mjs new file mode 100644 index 0000000000000000000000000000000000000000..5f3f366cddd58e6294fededd89e14fabcd79a524 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/deburr.mjs @@ -0,0 +1,63 @@ +//#region src/string/deburr.ts +const deburrMap = new Map([ + ["Æ", "Ae"], + ["Ð", "D"], + ["Ø", "O"], + ["Þ", "Th"], + ["ß", "ss"], + ["æ", "ae"], + ["ð", "d"], + ["ø", "o"], + ["þ", "th"], + ["Đ", "D"], + ["đ", "d"], + ["Ħ", "H"], + ["ħ", "h"], + ["ı", "i"], + ["IJ", "IJ"], + ["ij", "ij"], + ["ĸ", "k"], + ["Ŀ", "L"], + ["ŀ", "l"], + ["Ł", "L"], + ["ł", "l"], + ["ʼn", "'n"], + ["Ŋ", "N"], + ["ŋ", "n"], + ["Œ", "Oe"], + ["œ", "oe"], + ["Ŧ", "T"], + ["ŧ", "t"], + ["ſ", "s"] +]); +/** +* 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) { + str = str.normalize("NFD"); + let result = ""; + for (let i = 0; i < str.length; i++) { + const char = str[i]; + if (char >= "̀" && char <= "ͯ" || char >= "⃐" && char <= "⃿" || char >= "︠" && char <= "︯") continue; + result += deburrMap.get(char) ?? char; + } + return result; +} +//#endregion +export { deburr }; diff --git a/node_modules/es-toolkit/dist/string/escape.d.mts b/node_modules/es-toolkit/dist/string/escape.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d56a97462bce68ef404fc088f159df752f133ee5 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/escape.d.mts @@ -0,0 +1,17 @@ +//#region src/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(str: string): string; +//#endregion +export { escape }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/escape.d.ts b/node_modules/es-toolkit/dist/string/escape.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d56a97462bce68ef404fc088f159df752f133ee5 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/escape.d.ts @@ -0,0 +1,17 @@ +//#region src/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(str: string): string; +//#endregion +export { escape }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/escape.js b/node_modules/es-toolkit/dist/string/escape.js new file mode 100644 index 0000000000000000000000000000000000000000..de6a1b96cedc879303521700af884402b6cb4192 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/escape.js @@ -0,0 +1,26 @@ +//#region src/string/escape.ts +const htmlEscapes = { + "&": "&", + "<": "<", + ">": ">", + "\"": """, + "'": "'" +}; +/** +* 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(str) { + return str.replace(/[&<>"']/g, (match) => htmlEscapes[match]); +} +//#endregion +exports.escape = escape; diff --git a/node_modules/es-toolkit/dist/string/escape.mjs b/node_modules/es-toolkit/dist/string/escape.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7c3f4caffd3ff27eed8693733cc7c7952464a59a --- /dev/null +++ b/node_modules/es-toolkit/dist/string/escape.mjs @@ -0,0 +1,26 @@ +//#region src/string/escape.ts +const htmlEscapes = { + "&": "&", + "<": "<", + ">": ">", + "\"": """, + "'": "'" +}; +/** +* 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(str) { + return str.replace(/[&<>"']/g, (match) => htmlEscapes[match]); +} +//#endregion +export { escape }; diff --git a/node_modules/es-toolkit/dist/string/escapeRegExp.d.mts b/node_modules/es-toolkit/dist/string/escapeRegExp.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d8f4a0ef7e629ed8618d6f9c58bbdb9b8b64db0a --- /dev/null +++ b/node_modules/es-toolkit/dist/string/escapeRegExp.d.mts @@ -0,0 +1,15 @@ +//#region src/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/string/escapeRegExp.d.ts b/node_modules/es-toolkit/dist/string/escapeRegExp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8f4a0ef7e629ed8618d6f9c58bbdb9b8b64db0a --- /dev/null +++ b/node_modules/es-toolkit/dist/string/escapeRegExp.d.ts @@ -0,0 +1,15 @@ +//#region src/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/string/escapeRegExp.js b/node_modules/es-toolkit/dist/string/escapeRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..803ca36834e46ee7e34869259058981fe23b7628 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/escapeRegExp.js @@ -0,0 +1,17 @@ +//#region src/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 str.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&"); +} +//#endregion +exports.escapeRegExp = escapeRegExp; diff --git a/node_modules/es-toolkit/dist/string/escapeRegExp.mjs b/node_modules/es-toolkit/dist/string/escapeRegExp.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a28668883002c034bfa6a822ff60218cfcb443ed --- /dev/null +++ b/node_modules/es-toolkit/dist/string/escapeRegExp.mjs @@ -0,0 +1,17 @@ +//#region src/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 str.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&"); +} +//#endregion +export { escapeRegExp }; diff --git a/node_modules/es-toolkit/dist/string/index.d.mts b/node_modules/es-toolkit/dist/string/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..6f778d125020f7faab5f261c61f9bdda6da8bf63 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/index.d.mts @@ -0,0 +1,22 @@ +import { camelCase } from "./camelCase.mjs"; +import { capitalize } from "./capitalize.mjs"; +import { constantCase } from "./constantCase.mjs"; +import { deburr } from "./deburr.mjs"; +import { escape } from "./escape.mjs"; +import { escapeRegExp } from "./escapeRegExp.mjs"; +import { kebabCase } from "./kebabCase.mjs"; +import { lowerCase } from "./lowerCase.mjs"; +import { lowerFirst } from "./lowerFirst.mjs"; +import { pad } from "./pad.mjs"; +import { pascalCase } from "./pascalCase.mjs"; +import { reverseString } from "./reverseString.mjs"; +import { snakeCase } from "./snakeCase.mjs"; +import { startCase } from "./startCase.mjs"; +import { trim } from "./trim.mjs"; +import { trimEnd } from "./trimEnd.mjs"; +import { trimStart } from "./trimStart.mjs"; +import { unescape } from "./unescape.mjs"; +import { upperCase } from "./upperCase.mjs"; +import { upperFirst } from "./upperFirst.mjs"; +import { words } from "./words.mjs"; +export { camelCase, capitalize, constantCase, deburr, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/index.d.ts b/node_modules/es-toolkit/dist/string/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ba883b4da09f907fda6bd8ea31b57fc19bd3688 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/index.d.ts @@ -0,0 +1,22 @@ +import { camelCase } from "./camelCase.js"; +import { capitalize } from "./capitalize.js"; +import { constantCase } from "./constantCase.js"; +import { deburr } from "./deburr.js"; +import { escape } from "./escape.js"; +import { escapeRegExp } from "./escapeRegExp.js"; +import { kebabCase } from "./kebabCase.js"; +import { lowerCase } from "./lowerCase.js"; +import { lowerFirst } from "./lowerFirst.js"; +import { pad } from "./pad.js"; +import { pascalCase } from "./pascalCase.js"; +import { reverseString } from "./reverseString.js"; +import { snakeCase } from "./snakeCase.js"; +import { startCase } from "./startCase.js"; +import { trim } from "./trim.js"; +import { trimEnd } from "./trimEnd.js"; +import { trimStart } from "./trimStart.js"; +import { unescape } from "./unescape.js"; +import { upperCase } from "./upperCase.js"; +import { upperFirst } from "./upperFirst.js"; +import { words } from "./words.js"; +export { camelCase, capitalize, constantCase, deburr, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/index.js b/node_modules/es-toolkit/dist/string/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1a01215cd675deb4fdb96f266169efde31bd5b19 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/index.js @@ -0,0 +1,43 @@ +Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); +const require_capitalize = require("./capitalize.js"); +const require_words = require("./words.js"); +const require_camelCase = require("./camelCase.js"); +const require_snakeCase = require("./snakeCase.js"); +const require_constantCase = require("./constantCase.js"); +const require_deburr = require("./deburr.js"); +const require_escape = require("./escape.js"); +const require_escapeRegExp = require("./escapeRegExp.js"); +const require_kebabCase = require("./kebabCase.js"); +const require_lowerCase = require("./lowerCase.js"); +const require_lowerFirst = require("./lowerFirst.js"); +const require_pad = require("./pad.js"); +const require_pascalCase = require("./pascalCase.js"); +const require_reverseString = require("./reverseString.js"); +const require_startCase = require("./startCase.js"); +const require_trimEnd = require("./trimEnd.js"); +const require_trimStart = require("./trimStart.js"); +const require_trim = require("./trim.js"); +const require_unescape = require("./unescape.js"); +const require_upperCase = require("./upperCase.js"); +const require_upperFirst = require("./upperFirst.js"); +exports.camelCase = require_camelCase.camelCase; +exports.capitalize = require_capitalize.capitalize; +exports.constantCase = require_constantCase.constantCase; +exports.deburr = require_deburr.deburr; +exports.escape = require_escape.escape; +exports.escapeRegExp = require_escapeRegExp.escapeRegExp; +exports.kebabCase = require_kebabCase.kebabCase; +exports.lowerCase = require_lowerCase.lowerCase; +exports.lowerFirst = require_lowerFirst.lowerFirst; +exports.pad = require_pad.pad; +exports.pascalCase = require_pascalCase.pascalCase; +exports.reverseString = require_reverseString.reverseString; +exports.snakeCase = require_snakeCase.snakeCase; +exports.startCase = require_startCase.startCase; +exports.trim = require_trim.trim; +exports.trimEnd = require_trimEnd.trimEnd; +exports.trimStart = require_trimStart.trimStart; +exports.unescape = require_unescape.unescape; +exports.upperCase = require_upperCase.upperCase; +exports.upperFirst = require_upperFirst.upperFirst; +exports.words = require_words.words; diff --git a/node_modules/es-toolkit/dist/string/index.mjs b/node_modules/es-toolkit/dist/string/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..83bb4a4807475176a843f95f15768d603b80d58c --- /dev/null +++ b/node_modules/es-toolkit/dist/string/index.mjs @@ -0,0 +1,22 @@ +import { capitalize } from "./capitalize.mjs"; +import { words } from "./words.mjs"; +import { camelCase } from "./camelCase.mjs"; +import { snakeCase } from "./snakeCase.mjs"; +import { constantCase } from "./constantCase.mjs"; +import { deburr } from "./deburr.mjs"; +import { escape } from "./escape.mjs"; +import { escapeRegExp } from "./escapeRegExp.mjs"; +import { kebabCase } from "./kebabCase.mjs"; +import { lowerCase } from "./lowerCase.mjs"; +import { lowerFirst } from "./lowerFirst.mjs"; +import { pad } from "./pad.mjs"; +import { pascalCase } from "./pascalCase.mjs"; +import { reverseString } from "./reverseString.mjs"; +import { startCase } from "./startCase.mjs"; +import { trimEnd } from "./trimEnd.mjs"; +import { trimStart } from "./trimStart.mjs"; +import { trim } from "./trim.mjs"; +import { unescape } from "./unescape.mjs"; +import { upperCase } from "./upperCase.mjs"; +import { upperFirst } from "./upperFirst.mjs"; +export { camelCase, capitalize, constantCase, deburr, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words }; diff --git a/node_modules/es-toolkit/dist/string/kebabCase.d.mts b/node_modules/es-toolkit/dist/string/kebabCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..385909e301f76a4c3b5eb6fd03632692cfa1a203 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/kebabCase.d.mts @@ -0,0 +1,18 @@ +//#region src/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/string/kebabCase.d.ts b/node_modules/es-toolkit/dist/string/kebabCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..385909e301f76a4c3b5eb6fd03632692cfa1a203 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/kebabCase.d.ts @@ -0,0 +1,18 @@ +//#region src/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/string/kebabCase.js b/node_modules/es-toolkit/dist/string/kebabCase.js new file mode 100644 index 0000000000000000000000000000000000000000..2b6b268adb6f4c6ba443f74e68196bed309c0fe7 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/kebabCase.js @@ -0,0 +1,21 @@ +const require_words = require("./words.js"); +//#region src/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(str).map((word) => word.toLowerCase()).join("-"); +} +//#endregion +exports.kebabCase = kebabCase; diff --git a/node_modules/es-toolkit/dist/string/kebabCase.mjs b/node_modules/es-toolkit/dist/string/kebabCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b6da14135bf895c1b379b91dba84757b2ff53de6 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/kebabCase.mjs @@ -0,0 +1,21 @@ +import { words } from "./words.mjs"; +//#region src/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(str).map((word) => word.toLowerCase()).join("-"); +} +//#endregion +export { kebabCase }; diff --git a/node_modules/es-toolkit/dist/string/lowerCase.d.mts b/node_modules/es-toolkit/dist/string/lowerCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..83877259cca78d9c199c530f2b213b4e21c82f1a --- /dev/null +++ b/node_modules/es-toolkit/dist/string/lowerCase.d.mts @@ -0,0 +1,18 @@ +//#region src/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/string/lowerCase.d.ts b/node_modules/es-toolkit/dist/string/lowerCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..83877259cca78d9c199c530f2b213b4e21c82f1a --- /dev/null +++ b/node_modules/es-toolkit/dist/string/lowerCase.d.ts @@ -0,0 +1,18 @@ +//#region src/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/string/lowerCase.js b/node_modules/es-toolkit/dist/string/lowerCase.js new file mode 100644 index 0000000000000000000000000000000000000000..698258210c99a922fd2d694fb63a994c1ef23480 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/lowerCase.js @@ -0,0 +1,21 @@ +const require_words = require("./words.js"); +//#region src/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(str).map((word) => word.toLowerCase()).join(" "); +} +//#endregion +exports.lowerCase = lowerCase; diff --git a/node_modules/es-toolkit/dist/string/lowerCase.mjs b/node_modules/es-toolkit/dist/string/lowerCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e6e54204f93f06ce66dd9394607951066b79c8e2 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/lowerCase.mjs @@ -0,0 +1,21 @@ +import { words } from "./words.mjs"; +//#region src/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(str).map((word) => word.toLowerCase()).join(" "); +} +//#endregion +export { lowerCase }; diff --git a/node_modules/es-toolkit/dist/string/lowerFirst.d.mts b/node_modules/es-toolkit/dist/string/lowerFirst.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fd044ce6d616427b3b826dd9229772f117a68b49 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/lowerFirst.d.mts @@ -0,0 +1,15 @@ +//#region src/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: string): string; +//#endregion +export { lowerFirst }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/lowerFirst.d.ts b/node_modules/es-toolkit/dist/string/lowerFirst.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd044ce6d616427b3b826dd9229772f117a68b49 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/lowerFirst.d.ts @@ -0,0 +1,15 @@ +//#region src/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: string): string; +//#endregion +export { lowerFirst }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/lowerFirst.js b/node_modules/es-toolkit/dist/string/lowerFirst.js new file mode 100644 index 0000000000000000000000000000000000000000..f106f58df6f1a9a2124aa4d32ffd45f2131e4598 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/lowerFirst.js @@ -0,0 +1,17 @@ +//#region src/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 str.substring(0, 1).toLowerCase() + str.substring(1); +} +//#endregion +exports.lowerFirst = lowerFirst; diff --git a/node_modules/es-toolkit/dist/string/lowerFirst.mjs b/node_modules/es-toolkit/dist/string/lowerFirst.mjs new file mode 100644 index 0000000000000000000000000000000000000000..857f446b411363c3d35021e49892fb0c138b2cc1 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/lowerFirst.mjs @@ -0,0 +1,17 @@ +//#region src/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 str.substring(0, 1).toLowerCase() + str.substring(1); +} +//#endregion +export { lowerFirst }; diff --git a/node_modules/es-toolkit/dist/string/pad.d.mts b/node_modules/es-toolkit/dist/string/pad.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8301810f6f61e382713ad5b6d8b45943d33f01e9 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/pad.d.mts @@ -0,0 +1,20 @@ +//#region src/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/string/pad.d.ts b/node_modules/es-toolkit/dist/string/pad.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8301810f6f61e382713ad5b6d8b45943d33f01e9 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/pad.d.ts @@ -0,0 +1,20 @@ +//#region src/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/string/pad.js b/node_modules/es-toolkit/dist/string/pad.js new file mode 100644 index 0000000000000000000000000000000000000000..fa11ec369d4f3936b115b8a94c4439c7b9f4fa17 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/pad.js @@ -0,0 +1,22 @@ +//#region src/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, chars = " ") { + return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars); +} +//#endregion +exports.pad = pad; diff --git a/node_modules/es-toolkit/dist/string/pad.mjs b/node_modules/es-toolkit/dist/string/pad.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2140337f1986b8eda588e96358511fef41450122 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/pad.mjs @@ -0,0 +1,22 @@ +//#region src/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, chars = " ") { + return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars); +} +//#endregion +export { pad }; diff --git a/node_modules/es-toolkit/dist/string/pascalCase.d.mts b/node_modules/es-toolkit/dist/string/pascalCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d75cd6e1c98c8fa371d5ed9a9aa99bf968c0c618 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/pascalCase.d.mts @@ -0,0 +1,18 @@ +//#region src/string/pascalCase.d.ts +/** + * Converts a string to Pascal case. + * + * Pascal case is the naming convention in which each word is capitalized and concatenated without any separator characters. + * + * @param str - The string that is to be changed to pascal case. + * @returns The converted string to Pascal case. + * + * @example + * const convertedStr1 = pascalCase('pascalCase') // returns 'PascalCase' + * const convertedStr2 = pascalCase('some whitespace') // returns 'SomeWhitespace' + * const convertedStr3 = pascalCase('hyphen-text') // returns 'HyphenText' + * const convertedStr4 = pascalCase('HTTPRequest') // returns 'HttpRequest' + */ +declare function pascalCase(str: string): string; +//#endregion +export { pascalCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/pascalCase.d.ts b/node_modules/es-toolkit/dist/string/pascalCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d75cd6e1c98c8fa371d5ed9a9aa99bf968c0c618 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/pascalCase.d.ts @@ -0,0 +1,18 @@ +//#region src/string/pascalCase.d.ts +/** + * Converts a string to Pascal case. + * + * Pascal case is the naming convention in which each word is capitalized and concatenated without any separator characters. + * + * @param str - The string that is to be changed to pascal case. + * @returns The converted string to Pascal case. + * + * @example + * const convertedStr1 = pascalCase('pascalCase') // returns 'PascalCase' + * const convertedStr2 = pascalCase('some whitespace') // returns 'SomeWhitespace' + * const convertedStr3 = pascalCase('hyphen-text') // returns 'HyphenText' + * const convertedStr4 = pascalCase('HTTPRequest') // returns 'HttpRequest' + */ +declare function pascalCase(str: string): string; +//#endregion +export { pascalCase }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/pascalCase.js b/node_modules/es-toolkit/dist/string/pascalCase.js new file mode 100644 index 0000000000000000000000000000000000000000..89fe0584d493039adf36121fb8b4f0087bb7decd --- /dev/null +++ b/node_modules/es-toolkit/dist/string/pascalCase.js @@ -0,0 +1,22 @@ +const require_capitalize = require("./capitalize.js"); +const require_words = require("./words.js"); +//#region src/string/pascalCase.ts +/** +* Converts a string to Pascal case. +* +* Pascal case is the naming convention in which each word is capitalized and concatenated without any separator characters. +* +* @param str - The string that is to be changed to pascal case. +* @returns The converted string to Pascal case. +* +* @example +* const convertedStr1 = pascalCase('pascalCase') // returns 'PascalCase' +* const convertedStr2 = pascalCase('some whitespace') // returns 'SomeWhitespace' +* const convertedStr3 = pascalCase('hyphen-text') // returns 'HyphenText' +* const convertedStr4 = pascalCase('HTTPRequest') // returns 'HttpRequest' +*/ +function pascalCase(str) { + return require_words.words(str).map((word) => require_capitalize.capitalize(word)).join(""); +} +//#endregion +exports.pascalCase = pascalCase; diff --git a/node_modules/es-toolkit/dist/string/pascalCase.mjs b/node_modules/es-toolkit/dist/string/pascalCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4cbce2f63b0e35b9ef55ec917a9e07700c87f2e9 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/pascalCase.mjs @@ -0,0 +1,22 @@ +import { capitalize } from "./capitalize.mjs"; +import { words } from "./words.mjs"; +//#region src/string/pascalCase.ts +/** +* Converts a string to Pascal case. +* +* Pascal case is the naming convention in which each word is capitalized and concatenated without any separator characters. +* +* @param str - The string that is to be changed to pascal case. +* @returns The converted string to Pascal case. +* +* @example +* const convertedStr1 = pascalCase('pascalCase') // returns 'PascalCase' +* const convertedStr2 = pascalCase('some whitespace') // returns 'SomeWhitespace' +* const convertedStr3 = pascalCase('hyphen-text') // returns 'HyphenText' +* const convertedStr4 = pascalCase('HTTPRequest') // returns 'HttpRequest' +*/ +function pascalCase(str) { + return words(str).map((word) => capitalize(word)).join(""); +} +//#endregion +export { pascalCase }; diff --git a/node_modules/es-toolkit/dist/string/reverseString.d.mts b/node_modules/es-toolkit/dist/string/reverseString.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..0e8abcd296055f72d42a786f2d53c6a43ab3a0d1 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/reverseString.d.mts @@ -0,0 +1,17 @@ +//#region src/string/reverseString.d.ts +/** + * Reverses a given string. + * + * This function takes a string as input and returns a new string that is the reverse of the input. + * + * @param value - The string that is to be reversed. + * @returns The reversed string. + * + * @example + * const reversedStr1 = reverseString('hello') // returns 'olleh' + * const reversedStr2 = reverseString('PascalCase') // returns 'esaClacsaP' + * const reversedStr3 = reverseString('foo 😄 bar') // returns 'rab 😄 oof' + */ +declare function reverseString(value: string): string; +//#endregion +export { reverseString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/reverseString.d.ts b/node_modules/es-toolkit/dist/string/reverseString.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e8abcd296055f72d42a786f2d53c6a43ab3a0d1 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/reverseString.d.ts @@ -0,0 +1,17 @@ +//#region src/string/reverseString.d.ts +/** + * Reverses a given string. + * + * This function takes a string as input and returns a new string that is the reverse of the input. + * + * @param value - The string that is to be reversed. + * @returns The reversed string. + * + * @example + * const reversedStr1 = reverseString('hello') // returns 'olleh' + * const reversedStr2 = reverseString('PascalCase') // returns 'esaClacsaP' + * const reversedStr3 = reverseString('foo 😄 bar') // returns 'rab 😄 oof' + */ +declare function reverseString(value: string): string; +//#endregion +export { reverseString }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/reverseString.js b/node_modules/es-toolkit/dist/string/reverseString.js new file mode 100644 index 0000000000000000000000000000000000000000..cc4f084f9d92e060a944d05bf3fd8ebabc1ff5c0 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/reverseString.js @@ -0,0 +1,19 @@ +//#region src/string/reverseString.ts +/** +* Reverses a given string. +* +* This function takes a string as input and returns a new string that is the reverse of the input. +* +* @param value - The string that is to be reversed. +* @returns The reversed string. +* +* @example +* const reversedStr1 = reverseString('hello') // returns 'olleh' +* const reversedStr2 = reverseString('PascalCase') // returns 'esaClacsaP' +* const reversedStr3 = reverseString('foo 😄 bar') // returns 'rab 😄 oof' +*/ +function reverseString(value) { + return [...value].reverse().join(""); +} +//#endregion +exports.reverseString = reverseString; diff --git a/node_modules/es-toolkit/dist/string/reverseString.mjs b/node_modules/es-toolkit/dist/string/reverseString.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9d38e11a84cd84aab36b3e2236d0bb7b08b7e8cc --- /dev/null +++ b/node_modules/es-toolkit/dist/string/reverseString.mjs @@ -0,0 +1,19 @@ +//#region src/string/reverseString.ts +/** +* Reverses a given string. +* +* This function takes a string as input and returns a new string that is the reverse of the input. +* +* @param value - The string that is to be reversed. +* @returns The reversed string. +* +* @example +* const reversedStr1 = reverseString('hello') // returns 'olleh' +* const reversedStr2 = reverseString('PascalCase') // returns 'esaClacsaP' +* const reversedStr3 = reverseString('foo 😄 bar') // returns 'rab 😄 oof' +*/ +function reverseString(value) { + return [...value].reverse().join(""); +} +//#endregion +export { reverseString }; diff --git a/node_modules/es-toolkit/dist/string/snakeCase.d.mts b/node_modules/es-toolkit/dist/string/snakeCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..1892c1d66611bac8b25742c3f1d20f62af9ab9e6 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/snakeCase.d.mts @@ -0,0 +1,18 @@ +//#region src/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/string/snakeCase.d.ts b/node_modules/es-toolkit/dist/string/snakeCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1892c1d66611bac8b25742c3f1d20f62af9ab9e6 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/snakeCase.d.ts @@ -0,0 +1,18 @@ +//#region src/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/string/snakeCase.js b/node_modules/es-toolkit/dist/string/snakeCase.js new file mode 100644 index 0000000000000000000000000000000000000000..cffb0060b3465ab82e76abb51824f4635b9431b4 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/snakeCase.js @@ -0,0 +1,21 @@ +const require_words = require("./words.js"); +//#region src/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(str).map((word) => word.toLowerCase()).join("_"); +} +//#endregion +exports.snakeCase = snakeCase; diff --git a/node_modules/es-toolkit/dist/string/snakeCase.mjs b/node_modules/es-toolkit/dist/string/snakeCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9f0fa058f25db42edcfee8123084aea905544107 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/snakeCase.mjs @@ -0,0 +1,21 @@ +import { words } from "./words.mjs"; +//#region src/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(str).map((word) => word.toLowerCase()).join("_"); +} +//#endregion +export { snakeCase }; diff --git a/node_modules/es-toolkit/dist/string/startCase.d.mts b/node_modules/es-toolkit/dist/string/startCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..114d4c23f52977f2b5e89747e4d516ea2c3c8d9b --- /dev/null +++ b/node_modules/es-toolkit/dist/string/startCase.d.mts @@ -0,0 +1,17 @@ +//#region src/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/string/startCase.d.ts b/node_modules/es-toolkit/dist/string/startCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..114d4c23f52977f2b5e89747e4d516ea2c3c8d9b --- /dev/null +++ b/node_modules/es-toolkit/dist/string/startCase.d.ts @@ -0,0 +1,17 @@ +//#region src/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/string/startCase.js b/node_modules/es-toolkit/dist/string/startCase.js new file mode 100644 index 0000000000000000000000000000000000000000..b712fcde8876d81b2c47913ec5e5c511142f826b --- /dev/null +++ b/node_modules/es-toolkit/dist/string/startCase.js @@ -0,0 +1,27 @@ +const require_words = require("./words.js"); +//#region src/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(str.trim()); + let result = ""; + for (let i = 0; i < words$1.length; i++) { + const word = words$1[i]; + if (result) result += " "; + result += word[0].toUpperCase() + word.slice(1).toLowerCase(); + } + return result; +} +//#endregion +exports.startCase = startCase; diff --git a/node_modules/es-toolkit/dist/string/startCase.mjs b/node_modules/es-toolkit/dist/string/startCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e690c7cc0ecb32525c3773e7d76c245846f5bdf9 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/startCase.mjs @@ -0,0 +1,27 @@ +import { words } from "./words.mjs"; +//#region src/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(str.trim()); + let result = ""; + for (let i = 0; i < words$1.length; i++) { + const word = words$1[i]; + if (result) result += " "; + result += word[0].toUpperCase() + word.slice(1).toLowerCase(); + } + return result; +} +//#endregion +export { startCase }; diff --git a/node_modules/es-toolkit/dist/string/trim.d.mts b/node_modules/es-toolkit/dist/string/trim.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..ef2d01cbc2d8ea8099fb62b5490046fc2b60c3a8 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trim.d.mts @@ -0,0 +1,16 @@ +//#region src/string/trim.d.ts +/** + * Removes leading and trailing whitespace or specified characters from a string. + * + * @param str - The string from which characters will be trimmed. + * @param chars - The character(s) to remove from the string. Can be a single character or an array of characters. + * @returns The resulting string after the specified characters have been removed. + * + * @example + * trim(" hello "); // "hello" + * trim("--hello--", "-"); // "hello" + * trim("##hello##", ["#", "o"]); // "hell" + */ +declare function trim(str: string, chars?: string | string[]): string; +//#endregion +export { trim }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/trim.d.ts b/node_modules/es-toolkit/dist/string/trim.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef2d01cbc2d8ea8099fb62b5490046fc2b60c3a8 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trim.d.ts @@ -0,0 +1,16 @@ +//#region src/string/trim.d.ts +/** + * Removes leading and trailing whitespace or specified characters from a string. + * + * @param str - The string from which characters will be trimmed. + * @param chars - The character(s) to remove from the string. Can be a single character or an array of characters. + * @returns The resulting string after the specified characters have been removed. + * + * @example + * trim(" hello "); // "hello" + * trim("--hello--", "-"); // "hello" + * trim("##hello##", ["#", "o"]); // "hell" + */ +declare function trim(str: string, chars?: string | string[]): string; +//#endregion +export { trim }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/trim.js b/node_modules/es-toolkit/dist/string/trim.js new file mode 100644 index 0000000000000000000000000000000000000000..8e4b1d2417b2074e1a5e9b2a00d461e76b490609 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trim.js @@ -0,0 +1,21 @@ +const require_trimEnd = require("./trimEnd.js"); +const require_trimStart = require("./trimStart.js"); +//#region src/string/trim.ts +/** +* Removes leading and trailing whitespace or specified characters from a string. +* +* @param str - The string from which characters will be trimmed. +* @param chars - The character(s) to remove from the string. Can be a single character or an array of characters. +* @returns The resulting string after the specified characters have been removed. +* +* @example +* trim(" hello "); // "hello" +* trim("--hello--", "-"); // "hello" +* trim("##hello##", ["#", "o"]); // "hell" +*/ +function trim(str, chars) { + if (chars === void 0) return str.trim(); + return require_trimStart.trimStart(require_trimEnd.trimEnd(str, chars), chars); +} +//#endregion +exports.trim = trim; diff --git a/node_modules/es-toolkit/dist/string/trim.mjs b/node_modules/es-toolkit/dist/string/trim.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bdca94b131c4d1d703fc33cca6712e70ae1afa95 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trim.mjs @@ -0,0 +1,21 @@ +import { trimEnd } from "./trimEnd.mjs"; +import { trimStart } from "./trimStart.mjs"; +//#region src/string/trim.ts +/** +* Removes leading and trailing whitespace or specified characters from a string. +* +* @param str - The string from which characters will be trimmed. +* @param chars - The character(s) to remove from the string. Can be a single character or an array of characters. +* @returns The resulting string after the specified characters have been removed. +* +* @example +* trim(" hello "); // "hello" +* trim("--hello--", "-"); // "hello" +* trim("##hello##", ["#", "o"]); // "hell" +*/ +function trim(str, chars) { + if (chars === void 0) return str.trim(); + return trimStart(trimEnd(str, chars), chars); +} +//#endregion +export { trim }; diff --git a/node_modules/es-toolkit/dist/string/trimEnd.d.mts b/node_modules/es-toolkit/dist/string/trimEnd.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..13c834f16a17b6d262760e8db61f841be1275db3 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trimEnd.d.mts @@ -0,0 +1,20 @@ +//#region src/string/trimEnd.d.ts +/** + * Removes trailing whitespace or specified characters from a string. + * + * If `chars` is a string, it should be a single character. To trim a string with multiple characters, + * provide an array instead. + * + * @param str - The string from which trailing characters will be trimmed. + * @param chars - The character(s) to remove from the end of the string. + * @returns The resulting string after the specified trailing character has been removed. + * + * @example + * const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello' + * const trimmedStr2 = trimEnd('123000', '0') // returns '123' + * const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab' + * const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed' + */ +declare function trimEnd(str: string, chars?: string | string[]): string; +//#endregion +export { trimEnd }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/trimEnd.d.ts b/node_modules/es-toolkit/dist/string/trimEnd.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13c834f16a17b6d262760e8db61f841be1275db3 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trimEnd.d.ts @@ -0,0 +1,20 @@ +//#region src/string/trimEnd.d.ts +/** + * Removes trailing whitespace or specified characters from a string. + * + * If `chars` is a string, it should be a single character. To trim a string with multiple characters, + * provide an array instead. + * + * @param str - The string from which trailing characters will be trimmed. + * @param chars - The character(s) to remove from the end of the string. + * @returns The resulting string after the specified trailing character has been removed. + * + * @example + * const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello' + * const trimmedStr2 = trimEnd('123000', '0') // returns '123' + * const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab' + * const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed' + */ +declare function trimEnd(str: string, chars?: string | string[]): string; +//#endregion +export { trimEnd }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/trimEnd.js b/node_modules/es-toolkit/dist/string/trimEnd.js new file mode 100644 index 0000000000000000000000000000000000000000..5602ee0b626f5ab67190ace215ec5af63eb32722 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trimEnd.js @@ -0,0 +1,31 @@ +//#region src/string/trimEnd.ts +/** +* Removes trailing whitespace or specified characters from a string. +* +* If `chars` is a string, it should be a single character. To trim a string with multiple characters, +* provide an array instead. +* +* @param str - The string from which trailing characters will be trimmed. +* @param chars - The character(s) to remove from the end of the string. +* @returns The resulting string after the specified trailing character has been removed. +* +* @example +* const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello' +* const trimmedStr2 = trimEnd('123000', '0') // returns '123' +* const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab' +* const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed' +*/ +function trimEnd(str, chars) { + if (chars === void 0) return str.trimEnd(); + let endIndex = str.length; + switch (typeof chars) { + case "string": + if (chars.length !== 1) throw new Error(`The 'chars' parameter should be a single character string.`); + while (endIndex > 0 && str[endIndex - 1] === chars) endIndex--; + break; + case "object": while (endIndex > 0 && chars.includes(str[endIndex - 1])) endIndex--; + } + return str.substring(0, endIndex); +} +//#endregion +exports.trimEnd = trimEnd; diff --git a/node_modules/es-toolkit/dist/string/trimEnd.mjs b/node_modules/es-toolkit/dist/string/trimEnd.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a9f644865fffad238c934ecd5100689025490755 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trimEnd.mjs @@ -0,0 +1,31 @@ +//#region src/string/trimEnd.ts +/** +* Removes trailing whitespace or specified characters from a string. +* +* If `chars` is a string, it should be a single character. To trim a string with multiple characters, +* provide an array instead. +* +* @param str - The string from which trailing characters will be trimmed. +* @param chars - The character(s) to remove from the end of the string. +* @returns The resulting string after the specified trailing character has been removed. +* +* @example +* const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello' +* const trimmedStr2 = trimEnd('123000', '0') // returns '123' +* const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab' +* const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed' +*/ +function trimEnd(str, chars) { + if (chars === void 0) return str.trimEnd(); + let endIndex = str.length; + switch (typeof chars) { + case "string": + if (chars.length !== 1) throw new Error(`The 'chars' parameter should be a single character string.`); + while (endIndex > 0 && str[endIndex - 1] === chars) endIndex--; + break; + case "object": while (endIndex > 0 && chars.includes(str[endIndex - 1])) endIndex--; + } + return str.substring(0, endIndex); +} +//#endregion +export { trimEnd }; diff --git a/node_modules/es-toolkit/dist/string/trimStart.d.mts b/node_modules/es-toolkit/dist/string/trimStart.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..d8df6a2a896c2e104e0e404dc554c416dc6cfb98 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trimStart.d.mts @@ -0,0 +1,20 @@ +//#region src/string/trimStart.d.ts +/** + * Removes leading whitespace or specified characters from a string. + * + * If `chars` is a string, it should be a single character. To trim a string with multiple characters, + * provide an array instead. + * + * @param str - The string from which leading characters will be trimmed. + * @param chars - The character(s) to remove from the start of the string. + * @returns The resulting string after the specified leading character has been removed. + * + * @example + * const trimmedStr1 = trimStart('---hello', '-') // returns 'hello' + * const trimmedStr2 = trimStart('000123', '0') // returns '123' + * const trimmedStr3 = trimStart('abcabcabc', 'a') // returns 'bcabcabc' + * const trimmedStr4 = trimStart('xxxtrimmed', 'x') // returns 'trimmed' + */ +declare function trimStart(str: string, chars?: string | string[]): string; +//#endregion +export { trimStart }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/trimStart.d.ts b/node_modules/es-toolkit/dist/string/trimStart.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8df6a2a896c2e104e0e404dc554c416dc6cfb98 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trimStart.d.ts @@ -0,0 +1,20 @@ +//#region src/string/trimStart.d.ts +/** + * Removes leading whitespace or specified characters from a string. + * + * If `chars` is a string, it should be a single character. To trim a string with multiple characters, + * provide an array instead. + * + * @param str - The string from which leading characters will be trimmed. + * @param chars - The character(s) to remove from the start of the string. + * @returns The resulting string after the specified leading character has been removed. + * + * @example + * const trimmedStr1 = trimStart('---hello', '-') // returns 'hello' + * const trimmedStr2 = trimStart('000123', '0') // returns '123' + * const trimmedStr3 = trimStart('abcabcabc', 'a') // returns 'bcabcabc' + * const trimmedStr4 = trimStart('xxxtrimmed', 'x') // returns 'trimmed' + */ +declare function trimStart(str: string, chars?: string | string[]): string; +//#endregion +export { trimStart }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/trimStart.js b/node_modules/es-toolkit/dist/string/trimStart.js new file mode 100644 index 0000000000000000000000000000000000000000..6556cc46501fc93fb2691e3df5f4ee1f0205e7cf --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trimStart.js @@ -0,0 +1,31 @@ +//#region src/string/trimStart.ts +/** +* Removes leading whitespace or specified characters from a string. +* +* If `chars` is a string, it should be a single character. To trim a string with multiple characters, +* provide an array instead. +* +* @param str - The string from which leading characters will be trimmed. +* @param chars - The character(s) to remove from the start of the string. +* @returns The resulting string after the specified leading character has been removed. +* +* @example +* const trimmedStr1 = trimStart('---hello', '-') // returns 'hello' +* const trimmedStr2 = trimStart('000123', '0') // returns '123' +* const trimmedStr3 = trimStart('abcabcabc', 'a') // returns 'bcabcabc' +* const trimmedStr4 = trimStart('xxxtrimmed', 'x') // returns 'trimmed' +*/ +function trimStart(str, chars) { + if (chars === void 0) return str.trimStart(); + let startIndex = 0; + switch (typeof chars) { + case "string": + if (chars.length !== 1) throw new Error(`The 'chars' parameter should be a single character string.`); + while (startIndex < str.length && str[startIndex] === chars) startIndex++; + break; + case "object": while (startIndex < str.length && chars.includes(str[startIndex])) startIndex++; + } + return str.substring(startIndex); +} +//#endregion +exports.trimStart = trimStart; diff --git a/node_modules/es-toolkit/dist/string/trimStart.mjs b/node_modules/es-toolkit/dist/string/trimStart.mjs new file mode 100644 index 0000000000000000000000000000000000000000..bd72f937c7a6a672e851e9a6e604fc43eeba8f8a --- /dev/null +++ b/node_modules/es-toolkit/dist/string/trimStart.mjs @@ -0,0 +1,31 @@ +//#region src/string/trimStart.ts +/** +* Removes leading whitespace or specified characters from a string. +* +* If `chars` is a string, it should be a single character. To trim a string with multiple characters, +* provide an array instead. +* +* @param str - The string from which leading characters will be trimmed. +* @param chars - The character(s) to remove from the start of the string. +* @returns The resulting string after the specified leading character has been removed. +* +* @example +* const trimmedStr1 = trimStart('---hello', '-') // returns 'hello' +* const trimmedStr2 = trimStart('000123', '0') // returns '123' +* const trimmedStr3 = trimStart('abcabcabc', 'a') // returns 'bcabcabc' +* const trimmedStr4 = trimStart('xxxtrimmed', 'x') // returns 'trimmed' +*/ +function trimStart(str, chars) { + if (chars === void 0) return str.trimStart(); + let startIndex = 0; + switch (typeof chars) { + case "string": + if (chars.length !== 1) throw new Error(`The 'chars' parameter should be a single character string.`); + while (startIndex < str.length && str[startIndex] === chars) startIndex++; + break; + case "object": while (startIndex < str.length && chars.includes(str[startIndex])) startIndex++; + } + return str.substring(startIndex); +} +//#endregion +export { trimStart }; diff --git a/node_modules/es-toolkit/dist/string/unescape.d.mts b/node_modules/es-toolkit/dist/string/unescape.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..94a63d656a135e7a7aba90996ed0c79cd7b8d3ba --- /dev/null +++ b/node_modules/es-toolkit/dist/string/unescape.d.mts @@ -0,0 +1,17 @@ +//#region src/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/string/unescape.d.ts b/node_modules/es-toolkit/dist/string/unescape.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..94a63d656a135e7a7aba90996ed0c79cd7b8d3ba --- /dev/null +++ b/node_modules/es-toolkit/dist/string/unescape.d.ts @@ -0,0 +1,17 @@ +//#region src/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/string/unescape.js b/node_modules/es-toolkit/dist/string/unescape.js new file mode 100644 index 0000000000000000000000000000000000000000..3fc02c4174ddf8bb766e11627d924b8f3c014885 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/unescape.js @@ -0,0 +1,26 @@ +//#region src/string/unescape.ts +const htmlUnescapes = { + "&": "&", + "<": "<", + ">": ">", + """: "\"", + "'": "'" +}; +/** +* 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 str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, (match) => htmlUnescapes[match] || "'"); +} +//#endregion +exports.unescape = unescape; diff --git a/node_modules/es-toolkit/dist/string/unescape.mjs b/node_modules/es-toolkit/dist/string/unescape.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c7273f91b4453366216a27f0f2b534efc45f04ef --- /dev/null +++ b/node_modules/es-toolkit/dist/string/unescape.mjs @@ -0,0 +1,26 @@ +//#region src/string/unescape.ts +const htmlUnescapes = { + "&": "&", + "<": "<", + ">": ">", + """: "\"", + "'": "'" +}; +/** +* 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 str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, (match) => htmlUnescapes[match] || "'"); +} +//#endregion +export { unescape }; diff --git a/node_modules/es-toolkit/dist/string/upperCase.d.mts b/node_modules/es-toolkit/dist/string/upperCase.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..8a0e133f8c7135c168c1208d662028d7e5f6f5c9 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/upperCase.d.mts @@ -0,0 +1,18 @@ +//#region src/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/string/upperCase.d.ts b/node_modules/es-toolkit/dist/string/upperCase.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a0e133f8c7135c168c1208d662028d7e5f6f5c9 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/upperCase.d.ts @@ -0,0 +1,18 @@ +//#region src/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/string/upperCase.js b/node_modules/es-toolkit/dist/string/upperCase.js new file mode 100644 index 0000000000000000000000000000000000000000..467f9cb4270414cb26f8c3436be6eddfd0cdea7e --- /dev/null +++ b/node_modules/es-toolkit/dist/string/upperCase.js @@ -0,0 +1,27 @@ +const require_words = require("./words.js"); +//#region src/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) { + const words$1 = require_words.words(str); + let result = ""; + for (let i = 0; i < words$1.length; i++) { + result += words$1[i].toUpperCase(); + if (i < words$1.length - 1) result += " "; + } + return result; +} +//#endregion +exports.upperCase = upperCase; diff --git a/node_modules/es-toolkit/dist/string/upperCase.mjs b/node_modules/es-toolkit/dist/string/upperCase.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a63dcd959f055923c87e0f8ee805cd997894ad2c --- /dev/null +++ b/node_modules/es-toolkit/dist/string/upperCase.mjs @@ -0,0 +1,27 @@ +import { words } from "./words.mjs"; +//#region src/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) { + const words$1 = words(str); + let result = ""; + for (let i = 0; i < words$1.length; i++) { + result += words$1[i].toUpperCase(); + if (i < words$1.length - 1) result += " "; + } + return result; +} +//#endregion +export { upperCase }; diff --git a/node_modules/es-toolkit/dist/string/upperFirst.d.mts b/node_modules/es-toolkit/dist/string/upperFirst.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9867343cf881206b798961a4ef12bd0c63054e6f --- /dev/null +++ b/node_modules/es-toolkit/dist/string/upperFirst.d.mts @@ -0,0 +1,15 @@ +//#region src/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: string): string; +//#endregion +export { upperFirst }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/upperFirst.d.ts b/node_modules/es-toolkit/dist/string/upperFirst.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9867343cf881206b798961a4ef12bd0c63054e6f --- /dev/null +++ b/node_modules/es-toolkit/dist/string/upperFirst.d.ts @@ -0,0 +1,15 @@ +//#region src/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: string): string; +//#endregion +export { upperFirst }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/upperFirst.js b/node_modules/es-toolkit/dist/string/upperFirst.js new file mode 100644 index 0000000000000000000000000000000000000000..98afc7805e32fd99755e0bced6e4c86a8f85d5c4 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/upperFirst.js @@ -0,0 +1,17 @@ +//#region src/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 str.substring(0, 1).toUpperCase() + str.substring(1); +} +//#endregion +exports.upperFirst = upperFirst; diff --git a/node_modules/es-toolkit/dist/string/upperFirst.mjs b/node_modules/es-toolkit/dist/string/upperFirst.mjs new file mode 100644 index 0000000000000000000000000000000000000000..8278b8303592c3581da9974541f36f07bbbfdb84 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/upperFirst.mjs @@ -0,0 +1,17 @@ +//#region src/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 str.substring(0, 1).toUpperCase() + str.substring(1); +} +//#endregion +export { upperFirst }; diff --git a/node_modules/es-toolkit/dist/string/words.d.mts b/node_modules/es-toolkit/dist/string/words.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..013664120dfe25ea8c17e67d3cbabd6a492a6452 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/words.d.mts @@ -0,0 +1,39 @@ +//#region src/string/words.d.ts +/** + * Regular expression pattern to split strings into words for various case conversions + * + * This pattern matches sequences of characters in a string, considering the following cases: + * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms) + * - Sequences of one uppercase letter optionally followed by lowercase letters and digits + * - Single uppercase letters + * - Sequences of digits + * - Emojis and other Unicode characters + * + * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into + * a consistent format like snake case. It also supports emojis and other Unicode characters. + * + * @example + * const matches = 'camelCaseHTTPRequest🚀'.match(CASE_SPLIT_PATTERN); + * // matches: ['camel', 'Case', 'HTTP', 'Request', '🚀'] + */ +declare const CASE_SPLIT_PATTERN: RegExp; +/** + * Splits `string` into an array of its words, treating spaces and punctuation marks as separators. + * + * @param str The string to inspect. + * @param [pattern] The pattern to match words. + * @returns Returns the words of `string`. + * + * @example + * words('fred, barney, & pebbles'); + * // => ['fred', 'barney', 'pebbles'] + * + * words('camelCaseHTTPRequest🚀'); + * // => ['camel', 'Case', 'HTTP', 'Request', '🚀'] + * + * words('Lunedì 18 Set') + * // => ['Lunedì', '18', 'Set'] + */ +declare function words(str: string): string[]; +//#endregion +export { words }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/words.d.ts b/node_modules/es-toolkit/dist/string/words.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..013664120dfe25ea8c17e67d3cbabd6a492a6452 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/words.d.ts @@ -0,0 +1,39 @@ +//#region src/string/words.d.ts +/** + * Regular expression pattern to split strings into words for various case conversions + * + * This pattern matches sequences of characters in a string, considering the following cases: + * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms) + * - Sequences of one uppercase letter optionally followed by lowercase letters and digits + * - Single uppercase letters + * - Sequences of digits + * - Emojis and other Unicode characters + * + * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into + * a consistent format like snake case. It also supports emojis and other Unicode characters. + * + * @example + * const matches = 'camelCaseHTTPRequest🚀'.match(CASE_SPLIT_PATTERN); + * // matches: ['camel', 'Case', 'HTTP', 'Request', '🚀'] + */ +declare const CASE_SPLIT_PATTERN: RegExp; +/** + * Splits `string` into an array of its words, treating spaces and punctuation marks as separators. + * + * @param str The string to inspect. + * @param [pattern] The pattern to match words. + * @returns Returns the words of `string`. + * + * @example + * words('fred, barney, & pebbles'); + * // => ['fred', 'barney', 'pebbles'] + * + * words('camelCaseHTTPRequest🚀'); + * // => ['camel', 'Case', 'HTTP', 'Request', '🚀'] + * + * words('Lunedì 18 Set') + * // => ['Lunedì', '18', 'Set'] + */ +declare function words(str: string): string[]; +//#endregion +export { words }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/string/words.js b/node_modules/es-toolkit/dist/string/words.js new file mode 100644 index 0000000000000000000000000000000000000000..2e2640aa0796257c09f5d2162a96139ef2d7e105 --- /dev/null +++ b/node_modules/es-toolkit/dist/string/words.js @@ -0,0 +1,41 @@ +//#region src/string/words.ts +/** +* Regular expression pattern to split strings into words for various case conversions +* +* This pattern matches sequences of characters in a string, considering the following cases: +* - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms) +* - Sequences of one uppercase letter optionally followed by lowercase letters and digits +* - Single uppercase letters +* - Sequences of digits +* - Emojis and other Unicode characters +* +* The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into +* a consistent format like snake case. It also supports emojis and other Unicode characters. +* +* @example +* const matches = 'camelCaseHTTPRequest🚀'.match(CASE_SPLIT_PATTERN); +* // matches: ['camel', 'Case', 'HTTP', 'Request', '🚀'] +*/ +const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu; +/** +* Splits `string` into an array of its words, treating spaces and punctuation marks as separators. +* +* @param str The string to inspect. +* @param [pattern] The pattern to match words. +* @returns Returns the words of `string`. +* +* @example +* words('fred, barney, & pebbles'); +* // => ['fred', 'barney', 'pebbles'] +* +* words('camelCaseHTTPRequest🚀'); +* // => ['camel', 'Case', 'HTTP', 'Request', '🚀'] +* +* words('Lunedì 18 Set') +* // => ['Lunedì', '18', 'Set'] +*/ +function words(str) { + return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []); +} +//#endregion +exports.words = words; diff --git a/node_modules/es-toolkit/dist/string/words.mjs b/node_modules/es-toolkit/dist/string/words.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a3e9238ac6114f664b1d6897f26329f12cf82c8e --- /dev/null +++ b/node_modules/es-toolkit/dist/string/words.mjs @@ -0,0 +1,41 @@ +//#region src/string/words.ts +/** +* Regular expression pattern to split strings into words for various case conversions +* +* This pattern matches sequences of characters in a string, considering the following cases: +* - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms) +* - Sequences of one uppercase letter optionally followed by lowercase letters and digits +* - Single uppercase letters +* - Sequences of digits +* - Emojis and other Unicode characters +* +* The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into +* a consistent format like snake case. It also supports emojis and other Unicode characters. +* +* @example +* const matches = 'camelCaseHTTPRequest🚀'.match(CASE_SPLIT_PATTERN); +* // matches: ['camel', 'Case', 'HTTP', 'Request', '🚀'] +*/ +const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu; +/** +* Splits `string` into an array of its words, treating spaces and punctuation marks as separators. +* +* @param str The string to inspect. +* @param [pattern] The pattern to match words. +* @returns Returns the words of `string`. +* +* @example +* words('fred, barney, & pebbles'); +* // => ['fred', 'barney', 'pebbles'] +* +* words('camelCaseHTTPRequest🚀'); +* // => ['camel', 'Case', 'HTTP', 'Request', '🚀'] +* +* words('Lunedì 18 Set') +* // => ['Lunedì', '18', 'Set'] +*/ +function words(str) { + return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []); +} +//#endregion +export { words }; diff --git a/node_modules/es-toolkit/dist/types/DeepPartial.d.mts b/node_modules/es-toolkit/dist/types/DeepPartial.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9e1140e9a83e068882bfe66983e704738bccc5c3 --- /dev/null +++ b/node_modules/es-toolkit/dist/types/DeepPartial.d.mts @@ -0,0 +1,21 @@ +//#region src/types/DeepPartial.d.ts +/** + * Makes all properties of `T` optional recursively, unlike the built-in + * `Partial` which only affects the first level. + * + * Recurses into plain objects, arrays/tuples (elements do not become sparse), + * and `Map`/`Set` contents. Functions, `Date`, and `RegExp` pass through + * unchanged. + * + * @template T - The type to make deeply optional. + * + * @example + * type Config = { server: { host: string; port: number }; debug: boolean }; + * type ConfigPatch = DeepPartial; + * // => { server?: { host?: string; port?: number }; debug?: boolean } + * + * const patch: ConfigPatch = { server: { port: 8080 } }; // ok, host omitted + */ +type DeepPartial = T extends ((...args: any[]) => unknown) | Date | RegExp ? T : T extends Map ? Map, DeepPartial> : T extends ReadonlyMap ? ReadonlyMap, DeepPartial> : T extends Set ? Set> : T extends ReadonlySet ? ReadonlySet> : T extends readonly unknown[] ? { [K in keyof T]: DeepPartial } : T extends object ? { [K in keyof T]?: DeepPartial } : T; +//#endregion +export { DeepPartial }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/DeepPartial.d.ts b/node_modules/es-toolkit/dist/types/DeepPartial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e1140e9a83e068882bfe66983e704738bccc5c3 --- /dev/null +++ b/node_modules/es-toolkit/dist/types/DeepPartial.d.ts @@ -0,0 +1,21 @@ +//#region src/types/DeepPartial.d.ts +/** + * Makes all properties of `T` optional recursively, unlike the built-in + * `Partial` which only affects the first level. + * + * Recurses into plain objects, arrays/tuples (elements do not become sparse), + * and `Map`/`Set` contents. Functions, `Date`, and `RegExp` pass through + * unchanged. + * + * @template T - The type to make deeply optional. + * + * @example + * type Config = { server: { host: string; port: number }; debug: boolean }; + * type ConfigPatch = DeepPartial; + * // => { server?: { host?: string; port?: number }; debug?: boolean } + * + * const patch: ConfigPatch = { server: { port: 8080 } }; // ok, host omitted + */ +type DeepPartial = T extends ((...args: any[]) => unknown) | Date | RegExp ? T : T extends Map ? Map, DeepPartial> : T extends ReadonlyMap ? ReadonlyMap, DeepPartial> : T extends Set ? Set> : T extends ReadonlySet ? ReadonlySet> : T extends readonly unknown[] ? { [K in keyof T]: DeepPartial } : T extends object ? { [K in keyof T]?: DeepPartial } : T; +//#endregion +export { DeepPartial }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/DeepReadonly.d.mts b/node_modules/es-toolkit/dist/types/DeepReadonly.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9c3a4ce3c974bd4a8b0da6f04029e1d0b29bb105 --- /dev/null +++ b/node_modules/es-toolkit/dist/types/DeepReadonly.d.mts @@ -0,0 +1,22 @@ +//#region src/types/DeepReadonly.d.ts +/** + * Makes all properties of `T` readonly recursively, unlike the built-in + * `Readonly` which only affects the first level. + * + * Arrays and tuples become readonly, and `Map`/`Set` become + * `ReadonlyMap`/`ReadonlySet`. Functions, `Date`, and `RegExp` pass through + * unchanged. + * + * @template T - The type to make deeply readonly. + * + * @example + * type State = { user: { name: string; tags: string[] } }; + * type FrozenState = DeepReadonly; + * // => { readonly user: { readonly name: string; readonly tags: readonly string[] } } + * + * declare const state: FrozenState; + * state.user.name = 'x'; // error: name is readonly + */ +type DeepReadonly = T extends ((...args: any[]) => unknown) | Date | RegExp ? T : T extends ReadonlyMap ? ReadonlyMap, DeepReadonly> : T extends ReadonlySet ? ReadonlySet> : T extends object ? { readonly [K in keyof T]: DeepReadonly } : T; +//#endregion +export { DeepReadonly }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/DeepReadonly.d.ts b/node_modules/es-toolkit/dist/types/DeepReadonly.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c3a4ce3c974bd4a8b0da6f04029e1d0b29bb105 --- /dev/null +++ b/node_modules/es-toolkit/dist/types/DeepReadonly.d.ts @@ -0,0 +1,22 @@ +//#region src/types/DeepReadonly.d.ts +/** + * Makes all properties of `T` readonly recursively, unlike the built-in + * `Readonly` which only affects the first level. + * + * Arrays and tuples become readonly, and `Map`/`Set` become + * `ReadonlyMap`/`ReadonlySet`. Functions, `Date`, and `RegExp` pass through + * unchanged. + * + * @template T - The type to make deeply readonly. + * + * @example + * type State = { user: { name: string; tags: string[] } }; + * type FrozenState = DeepReadonly; + * // => { readonly user: { readonly name: string; readonly tags: readonly string[] } } + * + * declare const state: FrozenState; + * state.user.name = 'x'; // error: name is readonly + */ +type DeepReadonly = T extends ((...args: any[]) => unknown) | Date | RegExp ? T : T extends ReadonlyMap ? ReadonlyMap, DeepReadonly> : T extends ReadonlySet ? ReadonlySet> : T extends object ? { readonly [K in keyof T]: DeepReadonly } : T; +//#endregion +export { DeepReadonly }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/NonEmptyArray.d.mts b/node_modules/es-toolkit/dist/types/NonEmptyArray.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..9dc90eca144de122e863c7c702db58d16d86019e --- /dev/null +++ b/node_modules/es-toolkit/dist/types/NonEmptyArray.d.mts @@ -0,0 +1,14 @@ +//#region src/types/NonEmptyArray.d.ts +/** + * An array guaranteed to have at least one element. + * The first element resolves to `T` instead of `T | undefined`. + * + * @template T - The type of the elements. + * + * @example + * const a: NonEmptyArray = [1, 2, 3]; // ok + * const b: NonEmptyArray = []; // error: empty array not allowed + */ +type NonEmptyArray = [T, ...T[]]; +//#endregion +export { NonEmptyArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/NonEmptyArray.d.ts b/node_modules/es-toolkit/dist/types/NonEmptyArray.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9dc90eca144de122e863c7c702db58d16d86019e --- /dev/null +++ b/node_modules/es-toolkit/dist/types/NonEmptyArray.d.ts @@ -0,0 +1,14 @@ +//#region src/types/NonEmptyArray.d.ts +/** + * An array guaranteed to have at least one element. + * The first element resolves to `T` instead of `T | undefined`. + * + * @template T - The type of the elements. + * + * @example + * const a: NonEmptyArray = [1, 2, 3]; // ok + * const b: NonEmptyArray = []; // error: empty array not allowed + */ +type NonEmptyArray = [T, ...T[]]; +//#endregion +export { NonEmptyArray }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/Simplify.d.mts b/node_modules/es-toolkit/dist/types/Simplify.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2efb14e699a9e306a96169fb2f6cb0c13af9fc02 --- /dev/null +++ b/node_modules/es-toolkit/dist/types/Simplify.d.mts @@ -0,0 +1,18 @@ +//#region src/types/Simplify.d.ts +/** + * Flattens an intersection or mapped type into a single, readable object type. + * + * The result is equivalent for plain object types, but editors show the + * resolved shape (`{ a: 1; b: 2 }`) instead of `A & B`. + * + * @template T - The type to flatten. + * + * @example + * type A = { name: string }; + * type B = { age: number }; + * type User = Simplify; + * // hover => { name: string; age: number } (instead of A & B) + */ +type Simplify = { [K in keyof T]: T[K] } & {}; +//#endregion +export { Simplify }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/Simplify.d.ts b/node_modules/es-toolkit/dist/types/Simplify.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2efb14e699a9e306a96169fb2f6cb0c13af9fc02 --- /dev/null +++ b/node_modules/es-toolkit/dist/types/Simplify.d.ts @@ -0,0 +1,18 @@ +//#region src/types/Simplify.d.ts +/** + * Flattens an intersection or mapped type into a single, readable object type. + * + * The result is equivalent for plain object types, but editors show the + * resolved shape (`{ a: 1; b: 2 }`) instead of `A & B`. + * + * @template T - The type to flatten. + * + * @example + * type A = { name: string }; + * type B = { age: number }; + * type User = Simplify; + * // hover => { name: string; age: number } (instead of A & B) + */ +type Simplify = { [K in keyof T]: T[K] } & {}; +//#endregion +export { Simplify }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/ValueOf.d.mts b/node_modules/es-toolkit/dist/types/ValueOf.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..2fee2abce848ae4c79346dbb01152bf91ffb0630 --- /dev/null +++ b/node_modules/es-toolkit/dist/types/ValueOf.d.mts @@ -0,0 +1,14 @@ +//#region src/types/ValueOf.d.ts +/** + * Creates a union of all value types in `T`. The value-side counterpart to `keyof`. + * + * @template T - The object type to read values from. + * + * @example + * const STATUS = { IDLE: 'idle', ERROR: 'error' } as const; + * type Status = ValueOf; + * // => 'idle' | 'error' + */ +type ValueOf = T[keyof T]; +//#endregion +export { ValueOf }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/ValueOf.d.ts b/node_modules/es-toolkit/dist/types/ValueOf.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fee2abce848ae4c79346dbb01152bf91ffb0630 --- /dev/null +++ b/node_modules/es-toolkit/dist/types/ValueOf.d.ts @@ -0,0 +1,14 @@ +//#region src/types/ValueOf.d.ts +/** + * Creates a union of all value types in `T`. The value-side counterpart to `keyof`. + * + * @template T - The object type to read values from. + * + * @example + * const STATUS = { IDLE: 'idle', ERROR: 'error' } as const; + * type Status = ValueOf; + * // => 'idle' | 'error' + */ +type ValueOf = T[keyof T]; +//#endregion +export { ValueOf }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/index.d.mts b/node_modules/es-toolkit/dist/types/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3d45b5bef8059498d6ca5870f73358da1e288965 --- /dev/null +++ b/node_modules/es-toolkit/dist/types/index.d.mts @@ -0,0 +1,7 @@ +import { DeepPartial } from "./DeepPartial.mjs"; +import { DeepReadonly } from "./DeepReadonly.mjs"; +import { NonEmptyArray } from "./NonEmptyArray.mjs"; +import { Simplify } from "./Simplify.mjs"; +import { ValueOf } from "./ValueOf.mjs"; +import { Writable } from "./Writable.mjs"; +export { type DeepPartial, type DeepReadonly, type NonEmptyArray, type Simplify, type ValueOf, type Writable }; \ No newline at end of file diff --git a/node_modules/es-toolkit/dist/types/index.d.ts b/node_modules/es-toolkit/dist/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d7913aa59d9d0c572fec127b88ba0432ffa32cd --- /dev/null +++ b/node_modules/es-toolkit/dist/types/index.d.ts @@ -0,0 +1,7 @@ +import { DeepPartial } from "./DeepPartial.js"; +import { DeepReadonly } from "./DeepReadonly.js"; +import { NonEmptyArray } from "./NonEmptyArray.js"; +import { Simplify } from "./Simplify.js"; +import { ValueOf } from "./ValueOf.js"; +import { Writable } from "./Writable.js"; +export { type DeepPartial, type DeepReadonly, type NonEmptyArray, type Simplify, type ValueOf, type Writable }; \ No newline at end of file