@@ -8,12 +8,18 @@ var escClose = '\0CLOSE'+Math.random()+'\0';
88var escComma = '\0COMMA' + Math . random ( ) + '\0' ;
99var escPeriod = '\0PERIOD' + Math . random ( ) + '\0' ;
1010
11+ /**
12+ * @return {number }
13+ */
1114function numeric ( str ) {
1215 return parseInt ( str , 10 ) == str
1316 ? parseInt ( str , 10 )
1417 : str . charCodeAt ( 0 ) ;
1518}
1619
20+ /**
21+ * @param {string } str
22+ */
1723function escapeBraces ( str ) {
1824 return str . split ( '\\\\' ) . join ( escSlash )
1925 . split ( '\\{' ) . join ( escOpen )
@@ -22,6 +28,9 @@ function escapeBraces(str) {
2228 . split ( '\\.' ) . join ( escPeriod ) ;
2329}
2430
31+ /**
32+ * @param {string } str
33+ */
2534function unescapeBraces ( str ) {
2635 return str . split ( escSlash ) . join ( '\\' )
2736 . split ( escOpen ) . join ( '{' )
@@ -30,10 +39,12 @@ function unescapeBraces(str) {
3039 . split ( escPeriod ) . join ( '.' ) ;
3140}
3241
33-
34- // Basically just str.split(","), but handling cases
35- // where we have nested braced sections, which should be
36- // treated as individual members, like {a,{b,c},d}
42+ /**
43+ * Basically just str.split(","), but handling cases
44+ * where we have nested braced sections, which should be
45+ * treated as individual members, like {a,{b,c},d}
46+ * @param {string } str
47+ */
3748function parseCommaParts ( str ) {
3849 if ( ! str )
3950 return [ '' ] ;
@@ -61,6 +72,9 @@ function parseCommaParts(str) {
6172 return parts ;
6273}
6374
75+ /**
76+ * @param {string } str
77+ */
6478function expandTop ( str ) {
6579 if ( ! str )
6680 return [ ] ;
@@ -78,21 +92,40 @@ function expandTop(str) {
7892 return expand ( escapeBraces ( str ) , true ) . map ( unescapeBraces ) ;
7993}
8094
95+ /**
96+ * @param {string } str
97+ */
8198function embrace ( str ) {
8299 return '{' + str + '}' ;
83100}
101+ /**
102+ * @param {string } el
103+ */
84104function isPadded ( el ) {
85105 return / ^ - ? 0 \d / . test ( el ) ;
86106}
87107
108+ /**
109+ * @param {number } i
110+ * @param {number } y
111+ */
88112function lte ( i , y ) {
89113 return i <= y ;
90114}
115+ /**
116+ * @param {number } i
117+ * @param {number } y
118+ */
91119function gte ( i , y ) {
92120 return i >= y ;
93121}
94122
123+ /**
124+ * @param {string } str
125+ * @param {boolean } [isTop]
126+ */
95127function expand ( str , isTop ) {
128+ /** @type {string[] } */
96129 var expansions = [ ] ;
97130
98131 var m = balanced ( '{' , '}' , str ) ;
@@ -104,7 +137,7 @@ function expand(str, isTop) {
104137 ? expand ( m . post , false )
105138 : [ '' ] ;
106139
107- if ( / \$ $ / . test ( m . pre ) ) {
140+ if ( / \$ $ / . test ( m . pre ) ) {
108141 for ( var k = 0 ; k < post . length ; k ++ ) {
109142 var expansion = pre + '{' + m . body + '}' + post [ k ] ;
110143 expansions . push ( expansion ) ;
0 commit comments