Skip to content

Latest commit

 

History

History
88 lines (72 loc) · 1.9 KB

README.md

File metadata and controls

88 lines (72 loc) · 1.9 KB

custver Build Status

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
  • semantic
custver.setOptions('alternative'); // Alternative version formatting
custver.setOptions('semantic'); // 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