Semver Checker
NewCompare two semantic versions or check whether a version satisfies an npm-style range like ^1.2.0 or ~2.0.0.
—————Supports exact versions and the common npm range operators: ^ (caret), ~ (tilde), >=, >, <=, <, and x/* wildcards. Compound ranges like 1.2.x - 1.4.x or || unions are not supported.
Frequently Asked Questions
What range operators are supported?
Caret (^) and tilde (~) ranges, comparison operators (>=, >, <=, <, =), and x/* wildcard versions like "1.2.x" or "1.x". Compound ranges that combine multiple clauses with " - " or "||" are not supported.
What's the difference between caret (^) and tilde (~) ranges?
Tilde (~1.2.3) allows patch-level updates only (>=1.2.3 <1.3.0). Caret (^1.2.3) allows any update that doesn't change the left-most non-zero digit — so ^1.2.3 allows up to <2.0.0, but ^0.2.3 (a pre-1.0 package) only allows up to <0.3.0, matching npm's special handling of 0.x versions.
How are prerelease versions compared?
Per the semver spec, a version with a prerelease tag (like 1.0.0-beta.1) is always considered lower than the same version without one (1.0.0). Between two prereleases, identifiers are compared piece by piece, with numeric identifiers compared numerically and alphanumeric identifiers compared as strings.
Does build metadata (the +build part) affect comparisons?
No — per the semver spec, build metadata is ignored entirely when determining version precedence. It's parsed and shown for reference but has no effect on the comparison or range-satisfaction result.
Can I use this to check if it's safe to upgrade a dependency?
It's a good sanity check for whether a specific version falls inside a package.json range, but it doesn't replace reading the changelog — semver compliance is a convention, not a guarantee, and breaking changes occasionally slip into minor/patch releases.
Related Tools
Docker Cheatsheet
NewComplete reference for Docker CLI commands — containers, images, volumes, networks, and Compose.
Linux Commands Reference
NewSearchable reference for essential Linux/Unix commands with examples, flags, and descriptions.
Kubernetes Cheatsheet
Newkubectl reference — resources, deployments, rollouts, debugging, and troubleshooting.