semver-lite
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -6,3 +6,3 @@ { | ||
"name": "semver-lite", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"keywords": [ | ||
@@ -9,0 +9,0 @@ "semver", |
@@ -86,3 +86,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var semver = { | ||
version: '0.0.4', | ||
version: '0.0.5', | ||
SemverVersion: SemverVersion, | ||
@@ -120,2 +120,9 @@ validate: function validate(version) { | ||
}, | ||
equal: function equal(a, b, needCompareBuildVersion) { | ||
var result = this.compare(a, b, needCompareBuildVersion); | ||
return result === 0; | ||
}, | ||
equalMain: function equalMain(a, b) { | ||
return new SemverVersion(a).mainVersion === new SemverVersion(b).mainVersion; | ||
}, | ||
@@ -122,0 +129,0 @@ // 主版本转成数字类型方便比较 |
{ | ||
"name": "semver-lite", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "semver compare library", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -52,2 +52,5 @@ # semver-lite [![Build Status](https://api.travis-ci.org/worktile/semver-lite.svg?branch=master)](https://travis-ci.org/worktile/semver-lite) | ||
semver.lte('2.0.1', '2.0.1'); // true | ||
semver.equal('2.0.1', '2.0.1'); // true | ||
semver.equal('2.0.1', '2.0.2'); // false | ||
semver.equalMain('2.0.0', '2.0.0-beta'); // true | ||
@@ -54,0 +57,0 @@ semver.mainVersionToNumeric('1.10.12, 4); // 100100012 , 1 0010 0012 |
const SemverVersion = require('./semver'); | ||
const semver = { | ||
version: '0.0.4', | ||
version: '0.0.5', | ||
SemverVersion: SemverVersion, | ||
@@ -37,2 +37,9 @@ validate(version) { | ||
}, | ||
equal(a, b, needCompareBuildVersion) { | ||
const result = this.compare(a, b, needCompareBuildVersion); | ||
return result === 0; | ||
}, | ||
equalMain(a, b) { | ||
return (new SemverVersion(a)).mainVersion === (new SemverVersion(b)).mainVersion; | ||
}, | ||
// 主版本转成数字类型方便比较 | ||
@@ -39,0 +46,0 @@ mainVersionToNumeric(version, digit = 6) { |
@@ -96,2 +96,38 @@ const test = require('ava'); | ||
// equal | ||
test('1.0.0 equal 2.0.0 return false', async t => { | ||
t.is(semver.equal('1.0.0', '2.0.0'), false); | ||
}); | ||
test('1.0.0 equal 1.0.0 return true', async t => { | ||
t.is(semver.equal('1.0.0', '1.0.0'), true); | ||
}); | ||
test('v1.0.0 equal 1.0.0 return true', async t => { | ||
t.is(semver.equal('v1.0.0', '1.0.0'), true); | ||
}); | ||
test('1.0.0-beta equal 1.0.0 return false', async t => { | ||
t.is(semver.equal('v1.0.0-beta', '1.0.0'), false); | ||
}); | ||
// equalMain | ||
test('1.0.0 equalMain 2.0.0 return false', async t => { | ||
t.is(semver.equalMain('1.0.0', '2.0.0'), false); | ||
}); | ||
test('1.0.0 equalMain 1.0.0-beta return true', async t => { | ||
t.is(semver.equalMain('1.0.0', '1.0.0-beta'), true); | ||
}); | ||
test('1.0.0 equalMain v1.0.0-beta+20171017 return true', async t => { | ||
t.is(semver.equalMain('1.0.0', 'v1.0.0-beta+20171017'), true); | ||
}); | ||
test('v1.0.0 equalMain v1.0.0-beta+222 return true', async t => { | ||
t.is(semver.equalMain('1.0.0', 'v1.0.0-beta+222'), true); | ||
}); | ||
// mainVersionToNumeric | ||
@@ -110,2 +146,3 @@ test('version 1.10.12-beta+20130222 main version to numeric is 100100012', async t => { | ||
// compareMainVersion | ||
test('compare main version 1.0.0-rc and 1.0.0-beta return 0', async t => { | ||
@@ -112,0 +149,0 @@ t.is(semver.compareMainVersion('1.0.0-rc', '1.0.0-beta'), 0); |
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
45066
751
97