Socket
Socket
Sign inDemoInstall

semver

Package Overview
Dependencies
Maintainers
0
Versions
108
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

LICENSE

5

package.json
{ "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

README.md

@@ -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()
})
}
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