# bare-semver

> Minimal semantic versioning library for Bare

Latest version **1.1.0** (published 2026-06-23) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install bare-semver
pnpm add bare-semver
yarn add bare-semver
bun add bare-semver
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-06-23 |
| First published | 2024-11-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 30.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | Holepunch |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/bare-semver
- Repository: https://github.com/holepunchto/bare-semver
- Homepage: https://github.com/holepunchto/bare-semver#readme
- Issues: https://github.com/holepunchto/bare-semver/issues
- npm.io page: https://npm.io/package/bare-semver

## Recent versions

- 1.1.0 (latest) — 2026-06-23
- 1.0.4 — 2026-06-19
- 1.0.3 — 2026-04-08
- 1.0.2 — 2025-10-23
- 1.0.1 — 2024-11-26
- 1.0.0 — 2024-11-13

## README

# bare-semver

Minimal semantic versioning library for Bare.

```
npm i bare-semver
```

## Usage

```js
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) // true
```

## API

#### `const satisfied = semver.satisfies(version, range)`

Test whether `version` satisfies `range`. Both `version` and `range` may be strings, in which case they will be parsed.

#### `semver.constants`

An object containing the comparison operator constants:

```js
constants = {
  EQ: 1,
  LT: 2,
  LTE: 3,
  GT: 4,
  GTE: 5
}
```

#### `semver.errors`

The `SemVerError` class. Thrown when parsing invalid versions or ranges.

#### `const version = new semver.Version(major, minor, patch[, options])`

Create a new version with the given `major`, `minor`, and `patch` components.

Options include:

```js
options = {
  prerelease: [],
  build: []
}
```

#### `version.major`

The major version number.

#### `version.minor`

The minor version number.

#### `version.patch`

The patch version number.

#### `version.prerelease`

An array of prerelease tags.

#### `version.build`

An array of build metadata tags.

#### `const result = version.compare(other)`

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.

#### `const string = version.toString()`

Return the string representation of `version`.

#### `const version = semver.Version.parse(input)`

Parse a semantic version string into a `Version` instance. Throws a `SemVerError` with code `INVALID_VERSION` if `input` is not a valid version string.

#### `const result = semver.Version.compare(a, b)`

Compare two `Version` instances, returning `1`, `-1`, or `0`.

#### `const comparator = new semver.Comparator(operator, version)`

Create a new comparator with the given `operator` constant and `version`.

#### `comparator.operator`

The comparison operator constant.

#### `comparator.version`

The `Version` instance to compare against.

#### `const satisfied = comparator.test(version)`

Test whether `version` satisfies the comparator.

#### `const string = comparator.toString()`

Return the string representation of the comparator, e.g. `>=1.0.0`.

#### `const range = new semver.Range([comparators])`

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.

#### `range.comparators`

The two-dimensional array of `Comparator` instances.

#### `const satisfied = range.test(version)`

Test whether `version` satisfies the range.

#### `const string = range.toString()`

Return the string representation of the range.

#### `const range = semver.Range.parse(input)`

Parse a range string into a `Range` instance. Supports the following syntax, which is desugared into sets of comparators following the [npm advanced range syntax](https://www.npmjs.com/package/semver#advanced-range-syntax):

- Comparison operators: `<`, `<=`, `>`, `>=`, `=`, e.g. `>=1.2.3`.
- Logical OR of comparator sets: `||`, e.g. `1.2.3 || >=2.0.0`.
- Caret ranges: `^1.2.3` allows changes that do not modify the left-most non-zero component, e.g. `^1.2.3` is `>=1.2.3 <2.0.0-0` and `^0.2.3` is `>=0.2.3 <0.3.0-0`.
- Tilde ranges: `~1.2.3` allows patch-level changes if a minor version is specified and minor-level changes if not, e.g. `~1.2.3` is `>=1.2.3 <1.3.0-0` and `~1` is `>=1.0.0 <2.0.0-0`. `~>` is accepted as an alias for `~`.
- X-ranges: `x`, `X`, or `*` stand in for a component, e.g. `1.2.x` is `>=1.2.0 <1.3.0-0` and `*` is `>=0.0.0`. Partial versions such as `1` and `1.2` are treated as X-ranges.
- Hyphen ranges: `1.2.3 - 2.3.4` specifies an inclusive set, expanding to `>=1.2.3 <=2.3.4`. A partial upper bound caps the range, e.g. `1.2.3 - 2.3` is `>=1.2.3 <2.4.0-0`.

## License

Apache-2.0

---
_Source: https://npm.io/package/bare-semver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
