1.0.0 • Published 11 years ago

semver-compare v1.0.0

Weekly downloads
5,601,044
License
MIT
Repository
github
Last release
11 years ago

semver-compare

compare two semver version strings, returning -1, 0, or 1

The return value can be fed straight into [].sort.

build status

example

var cmp = require('semver-compare');
var versions = [
    '1.2.3',
    '4.11.6',
    '4.2.0',
    '1.5.19',
    '1.5.5',
    '4.1.3',
    '2.3.1',
    '10.5.5',
    '11.3.0'
];
console.log(versions.sort(cmp).join('\n'));

prints:

1.2.3
1.5.5
1.5.19
2.3.1
4.1.3
4.2.0
4.11.6
10.5.5
11.3.0

whereas the default lexicographic sort (versions.sort()) would be:

1.2.3
1.5.19
1.5.5
10.5.5
11.3.0
2.3.1
4.1.3
4.11.6
4.2.0

methods

var cmp = require('semver-compare')

cmp(a, b)

If the semver string a is greater than b, return 1. If the semver string b is greater than a, return -1. If a equals b, return 0;

install

With npm do:

npm install semver-compare

license

MIT

please-upgrade-nodearchetype-librarychatbotcedocker-app-wrapperreact-native-bluetooth2agent-interfaceairscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notification@dotedu/ivx-app-story-playergraphxr-api-test4@jttechnic/interpretertrezor-link-browser-extensiongraphxr-api@newhorizon-tech/dd-npm-package-templateone-indexunblock-block-save-variables@infinitebrahmanuniverse/nolb-semvzfweb-cli@everything-registry/sub-chunk-2731tailwind-vector-effecttag-old-releasest.js-bla-blawin-find-jscript-compilerwebcheweweb-cliwx-mobtelefonica-libsvavatarthe-real-deployinatorvsts-task-tool-libvue-compmentvision-camera-plugin-scan-facesv9u-smb2-singstorvcloudcam-playkit-js-hlsverdaccio-offline-storageverdaccio-offline-storage-shlatchzvue-dev-clone@cryptocode99/token-lists@corelmax/react-native-my2c2p-sdk@dadi/boot@detools/appium-helper@blocklet/discuss-kit-ux@camunda/form-linting@camunda/linting@rapidload/page-optimizer@rbc-public/react-selectable-fastivx-story-playerjson-comb-corejnf-accesscontrol-rnttljoi-to-jsonjoi-to-json-smackggjangod-iweb-clikerneltoollaoitdev-core-pluginskudadfeuk-frontenddfeuk-frontend-manual@coinwisebr/safewise-jsapi@coinwisebr/safewise-link@coinwisebr/safewise.js@ercos/componentsstnenopmoc-iutt-ide-clitt-minigame-ide-clitypedoc-plugin-toc-group-modtypeorm-polymorphic-clonetipsi-appium-helpertrezor-link-nodetrezor.jstrezor.js-nodetrgkanki-template-clitrimbledesktopclienttriviabottwine-libtwine-library@apardellass/react-native-audio-stream@artilleryio/platform-fargate@arielapaula/components@arielapaula/test@aleph/nought-dev-scripts@cjbarth/github-release-notes@charliec3/gh-actions-example@charliec3/gh-actions-example-docs@charliec3/gh-actions-example-docs2@acceleratxr/electron-shared@bellese/version-toggle@botique/libphonenumber-js@dharmax/baselineykit-config-mockyt-playlist-proyoutube-playlist-playerwbfilmgrwebpack-mkcert-pluginvirsical-bpmn-js-properties-panelupdate-available
1.0.0

11 years ago