Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

semver-compare-range

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semver-compare-range

Compare two semver version or version range strings.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

semver compare

Build Status Dependency Status Coverage Status

NPM

Compare two semver version or version range strings, returning -1,0,1. To be used by passing into [].sort(). Developed to order versioned sql files to ensure proper order of execution.

Example

var cmp = require('semver-compare-all');
var versions = [
    '1.0.0',
    '0.0.1 - 0.0.9',
    '1.1.0 - 1.1.0',
    '0.0.0 - 0.0.1',
    '0.0.0',
    '0.0.9 - 1.0.0',
];
console.log(versions.sort(cmp).join('\n'));

Example Return

0.0.0
0.0.0 - 0.0.1
0.0.1 - 0.0.9
0.0.9 - 1.0.0
1.0.0
1.0.0 - 1.1.0

Methods

var cmp = require('semver-compare-range');

cmp(a,b)

  • * or (empty string) will return -1.
  • Invalid version will return 0.
  • a < b return -1; a == b return 0; a > b return 1.
  • When a is not a version range and b is a version range: a <= min(b) return -1; a > min(b) return 1.
  • When a and b are version ranges: min(a) < min(b) return -1; min(a) > min(b) return 1; min(a) == min(b) && max(a) < max(b) return -1; min(a) == min(b) && max(a) > max(b) return 1; a == b return 0.

Install

npm install semver-compare-range

License

MIT

Keywords

FAQs

Package last updated on 01 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc