Package Exports
- compare-versions
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (compare-versions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
compare-versions
Compare semver version strings to find which is greater, equal or lesser. Runs in the browser as well as node.js/iojs.
Install
$ bower install compare-versions --save
Usage
var compareVersions = require('compare-versions');
compareVersions('10.1.8', '10.0.4'); // 1
compareVersions('10.0.1', '10.0.1'); // 0
compareVersions('10.1.1', '10.2.2'); // -1
Can also be used for sorting:
var versions = [
'1.5.19'
'1.2.3',
'1.5.5',
];
console.log(versions.sort(compareVersions));
Outputs:
[
'1.2.3',
'1.5.5',
'1.5.19'
]