MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / compareVersions

Function compareVersions

frontend/src/components/pluginUtils.js:9–25  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

7 * equality: 0 if identical, non-zero otherwise.
8 */
9export function compareVersions(a, b) {
10 if (!a || !b) return 0;
11 const normalize = (v) => v.replace(/^v/, '');
12 const na = normalize(a);
13 const nb = normalize(b);
14 const isPrerelease = (v) => v.split('.').some((p) => !/^\d+$/.test(p));
15 if (isPrerelease(na) || isPrerelease(nb)) {
16 return na === nb ? 0 : 1;
17 }
18 const pa = na.split('.').map(Number);
19 const pb = nb.split('.').map(Number);
20 for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
21 const diff = (pa[i] || 0) - (pb[i] || 0);
22 if (diff !== 0) return diff;
23 }
24 return 0;
25}

Callers 8

PluginDetailPanelFunction · 0.90
buildLabelFunction · 0.90
AvailablePluginCardFunction · 0.90
executeInstallFunction · 0.90
confirmAndInstallFunction · 0.90
PluginCardFunction · 0.90
PluginBrowsePageFunction · 0.90
weightFunction · 0.90

Calls 2

normalizeFunction · 0.85
isPrereleaseFunction · 0.85

Tested by

no test coverage detected