Skip to main content

Function: min()

min(iterable: IterableResolvable <NumberResolvable>): number | null

Consumes the iterable and returns the lowest number element. If the iterable is empty, or contains only non-number values, it returns null.

Parameters

ParameterTypeDescription
iterableIterableResolvable <NumberResolvable>An iterator of number values to determine the minimum value of.

Returns

number | null

The minimum value in the input iterator, or null if the iterator is empty or contains only non-number values.

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.

Source

projects/utilities/packages/iterator-utilities/src/lib/min.ts:24