UNPKG

@enonic/mock-xp

Version:

Mock Enonic XP API JavaScript Library

56 lines (55 loc) 1.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Version = void 0; var tslib_1 = require("tslib"); var Version = (function () { function Version(version) { var _a = tslib_1.__read(version.split('.'), 3), major = _a[0], minor = _a[1], patchAndQualifier = _a[2]; this.major = Number(major); this.minor = Number(minor); var _b = tslib_1.__read(patchAndQualifier.split('-'), 2), patch = _b[0], qualifier = _b[1]; this.patch = Number(patch); this.qualifier = qualifier; } Version.prototype.toString = function () { return "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch).concat(this.qualifier ? "-".concat(this.qualifier) : ''); }; Version.prototype.compareTo = function (other) { if (this.major !== other.major) { return this.major - other.major; } if (this.minor !== other.minor) { return this.minor - other.minor; } if (this.patch !== other.patch) { return this.patch - other.patch; } if (this.qualifier && other.qualifier) { return this.qualifier.localeCompare(other.qualifier); } if (this.qualifier) { return 1; } if (other.qualifier) { return -1; } return 0; }; Version.prototype.equals = function (other) { return this.compareTo(other) === 0; }; Version.prototype.greaterThan = function (other) { return this.compareTo(other) > 0; }; Version.prototype.greaterThanOrEquals = function (other) { return this.compareTo(other) >= 0; }; Version.prototype.lessThan = function (other) { return this.compareTo(other) < 0; }; Version.prototype.lessThanOrEquals = function (other) { return this.compareTo(other) <= 0; }; return Version; }()); exports.Version = Version;