tryParse

import { tryParse } from "jsr:@ende/chronver";

function

function tryParse(value: string): ChronVer | undefined

Returns the parsed ChronVer, or undefined if it's not valid.

value: string

The version string to parse

Returns

A valid ChronVer or undefined

Example: Usage

import { tryParse } from "@ende/chronver/try-parse";
import { assertEquals } from "@ende/assert";

assertEquals(tryParse("2024.04.03.1"), { year: 2024, month: 4, day: 3, changeset: 1, isBreaking: false });
assertEquals(tryParse("2023.02.29"), undefined);
assertEquals(tryParse("invalid"), undefined);

Source