Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
semver-diff
Advanced tools
Package description
The semver-diff npm package is a utility for comparing two semantic version numbers and determining the type of version difference between them. It can identify whether the change is a major, minor, patch, pre-release, or build difference.
Version difference identification
This feature allows you to compare two semantic version numbers and determine the type of change. The code sample demonstrates how to use semver-diff to compare versions '1.0.0' and '2.0.0', which would log 'major' as the type of version difference.
"use strict";
const semverDiff = require('semver-diff');
const diffType = semverDiff('1.0.0', '2.0.0');
console.log(diffType); // 'major'"
The semver package is a more comprehensive semantic version parser and utility. It includes functions for parsing, comparing, and incrementing version numbers, as well as determining version precedence. Compared to semver-diff, semver offers a broader set of tools for working with semantic versions beyond just identifying the difference between two versions.
Compare-versions is a simple utility for comparing and sorting semantic version numbers. It provides a straightforward API for comparing version strings and determining their order. While semver-diff specifically identifies the type of version difference, compare-versions focuses on comparison and sorting without categorizing the type of change.
Readme
Get the diff type of two semver versions:
0.0.1 0.0.2
→patch
$ npm install --save semver-diff
var semverDiff = require('semver-diff');
semverDiff('1.1.1', '1.1.2');
//=> 'patch'
semverDiff('0.0.1', '1.0.0');
//=> 'major'
semverDiff('0.0.1', '0.1.0');
//=> 'minor'
semverDiff('0.0.1-foo', '0.0.1-foo.bar');
//=> 'prerelease'
semverDiff('0.1.0', '0.1.0+foo');
//=> 'build'
semverDiff('0.0.1', '0.0.1');
//=> null
semverDiff('0.0.2', '0.0.1');
//=> null
Returns the difference type between two semver versions, or null
if they're identical or the second one is lower than the first.
Possible values: 'major'
, 'minor'
, 'patch'
, 'prerelease'
, 'build'
, null
.
MIT © Sindre Sorhus
FAQs
Get the diff type of two semver versions: 0.0.1 0.0.2 → patch
The npm package semver-diff receives a total of 5,681,723 weekly downloads. As such, semver-diff popularity was classified as popular.
We found that semver-diff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.