GithubHelp home page GithubHelp logo

semver-diff's Introduction

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

Related

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

semver-diff's People

Contributors

bendingbender avatar coreyfarrell avatar gochomugo avatar narkowicz avatar richienb avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

semver-diff's Issues

Types and examples omit 'premajor', 'preminor' and 'prepatch'

The TypeScript literal return type semverDiff.Result and examples in README, JSDoc omit the following possible values that can be returned internally by node-semver:

  • 'premajor'
  • 'preminor'
  • 'prepatch'
semverDiff('1.0.0-foo', '2.0.0');
//=> 'premajor'
semverDiff('1.0.0-foo', '1.1.0');
//=> 'preminor'
semverDiff('1.0.0-foo', '1.0.1');
//=> 'prepatch'

As in npm/node-semver#83 (comment)

`build` comparisons

According to the semver spec 1.0.0+1 and 1.0.0+2 are the same version. I believe based on the documentation of semver-diff the following test should pass:

assert(semverDiff('1.0.0+2', '1.0.0+1') === undefined);

The first version is not seen as greater than the second version so the comparison continues and 'build' is returned because the build are not identical.

Ref npm/node-semver#276

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.