/*! * extend-promise v0.0.6 * Homepage https://github.com/cnwhy/extend-promise#readme * License BSD-2-Clause */ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0 ? +count : 0; } return function(promises) { var defer = QClass.defer(); var data,_tempI = 0; var fillData = function(i){ var _p = promises[i]; QClass.resolve(_p).then(function(d) { if(typeof count != 'undefined'){ data.push(d); }else{ data[i] = d; } if (--_tempI == 0 || (!map && count && data.length>=count)) { defer.resolve(data); } }, function(err) { if (isEmpty(count)) { defer.reject(err); }else if(--_tempI == 0){ defer.resolve(data); } }) _tempI++; } if(isArray(promises)){ data = []; if(promises.length == 0){defer.resolve(data)}; for(var i = 0; i= 0 ? +count : 0; return getall(false,count)(proArr) } } //map if(asbind("map")){ QClass.map = function(data,mapfun,options){ var defer = QClass.defer(); var promiseArr = []; var concurrency = options ? +options.concurrency : 0 //无并发控制 if(concurrency == 0 || concurrency != concurrency){ for(var i in data){ promiseArr.push(mapfun(data[i],i,data)); } QClass.all(promiseArr).then(defer.resolve,defer.reject) return defer.promise; } var k = 0; var keys = (function(){ var ks = []; for(var k in data){ ks.push(k); } return ks; })(); function next(){ if(k0 && k