lib/kissy/5.0.0-alpha.3/build/promise-debug.js
function (promises) {
            var count = promises.length;
            if (!count) {
                return null;
            }
            var defer = new Defer();
            for (var i = 0; i < promises.length; i++) {
                /*jshint loopfunc:true*/
                (function (promise, i) {
                    when(promise, function (value) {
                        promises[i] = value;
                        if (--count === 0) {
                            // if all is resolved
                            // then resolve final returned promise with all value
                            defer.resolve(promises);
                        }
                    }, function (r) {
                        // if any one is rejected
                        // then reject final return promise with first reason
                        defer.reject(r);
                    });
                }(promises[i], i));
            }
            return defer.promise;
        }
function (promises) {
            var count = promises.length;
            if (!count) {
                return null;
            }
            var defer = new Defer();
            for (var i = 0; i < promises.length; i++) {
                /*jshint loopfunc:true*/
                (function (promise, i) {
                    when(promise, function (value) {
                        promises[i] = value;
                        if (--count === 0) {
                            // if all is resolved
                            // then resolve final returned promise with all value
                            defer.resolve(promises);
                        }
                    }, function (r) {
                        // if any one is rejected
                        // then reject final return promise with first reason
                        defer.reject(r);
                    });
                }(promises[i], i));
            }
            return defer.promise;
        }
function ( promises ) { var count = promises . length ; if ( ! count ) { return null ; } var defer = new Defer ( ) ; for ( var i = 0 ; i < promises . length ; i ++ ) { /*jshint loopfunc:true*/ ( function ( promise , i ) { when ( promise , function ( value ) { promises [ i ] = value ; if ( -- count === 0 ) { // if all is resolved // then resolve final returned promise with all value defer . resolve ( promises ) ; } } , function ( r ) { // if any one is rejected // then reject final return promise with first reason defer . reject ( r ) ; } ) ; } ( promises [ i ] , i ) ) ; } return defer . promise ; }
return a new promise
which is resolved when all promises is resolved
and rejected when any one of promises is rejected
@param {KISSY.Promise[]} promises list of promises
@static
@return {KISSY.Promise}
@member KISSY.Promise
return a new promise which is resolved when all promises is resolved and rejected when any one of promises is rejected