@@ -962,6 +962,8 @@ var hasRequiredRange;
962
962
function requireRange ( ) {
963
963
if ( hasRequiredRange ) return range ;
964
964
hasRequiredRange = 1 ;
965
+ const SPACE_CHARACTERS = / \s + / g;
966
+
965
967
// hoisted class for cyclic dependency
966
968
class Range {
967
969
constructor ( range , options ) {
@@ -982,7 +984,7 @@ function requireRange () {
982
984
// just put it in the set and return
983
985
this . raw = range . value ;
984
986
this . set = [ [ range ] ] ;
985
- this . format ( ) ;
987
+ this . formatted = undefined ;
986
988
return this
987
989
}
988
990
@@ -993,10 +995,7 @@ function requireRange () {
993
995
// First reduce all whitespace as much as possible so we do not have to rely
994
996
// on potentially slow regexes like \s*. This is then stored and used for
995
997
// future error messages as well.
996
- this . raw = range
997
- . trim ( )
998
- . split ( / \s + / )
999
- . join ( ' ' ) ;
998
+ this . raw = range . trim ( ) . replace ( SPACE_CHARACTERS , ' ' ) ;
1000
999
1001
1000
// First, split on ||
1002
1001
this . set = this . raw
@@ -1030,14 +1029,29 @@ function requireRange () {
1030
1029
}
1031
1030
}
1032
1031
1033
- this . format ( ) ;
1032
+ this . formatted = undefined ;
1033
+ }
1034
+
1035
+ get range ( ) {
1036
+ if ( this . formatted === undefined ) {
1037
+ this . formatted = '' ;
1038
+ for ( let i = 0 ; i < this . set . length ; i ++ ) {
1039
+ if ( i > 0 ) {
1040
+ this . formatted += '||' ;
1041
+ }
1042
+ const comps = this . set [ i ] ;
1043
+ for ( let k = 0 ; k < comps . length ; k ++ ) {
1044
+ if ( k > 0 ) {
1045
+ this . formatted += ' ' ;
1046
+ }
1047
+ this . formatted += comps [ k ] . toString ( ) . trim ( ) ;
1048
+ }
1049
+ }
1050
+ }
1051
+ return this . formatted
1034
1052
}
1035
1053
1036
1054
format ( ) {
1037
- this . range = this . set
1038
- . map ( ( comps ) => comps . join ( ' ' ) . trim ( ) )
1039
- . join ( '||' )
1040
- . trim ( ) ;
1041
1055
return this . range
1042
1056
}
1043
1057
0 commit comments