Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

to-semver

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-semver

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

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

to-semver Build Status

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

const toSemver = require('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.

  • 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

License

MIT © Sindre Sorhus

Keywords

FAQs

Package last updated on 21 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc