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

semver-extra

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semver-extra - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

test/semver-extra.js

19

index.js

@@ -8,2 +8,6 @@ 'use strict';

extra.isPrerelease = isPrerelease;
extra.isExplicit = isExplicit;
extra.max = max;
extra.maxStable = maxStable;
extra.maxPrerelease = maxPrerelease;

@@ -20,4 +24,5 @@ var util = require('util');

// isPrerelease('1.1.0-abc') -> true
if (!prerelease && pr.length) {
return true;
// isPrerelease('1.1.0') -> false
if (!prerelease) {
return !!pr.length;
}

@@ -29,2 +34,7 @@

// Returns whether it is a explicit version
function isExplicit (version) {
var range = semver.validRange(version);
return range === version;
}

@@ -37,3 +47,4 @@ function arrayEqual (a, b) {

return a.every(function (v, i) {
return v === b[i];
// Double equal, simply deal with numeric prerelease versions
return v == b[i];
});

@@ -62,3 +73,3 @@ }

function desc (versions) {
return versions.filter(semver.rcompare);
return versions.sort(semver.rcompare);
}

@@ -65,0 +76,0 @@

{
"name": "semver-extra",
"version": "1.0.0",
"description": "semver-extra contains methods that aren't included in the vanilla semver package.",
"version": "1.0.1",
"description": "semver-extra contains useful methods that aren't included in the vanilla semver package.",
"main": "index.js",

@@ -6,0 +6,0 @@ "scripts": {

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

# semver-stable [![NPM version](https://badge.fury.io/js/semver-stable.svg)](http://badge.fury.io/js/semver-stable) [![Build Status](https://travis-ci.org/kaelzhang/node-semver-stable.svg?branch=master)](https://travis-ci.org/kaelzhang/node-semver-stable) [![Dependency Status](https://gemnasium.com/kaelzhang/node-semver-stable.svg)](https://gemnasium.com/kaelzhang/node-semver-stable)
# semver-extra [![NPM version](https://badge.fury.io/js/semver-extra.svg)](http://badge.fury.io/js/semver-extra) [![Build Status](https://travis-ci.org/kaelzhang/node-semver-extra.svg?branch=master)](https://travis-ci.org/kaelzhang/node-semver-extra) [![Dependency Status](https://gemnasium.com/kaelzhang/node-semver-extra.svg)](https://gemnasium.com/kaelzhang/node-semver-extra)
Manage stable semver versions
`semver-extra` contains useful methods that aren't included in the vanilla semver package.
The main reason `semver-extra` exists is to deal with pre-release versions.
## Install
```bash
$ npm install semver-stable --save
$ npm install semver-extra --save
```

@@ -14,41 +16,90 @@

```js
var stable = require('semver-stable');
var se = require('semver-extra');
```
### stable.is(version)
First of all, `semver-extra` contains all methods of [`semver@3.x`](https://www.npmjs.org/package/semver), so we could use `semver-extra` only without the vanilla one.
```js
stable.is('1.2.3'); // -> true
stable.is('1.2.3-stable'); // -> false
stable.is('1.2.3-alpha'); // -> false
se.validRange('^1.2.3'); // '>=1.2.3-0 <2.0.0-0'
```
Returns `Boolean` whether the `version` is stable.
### se.isStable(version)
```js
se.isStable('1.2.3'); // -> true
se.isStable('1.2.3-stable'); // -> false
se.isStable('1.2.3-alpha'); // -> false
```
### stable.maxSatisfying(versions, range)
Checks whether the `version` is a stable version.
- versions `Array.<semver>`
- range `String` semver range
### se.isPrerelease(version, [prerelease])
- version `string`
- prerelease `String=`
- If argument `prerelease` is not passed and `version` is an unstable version, it will return `true`.
- or `prerelease` could be the pre-release string.
```js
stable.maxSatisfying([
'1.3.3', // not match the range
'1.2.3-beta', // not a stable version
'1.2.2', // that's it
'1.2.1', // much older
se.isPrerelease('1.2.3'); // false
se.isPrerelease('1.2.3-beta'); // true
se.isPrerelease('1.2.3-beta', 'alpha'); // false
se.isPrerelease('1.2.3-1.2.3', '1.2.3'); // true, that supports numeric prerelease versions
se.isPrerelease('1.2.3-alpha.1', 'alpha.1'); // true
```
Checks whether the `version` is an unstable version or matches the `prerelease`.
### se.isExplicit(version)
```js
se.isExplicit('1.0.0'); // true
se.isExplicit('^1.1.0'); // false
```
Checks whehter the `version` is an explicit version, i.e. it is not a range.
```js
var versions = [
'1.1.2'
], '~1.2.0');
// -> 1.2.2
'1.2.3-beta',
'1.2.2',
'1.2.1',
'1.3.3',
'1.5.0-rc'
];
```
Returns `String` the latest stable version matches the range.
### stable.max(versions)
```js
se.max(versions); // '1.5.0-rc'
```
### stable.max(versions);
Returns `String` the maximun version in the list.
Returns `String` the max stable version.
### stable.maxStable(versions)
```js
se.maxStable(versions); // '1.3.3'
```
Returns `String` the maximun stable version in the list.
### stable.maxPrerelease(versions, [prerelease])
```js
se.maxPrerelease(versions, 'alpha'); // null
se.maxPrerelease(versions); // '1.5.0-rc'
se.maxPrerelease(versions, 'beta'); // '1.2.3-beta'
```
Returns the maximun (matched) pre-release version matches the prerelease.
## License
MIT
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