simple-semver
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6640
107