• Example

    compareVersions('11.1.1', '10.0.0') //  1
    compareVersions('10.0.0', '10.0.0') // 0
    compareVersions('10.0.0', '11.1.1') // -1

    Example

    const versions = ['1.5.19', '1.2.3', '1.5.5']
    const sorted = versions.sort(compareVersions)
    /*
    [
    '1.2.3',
    '1.5.5',
    '1.5.19'
    ]
    */

    Returns

    An integer representation of v1 compared to v2

    Integer Semantics
    -1 Less Than
    0 Equal To
    1 Greater Than

    Parameters

    • v1: string

      The first semantic version to compare.

    • v2: string

      The second semantic version to compare.

    Returns 0 | 1 | -1

Generated using TypeDoc