es-toolkit 1.37.2-dev.1269 → 1.37.2-dev.1270

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.
@@ -2634,17 +2634,21 @@ function inRange(value, minimum, maximum) {
2634
2634
  return range$1.inRange(value, minimum, maximum);
2635
2635
  }
2636
2636
 
2637
- function max(items = []) {
2638
- let maxElement = items[0];
2639
- let max = undefined;
2637
+ function max(items) {
2638
+ if (!items || items.length === 0) {
2639
+ return undefined;
2640
+ }
2641
+ let maxResult = undefined;
2640
2642
  for (let i = 0; i < items.length; i++) {
2641
- const element = items[i];
2642
- if (max == null || element > max) {
2643
- max = element;
2644
- maxElement = element;
2643
+ const current = items[i];
2644
+ if (current == null || Number.isNaN(current) || typeof current === 'symbol') {
2645
+ continue;
2646
+ }
2647
+ if (maxResult === undefined || current > maxResult) {
2648
+ maxResult = current;
2645
2649
  }
2646
2650
  }
2647
- return maxElement;
2651
+ return maxResult;
2648
2652
  }
2649
2653
 
2650
2654
  function maxBy(items, iteratee$1) {
@@ -2692,17 +2696,21 @@ function meanBy(items, iteratee$1) {
2692
2696
  return range$1.meanBy(Array.from(items), iteratee(iteratee$1));
2693
2697
  }
2694
2698
 
2695
- function min(items = []) {
2696
- let minElement = items[0];
2697
- let min = undefined;
2699
+ function min(items) {
2700
+ if (!items || items.length === 0) {
2701
+ return undefined;
2702
+ }
2703
+ let minResult = undefined;
2698
2704
  for (let i = 0; i < items.length; i++) {
2699
- const element = items[i];
2700
- if (min == null || element < min) {
2701
- min = element;
2702
- minElement = element;
2705
+ const current = items[i];
2706
+ if (current == null || Number.isNaN(current) || typeof current === 'symbol') {
2707
+ continue;
2708
+ }
2709
+ if (minResult === undefined || current < minResult) {
2710
+ minResult = current;
2703
2711
  }
2704
2712
  }
2705
- return minElement;
2713
+ return minResult;
2706
2714
  }
2707
2715
 
2708
2716
  function minBy(items, iteratee$1) {
@@ -22,9 +22,9 @@ declare function max(): undefined;
22
22
  * Finds the element in an array that has the maximum value.
23
23
  *
24
24
  * @template T - The type of elements in the array.
25
- * @param {T[]} [items] - The array of elements to search. Defaults to an empty array.
25
+ * @param {ArrayLike<T> | null | undefined} [items] - The array of elements to search. Defaults to an empty array.
26
26
  * @returns {T | undefined} - The element with the maximum value, or undefined if the array is empty.
27
27
  */
28
- declare function max<T>(items?: readonly T[]): T | undefined;
28
+ declare function max<T>(items?: ArrayLike<T> | null | undefined): T | undefined;
29
29
 
30
30
  export { max };
@@ -22,9 +22,9 @@ declare function max(): undefined;
22
22
  * Finds the element in an array that has the maximum value.
23
23
  *
24
24
  * @template T - The type of elements in the array.
25
- * @param {T[]} [items] - The array of elements to search. Defaults to an empty array.
25
+ * @param {ArrayLike<T> | null | undefined} [items] - The array of elements to search. Defaults to an empty array.
26
26
  * @returns {T | undefined} - The element with the maximum value, or undefined if the array is empty.
27
27
  */
28
- declare function max<T>(items?: readonly T[]): T | undefined;
28
+ declare function max<T>(items?: ArrayLike<T> | null | undefined): T | undefined;
29
29
 
30
30
  export { max };
@@ -1,14 +1,18 @@
1
- function max(items = []) {
2
- let maxElement = items[0];
3
- let max = undefined;
1
+ function max(items) {
2
+ if (!items || items.length === 0) {
3
+ return undefined;
4
+ }
5
+ let maxResult = undefined;
4
6
  for (let i = 0; i < items.length; i++) {
5
- const element = items[i];
6
- if (max == null || element > max) {
7
- max = element;
8
- maxElement = element;
7
+ const current = items[i];
8
+ if (current == null || Number.isNaN(current) || typeof current === 'symbol') {
9
+ continue;
10
+ }
11
+ if (maxResult === undefined || current > maxResult) {
12
+ maxResult = current;
9
13
  }
10
14
  }
11
- return maxElement;
15
+ return maxResult;
12
16
  }
13
17
 
14
18
  export { max };
@@ -23,9 +23,9 @@ declare function min(): undefined;
23
23
  * Finds the element in an array that has the minimum value.
24
24
  *
25
25
  * @template T - The type of elements in the array.
26
- * @param {T[]} [items] - The array of elements to search. Defaults to an empty array.
26
+ * @param {ArrayLike<T> | null | undefined} [items] - The array of elements to search. Defaults to an empty array.
27
27
  * @returns {T | undefined} - The element with the minimum value, or undefined if the array is empty.
28
28
  */
29
- declare function min<T>(items?: readonly T[]): T | undefined;
29
+ declare function min<T>(items?: ArrayLike<T> | null | undefined): T | undefined;
30
30
 
31
31
  export { min };
@@ -23,9 +23,9 @@ declare function min(): undefined;
23
23
  * Finds the element in an array that has the minimum value.
24
24
  *
25
25
  * @template T - The type of elements in the array.
26
- * @param {T[]} [items] - The array of elements to search. Defaults to an empty array.
26
+ * @param {ArrayLike<T> | null | undefined} [items] - The array of elements to search. Defaults to an empty array.
27
27
  * @returns {T | undefined} - The element with the minimum value, or undefined if the array is empty.
28
28
  */
29
- declare function min<T>(items?: readonly T[]): T | undefined;
29
+ declare function min<T>(items?: ArrayLike<T> | null | undefined): T | undefined;
30
30
 
31
31
  export { min };
@@ -1,14 +1,18 @@
1
- function min(items = []) {
2
- let minElement = items[0];
3
- let min = undefined;
1
+ function min(items) {
2
+ if (!items || items.length === 0) {
3
+ return undefined;
4
+ }
5
+ let minResult = undefined;
4
6
  for (let i = 0; i < items.length; i++) {
5
- const element = items[i];
6
- if (min == null || element < min) {
7
- min = element;
8
- minElement = element;
7
+ const current = items[i];
8
+ if (current == null || Number.isNaN(current) || typeof current === 'symbol') {
9
+ continue;
10
+ }
11
+ if (minResult === undefined || current < minResult) {
12
+ minResult = current;
9
13
  }
10
14
  }
11
- return minElement;
15
+ return minResult;
12
16
  }
13
17
 
14
18
  export { min };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.37.2-dev.1269+011ba198",
4
+ "version": "1.37.2-dev.1270+712176c8",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {