@@ -27,9 +27,14 @@ class Core extends Emitter {
2727 this . constraints = new Constraints ;
2828 this . filters = new Filters ;
2929
30- if ( this . capcity > 0 ) {
31- this . addConstraint ( ( ) => this . stat . getTotal ( ) >= this . capcity ) ;
32- }
30+ this . addConstraint ( ( ) => {
31+ if ( this . capcity > 0 ) {
32+ return this . stat . getTotal ( ) >= this . capcity
33+ }
34+ else {
35+ return false ;
36+ }
37+ } ) ;
3338
3439 if ( this . accept && this . accept . length > 0 ) {
3540 this . addFilter ( ( file ) => {
@@ -62,7 +67,7 @@ class Core extends Emitter {
6267 options . fitlers . forEach ( filter => this . addFilter ( filter ) ) ;
6368 }
6469
65- const request = options . request || { } ;
70+ let request = options . request || { } ;
6671 REQUEST_OPTIONS . forEach ( ( key ) => {
6772 if ( options . hasOwnProperty ( key ) ) {
6873 request [ key ] = options [ key ] ;
@@ -72,6 +77,23 @@ class Core extends Emitter {
7277 this . requestOptions = request ;
7378 }
7479
80+ setOptions ( options ) {
81+ if ( typeof options === 'object' && ! ( options instanceof Array ) ) {
82+ this . autoPending = options . autoPending || options . auto || this . autoPending ;
83+ this . capcity = options . capcity || options . queueCapcity || this . capcity ;
84+ this . sizeLimit = parseSize ( options . sizeLimit || options . fileSizeLimit || this . sizeLimit ) ;
85+ let requestOptions = this . requestOptions
86+ REQUEST_OPTIONS . forEach ( ( key ) => {
87+ if ( options . hasOwnProperty ( key ) ) {
88+ requestOptions [ key ] = options [ key ] ;
89+ }
90+ } ) ;
91+ }
92+ else {
93+ console && console . error ( 'setOptions: type error, options should be an object/hashMap' ) ;
94+ }
95+ }
96+
7597 createFileRequest ( file ) {
7698 return new FileRequest ( file , this . requestOptions ) ;
7799 }
0 commit comments