minSatisfying

import { minSatisfying } from "jsr:@ende/semver";

function

function minSatisfying(versions: SemVer[], range: Range): SemVer | undefined

Returns the lowest SemVer in the list that satisfies the range, or undefined if none of them do.

versions: SemVer[]

The versions to check.

range: Range

The range of possible versions to compare to.

Returns

The lowest version in versions that satisfies the range.

Example: Usage

import { parse, parseRange, minSatisfying } from "@ende/semver";
import { assertEquals } from "@ende/assert";

const versions = ["0.2.0", "1.2.3", "1.3.0", "2.0.0", "2.1.0"].map(parse);
const range = parseRange(">=1.0.0 <2.0.0");

assertEquals(minSatisfying(versions, range), parse("1.2.3"));

Source