export function matchRange()

in src/Utils/VersionHelper.ts [17:35]


export function matchRange(version: string, range: string): boolean {
    const strictMatchGrp: RegExpMatchArray = range.match(strictRange);
    if (strictMatchGrp) {
        return compareVersions(strictMatchGrp[1], version) <= 0
            && compareVersions(strictMatchGrp[2], version) >= 0;
    }
    const horMatchGrp: RegExpMatchArray = range.match(halfopenRightRange);
    if (horMatchGrp) {
        return compareVersions(horMatchGrp[1], version) <= 0
            && compareVersions(horMatchGrp[2], version) > 0;
    }
    const holMatchGrp: RegExpMatchArray = range.match(halfopenLeftRange);
    if (holMatchGrp) {
        return compareVersions(holMatchGrp[1], version) < 0
            && compareVersions(holMatchGrp[2], version) >= 0;
    }

    return compareVersions(range, version) <= 0;
}