Function compareVersions

Compare semver version strings to find greater, equal or lesser. This library supports the full semver specification, including comparing versions with different number of digits like 1.0.0, 1.0, 1, and pre-release versions like 1.0.0-alpha.

  • Parameters

    • v1: string

      First version to compare

    • v2: string

      Second version to compare

    Returns -1 | 0 | 1

    Numeric value compatible with the Array.sort(fn) interface.