Use Bluebird reflect() instead of deprecated settle()

This commit is contained in:
Dan Stillman 2016-04-27 02:34:46 -04:00
parent 05de47149f
commit 1a97f27fe3

View File

@ -105,16 +105,17 @@ ConcurrentCaller.prototype.pause = function (ms) {
* Add a task to the queue without starting it * Add a task to the queue without starting it
* *
* @param {Function|Function[]} - One or more functions to run * @param {Function|Function[]} - One or more functions to run
* @return {Promise[]} - An array of promises for passed functions, resolved once they have all * @return {Promise|Promise<PromiseInspection[]>} - If one function is passed, a promise for the return
* finished (even if other functions are still running) * value of the passed function; if multiple, a promise for an array of PromiseInspection objects
* for those functions, resolved once they have all finished, even if other functions are still running
*/ */
ConcurrentCaller.prototype.add = function (func) { ConcurrentCaller.prototype.add = function (func) {
if (Array.isArray(func)) { if (Array.isArray(func)) {
let promises = []; let promises = [];
for (let i = 0; i < func.length; i++) { for (let i = 0; i < func.length; i++) {
promises.push(this.start(func[i])); promises.push(this.start(func[i]).reflect());
} }
return Promise.settle(promises); return Promise.all(promises);
} }
if (!this._deferred || !this._deferred.promise.isPending()) { if (!this._deferred || !this._deferred.promise.isPending()) {