@@ -27,7 +27,7 @@ function String_random (pattern, options) {
2727 if ( next === ':' ) {
2828 // just create a group
2929 } else {
30- throw "Invalid group" ;
30+ throw Error ( "Invalid group" ) ;
3131 }
3232 } else
3333 if ( next === '(' || next === ')' ) {
@@ -44,46 +44,46 @@ function String_random (pattern, options) {
4444 }
4545 }
4646
47- if ( stack . length > 1 ) throw "missmatch paren";
47+ if ( stack . length > 1 ) throw Error ( "mismatch paren") ;
4848
4949 return tree ;
5050 }
5151
5252 function processSelect ( tree ) {
53- const candinates = [ [ ] ] ;
53+ const candidates = [ [ ] ] ;
5454
5555 while ( tree . length ) {
5656 let chr = tree . shift ( ) ;
5757 if ( chr === '\\' ) {
5858 const next = tree . shift ( ) ;
5959 if ( next === '|' ) {
60- candinates [ 0 ] . push ( next ) ;
60+ candidates [ 0 ] . push ( next ) ;
6161 } else {
62- candinates [ 0 ] . push ( chr , next ) ;
62+ candidates [ 0 ] . push ( chr , next ) ;
6363 }
6464 } else
6565 if ( chr === '[' ) {
66- candinates [ 0 ] . push ( chr ) ;
66+ candidates [ 0 ] . push ( chr ) ;
6767 while ( tree . length ) {
6868 chr = tree . shift ( ) ;
69- candinates [ 0 ] . push ( chr ) ;
69+ candidates [ 0 ] . push ( chr ) ;
7070 if ( chr === '\\' ) {
7171 const next = tree . shift ( ) ; // no warnings
72- candinates [ 0 ] . push ( next ) ;
72+ candidates [ 0 ] . push ( next ) ;
7373 } else
7474 if ( chr === ']' ) {
7575 break ;
7676 }
7777 }
7878 } else
7979 if ( chr === '|' ) {
80- candinates . unshift ( [ ] ) ;
80+ candidates . unshift ( [ ] ) ;
8181 } else {
82- candinates [ 0 ] . push ( chr ) ;
82+ candidates [ 0 ] . push ( chr ) ;
8383 }
8484 }
8585
86- for ( let i = 0 , it ; ( it = candinates [ i ] ) ; i ++ ) {
86+ for ( let i = 0 , it ; ( it = candidates [ i ] ) ; i ++ ) {
8787 tree . push ( it ) ;
8888 for ( let j = 0 , len = it . length ; j < len ; j ++ ) {
8989 if ( it [ j ] instanceof Array ) {
@@ -92,7 +92,7 @@ function String_random (pattern, options) {
9292 }
9393 }
9494
95- // 入れ子、 奇数段が pattern 偶数段が candinates ,
95+ // 入れ子、 奇数段が pattern 偶数段が candidates ,
9696 return [ tree ] ;
9797 }
9898
@@ -163,7 +163,7 @@ function String_random (pattern, options) {
163163 }
164164 }
165165
166- if ( chr !== '}' ) throw " missmatch brace: " + chr ;
166+ if ( chr !== '}' ) throw Error ( ` missmatch brace: ${ chr } ` ) ;
167167
168168 const dd = brace . split ( / , / ) ;
169169 const min = + dd [ 0 ] ;
@@ -189,7 +189,7 @@ function String_random (pattern, options) {
189189 candinates = [ REFERENCE [ escaped ] || '' ] ;
190190 } else {
191191 if ( escaped === 'b' || escaped === 'B' ) {
192- throw " \\b and \\B is not supported" ;
192+ throw Error ( ` \\b and \\B is not supported` ) ;
193193 }
194194 candinates = CLASSES [ escaped ] ;
195195 }
0 commit comments