CH-J Server Managerspráva serverů přes SSH
Menu
Vydané zdroje

CH-J Server Manager

Procházejte adresáře a soubory konkrétního vydání aplikace.

Stáhnout zdroje ZIP
CH-J Proprietary Software License 1.14

Zdroje jsou zveřejněny pod CH-J Proprietary Software License 1.14. Jejich dostupnost nemění licenční podmínky ani neposkytuje další oprávnění.

1,7 KB · 56 řádkůStáhnout soubor
1"use strict";
3const VERSION_PATTERN = /^v?(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
5function parseVersion(input) {
6 const raw = String(input || "").trim();
7 const match = VERSION_PATTERN.exec(raw);
8 if (!match) {
9 throw new Error(`Invalid version: ${raw || "<empty>"}`);
10 }
12 return {
13 raw: raw.replace(/^v/i, ""),
14 numbers: [match[1], match[2], match[3] || "0", match[4] || "0"].map(Number),
15 prerelease: match[5] ? match[5].split(".") : []
16 };
19function comparePrerelease(left, right) {
20 if (left.length === 0 && right.length === 0) return 0;
21 if (left.length === 0) return 1;
22 if (right.length === 0) return -1;
24 const length = Math.max(left.length, right.length);
25 for (let index = 0; index < length; index += 1) {
26 if (left[index] === undefined) return -1;
27 if (right[index] === undefined) return 1;
28 if (left[index] === right[index]) continue;
30 const leftNumeric = /^\d+$/.test(left[index]);
31 const rightNumeric = /^\d+$/.test(right[index]);
32 if (leftNumeric && rightNumeric) {
33 return Number(left[index]) > Number(right[index]) ? 1 : -1;
34 }
35 if (leftNumeric !== rightNumeric) return leftNumeric ? -1 : 1;
36 return left[index] > right[index] ? 1 : -1;
37 }
38 return 0;
41function compareVersions(leftInput, rightInput) {
42 const left = parseVersion(leftInput);
43 const right = parseVersion(rightInput);
45 for (let index = 0; index < left.numbers.length; index += 1) {
46 if (left.numbers[index] === right.numbers[index]) continue;
47 return left.numbers[index] > right.numbers[index] ? 1 : -1;
48 }
49 return comparePrerelease(left.prerelease, right.prerelease);
52module.exports = {
53 VERSION_PATTERN,
54 compareVersions,
55 parseVersion
56};

SHA-256: f72255fe2089bfcd9cdd4727c5a47e9e563195db470dbe8073ebe311aa120804

SHA-256 archivu: 5ac91caf4fa32a6fdb114f2430deed486fbe7489d5eea343d1f034169fafb5e0