Socket
Socket
Sign inDemoInstall

semver

Package Overview
Dependencies
Maintainers
6
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 7.3.5 to 7.3.6

25

bin/semver.js

@@ -30,6 +30,8 @@ #!/usr/bin/env node

const options = {}
let options = {}
const main = () => {
if (!argv.length) return help()
if (!argv.length) {
return help()
}
while (argv.length) {

@@ -89,3 +91,3 @@ let a = argv.shift()

const options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }

@@ -97,4 +99,8 @@ versions = versions.map((v) => {

})
if (!versions.length) return fail()
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
if (!versions.length) {
return fail()
}
if (inc && (versions.length !== 1 || range.length)) {
return failInc()
}

@@ -105,3 +111,5 @@ for (let i = 0, l = range.length; i < l; i++) {

})
if (!versions.length) return fail()
if (!versions.length) {
return fail()
}
}

@@ -111,3 +119,2 @@ return success(versions)

const failInc = () => {

@@ -128,3 +135,5 @@ console.error('--inc can only be used on a single version with no range')

return inc ? semver.inc(v, inc, options, identifier) : v
}).forEach((v, i, _) => { console.log(v) })
}).forEach((v, i, _) => {
console.log(v)
})
}

@@ -131,0 +140,0 @@

@@ -7,2 +7,3 @@ const ANY = Symbol('SemVer ANY')

}
constructor (comp, options) {

@@ -84,3 +85,3 @@ options = parseOptions(options)

loose: !!options,
includePrerelease: false
includePrerelease: false,
}

@@ -133,3 +134,3 @@ }

const parseOptions = require('../internal/parse-options')
const {re, t} = require('../internal/re')
const { re, t } = require('../internal/re')
const cmp = require('../functions/cmp')

@@ -136,0 +137,0 @@ const debug = require('../internal/debug')

module.exports = {
SemVer: require('./semver.js'),
Range: require('./range.js'),
Comparator: require('./comparator.js')
Comparator: require('./comparator.js'),
}

@@ -32,5 +32,5 @@ // hoisted class for cyclic dependency

this.set = range
.split(/\s*\|\|\s*/)
.split('||')
// map the range to a 2d array of comparators
.map(range => this.parseRange(range.trim()))
.map(r => this.parseRange(r.trim()))
// throw out any comparator lists that are empty

@@ -50,5 +50,5 @@ // this generally means that it was not a valid range, which is allowed

