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@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-pluginskudaignite-corehomebridge-cowayhuoban-app-sdkhexyun.helpershera-clihera-wewebinspectpacklipc-bpmn-js-properties-panellerna-update-wizardledsrv-test-docker-applib-errorlive-wallpaper-ecorplrequirelwc-servicesmdlib-utils-stringsknowre-umzugmct1-server@thinkincoin-libs/token-lists@udooku/react-image-comparison-slider@torswap/tor-token-lists@thedoctor0/vuex-shared-mutations@things-factory/node-urx@vindigo/cli@upacyxou/react-native-draggable-flatlist@uxhispam/kenos-web@xswap/token-lists@yplabs-ltd/react-native-detector@yqg/max-mini-deploy@yak-spirit/yak-swap-ui@zedtk/eslint-config@zh0st/evm-chains@telefonica/mistica@zckevin/electron-asar-differential-updaterautochangelogauto-npx-containerazure-pipelines-tool-libarduino-create-agent-js-clientanyi-properties-panelanyi-bpmn-js-element-templatesartillery-proappxgenappxtest2appverse-doctorapiconnect-explorer
1.0.0

11 years ago