MCPcopy Create free account
hub / github.com/fontsource/fontsource / sortSemverList

Function sortSemverList

api/metadata/src/stats/util.ts:11–30  ·  view source on GitHub ↗
(list: string[])

Source from the content-addressed store, hash-verified

9}
10
11export const sortSemverList = (list: string[]): string[] => {
12 return list.sort((a, b) => {
13 const aSplit = a.split('.');
14 const bSplit = b.split('.');
15
16 const aMajor = Number(aSplit[0]);
17 const bMajor = Number(bSplit[0]);
18 const aMinor = Number(aSplit[1]);
19 const bMinor = Number(bSplit[1]);
20 const aPatch = Number(aSplit[2]);
21 const bPatch = Number(bSplit[2]);
22 if (aMajor > bMajor) return -1;
23 if (aMajor < bMajor) return 1;
24 if (aMinor > bMinor) return -1;
25 if (aMinor < bMinor) return 1;
26 if (aPatch > bPatch) return -1;
27 if (aPatch < bPatch) return 1;
28 return 0;
29 });
30};
31
32export const getAvailableVersions = async (
33 id: string,

Callers 1

getAvailableVersionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected