{"id":23817807,"url":"https://github.com/lsongdev/semver","last_synced_at":"2026-05-06T09:30:20.835Z","repository":{"id":68774093,"uuid":"283165971","full_name":"lsongdev/semver","owner":"lsongdev","description":":package: Semantic Versioning Comparer","archived":false,"fork":false,"pushed_at":"2020-08-03T10:18:25.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T22:23:48.243Z","etag":null,"topics":["semver"],"latest_commit_sha":null,"homepage":"https://semver.org","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lsongdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"song940","patreon":"song940","open_collective":"song940","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://git.io/fjRcB"}},"created_at":"2020-07-28T09:32:51.000Z","updated_at":"2021-08-18T02:32:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"dbdf0f0c-8872-44d5-a9ee-605898d537a3","html_url":"https://github.com/lsongdev/semver","commit_stats":null,"previous_names":["lsongdev/semver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fsemver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fsemver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fsemver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fsemver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lsongdev","download_url":"https://codeload.github.com/lsongdev/semver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240093155,"owners_count":19746780,"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":["semver"],"created_at":"2025-01-02T05:48:48.151Z","updated_at":"2026-05-06T09:30:20.774Z","avatar_url":"https://github.com/lsongdev.png","language":"JavaScript","funding_links":["https://github.com/sponsors/song940","https://patreon.com/song940","https://opencollective.com/song940","https://git.io/fjRcB"],"categories":[],"sub_categories":[],"readme":"# semver\n\n\u003e A tiny utility to compare semver strings.\n\n[![Build Status](https://travis-ci.org/song940/semver.svg?branch=master)](https://travis-ci.org/song940/semver)\n\nCompare semver strings (eg, `1.8.2`, `2.0.0-next.6`, `0.0.0-alpha-1`, etc) \n\nThe output will always be `0`, `1`, or `-1`, allowing `semver` 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\n## Install\n\n```\n$ npm install --save @song940/semver\n```\n\n## Usage\n\n```js\nimport semver from '@song940/semver';\n\n// A === B\nsemver('0.0.0', '0.0.0'); //=\u003e 0\nsemver('1.2.3', '1.2.3'); //=\u003e 0\n\n// A \u003e B\nsemver('2.1.0', '1.9.0'); //=\u003e 1\nsemver('1.9.1', '1.9.0'); //=\u003e 1\nsemver('10.0.0', '1.0.0'); //=\u003e 1\nsemver('10.0.0', '8.9.0'); //=\u003e 1\nsemver('1.2.3-next.10', '1.2.3-next.6'); //=\u003e 1\nsemver('2.0.0-alpha-10', '2.0.0-alpha-6'); //=\u003e 1\nsemver('2.0.0-beta.1', '2.0.0-alpha.8'); //=\u003e 1\n\n// A \u003c B\nsemver('1.9.0', '2.1.0'); //=\u003e -1\nsemver('1.9.0', '1.9.1'); //=\u003e -1\nsemver('1.0.0', '10.0.0'); //=\u003e -1\nsemver('8.9.0', '10.0.0'); //=\u003e -1\nsemver('1.2.3-next.6', '1.2.3-next.10'); //=\u003e -1\nsemver('2.0.0-alpha-6', '2.0.0-alpha-10'); //=\u003e -1\nsemver('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(semver);\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### semver(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## License\n\nMIT © [Liu Song](https://lsong.org)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsongdev%2Fsemver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flsongdev%2Fsemver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsongdev%2Fsemver/lists"}