1. semver-diff
Get the diff type of two semver versions: 0.0.1 0.0.2 → patch
semver-diff
Package: semver-diff
Created by: sindresorhus
Last modified: Mon, 10 Jul 2023 23:16:41 GMT
Version: 4.0.0
License: MIT
Downloads: 30,150,802
Repository: https://github.com/sindresorhus/semver-diff

Install

npm install semver-diff
yarn add semver-diff

semver-diff

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

Install

$ npm install semver-diff

Usage

 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

API

semverDiff(versionA, versionB)

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
  • 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.

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin