File tree Expand file tree Collapse file tree 4 files changed +30
-16
lines changed
Expand file tree Collapse file tree 4 files changed +30
-16
lines changed Original file line number Diff line number Diff line change 1+ const SPACE_CHARACTERS = / \s + / g
2+
13// hoisted class for cyclic dependency
24class Range {
35 constructor ( range , options ) {
@@ -18,7 +20,7 @@ class Range {
1820 // just put it in the set and return
1921 this . raw = range . value
2022 this . set = [ [ range ] ]
21- this . format ( )
23+ this . formatted = undefined
2224 return this
2325 }
2426
@@ -29,10 +31,7 @@ class Range {
2931 // First reduce all whitespace as much as possible so we do not have to rely
3032 // on potentially slow regexes like \s*. This is then stored and used for
3133 // future error messages as well.
32- this . raw = range
33- . trim ( )
34- . split ( / \s + / )
35- . join ( ' ' )
34+ this . raw = range . trim ( ) . replace ( SPACE_CHARACTERS , ' ' )
3635
3736 // First, split on ||
3837 this . set = this . raw
@@ -66,14 +65,29 @@ class Range {
6665 }
6766 }
6867
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
7088 }
7189
7290 format ( ) {
73- this . range = this . set
74- . map ( ( comps ) => comps . join ( ' ' ) . trim ( ) )
75- . join ( '||' )
76- . trim ( )
7791 return this . range
7892 }
7993
Original file line number Diff line number Diff line change 11{
22 "name" : " semver" ,
3- "version" : " 7.6.2 " ,
3+ "version" : " 7.6.3 " ,
44 "description" : " The semantic version parser used by npm." ,
55 "main" : " index.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change 143143 "proc-log": "^4.2.0",
144144 "qrcode-terminal": "^0.12.0",
145145 "read": "^3.0.1",
146- "semver": "^7.6.2 ",
146+ "semver": "^7.6.3 ",
147147 "spdx-expression-parse": "^4.0.0",
148148 "ssri": "^10.0.6",
149149 "supports-color": "^9.4.0",
1154911549 }
1155011550 },
1155111551 "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 ==",
1155511555 "inBundle": true,
1155611556 "license": "ISC",
1155711557 "bin": {
Original file line number Diff line number Diff line change 108108 "proc-log" : " ^4.2.0" ,
109109 "qrcode-terminal" : " ^0.12.0" ,
110110 "read" : " ^3.0.1" ,
111- "semver" : " ^7.6.2 " ,
111+ "semver" : " ^7.6.3 " ,
112112 "spdx-expression-parse" : " ^4.0.0" ,
113113 "ssri" : " ^10.0.6" ,
114114 "supports-color" : " ^9.4.0" ,
You can’t perform that action at this time.
0 commit comments