sp core library.version - microsoft/Viva-Connections-Extensibility-Beta GitHub Wiki
Home > @microsoft/sp-core-library > Version
Represents a version number with two, three, or four parts.
Signature:
export default class VersionThis class represents versions that follow the string format of MAJOR.MINOR[.PATCH[.REVISION]] where the MAJOR, MINOR, PATCH and REVISION parts are integers. PATCH and REVISION are optional. Leading zero digits are allowed, but they are discarded. Missing parts are treated as zeroes for comparisons.
Examples: 1.0, 1.0.0, 1.0.0.0, 1.01, 01.02.03, 001.002.003.004
| Property | Modifiers | Type | Description |
|---|---|---|---|
| major | number | Returns the first component of the version string. | |
| minor | number | Returns the second component of the version string. | |
| patch | number | undefined | The third number in the version string, or undefined if unspecified. | |
| revision | number | undefined | The fourth number in the version string, or undefined if unspecified. |
| Method | Modifiers | Description |
|---|---|---|
| compare(v1, v2) | static |
Compares two Version objects to determine which version is newer. |
| equals(compareWith) | Tests whether this version is equal to the input parameter. | |
| greaterThan(compareWith) | Tests whether this version is greater than (i.e. newer than) the input parameter. | |
| isValid(versionString) | static |
Test whether a string is a valid version specifier. |
| lessThan(compareWith) | Tests whether this version is less than (i.e. older than) the input parameter. | |
| parse(versionString) | static |
Constructs a new Version instance using the version string. An exception is thrown if the string cannot be parsed. |
| satisfies(compareWith) | Tests whether this version satisfies the compatibility requirements of the input version, i.e. is backwards compatible. | |
| toString() | Returns a string representation of the version. | |
| tryParse(versionString) | static |
Attempts to parse the input string to construct a new Version object. If the string cannot be parsed, then undefined is returned. |