Add settings page for managing forecasting API key and URL via UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 14:37:36 +00:00
parent cae411eae7
commit 1c411e402e
19809 changed files with 1962608 additions and 97 deletions

19
frontend/node_modules/es-toolkit/dist/array/at.d.mts generated vendored Normal file
View file

@ -0,0 +1,19 @@
//#region src/array/at.d.ts
/**
* Retrieves elements from an array at the specified indices.
*
* This function supports negative indices, which count from the end of the array.
*
* @template T
* @param arr - The array to retrieve elements from.
* @param indices - An array of indices specifying the positions of elements to retrieve.
* @returns A new array containing the elements at the specified indices.
*
* @example
* const numbers = [10, 20, 30, 40, 50];
* const result = at(numbers, [1, 3, 4]);
* console.log(result); // [20, 40, 50]
*/
declare function at<T>(arr: readonly T[], indices: number[]): T[];
//#endregion
export { at };

19
frontend/node_modules/es-toolkit/dist/array/at.d.ts generated vendored Normal file
View file

@ -0,0 +1,19 @@
//#region src/array/at.d.ts
/**
* Retrieves elements from an array at the specified indices.
*
* This function supports negative indices, which count from the end of the array.
*
* @template T
* @param arr - The array to retrieve elements from.
* @param indices - An array of indices specifying the positions of elements to retrieve.
* @returns A new array containing the elements at the specified indices.
*
* @example
* const numbers = [10, 20, 30, 40, 50];
* const result = at(numbers, [1, 3, 4]);
* console.log(result); // [20, 40, 50]
*/
declare function at<T>(arr: readonly T[], indices: number[]): T[];
//#endregion
export { at };

29
frontend/node_modules/es-toolkit/dist/array/at.js generated vendored Normal file
View file

@ -0,0 +1,29 @@
//#region src/array/at.ts
/**
* Retrieves elements from an array at the specified indices.
*
* This function supports negative indices, which count from the end of the array.
*
* @template T
* @param arr - The array to retrieve elements from.
* @param indices - An array of indices specifying the positions of elements to retrieve.
* @returns A new array containing the elements at the specified indices.
*
* @example
* const numbers = [10, 20, 30, 40, 50];
* const result = at(numbers, [1, 3, 4]);
* console.log(result); // [20, 40, 50]
*/
function at(arr, indices) {
const result = new Array(indices.length);
const length = arr.length;
for (let i = 0; i < indices.length; i++) {
let index = indices[i];
index = Number.isInteger(index) ? index : Math.trunc(index) || 0;
if (index < 0) index += length;
result[i] = arr[index];
}
return result;
}
//#endregion
exports.at = at;

29
frontend/node_modules/es-toolkit/dist/array/at.mjs generated vendored Normal file
View file

@ -0,0 +1,29 @@
//#region src/array/at.ts
/**
* Retrieves elements from an array at the specified indices.
*
* This function supports negative indices, which count from the end of the array.
*
* @template T
* @param arr - The array to retrieve elements from.
* @param indices - An array of indices specifying the positions of elements to retrieve.
* @returns A new array containing the elements at the specified indices.
*
* @example
* const numbers = [10, 20, 30, 40, 50];
* const result = at(numbers, [1, 3, 4]);
* console.log(result); // [20, 40, 50]
*/
function at(arr, indices) {
const result = new Array(indices.length);
const length = arr.length;
for (let i = 0; i < indices.length; i++) {
let index = indices[i];
index = Number.isInteger(index) ? index : Math.trunc(index) || 0;
if (index < 0) index += length;
result[i] = arr[index];
}
return result;
}
//#endregion
export { at };

View file

@ -0,0 +1,75 @@
//#region src/array/cartesianProduct.d.ts
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* @template T
* @param arr1 - The array to take the product of.
* @returns An array of single-element tuples.
*/
declare function cartesianProduct<T>(arr1: readonly T[]): Array<[T]>;
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* @template T, U
* @param arr1 - The first array to take the product of.
* @param arr2 - The second array to take the product of.
* @returns An array of tuples representing the Cartesian product.
*
* @example
* cartesianProduct([1, 2], ['a', 'b']);
* // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
*/
declare function cartesianProduct<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* @template T, U, V
* @param arr1 - The first array to take the product of.
* @param arr2 - The second array to take the product of.
* @param arr3 - The third array to take the product of.
* @returns An array of tuples representing the Cartesian product.
*/
declare function cartesianProduct<T, U, V>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[]): Array<[T, U, V]>;
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* @template T, U, V, W
* @param arr1 - The first array to take the product of.
* @param arr2 - The second array to take the product of.
* @param arr3 - The third array to take the product of.
* @param arr4 - The fourth array to take the product of.
* @returns An array of tuples representing the Cartesian product.
*/
declare function cartesianProduct<T, U, V, W>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): Array<[T, U, V, W]>;
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* Returns every possible tuple formed by picking one element from each input array, in lexicographic order.
* The rightmost array advances fastest, like the digits of an odometer.
*
* If no arrays are passed, the result is `[[]]` (a single empty tuple).
* If any input array is empty, the result is `[]`.
*
* @template T
* @param arrs - The arrays to take the product of.
* @returns An array of tuples representing the Cartesian product.
*
* @example
* cartesianProduct([1, 2], ['a', 'b']);
* // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
*
* @example
* cartesianProduct([0, 1], [0, 1], [0, 1]);
* // => [[0,0,0], [0,0,1], [0,1,0], [0,1,1], [1,0,0], [1,0,1], [1,1,0], [1,1,1]]
*
* @example
* cartesianProduct([1, 2, 3], []);
* // => []
*
* @example
* cartesianProduct();
* // => [[]]
*/
declare function cartesianProduct<T>(...arrs: Array<readonly T[]>): T[][];
//#endregion
export { cartesianProduct };

View file

@ -0,0 +1,75 @@
//#region src/array/cartesianProduct.d.ts
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* @template T
* @param arr1 - The array to take the product of.
* @returns An array of single-element tuples.
*/
declare function cartesianProduct<T>(arr1: readonly T[]): Array<[T]>;
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* @template T, U
* @param arr1 - The first array to take the product of.
* @param arr2 - The second array to take the product of.
* @returns An array of tuples representing the Cartesian product.
*
* @example
* cartesianProduct([1, 2], ['a', 'b']);
* // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
*/
declare function cartesianProduct<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* @template T, U, V
* @param arr1 - The first array to take the product of.
* @param arr2 - The second array to take the product of.
* @param arr3 - The third array to take the product of.
* @returns An array of tuples representing the Cartesian product.
*/
declare function cartesianProduct<T, U, V>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[]): Array<[T, U, V]>;
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* @template T, U, V, W
* @param arr1 - The first array to take the product of.
* @param arr2 - The second array to take the product of.
* @param arr3 - The third array to take the product of.
* @param arr4 - The fourth array to take the product of.
* @returns An array of tuples representing the Cartesian product.
*/
declare function cartesianProduct<T, U, V, W>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): Array<[T, U, V, W]>;
/**
* Computes the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of the input arrays.
*
* Returns every possible tuple formed by picking one element from each input array, in lexicographic order.
* The rightmost array advances fastest, like the digits of an odometer.
*
* If no arrays are passed, the result is `[[]]` (a single empty tuple).
* If any input array is empty, the result is `[]`.
*
* @template T
* @param arrs - The arrays to take the product of.
* @returns An array of tuples representing the Cartesian product.
*
* @example
* cartesianProduct([1, 2], ['a', 'b']);
* // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
*
* @example
* cartesianProduct([0, 1], [0, 1], [0, 1]);
* // => [[0,0,0], [0,0,1], [0,1,0], [0,1,1], [1,0,0], [1,0,1], [1,1,0], [1,1,1]]
*
* @example
* cartesianProduct([1, 2, 3], []);
* // => []
*
* @example
* cartesianProduct();
* // => [[]]
*/
declare function cartesianProduct<T>(...arrs: Array<readonly T[]>): T[][];
//#endregion
export { cartesianProduct };

View file

@ -0,0 +1,23 @@
//#region src/array/cartesianProduct.ts
function cartesianProduct(...arrs) {
if (arrs.length === 0) return [[]];
let total = 1;
for (let i = 0; i < arrs.length; i++) total *= arrs[i].length;
if (total === 0) return [];
const n = arrs.length;
const result = Array(total);
for (let i = 0; i < total; i++) {
const tuple = Array(n);
let idx = i;
for (let j = n - 1; j >= 0; j--) {
const arr = arrs[j];
const len = arr.length;
tuple[j] = arr[idx % len];
idx = Math.floor(idx / len);
}
result[i] = tuple;
}
return result;
}
//#endregion
exports.cartesianProduct = cartesianProduct;

View file

@ -0,0 +1,23 @@
//#region src/array/cartesianProduct.ts
function cartesianProduct(...arrs) {
if (arrs.length === 0) return [[]];
let total = 1;
for (let i = 0; i < arrs.length; i++) total *= arrs[i].length;
if (total === 0) return [];
const n = arrs.length;
const result = Array(total);
for (let i = 0; i < total; i++) {
const tuple = Array(n);
let idx = i;
for (let j = n - 1; j >= 0; j--) {
const arr = arrs[j];
const len = arr.length;
tuple[j] = arr[idx % len];
idx = Math.floor(idx / len);
}
result[i] = tuple;
}
return result;
}
//#endregion
export { cartesianProduct };

View file

@ -0,0 +1,27 @@
//#region src/array/chunk.d.ts
/**
* Splits an array into smaller arrays of a specified length.
*
* This function takes an input array and divides it into multiple smaller arrays,
* each of a specified length. If the input array cannot be evenly divided,
* the final sub-array will contain the remaining elements.
*
* @template T The type of elements in the array.
* @param arr - The array to be chunked into smaller arrays.
* @param size - The size of each smaller array. Must be a positive integer.
* @returns A two-dimensional array where each sub-array has a maximum length of `size`.
* @throws {Error} Throws an error if `size` is not a positive integer.
*
* @example
* // Splits an array of numbers into sub-arrays of length 2
* chunk([1, 2, 3, 4, 5], 2);
* // Returns: [[1, 2], [3, 4], [5]]
*
* @example
* // Splits an array of strings into sub-arrays of length 3
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
*/
declare function chunk<T>(arr: readonly T[], size: number): T[][];
//#endregion
export { chunk };

27
frontend/node_modules/es-toolkit/dist/array/chunk.d.ts generated vendored Normal file
View file

@ -0,0 +1,27 @@
//#region src/array/chunk.d.ts
/**
* Splits an array into smaller arrays of a specified length.
*
* This function takes an input array and divides it into multiple smaller arrays,
* each of a specified length. If the input array cannot be evenly divided,
* the final sub-array will contain the remaining elements.
*
* @template T The type of elements in the array.
* @param arr - The array to be chunked into smaller arrays.
* @param size - The size of each smaller array. Must be a positive integer.
* @returns A two-dimensional array where each sub-array has a maximum length of `size`.
* @throws {Error} Throws an error if `size` is not a positive integer.
*
* @example
* // Splits an array of numbers into sub-arrays of length 2
* chunk([1, 2, 3, 4, 5], 2);
* // Returns: [[1, 2], [3, 4], [5]]
*
* @example
* // Splits an array of strings into sub-arrays of length 3
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
*/
declare function chunk<T>(arr: readonly T[], size: number): T[][];
//#endregion
export { chunk };

37
frontend/node_modules/es-toolkit/dist/array/chunk.js generated vendored Normal file
View file

@ -0,0 +1,37 @@
//#region src/array/chunk.ts
/**
* Splits an array into smaller arrays of a specified length.
*
* This function takes an input array and divides it into multiple smaller arrays,
* each of a specified length. If the input array cannot be evenly divided,
* the final sub-array will contain the remaining elements.
*
* @template T The type of elements in the array.
* @param arr - The array to be chunked into smaller arrays.
* @param size - The size of each smaller array. Must be a positive integer.
* @returns A two-dimensional array where each sub-array has a maximum length of `size`.
* @throws {Error} Throws an error if `size` is not a positive integer.
*
* @example
* // Splits an array of numbers into sub-arrays of length 2
* chunk([1, 2, 3, 4, 5], 2);
* // Returns: [[1, 2], [3, 4], [5]]
*
* @example
* // Splits an array of strings into sub-arrays of length 3
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
*/
function chunk(arr, size) {
if (!Number.isInteger(size) || size <= 0) throw new Error("Size must be an integer greater than zero.");
const chunkLength = Math.ceil(arr.length / size);
const result = Array(chunkLength);
for (let index = 0; index < chunkLength; index++) {
const start = index * size;
const end = start + size;
result[index] = arr.slice(start, end);
}
return result;
}
//#endregion
exports.chunk = chunk;

