talira

pub_semver

Version numbers and version constraints the way pub handles them, in Dart

open sourceBSD-3-Clausefree

pub_semver is the Dart team's package for parsing and comparing version numbers and version constraints the way the pub package manager does. It follows Semantic Versioning closely, with a few deliberate differences: build suffixes count when ordering versions, pre-releases of a range's upper bound are excluded (so <2.0.0 doesn't allow 2.0.0-beta), and pre-release versions are avoided when a stable one fits. It has Version, VersionConstraint and VersionRange types with operations such as intersect and union. It lives in the dart-lang/tools repository and is under the BSD-3-Clause licence.

Problems it solves

  • compare semantic version numbers in Dart
  • check whether a version satisfies a constraint like ^1.2.0 in Dart
  • resolve package version ranges the same way pub does

Features

  • parses semantic version numbers and constraints
  • pub's ordering of build suffixes and pre-releases
  • version ranges with intersection and union

Limitations

  • Follows pub's rules, which differ from the Semantic Versioning spec in a few corner cases such as build suffix ordering1

Alternatives

The same job

These do what pub_semver does.

  1. version (Dart) Parse, compare and increment semantic versions in Dart

Compare pub_semver with the top 3