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

semver-compare

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semver-compare

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

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.7M
increased by2.13%
Maintainers
1
Weekly downloads
 
Created

What is semver-compare?

The semver-compare npm package is a simple utility for comparing semantic version strings. It allows developers to determine the order of semantic versions, check if one version is greater than, less than, or equal to another, and sort arrays of version strings.

What are semver-compare's main functionalities?

Compare two semantic version strings

This feature allows you to compare two semantic version strings and returns -1, 0, or 1 depending on whether the first version is less than, equal to, or greater than the second version.

"const compare = require('semver-compare');
let result = compare('1.2.3', '1.2.4');
console.log(result); // -1"

Sort an array of semantic version strings

This feature allows you to sort an array of semantic version strings in ascending order using the compare function provided by the package.

"const compare = require('semver-compare');
let versions = ['1.2.3', '1.2.4', '1.2.2'];
versions.sort(compare);
console.log(versions); // ['1.2.2', '1.2.3', '1.2.4']"

Other packages similar to semver-compare

Keywords

FAQs

Package last updated on 08 Nov 2014

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