Clear Up
SharpKit Reference

Version Class

A utility class that wrap around a string version number and provide convenient method to perform comparison. See also: compare. Example:

  
var version = new Ext.Version('1.0.2beta');
            console.log("Version is " + version); // Version is 1.0.2beta
            console.log(version.getMajor()); // 1
            console.log(version.getMinor()); // 0
            console.log(version.getPatch()); // 2
            console.log(version.getBuild()); // 0
            console.log(version.getRelease()); // beta
            console.log(version.isGreaterThan('1.0.1')); // True
            console.log(version.isGreaterThan('1.0.2alpha')); // True
            console.log(version.isGreaterThan('1.0.2RC')); // False
            console.log(version.isGreaterThan('1.0.2')); // False
            console.log(version.isLessThan('1.0.2')); // True
            console.log(version.match(1.0)); // True
            console.log(version.match('1.0.2')); // True
            

Namespace: Ext

Base Types

System.Object

Constructors

Name Description
Version(object) Parameters
  • version : String/Number

    The version number in the following standard format:

    major[.minor[.patch[.build[release]]]]
                

    Examples:

    1.0
                1.2.3beta
                1.2.3.4RC
                
  • Version(VersionConfig)
    Version()
    Version(Object[])

    Methods

    Name Description
    compare(JsString, JsString) Compare 2 specified versions, starting from left to right. If a part contains special version strings, they are handled in the following order: 'dev' < 'alpha' = 'a' < 'beta' = 'b' < 'RC' = 'rc' < '#' < 'pl' = 'p' < 'anything else'
    equals(object) Returns whether this version equals to the supplied argument
    getBuild() Returns the build component value
    getComponentValue(object) Converts a version component to a comparable value
    getMajor() Returns the major component value
    getMinor() Returns the minor component value
    getPatch() Returns the patch component value
    getRelease() Returns the release component value
    getShortVersion() Returns shortVersion version without dots and release
    gt(object) Convenient alias to isGreaterThan
    gtEq(object) Convenient alias to isGreaterThanOrEqual
    isGreaterThan(object) Returns whether this version if greater than the supplied argument
    isGreaterThanOrEqual(object) Returns whether this version if greater than or equal to the supplied argument
    isLessThan(object) Returns whether this version if smaller than the supplied argument
    isLessThanOrEqual(object) Returns whether this version if less than or equal to the supplied argument
    lt(object) Convenient alias to isLessThan
    ltEq(object) Convenient alias to isLessThanOrEqual
    match(object) Returns whether this version matches the supplied argument. Example:
    var version = new Ext.Version('1.0.2beta');
                console.log(version.match(1)); // True
                console.log(version.match(1.0)); // True
                console.log(version.match('1.0.2')); // True
                console.log(version.match('1.0.2RC')); // False
                
    toArray() Returns this format: [major, minor, patch, build, release]. Useful for comparison
    © Copyright 2005-2011 SharpKit. All rights reserved.