A JavaScript library to compare Mozilla add-on versions that follow the Manifest Version Format.
This library exposes a mozCompare()
function that takes two (string) versions A
and B
and returns:
-1
ifA < B
0
ifA == B
1
ifA > B
This implementation matches the Firefox implementation except that there are only 3 different possible return values (Firefox returns strictly negative and strictly positive values instead of -1
and 1
).
npm i addons-moz-compare
or
yarn add addons-moz-compare
const { mozCompare } = require('addons-moz-compare');
Use window.mozCompare
after having included the source of this library.
This plugin is released under the Mozilla Public License Version 2.0. See the bundled LICENSE file for details.