Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
vending-agent-dep / usr / local / lib / vending / agent / node_modules / dpkg-compare-versions
  ..
  dpkg-compare.test.js
  package.json
  dpkg-compare.js
  .editorconfig
  README.md
Size: Mime:

dpkg --compare-versions

Pure javascript implementation of the dpkg --compare-versions functionality.

This implementation is a port of the C implementation of dpkg. Supports epoch, version and revision.

Usage

First you will need to install from the npm package repository:

npm install --save dpkg-compare-versions

Then you'll be able to require it in your program.

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:

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) manual page.

Tests

Tests can be run by executing the command npm test. This will run standard and jest. 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.