(version: string)
| 14 | * Parse a semantic version string into its components |
| 15 | */ |
| 16 | export function parseVersion(version: string): Version { |
| 17 | const match = version.match(/^(\d+)\.(\d+)\.(\d+)$/) |
| 18 | if (!match) { |
| 19 | throw new Error(`Invalid semantic version format: ${version}`) |
| 20 | } |
| 21 | return { |
| 22 | major: parseInt(match[1], 10), |
| 23 | minor: parseInt(match[2], 10), |
| 24 | patch: parseInt(match[3], 10), |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | export function stringifyVersion(version: Version): string { |
| 29 | return `${version.major}.${version.minor}.${version.patch}` |
no outgoing calls
no test coverage detected