1
0
mirror of https://github.com/prometheus/docs.git synced 2026-02-05 15:45:27 +01:00
Files
docs/scripts/utils.ts
Julius Volz 18209a3827 More work on new docs site
Signed-off-by: Julius Volz <julius.volz@gmail.com>
2025-05-12 14:03:08 +02:00

16 lines
519 B
TypeScript

import { compare } from "semver";
// Takes a full Prometheus tag / version string and returns the major and minor version.
// "v3.4.0-rc.0" -> "3.4"
export const majorMinor = (version: string) => {
return version.replace(/^v/, "").split(".").slice(0, 2).join(".");
};
export const compareFullVersion = (a: string, b: string) => {
return compare(a.replace(/^v/, ""), b.replace(/^v/, ""));
};
export function filterUnique(value: string, index: number, array: string[]) {
return array.indexOf(value) === index;
}