wonderful-version

1.3.2 • Public • Published




Site | NPM Module | GitHub Repo

wonderful-version is the official npm module of Wonderful Version, a free app for gracefully checking semantic versions instead of throwing errors.

🌐 Wonderful Version Works in Node AND browser environments

Yes, this module works in both Node and browser environments, including compatibility with Webpack and Browserify!

🦄 Features

  • Gracefully check semantic versions instead of throwing errors

📦 Install Wonderful Version

Option 1: Install via npm

Install with npm if you plan to use wonderful-version in a Node project or in the browser.

npm install wonderful-version

If you plan to use wonderful-version in a browser environment, you will probably need to use Webpack, Browserify, or a similar service to compile it.

const wonderfulVersion = require('wonderful-version');

Option 2: Install via CDN

Install with CDN if you plan to use Wonderful Version only in a browser environment.

<script src="https://cdn.jsdelivr.net/npm/wonderful-version@latest/dist/index.min.js"></script>
<script type="text/javascript">
  var wonderfulVersion = WonderfulVersion;
</script>

⚡️ Usage

.clean(version)

Cleans a version string by removing non-numeric characters and trailing zeros.

console.log(wonderfulVersion.clean('v1.02.30')); // '1.2.3'

.equals(version1, version2)

Checks if two version strings are equal after cleaning.

console.log(wonderfulVersion.equals('1.0.0', '1')); // true

.lessThan(version1, version2)

Checks if version1 is less than version2.

console.log(wonderfulVersion.lessThan('1.2.3', '1.2.4')); // true

.greaterThan(version1, version2)

Checks if version1 is greater than version2.

console.log(wonderfulVersion.greaterThan('1.2.4', '1.2.3')); // true

.lessThanOrEqual(version1, version2)

Checks if version1 is less than or equal to version2.

console.log(wonderfulVersion.lessThanOrEqual('1.2.3', '1.2.4')); // true

.greaterThanOrEqual(version1, version2)

Checks if version1 is greater than or equal to version2.

console.log(wonderfulVersion.greaterThanOrEqual('1.2.4', '1.2.3')); // true

.is(version1, comparator, version2)

Checks if version1 is ['===', '!=', '>', '>=', '<', '<='] to version2.

console.log(wonderfulVersion.is('1.2.4', '>=', '1.2.3')); // true
console.log(wonderfulVersion.is('1.2.4', '!=', '1.2.3')); // true
console.log(wonderfulVersion.is('1.2.4', '===', '1.2.4')); // true

.major(version)

Returns the major version number.

console.log(wonderfulVersion.major('1.2.3')); // 1

.minor(version)

Returns the minor version number.

console.log(wonderfulVersion.minor('1.2.3')); // 2

.patch(version)

Returns the patch version number.

console.log(wonderfulVersion.patch('1.2.3')); // 3

.levelDifference(version1, version2)

Determines which version level (major, minor, or patch) version1 is behind compared to version2.

console.log(wonderfulVersion.behindLevel('1.2.3', '2.0.0')); // 'major'

.increment(version, level, amount)

Increments a version number by a certain level and amount. Segments following the incremented level are reset to 0.

console.log(wonderfulVersion.increment('1.2.3', 'major', 1)); // '2.0.0'
console.log(wonderfulVersion.increment('1.2.3', 'minor', 1)); // '1.3.0'
console.log(wonderfulVersion.increment('1.2.3', 'patch', 1)); // '1.2.4'

📘 Using Wonderful Version

After you have followed the install step, you can start using wonderful-version to enhance your project.

For a more in-depth documentation of this library and the Wonderful Version service, please visit the official Wonderful Version website.

📝 What Can Wonderful Version do?

A far-less-frustrating rendition of semver

🗨️ Final Words

If you are still having difficulty, we would love for you to post a question to the Wonderful Version issues page. It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)

📚 Projects Using this Library

Ask us to have your project listed! :)

Readme

Keywords

Package Sidebar

Install

npm i wonderful-version

Weekly Downloads

77

Version

1.3.2

License

MIT

Unpacked Size

15.1 kB

Total Files

6

Last publish

Collaborators

  • itwcw2000