MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / parseVersion

Function parseVersion

src/core/version.ts:63–71  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

61}
62
63function parseVersion(s: string): ParsedVersion {
64 const stripped = s.replace(/^v/, '')
65 const dashIdx = stripped.indexOf('-')
66 const core = dashIdx === -1 ? stripped : stripped.slice(0, dashIdx)
67 const pre = dashIdx === -1 ? null : stripped.slice(dashIdx + 1)
68 const coreNums = core.split('.').map((n) => parseInt(n, 10) || 0)
69 while (coreNums.length < 3) coreNums.push(0)
70 return { core: coreNums.slice(0, 3), pre }
71}
72
73/**
74 * Compare two semver-style versions. Returns negative if a<b, 0 if equal,

Callers 1

compareVersionsFunction · 0.70

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected