Minimal semantic versioning library for Bare.
npm i bare-semver
const semver = require('bare-semver')
const version = semver.Version.parse('1.2.3-alpha.1+build.42')
console.log(version.major) // 1
console.log(version.minor) // 2
console.log(version.patch) // 3
const satisfied = semver.satisfies('1.2.3', '>=1.0.0 <2.0.0')
console.log(satisfied) // trueTest whether version satisfies range. Both version and range may be strings, in which case they will be parsed.
An object containing the comparison operator constants:
constants = {
EQ: 1,
LT: 2,
LTE: 3,
GT: 4,
GTE: 5
}The SemVerError class. Thrown when parsing invalid versions or ranges.
Create a new version with the given major, minor, and patch components.
Options include:
options = {
prerelease: [],
build: []
}The major version number.
The minor version number.
The patch version number.
An array of prerelease tags.
An array of build metadata tags.
Compare version with other, returning 1 if version is greater, -1 if less, or 0 if equal. Comparison follows the Semantic Versioning 2.0.0 specification, including prerelease precedence rules.
Return the string representation of version.
Parse a semantic version string into a Version instance. Throws a SemVerError with code INVALID_VERSION if input is not a valid version string.
Compare two Version instances, returning 1, -1, or 0.
Create a new comparator with the given operator constant and version.
The comparison operator constant.
The Version instance to compare against.
Test whether version satisfies the comparator.
Return the string representation of the comparator, e.g. >=1.0.0.
Create a new range from a two-dimensional array of Comparator instances. Each inner array represents a set of comparators joined by intersection, and the outer array represents the union of those sets.
The two-dimensional array of Comparator instances.
Test whether version satisfies the range.
Return the string representation of the range.
Parse a range string into a Range instance. Supports comparison operators (<, <=, >, >=, =), partial versions, and logical OR (||).
Apache-2.0