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

simple-semver

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-semver - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

71

lib/index.js

@@ -25,3 +25,3 @@ 'use strict';

}
return _compareSize(_clean(a), _clean(b), 'greaterThan');
return _cleanCompare(a, b) === 'GT';
}

@@ -33,3 +33,3 @@

}
return _compareSize(_clean(a), _clean(b), 'lessThan');
return _cleanCompare(a, b) === 'LT';
}

@@ -41,11 +41,19 @@

}
return _clean(a).join('.') === _clean(b).join('.');
return _cleanCompare(a, b) === 'EQ';
}
function gte(a, b) {
return gt(a, b) || eq(a, b);
if (!_validate(a, b)) {
return false;
}
var result = _cleanCompare(a, b);
return result === 'GT' || result === 'EQ';
}
function lte(a, b) {
return lt(a, b) || eq(a, b);
if (!_validate(a, b)) {
return false;
}
var result = _cleanCompare(a, b);
return result === 'LT' || result === 'EQ';
}

@@ -57,3 +65,3 @@

}
return !eq(a, b);
return _cleanCompare(a, b) !== 'EQ';
}

@@ -63,3 +71,2 @@

if (typeof data !== 'string') {
// throw TypeError('Invalid Type: params should be string')
return false;

@@ -70,9 +77,5 @@ }

if (arr.length !== 3) {
// throw TypeError('Invalid Type: params\'s format should be x.x.x')
return false;
}
var pass = arr.every(function (el) {
// if (!/^[0-9]+$/.test(el)) {
// throw TypeError('Invalid Type: params should only contain Number and dot(.)')
// }
return (/^[0-9]+$/.test(el)

@@ -84,30 +87,26 @@ );

function _compareSize(a, b, type) {
var index = 0;
return _compare(a, b);
function _cleanCompare(a, b) {
return _compareVersion(_clean(a), _clean(b));
}
function _compare(a, b) {
var aa = a[index];
var bb = b[index];
var expression = void 0;
switch (type) {
case 'greaterThan':
expression = aa > bb;
function _compare(a, b) {
return a === b ? 'EQ' : a > b ? 'GT' : 'LT';
}
function _compareVersion(a, b) {
if (a.join('.') === b.join('.')) {
return 'EQ';
}
for (var i = 0; i < a.length; i++) {
var result = _compare(a[i], b[i]);
switch (result) {
case 'EQ':
continue;
break;
case 'lessThan':
expression = aa < bb;
break;
case 'GT':
return 'GT';
case 'LT':
return 'LT';
}
if (expression) {
return true;
} else if (aa === bb) {
index++;
if (index === 3) {
return false;
}
return _compare(a, b);
} else {
return false;
}
}

@@ -114,0 +113,0 @@ }

{
"name": "simple-semver",
"version": "1.1.2",
"version": "1.1.3",
"description": "simple-semver",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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