this.set = this.set.filter(c => !isNullSet(c[0]))
if (this.set.length === 0)
if (this.set.length === 0) {
this.set = [first]
else if (this.set.length > 1) {
} else if (this.set.length > 1) {
// if we have any that are *, then the range is just *

@@ -89,4 +89,5 @@ for (const c of this.set) {

const cached = cache.get(memoKey)
if (cached)
if (cached) {
return cached
}

@@ -100,3 +101,3 @@ const loose = this.options.loose

range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
debug('comparator trim', range, re[t.COMPARATORTRIM])
debug('comparator trim', range)

@@ -115,4 +116,3 @@ // `~ 1.2.3` => `~1.2.3`

const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
const rangeList = range
let rangeList = range
.split(' ')

@@ -124,5 +124,11 @@ .map(comp => parseComparator(comp, this.options))

.map(comp => replaceGTE0(comp, this.options))
if (loose) {
// in loose mode, throw out any that are not valid comparators
.filter(this.options.loose ? comp => !!comp.match(compRe) : () => true)
.map(comp => new Comparator(comp, this.options))
rangeList = rangeList.filter(comp => {
debug('loose invalid filter', comp, this.options)
return !!comp.match(re[t.COMPARATORLOOSE])
})
}
debug('range list', rangeList)

@@ -132,11 +138,13 @@ // if any comparators are the null set, then replace with JUST null set

// also, don't include the same comparator more than once
const l = rangeList.length
const rangeMap = new Map()
for (const comp of rangeList) {
if (isNullSet(comp))
const comparators = rangeList.map(comp => new Comparator(comp, this.options))
for (const comp of comparators) {
if (isNullSet(comp)) {
return [comp]
}
rangeMap.set(comp.value, comp)
}
if (rangeMap.size > 1 && rangeMap.has(''))
if (rangeMap.size > 1 && rangeMap.has('')) {
rangeMap.delete('')
}

@@ -206,3 +214,3 @@ const result = [...rangeMap.values()]

tildeTrimReplace,
caretTrimReplace
caretTrimReplace,
} = require('../internal/re')

@@ -256,4 +264,4 @@

const replaceTildes = (comp, options) =>
comp.trim().split(/\s+/).map((comp) => {
return replaceTilde(comp, options)
comp.trim().split(/\s+/).map((c) => {
return replaceTilde(c, options)
}).join(' ')

@@ -296,4 +304,4 @@

const replaceCarets = (comp, options) =>
comp.trim().split(/\s+/).map((comp) => {
return replaceCaret(comp, options)
comp.trim().split(/\s+/).map((c) => {
return replaceCaret(c, options)
}).join(' ')

@@ -356,4 +364,4 @@

debug('replaceXRanges', comp, options)
return comp.split(/\s+/).map((comp) => {
return replaceXRange(comp, options)
return comp.split(/\s+/).map((c) => {
return replaceXRange(c, options)
}).join(' ')

@@ -419,4 +427,5 @@ }

if (gtlt === '<')
if (gtlt === '<') {
pr = '-0'
}

@@ -423,0 +432,0 @@ ret = `${gtlt + M}.${m}.${p}${pr}`

@@ -11,13 +11,17 @@ const eq = require('./eq')

case '===':
if (typeof a === 'object')
if (typeof a === 'object') {
a = a.version
if (typeof b === 'object')
}
if (typeof b === 'object') {
b = b.version
}
return a === b
case '!==':
if (typeof a === 'object')
if (typeof a === 'object') {
a = a.version
if (typeof b === 'object')
}
if (typeof b === 'object') {
b = b.version
}
return a !== b

@@ -24,0 +28,0 @@

const SemVer = require('../classes/semver')
const parse = require('./parse')
const {re, t} = require('../internal/re')
const { re, t } = require('../internal/re')

@@ -46,4 +46,5 @@ const coerce = (version, options) => {

if (match === null)
if (match === null) {
return null
}

@@ -50,0 +51,0 @@ return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)

@@ -1,2 +0,2 @@

const {MAX_LENGTH} = require('../internal/constants')
const { MAX_LENGTH } = require('../internal/constants')
const { re, t } = require('../internal/re')

@@ -3,0 +3,0 @@ const SemVer = require('../classes/semver')

@@ -7,3 +7,3 @@ // Note: this is the semver.org version of the spec that it implements

const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
/* istanbul ignore next */ 9007199254740991
/* istanbul ignore next */ 9007199254740991

@@ -17,3 +17,3 @@ // Max safe segment length for coercion.

MAX_SAFE_INTEGER,
MAX_SAFE_COMPONENT_LENGTH
MAX_SAFE_COMPONENT_LENGTH,
}

@@ -22,3 +22,3 @@ const numeric = /^[0-9]+$/

compareIdentifiers,
rcompareIdentifiers
rcompareIdentifiers,
}

@@ -7,6 +7,6 @@ // parse out just the options we care about so we always get a consistent

: typeof options !== 'object' ? { loose: true }
: opts.filter(k => options[k]).reduce((options, k) => {
options[k] = true
return options
: opts.filter(k => options[k]).reduce((o, k) => {
o[k] = true
return o
}, {})
module.exports = parseOptions

@@ -13,3 +13,3 @@ const { MAX_SAFE_COMPONENT_LENGTH } = require('./constants')

const index = R++
debug(index, value)
debug(name, index, value)
t[name] = index

@@ -182,3 +182,3 @@ src[index] = value

// >=0.0.0 is like a star
createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$')
createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$')
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$')
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$')
{
"name": "semver",
"version": "7.3.5",
"version": "7.3.6",
"description": "The semantic version parser used by npm.",

@@ -11,9 +11,20 @@ "main": "index.js",

"postversion": "npm publish",
"postpublish": "git push origin --follow-tags"
"postpublish": "git push origin --follow-tags",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"lintfix": "npm run lint -- --fix",
"prepublishOnly": "git push origin --follow-tags",
"posttest": "npm run lint",
"template-oss-apply": "template-oss-apply --force"
},
"devDependencies": {
"tap": "^14.10.7"
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.2.2",
"tap": "^16.0.0"
},
"license": "ISC",
"repository": "https://github.com/npm/node-semver",
"repository": {
"type": "git",
"url": "https://github.com/npm/node-semver.git"
},
"bin": {

@@ -23,10 +34,10 @@ "semver": "bin/semver.js"

"files": [
"bin/**/*.js",
"range.bnf",
"classes/**/*.js",
"functions/**/*.js",
"internal/**/*.js",
"ranges/**/*.js",
"bin/",
"classes/",
"functions/",
"internal/",
"ranges/",
"index.js",
"preload.js"
"preload.js",
"range.bnf"
],

@@ -38,7 +49,29 @@ "tap": {

"engines": {
"node": ">=10"
"node": "^10.0.0 || ^12.0.0 || ^14.0.0 || >=16.0.0"
},
"dependencies": {
"lru-cache": "^6.0.0"
"lru-cache": "^7.4.0"
},
"author": "GitHub Inc.",
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.2.2",
"ciVersions": [
"10.0.0",
"10.x",
"12.x",
"14.x",
"16.x"
],
"distPaths": [
"bin/",
"classes/",
"functions/",
"internal/",
"ranges/",
"index.js",
"preload.js",
"range.bnf"
]
}
}

@@ -50,4 +50,5 @@ const SemVer = require('../classes/semver')

})
if (setMin && (!minver || gt(minver, setMin)))
if (setMin && (!minver || gt(minver, setMin))) {
minver = setMin
}
}

@@ -54,0 +55,0 @@

const SemVer = require('../classes/semver')
const Comparator = require('../classes/comparator')
const {ANY} = Comparator
const { ANY } = Comparator
const Range = require('../classes/range')

@@ -5,0 +5,0 @@ const satisfies = require('../functions/satisfies')

@@ -8,3 +8,3 @@ // given a set of versions and a range, create a "simplified" range

const set = []
let min = null
let first = null
let prev = null

@@ -16,27 +16,30 @@ const v = versions.sort((a, b) => compare(a, b, options))

prev = version
if (!min)
min = version
if (!first) {
first = version
}
} else {
if (prev) {
set.push([min, prev])
set.push([first, prev])
}
prev = null
min = null
first = null
}
}
if (min)
set.push([min, null])
if (first) {
set.push([first, null])
}
const ranges = []
for (const [min, max] of set) {
if (min === max)
if (min === max) {
ranges.push(min)
else if (!max && min === v[0])
} else if (!max && min === v[0]) {
ranges.push('*')
else if (!max)
} else if (!max) {
ranges.push(`>=${min}`)
else if (min === v[0])
} else if (min === v[0]) {
ranges.push(`<=${max}`)
else
} else {
ranges.push(`${min} - ${max}`)
}
}

@@ -43,0 +46,0 @@ const simplified = ranges.join(' || ')

@@ -44,4 +44,5 @@ const Range = require('../classes/range.js')

const subset = (sub, dom, options = {}) => {
if (sub === dom)
if (sub === dom) {
return true
}

@@ -56,4 +57,5 @@ sub = new Range(sub, options)

sawNonNull = sawNonNull || isSub !== null
if (isSub)
if (isSub) {
continue OUTER
}
}

@@ -64,4 +66,5 @@ // the null set is a subset of everything, but null simple ranges in

// then it is a subset.
if (sawNonNull)
if (sawNonNull) {
return false
}
}

@@ -72,19 +75,22 @@ return true

const simpleSubset = (sub, dom, options) => {
if (sub === dom)
if (sub === dom) {
return true
}
if (sub.length === 1 && sub[0].semver === ANY) {
if (dom.length === 1 && dom[0].semver === ANY)
if (dom.length === 1 && dom[0].semver === ANY) {
return true
else if (options.includePrerelease)
sub = [ new Comparator('>=0.0.0-0') ]
else
sub = [ new Comparator('>=0.0.0') ]
} else if (options.includePrerelease) {
sub = [new Comparator('>=0.0.0-0')]
} else {
sub = [new Comparator('>=0.0.0')]
}
}
if (dom.length === 1 && dom[0].semver === ANY) {
if (options.includePrerelease)
if (options.includePrerelease) {
return true
else
dom = [ new Comparator('>=0.0.0') ]
} else {
dom = [new Comparator('>=0.0.0')]
}
}

@@ -95,12 +101,14 @@

for (const c of sub) {
if (c.operator === '>' || c.operator === '>=')
if (c.operator === '>' || c.operator === '>=') {
gt = higherGT(gt, c, options)
else if (c.operator === '<' || c.operator === '<=')
} else if (c.operator === '<' || c.operator === '<=') {
lt = lowerLT(lt, c, options)
else
} else {
eqSet.add(c.semver)
}
}
if (eqSet.size > 1)
if (eqSet.size > 1) {
return null
}

@@ -110,6 +118,7 @@ let gtltComp

gtltComp = compare(gt.semver, lt.semver, options)
if (gtltComp > 0)
if (gtltComp > 0) {
return null
else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<='))
} else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
return null
}
}

@@ -119,11 +128,14 @@

for (const eq of eqSet) {
if (gt && !satisfies(eq, String(gt), options))
if (gt && !satisfies(eq, String(gt), options)) {
return null
}
if (lt && !satisfies(eq, String(lt), options))
if (lt && !satisfies(eq, String(lt), options)) {
return null
}
for (const c of dom) {
if (!satisfies(eq, String(c), options))
if (!satisfies(eq, String(c), options)) {
return false
}
}

@@ -164,6 +176,8 @@

higher = higherGT(gt, c, options)
if (higher === c && higher !== gt)
if (higher === c && higher !== gt) {
return false
} else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options))
}
} else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
return false
}
}

@@ -181,9 +195,12 @@ if (lt) {

lower = lowerLT(lt, c, options)
if (lower === c && lower !== lt)
if (lower === c && lower !== lt) {
return false
} else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options))
}
} else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
return false
}
}
if (!c.operator && (lt || gt) && gtltComp !== 0)
if (!c.operator && (lt || gt) && gtltComp !== 0) {
return false
}
}

@@ -194,7 +211,9 @@

// Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
if (gt && hasDomLT && !lt && gtltComp !== 0)
if (gt && hasDomLT && !lt && gtltComp !== 0) {
return false
}
if (lt && hasDomGT && !gt && gtltComp !== 0)
if (lt && hasDomGT && !gt && gtltComp !== 0) {
return false
}

@@ -204,4 +223,5 @@ // we needed a prerelease range in a specific tuple, but didn't get one

// because it includes prereleases in the 1.2.3 tuple
if (needDomGTPre || needDomLTPre)
if (needDomGTPre || needDomLTPre) {
return false
}

@@ -213,4 +233,5 @@ return true

const higherGT = (a, b, options) => {
if (!a)
if (!a) {
return b
}
const comp = compare(a.semver, b.semver, options)

@@ -225,4 +246,5 @@ return comp > 0 ? a

const lowerLT = (a, b, options) => {
if (!a)
if (!a) {
return b
}
const comp = compare(a.semver, b.semver, options)

@@ -229,0 +251,0 @@ return comp < 0 ? a

@@ -267,3 +267,5 @@ semver(1) -- The semantic versioner for npm

* `*` := `>=0.0.0` (Any version satisfies)
* `*` := `>=0.0.0` (Any non-prerelease version satisfies, unless
`includePrerelease` is specified, in which case any version at all
satisfies)
* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version)

@@ -270,0 +272,0 @@ * `1.2.x` := `>=1.2.0 <1.3.0-0` (Matching major and minor versions)

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