Coder Social home page Coder Social logo

semver-range's Introduction

semver-range | dependencies Status Build Status

npm package (research tool) to help with comparison of semantic version ranges (semver).

  • semver-range.Comparison categorize changes into upgrade, downgrade, not changed, prerelease, url, and other.
  • semver-range.Diff categorizes changes into major, premajor, minor, premino, patch, prepatch, prerelease, url, and other

For example you can use this tool if you want to compare ^4.0.x and 4.x which is technically no change in the version.

Example usage:

const semverCompare = require('./semver-range').semverCompare;
const semverDiff = require('./semver-range').semverDiff;

console.log('^4.0.x AND 4.x: ', semverCompare('^4.0.x', '4.x'), '~', semverDiff('^4.0.x', '4.x'));

// output:
// ^4.0.x AND 4.x:  not_changed ~ other

see test.js for more examples, and run npm test to print examples to stdout.

Note:

In some cases it's hard to tell if a change of version will actually result in an upgrade or downgrade and it can be different depending on the package. To resolve this issue I made some assumptions which you should consider if you use this package. It is as described bellow: When comparing v1 and v2, Each range has an upper bound and a lower bound.

  • If v2.upper is decreased and v2.lower is increased it can be upgrade or downgrade depending on the latest version of that specific package o n npm.
  • If v1 or v2 is a latest, stable, etc then it will be categorized as 'other'!
  • Upgrade = When v2.lower and/or v2.upper is increased (May not be an upgrade depending on latest version of that specific package o n npm.)
  • Downgrade = When v2.upper is decreased (May not be an downgrade depending on latest version of that specific package o n npm.)

TO-DO:

  • Refactoring
  • More test cases

semver-range's People

Contributors

azure-pipelines[bot] avatar dependabot-preview[bot] avatar dependabot[bot] avatar ssmirr avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.