npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

major-version-check

v1.4.1

Published

A small module to check if two specified version numbers are major changes

Downloads

5

Readme

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 version is a major change.


Changelog (v1.4.1)

Fixed conflict in docs.
• Added new function to readme.md.
• Added new function to tests.
• 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 Typescript 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 Typescript 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' })}`);

Thats 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 |