bare-semver
Reference for bare-semver: a minimal semantic-versioning library for Bare—parse versions, build comparators and ranges, and test satisfaction.
stable
bare-semver is a minimal semantic-versioning library for Bare: parse and compare versions, and build and test ranges. It's pure JavaScript and underpins Bare's module/addon resolution.
npm i bare-semverUsage
const semver = require('bare-semver')
const version = semver.Version.parse('1.2.3-alpha.1+build.42')
console.log(version.major, version.minor, version.patch) // 1 2 3
console.log(semver.satisfies('1.2.3', '>=1.0.0 <2.0.0')) // trueAPI
const satisfied = semver.satisfies(version, range)
Test whether a version satisfies a range. semver.constants and semver.errors expose the supporting tables.
Version
const version = new semver.Version(major, minor, patch[, options]) · semver.Version.parse(input)
A parsed version with major, minor, patch, prerelease, and build, plus version.compare(other), version.toString(), and the static semver.Version.compare(a, b).
Comparator and range
const comparator = new semver.Comparator(operator, version)
A single comparator (operator, version, test(version), toString()).
const range = new semver.Range([comparators]) · semver.Range.parse(input)
A range of comparators: range.comparators, range.test(version), range.toString().
See also
bare-module-resolve—uses semver ranges during resolution.- Bare modules—the full
bare-*catalog. - Bare runtime API—the runtime this runs on.