Socket
Socket
Sign inDemoInstall

semver-diff

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    semver-diff

Get the diff type of two semver versions: 0.0.1 0.0.2 → patch


Version published
Weekly downloads
7M
decreased by-1.02%
Maintainers
1
Install size
72.6 kB
Created
Weekly downloads
 

Package description

What is semver-diff?

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.

What are semver-diff's main functionalities?

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'"

Other packages similar to semver-diff

Readme

Source

semver-diff Build Status

Get the diff type of two semver versions: 0.0.1 0.0.2patch

Install

$ npm install semver-diff

Usage

const semverDiff = require('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

API

semverDiff(versionA, versionB)

Returns the difference type between two semver versions, or undefined if they're identical or the second one is lower than the first.

Possible values: 'major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease', 'build', undefined.

  • latest-semver - Get the latest stable semver version from an array of versions
  • to-semver - Get an array of valid, sorted, and cleaned semver versions from an array of strings
  • semver-regex - Regular expression for matching semver versions
  • semver-truncate - Truncate a semver version: 1.2.31.2.0

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Keywords

FAQs

Last updated on 14 Oct 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc