Skip to content
On this page

@bridge/compare-versions

Functions

compare

compare(firstVersion, secondVersion, operator): boolean

Compare semver version strings using the specified operator.

example

compareVersions.compare('10.1.8', '10.0.4', '>'); // return true
compareVersions.compare('10.0.1', '10.0.1', '='); // return true
compareVersions.compare('10.1.1', '10.2.2', '<'); // return true
compareVersions.compare('10.1.1', '10.2.2', '<='); // return true
compareVersions.compare('10.1.1', '10.2.2', '>='); // return false

Parameters

NameTypeDescription
firstVersionstringFirst version to compare
secondVersionstringSecond version to compare
operator">" | ">=" | "=" | "<" | "<="Allowed arithmetic operator to use

Returns

boolean

true if the comparison between the firstVersion and the secondVersion satisfies the operator, false otherwise.

Released under the GPL-3.0 License.