SemiVer is a lightweight (187B) utility designed for accurate comparison of semantic version strings, including those with pre-release identifiers (e.g., `1.0.0-alpha.1` vs `1.0.0-beta`). It leverages the native JavaScript `Intl.Collator` API to perform language-sensitive string comparisons, ensuring correctness across various versioning formats. The library is currently stable at version 1.1.0 and is actively maintained with an as-needed release cadence for bug fixes and minor enhancements. Its primary differentiators are its minimal bundle size, its reliance on a native Web API rather than a heavy parsing library, and its direct compatibility with `Array.sort()` as a comparison function, making it an efficient choice for sorting version lists without external dependencies. Unlike other semver utilities that provide parsing and range matching, SemiVer focuses solely on providing a three-way comparison, outputting `0`, `1`, or `-1`.
npm install semiverVerified import paths — ran on the pinned version, not inferred.
Demonstrates how `semiver` can be used directly as a comparison function for `Array.sort()` to sort an array of semantic version strings, including pre-release identifiers, in ascending order.
Ensure the target environment supports `Intl.Collator`. For extremely old environments, consider polyfills, though this is rarely necessary for current usage.
Always ensure that input strings are valid semantic versions to guarantee accurate comparisons.
Update your Node.js version (Node.js 6+ includes `Intl.Collator`) or ensure your browser environment is modern enough (Chrome 24+, Firefox 29+, Edge 12+, Safari 10+).
Verify that `semiver` is correctly imported via `import semiver from 'semiver';` (ESM) or `const semiver = require('semiver');` (CJS) and then passed directly to `Array.sort()` like `arr.sort(semiver)`.No dependency data recorded yet.