Expose releases as an api (#4247)

This commit is contained in:
Félix Malfait
2024-02-29 17:48:11 +01:00
committed by GitHub
parent 8625a71f15
commit 6670ecdfda
5 changed files with 85 additions and 51 deletions

View File

@ -0,0 +1,16 @@
export function compareSemanticVersions(a: string, b: string) {
const a1 = a.split('.');
const b1 = b.split('.');
const len = Math.min(a1.length, b1.length);
for (let i = 0; i < len; i++) {
const a2 = +a1[i] || 0;
const b2 = +b1[i] || 0;
if (a2 !== b2) {
return a2 > b2 ? 1 : -1;
}
}
return b1.length - a1.length;
}