deno.land / std@0.224.0 / semver / max_satisfying.ts

max_satisfying.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.import type { Range, SemVer } from "./types.ts";import { satisfies } from "./satisfies.ts";import { greaterThan } from "./greater_than.ts";
/** * Returns the highest version in the list that satisfies the range, or `undefined` * if none of them do. * @param versions The versions to check. * @param range The range of possible versions to compare to. * @returns The highest version in versions that satisfies the range. */export function maxSatisfying( versions: SemVer[], range: Range,): SemVer | undefined { let max; for (const version of versions) { if (!satisfies(version, range)) continue; max = max && greaterThan(max, version) ? max : version; } return max;}
std

Version Info

Tagged at
3 weeks ago