Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

addons-moz-compare

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

addons-moz-compare - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "addons-moz-compare",
"version": "1.0.0",
"version": "1.0.1",
"description": "JS implementation to compare add-on versions.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -5,4 +5,38 @@ # addons-moz-compare

A JavaScript library to compare Mozilla add-on versions.
A JavaScript library to compare Mozilla add-on versions that follow the [Manifest Version Format](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version/format).
For more information: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version/format
## API
This library exposes a `mozCompare()` function that takes two (string) versions `A` and `B` and returns:
- `-1` if `A < B`
- `0` if `A == B`
- `1` if `A > 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`).
## Usage
```
npm i addons-moz-compare
```
or
```
yarn add addons-moz-compare
```
### Node
```
const { mozCompare } = require('addons-moz-compare');
```
### Browser
Use `window.mozCompare` after having included the source of this library.
## License
This plugin is released under the Mozilla Public License Version 2.0. See the bundled [LICENSE](./LICENSE.txt) file for details.

@@ -1,2 +0,2 @@

(function addonsMozComparator() {
(function addonsMozCompare() {
const compareParts = (partA, partB) => {

@@ -10,2 +10,4 @@ if (partA === partB) {

// This isn't strictly a bytewise comparison but it has conditions that
// `compareParts()` does not have.
const compareByteWiseParts = (partA, partB) => {

@@ -50,3 +52,3 @@ if (!partA) {

const parsePart = (part) => {
// Normalize zero if needed.
// Normalize leading zero if needed.
if (!part || /^0+$/.test(part.toString())) {

@@ -118,5 +120,5 @@ return 0;

* @param versionB the second version
* @returns < 0 if A < B
* = 0 if A == B
* > 0 if A > B
* @returns -1 if A < B
* 0 if A == B
* 1 if A > B
*/

@@ -123,0 +125,0 @@ const mozCompare = (versionA, versionB) => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc