Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

semver

Package Overview
Dependencies
Maintainers
0
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semver - npm Package Compare versions

Comparing version
1.0.5
to
1.0.6
+23
LICENSE
Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
All rights reserved.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
+4
-1
{ "name" : "semver"
, "version" : "1.0.5"
, "version" : "1.0.6"
, "description" : "The semantic version parser used by npm."

@@ -7,3 +7,6 @@ , "main" : "semver.js"

, "devDependencies": { "tap" : "0.x" }
, "license" :
{ "type" : "MIT"
, "url" : "https://github.com/isaacs/semver/raw/master/LICENSE" }
, "repository" : "git://github.com/isaacs/node-semver.git"
, "bin" : { "semver" : "./bin/semver" } }
+2
-0

@@ -91,2 +91,4 @@ # semver

* valid(v): Return the parsed version, or null if it's not valid.
* inc(v, release): Return the version incremented by the release type
(major, minor, patch, or build), or null if it's not valid.

@@ -93,0 +95,0 @@ ### Comparison

@@ -39,2 +39,3 @@

exports.cmp = cmp
exports.inc = inc

@@ -46,8 +47,13 @@ exports.valid = valid

function clean (ver) {
v = exports.parse(ver)
if (!v) return v
function stringify (version) {
var v = version
return [v[1]||'', v[2]||'', v[3]||''].join(".") + (v[4]||'') + (v[5]||'')
}
function clean (version) {
version = exports.parse(version)
if (!version) return version
return stringify(version)
}
function valid (version) {

@@ -262,2 +268,27 @@ return exports.parse(version) && version.trim().replace(/^[v=]+/, '')

function inc (version, release) {
version = exports.parse(version)
if (!version) return null
var parsedIndexLookup =
{ 'major': 1
, 'minor': 2
, 'patch': 3
, 'build': 4 }
var incIndex = parsedIndexLookup[release]
if (incIndex === undefined) return null
var current = num(version[incIndex])
version[incIndex] = current === -1 ? 1 : current + 1
for (var i = incIndex + 1; i < 5; i ++) {
if (num(version[i]) !== -1) version[i] = "0"
}
if (version[4]) version[4] = "-" + version[4]
version[5] = ""
return stringify(version)
}
if (module === require.main) { // tests below

@@ -268,3 +299,3 @@

tap.plan(4)
tap.plan(5)

@@ -468,2 +499,25 @@ test("comparison tests", function (t) {

test("increment versions test", function (t) {
; [ [ "1.2.3", "major", "2.0.0" ]
, [ "1.2.3", "minor", "1.3.0" ]
, [ "1.2.3", "patch", "1.2.4" ]
, [ "1.2.3", "build", "1.2.3-1" ]
, [ "1.2.3-4", "build", "1.2.3-5" ]
, [ "1.2.3tag", "major", "2.0.0" ]
, [ "1.2.3-tag", "major", "2.0.0" ]
, [ "1.2.3tag", "build", "1.2.3-1" ]
, [ "1.2.3-tag", "build", "1.2.3-1" ]
, [ "1.2.3-4-tag", "build", "1.2.3-5" ]
, [ "1.2.3-4tag", "build", "1.2.3-5" ]
, [ "1.2.3", "fake", null ]
, [ "fake", "major", null ]
].forEach(function (v) {
t.equal(inc(v[0], v[1]), v[2], "inc("+v[0]+", "+v[1]+") === "+v[2])
})
t.end()
})
}