Function: min()
min<
ElementType>(iterable:IterableResolvable<ElementType>):null|ElementType
Defined in: projects/utilities/packages/iterator-utilities/src/lib/min.ts:31
Consumes the iterable and returns the lowest number element. If the iterable is empty, it returns null.
This function uses the default comparator (lexicographically), which means it will compare the elements as strings. If this is undesirable, use minBy instead.
Type Parameters
| Type Parameter | 
|---|
| ElementType | 
Parameters
| Parameter | Type | Description | 
|---|---|---|
| iterable | IterableResolvable<ElementType> | An iterator of number values to determine the minimum value of. | 
Returns
null | ElementType
The minimum value in the input iterator, or null if the iterator is empty or contains only non-number values.
Seealso
minBy for a version that allows custom comparators.
Seealso
minByKey for a version that allows custom key extractors.
Example
import { min } from '@sapphire/iterator-utilities';
const iterable = [1, 2, 3, 4, 5];
console.log(min(iterable));
// Output: 1
Remarks
This function consumes the entire iterator.