Getting Started

Build Status

Package Managers

npm: npm install semver.js

bower: bower install semver.js

semver

Lightweight module to compare semver versions.

compare

Compare two semver values. Optionally accepts param to force comparison based on passed specificity (major, minor, patch).

Function
compare(firstComparator, secondComparator, specificity)

Parameters

Name Type Default Description
firstComparator string The semver string to compare with.
secondComparator string The semver string to compare against.
specificity string patch major || minor || patch.

isGreater

Determine if semver a > semver b.

Function
isGreater(firstComparator, secondComparator, specificity)

Parameters

Name Type Default Description
firstComparator string The semver string to compare with.
secondComparator string The semver string to compare against.
specificity string patch major || minor || patch.
semver.isGreater("1.0.0", "0.9.0");
// true

isLess

Determine if semver a < semver b.

Function
isLess(firstComparator, secondComparator, specificity)

Parameters

Name Type Default Description
firstComparator string The semver string to compare with.
secondComparator string The semver string to compare against.
specificity string patch major || minor || patch.
semver.isLess("0.9.0", "1.0.0");
// true

isEqual

Determine if semver a === semver b.

Function
isEqual(firstComparator, secondComparator, specificity)

Parameters

Name Type Default Description
firstComparator string The semver string to compare with.
secondComparator string The semver string to compare against.
specificity string patch major || minor || patch.
semver.isEqual("1.0.0", "1.0.0");
// true

Test

All dependencies must be installed (npm install)

Run: npm test

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Also, please don't edit files in the "dist" subdirectory as they are generated via Grunt. You'll find source code in the "lib" subdirectory!

License

The MIT License (MIT) Copyright (c) Jarid Margolin <jaridmargolin@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.