# addons-moz-compare

> JS implementation to compare add-on versions.

Latest version **1.4.0** (published 2026-09-09) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install addons-moz-compare
pnpm add addons-moz-compare
yarn add addons-moz-compare
bun add addons-moz-compare
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2026-09-09 |
| First published | 2021-04-21 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 24.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Mozilla Add-ons Team |
| Maintainers | addons-robot |

## Links

- npm: https://www.npmjs.com/package/addons-moz-compare
- Repository: https://github.com/mozilla/addons-moz-compare
- Issues: http://github.com/mozilla/addons-moz-compare/issues
- npm.io page: https://npm.io/package/addons-moz-compare

## Recent versions

- 1.4.0 (latest) — 2026-09-09
- 1.3.0 — 2022-11-03
- 1.2.0 — 2021-08-13
- 1.1.0 — 2021-05-31
- 1.0.2 — 2021-05-04
- 1.0.1 — 2021-04-28
- 1.0.0 — 2021-04-22
- 0.0.3 — 2021-04-21
- 0.0.2 — 2021-04-21
- 0.0.1 — 2021-04-21

## README

# addons-moz-compare

[![CircleCI](https://circleci.com/gh/mozilla/addons-moz-compare.svg?style=svg)](https://circleci.com/gh/mozilla/addons-moz-compare) [![npm version](https://badge.fury.io/js/addons-moz-compare.svg)](https://www.npmjs.com/package/addons-moz-compare)

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

## 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
```

### 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.

---
_Source: https://npm.io/package/addons-moz-compare · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
