parse

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

function

function parse(value: string): ChronVer

Parses a string as a ChronVer, returning a ChronVer object.

The format is YYYY.MM.DD[.CHANGESET][-FEATURE|-break]. The date must be a real calendar date, so 2024.02.29 is valid but 2023.02.29 is not. The changeset is optional, but when present it's a positive integer with no leading zeros. A version is either a feature or -break, not both: in 2024.04.03-ui-break the feature is ui-break.

Every string this accepts formats back to itself with format.

value: string

The version string to parse

Returns

A valid ChronVer

Example: Usage

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

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

assertEquals(parse("2024.04.03-new-ui").feature, "new-ui");
assertEquals(parse("2024.04.03.1-break").isBreaking, true);

Source