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

min_satisfying.ts
View Documentation
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 { lessThan } from "./less_than.ts";
/** * Returns the lowest 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 lowest version in versions that satisfies the range. */export function minSatisfying( versions: SemVer[], range: Range,): SemVer | undefined { let min; for (const version of versions) { if (!satisfies(version, range)) continue; min = min && lessThan(min, version) ? min : version; } return min;}
std

Version Info

Tagged at
6 months ago