Skip to content

Commit 71ae4c9

Browse files
committed
reimplement getPromiseResults again
1 parent 2b8b5f2 commit 71ae4c9

File tree

3 files changed

+18
-36
lines changed

3 files changed

+18
-36
lines changed

glutil.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff 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
/**

glutil_min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

promise.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@
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

@@ -112,10 +108,6 @@
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

@@ -185,10 +177,6 @@
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);

0 commit comments

Comments
 (0)