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

@hapi/somever

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapi/somever - npm Package Compare versions

Comparing version 2.1.1 to 3.0.0

156

lib/index.js

@@ -47,2 +47,82 @@ 'use strict';

exports.compare = function (a, b, options = {}) {
let aFirst = -1;
let bFirst = 1;
a = exports.version(a, options);
b = exports.version(b, options);
// Mark incompatible prereleases
if (options.range &&
a.prerelease.length &&
(a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch || !b.prerelease.length)) {
aFirst = -2;
bFirst = 2;
}
// Compare versions
for (let i = 0; i < 3; ++i) {
const av = a.dots[i];
const bv = b.dots[i];
if (av === bv ||
av === internals.any || // Wildcard is equal to everything
bv === internals.any) {
continue;
}
return av - bv < 0 ? aFirst : bFirst;
}
// Compare prerelease
if (!a.prerelease.length &&
!b.prerelease.length) {
return 0;
}
if (!!a.prerelease.length !== !!b.prerelease.length) {
return (a.prerelease.length ? aFirst : bFirst); // prerelease < none
}
for (let i = 0; ; ++i) {
const ai = a.prerelease[i];
const bi = b.prerelease[i];
if (ai === undefined &&
bi === undefined) {
return 0;
}
if (ai === bi) {
continue;
}
if (ai === undefined) {
return aFirst;
}
if (bi === undefined) {
return bFirst;
}
const an = Number.isFinite(ai);
const bn = Number.isFinite(bi);
if (an !== bn) {
return an ? aFirst : bFirst;
}
return (a < b ? aFirst : bFirst);
}
};
internals.Version = class {

@@ -152,77 +232,3 @@

let aFirst = -1;
let bFirst = 1;
a = exports.version(a, options);
b = exports.version(b, options);
// Mark incompatible prereleases
if (options.range &&
a.prerelease.length &&
(a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch || !b.prerelease.length)) {
aFirst = -2;
bFirst = 2;
}
// Compare versions
for (let i = 0; i < 3; ++i) {
const av = a.dots[i];
const bv = b.dots[i];
if (av === bv ||
av === internals.any || // Wildcard is equal to everything
bv === internals.any) {
continue;
}
return av - bv < 0 ? aFirst : bFirst;
}
// Compare prerelease
if (!a.prerelease.length &&
!b.prerelease.length) {
return 0;
}
if (!!a.prerelease.length !== !!b.prerelease.length) {
return (a.prerelease.length ? aFirst : bFirst); // prerelease < none
}
for (let i = 0; ; ++i) {
const ai = a.prerelease[i];
const bi = b.prerelease[i];
if (ai === undefined &&
bi === undefined) {
return 0;
}
if (ai === bi) {
continue;
}
if (ai === undefined) {
return aFirst;
}
if (bi === undefined) {
return bFirst;
}
const an = Number.isFinite(ai);
const bn = Number.isFinite(bi);
if (an !== bn) {
return an ? aFirst : bFirst;
}
return (a < b ? aFirst : bFirst);
}
return exports.compare(a, b, options);
}

@@ -229,0 +235,0 @@ };

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

Copyright (c) 2018-2019, Sideway Inc, and project contributors
Copyright (c) 2018-2020, Sideway Inc, and project contributors
All rights reserved.

@@ -3,0 +3,0 @@

{
"name": "@hapi/somever",
"description": "Semantic versioning rules parser",
"version": "2.1.1",
"version": "3.0.0",
"repository": "git://github.com/hapijs/somever",
"main": "lib/index.js",
"files": [
"lib"
],
"keywords": [

@@ -13,8 +16,8 @@ "semantic",

"dependencies": {
"@hapi/bounce": "1.x.x",
"@hapi/hoek": "8.x.x"
"@hapi/bounce": "2.x.x",
"@hapi/hoek": "9.x.x"
},
"devDependencies": {
"@hapi/code": "6.x.x",
"@hapi/lab": "20.x.x"
"@hapi/code": "8.x.x",
"@hapi/lab": "22.x.x"
},

@@ -21,0 +24,0 @@ "scripts": {

<a href="http://hapijs.com"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
# somever
# @hapi/somever

@@ -10,3 +10,2 @@ Semantic versioning rules parser, compatible with version ranges used in package.json files and the

[![Build Status](https://secure.travis-ci.org/hapijs/somever.svg?branch=master)](https://travis-ci.org/hapijs/somever)
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