37
frontend/node_modules/es-toolkit/dist/array/chunk.mjs generated vendored Normal file
View file

@ -0,0 +1,37 @@
//#region src/array/chunk.ts
/**
* Splits an array into smaller arrays of a specified length.
*
* This function takes an input array and divides it into multiple smaller arrays,
* each of a specified length. If the input array cannot be evenly divided,
* the final sub-array will contain the remaining elements.
*
* @template T The type of elements in the array.
* @param arr - The array to be chunked into smaller arrays.
* @param size - The size of each smaller array. Must be a positive integer.
* @returns A two-dimensional array where each sub-array has a maximum length of `size`.
* @throws {Error} Throws an error if `size` is not a positive integer.
*
* @example
* // Splits an array of numbers into sub-arrays of length 2
* chunk([1, 2, 3, 4, 5], 2);
* // Returns: [[1, 2], [3, 4], [5]]
*
* @example
* // Splits an array of strings into sub-arrays of length 3
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
*/
function chunk(arr, size) {
if (!Number.isInteger(size) || size <= 0) throw new Error("Size must be an integer greater than zero.");
const chunkLength = Math.ceil(arr.length / size);
const result = Array(chunkLength);
for (let index = 0; index < chunkLength; index++) {
const start = index * size;
const end = start + size;
result[index] = arr.slice(start, end);
}
return result;
}
//#endregion
export { chunk };

View file

@ -0,0 +1,32 @@
//#region src/array/chunkBy.d.ts
/**
* Splits an array into chunks of consecutive elements that share the same key.
*
* Walking left to right, each element's key is derived by `iteratee`. Whenever
* the key differs from the previous element's key, a new chunk is started;
* otherwise the element is appended to the current chunk. Keys are compared with
* `!==` (strict inequality), so equal primitives stay together while distinct
* object references always start a new chunk.
*
* Unlike {@link chunk}, which splits by a fixed size, `chunkBy` splits by a
* boundary condition, keeping runs of same-keyed elements together.
*
* @template T - The type of elements in the array.
* @param arr - The array to split into chunks.
* @param iteratee - A function that derives the comparison key for each element.
* @returns A two-dimensional array where each sub-array is a run of consecutive
* elements that produced the same key.
*
* @example
* // Group consecutive equal numbers
* chunkBy([1, 1, 2, 3, 3, 3], value => value);
* // Returns: [[1, 1], [2], [3, 3, 3]]
*
* @example
* // Group consecutive words by their length
* chunkBy(['a', 'b', 'cd', 'ef', 'g'], word => word.length);
* // Returns: [['a', 'b'], ['cd', 'ef'], ['g']]
*/
declare function chunkBy<T>(arr: readonly T[], iteratee: (value: T) => unknown): T[][];
//#endregion
export { chunkBy };

View file

@ -0,0 +1,32 @@
//#region src/array/chunkBy.d.ts
/**
* Splits an array into chunks of consecutive elements that share the same key.
*
* Walking left to right, each element's key is derived by `iteratee`. Whenever
* the key differs from the previous element's key, a new chunk is started;
* otherwise the element is appended to the current chunk. Keys are compared with
* `!==` (strict inequality), so equal primitives stay together while distinct
* object references always start a new chunk.
*
* Unlike {@link chunk}, which splits by a fixed size, `chunkBy` splits by a
* boundary condition, keeping runs of same-keyed elements together.
*
* @template T - The type of elements in the array.
* @param arr - The array to split into chunks.
* @param iteratee - A function that derives the comparison key for each element.
* @returns A two-dimensional array where each sub-array is a run of consecutive
* elements that produced the same key.
*
* @example
* // Group consecutive equal numbers
* chunkBy([1, 1, 2, 3, 3, 3], value => value);
* // Returns: [[1, 1], [2], [3, 3, 3]]
*
* @example
* // Group consecutive words by their length
* chunkBy(['a', 'b', 'cd', 'ef', 'g'], word => word.length);
* // Returns: [['a', 'b'], ['cd', 'ef'], ['g']]
*/
declare function chunkBy<T>(arr: readonly T[], iteratee: (value: T) => unknown): T[][];
//#endregion
export { chunkBy };

42
frontend/node_modules/es-toolkit/dist/array/chunkBy.js generated vendored Normal file
View file

@ -0,0 +1,42 @@
//#region src/array/chunkBy.ts
/**
* Splits an array into chunks of consecutive elements that share the same key.
*
* Walking left to right, each element's key is derived by `iteratee`. Whenever
* the key differs from the previous element's key, a new chunk is started;
* otherwise the element is appended to the current chunk. Keys are compared with
* `!==` (strict inequality), so equal primitives stay together while distinct
* object references always start a new chunk.
*
* Unlike {@link chunk}, which splits by a fixed size, `chunkBy` splits by a
* boundary condition, keeping runs of same-keyed elements together.
*
* @template T - The type of elements in the array.
* @param arr - The array to split into chunks.
* @param iteratee - A function that derives the comparison key for each element.
* @returns A two-dimensional array where each sub-array is a run of consecutive
* elements that produced the same key.
*
* @example
* // Group consecutive equal numbers
* chunkBy([1, 1, 2, 3, 3, 3], value => value);
* // Returns: [[1, 1], [2], [3, 3, 3]]
*
* @example
* // Group consecutive words by their length
* chunkBy(['a', 'b', 'cd', 'ef', 'g'], word => word.length);
* // Returns: [['a', 'b'], ['cd', 'ef'], ['g']]
*/
function chunkBy(arr, iteratee) {
const result = [];
let prevKey;
for (let i = 0; i < arr.length; i++) {
const key = iteratee(arr[i]);
if (i === 0 || key !== prevKey) result.push([arr[i]]);
else result[result.length - 1].push(arr[i]);
prevKey = key;
}
return result;
}
//#endregion
exports.chunkBy = chunkBy;

View file

@ -0,0 +1,42 @@
//#region src/array/chunkBy.ts
/**
* Splits an array into chunks of consecutive elements that share the same key.
*
* Walking left to right, each element's key is derived by `iteratee`. Whenever
* the key differs from the previous element's key, a new chunk is started;
* otherwise the element is appended to the current chunk. Keys are compared with
* `!==` (strict inequality), so equal primitives stay together while distinct
* object references always start a new chunk.
*
* Unlike {@link chunk}, which splits by a fixed size, `chunkBy` splits by a
* boundary condition, keeping runs of same-keyed elements together.
*
* @template T - The type of elements in the array.
* @param arr - The array to split into chunks.
* @param iteratee - A function that derives the comparison key for each element.
* @returns A two-dimensional array where each sub-array is a run of consecutive
* elements that produced the same key.
*
* @example
* // Group consecutive equal numbers
* chunkBy([1, 1, 2, 3, 3, 3], value => value);
* // Returns: [[1, 1], [2], [3, 3, 3]]
*
* @example
* // Group consecutive words by their length
* chunkBy(['a', 'b', 'cd', 'ef', 'g'], word => word.length);
* // Returns: [['a', 'b'], ['cd', 'ef'], ['g']]
*/
function chunkBy(arr, iteratee) {
const result = [];
let prevKey;
for (let i = 0; i < arr.length; i++) {
const key = iteratee(arr[i]);
if (i === 0 || key !== prevKey) result.push([arr[i]]);
else result[result.length - 1].push(arr[i]);
prevKey = key;
}
return result;
}
//#endregion
export { chunkBy };

View file

@ -0,0 +1,35 @@
//#region src/array/combinations.d.ts
/**
* Returns all `r`-length combinations of elements from the input array.
*
* Combinations are emitted in lexicographic order based on the position of elements in the input array.
* Elements are treated as unique by position, not by value, so duplicates in the input may produce
* combinations that look identical.
*
* The number of combinations is `n! / r! / (n - r)!` when `0 <= r <= n`, and zero when `r > n`.
*
* @template T
* @param arr - The input array.
* @param r - The length of each combination. Must be a non-negative integer.
* @returns An array of `r`-length combinations.
* @throws {Error} If `r` is not a non-negative integer.
*
* @example
* combinations(['A', 'B', 'C', 'D'], 2);
* // => [['A','B'], ['A','C'], ['A','D'], ['B','C'], ['B','D'], ['C','D']]
*
* @example
* combinations([1, 2, 3, 4], 3);
* // => [[1,2,3], [1,2,4], [1,3,4], [2,3,4]]
*
* @example
* combinations([1, 2, 3], 0);
* // => [[]]
*
* @example
* combinations([1, 2], 5);
* // => []
*/
declare function combinations<T>(arr: readonly T[], r: number): T[][];
//#endregion
export { combinations };

View file

@ -0,0 +1,35 @@
//#region src/array/combinations.d.ts
/**
* Returns all `r`-length combinations of elements from the input array.
*
* Combinations are emitted in lexicographic order based on the position of elements in the input array.
* Elements are treated as unique by position, not by value, so duplicates in the input may produce
* combinations that look identical.
*
* The number of combinations is `n! / r! / (n - r)!` when `0 <= r <= n`, and zero when `r > n`.
*
* @template T
* @param arr - The input array.
* @param r - The length of each combination. Must be a non-negative integer.
* @returns An array of `r`-length combinations.
* @throws {Error} If `r` is not a non-negative integer.
*
* @example
* combinations(['A', 'B', 'C', 'D'], 2);
* // => [['A','B'], ['A','C'], ['A','D'], ['B','C'], ['B','D'], ['C','D']]
*
* @example
* combinations([1, 2, 3, 4], 3);
* // => [[1,2,3], [1,2,4], [1,3,4], [2,3,4]]
*
* @example
* combinations([1, 2, 3], 0);
* // => [[]]
*
* @example
* combinations([1, 2], 5);
* // => []
*/
declare function combinations<T>(arr: readonly T[], r: number): T[][];
//#endregion
export { combinations };

View file

@ -0,0 +1,53 @@
//#region src/array/combinations.ts
/**
* Returns all `r`-length combinations of elements from the input array.
*
* Combinations are emitted in lexicographic order based on the position of elements in the input array.
* Elements are treated as unique by position, not by value, so duplicates in the input may produce
* combinations that look identical.
*
* The number of combinations is `n! / r! / (n - r)!` when `0 <= r <= n`, and zero when `r > n`.
*
* @template T
* @param arr - The input array.
* @param r - The length of each combination. Must be a non-negative integer.
* @returns An array of `r`-length combinations.
* @throws {Error} If `r` is not a non-negative integer.
*
* @example
* combinations(['A', 'B', 'C', 'D'], 2);
* // => [['A','B'], ['A','C'], ['A','D'], ['B','C'], ['B','D'], ['C','D']]
*
* @example
* combinations([1, 2, 3, 4], 3);
* // => [[1,2,3], [1,2,4], [1,3,4], [2,3,4]]
*
* @example
* combinations([1, 2, 3], 0);
* // => [[]]
*
* @example
* combinations([1, 2], 5);
* // => []
*/
function combinations(arr, r) {
if (!Number.isInteger(r) || r < 0) throw new Error("r must be a non-negative integer.");
const n = arr.length;
if (r > n) return [];
if (r === 0) return [[]];
const indices = Array(r);
for (let i = 0; i < r; i++) indices[i] = i;
const result = [];
while (true) {
const tuple = Array(r);
for (let i = 0; i < r; i++) tuple[i] = arr[indices[i]];
result.push(tuple);
let i = r - 1;
while (i >= 0 && indices[i] === i + n - r) i--;
if (i < 0) return result;
indices[i]++;
for (let j = i + 1; j < r; j++) indices[j] = indices[j - 1] + 1;
}
}
//#endregion
exports.combinations = combinations;

View file

