
Research
Security News
Malicious npm Packages Use Telegram to Exfiltrate BullX Credentials
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
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 semver-diff
import semverDiff from 'semver-diff';
semverDiff('1.1.1', '1.1.2');
//=> 'patch'
semverDiff('1.1.1-foo', '1.1.2');
//=> 'prepatch'
semverDiff('0.0.1', '1.0.0');
//=> 'major'
semverDiff('0.0.1-foo', '1.0.0');
//=> 'premajor'
semverDiff('0.0.1', '0.1.0');
//=> 'minor'
semverDiff('0.0.1-foo', '0.1.0');
//=> 'preminor'
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');
//=> undefined
semverDiff('0.0.2', '0.0.1');
//=> undefined
Returns the difference type between two semver versions, or undefined
if they are identical or the second one is lower than the first.
Possible values:
'major'
,'premajor'
,'minor'
,'preminor'
,'patch'
,'prepatch'
,'prerelease'
,'build'
,undefined
1.2.3
→ 1.2.0
FAQs
Get the diff type of two semver versions: 0.0.1 0.0.2 → patch
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.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.
Security News
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.