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

compare.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
26
27
28
29
30
31
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.import type { SemVer } from "./types.ts";import { checkIdentifier, compareIdentifier, compareNumber,} from "./_shared.ts";
/** * Compare two semantic version objects. * * Returns `0` if `s0 === s1`, or `1` if `s0` is greater, or `-1` if `s1` is * greater. * * Sorts in ascending order if passed to `Array.sort()`, */export function compare( s0: SemVer, s1: SemVer,): 1 | 0 | -1 { if (s0 === s1) return 0; return ( compareNumber(s0.major, s1.major) || compareNumber(s0.minor, s1.minor) || compareNumber(s0.patch, s1.patch) || checkIdentifier(s0.prerelease, s1.prerelease) || compareIdentifier(s0.prerelease, s1.prerelease) );}
std

Version Info

Tagged at
6 months ago