{"id":13725714,"url":"https://github.com/lukeed/semiver","last_synced_at":"2025-10-09T18:24:31.997Z","repository":{"id":41553776,"uuid":"187420302","full_name":"lukeed/semiver","owner":"lukeed","description":"A tiny (153B) utility to compare semver strings.","archived":false,"fork":false,"pushed_at":"2024-07-04T11:55:41.000Z","size":11,"stargazers_count":123,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-11T17:50:28.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukeed.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-19T01:14:21.000Z","updated_at":"2024-09-19T18:20:43.000Z","dependencies_parsed_at":"2022-08-26T05:10:58.510Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/semiver","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fsemiver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fsemiver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fsemiver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fsemiver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/semiver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224645556,"owners_count":17346184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:02:32.234Z","updated_at":"2025-10-09T18:24:31.905Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","readme":"# semiver [![Build Status](https://badgen.now.sh/travis/lukeed/semiver)](https://travis-ci.org/lukeed/semiver)\n\n\u003e A tiny (187B) utility to compare semver strings.\n\nCompare semver strings (eg, `1.8.2`, `2.0.0-next.6`, `0.0.0-alpha-1`, etc) using the [`Intl.Collator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator) class.\u003cbr\u003e\nVersion suffixes are supported and are considered during comparison.\n\nThe output will always be `0`, `1`, or `-1`, allowing `semiver` to be used directly as a compare function for [`Array.sort()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort).\n\nThis module exposes three module definitions:\n\n* **ES Module**: `dist/semiver.mjs`\n* **CommonJS**: `dist/semiver.js`\n* **UMD**: `dist/semiver.min.js`\n\n\n## Install\n\n```\n$ npm install --save semiver\n```\n\n\n## Usage\n\n```js\nimport semiver from 'semiver';\n\n// A === B\nsemiver('0.0.0', '0.0.0'); //=\u003e 0\nsemiver('1.2.3', '1.2.3'); //=\u003e 0\n\n// A \u003e B\nsemiver('2.1.0', '1.9.0'); //=\u003e 1\nsemiver('1.9.1', '1.9.0'); //=\u003e 1\nsemiver('10.0.0', '1.0.0'); //=\u003e 1\nsemiver('10.0.0', '8.9.0'); //=\u003e 1\nsemiver('1.2.3-next.10', '1.2.3-next.6'); //=\u003e 1\nsemiver('2.0.0-alpha-10', '2.0.0-alpha-6'); //=\u003e 1\nsemiver('2.0.0-beta.1', '2.0.0-alpha.8'); //=\u003e 1\n\n// A \u003c B\nsemiver('1.9.0', '2.1.0'); //=\u003e -1\nsemiver('1.9.0', '1.9.1'); //=\u003e -1\nsemiver('1.0.0', '10.0.0'); //=\u003e -1\nsemiver('8.9.0', '10.0.0'); //=\u003e -1\nsemiver('1.2.3-next.6', '1.2.3-next.10'); //=\u003e -1\nsemiver('2.0.0-alpha-6', '2.0.0-alpha-10'); //=\u003e -1\nsemiver('2.0.0-alpha.8', '2.0.0-beta.1'); //=\u003e -1\n\n// Sorting\n[\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].sort(semiver);\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```\n\n\n## API\n\n### semiver(a, b)\n\nReturns: `Number`\n\n* `0` indicates that `a` is equal to `b`\n* `-1` indicates that `a` is less than `b`\n* `1` indicates that `a` is greater than `b`\n\n#### a\nType: `String`\n\nThe input string to compare.\n\n#### b\nType: `String`\n\nThe string to compare against.\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","funding_links":[],"categories":["JavaScript","Packages"],"sub_categories":["Others"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fsemiver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fsemiver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fsemiver/lists"}