promise-toolbox
Advanced tools
Comparing version 0.10.1 to 0.11.0
{ | ||
"name": "promise-toolbox", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"license": "ISC", | ||
@@ -40,11 +40,11 @@ "description": "Essential utils for promises", | ||
"devDependencies": { | ||
"@babel/cli": "7.0.0", | ||
"@babel/core": "7.0.0", | ||
"@babel/plugin-proposal-function-bind": "7.0.0", | ||
"@babel/preset-env": "7.0.0", | ||
"@babel/cli": "^7.0.0", | ||
"@babel/core": "^7.0.0", | ||
"@babel/plugin-proposal-function-bind": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-eslint": "^9.0.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-jest": "^23.2.0", | ||
"babel-minify": "^0.4.0", | ||
"babelify": "^8.0.0", | ||
"babel-minify": "^0.5.0", | ||
"babelify": "^10.0.0", | ||
"browserify": "^16.0.0", | ||
@@ -55,6 +55,6 @@ "cross-env": "^5.1.3", | ||
"eslint-plugin-import": "^2.8.0", | ||
"eslint-plugin-node": "^7.0.1", | ||
"eslint-plugin-node": "^8.0.0", | ||
"eslint-plugin-promise": "^4.0.0", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"husky": "^0.14.3", | ||
"husky": "^1.1.1", | ||
"jest": "^23.2.0", | ||
@@ -66,3 +66,2 @@ "rimraf": "^2.6.2" | ||
"clean": "rimraf '*.js' '*.js.map'", | ||
"commitmsg": "npm test", | ||
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=./ src/", | ||
@@ -84,3 +83,8 @@ "dev-test": "jest --bail --watch", | ||
"testRegex": "\\.spec\\.js$" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "npm test" | ||
} | ||
} | ||
} |
@@ -746,6 +746,6 @@ # promise-toolbox [![Build Status](https://travis-ci.org/JsCommunity/promise-toolbox.png?branch=master)](https://travis-ci.org/JsCommunity/promise-toolbox) | ||
> If the callback is omitted, the returned promise is rejected with a | ||
> `Timeout` error. | ||
> `TimeoutError`. | ||
```js | ||
import { timeout } from 'promise-toolbox' | ||
import { timeout, TimeoutError } from 'promise-toolbox' | ||
@@ -764,2 +764,5 @@ await doLongOperation()::timeout(100, () => { | ||
> Note: `0` is a special value which disable the timeout, useful if the delay is | ||
> configurable in your app. | ||
## Development | ||
@@ -766,0 +769,0 @@ |
@@ -8,2 +8,10 @@ "use strict"; | ||
if (onReject === void 0) { | ||
onReject = new TimeoutError(); | ||
} | ||
if (ms === 0) { | ||
return this; | ||
} | ||
return new Promise(function (resolve, reject) { | ||
@@ -24,3 +32,3 @@ var handle = setTimeout(function () { | ||
} else { | ||
reject(onReject !== undefined ? onReject : new TimeoutError()); | ||
reject(onReject); | ||
} | ||
@@ -27,0 +35,0 @@ }, ms); |
@@ -5,3 +5,3 @@ "use strict"; | ||
module.exports = function (fn) { | ||
module.exports = function pTry(fn) { | ||
try { | ||
@@ -8,0 +8,0 @@ return resolve(fn()); |
@@ -1,1 +0,1 @@ | ||
(function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.promiseToolbox=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c<g.length;c++)a(g[c]);return a}return b}()({1:[function(a,b){"use strict";b.exports=function(){function a(a){void 0===a&&(a="this action has been canceled"),Object.defineProperty(this,"message",{enumerable:!0,value:a})}var b=a.prototype;return b.toString=function(){return"Cancel: "+this.message},a}()},{}],2:[function(a,b){"use strict";function c(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function d(a,b,d){return b&&c(a.prototype,b),d&&c(a,d),a}function e(a){if(void 0===this._reason){var b=this._reason=a instanceof j?a:new j(a),c=this._resolve;void 0!==c&&(this._resolve=void 0,c(b));var d=this._handlers;if(void 0!==d){this._handlers=void 0;for(var e=h(),f=e.promise,g=e.resolve,l=0,m=function(){if(0==--l)return g()},o=0,p=d.length;o<p;++o)try{var n=d[o](b);k(n)&&(++l,n.then(m,m))}catch(a){}if(0!==l)return f}}}function f(a){var b=this._handlers;if(b!==void 0){var c=b.indexOf(a);-1!==c&&b.splice(c,1)}}function g(a){var b=this.cancel=e.bind(this.token=new o(n));null==a||a.forEach(function(a){var c=a.reason;return void 0===c?void a.addHandler(b):(b(c),!1)})}var h=a("./defer"),j=a("./Cancel"),k=a("./isPromise"),i=a("./_symbols"),l=i.$$toStringTag,m="CancelToken",n={},o=function(){function a(a){this._handlers=void 0,this._promise=void 0,this._reason=void 0,this._resolve=void 0,a!==n&&a(e.bind(this))}a.isCancelToken=function(a){return null!=a&&a[l]===m},a.source=function(a){return new g(a)};var b=a.prototype;return b.addHandler=function(a){var b=this._handlers;if(void 0===b){if(this.requested)throw new TypeError("cannot add a handler to an already canceled token");b=this._handlers=[]}return b.push(a),f.bind(this,a)},b.throwIfRequested=function(){var a=this._reason;if(void 0!==a)throw a},d(a,[{key:"promise",get:function(){var a=this,b=this._promise;if(void 0===b){var c=this._reason;b=this._promise=void 0===c?new Promise(function(b){a._resolve=b}):Promise.resolve(c)}return b}},{key:"reason",get:function(){return this._reason}},{key:"requested",get:function(){return void 0!==this._reason}},{key:l,get:function(){return m}}]),a}();e.call(o.canceled=new o(n)),o.none=new o(n),b.exports=o},{"./Cancel":1,"./_symbols":12,"./defer":19,"./isPromise":33}],3:[function(a,b){"use strict";function c(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}var d=a("make-error"),e=d.BaseError;b.exports=function(a){function b(){return a.call(this,"operation timed out")||this}return c(b,a),b}(e)},{"make-error":36}],4:[function(a,b){"use strict";b.exports=function(a,b){this.d=b,this.p=a}},{}],5:[function(a,b){"use strict";b.exports=function(a){return a}},{}],6:[function(a,b){"use strict";b.exports=function(a){return a instanceof ReferenceError||a instanceof SyntaxError||a instanceof TypeError}},{}],7:[function(a,b){"use strict";var c=a("./_noop"),d=a("./_once");b.exports=function(a,b,e){var f=b.addEventListener||b.addListener||b.on;if(void 0===f)throw new Error("cannot register event listener");var g=b.removeEventListener||b.removeListener||b.off,h=[],j=c;return void 0!==g&&(j=d(function(){for(var a=0,c=h.length;a<c;a+=2)g.call(b,h[a],h[a+1])}),a.promise.then(j)),e?function(a,c){function d(){j();for(var b=arguments.length,d=Array(b),e=0;e<b;++e)d[e]=arguments[e];d.event=a,c(d)}h.push(a,d),f.call(b,a,d)}:function(a,c){var d=function(a){j(),c(a)};h.push(a,d),f.call(b,a,d)}}},{"./_noop":8,"./_once":9}],8:[function(a,b){"use strict";b.exports=Function.prototype},{}],9:[function(a,b){"use strict";b.exports=function(a){var b;return function(){return void 0!==a&&(b=a.apply(this,arguments),a=void 0),b}}},{}],10:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){return c(a)?a:Promise.resolve(a)}},{"./isPromise":33}],11:[function(a,b){"use strict";b.exports=function(){var b=Object.defineProperties;try{var c=b(function(){},{length:{value:2},name:{value:"foo"}});if(2===c.length&&"foo"===c.name)return function(a,c,d){return b(a,{length:{configurable:!0,value:d},name:{configurable:!0,value:c}})}}catch(a){}return a("./_identity")}()},{"./_identity":5}],12:[function(a,b,c){"use strict";var d="function"==typeof Symbol?function(a){var b=Symbol[a];return b===void 0?"@@"+a:b}:function(a){return"@@"+a};c.$$iterator=d("iterator"),c.$$toStringTag=d("toStringTag")},{}],13:[function(a,b,c){"use strict";if("function"!=typeof Promise||"function"!=typeof Promise.reject||"function"!=typeof Promise.resolve)throw new Error("a standard Promise implementation is required (https://github.com/JsCommunity/promise-toolbox#usage)");var d=a("./isPromise"),e=a("./_symbols"),f=e.$$iterator;c.applyThen=function(a,b,c,e){var f;try{if(f=a.apply(void 0,b),d(f))return void f.then(c,e)}catch(a){return void e(a)}c(f)},c.endsWith=function(a,b,c){return void 0===c&&(c=a.length),c-=b.length,0<=c&&a.indexOf(b,c)===c};var g=c.forArray=function(a,b){for(var c=a.length,d=0;d<c;++d)b(a[d],d,a)};c.forIn=function(a,b){for(var c in a)b(a[c],c,a)};var h=c.forIterable=function(a,b){for(var c,d=a[f]();!(c=d.next()).done;)b(c.value,void 0,a)},i=Object.prototype.hasOwnProperty,j=c.forOwn=function(a,b){for(var c in a)i.call(a,c)&&b(a[c],c,a)},k=function(a){return null!=a&&"function"==typeof a[f]},l=c.forEach=function(a,b){return n(a)?g(a,b):k(a)?h(a,b):p(a)?g(a,b):j(a,b)},m=Array.isArray,n=void 0===m?function(a){return a instanceof Array}:m;c.isArray=n;var o=function(a){return"number"==typeof a&&0<=a&&a<1/0&&Math.floor(a)===a},p=c.isArrayLike=function(a){return"function"!=typeof a&&null!=a&&o(a.length)};c.makeAsyncIterator=function(a){return function b(c,e){if(d(c))return c.then(function(a){return b(a,e)});var f=Promise.resolve();return a(c,function(a,b){f=d(a)?f.then(function(){return a.then(function(a){return e(a,b,c)})}):f.then(function(){return e(a,b,c)})}),f}},c.map=function(a,b){var c=[];return l(a,function(a,d,e){c.push(b(a,d,e))}),c},c.mapAuto=function(a,b){var c=p(a)?Array(a.length):Object.create(null);return void 0!==b&&l(a,function(a,d,e){c[d]=b(a,d,e)}),c}},{"./_symbols":12,"./isPromise":33}],14:[function(a,b){"use strict";var c=a("./isPromise"),d=a("./_utils"),e=d.forEach,f=d.mapAuto,g=function(a,b){return new Promise(function(d,g){var h=f(a,b),i=1,j=function(){if(0==--i){var a=h;h=void 0,d(a)}},k=function(a,b){h&&(h[b]=a,j())},l=function(a){h&&(h=void 0,g(a))};e(b===void 0?a:h,function(a,b){++i,c(a)?a.then(function(a){return k(a,b)},l):k(a,b)}),j()})};b.exports=function(a){return c(this)?this.then(function(b){return g(b,a)}):g(this,a)}},{"./_utils":13,"./isPromise":33}],15:[function(a,b){"use strict";b.exports=function(a){return"function"==typeof a&&this.then(function(b){return a(void 0,b)},a),this}},{}],16:[function(a,b){"use strict";function c(a,b){var c;try{c=this.iterator[a](b)}catch(a){return this.reject(a)}b=c.value,c.done?this.resolve(b):this.toPromise(b).then(this.onFulfill,this.onReject)}function d(a,b,d){this.iterator=a,this.onFulfill=c.bind(this,"next"),this.onReject=c.bind(this,"throw"),this.reject=d,this.resolve=b,this.toPromise=e}var e=a("./_resolve"),f=function(a){return function(){var b=this,c=arguments;return new Promise(function(e,f){return new d(a.apply(b,c),e,f).onFulfill()})}};f.cancelable=function(a){return function(b){var c=this,f=arguments;return b.requested?Promise.reject(b.reason):new Promise(function(g,h){var i=new d(a.apply(c,f),g,h),j=b.promise;j.then(function(){i.toPromise=e}),i.toPromise=function(a){return new Promise(function(b,c){e(a).then(b,c),j.then(c)})},i.onFulfill()})}},b.exports=f},{"./_resolve":10}],17:[function(a,b){"use strict";var c=a("./CancelToken"),d=c.isCancelToken,e=c.source;b.exports=function(a,b,c){function f(){var a=arguments.length;if(0!==a&&d(arguments[0]))return g.apply(this,arguments);var b=e(),c=b.cancel,f=b.token,h=Array(a+1);h[0]=f;for(var j=0;j<a;++j)h[j+1]=arguments[j];var k=g.apply(this,h);return k.cancel=c,k}var g=c===void 0?a:c.value;return void 0===c?f:(c.value=f,c)}},{"./CancelToken":2}],18:[function(a,b){"use strict";var c=a("./_isProgrammerError"),d=function(a,b){if("function"==typeof a)return a===Error||a.prototype instanceof Error?b instanceof a:a(b);if(null!=b&&"object"==typeof a){for(var c in a)if(hasOwnProperty.call(a,c)&&b[c]!==a[c])return!1;return!0}};b.exports=function(){var a,b=this,e=arguments.length;if(0===e||"function"!=typeof(a=arguments[--e]))return this;if(0===e)return this.then(void 0,function(d){return c(d)?b:a(d)});for(var f=Array(e),g=0;g<e;++g)f[g]=arguments[g];return this.then(void 0,function(c){for(var g=0;g<e;++g)if(d(f[g],c))return a(c);return b})}},{"./_isProgrammerError":6}],19:[function(a,b){"use strict";b.exports=function(){var a,b,c=new Promise(function(c,d){a=c,b=d});return{promise:c,reject:b,resolve:a}}},{}],20:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){var b=2===arguments.length?arguments[1]:this;return c(b)?b.then(function(b){return new Promise(function(c){setTimeout(c,a,b)})}):new Promise(function(c){setTimeout(c,a,b)})}},{"./isPromise":33}],21:[function(a,b){"use strict";var c=a("./_Resource");b.exports=function a(a){return new c(this,a)}},{"./_Resource":4}],22:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(a,a).then(function(){return b})}},{}],23:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forArray)},{"./_utils":13,"./makeAsyncIterator":34}],24:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forEach)},{"./_utils":13,"./makeAsyncIterator":34}],25:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIn)},{"./_utils":13,"./makeAsyncIterator":34}],26:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIterable)},{"./_utils":13,"./makeAsyncIterator":34}],27:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forOwn)},{"./_utils":13,"./makeAsyncIterator":34}],28:[function(a,b){"use strict";b.exports=function(a){return new Promise(function(b,c){return a(function(a,d){return null==a?b(d):c(a)})})}},{}],29:[function(a,b){"use strict";var c=a("./cancelable"),d=a("./_makeEventAdder"),e=c(function(a,b,c,e){return void 0===e&&(e={}),new Promise(function(f,g){var h=d(a,b,e.array);if(h(c,f),!e.ignoreErrors){var i=e,j=i.error,k=void 0===j?"error":j;k!==c&&h(k,g)}})});b.exports=e},{"./_makeEventAdder":7,"./cancelable":17}],30:[function(a,b){"use strict";var c=a("./cancelable"),d=a("./_makeEventAdder"),e=a("./_utils"),f=e.forArray,g=c(function(a,b,c,e){return void 0===e&&(e=["error"]),new Promise(function(g,h){var i=d(a,b,!0);f(c,function(a){return i(a,g)}),f(e,function(a){return i(a,h)})})});b.exports=g},{"./_makeEventAdder":7,"./_utils":13,"./cancelable":17}],31:[function(a,b){"use strict";var c=a("./_isProgrammerError"),d=function(a){if(c(a))throw a};b.exports=function(){return this.then(void 0,d)}},{"./_isProgrammerError":6}],32:[function(a,b,c){"use strict";c.pAll=c.all=a("./all"),c.pAsCallback=c.asCallback=a("./asCallback"),c.pAsyncFn=c.asyncFn=a("./asyncFn"),c.pCancel=c.Cancel=a("./Cancel"),c.pCancelable=c.cancelable=a("./cancelable"),c.pCancelToken=c.CancelToken=a("./CancelToken"),c.pCatch=c.catch=a("./catch"),c.pDefer=c.defer=a("./defer"),c.pDelay=c.delay=a("./delay"),c.pDisposer=c.disposer=a("./disposer"),c.pFinally=c.finally=a("./finally"),c.pForArray=c.forArray=a("./forArray"),c.pForEach=c.forEach=a("./forEach"),c.pForIn=c.forIn=a("./forIn"),c.pForIterable=c.forIterable=a("./forIterable"),c.pForOwn=c.forOwn=a("./forOwn"),c.pFromCallback=c.fromCallback=a("./fromCallback"),c.pFromEvent=c.fromEvent=a("./fromEvent"),c.pFromEvents=c.fromEvents=a("./fromEvents"),c.pIgnoreErrors=c.ignoreErrors=a("./ignoreErrors"),c.pIsPromise=c.isPromise=a("./isPromise"),c.pMakeAsyncIterator=c.makeAsyncIterator=a("./makeAsyncIterator"),c.pMap=c.map=a("./map"),c.pPromisify=c.promisify=a("./promisify"),c.pPromisifyAll=c.promisifyAll=a("./promisifyAll"),c.pReflect=c.reflect=a("./reflect"),c.pSettle=c.settle=a("./settle"),c.pSome=c.some=a("./some"),c.pSuppressUnhandledRejections=c.suppressUnhandledRejections=a("./suppressUnhandledRejections"),c.pTap=c.tap=a("./tap"),c.pTapCatch=c.tapCatch=a("./tapCatch"),c.pTimeout=c.timeout=a("./timeout"),c.pTimeoutError=c.TimeoutError=a("./TimeoutError"),c.pTry=c.try=a("./try"),c.pUnpromisify=c.unpromisify=a("./unpromisify"),c.pUsing=c.using=a("./using"),c.pWrapApply=c.wrapApply=a("./wrapApply"),c.pWrapCall=c.wrapCall=a("./wrapCall")},{"./Cancel":1,"./CancelToken":2,"./TimeoutError":3,"./all":14,"./asCallback":15,"./asyncFn":16,"./cancelable":17,"./catch":18,"./defer":19,"./delay":20,"./disposer":21,"./finally":22,"./forArray":23,"./forEach":24,"./forIn":25,"./forIterable":26,"./forOwn":27,"./fromCallback":28,"./fromEvent":29,"./fromEvents":30,"./ignoreErrors":31,"./isPromise":33,"./makeAsyncIterator":34,"./map":35,"./promisify":37,"./promisifyAll":38,"./reflect":39,"./settle":40,"./some":41,"./suppressUnhandledRejections":42,"./tap":43,"./tapCatch":44,"./timeout":45,"./try":46,"./unpromisify":47,"./using":48,"./wrapApply":49,"./wrapCall":50}],33:[function(a,b){"use strict";b.exports=function(a){return null!=a&&"function"==typeof a.then}},{}],34:[function(a,b){"use strict";var c=a("./_noop"),d=a("./_utils"),e=d.makeAsyncIterator;b.exports=function(a){var b=e(a);return function(a){return b(this,a).then(c)}}},{"./_noop":8,"./_utils":13}],35:[function(a,b){"use strict";var c=a("./defer"),d=a("./_identity"),e=a("./isPromise"),f=a("./_utils"),g=f.applyThen,h=f.forEach,i=function a(b,f){if(void 0===f&&(f=d),e(b))return b.then(function(b){return a(b,f)});var j,k=1,l=[],m=c(),n=m.promise,o=m.reject,p=m.resolve,q=function(){0==--k&&(void 0===j?p(l):o(j.error))},r=function(a){void 0===j&&(j={error:a}),q()},s=function a(b){var c=b[0];return e(c)?c.then(function(c){return b[0]=c,a(b)}):void g(f,b,function(a){l[b[3]]=a,q()},r)},t=0;return h(b,function(a,b,c){++k,s([a,b,c,t++])}),q(),n};b.exports=function(a){return i(this,a)}},{"./_identity":5,"./_utils":13,"./defer":19,"./isPromise":33}],36:[function(a,b,c){"use strict";function d(a){a!==void 0&&f(this,"message",{configurable:!0,value:a,writable:!0});var b=this.constructor.name;b!==void 0&&b!==this.name&&f(this,"name",{configurable:!0,value:b,writable:!0}),g(this,this.constructor)}var e="undefined"==typeof Reflect?void 0:Reflect.construct,f=Object.defineProperty,g=Error.captureStackTrace;g===void 0&&(g=function(a){var b=new Error;f(a,"stack",{configurable:!0,get:function(){var a=b.stack;return f(this,"stack",{configurable:!0,value:a,writable:!0}),a},set:function(b){f(a,"stack",{configurable:!0,value:b,writable:!0})}})}),d.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:d,writable:!0}});var h=function(){function a(a,b){return f(a,"name",{configurable:!0,value:b})}try{var b=function(){};if(a(b,"foo"),"foo"===b.name)return a}catch(a){}}();c=b.exports=function(a,b){if(null==b||b===Error)b=d;else if("function"!=typeof b)throw new TypeError("super_ should be a function");var c;if("string"==typeof a)c=a,a=void 0===e?function(){b.apply(this,arguments)}:function(){return e(b,arguments,this.constructor)},void 0!==h&&(h(a,c),c=void 0);else if("function"!=typeof a)throw new TypeError("constructor should be either a string or a function");a.super_=a["super"]=b;var f={constructor:{configurable:!0,value:a,writable:!0}};return void 0!==c&&(f.name={configurable:!0,value:c,writable:!0}),a.prototype=Object.create(b.prototype,f),a},c.BaseError=d},{}],37:[function(a,b){"use strict";var c=a("./_setFunctionNameAndLength");b.exports=function(a,b){return c(function(){for(var c=this,d=arguments.length,e=Array(d+1),f=0;f<d;++f)e[f]=arguments[f];return new Promise(function(f,g){e[d]=function(a,b){return a?g(a):f(b)},a.apply(b===void 0?c:b,e)})},a.name,0!==a.length&&a.length-1)}},{"./_setFunctionNameAndLength":11}],38:[function(a,b){"use strict";var c=a("./promisify"),d=a("./_utils"),e=d.endsWith,f=d.forIn,g=function(a,b){return!(e(b,"Sync")||e(b,"Async"))&&b};b.exports=function(a,b){var d=void 0===b?{}:b,e=d.mapper,h=void 0===e?g:e,i=d.target,j=void 0===i?{}:i,k=d.context,l=void 0===k?a:k;return f(a,function(b,d){var e;"function"==typeof b&&(e=h(b,d,a))&&(j[e]=c(b,l))}),j}},{"./_utils":13,"./promisify":37}],39:[function(a,b){"use strict";var c=function(){return!1},d=function(){return!0},e=function(a){return function(b){return{__proto__:a,value:function(){return b}}}}({isFulfilled:d,isPending:c,isRejected:c,reason:function(){throw new Error("no reason, the promise has resolved")}}),f=function(a){return function(b){return{__proto__:a,reason:function(){return b}}}}({isFulfilled:c,isPending:c,isRejected:d,value:function(){throw new Error("no value, the promise has rejected")}});b.exports=function(){return this.then(e,f)}},{}],40:[function(a,b){"use strict";var c=a("./all"),d=a("./reflect"),e=a("./_resolve");b.exports=function(){return c.call(this,function(a){var b;return(b=e(a),d).call(b)})}},{"./_resolve":10,"./all":14,"./reflect":39}],41:[function(a,b){"use strict";var c=a("./_resolve"),d=a("./_utils"),e=d.forEach,f=function(a,b){return new Promise(function(c,d){var f=[],g=[],h=function(a){f&&(f.push(a),0==--b&&(c(f),f=g=void 0))},i=-b,j=function(a){f&&(g.push(a),0==--i&&(d(g),f=g=void 0))};e(a,function(a){++i,c(a).then(h,j)})})};b.exports=function(a){return c(this).then(function(b){return f(b,a)})}},{"./_resolve":10,"./_utils":13}],42:[function(a,b){"use strict";var c=a("./_noop");b.exports=function(){var a=this.suppressUnhandledRejections;return"function"==typeof a?a.call(this):this.then(void 0,c),this}},{"./_noop":8}],43:[function(a,b){"use strict";b.exports=function(a,b){var c=this;return this.then(a,b).then(function(){return c})}},{}],44:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(void 0,a).then(function(){return b})}},{}],45:[function(a,b){"use strict";var c=a("./TimeoutError");b.exports=function(a,b){var d=this;return new Promise(function(e,f){var g=setTimeout(function(){if(g=void 0,"function"==typeof d.cancel&&d.cancel(),"function"==typeof b)try{e(b())}catch(a){f(a)}else f(void 0===b?new c:b)},a);d.then(function(a){g!==void 0&&clearTimeout(g),e(a)},function(a){g!==void 0&&clearTimeout(g),f(a)})})}},{"./TimeoutError":3}],46:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a){try{return c(a())}catch(a){return Promise.reject(a)}}},{"./_resolve":10}],47:[function(a,b){"use strict";var c=a("./_setFunctionNameAndLength");b.exports=function(){var a=this;return c(function(){var b,c=arguments.length-1;if(0>c||"function"!=typeof(b=arguments[c]))throw new Error("missing callback");for(var d=Array(c),e=0;e<c;++e)d[e]=arguments[e];a.apply(this,d).then(function(a){return b(void 0,a)},function(a){return b(a)})},a.name,a.length+1)}},{"./_setFunctionNameAndLength":11}],48:[function(a,b){"use strict";var c=a("./_once"),d=a("./_Resource"),e=a("./wrapApply"),f=a("./wrapCall"),g=a("./_utils"),h=g.forArray,j=g.isArray;b.exports=function(){var a=this,b=arguments.length-1;if(1>b)throw new TypeError("using expects at least 2 arguments");var g=arguments[b],k=arguments[0],l=1<b||!j(k);if(l){k=Array(b);for(var m=0;m<b;++m)k[m]=arguments[m]}else b=k.length;var n=c(function(a,c){var e=b,g=function(){0==--e&&a(c)},i=function(a){setTimeout(function(){throw a},0)};h(k,function(a){var b;null!=a&&"function"==typeof(b=a.d)?(a.p.then(function(a){return f(b,a).then(g,i)},g),a.p=a.d=void 0):--e})});return new Promise(function(c,i){var j=Array(b),m=b,o=function(a){o=p,r=function(){return n(i,a)},p()},q=function(a){return o(a)},p=function(){0==--m&&r()},r=function(){return(l?e:f)(g,j,a).then(function(a){return n(c,a)},function(a){return n(i,a)})};h(k,function(a,b){var c=a instanceof d?a.p:a;return void 0===c?void q(new TypeError("resource has already been disposed of")):void c.then(function(a){j[b]=a,p()},q)})})}},{"./_Resource":4,"./_once":9,"./_utils":13,"./wrapApply":49,"./wrapCall":50}],49:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a,b,d){try{return c(a.apply(d,b))}catch(a){return Promise.reject(a)}}},{"./_resolve":10}],50:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a,b,d){try{return c(a.call(d,b))}catch(a){return Promise.reject(a)}}},{"./_resolve":10}]},{},[32])(32)}); | ||
(function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.promiseToolbox=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c<g.length;c++)a(g[c]);return a}return b}()({1:[function(a,b){"use strict";b.exports=function(){function a(a){void 0===a&&(a="this action has been canceled"),Object.defineProperty(this,"message",{enumerable:!0,value:a})}var b=a.prototype;return b.toString=function(){return"Cancel: "+this.message},a}()},{}],2:[function(a,b){"use strict";function c(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function d(a,b,d){return b&&c(a.prototype,b),d&&c(a,d),a}function e(a){if(void 0===this._reason){var b=this._reason=a instanceof j?a:new j(a),c=this._resolve;void 0!==c&&(this._resolve=void 0,c(b));var d=this._handlers;if(void 0!==d){this._handlers=void 0;for(var e=h(),f=e.promise,g=e.resolve,l=0,m=function(){if(0==--l)return g()},o=0,p=d.length;o<p;++o)try{var n=d[o](b);k(n)&&(++l,n.then(m,m))}catch(a){}if(0!==l)return f}}}function f(a){var b=this._handlers;if(b!==void 0){var c=b.indexOf(a);-1!==c&&b.splice(c,1)}}function g(a){var b=this.cancel=e.bind(this.token=new p(o));null==a||a.forEach(function(a){var c=a.reason;return void 0===c?void a.addHandler(b):(b(c),!1)})}var h=a("./defer"),j=a("./Cancel"),k=a("./isPromise"),l=a("./_symbols"),m=l.$$toStringTag,n="CancelToken",o={},p=function(){function a(a){this._handlers=void 0,this._promise=void 0,this._reason=void 0,this._resolve=void 0,a!==o&&a(e.bind(this))}a.isCancelToken=function(a){return null!=a&&a[m]===n},a.source=function(a){return new g(a)};var b=a.prototype;return b.addHandler=function(a){var b=this._handlers;if(void 0===b){if(this.requested)throw new TypeError("cannot add a handler to an already canceled token");b=this._handlers=[]}return b.push(a),f.bind(this,a)},b.throwIfRequested=function(){var a=this._reason;if(void 0!==a)throw a},d(a,[{key:"promise",get:function(){var a=this,b=this._promise;if(void 0===b){var c=this._reason;b=this._promise=void 0===c?new Promise(function(b){a._resolve=b}):Promise.resolve(c)}return b}},{key:"reason",get:function(){return this._reason}},{key:"requested",get:function(){return void 0!==this._reason}},{key:m,get:function(){return n}}]),a}();e.call(p.canceled=new p(o)),p.none=new p(o),b.exports=p},{"./Cancel":1,"./_symbols":12,"./defer":19,"./isPromise":33}],3:[function(a,b){"use strict";function c(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}var d=a("make-error"),e=d.BaseError;b.exports=function(a){function b(){return a.call(this,"operation timed out")||this}return c(b,a),b}(e)},{"make-error":36}],4:[function(a,b){"use strict";b.exports=function(a,b){this.d=b,this.p=a}},{}],5:[function(a,b){"use strict";b.exports=function(a){return a}},{}],6:[function(a,b){"use strict";b.exports=function(a){return a instanceof ReferenceError||a instanceof SyntaxError||a instanceof TypeError}},{}],7:[function(a,b){"use strict";var c=a("./_noop"),d=a("./_once");b.exports=function(a,b,e){var f=b.addEventListener||b.addListener||b.on;if(void 0===f)throw new Error("cannot register event listener");var g=b.removeEventListener||b.removeListener||b.off,h=[],j=c;return void 0!==g&&(j=d(function(){for(var a=0,c=h.length;a<c;a+=2)g.call(b,h[a],h[a+1])}),a.promise.then(j)),e?function(a,c){function d(){j();for(var b=arguments.length,d=Array(b),e=0;e<b;++e)d[e]=arguments[e];d.event=a,c(d)}h.push(a,d),f.call(b,a,d)}:function(a,c){var d=function(a){j(),c(a)};h.push(a,d),f.call(b,a,d)}}},{"./_noop":8,"./_once":9}],8:[function(a,b){"use strict";b.exports=Function.prototype},{}],9:[function(a,b){"use strict";b.exports=function(a){var b;return function(){return void 0!==a&&(b=a.apply(this,arguments),a=void 0),b}}},{}],10:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){return c(a)?a:Promise.resolve(a)}},{"./isPromise":33}],11:[function(a,b){"use strict";b.exports=function(){var b=Object.defineProperties;try{var c=b(function(){},{length:{value:2},name:{value:"foo"}});if(2===c.length&&"foo"===c.name)return function(a,c,d){return b(a,{length:{configurable:!0,value:d},name:{configurable:!0,value:c}})}}catch(a){}return a("./_identity")}()},{"./_identity":5}],12:[function(a,b,c){"use strict";var d="function"==typeof Symbol?function(a){var b=Symbol[a];return b===void 0?"@@"+a:b}:function(a){return"@@"+a};c.$$iterator=d("iterator"),c.$$toStringTag=d("toStringTag")},{}],13:[function(a,b,c){"use strict";if("function"!=typeof Promise||"function"!=typeof Promise.reject||"function"!=typeof Promise.resolve)throw new Error("a standard Promise implementation is required (https://github.com/JsCommunity/promise-toolbox#usage)");var d=a("./isPromise"),e=a("./_symbols"),f=e.$$iterator;c.applyThen=function(a,b,c,e){var f;try{if(f=a.apply(void 0,b),d(f))return void f.then(c,e)}catch(a){return void e(a)}c(f)},c.endsWith=function(a,b,c){return void 0===c&&(c=a.length),c-=b.length,0<=c&&a.indexOf(b,c)===c};var g=c.forArray=function(a,b){for(var c=a.length,d=0;d<c;++d)b(a[d],d,a)};c.forIn=function(a,b){for(var c in a)b(a[c],c,a)};var h=c.forIterable=function(a,b){for(var c,d=a[f]();!(c=d.next()).done;)b(c.value,void 0,a)},i=Object.prototype.hasOwnProperty,j=c.forOwn=function(a,b){for(var c in a)i.call(a,c)&&b(a[c],c,a)},k=function(a){return null!=a&&"function"==typeof a[f]},l=c.forEach=function(a,b){return n(a)?g(a,b):k(a)?h(a,b):p(a)?g(a,b):j(a,b)},m=Array.isArray,n=void 0===m?function(a){return a instanceof Array}:m;c.isArray=n;var o=function(a){return"number"==typeof a&&0<=a&&a<1/0&&Math.floor(a)===a},p=c.isArrayLike=function(a){return"function"!=typeof a&&null!=a&&o(a.length)};c.makeAsyncIterator=function(a){return function b(c,e){if(d(c))return c.then(function(a){return b(a,e)});var f=Promise.resolve();return a(c,function(a,b){f=d(a)?f.then(function(){return a.then(function(a){return e(a,b,c)})}):f.then(function(){return e(a,b,c)})}),f}},c.map=function(a,b){var c=[];return l(a,function(a,d,e){c.push(b(a,d,e))}),c},c.mapAuto=function(a,b){var c=p(a)?Array(a.length):Object.create(null);return void 0!==b&&l(a,function(a,d,e){c[d]=b(a,d,e)}),c}},{"./_symbols":12,"./isPromise":33}],14:[function(a,b){"use strict";var c=a("./isPromise"),d=a("./_utils"),e=d.forEach,f=d.mapAuto,g=function(a,b){return new Promise(function(d,g){var h=f(a,b),i=1,j=function(){if(0==--i){var a=h;h=void 0,d(a)}},k=function(a,b){h&&(h[b]=a,j())},l=function(a){h&&(h=void 0,g(a))};e(b===void 0?a:h,function(a,b){++i,c(a)?a.then(function(a){return k(a,b)},l):k(a,b)}),j()})};b.exports=function(a){return c(this)?this.then(function(b){return g(b,a)}):g(this,a)}},{"./_utils":13,"./isPromise":33}],15:[function(a,b){"use strict";b.exports=function(a){return"function"==typeof a&&this.then(function(b){return a(void 0,b)},a),this}},{}],16:[function(a,b){"use strict";function c(a,b){var c;try{c=this.iterator[a](b)}catch(a){return this.reject(a)}b=c.value,c.done?this.resolve(b):this.toPromise(b).then(this.onFulfill,this.onReject)}function d(a,b,d){this.iterator=a,this.onFulfill=c.bind(this,"next"),this.onReject=c.bind(this,"throw"),this.reject=d,this.resolve=b,this.toPromise=e}var e=a("./_resolve"),f=function(a){return function(){var b=this,c=arguments;return new Promise(function(e,f){return new d(a.apply(b,c),e,f).onFulfill()})}};f.cancelable=function(a){return function(b){var c=this,f=arguments;return b.requested?Promise.reject(b.reason):new Promise(function(g,h){var i=new d(a.apply(c,f),g,h),j=b.promise;j.then(function(){i.toPromise=e}),i.toPromise=function(a){return new Promise(function(b,c){e(a).then(b,c),j.then(c)})},i.onFulfill()})}},b.exports=f},{"./_resolve":10}],17:[function(a,b){"use strict";var c=a("./CancelToken"),d=c.isCancelToken,e=c.source;b.exports=function(a,b,c){function f(){var a=arguments.length;if(0!==a&&d(arguments[0]))return g.apply(this,arguments);var b=e(),c=b.cancel,f=b.token,h=Array(a+1);h[0]=f;for(var j=0;j<a;++j)h[j+1]=arguments[j];var k=g.apply(this,h);return k.cancel=c,k}var g=c===void 0?a:c.value;return void 0===c?f:(c.value=f,c)}},{"./CancelToken":2}],18:[function(a,b){"use strict";var c=a("./_isProgrammerError"),d=function(a,b){if("function"==typeof a)return a===Error||a.prototype instanceof Error?b instanceof a:a(b);if(null!=b&&"object"==typeof a){for(var c in a)if(hasOwnProperty.call(a,c)&&b[c]!==a[c])return!1;return!0}};b.exports=function(){var a,b=this,e=arguments.length;if(0===e||"function"!=typeof(a=arguments[--e]))return this;if(0===e)return this.then(void 0,function(d){return c(d)?b:a(d)});for(var f=Array(e),g=0;g<e;++g)f[g]=arguments[g];return this.then(void 0,function(c){for(var g=0;g<e;++g)if(d(f[g],c))return a(c);return b})}},{"./_isProgrammerError":6}],19:[function(a,b){"use strict";b.exports=function(){var a,b,c=new Promise(function(c,d){a=c,b=d});return{promise:c,reject:b,resolve:a}}},{}],20:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){var b=2===arguments.length?arguments[1]:this;return c(b)?b.then(function(b){return new Promise(function(c){setTimeout(c,a,b)})}):new Promise(function(c){setTimeout(c,a,b)})}},{"./isPromise":33}],21:[function(a,b){"use strict";var c=a("./_Resource");b.exports=function a(a){return new c(this,a)}},{"./_Resource":4}],22:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(a,a).then(function(){return b})}},{}],23:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forArray)},{"./_utils":13,"./makeAsyncIterator":34}],24:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forEach)},{"./_utils":13,"./makeAsyncIterator":34}],25:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIn)},{"./_utils":13,"./makeAsyncIterator":34}],26:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIterable)},{"./_utils":13,"./makeAsyncIterator":34}],27:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forOwn)},{"./_utils":13,"./makeAsyncIterator":34}],28:[function(a,b){"use strict";b.exports=function(a){return new Promise(function(b,c){return a(function(a,d){return null==a?b(d):c(a)})})}},{}],29:[function(a,b){"use strict";var c=a("./cancelable"),d=a("./_makeEventAdder"),e=c(function(a,b,c,e){return void 0===e&&(e={}),new Promise(function(f,g){var h=d(a,b,e.array);if(h(c,f),!e.ignoreErrors){var i=e,j=i.error,k=void 0===j?"error":j;k!==c&&h(k,g)}})});b.exports=e},{"./_makeEventAdder":7,"./cancelable":17}],30:[function(a,b){"use strict";var c=a("./cancelable"),d=a("./_makeEventAdder"),e=a("./_utils"),f=e.forArray,g=c(function(a,b,c,e){return void 0===e&&(e=["error"]),new Promise(function(g,h){var i=d(a,b,!0);f(c,function(a){return i(a,g)}),f(e,function(a){return i(a,h)})})});b.exports=g},{"./_makeEventAdder":7,"./_utils":13,"./cancelable":17}],31:[function(a,b){"use strict";var c=a("./_isProgrammerError"),d=function(a){if(c(a))throw a};b.exports=function(){return this.then(void 0,d)}},{"./_isProgrammerError":6}],32:[function(a,b,c){"use strict";c.pAll=c.all=a("./all"),c.pAsCallback=c.asCallback=a("./asCallback"),c.pAsyncFn=c.asyncFn=a("./asyncFn"),c.pCancel=c.Cancel=a("./Cancel"),c.pCancelable=c.cancelable=a("./cancelable"),c.pCancelToken=c.CancelToken=a("./CancelToken"),c.pCatch=c.catch=a("./catch"),c.pDefer=c.defer=a("./defer"),c.pDelay=c.delay=a("./delay"),c.pDisposer=c.disposer=a("./disposer"),c.pFinally=c.finally=a("./finally"),c.pForArray=c.forArray=a("./forArray"),c.pForEach=c.forEach=a("./forEach"),c.pForIn=c.forIn=a("./forIn"),c.pForIterable=c.forIterable=a("./forIterable"),c.pForOwn=c.forOwn=a("./forOwn"),c.pFromCallback=c.fromCallback=a("./fromCallback"),c.pFromEvent=c.fromEvent=a("./fromEvent"),c.pFromEvents=c.fromEvents=a("./fromEvents"),c.pIgnoreErrors=c.ignoreErrors=a("./ignoreErrors"),c.pIsPromise=c.isPromise=a("./isPromise"),c.pMakeAsyncIterator=c.makeAsyncIterator=a("./makeAsyncIterator"),c.pMap=c.map=a("./map"),c.pPromisify=c.promisify=a("./promisify"),c.pPromisifyAll=c.promisifyAll=a("./promisifyAll"),c.pReflect=c.reflect=a("./reflect"),c.pSettle=c.settle=a("./settle"),c.pSome=c.some=a("./some"),c.pSuppressUnhandledRejections=c.suppressUnhandledRejections=a("./suppressUnhandledRejections"),c.pTap=c.tap=a("./tap"),c.pTapCatch=c.tapCatch=a("./tapCatch"),c.pTimeout=c.timeout=a("./timeout"),c.pTimeoutError=c.TimeoutError=a("./TimeoutError"),c.pTry=c.try=a("./try"),c.pUnpromisify=c.unpromisify=a("./unpromisify"),c.pUsing=c.using=a("./using"),c.pWrapApply=c.wrapApply=a("./wrapApply"),c.pWrapCall=c.wrapCall=a("./wrapCall")},{"./Cancel":1,"./CancelToken":2,"./TimeoutError":3,"./all":14,"./asCallback":15,"./asyncFn":16,"./cancelable":17,"./catch":18,"./defer":19,"./delay":20,"./disposer":21,"./finally":22,"./forArray":23,"./forEach":24,"./forIn":25,"./forIterable":26,"./forOwn":27,"./fromCallback":28,"./fromEvent":29,"./fromEvents":30,"./ignoreErrors":31,"./isPromise":33,"./makeAsyncIterator":34,"./map":35,"./promisify":37,"./promisifyAll":38,"./reflect":39,"./settle":40,"./some":41,"./suppressUnhandledRejections":42,"./tap":43,"./tapCatch":44,"./timeout":45,"./try":46,"./unpromisify":47,"./using":48,"./wrapApply":49,"./wrapCall":50}],33:[function(a,b){"use strict";b.exports=function(a){return null!=a&&"function"==typeof a.then}},{}],34:[function(a,b){"use strict";var c=a("./_noop"),d=a("./_utils"),e=d.makeAsyncIterator;b.exports=function(a){var b=e(a);return function(a){return b(this,a).then(c)}}},{"./_noop":8,"./_utils":13}],35:[function(a,b){"use strict";var c=a("./defer"),d=a("./_identity"),e=a("./isPromise"),f=a("./_utils"),g=f.applyThen,h=f.forEach,i=function a(b,f){if(void 0===f&&(f=d),e(b))return b.then(function(b){return a(b,f)});var j,k=1,l=[],m=c(),n=m.promise,o=m.reject,p=m.resolve,q=function(){0==--k&&(void 0===j?p(l):o(j.error))},r=function(a){void 0===j&&(j={error:a}),q()},s=function a(b){var c=b[0];return e(c)?c.then(function(c){return b[0]=c,a(b)}):void g(f,b,function(a){l[b[3]]=a,q()},r)},t=0;return h(b,function(a,b,c){++k,s([a,b,c,t++])}),q(),n};b.exports=function(a){return i(this,a)}},{"./_identity":5,"./_utils":13,"./defer":19,"./isPromise":33}],36:[function(a,b,c){"use strict";function d(a){a!==void 0&&f(this,"message",{configurable:!0,value:a,writable:!0});var b=this.constructor.name;b!==void 0&&b!==this.name&&f(this,"name",{configurable:!0,value:b,writable:!0}),g(this,this.constructor)}var e="undefined"==typeof Reflect?void 0:Reflect.construct,f=Object.defineProperty,g=Error.captureStackTrace;g===void 0&&(g=function(a){var b=new Error;f(a,"stack",{configurable:!0,get:function(){var a=b.stack;return f(this,"stack",{configurable:!0,value:a,writable:!0}),a},set:function(b){f(a,"stack",{configurable:!0,value:b,writable:!0})}})}),d.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:d,writable:!0}});var h=function(){function a(a,b){return f(a,"name",{configurable:!0,value:b})}try{var b=function(){};if(a(b,"foo"),"foo"===b.name)return a}catch(a){}}();c=b.exports=function(a,b){if(null==b||b===Error)b=d;else if("function"!=typeof b)throw new TypeError("super_ should be a function");var c;if("string"==typeof a)c=a,a=void 0===e?function(){b.apply(this,arguments)}:function(){return e(b,arguments,this.constructor)},void 0!==h&&(h(a,c),c=void 0);else if("function"!=typeof a)throw new TypeError("constructor should be either a string or a function");a.super_=a["super"]=b;var f={constructor:{configurable:!0,value:a,writable:!0}};return void 0!==c&&(f.name={configurable:!0,value:c,writable:!0}),a.prototype=Object.create(b.prototype,f),a},c.BaseError=d},{}],37:[function(a,b){"use strict";var c=a("./_setFunctionNameAndLength");b.exports=function(a,b){return c(function(){for(var c=this,d=arguments.length,e=Array(d+1),f=0;f<d;++f)e[f]=arguments[f];return new Promise(function(f,g){e[d]=function(a,b){return a?g(a):f(b)},a.apply(b===void 0?c:b,e)})},a.name,0!==a.length&&a.length-1)}},{"./_setFunctionNameAndLength":11}],38:[function(a,b){"use strict";var c=a("./promisify"),d=a("./_utils"),e=d.endsWith,f=d.forIn,g=function(a,b){return!(e(b,"Sync")||e(b,"Async"))&&b};b.exports=function(a,b){var d=void 0===b?{}:b,e=d.mapper,h=void 0===e?g:e,i=d.target,j=void 0===i?{}:i,k=d.context,l=void 0===k?a:k;return f(a,function(b,d){var e;"function"==typeof b&&(e=h(b,d,a))&&(j[e]=c(b,l))}),j}},{"./_utils":13,"./promisify":37}],39:[function(a,b){"use strict";var c=function(){return!1},d=function(){return!0},e=function(a){return function(b){return{__proto__:a,value:function(){return b}}}}({isFulfilled:d,isPending:c,isRejected:c,reason:function(){throw new Error("no reason, the promise has resolved")}}),f=function(a){return function(b){return{__proto__:a,reason:function(){return b}}}}({isFulfilled:c,isPending:c,isRejected:d,value:function(){throw new Error("no value, the promise has rejected")}});b.exports=function(){return this.then(e,f)}},{}],40:[function(a,b){"use strict";var c=a("./all"),d=a("./reflect"),e=a("./_resolve");b.exports=function(){return c.call(this,function(a){var b;return(b=e(a),d).call(b)})}},{"./_resolve":10,"./all":14,"./reflect":39}],41:[function(a,b){"use strict";var c=a("./_resolve"),d=a("./_utils"),e=d.forEach,f=function(a,b){return new Promise(function(c,d){var f=[],g=[],h=function(a){f&&(f.push(a),0==--b&&(c(f),f=g=void 0))},i=-b,j=function(a){f&&(g.push(a),0==--i&&(d(g),f=g=void 0))};e(a,function(a){++i,c(a).then(h,j)})})};b.exports=function(a){return c(this).then(function(b){return f(b,a)})}},{"./_resolve":10,"./_utils":13}],42:[function(a,b){"use strict";var c=a("./_noop");b.exports=function(){var a=this.suppressUnhandledRejections;return"function"==typeof a?a.call(this):this.then(void 0,c),this}},{"./_noop":8}],43:[function(a,b){"use strict";b.exports=function(a,b){var c=this;return this.then(a,b).then(function(){return c})}},{}],44:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(void 0,a).then(function(){return b})}},{}],45:[function(a,b){"use strict";var c=a("./TimeoutError");b.exports=function(a,b){var d=this;return void 0===b&&(b=new c),0===a?this:new Promise(function(c,e){var f=setTimeout(function(){if(f=void 0,"function"==typeof d.cancel&&d.cancel(),"function"==typeof b)try{c(b())}catch(a){e(a)}else e(b)},a);d.then(function(a){void 0!==f&&clearTimeout(f),c(a)},function(a){void 0!==f&&clearTimeout(f),e(a)})})}},{"./TimeoutError":3}],46:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a){try{return c(a())}catch(a){return Promise.reject(a)}}},{"./_resolve":10}],47:[function(a,b){"use strict";var c=a("./_setFunctionNameAndLength");b.exports=function(){var a=this;return c(function(){var b,c=arguments.length-1;if(0>c||"function"!=typeof(b=arguments[c]))throw new Error("missing callback");for(var d=Array(c),e=0;e<c;++e)d[e]=arguments[e];a.apply(this,d).then(function(a){return b(void 0,a)},function(a){return b(a)})},a.name,a.length+1)}},{"./_setFunctionNameAndLength":11}],48:[function(a,b){"use strict";var c=a("./_once"),d=a("./_Resource"),e=a("./wrapApply"),f=a("./wrapCall"),g=a("./_utils"),h=g.forArray,j=g.isArray;b.exports=function(){var a=this,b=arguments.length-1;if(1>b)throw new TypeError("using expects at least 2 arguments");var g=arguments[b],k=arguments[0],l=1<b||!j(k);if(l){k=Array(b);for(var m=0;m<b;++m)k[m]=arguments[m]}else b=k.length;var n=c(function(a,c){var e=b,g=function(){0==--e&&a(c)},i=function(a){setTimeout(function(){throw a},0)};h(k,function(a){var b;null!=a&&"function"==typeof(b=a.d)?(a.p.then(function(a){return f(b,a).then(g,i)},g),a.p=a.d=void 0):--e})});return new Promise(function(c,i){var j=Array(b),m=b,o=function(a){o=r,s=function(){return n(i,a)},r()},q=function(a){return o(a)},r=function(){0==--m&&s()},s=function(){return(l?e:f)(g,j,a).then(function(a){return n(c,a)},function(a){return n(i,a)})};h(k,function(a,b){var c;if(!(a instanceof d))c=Promise.resolve(a);else if(c=a.p,void 0===c)return q(new TypeError("resource has already been disposed of"));c.then(function(a){j[b]=a,r()},q)})})}},{"./_Resource":4,"./_once":9,"./_utils":13,"./wrapApply":49,"./wrapCall":50}],49:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a,b,d){try{return c(a.apply(d,b))}catch(a){return Promise.reject(a)}}},{"./_resolve":10}],50:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a,b,d){try{return c(a.call(d,b))}catch(a){return Promise.reject(a)}}},{"./_resolve":10}]},{},[32])(32)}); |
13
using.js
@@ -99,7 +99,12 @@ "use strict"; | ||
forArray(resources, function (resource, i) { | ||
var p = resource instanceof Resource ? resource.p : resource; | ||
var p; | ||
if (p === undefined) { | ||
onProviderFailure(new TypeError('resource has already been disposed of')); | ||
return; | ||
if (resource instanceof Resource) { | ||
p = resource.p; | ||
if (p === undefined) { | ||
return onProviderFailure(new TypeError('resource has already been disposed of')); | ||
} | ||
} else { | ||
p = Promise.resolve(resource); | ||
} | ||
@@ -106,0 +111,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164157
103580
1188
799