Giter Site home page Giter Site logo

kk-designs / version-tools Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 373 KB

A small module to check the information about versions numbers, such as parsing version data, and checking if the two versions is a major change.

Home Page: https://www.npmjs.com/package/major-version-check

License: GNU General Public License v2.0

JavaScript 100.00%
typescript javascript nodejs npm npmjs node-package

version-tools's Introduction

versionweekly_downloadsdownloadsissueslicensemajor-version-check

Version tools

A small module to check the information about versions, such as comparing, parsing version data, and checking if the two versions are a major change.


Changelog (v1.4.1)

• Fixed conflict in docs.
• Added new function to readme.md.
• Added new function to tests.
• No longer use jest as it isn't required.
• Updated tsconfig.json.
• Added new scripts to package.json.
• Some more linting.
• Added the version check for old node versions.

To-do

• Make parseVersion() function return version numbers as a int instead of a string.


Installation

npm i major-version-check

Usage

This library is ONLY compatible with node version 14 and above

First, you must import the library using the following code:

const versionTools = require('major-version-check');
// or `import * as versionTools from 'major-version-check';` for ESM users


Then all you have to do is call the function with some values:

const versionTools = require('major-version-check');
// or `import * as versionTools from 'major-version-check';` for ESM users

// Will return true
console.log(versionTools.majorVer('1.0.0', '2.0.0'));

// Will return false
console.log(versionTools.majorVer('1.0.0', '1.0.1'));

// Will return info about the version
console.log(JSON.stringify(versionTools.parseVersion('1.0.0-beta')));

// Will return true
console.log(`Output:\n${versionTools.compare(versionTools.parseVersion('1.0.1'), versionTools.parseVersion('1.0.0'), { type: 'greaterThan' })}`);

// Will return false
console.log(`Output:\n${versionTools.compare(versionTools.parseVersion('1.0.1'), versionTools.parseVersion('1.0.0'), { type: 'lessThan' })}`);

That's it! Now you have it running!

Parameters

Parameter info for majorVer()

Parameters Type Usage Description
oldVersion string (required) majorVer(oldVersion, ...); The old version to compare
newVersion string (required) majorVer(..., newVersion); The new version to compare
options.debug boolean majorVer(..., ..., { debug: boolean }); Weather to log debug messages

Parameter info for parseVersion()

Parameters Type Usage Description
version string (required) parseVersion(version, ...); The version to parse
options.debug boolean parseVersion(..., { debug: boolean }); Weather to log debug messages

Parameter info for compare()

Parameters Type Usage Description
version object (required) compare(version, ...); The version to compare
comparator string (required) compare(..., comparator, ...); The second version to compare
options.debug boolean compare(..., ..., { debug: boolean }); Weather to log debug messages

version-tools's People

Contributors

dependabot[bot] avatar kk-designs avatar

Stargazers

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