Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adaxi/dpkg-compare-versions
Pure javascript implementation of the "dpkg --compare-versions" functionality
https://github.com/adaxi/dpkg-compare-versions
Last synced: 3 months ago
JSON representation
Pure javascript implementation of the "dpkg --compare-versions" functionality
- Host: GitHub
- URL: https://github.com/adaxi/dpkg-compare-versions
- Owner: adaxi
- License: mit
- Created: 2019-07-02T20:54:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T04:16:16.000Z (almost 2 years ago)
- Last Synced: 2024-09-29T02:40:55.147Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 791 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
dpkg --compare-versions
=======================
Pure javascript implementation of the `dpkg --compare-versions` functionality.This implementation is a port of the C implementation of [dpkg](https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/version.c).
Supports epoch, version and revision.Usage
-----First you will need to install from the npm [package repository](https://www.npmjs.com/package/dpkg-compare-versions):
`npm install --save dpkg-compare-versions`
Then you'll be able to require it in your program.
```js
const compare = require('dpkg-compare-versions');
compare('1.1.1', '1.0.1') // returns 1
compare('1.0.0', '1.0.0') // returns 0
compare('1.0.0~rc1', '1.0.0') // returns -1
compare('2:1.0.0', '1:2.0.0') // returns 1
```You can also use this function to sort packages:
```js
const compare = require('dpkg-compare-versions')
const versions = [ '2.1', '1.2.2', '3-3' ]
versions.sort(compare) // versions = [ '1.2.2', '2.1', '3-3' ]
```You can find more information about how sorting works in the [deb-version (5)](https://manpages.debian.org/buster/dpkg-dev/deb-version.7.en.html) manual page.
Tests
-----Tests can be run by executing the command `npm test`. This will run [standard](https://standardjs.com/) and [jest](https://jestjs.io/).
The package has 100% coverage tests. This can be verified by running `npm run coverage`.Contributions
-------------Contributions are welcome, but are expected to pass the `npm test` command.