Nanobots Protecting Microbots

    semver-truncate
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0 • Public • Published

    semver-truncate

    Truncate a semver version: 1.2.31.2.0

    Install

    $ npm install semver-truncate
    

    Usage

    import semverTruncate from 'semver-truncate';
    
    semverTruncate('1.2.3-foo', 'patch');
    //=> '1.2.3'
    
    semverTruncate('1.2.3', 'minor');
    //=> '1.2.0'
    
    semverTruncate('1.2.3', 'major');
    //=> '1.0.0'

    API

    truncateSemver(version, type)

    version

    Type: string

    Semver version.

    type

    Type: 'patch' | 'minor' | 'major'

    Version type to truncate to.

    Related

    • latest-semver - Get the latest stable semver version from an array of versions
    • to-semver - Get an array of valid, sorted, and cleaned semver versions from an array of strings
    • semver-regex - Regular expression for matching semver versions
    • semver-diff - Get the diff type of two semver versions: 0.0.1 0.0.2patch

    Install

    npm i semver-truncate

    DownloadsWeekly Downloads

    1,169,748

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    3.88 kB

    Total Files

    5

    Last publish

    Collaborators

    • sindresorhus