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

difference.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.import type { ReleaseType, SemVer } from "./types.ts";import { compareIdentifier } from "./_shared.ts";
/** * Returns difference between two versions by the release type, or `undefined` if the versions are the same. */export function difference(s0: SemVer, s1: SemVer): ReleaseType | undefined { const hasPrerelease = s0.prerelease?.length || s1.prerelease?.length;
if (s0.major !== s1.major) return hasPrerelease ? "premajor" : "major"; if (s0.minor !== s1.minor) return hasPrerelease ? "preminor" : "minor"; if (s0.patch !== s1.patch) return hasPrerelease ? "prepatch" : "patch";
if (compareIdentifier(s0.prerelease, s1.prerelease) !== 0) { return "prerelease"; }}
std

Version Info

Tagged at
6 months ago