File tree 4 files changed +30
-16
lines changed
4 files changed +30
-16
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " semver" ,
3
- "version" : " 7.6.2 " ,
3
+ "version" : " 7.6.3 " ,
4
4
"description" : " The semantic version parser used by npm." ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change 143
143
"proc-log": "^4.2.0",
144
144
"qrcode-terminal": "^0.12.0",
145
145
"read": "^3.0.1",
146
- "semver": "^7.6.2 ",
146
+ "semver": "^7.6.3 ",
147
147
"spdx-expression-parse": "^4.0.0",
148
148
"ssri": "^10.0.6",
149
149
"supports-color": "^9.4.0",
11549
11549
}
11550
11550
},
11551
11551
"node_modules/semver": {
11552
- "version": "7.6.2 ",
11553
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2 .tgz",
11554
- "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w ==",
11552
+ "version": "7.6.3 ",
11553
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3 .tgz",
11554
+ "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A ==",
11555
11555
"inBundle": true,
11556
11556
"license": "ISC",
11557
11557
"bin": {
Original file line number Diff line number Diff line change 108
108
"proc-log" : " ^4.2.0" ,
109
109
"qrcode-terminal" : " ^0.12.0" ,
110
110
"read" : " ^3.0.1" ,
111
- "semver" : " ^7.6.2 " ,
111
+ "semver" : " ^7.6.3 " ,
112
112
"spdx-expression-parse" : " ^4.0.0" ,
113
113
"ssri" : " ^10.0.6" ,
114
114
"supports-color" : " ^9.4.0" ,
You can’t perform that action at this time.
0 commit comments