https://github.com/onyx-nxt/version-tools
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.
https://github.com/onyx-nxt/version-tools
javascript node-package nodejs npm npmjs typescript
Last synced: 7 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/onyx-nxt/version-tools
- Owner: onyx-nxt
- License: gpl-2.0
- Created: 2021-10-06T04:33:06.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-20T04:48:52.000Z (over 1 year ago)
- Last Synced: 2025-05-16T12:15:05.439Z (7 months ago)
- Topics: javascript, node-package, nodejs, npm, npmjs, typescript
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/major-version-check
- Size: 364 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/KK-Designs/version-tools/releases/tag/v1.4.1)
[](https://www.npmjs.com/package/major-version-check#:~:text=Weekly%20Downloads)

[](https://github.com/KK-Designs/version-tools/issues)
[](https://github.com/KK-Designs/version-tools/blob/master/LICENSE)
[](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 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
```sh-session
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 ESM 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 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 |
#
[](#readme)