@ -0,0 +1,53 @@
//#region src/array/combinations.ts
/**
* Returns all `r`-length combinations of elements from the input array.
*
* Combinations are emitted in lexicographic order based on the position of elements in the input array.
* Elements are treated as unique by position, not by value, so duplicates in the input may produce
* combinations that look identical.
*
* The number of combinations is `n! / r! / (n - r)!` when `0 <= r <= n`, and zero when `r > n`.
*
* @template T
* @param arr - The input array.
* @param r - The length of each combination. Must be a non-negative integer.
* @returns An array of `r`-length combinations.
* @throws {Error} If `r` is not a non-negative integer.
*
* @example
* combinations(['A', 'B', 'C', 'D'], 2);
* // => [['A','B'], ['A','C'], ['A','D'], ['B','C'], ['B','D'], ['C','D']]
*
* @example
* combinations([1, 2, 3, 4], 3);
* // => [[1,2,3], [1,2,4], [1,3,4], [2,3,4]]
*
* @example
* combinations([1, 2, 3], 0);
* // => [[]]
*
* @example
* combinations([1, 2], 5);
* // => []
*/
function combinations(arr, r) {
if (!Number.isInteger(r) || r < 0) throw new Error("r must be a non-negative integer.");
const n = arr.length;
if (r > n) return [];
if (r === 0) return [[]];
const indices = Array(r);
for (let i = 0; i < r; i++) indices[i] = i;
const result = [];
while (true) {
const tuple = Array(r);
for (let i = 0; i < r; i++) tuple[i] = arr[indices[i]];
result.push(tuple);
let i = r - 1;
while (i >= 0 && indices[i] === i + n - r) i--;
if (i < 0) return result;
indices[i]++;
for (let j = i + 1; j < r; j++) indices[j] = indices[j - 1] + 1;
}
}
//#endregion
export { combinations };

View file

@ -0,0 +1,16 @@
//#region src/array/compact.d.ts
type NotFalsey<T> = Exclude<T, false | null | 0 | 0n | '' | undefined>;
/**
* Removes falsey values (false, null, 0, -0, 0n, '', undefined, NaN) from an array.
*
* @template T - The type of elements in the array.
* @param arr - The input array to remove falsey values.
* @returns A new array with all falsey values removed.
*
* @example
* compact([0, -0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
* Returns: [1, 2, 3, 4, 5]
*/
declare function compact<T>(arr: readonly T[]): Array<NotFalsey<T>>;
//#endregion
export { compact };

View file

@ -0,0 +1,16 @@
//#region src/array/compact.d.ts
type NotFalsey<T> = Exclude<T, false | null | 0 | 0n | '' | undefined>;
/**
* Removes falsey values (false, null, 0, -0, 0n, '', undefined, NaN) from an array.
*
* @template T - The type of elements in the array.
* @param arr - The input array to remove falsey values.
* @returns A new array with all falsey values removed.
*
* @example
* compact([0, -0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
* Returns: [1, 2, 3, 4, 5]
*/
declare function compact<T>(arr: readonly T[]): Array<NotFalsey<T>>;
//#endregion
export { compact };

22
frontend/node_modules/es-toolkit/dist/array/compact.js generated vendored Normal file
View file

@ -0,0 +1,22 @@
//#region src/array/compact.ts
/**
* Removes falsey values (false, null, 0, -0, 0n, '', undefined, NaN) from an array.
*
* @template T - The type of elements in the array.
* @param arr - The input array to remove falsey values.
* @returns A new array with all falsey values removed.
*
* @example
* compact([0, -0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
* Returns: [1, 2, 3, 4, 5]
*/
function compact(arr) {
const result = [];
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
if (item) result.push(item);
}
return result;
}
//#endregion
exports.compact = compact;

View file

@ -0,0 +1,22 @@
//#region src/array/compact.ts
/**
* Removes falsey values (false, null, 0, -0, 0n, '', undefined, NaN) from an array.
*
* @template T - The type of elements in the array.
* @param arr - The input array to remove falsey values.
* @returns A new array with all falsey values removed.
*
* @example
* compact([0, -0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
* Returns: [1, 2, 3, 4, 5]
*/
function compact(arr) {
const result = [];
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
if (item) result.push(item);
}
return result;
}
//#endregion
export { compact };

View file

@ -0,0 +1,37 @@
//#region src/array/countBy.d.ts
/**
* Count the occurrences of each item in an array
* based on a transformation function.
*
* This function takes an array and a transformation function
* that converts each item in the array to a key. It then
* counts the occurrences of each transformed item and returns
* an object with the transformed items as keys and the counts
* as values.
*
* @template T - The type of the items in the input array.
* @template K - The type of keys.
* @param arr - The input array to count occurrences.
* @param mapper - The transformation function that maps each item, its index, and the array to a key.
* @returns An object containing the transformed items as keys and the
* counts as values.
*
* @example
* const array = ['a', 'b', 'c', 'a', 'b', 'a'];
* const result = countBy(array, x => x);
* // result will be { a: 3, b: 2, c: 1 }
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = countBy(array, item => item % 2 === 0 ? 'even' : 'odd');
* // result will be { odd: 3, even: 2 }
*
* @example
* // Using index parameter
* const array = ['a', 'b', 'c', 'd'];
* const result = countBy(array, (item, index) => index < 2 ? 'first' : 'rest');
* // result will be { first: 2, rest: 2 }
*/
declare function countBy<T, K extends PropertyKey>(arr: readonly T[], mapper: (item: T, index: number, array: readonly T[]) => K): Record<K, number>;
//#endregion
export { countBy };

View file

@ -0,0 +1,37 @@
//#region src/array/countBy.d.ts
/**
* Count the occurrences of each item in an array
* based on a transformation function.
*
* This function takes an array and a transformation function
* that converts each item in the array to a key. It then
* counts the occurrences of each transformed item and returns
* an object with the transformed items as keys and the counts
* as values.
*
* @template T - The type of the items in the input array.
* @template K - The type of keys.
* @param arr - The input array to count occurrences.
* @param mapper - The transformation function that maps each item, its index, and the array to a key.
* @returns An object containing the transformed items as keys and the
* counts as values.
*
* @example
* const array = ['a', 'b', 'c', 'a', 'b', 'a'];
* const result = countBy(array, x => x);
* // result will be { a: 3, b: 2, c: 1 }
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = countBy(array, item => item % 2 === 0 ? 'even' : 'odd');
* // result will be { odd: 3, even: 2 }
*
* @example
* // Using index parameter
* const array = ['a', 'b', 'c', 'd'];
* const result = countBy(array, (item, index) => index < 2 ? 'first' : 'rest');
* // result will be { first: 2, rest: 2 }
*/
declare function countBy<T, K extends PropertyKey>(arr: readonly T[], mapper: (item: T, index: number, array: readonly T[]) => K): Record<K, number>;
//#endregion
export { countBy };

45
frontend/node_modules/es-toolkit/dist/array/countBy.js generated vendored Normal file
View file

@ -0,0 +1,45 @@
//#region src/array/countBy.ts
/**
* Count the occurrences of each item in an array
* based on a transformation function.
*
* This function takes an array and a transformation function
* that converts each item in the array to a key. It then
* counts the occurrences of each transformed item and returns
* an object with the transformed items as keys and the counts
* as values.
*
* @template T - The type of the items in the input array.
* @template K - The type of keys.
* @param arr - The input array to count occurrences.
* @param mapper - The transformation function that maps each item, its index, and the array to a key.
* @returns An object containing the transformed items as keys and the
* counts as values.
*
* @example
* const array = ['a', 'b', 'c', 'a', 'b', 'a'];
* const result = countBy(array, x => x);
* // result will be { a: 3, b: 2, c: 1 }
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = countBy(array, item => item % 2 === 0 ? 'even' : 'odd');
* // result will be { odd: 3, even: 2 }
*
* @example
* // Using index parameter
* const array = ['a', 'b', 'c', 'd'];
* const result = countBy(array, (item, index) => index < 2 ? 'first' : 'rest');
* // result will be { first: 2, rest: 2 }
*/
function countBy(arr, mapper) {
const result = {};
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
const key = mapper(item, i, arr);
result[key] = (result[key] ?? 0) + 1;
}
return result;
}
//#endregion
exports.countBy = countBy;

View file

@ -0,0 +1,45 @@
//#region src/array/countBy.ts
/**
* Count the occurrences of each item in an array
* based on a transformation function.
*
* This function takes an array and a transformation function
* that converts each item in the array to a key. It then
* counts the occurrences of each transformed item and returns
* an object with the transformed items as keys and the counts
* as values.
*
* @template T - The type of the items in the input array.
* @template K - The type of keys.
* @param arr - The input array to count occurrences.
* @param mapper - The transformation function that maps each item, its index, and the array to a key.
* @returns An object containing the transformed items as keys and the
* counts as values.
*
* @example
* const array = ['a', 'b', 'c', 'a', 'b', 'a'];
* const result = countBy(array, x => x);
* // result will be { a: 3, b: 2, c: 1 }
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = countBy(array, item => item % 2 === 0 ? 'even' : 'odd');
* // result will be { odd: 3, even: 2 }
*
* @example
* // Using index parameter
* const array = ['a', 'b', 'c', 'd'];
* const result = countBy(array, (item, index) => index < 2 ? 'first' : 'rest');
* // result will be { first: 2, rest: 2 }
*/
function countBy(arr, mapper) {
const result = {};
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
const key = mapper(item, i, arr);
result[key] = (result[key] ?? 0) + 1;
}
return result;
}
//#endregion
export { countBy };

View file

@ -0,0 +1,26 @@
//#region src/array/difference.d.ts
/**
* Computes the difference between two arrays.
*
* This function takes two arrays and returns a new array containing the elements
* that are present in the first array but not in the second array. It effectively
* filters out any elements from the first array that also appear in the second array.
*
* @template T
* @param firstArr - The array from which to derive the difference. This is the primary array
* from which elements will be compared and filtered.
* @param secondArr - The array containing elements to be excluded from the first array.
* Each element in this array will be checked against the first array, and if a match is found,
* that element will be excluded from the result.
* @returns A new array containing the elements that are present in the first array but not
* in the second array.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const result = difference(array1, array2);
* // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
*/
declare function difference<T>(firstArr: readonly T[], secondArr: readonly T[]): T[];
//#endregion
export { difference };

View file

@ -0,0 +1,26 @@
//#region src/array/difference.d.ts
/**
* Computes the difference between two arrays.
*
* This function takes two arrays and returns a new array containing the elements
* that are present in the first array but not in the second array. It effectively
* filters out any elements from the first array that also appear in the second array.
*
* @template T
* @param firstArr - The array from which to derive the difference. This is the primary array
* from which elements will be compared and filtered.
* @param secondArr - The array containing elements to be excluded from the first array.
* Each element in this array will be checked against the first array, and if a match is found,
* that element will be excluded from the result.
* @returns A new array containing the elements that are present in the first array but not
* in the second array.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const result = difference(array1, array2);
* // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
*/
declare function difference<T>(firstArr: readonly T[], secondArr: readonly T[]): T[];
//#endregion
export { difference };

View file

@ -0,0 +1,29 @@
//#region src/array/difference.ts
/**
* Computes the difference between two arrays.
*
* This function takes two arrays and returns a new array containing the elements
* that are present in the first array but not in the second array. It effectively
* filters out any elements from the first array that also appear in the second array.
*
* @template T
* @param firstArr - The array from which to derive the difference. This is the primary array
* from which elements will be compared and filtered.
* @param secondArr - The array containing elements to be excluded from the first array.
* Each element in this array will be checked against the first array, and if a match is found,
* that element will be excluded from the result.
* @returns A new array containing the elements that are present in the first array but not
* in the second array.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const result = difference(array1, array2);
* // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
*/
function difference(firstArr, secondArr) {
const secondSet = new Set(secondArr);
return firstArr.filter((item) => !secondSet.has(item));
}
//#endregion
exports.difference = difference;

View file

@ -0,0 +1,29 @@
//#region src/array/difference.ts
/**
* Computes the difference between two arrays.
*
* This function takes two arrays and returns a new array containing the elements
* that are present in the first array but not in the second array. It effectively
* filters out any elements from the first array that also appear in the second array.
*
* @template T
* @param firstArr - The array from which to derive the difference. This is the primary array
* from which elements will be compared and filtered.
* @param secondArr - The array containing elements to be excluded from the first array.
* Each element in this array will be checked against the first array, and if a match is found,
* that element will be excluded from the result.
* @returns A new array containing the elements that are present in the first array but not
* in the second array.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const result = difference(array1, array2);
* // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
*/
function difference(firstArr, secondArr) {
const secondSet = new Set(secondArr);
return firstArr.filter((item) => !secondSet.has(item));
}
//#endregion
export { difference };

View file

