https://github.com/boxuk/versions
Simple tool for comparing version numbers in Clojure and ClojureScript
https://github.com/boxuk/versions
Last synced: 16 days ago
JSON representation
Simple tool for comparing version numbers in Clojure and ClojureScript
- Host: GitHub
- URL: https://github.com/boxuk/versions
- Owner: boxuk
- Created: 2012-01-29T16:09:29.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2013-05-28T13:16:31.000Z (about 13 years ago)
- Last Synced: 2026-06-23T07:08:41.456Z (about 1 month ago)
- Language: Clojure
- Homepage: http://www.boxuk.com
- Size: 165 KB
- Stars: 2
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Versions [](http://travis-ci.org/boxuk/versions) [](http://clj-deps.herokuapp.com/github/boxuk/versions)
Versions is a super-simple library for comparing version numbers.
## Usage
Just pass version strings to the comparison functions.
```clojure
(use boxuk.versions)
(later-version? "1.0.0" "1.0.1") ; true
(later-version? "2.1.0" "1.2.0") ; false
(earlier-version? "1.0" "0.0.9" ) ; true
(earlier-version? "0.9.0" "0.10" ) ; false
(same-version? "0.1" "0.1.0.0.0.0" ) ; true
(same-version? "2.1" "1.2") ; false
```
You can also filter a sequence for the latest or earliest version.
```clojure
(latest-version ["1.1" "2.3"]) ; "2.3"
(earliest-version ["2.4" "3.4.2"]) ; "2.4"
```
## Stable/Unstable
Versions can make a distinction between stable and unstable versions.
Unstable versions are anything postfixed with for example _alpha_, _RC_, or _SNAPSHOT_.
```clojure
(stable? "1.2.3-SNAPSHOT") ; false
(unstable? "1.2.3-alpha2") ; true
(latest-stable ["1.2.2" "1.2.2-SNAPSHOT"] ; "1.2.2"
```
The order of comparison for unstable versions is:
```clojure
(> "SNAPSHOT" "RC" "beta" "alpha")
```
# Installation
Versions is available from [Clojars](http://clojars.org/boxuk/versions)
## ClojureScript
Versions also supports being used via ClojureScript.
## License
Dual licensed under GPLv2 and MIT.