Compare semver version strings using the specified operator.

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

    • v1: string

      First version to compare

    • v2: string

      Second version to compare

    • operator: CompareOperator

      Allowed arithmetic operator to use

    Returns boolean

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