@ -0,0 +1,36 @@
//#region src/array/differenceBy.d.ts
/**
* Computes the difference between two arrays after mapping their elements through a provided function.
*
* This function takes two arrays and a mapper function. It returns a new array containing the elements
* that are present in the first array but not in the second array, based on the identity calculated
* by the mapper function.
*
* Essentially, it filters out any elements from the first array that, when
* mapped, match an element in the mapped version of the second array.
*
* @template T, U
* @param firstArr - The primary array from which to derive the difference.
* @param secondArr - The array containing elements to be excluded from the first array.
* @param mapper - The function to map the elements of both arrays. This function
* is applied to each element in both arrays, and the comparison is made based on the mapped values.
* @returns A new array containing the elements from the first array that do not have a corresponding
* mapped identity in the second array.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const mapper = item => item.id;
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [2, 4];
* const mapper = item => (typeof item === 'object' ? item.id : item);
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since 2 is present in both arrays after mapping, and is excluded from the result.
*/
declare function differenceBy<T, U>(firstArr: readonly T[], secondArr: readonly U[], mapper: (value: T | U) => unknown): T[];
//#endregion
export { differenceBy };

View file

@ -0,0 +1,36 @@
//#region src/array/differenceBy.d.ts
/**
* Computes the difference between two arrays after mapping their elements through a provided function.
*
* This function takes two arrays and a mapper function. It returns a new array containing the elements
* that are present in the first array but not in the second array, based on the identity calculated
* by the mapper function.
*
* Essentially, it filters out any elements from the first array that, when
* mapped, match an element in the mapped version of the second array.
*
* @template T, U
* @param firstArr - The primary array from which to derive the difference.
* @param secondArr - The array containing elements to be excluded from the first array.
* @param mapper - The function to map the elements of both arrays. This function
* is applied to each element in both arrays, and the comparison is made based on the mapped values.
* @returns A new array containing the elements from the first array that do not have a corresponding
* mapped identity in the second array.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const mapper = item => item.id;
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [2, 4];
* const mapper = item => (typeof item === 'object' ? item.id : item);
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since 2 is present in both arrays after mapping, and is excluded from the result.
*/
declare function differenceBy<T, U>(firstArr: readonly T[], secondArr: readonly U[], mapper: (value: T | U) => unknown): T[];
//#endregion
export { differenceBy };

View file

@ -0,0 +1,41 @@
//#region src/array/differenceBy.ts
/**
* Computes the difference between two arrays after mapping their elements through a provided function.
*
* This function takes two arrays and a mapper function. It returns a new array containing the elements
* that are present in the first array but not in the second array, based on the identity calculated
* by the mapper function.
*
* Essentially, it filters out any elements from the first array that, when
* mapped, match an element in the mapped version of the second array.
*
* @template T, U
* @param firstArr - The primary array from which to derive the difference.
* @param secondArr - The array containing elements to be excluded from the first array.
* @param mapper - The function to map the elements of both arrays. This function
* is applied to each element in both arrays, and the comparison is made based on the mapped values.
* @returns A new array containing the elements from the first array that do not have a corresponding
* mapped identity in the second array.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const mapper = item => item.id;
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [2, 4];
* const mapper = item => (typeof item === 'object' ? item.id : item);
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since 2 is present in both arrays after mapping, and is excluded from the result.
*/
function differenceBy(firstArr, secondArr, mapper) {
const mappedSecondSet = new Set(secondArr.map((item) => mapper(item)));
return firstArr.filter((item) => {
return !mappedSecondSet.has(mapper(item));
});
}
//#endregion
exports.differenceBy = differenceBy;

View file

@ -0,0 +1,41 @@
//#region src/array/differenceBy.ts
/**
* Computes the difference between two arrays after mapping their elements through a provided function.
*
* This function takes two arrays and a mapper function. It returns a new array containing the elements
* that are present in the first array but not in the second array, based on the identity calculated
* by the mapper function.
*
* Essentially, it filters out any elements from the first array that, when
* mapped, match an element in the mapped version of the second array.
*
* @template T, U
* @param firstArr - The primary array from which to derive the difference.
* @param secondArr - The array containing elements to be excluded from the first array.
* @param mapper - The function to map the elements of both arrays. This function
* is applied to each element in both arrays, and the comparison is made based on the mapped values.
* @returns A new array containing the elements from the first array that do not have a corresponding
* mapped identity in the second array.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const mapper = item => item.id;
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [2, 4];
* const mapper = item => (typeof item === 'object' ? item.id : item);
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since 2 is present in both arrays after mapping, and is excluded from the result.
*/
function differenceBy(firstArr, secondArr, mapper) {
const mappedSecondSet = new Set(secondArr.map((item) => mapper(item)));
return firstArr.filter((item) => {
return !mappedSecondSet.has(mapper(item));
});
}
//#endregion
export { differenceBy };

View file

@ -0,0 +1,32 @@
//#region src/array/differenceWith.d.ts
/**
* Computes the difference between two arrays based on a custom equality function.
*
* This function takes two arrays and a custom comparison function. It returns a new array containing
* the elements that are present in the first array but not in the second array. The comparison to determine
* if elements are equal is made using the provided custom function.
*
* @template T, U
* @param firstArr - The array from which to get the difference.
* @param secondArr - The array containing elements to exclude from the first array.
* @param areItemsEqual - A function to determine if two items are equal.
* @returns A new array containing the elements from the first array that do not match any elements in the second array
* according to the custom equality function.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [2, 4];
* const areItemsEqual = (a, b) => a.id === b;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the element with id 2 is considered equal to the second array's element and is excluded from the result.
*/
declare function differenceWith<T, U>(firstArr: readonly T[], secondArr: readonly U[], areItemsEqual: (x: T, y: U) => boolean): T[];
//#endregion
export { differenceWith };

View file

@ -0,0 +1,32 @@
//#region src/array/differenceWith.d.ts
/**
* Computes the difference between two arrays based on a custom equality function.
*
* This function takes two arrays and a custom comparison function. It returns a new array containing
* the elements that are present in the first array but not in the second array. The comparison to determine
* if elements are equal is made using the provided custom function.
*
* @template T, U
* @param firstArr - The array from which to get the difference.
* @param secondArr - The array containing elements to exclude from the first array.
* @param areItemsEqual - A function to determine if two items are equal.
* @returns A new array containing the elements from the first array that do not match any elements in the second array
* according to the custom equality function.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [2, 4];
* const areItemsEqual = (a, b) => a.id === b;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the element with id 2 is considered equal to the second array's element and is excluded from the result.
*/
declare function differenceWith<T, U>(firstArr: readonly T[], secondArr: readonly U[], areItemsEqual: (x: T, y: U) => boolean): T[];
//#endregion
export { differenceWith };

View file

@ -0,0 +1,38 @@
//#region src/array/differenceWith.ts
/**
* Computes the difference between two arrays based on a custom equality function.
*
* This function takes two arrays and a custom comparison function. It returns a new array containing
* the elements that are present in the first array but not in the second array. The comparison to determine
* if elements are equal is made using the provided custom function.
*
* @template T, U
* @param firstArr - The array from which to get the difference.
* @param secondArr - The array containing elements to exclude from the first array.
* @param areItemsEqual - A function to determine if two items are equal.
* @returns A new array containing the elements from the first array that do not match any elements in the second array
* according to the custom equality function.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [2, 4];
* const areItemsEqual = (a, b) => a.id === b;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the element with id 2 is considered equal to the second array's element and is excluded from the result.
*/
function differenceWith(firstArr, secondArr, areItemsEqual) {
return firstArr.filter((firstItem) => {
return secondArr.every((secondItem) => {
return !areItemsEqual(firstItem, secondItem);
});
});
}
//#endregion
exports.differenceWith = differenceWith;

View file

@ -0,0 +1,38 @@
//#region src/array/differenceWith.ts
/**
* Computes the difference between two arrays based on a custom equality function.
*
* This function takes two arrays and a custom comparison function. It returns a new array containing
* the elements that are present in the first array but not in the second array. The comparison to determine
* if elements are equal is made using the provided custom function.
*
* @template T, U
* @param firstArr - The array from which to get the difference.
* @param secondArr - The array containing elements to exclude from the first array.
* @param areItemsEqual - A function to determine if two items are equal.
* @returns A new array containing the elements from the first array that do not match any elements in the second array
* according to the custom equality function.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [2, 4];
* const areItemsEqual = (a, b) => a.id === b;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the element with id 2 is considered equal to the second array's element and is excluded from the result.
*/
function differenceWith(firstArr, secondArr, areItemsEqual) {
return firstArr.filter((firstItem) => {
return secondArr.every((secondItem) => {
return !areItemsEqual(firstItem, secondItem);
});
});
}
//#endregion
export { differenceWith };

20
frontend/node_modules/es-toolkit/dist/array/drop.d.mts generated vendored Normal file
View file

@ -0,0 +1,20 @@
//#region src/array/drop.d.ts
/**
* Removes a specified number of elements from the beginning of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the start.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the beginning of the array.
* @returns A new array with the specified number of elements removed from the start.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = drop(array, 2);
* // result will be [3, 4, 5] since the first two elements are dropped.
*/
declare function drop<T>(arr: readonly T[], itemsCount: number): T[];
//#endregion
export { drop };

20
frontend/node_modules/es-toolkit/dist/array/drop.d.ts generated vendored Normal file
View file

@ -0,0 +1,20 @@
//#region src/array/drop.d.ts
/**
* Removes a specified number of elements from the beginning of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the start.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the beginning of the array.
* @returns A new array with the specified number of elements removed from the start.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = drop(array, 2);
* // result will be [3, 4, 5] since the first two elements are dropped.
*/
declare function drop<T>(arr: readonly T[], itemsCount: number): T[];
//#endregion
export { drop };

23
frontend/node_modules/es-toolkit/dist/array/drop.js generated vendored Normal file
View file

@ -0,0 +1,23 @@
//#region src/array/drop.ts
/**
* Removes a specified number of elements from the beginning of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the start.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the beginning of the array.
* @returns A new array with the specified number of elements removed from the start.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = drop(array, 2);
* // result will be [3, 4, 5] since the first two elements are dropped.
*/
function drop(arr, itemsCount) {
itemsCount = Math.max(itemsCount, 0);
return arr.slice(itemsCount);
}
//#endregion
exports.drop = drop;

23
frontend/node_modules/es-toolkit/dist/array/drop.mjs generated vendored Normal file
View file

@ -0,0 +1,23 @@
//#region src/array/drop.ts
/**
* Removes a specified number of elements from the beginning of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the start.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the beginning of the array.
* @returns A new array with the specified number of elements removed from the start.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = drop(array, 2);
* // result will be [3, 4, 5] since the first two elements are dropped.
*/
function drop(arr, itemsCount) {
itemsCount = Math.max(itemsCount, 0);
return arr.slice(itemsCount);
}
//#endregion
export { drop };

View file

@ -0,0 +1,20 @@
//#region src/array/dropRight.d.ts
/**
* Removes a specified number of elements from the end of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the end.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the end of the array.
* @returns A new array with the specified number of elements removed from the end.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRight(array, 2);
* // result will be [1, 2, 3] since the last two elements are dropped.
*/
declare function dropRight<T>(arr: readonly T[], itemsCount: number): T[];
//#endregion
export { dropRight };

View file

@ -0,0 +1,20 @@
//#region src/array/dropRight.d.ts
/**
* Removes a specified number of elements from the end of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the end.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the end of the array.
* @returns A new array with the specified number of elements removed from the end.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRight(array, 2);
* // result will be [1, 2, 3] since the last two elements are dropped.
*/
declare function dropRight<T>(arr: readonly T[], itemsCount: number): T[];
//#endregion
export { dropRight };

View file

@ -0,0 +1,24 @@
//#region src/array/dropRight.ts
/**
* Removes a specified number of elements from the end of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the end.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the end of the array.
* @returns A new array with the specified number of elements removed from the end.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRight(array, 2);
* // result will be [1, 2, 3] since the last two elements are dropped.
*/
function dropRight(arr, itemsCount) {
itemsCount = Math.min(-itemsCount, 0);
if (itemsCount === 0) return arr.slice();
return arr.slice(0, itemsCount);
}
//#endregion
exports.dropRight = dropRight;

View file

@ -0,0 +1,24 @@
//#region src/array/dropRight.ts
/**
* Removes a specified number of elements from the end of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the end.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the end of the array.
* @returns A new array with the specified number of elements removed from the end.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRight(array, 2);
* // result will be [1, 2, 3] since the last two elements are dropped.
*/
function dropRight(arr, itemsCount) {
itemsCount = Math.min(-itemsCount, 0);
if (itemsCount === 0) return arr.slice();
return arr.slice(0, itemsCount);
}
//#endregion
export { dropRight };

