Class: Version

Version

Provides various ways to access a version.


Members


<readonly> bytes :Array.<number>

The full version as a array of numbers. For example, if the version is '1.2.3.4', then bytes would return [1,2,3,4].

Type:
  • Array.<number>
Since:
  • 1.0

<readonly> str :string

String representation of the version in dotted notation. For example '1.2.3.4'.

Type:
  • string
Since:
  • 1.0

<readonly> v :number

The full version as a single number. For example, if the version is '1.2.3.4', then v would return 16909060 (0x01020304).

Type:
  • number
Since:
  • 1.0

<readonly> vBranch :number

'Branch' component of the version. This is the third of the four bytes that make up a version. bb in MM.mm.bb.rr. If the full version is 1.2.3.4, vBranch is 3.

Type:
  • number
Since:
  • 1.0

<readonly> vMajor :number

'Major' component of the version. This is the first of the four bytes that make up a version. MM in MM.mm.bb.rr. If the full version is 1.2.3.4, vMajor is 1.

Type:
  • number
Since:
  • 1.0

<readonly> vMinor :number

'Minor' component of the version. This is the second of the four bytes that make up a version. mm in MM.mm.bb.rr. If the full version is 1.2.3.4, vMinor is 2.

Type:
  • number
Since:
  • 1.0

<readonly> vRevision :number

'Revision' component of the version. This is the fourth of the four bytes that make up a version. rr in MM.mm.bb.rr. If the full version is 1.2.3.4, vRevision is 4.

Type:
  • number
Since:
  • 1.0

Methods


eq(ver)

Returns true if this version is equal to ver.

Parameters:
Name Type Description
ver number | string | Array.<number>

The string, number, or array representation of the version to compare to.

Since:
  • 1.0
Returns:
Type
bool

ge(ver)

Returns true if this version is greater than or equal to ver.

Parameters:
Name Type Description
ver number | string | Array.<number>

The string, number, or array representation of the version to compare to.

Since:
  • 1.0
Returns:
Type
bool

gt(ver)

Returns true if this version is greater than ver.

Parameters:
Name Type Description
ver number | string | Array.<number>

The string, number, or array representation of the version to compare to.

Since:
  • 1.0
Returns:
Type
bool
Example
if (version.gt('1.0')) console.log('Version is OK');
else console.warn('Version is not acceptable');

inRange(lower, upper)

Returns true if this version is in the range of [lower, upper). Same as (version.ge(lower) && ver.lt(upper)).

Parameters:
Name Type Description
lower number | string | Array.<number>

The lower bound of the range.

upper number | string | Array.<number>

The upper bound of the range.

Since:
  • 1.0
Returns:
Type
bool
Example
// determine if we have a version in the 1.x series of versions
var verOK = version.inRange('1', '2');

le(ver)

Returns true if this version is less than or equal to ver.

Parameters:
Name Type Description
ver number | string | Array.<number>

The string, number, or array representation of the version to compare to.

Since:
  • 1.0
Returns:
Type
bool

lt(ver)

Returns true if this version is less than ver.

Parameters:
Name Type Description
ver number | string | Array.<number>

The string, number, or array representation of the version to compare to.

Since:
  • 1.0
Returns:
Type
bool

ne(ver)

Returns true if this version is not equal to ver.

Parameters:
Name Type Description
ver number | string | Array.<number>

The string, number, or array representation of the version to compare to.

Since:
  • 1.0
Returns:
Type
bool