semver-truncate
Truncate a semver version: 1.2.3 → 1.2.0
Last updated 9 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install semver-truncate 
SYNC missed versions from official npm registry.

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

Current Tags

  • 3.0.0                                ...           latest (4 years ago)

6 Versions

  • 3.0.0                                ...           4 years ago
  • 2.0.0                                ...           6 years ago
  • 1.1.2                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 2
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (1)
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE