compare-versions

Zero-dependency semver comparison for Node.js and the browser, with support for ranges, wildcards, and Chromium-style versions.

Library
npm
v6.1.1
637 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
32 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 48
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
74 /100 Good
Architecture 74
Code Quality 78
Innovation 60
Learning Curve 82

compare-versions is a tiny, dependency-free library for comparing semantic version strings to determine which is greater, equal, or lesser. It implements the full semver specification, including versions with a varying number of segments (1, 1.0, 1.0.0), pre-release identifiers (1.0.0-alpha), wildcards (1.0.x), 4-part Chromium-style versions (25.0.1364.126), and npm-style version ranges (^1.2.3, 1.2.7 || >=1.2.9 <2.0.0).

The library exposes a small set of composable functions — compareVersions, compare, satisfies, validate, and validateStrict — and ships as ESM, CJS/UMD, and a browser global, making it usable directly in Array.prototype.sort, feature-flagging logic, or dependency-range checks without pulling in a full semver toolchain.

What You Get

  • compareVersions(v1, v2) returning -1/0/1, directly usable as an Array.sort comparator
  • compare(v1, v2, operator) for human-readable comparisons using >, <, =, >=, <=
  • satisfies(version, range) supporting npm-style semver ranges (^, ~, ||, hyphen ranges)
  • validate/validateStrict for lenient vs. strict semver-format checking
  • ESM, CJS/UMD, and browser-global builds with zero runtime dependencies

Common Use Cases

  • Sorting a list of release/version strings into semantic order
  • Gating a feature or migration behind a minimum required version check
  • Validating user- or config-supplied version strings before further processing
  • Checking whether an installed dependency version satisfies an npm-style range

Under The Hood

Architecture The library splits into single-purpose modules: utils.ts holds the shared validateAndParse/compareSegments parsing logic, and compareVersions.ts, compare.ts, satisfies.ts, and validate.ts each build a small, independent public function on top of that shared parser. index.ts simply re-exports each function, so the whole public API is composed from a handful of pure, side-effect-free functions rather than a single monolithic parser class.

Tech Stack Written in TypeScript, compiled to ESM via tsc and bundled to UMD via Rollup for the lib/umd browser/CJS build. It has zero runtime dependencies (sideEffects: false in package.json), and tests run under Mocha with c8 for coverage.

Code Quality The test/ directory maps directly onto the public API surface (compare.ts, satisfies.ts, sort.ts, validate.ts), giving each exported function its own dedicated suite. Functions are short, pure, and rely on shared parsing/validation helpers instead of duplicating segment-comparison logic across each entry point, keeping the exposed behavior consistent across compare, satisfies, and compareVersions.

API Design The API favors small, single-purpose functions over one configurable object, and documents each one with JSDoc directly in source. Since v5 the main export is named (import { compareVersions } from 'compare-versions') rather than default, aligning with modern ESM conventions, and the human-readable compare(v1, v2, '>') variant lowers the learning curve for callers unfamiliar with sort-comparator return values.

Used by 16 apps in this directory

Svelte
32%
GPL 3.0

Mathesar

Databases

5,158

Spreadsheet-like interface for your PostgreSQL database — self-hosted, no SQL required, native Postgres access control.

View details
70
Repo Health
80
Technical
68
Dependency
Built with
Svelte 32%
TypeScript 27%
Python 21%
Updated 6 days ago
TypeScript
65%
Other

NocoDB

Databases · Low Code Platforms · No Code Platforms

65,340

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
91
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 65%
Vue 30%
Updated 5 days ago
JavaScript
88%
GPL 3.0

NodeBB

Community

15,242

Modern Node.js forum software with real-time WebSockets, multi-database support, and a plugin ecosystem — the community platform built for the open web and the Fediverse.

View details
97
Repo Health
78
Technical
70
Dependency
Built with
JavaScript 88%
Go Template 11%
Updated 5 days ago
TypeScript
99%
Other

Rowy

Databases · Low Code Platforms

6,842

Manage Firestore data in an Airtable-like spreadsheet UI and build Cloud Functions workflows directly in your browser—on your own GCP project.

View details
45
Repo Health
71
Technical
65
Dependency
Built with
TypeScript 99%
Updated 1 years ago
TypeScript
83%
AGPL 3.0

Standard Notes

Note Taking

6,681

End-to-end encrypted notes and files — private by design, built to last, and fully self-hostable.

View details
89
Repo Health
83
Technical
68
Dependency
Built with
TypeScript 83%
JavaScript 14%
Updated 6 days ago
Rust
93%
Other

Tabby

AI Code Assistants

33,924

Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.

View details
55
Repo Health
78
Technical
61
Dependency
Built with
Rust 93%
Updated 4 months ago
JavaScript
56%
MIT

Uptime Kuma

Monitoring

92,816

Self-hosted monitoring for every service you run — 23 monitor types, 95 notification channels, live dashboards, and public status pages with no vendor lock-in.

View details
92
Repo Health
81
Technical
62
Dependency
Built with
JavaScript 56%
Vue 41%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers