UNPKG

dmclc

Version:

Dolphin Minecraft Launcher Core

25 lines (24 loc) 802 B
import { SemanticVersionImpl } from "./SemanticVersionImpl.js"; import { StringVersion } from "./StringVersion.js"; import { VersionParsingException } from "./VersionParsingException.js"; export class VersionParser { static parse(s, storeX) { if (s == null || s === "") { throw new VersionParsingException("Version must be a non-empty string!"); } let version; try { version = SemanticVersionImpl.of(s, storeX); } catch { version = new StringVersion(s); } return version; } static parseSemantic(s) { if (s == null || s === "") { throw new VersionParsingException("Version must be a non-empty string!"); } return SemanticVersionImpl.of(s, false); } }