A highly customizable version parser
npm install custver --save
In you nodeJS applicaiton
var custver = require('custver');
Defining the version formatting can be done in two ways.
This package comes with two predefined version formattings. These are;
- alternative
- semantic
custver.setOptions('alternative'); // Alternative version formatting
custver.setOptions('semantic'); // Symantic version formatting
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