Returns the highest SemVer in the list that satisfies the range, or undefined if none of them do.
undefined
The versions to check.
The range of possible versions to compare to.
The highest version in versions that satisfies the range.
import { parse, parseRange, maxSatisfying } from "@std/semver";import { assertEquals } from "@std/assert";const versions = ["1.2.3", "1.2.4", "1.3.0", "2.0.0", "2.1.0"].map(parse);const range = parseRange(">=1.0.0 <2.0.0");assertEquals(maxSatisfying(versions, range), parse("1.3.0")); Copy
import { parse, parseRange, maxSatisfying } from "@std/semver";import { assertEquals } from "@std/assert";const versions = ["1.2.3", "1.2.4", "1.3.0", "2.0.0", "2.1.0"].map(parse);const range = parseRange(">=1.0.0 <2.0.0");assertEquals(maxSatisfying(versions, range), parse("1.3.0"));
Returns the highest SemVer in the list that satisfies the range, or
undefinedif none of them do.