New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 3.0.0 to 4.0.0

35

index.d.ts

@@ -1,25 +0,23 @@

declare namespace toSemver {
interface Options {
/**
Include prereleases, like `1.2.3-alpha.3`.
export interface Options {
/**
Include prereleases, like `1.2.3-alpha.3`.
@default true
*/
readonly includePrereleases?: boolean;
@default true
*/
readonly includePrereleases?: boolean;
/**
Clean versions. For example `v1.3.0` → `1.3.0`.
/**
Clean versions. For example, `v1.3.0` → `1.3.0`.
@default true
*/
readonly clean?: boolean;
}
@default true
*/
readonly clean?: boolean;
}
/**
Get an array of valid, sorted, and cleaned [semver](https://semver.org/) versions from an array of strings.
Get an array of valid, sorted, and cleaned [semver](https://semver.org) versions from an array of strings.
@example
```
import toSemver = require('to-semver');
import toSemver from 'to-semver';

@@ -39,7 +37,2 @@ toSemver([

*/
declare function toSemver(
versions: readonly string[],
options?: toSemver.Options
): string[];
export = toSemver;
export default function toSemver(versions: readonly string[], options?: Options): string[];

22

index.js

@@ -1,11 +0,9 @@

'use strict';
const semver = require('semver');
const cleanSemver = require('clean-semver');
import semver from 'semver';
import cleanSemver from 'clean-semver';
module.exports = (versions, options) => {
options = {
includePrereleases: true,
clean: true,
...options
};
export default function toSemver(versions, options = {}) {
const {
includePrereleases = true,
clean = true
} = options;

@@ -18,7 +16,7 @@ let sortedVersions = versions

if (!options.includePrereleases) {
if (!includePrereleases) {
sortedVersions = sortedVersions.filter(version => semver.prerelease(version[1]) === null);
}
if (options.clean) {
if (clean) {
return sortedVersions.map(version => version[1]);

@@ -28,2 +26,2 @@ }

return sortedVersions.map(([version]) => version);
};
}
{
"name": "to-semver",
"version": "3.0.0",
"version": "4.0.0",
"description": "Get an array of valid, sorted, and cleaned semver versions from an array of strings",

@@ -13,4 +13,6 @@ "license": "MIT",

},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=10"
"node": ">=12"
},

@@ -46,9 +48,9 @@ "scripts": {

"clean-semver": "^2.1.0",
"semver": "^7.3.2"
"semver": "^7.3.5"
},
"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.11.0",
"xo": "^0.30.0"
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.39.1"
}
}

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

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

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

## Usage
```js
const toSemver = require('to-semver');
import toSemver from 'to-semver';

@@ -59,3 +58,3 @@ toSemver([

Clean versions. For example `v1.3.0` → `1.3.0`.
Clean versions. For example, `v1.3.0` → `1.3.0`.

@@ -62,0 +61,0 @@ ## Related

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