1
export type Version = [number, number, number];
2

3 5
export class VersionUtils {
4 5
    static isGreaterOrEqual(version: string, targetVersion: string): boolean {
5 0
        const v1 = parseVersion(version);
6 0
        const v2 = parseVersion(targetVersion);
7

8 0
        return v1[0] > v2[0] ||
9 0
            v1[0] === v2[0] && v1[1] > v2[1] ||
10 0
            v1[0] === v2[0] && v1[1] === v2[1] && v1[2] >= v2[2];
11
    }
12 5
}
13

14 0
function parseVersion(version: string = ""): Version {
15 0
    const v: Version = [0, 0, 0];
16

17 0
    version.split(".").forEach((value, i) => v[i] = parseInt(value, 10));
18

19 0
    return v;
20
}

Read our documentation on viewing source code .

Loading