--- /dev/null
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.parseVersion = exports.compareVersions = exports.isValidVersion = void 0;
+const versionExp = /^v?(\d+)\.(\d+).(\d+)$/;
+function isValidVersion(version) {
+ return Boolean(version.trim().match(versionExp));
+}
+exports.isValidVersion = isValidVersion;
+function compareVersions(version1, version2) {
+ const v1 = parseVersion(version1);
+ const v2 = parseVersion(version2);
+ for (let i = 0; i < 3; i++) {
+ if (v1[i] !== v2[i]) {
+ return Math.max(-1, Math.min(1, v1[i] - v2[i]));
+ }
+ }
+ return 0;
+}
+exports.compareVersions = compareVersions;
+function parseVersion(v) {
+ let ver = [0, 0, 0];
+ const match = v.trim().match(versionExp);
+ if (match) {
+ const [, major, minor, patch] = match;
+ ver = [parseInt(major), parseInt(minor), parseInt(patch)];
+ }
+ if (!isValidVersion(v)) {
+ throw new Error(`'${v}' is not a valid version`);
+ }
+ return ver;
+}
+exports.parseVersion = parseVersion;
+//# sourceMappingURL=versions.js.map
\ No newline at end of file