custver
v0.0.2
Published
A highly customizable version parser
Downloads
5
Maintainers
Readme
custver
A highly customizable version parser
Usage
npm install custver --save
In you nodeJS applicaiton
var custver = require('custver');
Defining Version Formatting
Defining the version formatting can be done in two ways.
Selecting a predefined version format
This package comes with two predefined version formattings. These are;
- alternative
- symantic
custver.setOptions('alternative'); // Alternative version formatting
custver.setOptions('symantic'); // Symantic version formatting
Defining a custom version formatiing
Below is an example of the alternative version formatting.
custver.setOptions({
versioning: {
expression: /^(\d+)\.(\d+)\.(\d+)+/i
},
developmentStages : [
{
type: 'Alpha',
expression: /\.v(\d*)$/i,
order: '1'
},
{
type: 'Beta',
expression: /\.Beta(\d*)$/i,
order: '2'
},
{
type: 'Release Candidate',
expression: /\.RC(\d*)$/i,
order: '3'
},
{
type: 'General Availability',
expression: /\.GA$/i,
order: '4'
}
],
defaultStageOrder: 4 // A version such as 4.0.0 will be treated as a development stage of General Availability
});
#Comparison Methods These are the comparison methods that expesoed by the custver module. They comply with the version formatting that has been defined. Each function returns a bool.
custver.gt(version1, version2); // version1 > version2
custver.gte(version1, version2); // version1 >= version2
custver.lt(version1, version2); // version1 < version2
custver.lte(version1, version2); // version1 <= version2
custver.eq(version1, version2); // version1 === version2
custver.neq(version1, version2); // version1 !== version2