Skip to content

SemverInterval

const SemverInterval: BoundIntervalType<string>;

Defined in: interval-semver.ts:63

Interval over semantic-version strings — exact precedence ordering, continuous.

Membership is plain precedence, not npm range matching: 2.0.0-rc.1 sorts below 2.0.0, so it IS inside [1.2.0,2.0.0), while npm’s >=1.2.0 <2.0.0 excludes prereleases by default.

import { SemverInterval } from "@xtandard/lib/semver";
const compatible = SemverInterval.closedOpen("1.2.0", "2.0.0");
compatible.contains("1.5.3"); // true
compatible.contains("2.0.0"); // false
compatible.contains("2.0.0-rc.1"); // true (precedence, not npm range rules)
compatible.intersection(SemverInterval.atLeast("1.4.0")).toString(); // "[1.4.0,2.0.0)"