View file

@ -0,0 +1,22 @@
//#region src/array/dropRightWhile.d.ts
/**
* Removes elements from the end of an array until the predicate returns false.
*
* This function iterates over an array from the end and drops elements until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element from the end,
* and dropping continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRightWhile(array, x => x > 3);
* // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.
*/
declare function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T, index: number, arr: readonly T[]) => boolean): T[];
//#endregion
export { dropRightWhile };

View file

@ -0,0 +1,22 @@
//#region src/array/dropRightWhile.d.ts
/**
* Removes elements from the end of an array until the predicate returns false.
*
* This function iterates over an array from the end and drops elements until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element from the end,
* and dropping continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRightWhile(array, x => x > 3);
* // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.
*/
declare function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T, index: number, arr: readonly T[]) => boolean): T[];
//#endregion
export { dropRightWhile };

View file

@ -0,0 +1,25 @@
//#region src/array/dropRightWhile.ts
/**
* Removes elements from the end of an array until the predicate returns false.
*
* This function iterates over an array from the end and drops elements until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element from the end,
* and dropping continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRightWhile(array, x => x > 3);
* // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.
*/
function dropRightWhile(arr, canContinueDropping) {
for (let i = arr.length - 1; i >= 0; i--) if (!canContinueDropping(arr[i], i, arr)) return arr.slice(0, i + 1);
return [];
}
//#endregion
exports.dropRightWhile = dropRightWhile;

View file

@ -0,0 +1,25 @@
//#region src/array/dropRightWhile.ts
/**
* Removes elements from the end of an array until the predicate returns false.
*
* This function iterates over an array from the end and drops elements until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element from the end,
* and dropping continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRightWhile(array, x => x > 3);
* // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.
*/
function dropRightWhile(arr, canContinueDropping) {
for (let i = arr.length - 1; i >= 0; i--) if (!canContinueDropping(arr[i], i, arr)) return arr.slice(0, i + 1);
return [];
}
//#endregion
export { dropRightWhile };

View file

@ -0,0 +1,22 @@
//#region src/array/dropWhile.d.ts
/**
* Removes elements from the beginning of an array until the predicate returns false.
*
* This function iterates over an array and drops elements from the start until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element, and dropping
* continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropWhile(array, x => x < 3);
* // result will be [3, 4, 5] since elements less than 3 are dropped.
*/
declare function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T, index: number, arr: readonly T[]) => boolean): T[];
//#endregion
export { dropWhile };

View file

@ -0,0 +1,22 @@
//#region src/array/dropWhile.d.ts
/**
* Removes elements from the beginning of an array until the predicate returns false.
*
* This function iterates over an array and drops elements from the start until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element, and dropping
* continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropWhile(array, x => x < 3);
* // result will be [3, 4, 5] since elements less than 3 are dropped.
*/
declare function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T, index: number, arr: readonly T[]) => boolean): T[];
//#endregion
export { dropWhile };

View file

@ -0,0 +1,26 @@
//#region src/array/dropWhile.ts
/**
* Removes elements from the beginning of an array until the predicate returns false.
*
* This function iterates over an array and drops elements from the start until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element, and dropping
* continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropWhile(array, x => x < 3);
* // result will be [3, 4, 5] since elements less than 3 are dropped.
*/
function dropWhile(arr, canContinueDropping) {
const dropEndIndex = arr.findIndex((item, index, arr) => !canContinueDropping(item, index, arr));
if (dropEndIndex === -1) return [];
return arr.slice(dropEndIndex);
}
//#endregion
exports.dropWhile = dropWhile;

View file

@ -0,0 +1,26 @@
//#region src/array/dropWhile.ts
/**
* Removes elements from the beginning of an array until the predicate returns false.
*
* This function iterates over an array and drops elements from the start until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to drop elements.
* @param canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element, and dropping
* continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropWhile(array, x => x < 3);
* // result will be [3, 4, 5] since elements less than 3 are dropped.
*/
function dropWhile(arr, canContinueDropping) {
const dropEndIndex = arr.findIndex((item, index, arr) => !canContinueDropping(item, index, arr));
if (dropEndIndex === -1) return [];
return arr.slice(dropEndIndex);
}
//#endregion
export { dropWhile };

86
frontend/node_modules/es-toolkit/dist/array/fill.d.mts generated vendored Normal file
View file

@ -0,0 +1,86 @@
//#region src/array/fill.d.ts
/**
* Fills the whole array with a specified value.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T - The type of the value to fill the array with.
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
declare function fill<T>(array: unknown[], value: T): T[];
/**
* Fills elements of an array with a specified value from the start position up to the end of the array.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T - The type of elements in the original array.
* @template U - The type of the value to fill the array with.
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @param [start=0] - The start position. Defaults to 0.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
declare function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;
/**
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T - The type of elements in the original array.
* @template U - The type of the value to fill the array with.
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @param [start=0] - The start position. Defaults to 0.
* @param [end=arr.length] - The end position. Defaults to the array's length.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
declare function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;
//#endregion
export { fill };

86
frontend/node_modules/es-toolkit/dist/array/fill.d.ts generated vendored Normal file
View file

@ -0,0 +1,86 @@
//#region src/array/fill.d.ts
/**
* Fills the whole array with a specified value.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T - The type of the value to fill the array with.
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
declare function fill<T>(array: unknown[], value: T): T[];
/**
* Fills elements of an array with a specified value from the start position up to the end of the array.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T - The type of elements in the original array.
* @template U - The type of the value to fill the array with.
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @param [start=0] - The start position. Defaults to 0.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
declare function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;
/**
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T - The type of elements in the original array.
* @template U - The type of the value to fill the array with.
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @param [start=0] - The start position. Defaults to 0.
* @param [end=arr.length] - The end position. Defaults to the array's length.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
declare function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;
//#endregion
export { fill };

38
frontend/node_modules/es-toolkit/dist/array/fill.js generated vendored Normal file
View file

@ -0,0 +1,38 @@
//#region src/array/fill.ts
/**
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T - The type of elements in the original array.
* @template U - The type of the value to fill the array with.
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @param [start=0] - The start position. Defaults to 0.
* @param [end=arr.length] - The end position. Defaults to the array's length.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
function fill(array, value, start = 0, end = array.length) {
const length = array.length;
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
for (let i = finalStart; i < finalEnd; i++) array[i] = value;
return array;
}
//#endregion
exports.fill = fill;

38
frontend/node_modules/es-toolkit/dist/array/fill.mjs generated vendored Normal file
View file

@ -0,0 +1,38 @@
//#region src/array/fill.ts
/**
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T - The type of elements in the original array.
* @template U - The type of the value to fill the array with.
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @param [start=0] - The start position. Defaults to 0.
* @param [end=arr.length] - The end position. Defaults to the array's length.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
function fill(array, value, start = 0, end = array.length) {
const length = array.length;
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
for (let i = finalStart; i < finalEnd; i++) array[i] = value;
return array;
}
//#endregion
export { fill };

View file

@ -0,0 +1,36 @@
//#region src/array/filterAsync.d.ts
interface FilterAsyncOptions {
concurrency?: number;
}
/**
* Filters an array asynchronously using an async predicate function.
*
* Returns a promise that resolves to a new array containing only the elements
* for which the predicate function returns a truthy value.
*
* @template T - The type of elements in the array.
* @param array The array to filter.
* @param predicate An async function that tests each element.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves to the filtered array.
* @example
* const users = [{ id: 1, active: true }, { id: 2, active: false }, { id: 3, active: true }];
* const activeUsers = await filterAsync(users, async (user) => {
* return await checkUserStatus(user.id);
* });
* // Returns: [{ id: 1, active: true }, { id: 3, active: true }]
*
* @example
* // With concurrency limit
* const numbers = [1, 2, 3, 4, 5];
* const evenNumbers = await filterAsync(
* numbers,
* async (n) => await isEvenAsync(n),
* { concurrency: 2 }
* );
* // Processes at most 2 operations concurrently
*/
declare function filterAsync<T>(array: readonly T[], predicate: (item: T, index: number, array: readonly T[]) => Promise<boolean>, options?: FilterAsyncOptions): Promise<T[]>;
//#endregion
export { filterAsync };

View file

@ -0,0 +1,36 @@
//#region src/array/filterAsync.d.ts
interface FilterAsyncOptions {
concurrency?: number;
}
/**
* Filters an array asynchronously using an async predicate function.
*
* Returns a promise that resolves to a new array containing only the elements
* for which the predicate function returns a truthy value.
*
* @template T - The type of elements in the array.
* @param array The array to filter.
* @param predicate An async function that tests each element.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves to the filtered array.
* @example
* const users = [{ id: 1, active: true }, { id: 2, active: false }, { id: 3, active: true }];
* const activeUsers = await filterAsync(users, async (user) => {
* return await checkUserStatus(user.id);
* });
* // Returns: [{ id: 1, active: true }, { id: 3, active: true }]
*
* @example
* // With concurrency limit
* const numbers = [1, 2, 3, 4, 5];
* const evenNumbers = await filterAsync(
* numbers,
* async (n) => await isEvenAsync(n),
* { concurrency: 2 }
* );
* // Processes at most 2 operations concurrently
*/
declare function filterAsync<T>(array: readonly T[], predicate: (item: T, index: number, array: readonly T[]) => Promise<boolean>, options?: FilterAsyncOptions): Promise<T[]>;
//#endregion
export { filterAsync };

View file

@ -0,0 +1,38 @@
const require_limitAsync = require("./limitAsync.js");
//#region src/array/filterAsync.ts
/**
* Filters an array asynchronously using an async predicate function.
*
* Returns a promise that resolves to a new array containing only the elements
* for which the predicate function returns a truthy value.
*
* @template T - The type of elements in the array.
* @param array The array to filter.
* @param predicate An async function that tests each element.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves to the filtered array.
* @example
* const users = [{ id: 1, active: true }, { id: 2, active: false }, { id: 3, active: true }];
* const activeUsers = await filterAsync(users, async (user) => {
* return await checkUserStatus(user.id);
* });
* // Returns: [{ id: 1, active: true }, { id: 3, active: true }]
*
* @example
* // With concurrency limit
* const numbers = [1, 2, 3, 4, 5];
* const evenNumbers = await filterAsync(
* numbers,
* async (n) => await isEvenAsync(n),
* { concurrency: 2 }
* );
* // Processes at most 2 operations concurrently
*/
async function filterAsync(array, predicate, options) {
if (options?.concurrency != null) predicate = require_limitAsync.limitAsync(predicate, options.concurrency);
const results = await Promise.all(array.map(predicate));
return array.filter((_, index) => results[index]);
}
//#endregion
exports.filterAsync = filterAsync;

View file

@ -0,0 +1,38 @@
import { limitAsync } from "./limitAsync.mjs";
//#region src/array/filterAsync.ts
/**
* Filters an array asynchronously using an async predicate function.
*
* Returns a promise that resolves to a new array containing only the elements
* for which the predicate function returns a truthy value.
*
* @template T - The type of elements in the array.
* @param array The array to filter.
* @param predicate An async function that tests each element.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves to the filtered array.
* @example
* const users = [{ id: 1, active: true }, { id: 2, active: false }, { id: 3, active: true }];
* const activeUsers = await filterAsync(users, async (user) => {
* return await checkUserStatus(user.id);
* });
* // Returns: [{ id: 1, active: true }, { id: 3, active: true }]
*
* @example
* // With concurrency limit
* const numbers = [1, 2, 3, 4, 5];
* const evenNumbers = await filterAsync(
* numbers,
* async (n) => await isEvenAsync(n),
* { concurrency: 2 }
* );
* // Processes at most 2 operations concurrently
*/
async function filterAsync(array, predicate, options) {
if (options?.concurrency != null) predicate = limitAsync(predicate, options.concurrency);
const results = await Promise.all(array.map(predicate));
return array.filter((_, index) => results[index]);
}
//#endregion
export { filterAsync };

View file

