[go: up one dir, main page]

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

4.0.0 • Public • Published

to-semver

Get an array of valid, sorted, and cleaned semver versions from an array of strings

Can be useful when you have an unsorted list of versions, like git tags, and want to use them as semver versions.

Install

$ npm install to-semver

Usage

import toSemver from 'to-semver';

toSemver([
	'v1.3.16',
	'v1.7.0',
	'test',
	'v1.6.9'
]);
/*
[
	'1.7.0',
	'1.6.9'
	'1.3.16'
]
*/

API

toSemver(versions, options?)

versions

Type: string[]

options

Type: object

includePrereleases

Type: boolean
Default: true

Include prereleases, like 1.2.3-alpha.3.

clean

Type: boolean
Default: true

Clean versions. For example, v1.3.01.3.0.

Related

  • latest-semver - Get the latest stable semver version from an array of versions
  • semver-regex - Regular expression for matching semver versions
  • semver-diff - Get the diff type of two semver versions: 0.0.1 0.0.2patch
  • semver-truncate - Truncate a semver version: 1.2.31.2.0

Package Sidebar

Install

npm i to-semver

Weekly Downloads

3,795

Version

4.0.0

License

MIT

Unpacked Size

4.56 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus