UNPKG

@playbasis1/playbasis

Version:
1,979 lines (1,730 loc) 469 kB
"use strict";var _typeof2=typeof Symbol==="function"&&typeof(typeof Symbol==="function"?Symbol.iterator:"@@iterator")==="symbol"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==(typeof Symbol==="function"?Symbol.prototype:"@@prototype")?"symbol":typeof obj;}; (function(f){if((typeof exports==="undefined"?"undefined":_typeof2(exports))==="object"&&typeof module!=="undefined"){module.exports=f();}else if(typeof define==="function"&&define.amd){define([],f);}else{var g;if(typeof window!=="undefined"){g=window;}else if(typeof global!=="undefined"){g=global;}else if(typeof self!=="undefined"){g=self;}else{g=this;}g.Playbasis=f();}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a;}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r);},p,p.exports,r,e,n,t);}return n[i].exports;}for(var u="function"==typeof require&&require,i=0;i<t.length;i++){o(t[i]);}return o;}return r;}()({1:[function(require,module,exports){ 'use strict'; exports.byteLength=byteLength; exports.toByteArray=toByteArray; exports.fromByteArray=fromByteArray; var lookup=[]; var revLookup=[]; var Arr=typeof Uint8Array!=='undefined'?Uint8Array:Array; var code='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for(var i=0,len=code.length;i<len;++i){ lookup[i]=code[i]; revLookup[code.charCodeAt(i)]=i; } revLookup['-'.charCodeAt(0)]=62; revLookup['_'.charCodeAt(0)]=63; function getLens(b64){ var len=b64.length; if(len%4>0){ throw new Error('Invalid string. Length must be a multiple of 4'); } var validLen=b64.indexOf('='); if(validLen===-1)validLen=len; var placeHoldersLen=validLen===len? 0: 4-validLen%4; return[validLen,placeHoldersLen]; } function byteLength(b64){ var lens=getLens(b64); var validLen=lens[0]; var placeHoldersLen=lens[1]; return(validLen+placeHoldersLen)*3/4-placeHoldersLen; } function _byteLength(b64,validLen,placeHoldersLen){ return(validLen+placeHoldersLen)*3/4-placeHoldersLen; } function toByteArray(b64){ var tmp; var lens=getLens(b64); var validLen=lens[0]; var placeHoldersLen=lens[1]; var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen)); var curByte=0; var len=placeHoldersLen>0? validLen-4: validLen; for(var i=0;i<len;i+=4){ tmp= revLookup[b64.charCodeAt(i)]<<18| revLookup[b64.charCodeAt(i+1)]<<12| revLookup[b64.charCodeAt(i+2)]<<6| revLookup[b64.charCodeAt(i+3)]; arr[curByte++]=tmp>>16&0xFF; arr[curByte++]=tmp>>8&0xFF; arr[curByte++]=tmp&0xFF; } if(placeHoldersLen===2){ tmp= revLookup[b64.charCodeAt(i)]<<2| revLookup[b64.charCodeAt(i+1)]>>4; arr[curByte++]=tmp&0xFF; } if(placeHoldersLen===1){ tmp= revLookup[b64.charCodeAt(i)]<<10| revLookup[b64.charCodeAt(i+1)]<<4| revLookup[b64.charCodeAt(i+2)]>>2; arr[curByte++]=tmp>>8&0xFF; arr[curByte++]=tmp&0xFF; } return arr; } function tripletToBase64(num){ return lookup[num>>18&0x3F]+ lookup[num>>12&0x3F]+ lookup[num>>6&0x3F]+ lookup[num&0x3F]; } function encodeChunk(uint8,start,end){ var tmp; var output=[]; for(var i=start;i<end;i+=3){ tmp= (uint8[i]<<16&0xFF0000)+( uint8[i+1]<<8&0xFF00)+( uint8[i+2]&0xFF); output.push(tripletToBase64(tmp)); } return output.join(''); } function fromByteArray(uint8){ var tmp; var len=uint8.length; var extraBytes=len%3; var parts=[]; var maxChunkLength=16383; for(var i=0,len2=len-extraBytes;i<len2;i+=maxChunkLength){ parts.push(encodeChunk( uint8,i,i+maxChunkLength>len2?len2:i+maxChunkLength)); } if(extraBytes===1){ tmp=uint8[len-1]; parts.push( lookup[tmp>>2]+ lookup[tmp<<4&0x3F]+ '=='); }else if(extraBytes===2){ tmp=(uint8[len-2]<<8)+uint8[len-1]; parts.push( lookup[tmp>>10]+ lookup[tmp>>4&0x3F]+ lookup[tmp<<2&0x3F]+ '='); } return parts.join(''); } },{}],2:[function(require,module,exports){ (function(process,global,setImmediate){ /* @preserve * The MIT License (MIT) * * Copyright (c) 2013-2018 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ !function(e){if("object"==(typeof exports==="undefined"?"undefined":_typeof2(exports))&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e();}}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f;}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e);},l,l.exports,e,t,n,r);}return n[o].exports;}var i=typeof _dereq_=="function"&&_dereq_;for(var o=0;o<r.length;o++){s(r[o]);}return s;}({1:[function(_dereq_,module,exports){ "use strict"; module.exports=function(Promise){ var SomePromiseArray=Promise._SomePromiseArray; function any(promises){ var ret=new SomePromiseArray(promises); var promise=ret.promise(); ret.setHowMany(1); ret.setUnwrap(); ret.init(); return promise; } Promise.any=function(promises){ return any(promises); }; Promise.prototype.any=function(){ return any(this); }; }; },{}],2:[function(_dereq_,module,exports){ "use strict"; var firstLineError; try{throw new Error();}catch(e){firstLineError=e;} var schedule=_dereq_("./schedule"); var Queue=_dereq_("./queue"); var util=_dereq_("./util"); function Async(){ this._customScheduler=false; this._isTickUsed=false; this._lateQueue=new Queue(16); this._normalQueue=new Queue(16); this._haveDrainedQueues=false; this._trampolineEnabled=true; var self=this; this.drainQueues=function(){ self._drainQueues(); }; this._schedule=schedule; } Async.prototype.setScheduler=function(fn){ var prev=this._schedule; this._schedule=fn; this._customScheduler=true; return prev; }; Async.prototype.hasCustomScheduler=function(){ return this._customScheduler; }; Async.prototype.enableTrampoline=function(){ this._trampolineEnabled=true; }; Async.prototype.disableTrampolineIfNecessary=function(){ if(util.hasDevTools){ this._trampolineEnabled=false; } }; Async.prototype.haveItemsQueued=function(){ return this._isTickUsed||this._haveDrainedQueues; }; Async.prototype.fatalError=function(e,isNode){ if(isNode){ process.stderr.write("Fatal "+(e instanceof Error?e.stack:e)+ "\n"); process.exit(2); }else{ this.throwLater(e); } }; Async.prototype.throwLater=function(fn,arg){ if(arguments.length===1){ arg=fn; fn=function fn(){throw arg;}; } if(typeof setTimeout!=="undefined"){ setTimeout(function(){ fn(arg); },0); }else try{ this._schedule(function(){ fn(arg); }); }catch(e){ throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n"); } }; function AsyncInvokeLater(fn,receiver,arg){ this._lateQueue.push(fn,receiver,arg); this._queueTick(); } function AsyncInvoke(fn,receiver,arg){ this._normalQueue.push(fn,receiver,arg); this._queueTick(); } function AsyncSettlePromises(promise){ this._normalQueue._pushOne(promise); this._queueTick(); } if(!util.hasDevTools){ Async.prototype.invokeLater=AsyncInvokeLater; Async.prototype.invoke=AsyncInvoke; Async.prototype.settlePromises=AsyncSettlePromises; }else{ Async.prototype.invokeLater=function(fn,receiver,arg){ if(this._trampolineEnabled){ AsyncInvokeLater.call(this,fn,receiver,arg); }else{ this._schedule(function(){ setTimeout(function(){ fn.call(receiver,arg); },100); }); } }; Async.prototype.invoke=function(fn,receiver,arg){ if(this._trampolineEnabled){ AsyncInvoke.call(this,fn,receiver,arg); }else{ this._schedule(function(){ fn.call(receiver,arg); }); } }; Async.prototype.settlePromises=function(promise){ if(this._trampolineEnabled){ AsyncSettlePromises.call(this,promise); }else{ this._schedule(function(){ promise._settlePromises(); }); } }; } function _drainQueue(queue){ while(queue.length()>0){ _drainQueueStep(queue); } } function _drainQueueStep(queue){ var fn=queue.shift(); if(typeof fn!=="function"){ fn._settlePromises(); }else{ var receiver=queue.shift(); var arg=queue.shift(); fn.call(receiver,arg); } } Async.prototype._drainQueues=function(){ _drainQueue(this._normalQueue); this._reset(); this._haveDrainedQueues=true; _drainQueue(this._lateQueue); }; Async.prototype._queueTick=function(){ if(!this._isTickUsed){ this._isTickUsed=true; this._schedule(this.drainQueues); } }; Async.prototype._reset=function(){ this._isTickUsed=false; }; module.exports=Async; module.exports.firstLineError=firstLineError; },{"./queue":26,"./schedule":29,"./util":36}],3:[function(_dereq_,module,exports){ "use strict"; module.exports=function(Promise,INTERNAL,tryConvertToPromise,debug){ var calledBind=false; var rejectThis=function rejectThis(_,e){ this._reject(e); }; var targetRejected=function targetRejected(e,context){ context.promiseRejectionQueued=true; context.bindingPromise._then(rejectThis,rejectThis,null,this,e); }; var bindingResolved=function bindingResolved(thisArg,context){ if((this._bitField&50397184)===0){ this._resolveCallback(context.target); } }; var bindingRejected=function bindingRejected(e,context){ if(!context.promiseRejectionQueued)this._reject(e); }; Promise.prototype.bind=function(thisArg){ if(!calledBind){ calledBind=true; Promise.prototype._propagateFrom=debug.propagateFromFunction(); Promise.prototype._boundValue=debug.boundValueFunction(); } var maybePromise=tryConvertToPromise(thisArg); var ret=new Promise(INTERNAL); ret._propagateFrom(this,1); var target=this._target(); ret._setBoundTo(maybePromise); if(maybePromise instanceof Promise){ var context={ promiseRejectionQueued:false, promise:ret, target:target, bindingPromise:maybePromise}; target._then(INTERNAL,targetRejected,undefined,ret,context); maybePromise._then( bindingResolved,bindingRejected,undefined,ret,context); ret._setOnCancel(maybePromise); }else{ ret._resolveCallback(target); } return ret; }; Promise.prototype._setBoundTo=function(obj){ if(obj!==undefined){ this._bitField=this._bitField|2097152; this._boundTo=obj; }else{ this._bitField=this._bitField&~2097152; } }; Promise.prototype._isBound=function(){ return(this._bitField&2097152)===2097152; }; Promise.bind=function(thisArg,value){ return Promise.resolve(value).bind(thisArg); }; }; },{}],4:[function(_dereq_,module,exports){ "use strict"; var old; if(typeof Promise!=="undefined")old=Promise; function noConflict(){ try{if(Promise===bluebird)Promise=old;} catch(e){} return bluebird; } var bluebird=_dereq_("./promise")(); bluebird.noConflict=noConflict; module.exports=bluebird; },{"./promise":22}],5:[function(_dereq_,module,exports){ "use strict"; var cr=Object.create; if(cr){ var callerCache=cr(null); var getterCache=cr(null); callerCache[" size"]=getterCache[" size"]=0; } module.exports=function(Promise){ var util=_dereq_("./util"); var canEvaluate=util.canEvaluate; var isIdentifier=util.isIdentifier; var getMethodCaller; var getGetter; if(!true){ var makeMethodCaller=function makeMethodCaller(methodName){ return new Function("ensureMethod"," \n\ return function(obj) { \n\ 'use strict' \n\ var len = this.length; \n\ ensureMethod(obj, 'methodName'); \n\ switch(len) { \n\ case 1: return obj.methodName(this[0]); \n\ case 2: return obj.methodName(this[0], this[1]); \n\ case 3: return obj.methodName(this[0], this[1], this[2]); \n\ case 0: return obj.methodName(); \n\ default: \n\ return obj.methodName.apply(obj, this); \n\ } \n\ }; \n\ ".replace(/methodName/g,methodName))(ensureMethod); }; var makeGetter=function makeGetter(propertyName){ return new Function("obj"," \n\ 'use strict'; \n\ return obj.propertyName; \n\ ".replace("propertyName",propertyName)); }; var getCompiled=function getCompiled(name,compiler,cache){ var ret=cache[name]; if(typeof ret!=="function"){ if(!isIdentifier(name)){ return null; } ret=compiler(name); cache[name]=ret; cache[" size"]++; if(cache[" size"]>512){ var keys=Object.keys(cache); for(var i=0;i<256;++i){delete cache[keys[i]];} cache[" size"]=keys.length-256; } } return ret; }; getMethodCaller=function getMethodCaller(name){ return getCompiled(name,makeMethodCaller,callerCache); }; getGetter=function getGetter(name){ return getCompiled(name,makeGetter,getterCache); }; } function ensureMethod(obj,methodName){ var fn; if(obj!=null)fn=obj[methodName]; if(typeof fn!=="function"){ var message="Object "+util.classString(obj)+" has no method '"+ util.toString(methodName)+"'"; throw new Promise.TypeError(message); } return fn; } function caller(obj){ var methodName=this.pop(); var fn=ensureMethod(obj,methodName); return fn.apply(obj,this); } Promise.prototype.call=function(methodName){ var args=[].slice.call(arguments,1);; if(!true){ if(canEvaluate){ var maybeCaller=getMethodCaller(methodName); if(maybeCaller!==null){ return this._then( maybeCaller,undefined,undefined,args,undefined); } } } args.push(methodName); return this._then(caller,undefined,undefined,args,undefined); }; function namedGetter(obj){ return obj[this]; } function indexedGetter(obj){ var index=+this; if(index<0)index=Math.max(0,index+obj.length); return obj[index]; } Promise.prototype.get=function(propertyName){ var isIndex=typeof propertyName==="number"; var getter; if(!isIndex){ if(canEvaluate){ var maybeGetter=getGetter(propertyName); getter=maybeGetter!==null?maybeGetter:namedGetter; }else{ getter=namedGetter; } }else{ getter=indexedGetter; } return this._then(getter,undefined,undefined,propertyName,undefined); }; }; },{"./util":36}],6:[function(_dereq_,module,exports){ "use strict"; module.exports=function(Promise,PromiseArray,apiRejection,debug){ var util=_dereq_("./util"); var tryCatch=util.tryCatch; var errorObj=util.errorObj; var async=Promise._async; Promise.prototype["break"]=Promise.prototype.cancel=function(){ if(!debug.cancellation())return this._warn("cancellation is disabled"); var promise=this; var child=promise; while(promise._isCancellable()){ if(!promise._cancelBy(child)){ if(child._isFollowing()){ child._followee().cancel(); }else{ child._cancelBranched(); } break; } var parent=promise._cancellationParent; if(parent==null||!parent._isCancellable()){ if(promise._isFollowing()){ promise._followee().cancel(); }else{ promise._cancelBranched(); } break; }else{ if(promise._isFollowing())promise._followee().cancel(); promise._setWillBeCancelled(); child=promise; promise=parent; } } }; Promise.prototype._branchHasCancelled=function(){ this._branchesRemainingToCancel--; }; Promise.prototype._enoughBranchesHaveCancelled=function(){ return this._branchesRemainingToCancel===undefined|| this._branchesRemainingToCancel<=0; }; Promise.prototype._cancelBy=function(canceller){ if(canceller===this){ this._branchesRemainingToCancel=0; this._invokeOnCancel(); return true; }else{ this._branchHasCancelled(); if(this._enoughBranchesHaveCancelled()){ this._invokeOnCancel(); return true; } } return false; }; Promise.prototype._cancelBranched=function(){ if(this._enoughBranchesHaveCancelled()){ this._cancel(); } }; Promise.prototype._cancel=function(){ if(!this._isCancellable())return; this._setCancelled(); async.invoke(this._cancelPromises,this,undefined); }; Promise.prototype._cancelPromises=function(){ if(this._length()>0)this._settlePromises(); }; Promise.prototype._unsetOnCancel=function(){ this._onCancelField=undefined; }; Promise.prototype._isCancellable=function(){ return this.isPending()&&!this._isCancelled(); }; Promise.prototype.isCancellable=function(){ return this.isPending()&&!this.isCancelled(); }; Promise.prototype._doInvokeOnCancel=function(onCancelCallback,internalOnly){ if(util.isArray(onCancelCallback)){ for(var i=0;i<onCancelCallback.length;++i){ this._doInvokeOnCancel(onCancelCallback[i],internalOnly); } }else if(onCancelCallback!==undefined){ if(typeof onCancelCallback==="function"){ if(!internalOnly){ var e=tryCatch(onCancelCallback).call(this._boundValue()); if(e===errorObj){ this._attachExtraTrace(e.e); async.throwLater(e.e); } } }else{ onCancelCallback._resultCancelled(this); } } }; Promise.prototype._invokeOnCancel=function(){ var onCancelCallback=this._onCancel(); this._unsetOnCancel(); async.invoke(this._doInvokeOnCancel,this,onCancelCallback); }; Promise.prototype._invokeInternalOnCancel=function(){ if(this._isCancellable()){ this._doInvokeOnCancel(this._onCancel(),true); this._unsetOnCancel(); } }; Promise.prototype._resultCancelled=function(){ this.cancel(); }; }; },{"./util":36}],7:[function(_dereq_,module,exports){ "use strict"; module.exports=function(NEXT_FILTER){ var util=_dereq_("./util"); var getKeys=_dereq_("./es5").keys; var tryCatch=util.tryCatch; var errorObj=util.errorObj; function catchFilter(instances,cb,promise){ return function(e){ var boundTo=promise._boundValue(); predicateLoop:for(var i=0;i<instances.length;++i){ var item=instances[i]; if(item===Error|| item!=null&&item.prototype instanceof Error){ if(e instanceof item){ return tryCatch(cb).call(boundTo,e); } }else if(typeof item==="function"){ var matchesPredicate=tryCatch(item).call(boundTo,e); if(matchesPredicate===errorObj){ return matchesPredicate; }else if(matchesPredicate){ return tryCatch(cb).call(boundTo,e); } }else if(util.isObject(e)){ var keys=getKeys(item); for(var j=0;j<keys.length;++j){ var key=keys[j]; if(item[key]!=e[key]){ continue predicateLoop; } } return tryCatch(cb).call(boundTo,e); } } return NEXT_FILTER; }; } return catchFilter; }; },{"./es5":13,"./util":36}],8:[function(_dereq_,module,exports){ "use strict"; module.exports=function(Promise){ var longStackTraces=false; var contextStack=[]; Promise.prototype._promiseCreated=function(){}; Promise.prototype._pushContext=function(){}; Promise.prototype._popContext=function(){return null;}; Promise._peekContext=Promise.prototype._peekContext=function(){}; function Context(){ this._trace=new Context.CapturedTrace(peekContext()); } Context.prototype._pushContext=function(){ if(this._trace!==undefined){ this._trace._promiseCreated=null; contextStack.push(this._trace); } }; Context.prototype._popContext=function(){ if(this._trace!==undefined){ var trace=contextStack.pop(); var ret=trace._promiseCreated; trace._promiseCreated=null; return ret; } return null; }; function createContext(){ if(longStackTraces)return new Context(); } function peekContext(){ var lastIndex=contextStack.length-1; if(lastIndex>=0){ return contextStack[lastIndex]; } return undefined; } Context.CapturedTrace=null; Context.create=createContext; Context.deactivateLongStackTraces=function(){}; Context.activateLongStackTraces=function(){ var Promise_pushContext=Promise.prototype._pushContext; var Promise_popContext=Promise.prototype._popContext; var Promise_PeekContext=Promise._peekContext; var Promise_peekContext=Promise.prototype._peekContext; var Promise_promiseCreated=Promise.prototype._promiseCreated; Context.deactivateLongStackTraces=function(){ Promise.prototype._pushContext=Promise_pushContext; Promise.prototype._popContext=Promise_popContext; Promise._peekContext=Promise_PeekContext; Promise.prototype._peekContext=Promise_peekContext; Promise.prototype._promiseCreated=Promise_promiseCreated; longStackTraces=false; }; longStackTraces=true; Promise.prototype._pushContext=Context.prototype._pushContext; Promise.prototype._popContext=Context.prototype._popContext; Promise._peekContext=Promise.prototype._peekContext=peekContext; Promise.prototype._promiseCreated=function(){ var ctx=this._peekContext(); if(ctx&&ctx._promiseCreated==null)ctx._promiseCreated=this; }; }; return Context; }; },{}],9:[function(_dereq_,module,exports){ "use strict"; module.exports=function(Promise,Context){ var getDomain=Promise._getDomain; var async=Promise._async; var Warning=_dereq_("./errors").Warning; var util=_dereq_("./util"); var es5=_dereq_("./es5"); var canAttachTrace=util.canAttachTrace; var unhandledRejectionHandled; var possiblyUnhandledRejection; var bluebirdFramePattern= /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/; var nodeFramePattern=/\((?:timers\.js):\d+:\d+\)/; var parseLinePattern=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/; var stackFramePattern=null; var formatStack=null; var indentStackFrames=false; var printWarning; var debugging=!!(util.env("BLUEBIRD_DEBUG")!=0&&( true|| util.env("BLUEBIRD_DEBUG")|| util.env("NODE_ENV")==="development")); var warnings=!!(util.env("BLUEBIRD_WARNINGS")!=0&&( debugging||util.env("BLUEBIRD_WARNINGS"))); var longStackTraces=!!(util.env("BLUEBIRD_LONG_STACK_TRACES")!=0&&( debugging||util.env("BLUEBIRD_LONG_STACK_TRACES"))); var wForgottenReturn=util.env("BLUEBIRD_W_FORGOTTEN_RETURN")!=0&&( warnings||!!util.env("BLUEBIRD_W_FORGOTTEN_RETURN")); Promise.prototype.suppressUnhandledRejections=function(){ var target=this._target(); target._bitField=target._bitField&~1048576| 524288; }; Promise.prototype._ensurePossibleRejectionHandled=function(){ if((this._bitField&524288)!==0)return; this._setRejectionIsUnhandled(); var self=this; setTimeout(function(){ self._notifyUnhandledRejection(); },1); }; Promise.prototype._notifyUnhandledRejectionIsHandled=function(){ fireRejectionEvent("rejectionHandled", unhandledRejectionHandled,undefined,this); }; Promise.prototype._setReturnedNonUndefined=function(){ this._bitField=this._bitField|268435456; }; Promise.prototype._returnedNonUndefined=function(){ return(this._bitField&268435456)!==0; }; Promise.prototype._notifyUnhandledRejection=function(){ if(this._isRejectionUnhandled()){ var reason=this._settledValue(); this._setUnhandledRejectionIsNotified(); fireRejectionEvent("unhandledRejection", possiblyUnhandledRejection,reason,this); } }; Promise.prototype._setUnhandledRejectionIsNotified=function(){ this._bitField=this._bitField|262144; }; Promise.prototype._unsetUnhandledRejectionIsNotified=function(){ this._bitField=this._bitField&~262144; }; Promise.prototype._isUnhandledRejectionNotified=function(){ return(this._bitField&262144)>0; }; Promise.prototype._setRejectionIsUnhandled=function(){ this._bitField=this._bitField|1048576; }; Promise.prototype._unsetRejectionIsUnhandled=function(){ this._bitField=this._bitField&~1048576; if(this._isUnhandledRejectionNotified()){ this._unsetUnhandledRejectionIsNotified(); this._notifyUnhandledRejectionIsHandled(); } }; Promise.prototype._isRejectionUnhandled=function(){ return(this._bitField&1048576)>0; }; Promise.prototype._warn=function(message,shouldUseOwnTrace,promise){ return warn(message,shouldUseOwnTrace,promise||this); }; Promise.onPossiblyUnhandledRejection=function(fn){ var domain=getDomain(); possiblyUnhandledRejection= typeof fn==="function"?domain===null? fn:util.domainBind(domain,fn): undefined; }; Promise.onUnhandledRejectionHandled=function(fn){ var domain=getDomain(); unhandledRejectionHandled= typeof fn==="function"?domain===null? fn:util.domainBind(domain,fn): undefined; }; var disableLongStackTraces=function disableLongStackTraces(){}; Promise.longStackTraces=function(){ if(async.haveItemsQueued()&&!config.longStackTraces){ throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n"); } if(!config.longStackTraces&&longStackTracesIsSupported()){ var Promise_captureStackTrace=Promise.prototype._captureStackTrace; var Promise_attachExtraTrace=Promise.prototype._attachExtraTrace; var Promise_dereferenceTrace=Promise.prototype._dereferenceTrace; config.longStackTraces=true; disableLongStackTraces=function disableLongStackTraces(){ if(async.haveItemsQueued()&&!config.longStackTraces){ throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n"); } Promise.prototype._captureStackTrace=Promise_captureStackTrace; Promise.prototype._attachExtraTrace=Promise_attachExtraTrace; Promise.prototype._dereferenceTrace=Promise_dereferenceTrace; Context.deactivateLongStackTraces(); async.enableTrampoline(); config.longStackTraces=false; }; Promise.prototype._captureStackTrace=longStackTracesCaptureStackTrace; Promise.prototype._attachExtraTrace=longStackTracesAttachExtraTrace; Promise.prototype._dereferenceTrace=longStackTracesDereferenceTrace; Context.activateLongStackTraces(); async.disableTrampolineIfNecessary(); } }; Promise.hasLongStackTraces=function(){ return config.longStackTraces&&longStackTracesIsSupported(); }; var fireDomEvent=function(){ try{ if(typeof CustomEvent==="function"){ var event=new CustomEvent("CustomEvent"); util.global.dispatchEvent(event); return function(name,event){ var eventData={ detail:event, cancelable:true}; es5.defineProperty( eventData,"promise",{value:event.promise}); es5.defineProperty(eventData,"reason",{value:event.reason}); var domEvent=new CustomEvent(name.toLowerCase(),eventData); return!util.global.dispatchEvent(domEvent); }; }else if(typeof Event==="function"){ var event=new Event("CustomEvent"); util.global.dispatchEvent(event); return function(name,event){ var domEvent=new Event(name.toLowerCase(),{ cancelable:true}); domEvent.detail=event; es5.defineProperty(domEvent,"promise",{value:event.promise}); es5.defineProperty(domEvent,"reason",{value:event.reason}); return!util.global.dispatchEvent(domEvent); }; }else{ var event=document.createEvent("CustomEvent"); event.initCustomEvent("testingtheevent",false,true,{}); util.global.dispatchEvent(event); return function(name,event){ var domEvent=document.createEvent("CustomEvent"); domEvent.initCustomEvent(name.toLowerCase(),false,true, event); return!util.global.dispatchEvent(domEvent); }; } }catch(e){} return function(){ return false; }; }(); var fireGlobalEvent=function(){ if(util.isNode){ return function(){ return process.emit.apply(process,arguments); }; }else{ if(!util.global){ return function(){ return false; }; } return function(name){ var methodName="on"+name.toLowerCase(); var method=util.global[methodName]; if(!method)return false; method.apply(util.global,[].slice.call(arguments,1)); return true; }; } }(); function generatePromiseLifecycleEventObject(name,promise){ return{promise:promise}; } var eventToObjectGenerator={ promiseCreated:generatePromiseLifecycleEventObject, promiseFulfilled:generatePromiseLifecycleEventObject, promiseRejected:generatePromiseLifecycleEventObject, promiseResolved:generatePromiseLifecycleEventObject, promiseCancelled:generatePromiseLifecycleEventObject, promiseChained:function promiseChained(name,promise,child){ return{promise:promise,child:child}; }, warning:function warning(name,_warning){ return{warning:_warning}; }, unhandledRejection:function unhandledRejection(name,reason,promise){ return{reason:reason,promise:promise}; }, rejectionHandled:generatePromiseLifecycleEventObject}; var activeFireEvent=function activeFireEvent(name){ var globalEventFired=false; try{ globalEventFired=fireGlobalEvent.apply(null,arguments); }catch(e){ async.throwLater(e); globalEventFired=true; } var domEventFired=false; try{ domEventFired=fireDomEvent(name, eventToObjectGenerator[name].apply(null,arguments)); }catch(e){ async.throwLater(e); domEventFired=true; } return domEventFired||globalEventFired; }; Promise.config=function(opts){ opts=Object(opts); if("longStackTraces"in opts){ if(opts.longStackTraces){ Promise.longStackTraces(); }else if(!opts.longStackTraces&&Promise.hasLongStackTraces()){ disableLongStackTraces(); } } if("warnings"in opts){ var warningsOption=opts.warnings; config.warnings=!!warningsOption; wForgottenReturn=config.warnings; if(util.isObject(warningsOption)){ if("wForgottenReturn"in warningsOption){ wForgottenReturn=!!warningsOption.wForgottenReturn; } } } if("cancellation"in opts&&opts.cancellation&&!config.cancellation){ if(async.haveItemsQueued()){ throw new Error( "cannot enable cancellation after promises are in use"); } Promise.prototype._clearCancellationData= cancellationClearCancellationData; Promise.prototype._propagateFrom=cancellationPropagateFrom; Promise.prototype._onCancel=cancellationOnCancel; Promise.prototype._setOnCancel=cancellationSetOnCancel; Promise.prototype._attachCancellationCallback= cancellationAttachCancellationCallback; Promise.prototype._execute=cancellationExecute; _propagateFromFunction=cancellationPropagateFrom; config.cancellation=true; } if("monitoring"in opts){ if(opts.monitoring&&!config.monitoring){ config.monitoring=true; Promise.prototype._fireEvent=activeFireEvent; }else if(!opts.monitoring&&config.monitoring){ config.monitoring=false; Promise.prototype._fireEvent=defaultFireEvent; } } return Promise; }; function defaultFireEvent(){return false;} Promise.prototype._fireEvent=defaultFireEvent; Promise.prototype._execute=function(executor,resolve,reject){ try{ executor(resolve,reject); }catch(e){ return e; } }; Promise.prototype._onCancel=function(){}; Promise.prototype._setOnCancel=function(handler){;}; Promise.prototype._attachCancellationCallback=function(onCancel){ ; }; Promise.prototype._captureStackTrace=function(){}; Promise.prototype._attachExtraTrace=function(){}; Promise.prototype._dereferenceTrace=function(){}; Promise.prototype._clearCancellationData=function(){}; Promise.prototype._propagateFrom=function(parent,flags){ ; ; }; function cancellationExecute(executor,resolve,reject){ var promise=this; try{ executor(resolve,reject,function(onCancel){ if(typeof onCancel!=="function"){ throw new TypeError("onCancel must be a function, got: "+ util.toString(onCancel)); } promise._attachCancellationCallback(onCancel); }); }catch(e){ return e; } } function cancellationAttachCancellationCallback(onCancel){ if(!this._isCancellable())return this; var previousOnCancel=this._onCancel(); if(previousOnCancel!==undefined){ if(util.isArray(previousOnCancel)){ previousOnCancel.push(onCancel); }else{ this._setOnCancel([previousOnCancel,onCancel]); } }else{ this._setOnCancel(onCancel); } } function cancellationOnCancel(){ return this._onCancelField; } function cancellationSetOnCancel(onCancel){ this._onCancelField=onCancel; } function cancellationClearCancellationData(){ this._cancellationParent=undefined; this._onCancelField=undefined; } function cancellationPropagateFrom(parent,flags){ if((flags&1)!==0){ this._cancellationParent=parent; var branchesRemainingToCancel=parent._branchesRemainingToCancel; if(branchesRemainingToCancel===undefined){ branchesRemainingToCancel=0; } parent._branchesRemainingToCancel=branchesRemainingToCancel+1; } if((flags&2)!==0&&parent._isBound()){ this._setBoundTo(parent._boundTo); } } function bindingPropagateFrom(parent,flags){ if((flags&2)!==0&&parent._isBound()){ this._setBoundTo(parent._boundTo); } } var _propagateFromFunction=bindingPropagateFrom; function _boundValueFunction(){ var ret=this._boundTo; if(ret!==undefined){ if(ret instanceof Promise){ if(ret.isFulfilled()){ return ret.value(); }else{ return undefined; } } } return ret; } function longStackTracesCaptureStackTrace(){ this._trace=new CapturedTrace(this._peekContext()); } function longStackTracesAttachExtraTrace(error,ignoreSelf){ if(canAttachTrace(error)){ var trace=this._trace; if(trace!==undefined){ if(ignoreSelf)trace=trace._parent; } if(trace!==undefined){ trace.attachExtraTrace(error); }else if(!error.__stackCleaned__){ var parsed=parseStackAndMessage(error); util.notEnumerableProp(error,"stack", parsed.message+"\n"+parsed.stack.join("\n")); util.notEnumerableProp(error,"__stackCleaned__",true); } } } function longStackTracesDereferenceTrace(){ this._trace=undefined; } function checkForgottenReturns(returnValue,promiseCreated,name,promise, parent){ if(returnValue===undefined&&promiseCreated!==null&& wForgottenReturn){ if(parent!==undefined&&parent._returnedNonUndefined())return; if((promise._bitField&65535)===0)return; if(name)name=name+" "; var handlerLine=""; var creatorLine=""; if(promiseCreated._trace){ var traceLines=promiseCreated._trace.stack.split("\n"); var stack=cleanStack(traceLines); for(var i=stack.length-1;i>=0;--i){ var line=stack[i]; if(!nodeFramePattern.test(line)){ var lineMatches=line.match(parseLinePattern); if(lineMatches){ handlerLine="at "+lineMatches[1]+ ":"+lineMatches[2]+":"+lineMatches[3]+" "; } break; } } if(stack.length>0){ var firstUserLine=stack[0]; for(var i=0;i<traceLines.length;++i){ if(traceLines[i]===firstUserLine){ if(i>0){ creatorLine="\n"+traceLines[i-1]; } break; } } } } var msg="a promise was created in a "+name+ "handler "+handlerLine+"but was not returned from it, "+ "see http://goo.gl/rRqMUw"+ creatorLine; promise._warn(msg,true,promiseCreated); } } function deprecated(name,replacement){ var message=name+ " is deprecated and will be removed in a future version."; if(replacement)message+=" Use "+replacement+" instead."; return warn(message); } function warn(message,shouldUseOwnTrace,promise){ if(!config.warnings)return; var warning=new Warning(message); var ctx; if(shouldUseOwnTrace){ promise._attachExtraTrace(warning); }else if(config.longStackTraces&&(ctx=Promise._peekContext())){ ctx.attachExtraTrace(warning); }else{ var parsed=parseStackAndMessage(warning); warning.stack=parsed.message+"\n"+parsed.stack.join("\n"); } if(!activeFireEvent("warning",warning)){ formatAndLogError(warning,"",true); } } function reconstructStack(message,stacks){ for(var i=0;i<stacks.length-1;++i){ stacks[i].push("From previous event:"); stacks[i]=stacks[i].join("\n"); } if(i<stacks.length){ stacks[i]=stacks[i].join("\n"); } return message+"\n"+stacks.join("\n"); } function removeDuplicateOrEmptyJumps(stacks){ for(var i=0;i<stacks.length;++i){ if(stacks[i].length===0|| i+1<stacks.length&&stacks[i][0]===stacks[i+1][0]){ stacks.splice(i,1); i--; } } } function removeCommonRoots(stacks){ var current=stacks[0]; for(var i=1;i<stacks.length;++i){ var prev=stacks[i]; var currentLastIndex=current.length-1; var currentLastLine=current[currentLastIndex]; var commonRootMeetPoint=-1; for(var j=prev.length-1;j>=0;--j){ if(prev[j]===currentLastLine){ commonRootMeetPoint=j; break; } } for(var j=commonRootMeetPoint;j>=0;--j){ var line=prev[j]; if(current[currentLastIndex]===line){ current.pop(); currentLastIndex--; }else{ break; } } current=prev; } } function cleanStack(stack){ var ret=[]; for(var i=0;i<stack.length;++i){ var line=stack[i]; var isTraceLine=" (No stack trace)"===line|| stackFramePattern.test(line); var isInternalFrame=isTraceLine&&shouldIgnore(line); if(isTraceLine&&!isInternalFrame){ if(indentStackFrames&&line.charAt(0)!==" "){ line=" "+line; } ret.push(line); } } return ret; } function stackFramesAsArray(error){ var stack=error.stack.replace(/\s+$/g,"").split("\n"); for(var i=0;i<stack.length;++i){ var line=stack[i]; if(" (No stack trace)"===line||stackFramePattern.test(line)){ break; } } if(i>0&&error.name!="SyntaxError"){ stack=stack.slice(i); } return stack; } function parseStackAndMessage(error){ var stack=error.stack; var message=error.toString(); stack=typeof stack==="string"&&stack.length>0? stackFramesAsArray(error):[" (No stack trace)"]; return{ message:message, stack:error.name=="SyntaxError"?stack:cleanStack(stack)}; } function formatAndLogError(error,title,isSoft){ if(typeof console!=="undefined"){ var message; if(util.isObject(error)){ var stack=error.stack; message=title+formatStack(stack,error); }else{ message=title+String(error); } if(typeof printWarning==="function"){ printWarning(message,isSoft); }else if(typeof console.log==="function"|| _typeof2(console.log)==="object"){ console.log(message); } } } function fireRejectionEvent(name,localHandler,reason,promise){ var localEventFired=false; try{ if(typeof localHandler==="function"){ localEventFired=true; if(name==="rejectionHandled"){ localHandler(promise); }else{ localHandler(reason,promise); } } }catch(e){ async.throwLater(e); } if(name==="unhandledRejection"){ if(!activeFireEvent(name,reason,promise)&&!localEventFired){ formatAndLogError(reason,"Unhandled rejection "); } }else{ activeFireEvent(name,promise); } } function formatNonError(obj){ var str; if(typeof obj==="function"){ str="[function "+( obj.name||"anonymous")+ "]"; }else{ str=obj&&typeof obj.toString==="function"? obj.toString():util.toString(obj); var ruselessToString=/\[object [a-zA-Z0-9$_]+\]/; if(ruselessToString.test(str)){ try{ var newStr=JSON.stringify(obj); str=newStr; } catch(e){ } } if(str.length===0){ str="(empty array)"; } } return"(<"+snip(str)+">, no stack trace)"; } function snip(str){ var maxChars=41; if(str.length<maxChars){ return str; } return str.substr(0,maxChars-3)+"..."; } function longStackTracesIsSupported(){ return typeof captureStackTrace==="function"; } var shouldIgnore=function shouldIgnore(){return false;}; var parseLineInfoRegex=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/; function parseLineInfo(line){ var matches=line.match(parseLineInfoRegex); if(matches){ return{ fileName:matches[1], line:parseInt(matches[2],10)}; } } function setBounds(firstLineError,lastLineError){ if(!longStackTracesIsSupported())return; var firstStackLines=firstLineError.stack.split("\n"); var lastStackLines=lastLineError.stack.split("\n"); var firstIndex=-1; var lastIndex=-1; var firstFileName; var lastFileName; for(var i=0;i<firstStackLines.length;++i){ var result=parseLineInfo(firstStackLines[i]); if(result){ firstFileName=result.fileName; firstIndex=result.line; break; } } for(var i=0;i<lastStackLines.length;++i){ var result=parseLineInfo(lastStackLines[i]); if(result){ lastFileName=result.fileName; lastIndex=result.line; break; } } if(firstIndex<0||lastIndex<0||!firstFileName||!lastFileName|| firstFileName!==lastFileName||firstIndex>=lastIndex){ return; } shouldIgnore=function shouldIgnore(line){ if(bluebirdFramePattern.test(line))return true; var info=parseLineInfo(line); if(info){ if(info.fileName===firstFileName&& firstIndex<=info.line&&info.line<=lastIndex){ return true; } } return false; }; } function CapturedTrace(parent){ this._parent=parent; this._promisesCreated=0; var length=this._length=1+(parent===undefined?0:parent._length); captureStackTrace(this,CapturedTrace); if(length>32)this.uncycle(); } util.inherits(CapturedTrace,Error); Context.CapturedTrace=CapturedTrace; CapturedTrace.prototype.uncycle=function(){ var length=this._length; if(length<2)return; var nodes=[]; var stackToIndex={}; for(var i=0,node=this;node!==undefined;++i){ nodes.push(node); node=node._parent; } length=this._length=i; for(var i=length-1;i>=0;--i){ var stack=nodes[i].stack; if(stackToIndex[stack]===undefined){ stackToIndex[stack]=i; } } for(var i=0;i<length;++i){ var currentStack=nodes[i].stack; var index=stackToIndex[currentStack]; if(index!==undefined&&index!==i){ if(index>0){ nodes[index-1]._parent=undefined; nodes[index-1]._length=1; } nodes[i]._parent=undefined; nodes[i]._length=1; var cycleEdgeNode=i>0?nodes[i-1]:this; if(index<length-1){ cycleEdgeNode._parent=nodes[index+1]; cycleEdgeNode._parent.uncycle(); cycleEdgeNode._length= cycleEdgeNode._parent._length+1; }else{ cycleEdgeNode._parent=undefined; cycleEdgeNode._length=1; } var currentChildLength=cycleEdgeNode._length+1; for(var j=i-2;j>=0;--j){ nodes[j]._length=currentChildLength; currentChildLength++; } return; } } }; CapturedTrace.prototype.attachExtraTrace=function(error){ if(error.__stackCleaned__)return; this.uncycle(); var parsed=parseStackAndMessage(error); var message=parsed.message; var stacks=[parsed.stack]; var trace=this; while(trace!==undefined){ stacks.push(cleanStack(trace.stack.split("\n"))); trace=trace._parent; } removeCommonRoots(stacks); removeDuplicateOrEmptyJumps(stacks); util.notEnumerableProp(error,"stack",reconstructStack(message,stacks)); util.notEnumerableProp(error,"__stackCleaned__",true); }; var captureStackTrace=function stackDetection(){ var v8stackFramePattern=/^\s*at\s*/; var v8stackFormatter=function v8stackFormatter(stack,error){ if(typeof stack==="string")return stack; if(error.name!==undefined&& error.message!==undefined){ return error.toString(); } return formatNonError(error); }; if(typeof Error.stackTraceLimit==="number"&& typeof Error.captureStackTrace==="function"){ Error.stackTraceLimit+=6; stackFramePattern=v8stackFramePattern; formatStack=v8stackFormatter; var captureStackTrace=Error.captureStackTrace; shouldIgnore=function shouldIgnore(line){ return bluebirdFramePattern.test(line); }; return function(receiver,ignoreUntil){ Error.stackTraceLimit+=6; captureStackTrace(receiver,ignoreUntil); Error.stackTraceLimit-=6; }; } var err=new Error(); if(typeof err.stack==="string"&& err.stack.split("\n")[0].indexOf("stackDetection@")>=0){ stackFramePattern=/@/; formatStack=v8stackFormatter; indentStackFrames=true; return function captureStackTrace(o){ o.stack=new Error().stack; }; } var hasStackAfterThrow; try{throw new Error();} catch(e){ hasStackAfterThrow="stack"in e; } if(!("stack"in err)&&hasStackAfterThrow&& typeof Error.stackTraceLimit==="number"){ stackFramePattern=v8stackFramePattern; formatStack=v8stackFormatter; return function captureStackTrace(o){ Error.stackTraceLimit+=6; try{throw new Error();} catch(e){o.stack=e.stack;} Error.stackTraceLimit-=6; }; } formatStack=function formatStack(stack,error){ if(typeof stack==="string")return stack; if(((typeof error==="undefined"?"undefined":_typeof2(error))==="object"|| typeof error==="function")&& error.name!==undefined&& error.message!==undefined){ return error.toString(); } return formatNonError(error); }; return null; }([]); if(typeof console!=="undefined"&&typeof console.warn!=="undefined"){ printWarning=function printWarning(message){ console.warn(message); }; if(util.isNode&&process.stderr.isTTY){ printWarning=function printWarning(message,isSoft){ var color=isSoft?"\x1B[33m":"\x1B[31m"; console.warn(color+message+"\x1B[0m\n"); }; }else if(!util.isNode&&typeof new Error().stack==="string"){ printWarning=function printWarning(message,isSoft){ console.warn("%c"+message, isSoft?"color: darkorange":"color: red"); }; } } var config={ warnings:warnings, longStackTraces:false, cancellation:false, monitoring:false}; if(longStackTraces)Promise.longStackTraces(); return{ longStackTraces:function longStackTraces(){ return config.longStackTraces; }, warnings:function warnings(){ return config.warnings; }, cancellation:function cancellation(){ return config.cancellation; }, monitoring:function monitoring(){ return config.monitoring; }, propagateFromFunction:function propagateFromFunction(){ return _propagateFromFunction; }, boundValueFunction:function boundValueFunction(){ return _boundValueFunction; }, checkForgottenReturns:checkForgottenReturns, setBounds:setBounds, warn:warn, deprecated:deprecated, CapturedTrace:CapturedTrace, fireDomEvent:fireDomEvent, fireGlobalEvent:fireGlobalEvent}; }; },{"./errors":12,"./es5":13,"./util":36}],10:[function(_dereq_,module,exports){ "use strict"; module.exports=function(Promise){ function returner(){ return this.value; } function thrower(){ throw this.reason; } Promise.prototype["return"]= Promise.prototype.thenReturn=function(value){ if(value instanceof Promise)value.suppressUnhandledRejections(); return this._then( returner,undefined,undefined,{value:value},undefined); }; Promise.prototype["throw"]= Promise.prototype.thenThrow=function(reason){ return this._then( thrower,undefined,undefined,{reason:reason},undefined); }; Promise.prototype.catchThrow=function(reason){ if(arguments.length<=1){ return this._then( undefined,thrower,undefined,{reason:reason},undefined); }else{ var _reason=arguments[1]; var handler=function handler(){throw _reason;}; return this.caught(reason,handler); } }; Promise.prototype.catchReturn=function(value){ if(arguments.length<=1){ if(value instanceof Promise)value.suppressUnhandledRejections(); return this._then( undefined,returner,undefined,{value:value},undefined); }else{ var _value=arguments[1]; if(_value instanceof Promise)_value.suppressUnhandledRejections(); var handler=function handler(){return _value;}; return this.caught(value,handler); } }; }; },{}],11:[function(_dereq_,module,exports){ "use strict"; module.exports=function(Promise,INTERNAL){ var PromiseReduce=Promise.reduce; var PromiseAll=Promise.all; function promiseAllThis(){ return PromiseAll(this); } function PromiseMapSeries(promises,fn){ return PromiseReduce(promises,fn,INTERNAL,INTERNAL); } Promise.prototype.each=function(fn){ return PromiseReduce(this,fn,INTERNAL,0). _then(promiseAllThis,undefined,undefined,this,undefined); }; Promise.prototype.mapSeries=function(fn){ return PromiseReduce(this,fn,INTERNAL,INTERNAL); }; Promise.each=function(promises,fn){ return PromiseReduce(promises,fn,INTERNAL,0). _then(promiseAllThis,undefined,undefined,promises,undefined); }; Promise.mapSeries=PromiseMapSeries; }; },{}],12:[function(_dereq_,module,exports){ "use strict"; var es5=_dereq_("./es5"); var Objectfreeze=es5.freeze; var util=_dereq_("./util"); var inherits=util.inherits; var notEnumerableProp=util.notEnumerableProp; function subError(nameProperty,defaultMessage){ function SubError(message){ if(!(this instanceof SubError))return new SubError(message); notEnumerableProp(this,"message", typeof message==="string"?message:defaultMessage); notEnumerableProp(this,"name",nameProperty); if(Error.captureStackTrace){ Error.captureStackTrace(this,this.constructor); }else{ Error.call(this); } } inherits(SubError,Error); return SubError; } var _TypeError,_RangeError; var Warning=subError("Warning","warning"); var CancellationError=subError("CancellationError","cancellation error"); var TimeoutError=subError("TimeoutError","timeout error"); var AggregateError=subError("AggregateError","aggregate error"); try{ _TypeError=TypeError; _RangeError=RangeError; }catch(e){ _TypeError=subError("TypeError","type error"); _RangeError=subError("RangeError","range error"); } var methods=("join pop push shift unshift slice filter forEach some "+ "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" "); for(var i=0;i<methods.length;++i){ if(typeof Array.prototype[methods[i]]==="function"){ AggregateError.prototype[methods[i]]=Array.prototype[methods[i]]; } } es5.defineProperty(AggregateError.prototype,"length",{ value:0, configurable:false, writable:true, enumerable:true}); AggregateError.prototype["isOperational"]=true; var level=0; AggregateError.prototype.toString=function(){ var indent=Array(level*4+1).join(" "); var ret="\n"+indent+"AggregateError of:"+"\n"; level++; indent=Array(level*4+1).join(" "); for(var i=0;i<this.length;++i){ var str=this[i]===this?"[Circular AggregateError]":this[i]+""; var lines=str.split("\n"); for(var j=0;j<lines.length;++j){ lines[j]=indent+lines[j]; } str=lines.join("\n"); ret+=str+"\n"; } level--; return ret; }; function OperationalError(message){ if(!(this instanceof OperationalError)) return new OperationalError(message); notEnumerableProp(this,"name","OperationalError"); notEnumerableProp(this,"message",message); this.cause=message; this["isOperational"]=true; if(message instanceof Error){ notEnumerableProp(this,"message",message.message); notEnumerableProp(this,"stack",message.stack); }else if(Error.captureStackTrace){ Error.captureStackTrace(this,this.constructor); } } inherits(OperationalError,Error); var errorTypes=Error["__BluebirdErrorTypes__"]; if(!errorTypes){ errorTypes=Objectfreeze({ CancellationError:CancellationError, TimeoutError:TimeoutError, OperationalError:OperationalError, RejectionError:OperationalError, AggregateError:AggregateError}); es5.defineProperty(Error,"__BluebirdErrorTypes__",{ value:errorTypes, writable:false, enumerable:false, configurable:false}); } module.exports={ Error:Error, TypeError:_TypeError, RangeError:_RangeError, CancellationError:errorTypes.CancellationError, OperationalError:errorTypes.OperationalError, TimeoutError:errorTypes.TimeoutError, AggregateError:errorTypes.AggregateError, Warning:Warning}; },{"./es5":13,"./util":36}],13:[function(_dereq_,module,exports){ var isES5=function(){ "use strict"; return this===undefined; }(); if(isES5){ module.exports={ freeze:Object.freeze, defineProperty:Object.definePrope