@ -0,0 +1,24 @@
//#region src/array/flatMap.d.ts
/**
* Maps each element in the array using the iteratee function and flattens the result up to the specified depth.
*
* @template T - The type of elements within the array.
* @template U - The type of elements within the returned array from the iteratee function.
* @template D - The depth to which the array should be flattened.
* @param arr - The array to flatten.
* @param iteratee - The function that produces the new array elements. It receives the element, its index, and the array.
* @param depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns The new array with the mapped and flattened elements.
*
* @example
* const arr = [1, 2, 3];
*
* flatMap(arr, (item: number) => [item, item]);
* // [1, 1, 2, 2, 3, 3]
*
* flatMap(arr, (item: number) => [[item, item]], 2);
* // [1, 1, 2, 2, 3, 3]
*/
declare function flatMap<T, U, D extends number = 1>(arr: readonly T[], iteratee: (item: T, index: number, array: readonly T[]) => U, depth?: D): Array<FlatArray<U[], D>>;
//#endregion
export { flatMap };

View file

@ -0,0 +1,24 @@
//#region src/array/flatMap.d.ts
/**
* Maps each element in the array using the iteratee function and flattens the result up to the specified depth.
*
* @template T - The type of elements within the array.
* @template U - The type of elements within the returned array from the iteratee function.
* @template D - The depth to which the array should be flattened.
* @param arr - The array to flatten.
* @param iteratee - The function that produces the new array elements. It receives the element, its index, and the array.
* @param depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns The new array with the mapped and flattened elements.
*
* @example
* const arr = [1, 2, 3];
*
* flatMap(arr, (item: number) => [item, item]);
* // [1, 1, 2, 2, 3, 3]
*
* flatMap(arr, (item: number) => [[item, item]], 2);
* // [1, 1, 2, 2, 3, 3]
*/
declare function flatMap<T, U, D extends number = 1>(arr: readonly T[], iteratee: (item: T, index: number, array: readonly T[]) => U, depth?: D): Array<FlatArray<U[], D>>;
//#endregion
export { flatMap };

27
frontend/node_modules/es-toolkit/dist/array/flatMap.js generated vendored Normal file
View file

@ -0,0 +1,27 @@
const require_flatten = require("./flatten.js");
//#region src/array/flatMap.ts
/**
* Maps each element in the array using the iteratee function and flattens the result up to the specified depth.
*
* @template T - The type of elements within the array.
* @template U - The type of elements within the returned array from the iteratee function.
* @template D - The depth to which the array should be flattened.
* @param arr - The array to flatten.
* @param iteratee - The function that produces the new array elements. It receives the element, its index, and the array.
* @param depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns The new array with the mapped and flattened elements.
*
* @example
* const arr = [1, 2, 3];
*
* flatMap(arr, (item: number) => [item, item]);
* // [1, 1, 2, 2, 3, 3]
*
* flatMap(arr, (item: number) => [[item, item]], 2);
* // [1, 1, 2, 2, 3, 3]
*/
function flatMap(arr, iteratee, depth = 1) {
return require_flatten.flatten(arr.map((item, index) => iteratee(item, index, arr)), depth);
}
//#endregion
exports.flatMap = flatMap;

View file

@ -0,0 +1,27 @@
import { flatten } from "./flatten.mjs";
//#region src/array/flatMap.ts
/**
* Maps each element in the array using the iteratee function and flattens the result up to the specified depth.
*
* @template T - The type of elements within the array.
* @template U - The type of elements within the returned array from the iteratee function.
* @template D - The depth to which the array should be flattened.
* @param arr - The array to flatten.
* @param iteratee - The function that produces the new array elements. It receives the element, its index, and the array.
* @param depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns The new array with the mapped and flattened elements.
*
* @example
* const arr = [1, 2, 3];
*
* flatMap(arr, (item: number) => [item, item]);
* // [1, 1, 2, 2, 3, 3]
*
* flatMap(arr, (item: number) => [[item, item]], 2);
* // [1, 1, 2, 2, 3, 3]
*/
function flatMap(arr, iteratee, depth = 1) {
return flatten(arr.map((item, index) => iteratee(item, index, arr)), depth);
}
//#endregion
export { flatMap };

View file

@ -0,0 +1,38 @@
//#region src/array/flatMapAsync.d.ts
interface FlatMapAsyncOptions {
concurrency?: number;
}
/**
* Maps each element in an array using an async callback function and flattens the result by one level.
*
* This is equivalent to calling `mapAsync` followed by `flat(1)`, but more efficient.
* Each callback should return an array, and all returned arrays are concatenated into
* a single output array.
*
* @template T - The type of elements in the input array.
* @template R - The type of elements in the arrays returned by the callback.
* @param array The array to transform.
* @param callback An async function that transforms each element into an array.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves to a flattened array of transformed values.
* @example
* const users = [{ id: 1 }, { id: 2 }];
* const allPosts = await flatMapAsync(users, async (user) => {
* return await fetchUserPosts(user.id);
* });
* // Returns: [post1, post2, post3, ...] (all posts from all users)
*
* @example
* // With concurrency limit
* const numbers = [1, 2, 3];
* const results = await flatMapAsync(
* numbers,
* async (n) => await fetchRelatedItems(n),
* { concurrency: 2 }
* );
* // Processes at most 2 operations concurrently
*/
declare function flatMapAsync<T, R>(array: readonly T[], callback: (item: T, index: number, array: readonly T[]) => Promise<R[]>, options?: FlatMapAsyncOptions): Promise<R[]>;
//#endregion
export { flatMapAsync };

View file

@ -0,0 +1,38 @@
//#region src/array/flatMapAsync.d.ts
interface FlatMapAsyncOptions {
concurrency?: number;
}
/**
* Maps each element in an array using an async callback function and flattens the result by one level.
*
* This is equivalent to calling `mapAsync` followed by `flat(1)`, but more efficient.
* Each callback should return an array, and all returned arrays are concatenated into
* a single output array.
*
* @template T - The type of elements in the input array.
* @template R - The type of elements in the arrays returned by the callback.
* @param array The array to transform.
* @param callback An async function that transforms each element into an array.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves to a flattened array of transformed values.
* @example
* const users = [{ id: 1 }, { id: 2 }];
* const allPosts = await flatMapAsync(users, async (user) => {
* return await fetchUserPosts(user.id);
* });
* // Returns: [post1, post2, post3, ...] (all posts from all users)
*
* @example
* // With concurrency limit
* const numbers = [1, 2, 3];
* const results = await flatMapAsync(
* numbers,
* async (n) => await fetchRelatedItems(n),
* { concurrency: 2 }
* );
* // Processes at most 2 operations concurrently
*/
declare function flatMapAsync<T, R>(array: readonly T[], callback: (item: T, index: number, array: readonly T[]) => Promise<R[]>, options?: FlatMapAsyncOptions): Promise<R[]>;
//#endregion
export { flatMapAsync };

View file

@ -0,0 +1,41 @@
const require_limitAsync = require("./limitAsync.js");
const require_flatten = require("./flatten.js");
//#region src/array/flatMapAsync.ts
/**
* Maps each element in an array using an async callback function and flattens the result by one level.
*
* This is equivalent to calling `mapAsync` followed by `flat(1)`, but more efficient.
* Each callback should return an array, and all returned arrays are concatenated into
* a single output array.
*
* @template T - The type of elements in the input array.
* @template R - The type of elements in the arrays returned by the callback.
* @param array The array to transform.
* @param callback An async function that transforms each element into an array.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves to a flattened array of transformed values.
* @example
* const users = [{ id: 1 }, { id: 2 }];
* const allPosts = await flatMapAsync(users, async (user) => {
* return await fetchUserPosts(user.id);
* });
* // Returns: [post1, post2, post3, ...] (all posts from all users)
*
* @example
* // With concurrency limit
* const numbers = [1, 2, 3];
* const results = await flatMapAsync(
* numbers,
* async (n) => await fetchRelatedItems(n),
* { concurrency: 2 }
* );
* // Processes at most 2 operations concurrently
*/
async function flatMapAsync(array, callback, options) {
if (options?.concurrency != null) callback = require_limitAsync.limitAsync(callback, options.concurrency);
const results = await Promise.all(array.map(callback));
return require_flatten.flatten(results);
}
//#endregion
exports.flatMapAsync = flatMapAsync;

View file

@ -0,0 +1,40 @@
import { limitAsync } from "./limitAsync.mjs";
import { flatten } from "./flatten.mjs";
//#region src/array/flatMapAsync.ts
/**
* Maps each element in an array using an async callback function and flattens the result by one level.
*
* This is equivalent to calling `mapAsync` followed by `flat(1)`, but more efficient.
* Each callback should return an array, and all returned arrays are concatenated into
* a single output array.
*
* @template T - The type of elements in the input array.
* @template R - The type of elements in the arrays returned by the callback.
* @param array The array to transform.
* @param callback An async function that transforms each element into an array.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves to a flattened array of transformed values.
* @example
* const users = [{ id: 1 }, { id: 2 }];
* const allPosts = await flatMapAsync(users, async (user) => {
* return await fetchUserPosts(user.id);
* });
* // Returns: [post1, post2, post3, ...] (all posts from all users)
*
* @example
* // With concurrency limit
* const numbers = [1, 2, 3];
* const results = await flatMapAsync(
* numbers,
* async (n) => await fetchRelatedItems(n),
* { concurrency: 2 }
* );
* // Processes at most 2 operations concurrently
*/
async function flatMapAsync(array, callback, options) {
if (options?.concurrency != null) callback = limitAsync(callback, options.concurrency);
return flatten(await Promise.all(array.map(callback)));
}
//#endregion
export { flatMapAsync };

View file

@ -0,0 +1,19 @@
import { ExtractNestedArrayType } from "./flattenDeep.mjs";
//#region src/array/flatMapDeep.d.ts
/**
* Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.
*
* @template T - The type of elements within the array.
* @template U - The type of elements within the returned array from the iteratee function.
* @param arr - The array to flatten.
* @param iteratee - The function that produces the new array elements. It receives the element, its index, and the array.
* @returns A new array that has been flattened.
*
* @example
* const result = flatMapDeep([1, 2, 3], n => [[n, n]]);
* // [1, 1, 2, 2, 3, 3]
*/
declare function flatMapDeep<T, U>(arr: readonly T[], iteratee: (item: T, index: number, array: readonly T[]) => U): Array<ExtractNestedArrayType<U>>;
//#endregion
export { flatMapDeep };

View file

@ -0,0 +1,19 @@
import { ExtractNestedArrayType } from "./flattenDeep.js";
//#region src/array/flatMapDeep.d.ts
/**
* Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.
*
* @template T - The type of elements within the array.
* @template U - The type of elements within the returned array from the iteratee function.
* @param arr - The array to flatten.
* @param iteratee - The function that produces the new array elements. It receives the element, its index, and the array.
* @returns A new array that has been flattened.
*
* @example
* const result = flatMapDeep([1, 2, 3], n => [[n, n]]);
* // [1, 1, 2, 2, 3, 3]
*/
declare function flatMapDeep<T, U>(arr: readonly T[], iteratee: (item: T, index: number, array: readonly T[]) => U): Array<ExtractNestedArrayType<U>>;
//#endregion
export { flatMapDeep };

View file

@ -0,0 +1,20 @@
const require_flattenDeep = require("./flattenDeep.js");
//#region src/array/flatMapDeep.ts
/**
* Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.
*
* @template T - The type of elements within the array.
* @template U - The type of elements within the returned array from the iteratee function.
* @param arr - The array to flatten.
* @param iteratee - The function that produces the new array elements. It receives the element, its index, and the array.
* @returns A new array that has been flattened.
*
* @example
* const result = flatMapDeep([1, 2, 3], n => [[n, n]]);
* // [1, 1, 2, 2, 3, 3]
*/
function flatMapDeep(arr, iteratee) {
return require_flattenDeep.flattenDeep(arr.map((item, index) => iteratee(item, index, arr)));
}
//#endregion
exports.flatMapDeep = flatMapDeep;

View file

@ -0,0 +1,20 @@
import { flattenDeep } from "./flattenDeep.mjs";
//#region src/array/flatMapDeep.ts
/**
* Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.
*
* @template T - The type of elements within the array.
* @template U - The type of elements within the returned array from the iteratee function.
* @param arr - The array to flatten.
* @param iteratee - The function that produces the new array elements. It receives the element, its index, and the array.
* @returns A new array that has been flattened.
*
* @example
* const result = flatMapDeep([1, 2, 3], n => [[n, n]]);
* // [1, 1, 2, 2, 3, 3]
*/
function flatMapDeep(arr, iteratee) {
return flattenDeep(arr.map((item, index) => iteratee(item, index, arr)));
}
//#endregion
export { flatMapDeep };

