@flourish/semver

    1.0.2 • Public • Published

    A short and simple module for parsing and comparing semantic version numbers, following the Semantic Versioning 2.0.0 specification.

    Does not support build metadata.

    const semver = require("@flourish/semver");
     
    semver.parse("1.0.0");
    // Returns [1, 0, 0]
     
    semver.parse("1.0.0-alpha.1.2.3");
    // Returns [1, 0, 0, "alpha", 1, 2, 3]
    semver.join([1, 2, 3]); // "1.2.3"
     
    semver.join([1, 2, 3, "alpha", 2]); // "1.2.3-alpha.2"
    semver.cmp(semver.parse("1.2.0"), semver.parse("1.2.1")); // -1
     
    semver.cmp(semver.parse("1.2.0"), semver.parse("1.2.0")); // 0
     
    semver.cmp(semver.parse("1.2.2"), semver.parse("1.2.2-alpha.1")); // +1
     
    semver.cmp(semver.parse("1.2.2"), semver.parse("1.2.3-alpha.1")); // -1
     
    // Sort a list of version numbers into order
    version_numbers
        .map(semver.parse)
        .sort(semver.cmp)
        .map(semver.join);

    Keywords

    none

    Install

    npm i @flourish/semver

    DownloadsWeekly Downloads

    221

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    7.65 kB

    Total Files

    9

    Last publish

    Collaborators

    • axwalker
    • shar.k
    • flourish-canva
    • declanvong
    • pinkopunko
    • vee_canva
    • florin.oprina
    • robinhouston
    • duncanclark
    • daanlouter
    • timbrock
    • hughsk
    • mark-kiln
    • animateddata
    • larsvers
    • luptilu
    • bobbysebolao
    • liakouras
    • oliviajanelawlor
    • hrobertson
    • eademoon
    • qubyte
    • chrisnewell
    • oampo
    • sebr
    • alextreppass
    • wearymonkey
    • mattcarter-canva
    • marcfallows
    • mafecafe
    • connormj
    • simonaats