format

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

function

function format(version: ChronVer): string

Formats a ChronVer object into a string.

The year is padded to 4 digits and a changeset of 0 is omitted, so format(parse(s)) === s for every string parse accepts. The version is validated first, so whatever this returns parses back to the same version.

version: ChronVer

The ChronVer to format

Returns

The string representation of the ChronVer

Example: Usage

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

assertEquals(format({ year: 2024, month: 4, day: 3, changeset: 0, isBreaking: false }), "2024.04.03");
assertEquals(format({ year: 2024, month: 4, day: 3, changeset: 1, feature: "new-ui", isBreaking: false }), "2024.04.03.1-new-ui");
assertEquals(format({ year: 2024, month: 4, day: 3, changeset: 1, isBreaking: true }), "2024.04.03.1-break");

Source