geneea-nlp-client
Version:
The TypeScript Client for Geneea Interpretor G3 API.
37 lines (36 loc) • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SemVer = void 0;
class SemVer {
constructor(major, minor, fix) {
this.major = major;
this.minor = minor;
this.fix = fix;
}
static valueOf(text) {
const match = this.REGEX.exec(text);
if (match === null) {
throw new Error(`Semantic version requires ${this.REGEX.source}.`);
}
const [major, minor, fix] = match.splice(1).map((x) => Number(x));
return new SemVer(major, minor, fix);
}
compareTo(other) {
if (this.major != other.major)
return this.major - other.major;
if (this.minor != other.minor)
return this.minor - other.minor;
return this.fix - other.fix;
}
isOlderThan(other) {
return this.compareTo(other) < 0;
}
isSameAs(other) {
return this.compareTo(other) === 0;
}
isSameOrNewerThan(other) {
return this.compareTo(other) >= 0;
}
}
exports.SemVer = SemVer;
SemVer.REGEX = /^(\d+)\.(\d+).(\d+)$/;