@@ -8,9 +8,6 @@ var escOpen = '\0OPEN'+Math.random()+'\0';
88var escClose = '\0CLOSE' + Math . random ( ) + '\0' ;
99var escComma = '\0COMMA' + Math . random ( ) + '\0' ;
1010var escPeriod = '\0PERIOD' + Math . random ( ) + '\0' ;
11- var EXPANSION_MAX = 100000 ;
12-
13- module . exports . EXPANSION_MAX = EXPANSION_MAX ;
1411
1512function numeric ( str ) {
1613 return parseInt ( str , 10 ) == str
@@ -65,13 +62,10 @@ function parseCommaParts(str) {
6562 return parts ;
6663}
6764
68- function expandTop ( str , options ) {
65+ function expandTop ( str ) {
6966 if ( ! str )
7067 return [ ] ;
7168
72- options = options || { } ;
73- var max = options . max == null ? EXPANSION_MAX : options . max ;
74-
7569 // I don't know why Bash 4.3 does this, but it does.
7670 // Anything starting with {} will have the first two bytes preserved
7771 // but *only* at the top level, so {},a }b will not expand to anything,
@@ -82,7 +76,7 @@ function expandTop(str, options) {
8276 str = '\\{\\}' + str . substr ( 2 ) ;
8377 }
8478
85- return expand ( escapeBraces ( str ) , max , true ) . map ( unescapeBraces ) ;
79+ return expand ( escapeBraces ( str ) , true ) . map ( unescapeBraces ) ;
8680}
8781
8882function identity ( e ) {
@@ -103,7 +97,7 @@ function gte(i, y) {
10397 return i >= y ;
10498}
10599
106- function expand ( str , max , isTop ) {
100+ function expand ( str , isTop ) {
107101 var expansions = [ ] ;
108102
109103 var m = balanced ( '{' , '}' , str ) ;
@@ -117,7 +111,7 @@ function expand(str, max, isTop) {
117111 // {a},b }
118112 if ( m . post . match ( / , (? ! , ) .* \} / ) ) {
119113 str = m . pre + '{' + m . body + escClose + m . post ;
120- return expand ( str , max , true ) ;
114+ return expand ( str ) ;
121115 }
122116 return [ str ] ;
123117 }
@@ -129,10 +123,10 @@ function expand(str, max, isTop) {
129123 n = parseCommaParts ( m . body ) ;
130124 if ( n . length === 1 ) {
131125 // x{{a,b}}y ==> x{a}y x{b}y
132- n = expand ( n [ 0 ] , max , false ) . map ( embrace ) ;
126+ n = expand ( n [ 0 ] , false ) . map ( embrace ) ;
133127 if ( n . length === 1 ) {
134128 var post = m . post . length
135- ? expand ( m . post , max , false )
129+ ? expand ( m . post , false )
136130 : [ '' ] ;
137131 return post . map ( function ( p ) {
138132 return m . pre + n [ 0 ] + p ;
@@ -147,7 +141,7 @@ function expand(str, max, isTop) {
147141 // no need to expand pre, since it is guaranteed to be free of brace-sets
148142 var pre = m . pre ;
149143 var post = m . post . length
150- ? expand ( m . post , max , false )
144+ ? expand ( m . post , false )
151145 : [ '' ] ;
152146
153147 var N ;
@@ -191,11 +185,11 @@ function expand(str, max, isTop) {
191185 N . push ( c ) ;
192186 }
193187 } else {
194- N = concatMap ( n , function ( el ) { return expand ( el , max , false ) } ) ;
188+ N = concatMap ( n , function ( el ) { return expand ( el , false ) } ) ;
195189 }
196190
197191 for ( var j = 0 ; j < N . length ; j ++ ) {
198- for ( var k = 0 ; k < post . length && expansions . length < max ; k ++ ) {
192+ for ( var k = 0 ; k < post . length ; k ++ ) {
199193 var expansion = pre + N [ j ] + post [ k ] ;
200194 if ( ! isTop || isSequence || expansion )
201195 expansions . push ( expansion ) ;
0 commit comments