es-toolkit 1.16.0-dev.474 → 1.16.0-dev.476

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,11 +5,12 @@
5
5
  * @template T - The type of elements in the array.
6
6
  * @param {T[]} items The array of elements to search.
7
7
  * @param {(element: T) => number} getValue A function that selects a numeric value from each element.
8
- * @returns {T} The element with the maximum value as determined by the `getValue` function.
8
+ * @returns {T | undefined} The element with the maximum value as determined by the `getValue` function.
9
9
  * @example
10
10
  * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
11
11
  * maxBy([], x => x.a); // Returns: undefined
12
12
  */
13
- declare function maxBy<T>(items: T[], getValue: (element: T) => number): T;
13
+ declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
+ declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
14
15
 
15
16
  export { maxBy };
@@ -5,11 +5,12 @@
5
5
  * @template T - The type of elements in the array.
6
6
  * @param {T[]} items The array of elements to search.
7
7
  * @param {(element: T) => number} getValue A function that selects a numeric value from each element.
8
- * @returns {T} The element with the maximum value as determined by the `getValue` function.
8
+ * @returns {T | undefined} The element with the maximum value as determined by the `getValue` function.
9
9
  * @example
10
10
  * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
11
11
  * maxBy([], x => x.a); // Returns: undefined
12
12
  */
13
- declare function maxBy<T>(items: T[], getValue: (element: T) => number): T;
13
+ declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
+ declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
14
15
 
15
16
  export { maxBy };
@@ -5,11 +5,12 @@
5
5
  * @template T - The type of elements in the array.
6
6
  * @param {T[]} items The array of elements to search.
7
7
  * @param {(element: T) => number} getValue A function that selects a numeric value from each element.
8
- * @returns {T} The element with the minimum value as determined by the `getValue` function.
8
+ * @returns {T | undefined} The element with the minimum value as determined by the `getValue` function.
9
9
  * @example
10
10
  * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
11
11
  * minBy([], x => x.a); // Returns: undefined
12
12
  */
13
- declare function minBy<T>(items: T[], getValue: (element: T) => number): T;
13
+ declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
+ declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
14
15
 
15
16
  export { minBy };
@@ -5,11 +5,12 @@
5
5
  * @template T - The type of elements in the array.
6
6
  * @param {T[]} items The array of elements to search.
7
7
  * @param {(element: T) => number} getValue A function that selects a numeric value from each element.
8
- * @returns {T} The element with the minimum value as determined by the `getValue` function.
8
+ * @returns {T | undefined} The element with the minimum value as determined by the `getValue` function.
9
9
  * @example
10
10
  * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
11
11
  * minBy([], x => x.a); // Returns: undefined
12
12
  */
13
- declare function minBy<T>(items: T[], getValue: (element: T) => number): T;
13
+ declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
+ declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
14
15
 
15
16
  export { minBy };