* Compare two semver strings a and b. * Returns 1 if a > b, -1 if a < b, 0 if equal.
(a: string, b: string)
| 175 | * Returns 1 if a > b, -1 if a < b, 0 if equal. |
| 176 | */ |
| 177 | function compareSemver(a: string, b: string): number { |
| 178 | const pa = a.split('.').map((n) => parseInt(n, 10)); |
| 179 | const pb = b.split('.').map((n) => parseInt(n, 10)); |
| 180 | const len = Math.max(pa.length, pb.length); |
| 181 | for (let i = 0; i < len; i++) { |
| 182 | const da = Number.isFinite(pa[i]) ? pa[i] : 0; |
| 183 | const db = Number.isFinite(pb[i]) ? pb[i] : 0; |
| 184 | if (da > db) return 1; |
| 185 | if (da < db) return -1; |
| 186 | } |
| 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Determine whether the bundled AXe meets a minimum version requirement. |
no outgoing calls
no test coverage detected