simple-semver
Advanced tools
Comparing version 1.1.1 to 1.1.2
# History | ||
## Release 1.1.2 | ||
- Remove 'throw TypeError()', it will interrupt proccess.That's too dangerous for user and programs |
@@ -12,2 +12,3 @@ 'use strict'; | ||
exports.neq = neq; | ||
exports.validate = validate; | ||
// (function (global, factory) { | ||
@@ -22,17 +23,20 @@ // typeof exports === 'object' && typeof module !== 'undefined' | ||
function gt(a, b) { | ||
a = _validateAndClean(a); | ||
b = _validateAndClean(b); | ||
return _compareSize(a, b, 'greaterThan'); | ||
if (!_validate(a, b)) { | ||
return false; | ||
} | ||
return _compareSize(_clean(a), _clean(b), 'greaterThan'); | ||
} | ||
function lt(a, b) { | ||
a = _validateAndClean(a); | ||
b = _validateAndClean(b); | ||
return _compareSize(a, b, 'lessThan'); | ||
if (!_validate(a, b)) { | ||
return false; | ||
} | ||
return _compareSize(_clean(a), _clean(b), 'lessThan'); | ||
} | ||
function eq(a, b) { | ||
a = _validateAndClean(a); | ||
b = _validateAndClean(b); | ||
return a.join('.') === b.join('.'); | ||
if (!_validate(a, b)) { | ||
return false; | ||
} | ||
return _clean(a).join('.') === _clean(b).join('.'); | ||
} | ||
@@ -49,5 +53,29 @@ | ||
function neq(a, b) { | ||
if (!_validate(a, b)) { | ||
return false; | ||
} | ||
return !eq(a, b); | ||
} | ||
function validate(data) { | ||
if (typeof data !== 'string') { | ||
// throw TypeError('Invalid Type: params should be string') | ||
return false; | ||
} | ||
data = data.replace(/-alpha/g, ''); | ||
var arr = data.split('.'); | ||
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) | ||
); | ||
}); | ||
return pass; | ||
} | ||
function _compareSize(a, b, type) { | ||
@@ -84,24 +112,6 @@ var index = 0; | ||
function _validateAndClean(data) { | ||
_validate(data); | ||
return _clean(data); | ||
function _validate(a, b) { | ||
return validate(a) && validate(b); | ||
} | ||
function _validate(data) { | ||
if (typeof data !== 'string') { | ||
throw TypeError('Invalid Type: params should be string'); | ||
} | ||
data = data.replace(/-alpha/g, ''); | ||
var arr = data.split('.'); | ||
if (arr.length !== 3) { | ||
throw TypeError('Invalid Type: params\'s format should be x.x.x'); | ||
} | ||
arr.forEach(function (el) { | ||
if (!/^[0-9]+$/.test(el)) { | ||
throw TypeError('Invalid Type: params should only contain Number and dot(.)'); | ||
} | ||
}); | ||
return true; | ||
} | ||
function _clean(data) { | ||
@@ -108,0 +118,0 @@ return data.replace(/-alpha/g, '').split('.').map(Number); |
{ | ||
"name": "simple-semver", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "simple-semver", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -30,2 +30,7 @@ [![Build Status](https://travis-ci.org/Stanlous/simple-semver.svg?branch=master)](https://travis-ci.org/Stanlous/simple-semver) | ||
simpleSemver.validate('1.3.0') // true | ||
simpleSemver.validate('a.b.0') // false | ||
simpleSemver.validate('1.0') // false | ||
// simple-semver only support xx.xx.xx(only contain Number and dot(.)) temporarily | ||
simpleSemver.gt('1.3.0', '1.1.0') // true (gt means greater than) | ||
@@ -32,0 +37,0 @@ simpleSemver.lt('1.1.0', '1.5.0') // true (lt means less than) |
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
6820
109
53