File tree Expand file tree Collapse file tree 3 files changed +18
-36
lines changed Expand file tree Collapse file tree 3 files changed +18
-36
lines changed Original file line number Diff line number Diff line change @@ -169,24 +169,18 @@ var GLUtil={
169169 successes :[ ] , failures :[ ] } ) ;
170170 }
171171 var ret = { successes :[ ] , failures :[ ] } ;
172- return new Promise ( function ( resolve , reject ) {
173- var ret = { successes :[ ] , failures :[ ] } ;
174- var totalPromises = promises . length ;
175- var count = 0 ;
176- for ( var i = 0 ; i < totalPromises ; i ++ ) {
177- var promise = promises [ i ] ;
178- promise . then ( function ( result ) {
179- ret . successes . push ( result ) ;
180- if ( progressResolve ) progressResolve ( result ) ;
181- count ++ ;
182- if ( count == totalPromises ) { resolve ( ret ) ; }
183- } , function ( result ) {
184- ret . failures . push ( result ) ;
185- if ( progressReject ) progressReject ( result ) ;
186- count ++ ;
187- if ( count == totalPromises ) { resolve ( ret ) ; }
188- } ) ;
189- }
172+ var newPromises = [ ]
173+ for ( var i = 0 ; i < promises . length ; i ++ ) {
174+ newPromises . push ( promises [ i ] . then ( function ( x ) {
175+ ret . successes . push ( x )
176+ return true ;
177+ } , function ( x ) {
178+ ret . failures . push ( x )
179+ return true ;
180+ } ) ) ;
181+ }
182+ return Promise . all ( newPromises ) . then ( function ( x ) {
183+ return Promise . resolve ( ret )
190184 } ) ;
191185} ,
192186/**
Original file line number Diff line number Diff line change 9797 return thenPromise ;
9898 }
9999
100- /**
101- * Fulfill this promise with a given value
102- * @param {any } value
103- */
104100 Promise . prototype . fulfill = function ( value ) {
105101 if ( this . _state != 0 ) { return this ; }
106102
112108 return this ;
113109 }
114110
115- /**
116- * Reject this promise with a given value
117- * @param {any } value
118- */
119111 Promise . prototype . reject = function ( value ) {
120112 if ( this . _state != 0 ) { return this ; }
121113
185177 this . fulfill ( x ) ;
186178 }
187179
188- /**
189- * Pass this promise's resolved value to another promise
190- * @param {Promise } promise
191- */
192180 Promise . prototype . chain = function ( promise ) {
193181 var resolve = function ( value ) {
194182 promise . resolve ( value ) ;
You can’t perform that action at this time.
0 commit comments