semver 7.6.1 → 7.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -459,7 +459,7 @@ strings that they parse.
459
459
  in descending order when passed to `Array.sort()`.
460
460
  * `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
461
461
  are equal. Sorts in ascending order if passed to `Array.sort()`.
462
- * `compareLoose(v1, v2)`: Short for ``compare(v1, v2, { loose: true })`.
462
+ * `compareLoose(v1, v2)`: Short for `compare(v1, v2, { loose: true })`.
463
463
  * `diff(v1, v2)`: Returns the difference between two versions by the release type
464
464
  (`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
465
465
  or null if the versions are the same.
package/classes/range.js CHANGED
@@ -1,3 +1,5 @@
1
+ const SPACE_CHARACTERS = /\s+/g
2
+
1
3
  // hoisted class for cyclic dependency
2
4
  class Range {
3
5
  constructor (range, options) {
@@ -18,7 +20,7 @@ class Range {
18
20
  // just put it in the set and return
19
21
  this.raw = range.value
20
22
  this.set = [[range]]
21
- this.format()
23
+ this.formatted = undefined
22
24
  return this
23
25
  }
24
26
 
@@ -29,10 +31,7 @@ class Range {
29
31
  // First reduce all whitespace as much as possible so we do not have to rely
30
32
  // on potentially slow regexes like \s*. This is then stored and used for
31
33
  // future error messages as well.
32
- this.raw = range
33
- .trim()
34
- .split(/\s+/)
35
- .join(' ')
34
+ this.raw = range.trim().replace(SPACE_CHARACTERS, ' ')
36
35
 
37
36
  // First, split on ||
38
37
  this.set = this.raw
@@ -66,14 +65,29 @@ class Range {
66
65
  }
67
66
  }
68
67
 
69
- this.format()
68
+ this.formatted = undefined
69
+ }
70
+
71
+ get range () {
72
+ if (this.formatted === undefined) {
73
+ this.formatted = ''
74
+ for (let i = 0; i < this.set.length; i++) {
75
+ if (i > 0) {
76
+ this.formatted += '||'
77
+ }
78
+ const comps = this.set[i]
79
+ for (let k = 0; k < comps.length; k++) {
80
+ if (k > 0) {
81
+ this.formatted += ' '
82
+ }
83
+ this.formatted += comps[k].toString().trim()
84
+ }
85
+ }
86
+ }
87
+ return this.formatted
70
88
  }
71
89
 
72
90
  format () {
73
- this.range = this.set
74
- .map((comps) => comps.join(' ').trim())
75
- .join('||')
76
- .trim()
77
91
  return this.range
78
92
  }
79
93
 
@@ -17,12 +17,7 @@ class LRUCache {
17
17
  }
18
18
 
19
19
  delete (key) {
20
- if (this.map.has(key)) {
21
- this.map.delete(key)
22
- return true
23
- } else {
24
- return false
25
- }
20
+ return this.map.delete(key)
26
21
  }
27
22
 
28
23
  set (key, value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semver",
3
- "version": "7.6.1",
3
+ "version": "7.6.3",
4
4
  "description": "The semantic version parser used by npm.",
5
5
  "main": "index.js",
6
6
  "scripts": {