Aktueller Stand
This commit is contained in:
23
backend/node_modules/find-my-way/lib/strategies/accept-version.js
generated
vendored
23
backend/node_modules/find-my-way/lib/strategies/accept-version.js
generated
vendored
@@ -7,8 +7,7 @@ function SemVerStore () {
|
||||
return new SemVerStore()
|
||||
}
|
||||
|
||||
this.store = {}
|
||||
|
||||
this.store = new Map()
|
||||
this.maxMajor = 0
|
||||
this.maxMinors = {}
|
||||
this.maxPatches = {}
|
||||
@@ -18,7 +17,7 @@ SemVerStore.prototype.set = function (version, store) {
|
||||
if (typeof version !== 'string') {
|
||||
throw new TypeError('Version should be a string')
|
||||
}
|
||||
let [major, minor, patch] = version.split('.')
|
||||
let [major, minor, patch] = version.split('.', 3)
|
||||
|
||||
if (isNaN(major)) {
|
||||
throw new TypeError('Major version must be a numeric value')
|
||||
@@ -30,29 +29,29 @@ SemVerStore.prototype.set = function (version, store) {
|
||||
|
||||
if (major >= this.maxMajor) {
|
||||
this.maxMajor = major
|
||||
this.store.x = store
|
||||
this.store['*'] = store
|
||||
this.store['x.x'] = store
|
||||
this.store['x.x.x'] = store
|
||||
this.store.set('x', store)
|
||||
this.store.set('*', store)
|
||||
this.store.set('x.x', store)
|
||||
this.store.set('x.x.x', store)
|
||||
}
|
||||
|
||||
if (minor >= (this.maxMinors[major] || 0)) {
|
||||
this.maxMinors[major] = minor
|
||||
this.store[`${major}.x`] = store
|
||||
this.store[`${major}.x.x`] = store
|
||||
this.store.set(`${major}.x`, store)
|
||||
this.store.set(`${major}.x.x`, store)
|
||||
}
|
||||
|
||||
if (patch >= (this.maxPatches[`${major}.${minor}`] || 0)) {
|
||||
this.maxPatches[`${major}.${minor}`] = patch
|
||||
this.store[`${major}.${minor}.x`] = store
|
||||
this.store.set(`${major}.${minor}.x`, store)
|
||||
}
|
||||
|
||||
this.store[`${major}.${minor}.${patch}`] = store
|
||||
this.store.set(`${major}.${minor}.${patch}`, store)
|
||||
return this
|
||||
}
|
||||
|
||||
SemVerStore.prototype.get = function (version) {
|
||||
return this.store[version]
|
||||
return this.store.get(version)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user