Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
semver-diff
Advanced tools
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.
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.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,677,412 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.