Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extend-promise

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extend-promise - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

test/1.txt

67

dist/extend-promise.js
/*!
* extend-promise v0.0.3
* extend-promise v0.0.6
* Homepage https://github.com/cnwhy/extend-promise#readme

@@ -69,8 +69,4 @@ * License BSD-2-Clause

//defer
if(isFunction(Promise.defer)){
QClass.defer = Promise.defer
}else if(isFunction(Promise.deferred)){
QClass.defer = Promise.deferred
}else{
//defer defer为最基础的实现
if(isFunction(Promise) && isFunction(Promise.prototype.then)){
QClass.defer = function() {

@@ -88,2 +84,8 @@ var resolve, reject;

}
}else if(isFunction(Promise.defer)){
QClass.defer = function(){return Promise.defer();}
}else if(isFunction(Promise.deferred)){
QClass.defer = function(){return Promise.deferred();}
}else{
throw new TypeError("此类不支持扩展!")
}

@@ -95,3 +97,6 @@

var defer = QClass.defer();
setTimeout(defer.resolve,ms,value)
setTimeout(function(){
//console.log('==========')
defer.resolve(value);
},ms)
return defer.promise;

@@ -127,5 +132,9 @@ }

var fillData = function(i){
var _p = promises[i]
var _p = promises[i];
QClass.resolve(_p).then(function(d) {
data[i] = d;
if(typeof count != 'undefined'){
data.push(d);
}else{
data[i] = d;
}
if (--_tempI == 0 || (!map && count && data.length>=count)) {

@@ -145,2 +154,3 @@ defer.resolve(data);

data = [];
if(promises.length == 0){defer.resolve(data)};
for(var i = 0; i<promises.length; i++){

@@ -150,8 +160,11 @@ fillData(i);

}else if(map && isPlainObject(promises)){
var _mark = 0;
data = {}
for(var i in promises){
fillData(i);
_mark++;
}
if(_mark == 0) defer.resolve(data)
}else{
defer.reject(new TypeError());
defer.reject(new TypeError("参数错误"));
}

@@ -173,3 +186,4 @@ return defer.promise;

QClass.some = function(proArr,count){
return getall(false,count||0)(proArr)
count = +count >= 0 ? +count : 0;
return getall(false,count)(proArr)
}

@@ -225,13 +239,11 @@ }

for (var i = 0; i < proArr.length; i++) {
+ function() {
(function() {
var _i = i;
//nextTick(function() {
var _p = proArr[_i];
QClass.resolve(_p).then(function(data) {
defer.resolve(data);
}, function(err) {
defer.reject(err);
})
//}, 0)
}()
var _p = proArr[_i];
QClass.resolve(_p).then(function(data) {
defer.resolve(data);
}, function(err) {
defer.reject(err);
})
})()
}

@@ -263,2 +275,3 @@ return defer.promise;

f.apply(_this,argsArray)
return defer.promise;
}

@@ -279,3 +292,3 @@

}else{
throw "args TypeError"
throw TypeError('"args" is not Array')
}

@@ -289,3 +302,3 @@ return defer.promise;

return function(){
return nfcall.call(_this,f,arg2arr(arguments))
return nfcall.apply(_this,[].concat([f],arg2arr(arguments)))
}

@@ -304,3 +317,3 @@ }

if(typeof no == "function") setTimeout(function(){no(err)},0)
else throw err;
else setTimeout(function(){throw err;},0)
})

@@ -310,3 +323,3 @@ }

return this.then(function(value){
return ok.apply(null,value);
return ok.apply(null,value);
},no);

@@ -374,3 +387,3 @@ }

exports.isArray = function(obj){
return Object.prototype.toString.call(obj) == "[objece Array]"
return Object.prototype.toString.call(obj) == "[object Array]"
}

@@ -377,0 +390,0 @@

/*!
* extend-promise v0.0.3
* extend-promise v0.0.6
* Homepage https://github.com/cnwhy/extend-promise#readme
* License BSD-2-Clause
*/
!function e(n,r,t){function o(u,f){if(!r[u]){if(!n[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=r[u]={exports:{}};n[u][0].call(s.exports,function(e){var r=n[u][1][e];return o(r?r:e)},s,s.exports,e,n,r,t)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<t.length;u++)o(t[u]);return o}({1:[function(e,n,r){!function(e,n){if("function"==typeof define&&(define.amd||define.cmd))define([],n);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!");var r="undefined"!=typeof window?window:self;r[e]=n(),"function"==typeof r.Promise&&r[e].auto(r.Promise)}}("extendPromise",function(){var n=e("../index");return n.auto=function(e){n.extendClass(e),n.extendPrototype(e)},n})},{"../index":2}],2:[function(e,n,r){n.exports={extendClass:e("./src/extendClass"),extendPrototype:e("./src/extendPrototype")}},{"./src/extendClass":3,"./src/extendPrototype":4}],3:[function(e,n,r){"use strict";function t(e,n,r){function t(e){if(i(r)){for(var n=!1,t=0;t<r.length;t++)if(r[t]==e){n=!0;break}if(!n)return!1}return!h||!f(d[e])}function o(e,n){return u(n)||(n=+n>0?+n:0),function(r){var t,o=d.defer(),f=0,s=function(i){var c=r[i];d.resolve(c).then(function(r){t[i]=r,(0==--f||!e&&n&&t.length>=n)&&o.resolve(t)},function(e){u(n)?o.reject(e):0==--f&&o.resolve(t)}),f++};if(i(r)){t=[];for(var l=0;l<r.length;l++)s(l)}else if(e&&c(r)){t={};for(var l in r)s(l)}else o.reject(new TypeError);return o.promise}}function l(e){for(var n=d.defer(),r=0;r<e.length;r++)+function(){var t=r,o=e[t];d.resolve(o).then(function(e){n.resolve(e)},function(e){n.reject(e)})}();return n.promise}function a(e){return function(n,r){return n?e.reject(n):void e.resolve(r)}}function p(e){var n=this===d?null:this,r=d.defer(),t=s(arguments,1);t.push(a(r)),e.apply(n,t)}var d,h;return n?(h=!0,d=n):d=e,d.Promise||e==n||(d.Promise=e),f(e.defer)?d.defer=e.defer:f(e.deferred)?d.defer=e.deferred:d.defer=function(){var n,r,t=new e(function(e,t){n=e,r=t});return{promise:t,resolve:n,reject:r}},t("delay")&&(d.delay=function(e,n){var r=d.defer();return setTimeout(r.resolve,e,n),r.promise}),t("resolve")&&(d.resolve=function(e){var n=d.defer();return n.resolve(e),n.promise}),t("reject")&&(d.reject=function(e){var n=d.defer();return n.reject(e),n.promise}),t("all")&&(d.all=o()),t("allMap")&&(d.allMap=o(!0)),t("some")&&(d.some=function(e,n){return o(!1,n||0)(e)}),t("map")&&(d.map=function(e,n,r){function t(){if(c<s.length){var r=s[c],f=d.resolve(n(e[r],r,e)).then(function(e){return t(),e},o.reject);i.push(f),u--,c++}else d.all(i).then(o.resolve,o.reject)}var o=d.defer(),i=[],u=r?+r.concurrency:0;if(0==u||u!=u){for(var f in e)i.push(n(e[f],f,e));return d.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var n=[];for(var r in e)n.push(r);return n}();do t();while(u>0&&c<s.length);return o.promise}),t("race")&&(d.race=l),t("any")&&(d.any=l),t("nfcall")&&(d.nfcall=p),t("nfapply")&&(d.nfapply=function(e,n){var r=this===d?null:this,t=d.defer();if(!i(n))throw"args TypeError";return n.push(a(t)),e.apply(r,n),t.promise}),d.denodeify=function(e){var n=this===d?null:this;return function(){return p.call(n,e,s(arguments))}},d}var o=e("./utils"),i=o.isArray,u=o.isEmpty,f=o.isFunction,c=o.isPlainObject,s=o.arg2arr;n.exports=t},{"./utils":5}],4:[function(e,n,r){function t(e){var n=e.prototype;return n.done=function(e,n){this.then(function(n){"function"==typeof e&&setTimeout(function(){e(n)},0)},function(e){if("function"!=typeof n)throw e;setTimeout(function(){n(e)},0)})},n.spread=function(e,n){return this.then(function(n){return e.apply(null,n)},n)},n.fail=n.catch=function(e){return this.then(null,e)},n.catchOf=function(e,n){return n=n||e,this.then(null,function(r){var t=typeof n;if("function"!=t)throw r;if(e===n)return n(r);if(e===r||"function"==typeof e&&r instanceof e)return n(r);throw r})},n.error=function(e){return this.catchOf(Error,e)},n.fin=n.finally=function(e){var n=function(n,r){try{e(n,r)}catch(e){}};return this.then(function(e){return n(e),e},function(e){throw n(null,e),e})},e}n.exports=t},{}],5:[function(e,n,r){"use strict";r.isPlainObject=function(e){return null!==e&&"object"==typeof e&&!e.nodeType&&e!==e.window&&!(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},r.isArray=function(e){return"[objece Array]"==Object.prototype.toString.call(e)},r.isFunction=function(e){return"function"==typeof e},r.isEmpty=function(e){return"undefined"==typeof e||null===e},r.arg2arr=function(e,n,r){return Array.prototype.slice.call(e,n,r)}},{}]},{},[1]);
!function e(n,r,t){function o(u,f){if(!r[u]){if(!n[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=r[u]={exports:{}};n[u][0].call(s.exports,function(e){var r=n[u][1][e];return o(r?r:e)},s,s.exports,e,n,r,t)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<t.length;u++)o(t[u]);return o}({1:[function(e,n,r){!function(e,n){if("function"==typeof define&&(define.amd||define.cmd))define([],n);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!");var r="undefined"!=typeof window?window:self;r[e]=n(),"function"==typeof r.Promise&&r[e].auto(r.Promise)}}("extendPromise",function(){var n=e("../index");return n.auto=function(e){n.extendClass(e),n.extendPrototype(e)},n})},{"../index":2}],2:[function(e,n,r){n.exports={extendClass:e("./src/extendClass"),extendPrototype:e("./src/extendPrototype")}},{"./src/extendClass":3,"./src/extendPrototype":4}],3:[function(e,n,r){"use strict";function t(e,n,r){function t(e){if(i(r)){for(var n=!1,t=0;t<r.length;t++)if(r[t]==e){n=!0;break}if(!n)return!1}return!y||!f(d[e])}function o(e,n){return u(n)||(n=+n>0?+n:0),function(r){var t,o=d.defer(),f=0,s=function(i){var c=r[i];d.resolve(c).then(function(r){"undefined"!=typeof n?t.push(r):t[i]=r,(0==--f||!e&&n&&t.length>=n)&&o.resolve(t)},function(e){u(n)?o.reject(e):0==--f&&o.resolve(t)}),f++};if(i(r)){t=[],0==r.length&&o.resolve(t);for(var l=0;l<r.length;l++)s(l)}else if(e&&c(r)){var a=0;t={};for(var l in r)s(l),a++;0==a&&o.resolve(t)}else o.reject(new TypeError("参数错误"));return o.promise}}function l(e){for(var n=d.defer(),r=0;r<e.length;r++)!function(){var t=r,o=e[t];d.resolve(o).then(function(e){n.resolve(e)},function(e){n.reject(e)})}();return n.promise}function a(e){return function(n,r){return n?e.reject(n):void e.resolve(r)}}function p(e){var n=this===d?null:this,r=d.defer(),t=s(arguments,1);return t.push(a(r)),e.apply(n,t),r.promise}var d,y;if(n?(y=!0,d=n):d=e,d.Promise||e==n||(d.Promise=e),f(e)&&f(e.prototype.then))d.defer=function(){var n,r,t=new e(function(e,t){n=e,r=t});return{promise:t,resolve:n,reject:r}};else if(f(e.defer))d.defer=function(){return e.defer()};else{if(!f(e.deferred))throw new TypeError("此类不支持扩展!");d.defer=function(){return e.deferred()}}return t("delay")&&(d.delay=function(e,n){var r=d.defer();return setTimeout(function(){r.resolve(n)},e),r.promise}),t("resolve")&&(d.resolve=function(e){var n=d.defer();return n.resolve(e),n.promise}),t("reject")&&(d.reject=function(e){var n=d.defer();return n.reject(e),n.promise}),t("all")&&(d.all=o()),t("allMap")&&(d.allMap=o(!0)),t("some")&&(d.some=function(e,n){return n=+n>=0?+n:0,o(!1,n)(e)}),t("map")&&(d.map=function(e,n,r){function t(){if(c<s.length){var r=s[c],f=d.resolve(n(e[r],r,e)).then(function(e){return t(),e},o.reject);i.push(f),u--,c++}else d.all(i).then(o.resolve,o.reject)}var o=d.defer(),i=[],u=r?+r.concurrency:0;if(0==u||u!=u){for(var f in e)i.push(n(e[f],f,e));return d.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var n=[];for(var r in e)n.push(r);return n}();do t();while(u>0&&c<s.length);return o.promise}),t("race")&&(d.race=l),t("any")&&(d.any=l),t("nfcall")&&(d.nfcall=p),t("nfapply")&&(d.nfapply=function(e,n){var r=this===d?null:this,t=d.defer();if(!i(n))throw TypeError('"args" is not Array');return n.push(a(t)),e.apply(r,n),t.promise}),d.denodeify=function(e){var n=this===d?null:this;return function(){return p.apply(n,[].concat([e],s(arguments)))}},d}var o=e("./utils"),i=o.isArray,u=o.isEmpty,f=o.isFunction,c=o.isPlainObject,s=o.arg2arr;n.exports=t},{"./utils":5}],4:[function(e,n,r){function t(e){var n=e.prototype;return n.done=function(e,n){this.then(function(n){"function"==typeof e&&setTimeout(function(){e(n)},0)},function(e){"function"==typeof n?setTimeout(function(){n(e)},0):setTimeout(function(){throw e},0)})},n.spread=function(e,n){return this.then(function(n){return e.apply(null,n)},n)},n.fail=n.catch=function(e){return this.then(null,e)},n.catchOf=function(e,n){return n=n||e,this.then(null,function(r){var t=typeof n;if("function"!=t)throw r;if(e===n)return n(r);if(e===r||"function"==typeof e&&r instanceof e)return n(r);throw r})},n.error=function(e){return this.catchOf(Error,e)},n.fin=n.finally=function(e){var n=function(n,r){try{e(n,r)}catch(e){}};return this.then(function(e){return n(e),e},function(e){throw n(null,e),e})},e}n.exports=t},{}],5:[function(e,n,r){"use strict";r.isPlainObject=function(e){return null!==e&&"object"==typeof e&&!e.nodeType&&e!==e.window&&!(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},r.isArray=function(e){return"[object Array]"==Object.prototype.toString.call(e)},r.isFunction=function(e){return"function"==typeof e},r.isEmpty=function(e){return"undefined"==typeof e||null===e},r.arg2arr=function(e,n,r){return Array.prototype.slice.call(e,n,r)}},{}]},{},[1]);
/*!
* extend-promise v0.0.3
* extend-promise v0.0.6
* Homepage https://github.com/cnwhy/extend-promise#readme

@@ -62,8 +62,4 @@ * License BSD-2-Clause

//defer
if(isFunction(Promise.defer)){
QClass.defer = Promise.defer
}else if(isFunction(Promise.deferred)){
QClass.defer = Promise.deferred
}else{
//defer defer为最基础的实现
if(isFunction(Promise) && isFunction(Promise.prototype.then)){
QClass.defer = function() {

@@ -81,2 +77,8 @@ var resolve, reject;

}
}else if(isFunction(Promise.defer)){
QClass.defer = function(){return Promise.defer();}
}else if(isFunction(Promise.deferred)){
QClass.defer = function(){return Promise.deferred();}
}else{
throw new TypeError("此类不支持扩展!")
}

@@ -88,3 +90,6 @@

var defer = QClass.defer();
setTimeout(defer.resolve,ms,value)
setTimeout(function(){
//console.log('==========')
defer.resolve(value);
},ms)
return defer.promise;

@@ -120,5 +125,9 @@ }

var fillData = function(i){
var _p = promises[i]
var _p = promises[i];
QClass.resolve(_p).then(function(d) {
data[i] = d;
if(typeof count != 'undefined'){
data.push(d);
}else{
data[i] = d;
}
if (--_tempI == 0 || (!map && count && data.length>=count)) {

@@ -138,2 +147,3 @@ defer.resolve(data);

data = [];
if(promises.length == 0){defer.resolve(data)};
for(var i = 0; i<promises.length; i++){

@@ -143,8 +153,11 @@ fillData(i);

}else if(map && isPlainObject(promises)){
var _mark = 0;
data = {}
for(var i in promises){
fillData(i);
_mark++;
}
if(_mark == 0) defer.resolve(data)
}else{
defer.reject(new TypeError());
defer.reject(new TypeError("参数错误"));
}

@@ -166,3 +179,4 @@ return defer.promise;

QClass.some = function(proArr,count){
return getall(false,count||0)(proArr)
count = +count >= 0 ? +count : 0;
return getall(false,count)(proArr)
}

@@ -218,13 +232,11 @@ }

for (var i = 0; i < proArr.length; i++) {
+ function() {
(function() {
var _i = i;
//nextTick(function() {
var _p = proArr[_i];
QClass.resolve(_p).then(function(data) {
defer.resolve(data);
}, function(err) {
defer.reject(err);
})
//}, 0)
}()
var _p = proArr[_i];
QClass.resolve(_p).then(function(data) {
defer.resolve(data);
}, function(err) {
defer.reject(err);
})
})()
}

@@ -256,2 +268,3 @@ return defer.promise;

f.apply(_this,argsArray)
return defer.promise;
}

@@ -272,3 +285,3 @@

}else{
throw "args TypeError"
throw TypeError('"args" is not Array')
}

@@ -282,3 +295,3 @@ return defer.promise;

return function(){
return nfcall.call(_this,f,arg2arr(arguments))
return nfcall.apply(_this,[].concat([f],arg2arr(arguments)))
}

@@ -297,3 +310,3 @@ }

if(typeof no == "function") setTimeout(function(){no(err)},0)
else throw err;
else setTimeout(function(){throw err;},0)
})

@@ -303,3 +316,3 @@ }

return this.then(function(value){
return ok.apply(null,value);
return ok.apply(null,value);
},no);

@@ -373,3 +386,3 @@ }

exports.isArray = function(obj){
return Object.prototype.toString.call(obj) == "[objece Array]"
return Object.prototype.toString.call(obj) == "[object Array]"
}

@@ -376,0 +389,0 @@

/*!
* extend-promise v0.0.3
* extend-promise v0.0.6
* Homepage https://github.com/cnwhy/extend-promise#readme
* License BSD-2-Clause
*/
!function e(r,n,t){function o(f,u){if(!n[f]){if(!r[f]){var c="function"==typeof require&&require;if(!u&&c)return c(f,!0);if(i)return i(f,!0);throw new Error("Cannot find module '"+f+"'")}var s=n[f]={exports:{}};r[f][0].call(s.exports,function(e){var n=r[f][1][e];return o(n?n:e)},s,s.exports,e,r,n,t)}return n[f].exports}for(var i="function"==typeof require&&require,f=0;f<t.length;f++)o(t[f]);return o}({1:[function(e,r,n){!function(e,r){if("function"==typeof define&&(define.amd||define.cmd))define([],r);else if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!")}("extendPromise",function(){var r="undefined"!=typeof window?window:self;if("function"!=typeof r.Promise)throw Error('需要Promise,但未找到,请尝试使用"promise-full.js"');var n=e("../src/polyfills")(r.Promise);return n})},{"../src/polyfills":4}],2:[function(e,r,n){"use strict";function t(e,r,n){function t(e){if(i(n)){for(var r=!1,t=0;t<n.length;t++)if(n[t]==e){r=!0;break}if(!r)return!1}return!h||!u(d[e])}function o(e,r){return f(r)||(r=+r>0?+r:0),function(n){var t,o=d.defer(),u=0,s=function(i){var c=n[i];d.resolve(c).then(function(n){t[i]=n,(0==--u||!e&&r&&t.length>=r)&&o.resolve(t)},function(e){f(r)?o.reject(e):0==--u&&o.resolve(t)}),u++};if(i(n)){t=[];for(var l=0;l<n.length;l++)s(l)}else if(e&&c(n)){t={};for(var l in n)s(l)}else o.reject(new TypeError);return o.promise}}function l(e){for(var r=d.defer(),n=0;n<e.length;n++)+function(){var t=n,o=e[t];d.resolve(o).then(function(e){r.resolve(e)},function(e){r.reject(e)})}();return r.promise}function a(e){return function(r,n){return r?e.reject(r):void e.resolve(n)}}function p(e){var r=this===d?null:this,n=d.defer(),t=s(arguments,1);t.push(a(n)),e.apply(r,t)}var d,h;return r?(h=!0,d=r):d=e,d.Promise||e==r||(d.Promise=e),u(e.defer)?d.defer=e.defer:u(e.deferred)?d.defer=e.deferred:d.defer=function(){var r,n,t=new e(function(e,t){r=e,n=t});return{promise:t,resolve:r,reject:n}},t("delay")&&(d.delay=function(e,r){var n=d.defer();return setTimeout(n.resolve,e,r),n.promise}),t("resolve")&&(d.resolve=function(e){var r=d.defer();return r.resolve(e),r.promise}),t("reject")&&(d.reject=function(e){var r=d.defer();return r.reject(e),r.promise}),t("all")&&(d.all=o()),t("allMap")&&(d.allMap=o(!0)),t("some")&&(d.some=function(e,r){return o(!1,r||0)(e)}),t("map")&&(d.map=function(e,r,n){function t(){if(c<s.length){var n=s[c],u=d.resolve(r(e[n],n,e)).then(function(e){return t(),e},o.reject);i.push(u),f--,c++}else d.all(i).then(o.resolve,o.reject)}var o=d.defer(),i=[],f=n?+n.concurrency:0;if(0==f||f!=f){for(var u in e)i.push(r(e[u],u,e));return d.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var r=[];for(var n in e)r.push(n);return r}();do t();while(f>0&&c<s.length);return o.promise}),t("race")&&(d.race=l),t("any")&&(d.any=l),t("nfcall")&&(d.nfcall=p),t("nfapply")&&(d.nfapply=function(e,r){var n=this===d?null:this,t=d.defer();if(!i(r))throw"args TypeError";return r.push(a(t)),e.apply(n,r),t.promise}),d.denodeify=function(e){var r=this===d?null:this;return function(){return p.call(r,e,s(arguments))}},d}var o=e("./utils"),i=o.isArray,f=o.isEmpty,u=o.isFunction,c=o.isPlainObject,s=o.arg2arr;r.exports=t},{"./utils":5}],3:[function(e,r,n){function t(e){var r=e.prototype;return r.done=function(e,r){this.then(function(r){"function"==typeof e&&setTimeout(function(){e(r)},0)},function(e){if("function"!=typeof r)throw e;setTimeout(function(){r(e)},0)})},r.spread=function(e,r){return this.then(function(r){return e.apply(null,r)},r)},r.fail=r.catch=function(e){return this.then(null,e)},r.catchOf=function(e,r){return r=r||e,this.then(null,function(n){var t=typeof r;if("function"!=t)throw n;if(e===r)return r(n);if(e===n||"function"==typeof e&&n instanceof e)return r(n);throw n})},r.error=function(e){return this.catchOf(Error,e)},r.fin=r.finally=function(e){var r=function(r,n){try{e(r,n)}catch(e){}};return this.then(function(e){return r(e),e},function(e){throw r(null,e),e})},e}r.exports=t},{}],4:[function(e,r,n){r.exports=function(r){return e("../src/extendClass")(r),e("../src/extendPrototype")(r),r}},{"../src/extendClass":2,"../src/extendPrototype":3}],5:[function(e,r,n){"use strict";n.isPlainObject=function(e){return null!==e&&"object"==typeof e&&!e.nodeType&&e!==e.window&&!(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},n.isArray=function(e){return"[objece Array]"==Object.prototype.toString.call(e)},n.isFunction=function(e){return"function"==typeof e},n.isEmpty=function(e){return"undefined"==typeof e||null===e},n.arg2arr=function(e,r,n){return Array.prototype.slice.call(e,r,n)}},{}]},{},[1]);
!function e(r,n,t){function o(f,u){if(!n[f]){if(!r[f]){var c="function"==typeof require&&require;if(!u&&c)return c(f,!0);if(i)return i(f,!0);throw new Error("Cannot find module '"+f+"'")}var s=n[f]={exports:{}};r[f][0].call(s.exports,function(e){var n=r[f][1][e];return o(n?n:e)},s,s.exports,e,r,n,t)}return n[f].exports}for(var i="function"==typeof require&&require,f=0;f<t.length;f++)o(t[f]);return o}({1:[function(e,r,n){!function(e,r){if("function"==typeof define&&(define.amd||define.cmd))define([],r);else if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!")}("extendPromise",function(){var r="undefined"!=typeof window?window:self;if("function"!=typeof r.Promise)throw Error('需要Promise,但未找到,请尝试使用"promise-full.js"');var n=e("../src/polyfills")(r.Promise);return n})},{"../src/polyfills":4}],2:[function(e,r,n){"use strict";function t(e,r,n){function t(e){if(i(n)){for(var r=!1,t=0;t<n.length;t++)if(n[t]==e){r=!0;break}if(!r)return!1}return!h||!u(d[e])}function o(e,r){return f(r)||(r=+r>0?+r:0),function(n){var t,o=d.defer(),u=0,s=function(i){var c=n[i];d.resolve(c).then(function(n){"undefined"!=typeof r?t.push(n):t[i]=n,(0==--u||!e&&r&&t.length>=r)&&o.resolve(t)},function(e){f(r)?o.reject(e):0==--u&&o.resolve(t)}),u++};if(i(n)){t=[],0==n.length&&o.resolve(t);for(var l=0;l<n.length;l++)s(l)}else if(e&&c(n)){var a=0;t={};for(var l in n)s(l),a++;0==a&&o.resolve(t)}else o.reject(new TypeError("参数错误"));return o.promise}}function l(e){for(var r=d.defer(),n=0;n<e.length;n++)!function(){var t=n,o=e[t];d.resolve(o).then(function(e){r.resolve(e)},function(e){r.reject(e)})}();return r.promise}function a(e){return function(r,n){return r?e.reject(r):void e.resolve(n)}}function p(e){var r=this===d?null:this,n=d.defer(),t=s(arguments,1);return t.push(a(n)),e.apply(r,t),n.promise}var d,h;if(r?(h=!0,d=r):d=e,d.Promise||e==r||(d.Promise=e),u(e)&&u(e.prototype.then))d.defer=function(){var r,n,t=new e(function(e,t){r=e,n=t});return{promise:t,resolve:r,reject:n}};else if(u(e.defer))d.defer=function(){return e.defer()};else{if(!u(e.deferred))throw new TypeError("此类不支持扩展!");d.defer=function(){return e.deferred()}}return t("delay")&&(d.delay=function(e,r){var n=d.defer();return setTimeout(function(){n.resolve(r)},e),n.promise}),t("resolve")&&(d.resolve=function(e){var r=d.defer();return r.resolve(e),r.promise}),t("reject")&&(d.reject=function(e){var r=d.defer();return r.reject(e),r.promise}),t("all")&&(d.all=o()),t("allMap")&&(d.allMap=o(!0)),t("some")&&(d.some=function(e,r){return r=+r>=0?+r:0,o(!1,r)(e)}),t("map")&&(d.map=function(e,r,n){function t(){if(c<s.length){var n=s[c],u=d.resolve(r(e[n],n,e)).then(function(e){return t(),e},o.reject);i.push(u),f--,c++}else d.all(i).then(o.resolve,o.reject)}var o=d.defer(),i=[],f=n?+n.concurrency:0;if(0==f||f!=f){for(var u in e)i.push(r(e[u],u,e));return d.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var r=[];for(var n in e)r.push(n);return r}();do t();while(f>0&&c<s.length);return o.promise}),t("race")&&(d.race=l),t("any")&&(d.any=l),t("nfcall")&&(d.nfcall=p),t("nfapply")&&(d.nfapply=function(e,r){var n=this===d?null:this,t=d.defer();if(!i(r))throw TypeError('"args" is not Array');return r.push(a(t)),e.apply(n,r),t.promise}),d.denodeify=function(e){var r=this===d?null:this;return function(){return p.apply(r,[].concat([e],s(arguments)))}},d}var o=e("./utils"),i=o.isArray,f=o.isEmpty,u=o.isFunction,c=o.isPlainObject,s=o.arg2arr;r.exports=t},{"./utils":5}],3:[function(e,r,n){function t(e){var r=e.prototype;return r.done=function(e,r){this.then(function(r){"function"==typeof e&&setTimeout(function(){e(r)},0)},function(e){"function"==typeof r?setTimeout(function(){r(e)},0):setTimeout(function(){throw e},0)})},r.spread=function(e,r){return this.then(function(r){return e.apply(null,r)},r)},r.fail=r.catch=function(e){return this.then(null,e)},r.catchOf=function(e,r){return r=r||e,this.then(null,function(n){var t=typeof r;if("function"!=t)throw n;if(e===r)return r(n);if(e===n||"function"==typeof e&&n instanceof e)return r(n);throw n})},r.error=function(e){return this.catchOf(Error,e)},r.fin=r.finally=function(e){var r=function(r,n){try{e(r,n)}catch(e){}};return this.then(function(e){return r(e),e},function(e){throw r(null,e),e})},e}r.exports=t},{}],4:[function(e,r,n){r.exports=function(r){return e("../src/extendClass")(r),e("../src/extendPrototype")(r),r}},{"../src/extendClass":2,"../src/extendPrototype":3}],5:[function(e,r,n){"use strict";n.isPlainObject=function(e){return null!==e&&"object"==typeof e&&!e.nodeType&&e!==e.window&&!(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},n.isArray=function(e){return"[object Array]"==Object.prototype.toString.call(e)},n.isFunction=function(e){return"function"==typeof e},n.isEmpty=function(e){return"undefined"==typeof e||null===e},n.arg2arr=function(e,r,n){return Array.prototype.slice.call(e,r,n)}},{}]},{},[1]);
/*!
* extend-promise v0.0.3
* extend-promise v0.0.6
* Homepage https://github.com/cnwhy/extend-promise#readme

@@ -253,8 +253,4 @@ * License BSD-2-Clause

//defer
if(isFunction(Promise.defer)){
QClass.defer = Promise.defer
}else if(isFunction(Promise.deferred)){
QClass.defer = Promise.deferred
}else{
//defer defer为最基础的实现
if(isFunction(Promise) && isFunction(Promise.prototype.then)){
QClass.defer = function() {

@@ -272,2 +268,8 @@ var resolve, reject;

}
}else if(isFunction(Promise.defer)){
QClass.defer = function(){return Promise.defer();}
}else if(isFunction(Promise.deferred)){
QClass.defer = function(){return Promise.deferred();}
}else{
throw new TypeError("此类不支持扩展!")
}

@@ -279,3 +281,6 @@

var defer = QClass.defer();
setTimeout(defer.resolve,ms,value)
setTimeout(function(){
//console.log('==========')
defer.resolve(value);
},ms)
return defer.promise;

@@ -311,5 +316,9 @@ }

var fillData = function(i){
var _p = promises[i]
var _p = promises[i];
QClass.resolve(_p).then(function(d) {
data[i] = d;
if(typeof count != 'undefined'){
data.push(d);
}else{
data[i] = d;
}
if (--_tempI == 0 || (!map && count && data.length>=count)) {

@@ -329,2 +338,3 @@ defer.resolve(data);

data = [];
if(promises.length == 0){defer.resolve(data)};
for(var i = 0; i<promises.length; i++){

@@ -334,8 +344,11 @@ fillData(i);

}else if(map && isPlainObject(promises)){
var _mark = 0;
data = {}
for(var i in promises){
fillData(i);
_mark++;
}
if(_mark == 0) defer.resolve(data)
}else{
defer.reject(new TypeError());
defer.reject(new TypeError("参数错误"));
}

@@ -357,3 +370,4 @@ return defer.promise;

QClass.some = function(proArr,count){
return getall(false,count||0)(proArr)
count = +count >= 0 ? +count : 0;
return getall(false,count)(proArr)
}

@@ -409,13 +423,11 @@ }

for (var i = 0; i < proArr.length; i++) {
+ function() {
(function() {
var _i = i;
//nextTick(function() {
var _p = proArr[_i];
QClass.resolve(_p).then(function(data) {
defer.resolve(data);
}, function(err) {
defer.reject(err);
})
//}, 0)
}()
var _p = proArr[_i];
QClass.resolve(_p).then(function(data) {
defer.resolve(data);
}, function(err) {
defer.reject(err);
})
})()
}

@@ -447,2 +459,3 @@ return defer.promise;

f.apply(_this,argsArray)
return defer.promise;
}

@@ -463,3 +476,3 @@

}else{
throw "args TypeError"
throw TypeError('"args" is not Array')
}

@@ -473,3 +486,3 @@ return defer.promise;

return function(){
return nfcall.call(_this,f,arg2arr(arguments))
return nfcall.apply(_this,[].concat([f],arg2arr(arguments)))
}

@@ -488,3 +501,3 @@ }

if(typeof no == "function") setTimeout(function(){no(err)},0)
else throw err;
else setTimeout(function(){throw err;},0)
})

@@ -494,3 +507,3 @@ }

return this.then(function(value){
return ok.apply(null,value);
return ok.apply(null,value);
},no);

@@ -564,3 +577,3 @@ }

exports.isArray = function(obj){
return Object.prototype.toString.call(obj) == "[objece Array]"
return Object.prototype.toString.call(obj) == "[object Array]"
}

@@ -567,0 +580,0 @@

/*!
* extend-promise v0.0.3
* extend-promise v0.0.6
* Homepage https://github.com/cnwhy/extend-promise#readme
* License BSD-2-Clause
*/
!function e(t,n,r){function o(u,f){if(!n[u]){if(!t[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=n[u]={exports:{}};t[u][0].call(s.exports,function(e){var n=t[u][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t,n){!function(e,t){if("function"==typeof define&&(define.amd||define.cmd))define([],t);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!");var n="undefined"!=typeof window?window:self;n[e]=t()}}("Promise",function(){var t=e("../promise/setTimeout");return t})},{"../promise/setTimeout":4}],2:[function(e,t,n){t.exports=e("./src")(function(e){setTimeout(e,0)})},{"./src":3}],3:[function(e,t,n){"use strict";t.exports=function(e){function t(e,r){if(n(r))r.then(e.resolve,e.reject);else if(!r||"function"!=typeof r&&"object"!=typeof r)e.resolve(r);else{var o,i=!1;try{o=r.then,"function"==typeof o?o.call(r,function(n){i||(i=!0,t(e,n))},function(t){i||(i=!0,e.reject(t))}):e.resolve(r)}catch(t){i||(i=!0,e.reject(t))}}}function n(e){return e instanceof r}function r(e){function n(e){o.call(c,1,e)}function r(e){o.call(c,0,e)}function i(e){if(!s)return s=!0,c===e?r(new TypeError("The promise and its value refer to the same object")):void t({resolve:n,reject:r},e)}function u(e){s||(s=!0,r(e))}var c=this;this.status=-1,this._events=[];var s=!1;if(this.resolve=i,this.reject=u,e!==f&&"function"==typeof e)try{e(this.resolve,this.reject)}catch(e){this.reject(e)}}function o(e,t){var n=this;~this.status||(this.status=e,e?this.value=t:this.reason=t,i.call(n))}function i(){if(~this.status){for(var e=this,t=e._events,n=e.status?e.value:e.reason,r=e.status?0:1,o=0;o<t.length;o++)!function(t){var o=t[r],i=t[2];u(o,n,i,e.status)}(t[o]);t=[]}}function u(t,n,r,o){var i=r.resolve,u=r.reject;"function"==typeof t?e(function(){var e;try{e=t(n)}catch(e){return void u(e)}i(e)}):o?i(n):u(n)}var f=function(){};return r.defer=function(){var e=new r(f);return{promise:e,resolve:e.resolve,reject:e.reject}},r.resolve=function(e){return n(e)?e:new r(function(t,n){t(e)})},r.reject=function(e){return new r(function(t,n){n(e)})},Promise.prototype.toString=function(){return"[object Promise]"},r.prototype.then=function(e,t){var n=this.status,o=r.defer(),i=o.promise;return~n?n&&"function"==typeof e?u(e,this.value,i,n):n||"function"!=typeof t?n?o.resolve(this.value):o.reject(this.reason):u(t,this.reason,i,n):this._events.push([e,t,i]),i},r}},{}],4:[function(e,t,n){var r=e("easy-promise/setTimeout");t.exports=e("../src/polyfills")(r)},{"../src/polyfills":7,"easy-promise/setTimeout":2}],5:[function(e,t,n){"use strict";function r(e,t,n){function r(e){if(i(n)){for(var t=!1,r=0;r<n.length;r++)if(n[r]==e){t=!0;break}if(!t)return!1}return!h||!f(v[e])}function o(e,t){return u(t)||(t=+t>0?+t:0),function(n){var r,o=v.defer(),f=0,s=function(i){var c=n[i];v.resolve(c).then(function(n){r[i]=n,(0==--f||!e&&t&&r.length>=t)&&o.resolve(r)},function(e){u(t)?o.reject(e):0==--f&&o.resolve(r)}),f++};if(i(n)){r=[];for(var a=0;a<n.length;a++)s(a)}else if(e&&c(n)){r={};for(var a in n)s(a)}else o.reject(new TypeError);return o.promise}}function a(e){for(var t=v.defer(),n=0;n<e.length;n++)+function(){var r=n,o=e[r];v.resolve(o).then(function(e){t.resolve(e)},function(e){t.reject(e)})}();return t.promise}function l(e){return function(t,n){return t?e.reject(t):void e.resolve(n)}}function p(e){var t=this===v?null:this,n=v.defer(),r=s(arguments,1);r.push(l(n)),e.apply(t,r)}var v,h;return t?(h=!0,v=t):v=e,v.Promise||e==t||(v.Promise=e),f(e.defer)?v.defer=e.defer:f(e.deferred)?v.defer=e.deferred:v.defer=function(){var t,n,r=new e(function(e,r){t=e,n=r});return{promise:r,resolve:t,reject:n}},r("delay")&&(v.delay=function(e,t){var n=v.defer();return setTimeout(n.resolve,e,t),n.promise}),r("resolve")&&(v.resolve=function(e){var t=v.defer();return t.resolve(e),t.promise}),r("reject")&&(v.reject=function(e){var t=v.defer();return t.reject(e),t.promise}),r("all")&&(v.all=o()),r("allMap")&&(v.allMap=o(!0)),r("some")&&(v.some=function(e,t){return o(!1,t||0)(e)}),r("map")&&(v.map=function(e,t,n){function r(){if(c<s.length){var n=s[c],f=v.resolve(t(e[n],n,e)).then(function(e){return r(),e},o.reject);i.push(f),u--,c++}else v.all(i).then(o.resolve,o.reject)}var o=v.defer(),i=[],u=n?+n.concurrency:0;if(0==u||u!=u){for(var f in e)i.push(t(e[f],f,e));return v.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var t=[];for(var n in e)t.push(n);return t}();do r();while(u>0&&c<s.length);return o.promise}),r("race")&&(v.race=a),r("any")&&(v.any=a),r("nfcall")&&(v.nfcall=p),r("nfapply")&&(v.nfapply=function(e,t){var n=this===v?null:this,r=v.defer();if(!i(t))throw"args TypeError";return t.push(l(r)),e.apply(n,t),r.promise}),v.denodeify=function(e){var t=this===v?null:this;return function(){return p.call(t,e,s(arguments))}},v}var o=e("./utils"),i=o.isArray,u=o.isEmpty,f=o.isFunction,c=o.isPlainObject,s=o.arg2arr;t.exports=r},{"./utils":8}],6:[function(e,t,n){function r(e){var t=e.prototype;return t.done=function(e,t){this.then(function(t){"function"==typeof e&&setTimeout(function(){e(t)},0)},function(e){if("function"!=typeof t)throw e;setTimeout(function(){t(e)},0)})},t.spread=function(e,t){return this.then(function(t){return e.apply(null,t)},t)},t.fail=t.catch=function(e){return this.then(null,e)},t.catchOf=function(e,t){return t=t||e,this.then(null,function(n){var r=typeof t;if("function"!=r)throw n;if(e===t)return t(n);if(e===n||"function"==typeof e&&n instanceof e)return t(n);throw n})},t.error=function(e){return this.catchOf(Error,e)},t.fin=t.finally=function(e){var t=function(t,n){try{e(t,n)}catch(e){}};return this.then(function(e){return t(e),e},function(e){throw t(null,e),e})},e}t.exports=r},{}],7:[function(e,t,n){t.exports=function(t){return e("../src/extendClass")(t),e("../src/extendPrototype")(t),t}},{"../src/extendClass":5,"../src/extendPrototype":6}],8:[function(e,t,n){"use strict";n.isPlainObject=function(e){return null!==e&&"object"==typeof e&&!e.nodeType&&e!==e.window&&!(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},n.isArray=function(e){return"[objece Array]"==Object.prototype.toString.call(e)},n.isFunction=function(e){return"function"==typeof e},n.isEmpty=function(e){return"undefined"==typeof e||null===e},n.arg2arr=function(e,t,n){return Array.prototype.slice.call(e,t,n)}},{}]},{},[1]);
!function e(t,n,r){function o(u,f){if(!n[u]){if(!t[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=n[u]={exports:{}};t[u][0].call(s.exports,function(e){var n=t[u][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t,n){!function(e,t){if("function"==typeof define&&(define.amd||define.cmd))define([],t);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!");var n="undefined"!=typeof window?window:self;n[e]=t()}}("Promise",function(){var t=e("../promise/setTimeout");return t})},{"../promise/setTimeout":4}],2:[function(e,t,n){t.exports=e("./src")(function(e){setTimeout(e,0)})},{"./src":3}],3:[function(e,t,n){"use strict";t.exports=function(e){function t(e,r){if(n(r))r.then(e.resolve,e.reject);else if(!r||"function"!=typeof r&&"object"!=typeof r)e.resolve(r);else{var o,i=!1;try{o=r.then,"function"==typeof o?o.call(r,function(n){i||(i=!0,t(e,n))},function(t){i||(i=!0,e.reject(t))}):e.resolve(r)}catch(t){i||(i=!0,e.reject(t))}}}function n(e){return e instanceof r}function r(e){function n(e){o.call(c,1,e)}function r(e){o.call(c,0,e)}function i(e){if(!s)return s=!0,c===e?r(new TypeError("The promise and its value refer to the same object")):void t({resolve:n,reject:r},e)}function u(e){s||(s=!0,r(e))}var c=this;this.status=-1,this._events=[];var s=!1;if(this.resolve=i,this.reject=u,e!==f&&"function"==typeof e)try{e(this.resolve,this.reject)}catch(e){this.reject(e)}}function o(e,t){var n=this;~this.status||(this.status=e,e?this.value=t:this.reason=t,i.call(n))}function i(){if(~this.status){for(var e=this,t=e._events,n=e.status?e.value:e.reason,r=e.status?0:1,o=0;o<t.length;o++)!function(t){var o=t[r],i=t[2];u(o,n,i,e.status)}(t[o]);t=[]}}function u(t,n,r,o){var i=r.resolve,u=r.reject;"function"==typeof t?e(function(){var e;try{e=t(n)}catch(e){return void u(e)}i(e)}):o?i(n):u(n)}var f=function(){};return r.defer=function(){var e=new r(f);return{promise:e,resolve:e.resolve,reject:e.reject}},r.resolve=function(e){return n(e)?e:new r(function(t,n){t(e)})},r.reject=function(e){return new r(function(t,n){n(e)})},Promise.prototype.toString=function(){return"[object Promise]"},r.prototype.then=function(e,t){var n=this.status,o=r.defer(),i=o.promise;return~n?n&&"function"==typeof e?u(e,this.value,i,n):n||"function"!=typeof t?n?o.resolve(this.value):o.reject(this.reason):u(t,this.reason,i,n):this._events.push([e,t,i]),i},r}},{}],4:[function(e,t,n){var r=e("easy-promise/setTimeout");t.exports=e("../src/polyfills")(r)},{"../src/polyfills":7,"easy-promise/setTimeout":2}],5:[function(e,t,n){"use strict";function r(e,t,n){function r(e){if(i(n)){for(var t=!1,r=0;r<n.length;r++)if(n[r]==e){t=!0;break}if(!t)return!1}return!v||!f(h[e])}function o(e,t){return u(t)||(t=+t>0?+t:0),function(n){var r,o=h.defer(),f=0,s=function(i){var c=n[i];h.resolve(c).then(function(n){"undefined"!=typeof t?r.push(n):r[i]=n,(0==--f||!e&&t&&r.length>=t)&&o.resolve(r)},function(e){u(t)?o.reject(e):0==--f&&o.resolve(r)}),f++};if(i(n)){r=[],0==n.length&&o.resolve(r);for(var a=0;a<n.length;a++)s(a)}else if(e&&c(n)){var l=0;r={};for(var a in n)s(a),l++;0==l&&o.resolve(r)}else o.reject(new TypeError("参数错误"));return o.promise}}function a(e){for(var t=h.defer(),n=0;n<e.length;n++)!function(){var r=n,o=e[r];h.resolve(o).then(function(e){t.resolve(e)},function(e){t.reject(e)})}();return t.promise}function l(e){return function(t,n){return t?e.reject(t):void e.resolve(n)}}function p(e){var t=this===h?null:this,n=h.defer(),r=s(arguments,1);return r.push(l(n)),e.apply(t,r),n.promise}var h,v;if(t?(v=!0,h=t):h=e,h.Promise||e==t||(h.Promise=e),f(e)&&f(e.prototype.then))h.defer=function(){var t,n,r=new e(function(e,r){t=e,n=r});return{promise:r,resolve:t,reject:n}};else if(f(e.defer))h.defer=function(){return e.defer()};else{if(!f(e.deferred))throw new TypeError("此类不支持扩展!");h.defer=function(){return e.deferred()}}return r("delay")&&(h.delay=function(e,t){var n=h.defer();return setTimeout(function(){n.resolve(t)},e),n.promise}),r("resolve")&&(h.resolve=function(e){var t=h.defer();return t.resolve(e),t.promise}),r("reject")&&(h.reject=function(e){var t=h.defer();return t.reject(e),t.promise}),r("all")&&(h.all=o()),r("allMap")&&(h.allMap=o(!0)),r("some")&&(h.some=function(e,t){return t=+t>=0?+t:0,o(!1,t)(e)}),r("map")&&(h.map=function(e,t,n){function r(){if(c<s.length){var n=s[c],f=h.resolve(t(e[n],n,e)).then(function(e){return r(),e},o.reject);i.push(f),u--,c++}else h.all(i).then(o.resolve,o.reject)}var o=h.defer(),i=[],u=n?+n.concurrency:0;if(0==u||u!=u){for(var f in e)i.push(t(e[f],f,e));return h.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var t=[];for(var n in e)t.push(n);return t}();do r();while(u>0&&c<s.length);return o.promise}),r("race")&&(h.race=a),r("any")&&(h.any=a),r("nfcall")&&(h.nfcall=p),r("nfapply")&&(h.nfapply=function(e,t){var n=this===h?null:this,r=h.defer();if(!i(t))throw TypeError('"args" is not Array');return t.push(l(r)),e.apply(n,t),r.promise}),h.denodeify=function(e){var t=this===h?null:this;return function(){return p.apply(t,[].concat([e],s(arguments)))}},h}var o=e("./utils"),i=o.isArray,u=o.isEmpty,f=o.isFunction,c=o.isPlainObject,s=o.arg2arr;t.exports=r},{"./utils":8}],6:[function(e,t,n){function r(e){var t=e.prototype;return t.done=function(e,t){this.then(function(t){"function"==typeof e&&setTimeout(function(){e(t)},0)},function(e){"function"==typeof t?setTimeout(function(){t(e)},0):setTimeout(function(){throw e},0)})},t.spread=function(e,t){return this.then(function(t){return e.apply(null,t)},t)},t.fail=t.catch=function(e){return this.then(null,e)},t.catchOf=function(e,t){return t=t||e,this.then(null,function(n){var r=typeof t;if("function"!=r)throw n;if(e===t)return t(n);if(e===n||"function"==typeof e&&n instanceof e)return t(n);throw n})},t.error=function(e){return this.catchOf(Error,e)},t.fin=t.finally=function(e){var t=function(t,n){try{e(t,n)}catch(e){}};return this.then(function(e){return t(e),e},function(e){throw t(null,e),e})},e}t.exports=r},{}],7:[function(e,t,n){t.exports=function(t){return e("../src/extendClass")(t),e("../src/extendPrototype")(t),t}},{"../src/extendClass":5,"../src/extendPrototype":6}],8:[function(e,t,n){"use strict";n.isPlainObject=function(e){return null!==e&&"object"==typeof e&&!e.nodeType&&e!==e.window&&!(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},n.isArray=function(e){return"[object Array]"==Object.prototype.toString.call(e)},n.isFunction=function(e){return"function"==typeof e},n.isEmpty=function(e){return"undefined"==typeof e||null===e},n.arg2arr=function(e,t,n){return Array.prototype.slice.call(e,t,n)}},{}]},{},[1]);

@@ -8,2 +8,4 @@ var path = require("path");

var header = require("gulp-header");
var mocha = require("gulp-mocha");
var istanbul = require("gulp-istanbul");

@@ -31,6 +33,19 @@ var package = require("./package.json");

gulp.task('pre-test', function () {
return gulp.src(['src/**/*.js'])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
//gulp.task('test',['pre-test'],function(){
gulp.task('test',function(){
return gulp.src('test/mocha_*.js', {read: false})
.pipe(mocha({reporter: 'dot'}))
// .pipe(istanbul.writeReports())
// .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
});
gulp.task('default', ['build']);
{
"name": "extend-promise",
"version": "0.0.5",
"version": "0.0.6",
"description": "基于promise扩展一些常用方法",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "gulp test"
},

@@ -26,5 +26,7 @@ "repository": {

"devDependencies": {
"easy-promise": "0.0.3",
"gulp": "^3.9.1",
"gulp-browserify": "^0.5.1",
"gulp-header": "^1.8.8",
"gulp-istanbul": "^1.1.1",
"gulp-mocha": "^3.0.1",

@@ -34,7 +36,5 @@ "gulp-rename": "^1.2.2",

"istanbul": "^0.4.5",
"mocha": "^3.2.0",
"easy-promise": "0.0.3"
"mocha": "^3.2.0"
},
"dependencies": {
}
"dependencies": {}
}

@@ -37,3 +37,3 @@ 'use strict';

//defer
//defer defer为最基础的实现
if(isFunction(Promise) && isFunction(Promise.prototype.then)){

@@ -65,2 +65,3 @@ QClass.defer = function() {

setTimeout(function(){
//console.log('==========')
defer.resolve(value);

@@ -98,5 +99,9 @@ },ms)

var fillData = function(i){
var _p = promises[i]
var _p = promises[i];
QClass.resolve(_p).then(function(d) {
data[i] = d;
if(typeof count != 'undefined'){
data.push(d);
}else{
data[i] = d;
}
if (--_tempI == 0 || (!map && count && data.length>=count)) {

@@ -116,2 +121,3 @@ defer.resolve(data);

data = [];
if(promises.length == 0){defer.resolve(data)};
for(var i = 0; i<promises.length; i++){

@@ -121,6 +127,9 @@ fillData(i);

}else if(map && isPlainObject(promises)){
var _mark = 0;
data = {}
for(var i in promises){
fillData(i);
_mark++;
}
if(_mark == 0) defer.resolve(data)
}else{

@@ -144,3 +153,4 @@ defer.reject(new TypeError("参数错误"));

QClass.some = function(proArr,count){
return getall(false,count||0)(proArr)
count = +count >= 0 ? +count : 0;
return getall(false,count)(proArr)
}

@@ -196,13 +206,11 @@ }

for (var i = 0; i < proArr.length; i++) {
+ function() {
(function() {
var _i = i;
//nextTick(function() {
var _p = proArr[_i];
QClass.resolve(_p).then(function(data) {
defer.resolve(data);
}, function(err) {
defer.reject(err);
})
//}, 0)
}()
var _p = proArr[_i];
QClass.resolve(_p).then(function(data) {
defer.resolve(data);
}, function(err) {
defer.reject(err);
})
})()
}

@@ -234,2 +242,3 @@ return defer.promise;

f.apply(_this,argsArray)
return defer.promise;
}

@@ -259,3 +268,3 @@

return function(){
return nfcall.call(_this,f,arg2arr(arguments))
return nfcall.apply(_this,[].concat([f],arg2arr(arguments)))
}

@@ -262,0 +271,0 @@ }

@@ -8,3 +8,3 @@ function extendPrototype(Promise){

if(typeof no == "function") setTimeout(function(){no(err)},0)
else throw err;
else setTimeout(function(){throw err;},0)
})

@@ -14,3 +14,3 @@ }

return this.then(function(value){
return ok.apply(null,value);
return ok.apply(null,value);
},no);

@@ -17,0 +17,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc