# major-version-check

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

Latest version **1.4.1** (published 2021-12-18) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install major-version-check
pnpm add major-version-check
yarn add major-version-check
bun add major-version-check
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2021-12-18 |
| First published | 2021-10-06 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14.0.0 |
| Dependencies | 1 |
| Unpacked size | 43.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | NotBacon |
| Maintainers | notbacon |
| Keywords | major, version, version check, version-tools, major-version-check, parser, semver, version-parser, first-package, javascript, typescript |

## Links

- npm: https://www.npmjs.com/package/major-version-check
- Repository: https://github.com/KK-Designs/version-tools
- Homepage: https://github.com/KK-Designs/version-tools#readme
- Issues: https://github.com/KK-Designs/version-tools/issues
- npm.io page: https://npm.io/package/major-version-check

## Dependencies (1)

- [meant](https://npm.io/package/meant.md) ^2.0.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.4.1 (latest) — 2021-12-18
- 1.4.0 — 2021-12-17
- 1.3.3 — 2021-10-10
- 1.2.2 — 2021-10-08
- 1.2.1 — 2021-10-08
- 1.0.2 — 2021-10-07
- 1.0.1 — 2021-10-06
- 1.0.0 — 2021-10-06

## README

[![version](https://img.shields.io/npm/v/major-version-check?color=blueviolet&style=for-the-badge "Version")](https://github.com/KK-Designs/version-tools/releases/tag/v1.3.3)
‎
[![weekly_downloads](https://img.shields.io/npm/dw/major-version-check?color=blue&style=for-the-badge "Weekly Downloads")](https://www.npmjs.com/package/major-version-check#:~:text=Weekly%20Downloads)
‎
![downloads](https://badgen.net/npm/dt/major-version-check "Downloads")
‎
[![issues](https://img.shields.io/github/issues/KK-Designs/KK-Designs/version-tools?style=for-the-badge "Issues")](https://github.com/KK-Designs/version-tools/issues)
‎
[![license](https://img.shields.io/github/license/KK-Designs/version-tools?color=important&style=for-the-badge "License")](https://github.com/KK-Designs/version-tools/blob/master/LICENSE)
‎
[![major-version-check](https://nodei.co/npm/major-version-check.png "Major-version-check on NPM")](https://www.npmjs.com/package/major-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:
```javascript
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:
```javascript
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 |

#
[![](backToTop.png?raw=true "Back to top")](#readme)

---
_Source: https://npm.io/package/major-version-check · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
