{"library":"semiver","title":"SemiVer String Comparator","description":"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`.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install semiver"],"cli":null},"imports":["import semiver from 'semiver';","const semiver = require('semiver');","import type semiver from 'semiver';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import semiver from 'semiver';\n\nconst versions = [\n  '4.11.6', '4.2.0',\n  '1.5.19', '1.5.5',\n  '1.0.0', '1.0.0-rc.1',\n  '1.2.3', '1.2.3-alpha',\n  '1.0.0-alpha.1', '1.0.0-alpha',\n  '1.0.0-beta.11', '1.0.0-beta'\n];\n\n// Sort an array of semver strings using semiver directly\nversions.sort(semiver);\n\nconsole.log(versions);\n/* Expected output:\n[\n  '1.0.0-alpha',\n  '1.0.0-alpha.1',\n  '1.0.0-beta',\n  '1.0.0-beta.11',\n  '1.0.0-rc.1',\n  '1.0.0',\n  '1.2.3-alpha',\n  '1.2.3',\n  '1.5.5',\n  '1.5.19',\n  '4.2.0',\n  '4.11.6'\n]\n*/","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}