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 - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

13

index.js
'use strict';
const semver = require('semver');
const cleanSemver = require('clean-semver');

@@ -11,13 +12,17 @@ module.exports = (versions, options) => {

let sortedVersions = versions.filter(version => semver.valid(version)).sort(semver.rcompare);
let sortedVersions = versions
.map(version => version.trim())
.map(version => [version, cleanSemver(version)])
.filter(version => version[1])
.sort((a, b) => semver.rcompare(a[1], b[1]));
if (!options.includePrereleases) {
sortedVersions = sortedVersions.filter(version => semver.prerelease(version) === null);
sortedVersions = sortedVersions.filter(version => semver.prerelease(version[1]) === null);
}
if (options.clean) {
sortedVersions = sortedVersions.map(version => semver.clean(version));
return sortedVersions.map(version => version[1]);
}
return sortedVersions;
return sortedVersions.map(([version]) => version);
};
{
"name": "to-semver",
"version": "2.0.0",
"version": "3.0.0",
"description": "Get an array of valid, sorted, and cleaned semver versions from an array of strings",
"license": "MIT",
"repository": "sindresorhus/to-semver",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=8"
"node": ">=10"
},

@@ -43,9 +44,10 @@ "scripts": {

"dependencies": {
"semver": "^6.0.0"
"clean-semver": "^2.1.0",
"semver": "^7.3.2"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^2.4.0",
"tsd": "^0.11.0",
"xo": "^0.30.0"
}
}

@@ -1,2 +0,2 @@

# to-semver [![Build Status](https://travis-ci.org/sindresorhus/to-semver.svg?branch=master)](https://travis-ci.org/sindresorhus/to-semver)
# to-semver [![Build Status](https://travis-ci.com/sindresorhus/to-semver.svg?branch=master)](https://travis-ci.com/sindresorhus/to-semver)

@@ -7,3 +7,2 @@ > Get an array of valid, sorted, and cleaned [semver](https://semver.org) versions from an array of strings

## Install

@@ -36,6 +35,5 @@

## API
### toSemver(versions, [options])
### toSemver(versions, options?)

@@ -52,3 +50,3 @@ #### versions

Type: `boolean`<br>
Type: `boolean`\
Default: `true`

@@ -60,3 +58,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `true`

@@ -66,3 +64,2 @@

## Related

@@ -74,6 +71,1 @@

- [semver-truncate](https://github.com/sindresorhus/semver-truncate) - Truncate a semver version: `1.2.3` → `1.2.0`
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

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