View file

@ -0,0 +1,20 @@
//#region src/array/flatten.d.ts
/**
* Flattens an array up to the specified depth.
*
* @template T - The type of elements within the array.
* @template D - The depth to which the array should be flattened.
* @param arr - The array to flatten.
* @param depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns A new array that has been flattened.
*
* @example
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);
* // Returns: [1, 2, 3, 4, [5, 6]]
*
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);
* // Returns: [1, 2, 3, 4, 5, 6]
*/
declare function flatten<T, D extends number = 1>(arr: readonly T[], depth?: D): Array<FlatArray<T[], D>>;
//#endregion
export { flatten };

View file

@ -0,0 +1,20 @@
//#region src/array/flatten.d.ts
/**
* Flattens an array up to the specified depth.
*
* @template T - The type of elements within the array.
* @template D - The depth to which the array should be flattened.
* @param arr - The array to flatten.
* @param depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns A new array that has been flattened.
*
* @example
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);
* // Returns: [1, 2, 3, 4, [5, 6]]
*
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);
* // Returns: [1, 2, 3, 4, 5, 6]
*/
declare function flatten<T, D extends number = 1>(arr: readonly T[], depth?: D): Array<FlatArray<T[], D>>;
//#endregion
export { flatten };

32
frontend/node_modules/es-toolkit/dist/array/flatten.js generated vendored Normal file
View file

@ -0,0 +1,32 @@
//#region src/array/flatten.ts
/**
* Flattens an array up to the specified depth.
*
* @template T - The type of elements within the array.
* @template D - The depth to which the array should be flattened.
* @param arr - The array to flatten.
* @param depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns A new array that has been flattened.
*
* @example
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);
* // Returns: [1, 2, 3, 4, [5, 6]]
*
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);
* // Returns: [1, 2, 3, 4, 5, 6]
*/
function flatten(arr, depth = 1) {
const result = [];
const flooredDepth = Math.floor(depth);
const recursive = (arr, currentDepth) => {
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
if (Array.isArray(item) && currentDepth < flooredDepth) recursive(item, currentDepth + 1);
else result.push(item);
}
};
recursive(arr, 0);
return result;
}
//#endregion
exports.flatten = flatten;

View file

@ -0,0 +1,32 @@
//#region src/array/flatten.ts
/**
* Flattens an array up to the specified depth.
*
* @template T - The type of elements within the array.
* @template D - The depth to which the array should be flattened.
* @param arr - The array to flatten.
* @param depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
* @returns A new array that has been flattened.
*
* @example
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);
* // Returns: [1, 2, 3, 4, [5, 6]]
*
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);
* // Returns: [1, 2, 3, 4, 5, 6]
*/
function flatten(arr, depth = 1) {
const result = [];
const flooredDepth = Math.floor(depth);
const recursive = (arr, currentDepth) => {
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
if (Array.isArray(item) && currentDepth < flooredDepth) recursive(item, currentDepth + 1);
else result.push(item);
}
};
recursive(arr, 0);
return result;
}
//#endregion
export { flatten };

View file

@ -0,0 +1,26 @@
//#region src/array/flattenDeep.d.ts
/**
* Utility type for recursively unpacking nested array types to extract the type of the innermost element
*
* @example
* ExtractNestedArrayType<(number | (number | number[])[])[]>
* // number
*
* ExtractNestedArrayType<(boolean | (string | number[])[])[]>
* // string | number | boolean
*/
type ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNestedArrayType<U> : T;
/**
* Flattens all depths of a nested array.
*
* @template T - The type of elements within the array.
* @param arr - The array to flatten.
* @returns A new array that has been flattened.
*
* @example
* const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);
* // Returns: [1, 2, 3, 4, 5, 6]
*/
declare function flattenDeep<T>(arr: readonly T[]): Array<ExtractNestedArrayType<T>>;
//#endregion
export { ExtractNestedArrayType, flattenDeep };

View file

@ -0,0 +1,26 @@
//#region src/array/flattenDeep.d.ts
/**
* Utility type for recursively unpacking nested array types to extract the type of the innermost element
*
* @example
* ExtractNestedArrayType<(number | (number | number[])[])[]>
* // number
*
* ExtractNestedArrayType<(boolean | (string | number[])[])[]>
* // string | number | boolean
*/
type ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNestedArrayType<U> : T;
/**
* Flattens all depths of a nested array.
*
* @template T - The type of elements within the array.
* @param arr - The array to flatten.
* @returns A new array that has been flattened.
*
* @example
* const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);
* // Returns: [1, 2, 3, 4, 5, 6]
*/
declare function flattenDeep<T>(arr: readonly T[]): Array<ExtractNestedArrayType<T>>;
//#endregion
export { ExtractNestedArrayType, flattenDeep };

View file

@ -0,0 +1,18 @@
const require_flatten = require("./flatten.js");
//#region src/array/flattenDeep.ts
/**
* Flattens all depths of a nested array.
*
* @template T - The type of elements within the array.
* @param arr - The array to flatten.
* @returns A new array that has been flattened.
*
* @example
* const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);
* // Returns: [1, 2, 3, 4, 5, 6]
*/
function flattenDeep(arr) {
return require_flatten.flatten(arr, Infinity);
}
//#endregion
exports.flattenDeep = flattenDeep;

View file

@ -0,0 +1,18 @@
import { flatten } from "./flatten.mjs";
//#region src/array/flattenDeep.ts
/**
* Flattens all depths of a nested array.
*
* @template T - The type of elements within the array.
* @param arr - The array to flatten.
* @returns A new array that has been flattened.
*
* @example
* const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);
* // Returns: [1, 2, 3, 4, 5, 6]
*/
function flattenDeep(arr) {
return flatten(arr, Infinity);
}
//#endregion
export { flattenDeep };

View file

@ -0,0 +1,36 @@
//#region src/array/forEachAsync.d.ts
interface ForEachAsyncOptions {
concurrency?: number;
}
/**
* Executes an async callback function for each element in an array.
*
* Unlike the native `forEach`, this function returns a promise that resolves
* when all async operations complete. It supports optional concurrency limiting.
*
* @template T - The type of elements in the array.
* @param array The array to iterate over.
* @param callback An async function to execute for each element.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves when all operations complete.
* @example
* const users = [{ id: 1 }, { id: 2 }, { id: 3 }];
* await forEachAsync(users, async (user) => {
* await updateUser(user.id);
* });
* // All users have been updated
*
* @example
* // With concurrency limit
* const items = [1, 2, 3, 4, 5];
* await forEachAsync(
* items,
* async (item) => await processItem(item),
* { concurrency: 2 }
* );
* // Processes at most 2 items concurrently
*/
declare function forEachAsync<T>(array: readonly T[], callback: (item: T, index: number, array: readonly T[]) => Promise<void>, options?: ForEachAsyncOptions): Promise<void>;
//#endregion
export { forEachAsync };

View file

@ -0,0 +1,36 @@
//#region src/array/forEachAsync.d.ts
interface ForEachAsyncOptions {
concurrency?: number;
}
/**
* Executes an async callback function for each element in an array.
*
* Unlike the native `forEach`, this function returns a promise that resolves
* when all async operations complete. It supports optional concurrency limiting.
*
* @template T - The type of elements in the array.
* @param array The array to iterate over.
* @param callback An async function to execute for each element.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves when all operations complete.
* @example
* const users = [{ id: 1 }, { id: 2 }, { id: 3 }];
* await forEachAsync(users, async (user) => {
* await updateUser(user.id);
* });
* // All users have been updated
*
* @example
* // With concurrency limit
* const items = [1, 2, 3, 4, 5];
* await forEachAsync(
* items,
* async (item) => await processItem(item),
* { concurrency: 2 }
* );
* // Processes at most 2 items concurrently
*/
declare function forEachAsync<T>(array: readonly T[], callback: (item: T, index: number, array: readonly T[]) => Promise<void>, options?: ForEachAsyncOptions): Promise<void>;
//#endregion
export { forEachAsync };

View file

@ -0,0 +1,37 @@
const require_limitAsync = require("./limitAsync.js");
//#region src/array/forEachAsync.ts
/**
* Executes an async callback function for each element in an array.
*
* Unlike the native `forEach`, this function returns a promise that resolves
* when all async operations complete. It supports optional concurrency limiting.
*
* @template T - The type of elements in the array.
* @param array The array to iterate over.
* @param callback An async function to execute for each element.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves when all operations complete.
* @example
* const users = [{ id: 1 }, { id: 2 }, { id: 3 }];
* await forEachAsync(users, async (user) => {
* await updateUser(user.id);
* });
* // All users have been updated
*
* @example
* // With concurrency limit
* const items = [1, 2, 3, 4, 5];
* await forEachAsync(
* items,
* async (item) => await processItem(item),
* { concurrency: 2 }
* );
* // Processes at most 2 items concurrently
*/
async function forEachAsync(array, callback, options) {
if (options?.concurrency != null) callback = require_limitAsync.limitAsync(callback, options.concurrency);
await Promise.all(array.map(callback));
}
//#endregion
exports.forEachAsync = forEachAsync;

View file

@ -0,0 +1,37 @@
import { limitAsync } from "./limitAsync.mjs";
//#region src/array/forEachAsync.ts
/**
* Executes an async callback function for each element in an array.
*
* Unlike the native `forEach`, this function returns a promise that resolves
* when all async operations complete. It supports optional concurrency limiting.
*
* @template T - The type of elements in the array.
* @param array The array to iterate over.
* @param callback An async function to execute for each element.
* @param [options] Optional configuration object.
* @param [options.concurrency] Maximum number of concurrent async operations. If not specified, all operations run concurrently.
* @returns A promise that resolves when all operations complete.
* @example
* const users = [{ id: 1 }, { id: 2 }, { id: 3 }];
* await forEachAsync(users, async (user) => {
* await updateUser(user.id);
* });
* // All users have been updated
*
* @example
* // With concurrency limit
* const items = [1, 2, 3, 4, 5];
* await forEachAsync(
* items,
* async (item) => await processItem(item),
* { concurrency: 2 }
* );
* // Processes at most 2 items concurrently
*/
async function forEachAsync(array, callback, options) {
if (options?.concurrency != null) callback = limitAsync(callback, options.concurrency);
await Promise.all(array.map(callback));
}
//#endregion
export { forEachAsync };

View file

@ -0,0 +1,49 @@
//#region src/array/forEachRight.d.ts
/**
* Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.
*
* @template T - The type of elements in the array.
* @param arr - The array to iterate over.
* @param callback - The function invoked per iteration.
* The callback function receives three arguments:
* - 'value': The current element being processed in the array.
* - 'index': The index of the current element being processed in the array.
* - 'arr': The array 'forEachRight' was called upon.
*
* @example
* const array = [1, 2, 3];
* const result: number[] = [];
*
* // Use the forEachRight function to iterate through the array and add each element to the result array.
* forEachRight(array, (value) => {
* result.push(value);
* })
*
* console.log(result) // Output: [3, 2, 1]
*/
declare function forEachRight<T>(arr: T[], callback: (value: T, index: number, arr: T[]) => void): void;
/**
* Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.
*
* @template T - The type of elements in the array.
* @param arr - The array to iterate over.
* @param callback - The function invoked per iteration.
* The callback function receives three arguments:
* - 'value': The current element being processed in the array.
* - 'index': The index of the current element being processed in the array.
* - 'arr': The array 'forEachRight' was called upon.
*
* @example
* const array = [1, 2, 3];
* const result: number[] = [];
*
* // Use the forEachRight function to iterate through the array and add each element to the result array.
* forEachRight(array, (value) => {
* result.push(value);
* })
*
* console.log(result) // Output: [3, 2, 1]
*/
declare function forEachRight<T>(arr: readonly T[], callback: (value: T, index: number, arr: readonly T[]) => void): void;
//#endregion
export { forEachRight };

View file

@ -0,0 +1,49 @@
//#region src/array/forEachRight.d.ts
/**
* Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.
*
* @template T - The type of elements in the array.
* @param arr - The array to iterate over.
* @param callback - The function invoked per iteration.
* The callback function receives three arguments:
* - 'value': The current element being processed in the array.
* - 'index': The index of the current element being processed in the array.
* - 'arr': The array 'forEachRight' was called upon.
*
* @example
* const array = [1, 2, 3];
* const result: number[] = [];
*
* // Use the forEachRight function to iterate through the array and add each element to the result array.
* forEachRight(array, (value) => {
* result.push(value);
* })
*
* console.log(result) // Output: [3, 2, 1]
*/
declare function forEachRight<T>(arr: T[], callback: (value: T, index: number, arr: T[]) => void): void;
/**
* Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.
*
* @template T - The type of elements in the array.
* @param arr - The array to iterate over.
* @param callback - The function invoked per iteration.
* The callback function receives three arguments:
* - 'value': The current element being processed in the array.
* - 'index': The index of the current element being processed in the array.
* - 'arr': The array 'forEachRight' was called upon.
*
* @example
* const array = [1, 2, 3];
* const result: number[] = [];
*
* // Use the forEachRight function to iterate through the array and add each element to the result array.
* forEachRight(array, (value) => {
* result.push(value);
* })
*
* console.log(result) // Output: [3, 2, 1]
*/
declare function forEachRight<T>(arr: readonly T[], callback: (value: T, index: number, arr: readonly T[]) => void): void;
//#endregion
export { forEachRight };

View file

@ -0,0 +1,31 @@
//#region src/array/forEachRight.ts
/**
* Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.
*
* @template T - The type of elements in the array.
* @param arr - The array to iterate over.
* @param callback - The function invoked per iteration.
* The callback function receives three arguments:
* - 'value': The current element being processed in the array.
* - 'index': The index of the current element being processed in the array.
* - 'arr': The array 'forEachRight' was called upon.
*
* @example
* const array = [1, 2, 3];
* const result: number[] = [];
*
* // Use the forEachRight function to iterate through the array and add each element to the result array.
* forEachRight(array, (value) => {
* result.push(value);
* })
*
* console.log(result) // Output: [3, 2, 1]
*/
function forEachRight(arr, callback) {
for (let i = arr.length - 1; i >= 0; i--) {
const element = arr[i];
callback(element, i, arr);
}
}
//#endregion
exports.forEachRight = forEachRight;

View file

@ -0,0 +1,31 @@
//#region src/array/forEachRight.ts
/**
* Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.
*
* @template T - The type of elements in the array.
* @param arr - The array to iterate over.
* @param callback - The function invoked per iteration.
* The callback function receives three arguments:
* - 'value': The current element being processed in the array.
* - 'index': The index of the current element being processed in the array.
* - 'arr': The array 'forEachRight' was called upon.
*
* @example
* const array = [1, 2, 3];
* const result: number[] = [];
*
* // Use the forEachRight function to iterate through the array and add each element to the result array.
* forEachRight(array, (value) => {
* result.push(value);
* })
*
* console.log(result) // Output: [3, 2, 1]
*/
function forEachRight(arr, callback) {
for (let i = arr.length - 1; i >= 0; i--) {
const element = arr[i];
callback(element, i, arr);
}
}
//#endregion
export { forEachRight };

View file

@ -0,0 +1,42 @@
//#region src/array/groupBy.d.ts
/**
* Groups the elements of an array based on a provided key-generating function.
*
* This function takes an array and a function that generates a key from each element. It returns
* an object where the keys are the generated keys and the values are arrays of elements that share
* the same key.
*
* @template T - The type of elements in the array.
* @template K - The type of keys.
* @param arr - The array to group.
* @param getKeyFromItem - A function that generates a key from an element, its index, and the array.
* @returns An object where each key is associated with an array of elements that
* share that key.
*
* @example
* const array = [
* { category: 'fruit', name: 'apple' },
* { category: 'fruit', name: 'banana' },
* { category: 'vegetable', name: 'carrot' }
* ];
* const result = groupBy(array, item => item.category);
* // result will be:
* // {
* // fruit: [
* // { category: 'fruit', name: 'apple' },
* // { category: 'fruit', name: 'banana' }
* // ],
* // vegetable: [
* // { category: 'vegetable', name: 'carrot' }
* // ]
* // }
*
* @example
* // Using index parameter
* const items = ['a', 'b', 'c', 'd'];
* const result = groupBy(items, (item, index) => index % 2 === 0 ? 'even' : 'odd');
* // result will be: { even: ['a', 'c'], odd: ['b', 'd'] }
*/
declare function groupBy<T, K extends PropertyKey>(arr: readonly T[], getKeyFromItem: (item: T, index: number, array: readonly T[]) => K): Record<K, T[]>;
//#endregion
export { groupBy };

View file

@ -0,0 +1,42 @@
//#region src/array/groupBy.d.ts
/**
* Groups the elements of an array based on a provided key-generating function.
*
* This function takes an array and a function that generates a key from each element. It returns
* an object where the keys are the generated keys and the values are arrays of elements that share
* the same key.
*
* @template T - The type of elements in the array.
* @template K - The type of keys.
* @param arr - The array to group.
* @param getKeyFromItem - A function that generates a key from an element, its index, and the array.
* @returns An object where each key is associated with an array of elements that
* share that key.
*
* @example
* const array = [
* { category: 'fruit', name: 'apple' },
* { category: 'fruit', name: 'banana' },
* { category: 'vegetable', name: 'carrot' }
* ];
* const result = groupBy(array, item => item.category);
* // result will be:
* // {
* // fruit: [
* // { category: 'fruit', name: 'apple' },
* // { category: 'fruit', name: 'banana' }
* // ],
* // vegetable: [
* // { category: 'vegetable', name: 'carrot' }
* // ]
* // }
*
* @example
* // Using index parameter
* const items = ['a', 'b', 'c', 'd'];
* const result = groupBy(items, (item, index) => index % 2 === 0 ? 'even' : 'odd');
* // result will be: { even: ['a', 'c'], odd: ['b', 'd'] }
*/
declare function groupBy<T, K extends PropertyKey>(arr: readonly T[], getKeyFromItem: (item: T, index: number, array: readonly T[]) => K): Record<K, T[]>;
//#endregion
export { groupBy };

51
frontend/node_modules/es-toolkit/dist/array/groupBy.js generated vendored Normal file
View file

@ -0,0 +1,51 @@
//#region src/array/groupBy.ts
/**
* Groups the elements of an array based on a provided key-generating function.
*
* This function takes an array and a function that generates a key from each element. It returns
* an object where the keys are the generated keys and the values are arrays of elements that share
* the same key.
*
* @template T - The type of elements in the array.
* @template K - The type of keys.
* @param arr - The array to group.
* @param getKeyFromItem - A function that generates a key from an element, its index, and the array.
* @returns An object where each key is associated with an array of elements that
* share that key.
*
* @example
* const array = [
* { category: 'fruit', name: 'apple' },
* { category: 'fruit', name: 'banana' },
* { category: 'vegetable', name: 'carrot' }
* ];
* const result = groupBy(array, item => item.category);
* // result will be:
* // {
* // fruit: [
* // { category: 'fruit', name: 'apple' },
* // { category: 'fruit', name: 'banana' }
* // ],
* // vegetable: [
* // { category: 'vegetable', name: 'carrot' }
* // ]
* // }
*
* @example
* // Using index parameter
* const items = ['a', 'b', 'c', 'd'];
* const result = groupBy(items, (item, index) => index % 2 === 0 ? 'even' : 'odd');
* // result will be: { even: ['a', 'c'], odd: ['b', 'd'] }
*/
function groupBy(arr, getKeyFromItem) {
const result = {};
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
const key = getKeyFromItem(item, i, arr);
if (!Object.hasOwn(result, key)) result[key] = [];
result[key].push(item);
}
return result;
}
//#endregion
exports.groupBy = groupBy;

View file

@ -0,0 +1,51 @@
//#region src/array/groupBy.ts
/**
* Groups the elements of an array based on a provided key-generating function.
*
* This function takes an array and a function that generates a key from each element. It returns
* an object where the keys are the generated keys and the values are arrays of elements that share
* the same key.
*
* @template T - The type of elements in the array.
* @template K - The type of keys.
* @param arr - The array to group.
* @param getKeyFromItem - A function that generates a key from an element, its index, and the array.
* @returns An object where each key is associated with an array of elements that
* share that key.
*
* @example
* const array = [
* { category: 'fruit', name: 'apple' },
* { category: 'fruit', name: 'banana' },
* { category: 'vegetable', name: 'carrot' }
* ];
* const result = groupBy(array, item => item.category);
* // result will be:
* // {
* // fruit: [
* // { category: 'fruit', name: 'apple' },
* // { category: 'fruit', name: 'banana' }
* // ],
* // vegetable: [
* // { category: 'vegetable', name: 'carrot' }
* // ]
* // }
*
* @example
* // Using index parameter
* const items = ['a', 'b', 'c', 'd'];
* const result = groupBy(items, (item, index) => index % 2 === 0 ? 'even' : 'odd');
* // result will be: { even: ['a', 'c'], odd: ['b', 'd'] }
*/
function groupBy(arr, getKeyFromItem) {
const result = {};
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
const key = getKeyFromItem(item, i, arr);
if (!Object.hasOwn(result, key)) result[key] = [];
result[key].push(item);
}
return result;
}
//#endregion
export { groupBy };

35
frontend/node_modules/es-toolkit/dist/array/head.d.mts generated vendored Normal file
View file

@ -0,0 +1,35 @@
//#region src/array/head.d.ts
/**
* Returns the first element of an array.
*
* This function takes an array and returns the first element of the array.
* If the array is empty, the function returns `undefined`.
*
* @template T - The type of elements in the array.
* @param arr - A non-empty array from which to get the first element.
* @returns The first element of the array.
*
* @example
* const arr = [1, 2, 3];
* const firstElement = head(arr);
* // firstElement will be 1
*/
declare function head<T>(arr: readonly [T, ...T[]]): T;
/**
* Returns the first element of an array or `undefined` if the array is empty.
*
* This function takes an array and returns the first element of the array.
* If the array is empty, the function returns `undefined`.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to get the first element.
* @returns The first element of the array, or `undefined` if the array is empty.
*
* @example
* const emptyArr: number[] = [];
* const noElement = head(emptyArr);
* // noElement will be undefined
*/
declare function head<T>(arr: readonly T[]): T | undefined;
//#endregion
export { head };

35
frontend/node_modules/es-toolkit/dist/array/head.d.ts generated vendored Normal file
View file

@ -0,0 +1,35 @@
//#region src/array/head.d.ts
/**
* Returns the first element of an array.
*
* This function takes an array and returns the first element of the array.
* If the array is empty, the function returns `undefined`.
*
* @template T - The type of elements in the array.
* @param arr - A non-empty array from which to get the first element.
* @returns The first element of the array.
*
* @example
* const arr = [1, 2, 3];
* const firstElement = head(arr);
* // firstElement will be 1
*/
declare function head<T>(arr: readonly [T, ...T[]]): T;
/**
* Returns the first element of an array or `undefined` if the array is empty.
*
* This function takes an array and returns the first element of the array.
* If the array is empty, the function returns `undefined`.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to get the first element.
* @returns The first element of the array, or `undefined` if the array is empty.
*
* @example
* const emptyArr: number[] = [];
* const noElement = head(emptyArr);
* // noElement will be undefined
*/
declare function head<T>(arr: readonly T[]): T | undefined;
//#endregion
export { head };

21
frontend/node_modules/es-toolkit/dist/array/head.js generated vendored Normal file
View file

@ -0,0 +1,21 @@
//#region src/array/head.ts
/**
* Returns the first element of an array or `undefined` if the array is empty.
*
* This function takes an array and returns the first element of the array.
* If the array is empty, the function returns `undefined`.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to get the first element.
* @returns The first element of the array, or `undefined` if the array is empty.
*
* @example
* const emptyArr: number[] = [];
* const noElement = head(emptyArr);
* // noElement will be undefined
*/
function head(arr) {
return arr[0];
}
//#endregion
exports.head = head;

21
frontend/node_modules/es-toolkit/dist/array/head.mjs generated vendored Normal file
View file

@ -0,0 +1,21 @@
//#region src/array/head.ts
/**
* Returns the first element of an array or `undefined` if the array is empty.
*
* This function takes an array and returns the first element of the array.
* If the array is empty, the function returns `undefined`.
*
* @template T - The type of elements in the array.
* @param arr - The array from which to get the first element.
* @returns The first element of the array, or `undefined` if the array is empty.
*
* @example
* const emptyArr: number[] = [];
* const noElement = head(emptyArr);
* // noElement will be undefined
*/
function head(arr) {
return arr[0];
}
//#endregion
export { head };

Some files were not shown because too many files have changed in this diff Show more