MCPcopy Create free account
hub / github.com/material-shell/material-shell / parseVersion

Function parseVersion

src/utils/shellVersionMatch.ts:97–108  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

95/// which ensures that sorting works correctly.
96/// E.g. "43.alpha" will be parsed to [43,-3]
97export function parseVersion(s: string): number[] {
98 const components = s.split('.').map((x) => {
99 if (x === 'alpha') return -3;
100 if (x === 'beta') return -2;
101 if (x === 'rc') return -1;
102 return Number(x);
103 });
104 if (!components.every((x) => isFinite(x))) {
105 throw new Error(`Could not parse version number: ${s}`);
106 }
107 return components;
108}
109
110/// Compares to versions, returns -1 if lhs < rhs, 1 if lhs > rhs and 0 if lhs == rhs
111/// Lhs and rhs may be of different lengths, missing components will be assumed to be zero.

Callers 9

statusArea.tsFile · 0.90
disableMethod · 0.90
button.tsFile · 0.90
gnomeVersionEqualToFunction · 0.85

Calls 2

mapMethod · 0.65
splitMethod · 0.65

Tested by

no test coverage detected