MCPcopy
hub / github.com/vercel/next.js / compareVersions

Function compareVersions

packages/next-codemod/lib/agents-md.ts:622–635  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

620}
621
622function compareVersions(a: string, b: string): number {
623 const parseVersion = (v: string) => {
624 const match = v.match(/^(\d+)\.(\d+)\.(\d+)/)
625 if (!match) return [0, 0, 0]
626 return [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])]
627 }
628
629 const [aMajor, aMinor, aPatch] = parseVersion(a)
630 const [bMajor, bMinor, bPatch] = parseVersion(b)
631
632 if (aMajor !== bMajor) return aMajor - bMajor
633 if (aMinor !== bMinor) return aMinor - bMinor
634 return aPatch - bPatch
635}

Callers 4

findHighestVersionFunction · 0.85
runUpgradeFunction · 0.85
suggestTurbopackFunction · 0.85
suggestCodemodsFunction · 0.85

Calls 1

parseVersionFunction · 0.70

Tested by

no test coverage detected