lofig.min.js 241 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ var parentHotUpdateCallback = this["webpackHotUpdate"];
  3. /******/ this["webpackHotUpdate"] =
  4. /******/ function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
  5. /******/ hotAddUpdateChunk(chunkId, moreModules);
  6. /******/ if(parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules);
  7. /******/ }
  8. /******/
  9. /******/ function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars
  10. /******/ var head = document.getElementsByTagName("head")[0];
  11. /******/ var script = document.createElement("script");
  12. /******/ script.type = "text/javascript";
  13. /******/ script.charset = "utf-8";
  14. /******/ script.src = __webpack_require__.p + "" + chunkId + "." + hotCurrentHash + ".hot-update.js";
  15. /******/ head.appendChild(script);
  16. /******/ }
  17. /******/
  18. /******/ function hotDownloadManifest(callback) { // eslint-disable-line no-unused-vars
  19. /******/ if(typeof XMLHttpRequest === "undefined")
  20. /******/ return callback(new Error("No browser support"));
  21. /******/ try {
  22. /******/ var request = new XMLHttpRequest();
  23. /******/ var requestPath = __webpack_require__.p + "" + hotCurrentHash + ".hot-update.json";
  24. /******/ request.open("GET", requestPath, true);
  25. /******/ request.timeout = 10000;
  26. /******/ request.send(null);
  27. /******/ } catch(err) {
  28. /******/ return callback(err);
  29. /******/ }
  30. /******/ request.onreadystatechange = function() {
  31. /******/ if(request.readyState !== 4) return;
  32. /******/ if(request.status === 0) {
  33. /******/ // timeout
  34. /******/ callback(new Error("Manifest request to " + requestPath + " timed out."));
  35. /******/ } else if(request.status === 404) {
  36. /******/ // no update available
  37. /******/ callback();
  38. /******/ } else if(request.status !== 200 && request.status !== 304) {
  39. /******/ // other failure
  40. /******/ callback(new Error("Manifest request to " + requestPath + " failed."));
  41. /******/ } else {
  42. /******/ // success
  43. /******/ try {
  44. /******/ var update = JSON.parse(request.responseText);
  45. /******/ } catch(e) {
  46. /******/ callback(e);
  47. /******/ return;
  48. /******/ }
  49. /******/ callback(null, update);
  50. /******/ }
  51. /******/ };
  52. /******/ }
  53. /******/
  54. /******/
  55. /******/ // Copied from https://github.com/facebook/react/blob/bef45b0/src/shared/utils/canDefineProperty.js
  56. /******/ var canDefineProperty = false;
  57. /******/ try {
  58. /******/ Object.defineProperty({}, "x", {
  59. /******/ get: function() {}
  60. /******/ });
  61. /******/ canDefineProperty = true;
  62. /******/ } catch(x) {
  63. /******/ // IE will fail on defineProperty
  64. /******/ }
  65. /******/
  66. /******/ var hotApplyOnUpdate = true;
  67. /******/ var hotCurrentHash = "de2d345adf580af29a40"; // eslint-disable-line no-unused-vars
  68. /******/ var hotCurrentModuleData = {};
  69. /******/ var hotCurrentParents = []; // eslint-disable-line no-unused-vars
  70. /******/
  71. /******/ function hotCreateRequire(moduleId) { // eslint-disable-line no-unused-vars
  72. /******/ var me = installedModules[moduleId];
  73. /******/ if(!me) return __webpack_require__;
  74. /******/ var fn = function(request) {
  75. /******/ if(me.hot.active) {
  76. /******/ if(installedModules[request]) {
  77. /******/ if(installedModules[request].parents.indexOf(moduleId) < 0)
  78. /******/ installedModules[request].parents.push(moduleId);
  79. /******/ if(me.children.indexOf(request) < 0)
  80. /******/ me.children.push(request);
  81. /******/ } else hotCurrentParents = [moduleId];
  82. /******/ } else {
  83. /******/ console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
  84. /******/ hotCurrentParents = [];
  85. /******/ }
  86. /******/ return __webpack_require__(request);
  87. /******/ };
  88. /******/ for(var name in __webpack_require__) {
  89. /******/ if(Object.prototype.hasOwnProperty.call(__webpack_require__, name)) {
  90. /******/ if(canDefineProperty) {
  91. /******/ Object.defineProperty(fn, name, (function(name) {
  92. /******/ return {
  93. /******/ configurable: true,
  94. /******/ enumerable: true,
  95. /******/ get: function() {
  96. /******/ return __webpack_require__[name];
  97. /******/ },
  98. /******/ set: function(value) {
  99. /******/ __webpack_require__[name] = value;
  100. /******/ }
  101. /******/ };
  102. /******/ }(name)));
  103. /******/ } else {
  104. /******/ fn[name] = __webpack_require__[name];
  105. /******/ }
  106. /******/ }
  107. /******/ }
  108. /******/
  109. /******/ function ensure(chunkId, callback) {
  110. /******/ if(hotStatus === "ready")
  111. /******/ hotSetStatus("prepare");
  112. /******/ hotChunksLoading++;
  113. /******/ __webpack_require__.e(chunkId, function() {
  114. /******/ try {
  115. /******/ callback.call(null, fn);
  116. /******/ } finally {
  117. /******/ finishChunkLoading();
  118. /******/ }
  119. /******/
  120. /******/ function finishChunkLoading() {
  121. /******/ hotChunksLoading--;
  122. /******/ if(hotStatus === "prepare") {
  123. /******/ if(!hotWaitingFilesMap[chunkId]) {
  124. /******/ hotEnsureUpdateChunk(chunkId);
  125. /******/ }
  126. /******/ if(hotChunksLoading === 0 && hotWaitingFiles === 0) {
  127. /******/ hotUpdateDownloaded();
  128. /******/ }
  129. /******/ }
  130. /******/ }
  131. /******/ });
  132. /******/ }
  133. /******/ if(canDefineProperty) {
  134. /******/ Object.defineProperty(fn, "e", {
  135. /******/ enumerable: true,
  136. /******/ value: ensure
  137. /******/ });
  138. /******/ } else {
  139. /******/ fn.e = ensure;
  140. /******/ }
  141. /******/ return fn;
  142. /******/ }
  143. /******/
  144. /******/ function hotCreateModule(moduleId) { // eslint-disable-line no-unused-vars
  145. /******/ var hot = {
  146. /******/ // private stuff
  147. /******/ _acceptedDependencies: {},
  148. /******/ _declinedDependencies: {},
  149. /******/ _selfAccepted: false,
  150. /******/ _selfDeclined: false,
  151. /******/ _disposeHandlers: [],
  152. /******/
  153. /******/ // Module API
  154. /******/ active: true,
  155. /******/ accept: function(dep, callback) {
  156. /******/ if(typeof dep === "undefined")
  157. /******/ hot._selfAccepted = true;
  158. /******/ else if(typeof dep === "function")
  159. /******/ hot._selfAccepted = dep;
  160. /******/ else if(typeof dep === "object")
  161. /******/ for(var i = 0; i < dep.length; i++)
  162. /******/ hot._acceptedDependencies[dep[i]] = callback;
  163. /******/ else
  164. /******/ hot._acceptedDependencies[dep] = callback;
  165. /******/ },
  166. /******/ decline: function(dep) {
  167. /******/ if(typeof dep === "undefined")
  168. /******/ hot._selfDeclined = true;
  169. /******/ else if(typeof dep === "number")
  170. /******/ hot._declinedDependencies[dep] = true;
  171. /******/ else
  172. /******/ for(var i = 0; i < dep.length; i++)
  173. /******/ hot._declinedDependencies[dep[i]] = true;
  174. /******/ },
  175. /******/ dispose: function(callback) {
  176. /******/ hot._disposeHandlers.push(callback);
  177. /******/ },
  178. /******/ addDisposeHandler: function(callback) {
  179. /******/ hot._disposeHandlers.push(callback);
  180. /******/ },
  181. /******/ removeDisposeHandler: function(callback) {
  182. /******/ var idx = hot._disposeHandlers.indexOf(callback);
  183. /******/ if(idx >= 0) hot._disposeHandlers.splice(idx, 1);
  184. /******/ },
  185. /******/
  186. /******/ // Management API
  187. /******/ check: hotCheck,
  188. /******/ apply: hotApply,
  189. /******/ status: function(l) {
  190. /******/ if(!l) return hotStatus;
  191. /******/ hotStatusHandlers.push(l);
  192. /******/ },
  193. /******/ addStatusHandler: function(l) {
  194. /******/ hotStatusHandlers.push(l);
  195. /******/ },
  196. /******/ removeStatusHandler: function(l) {
  197. /******/ var idx = hotStatusHandlers.indexOf(l);
  198. /******/ if(idx >= 0) hotStatusHandlers.splice(idx, 1);
  199. /******/ },
  200. /******/
  201. /******/ //inherit from previous dispose call
  202. /******/ data: hotCurrentModuleData[moduleId]
  203. /******/ };
  204. /******/ return hot;
  205. /******/ }
  206. /******/
  207. /******/ var hotStatusHandlers = [];
  208. /******/ var hotStatus = "idle";
  209. /******/
  210. /******/ function hotSetStatus(newStatus) {
  211. /******/ hotStatus = newStatus;
  212. /******/ for(var i = 0; i < hotStatusHandlers.length; i++)
  213. /******/ hotStatusHandlers[i].call(null, newStatus);
  214. /******/ }
  215. /******/
  216. /******/ // while downloading
  217. /******/ var hotWaitingFiles = 0;
  218. /******/ var hotChunksLoading = 0;
  219. /******/ var hotWaitingFilesMap = {};
  220. /******/ var hotRequestedFilesMap = {};
  221. /******/ var hotAvailibleFilesMap = {};
  222. /******/ var hotCallback;
  223. /******/
  224. /******/ // The update info
  225. /******/ var hotUpdate, hotUpdateNewHash;
  226. /******/
  227. /******/ function toModuleId(id) {
  228. /******/ var isNumber = (+id) + "" === id;
  229. /******/ return isNumber ? +id : id;
  230. /******/ }
  231. /******/
  232. /******/ function hotCheck(apply, callback) {
  233. /******/ if(hotStatus !== "idle") throw new Error("check() is only allowed in idle status");
  234. /******/ if(typeof apply === "function") {
  235. /******/ hotApplyOnUpdate = false;
  236. /******/ callback = apply;
  237. /******/ } else {
  238. /******/ hotApplyOnUpdate = apply;
  239. /******/ callback = callback || function(err) {
  240. /******/ if(err) throw err;
  241. /******/ };
  242. /******/ }
  243. /******/ hotSetStatus("check");
  244. /******/ hotDownloadManifest(function(err, update) {
  245. /******/ if(err) return callback(err);
  246. /******/ if(!update) {
  247. /******/ hotSetStatus("idle");
  248. /******/ callback(null, null);
  249. /******/ return;
  250. /******/ }
  251. /******/
  252. /******/ hotRequestedFilesMap = {};
  253. /******/ hotAvailibleFilesMap = {};
  254. /******/ hotWaitingFilesMap = {};
  255. /******/ for(var i = 0; i < update.c.length; i++)
  256. /******/ hotAvailibleFilesMap[update.c[i]] = true;
  257. /******/ hotUpdateNewHash = update.h;
  258. /******/
  259. /******/ hotSetStatus("prepare");
  260. /******/ hotCallback = callback;
  261. /******/ hotUpdate = {};
  262. /******/ var chunkId = 0;
  263. /******/ { // eslint-disable-line no-lone-blocks
  264. /******/ /*globals chunkId */
  265. /******/ hotEnsureUpdateChunk(chunkId);
  266. /******/ }
  267. /******/ if(hotStatus === "prepare" && hotChunksLoading === 0 && hotWaitingFiles === 0) {
  268. /******/ hotUpdateDownloaded();
  269. /******/ }
  270. /******/ });
  271. /******/ }
  272. /******/
  273. /******/ function hotAddUpdateChunk(chunkId, moreModules) { // eslint-disable-line no-unused-vars
  274. /******/ if(!hotAvailibleFilesMap[chunkId] || !hotRequestedFilesMap[chunkId])
  275. /******/ return;
  276. /******/ hotRequestedFilesMap[chunkId] = false;
  277. /******/ for(var moduleId in moreModules) {
  278. /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
  279. /******/ hotUpdate[moduleId] = moreModules[moduleId];
  280. /******/ }
  281. /******/ }
  282. /******/ if(--hotWaitingFiles === 0 && hotChunksLoading === 0) {
  283. /******/ hotUpdateDownloaded();
  284. /******/ }
  285. /******/ }
  286. /******/
  287. /******/ function hotEnsureUpdateChunk(chunkId) {
  288. /******/ if(!hotAvailibleFilesMap[chunkId]) {
  289. /******/ hotWaitingFilesMap[chunkId] = true;
  290. /******/ } else {
  291. /******/ hotRequestedFilesMap[chunkId] = true;
  292. /******/ hotWaitingFiles++;
  293. /******/ hotDownloadUpdateChunk(chunkId);
  294. /******/ }
  295. /******/ }
  296. /******/
  297. /******/ function hotUpdateDownloaded() {
  298. /******/ hotSetStatus("ready");
  299. /******/ var callback = hotCallback;
  300. /******/ hotCallback = null;
  301. /******/ if(!callback) return;
  302. /******/ if(hotApplyOnUpdate) {
  303. /******/ hotApply(hotApplyOnUpdate, callback);
  304. /******/ } else {
  305. /******/ var outdatedModules = [];
  306. /******/ for(var id in hotUpdate) {
  307. /******/ if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
  308. /******/ outdatedModules.push(toModuleId(id));
  309. /******/ }
  310. /******/ }
  311. /******/ callback(null, outdatedModules);
  312. /******/ }
  313. /******/ }
  314. /******/
  315. /******/ function hotApply(options, callback) {
  316. /******/ if(hotStatus !== "ready") throw new Error("apply() is only allowed in ready status");
  317. /******/ if(typeof options === "function") {
  318. /******/ callback = options;
  319. /******/ options = {};
  320. /******/ } else if(options && typeof options === "object") {
  321. /******/ callback = callback || function(err) {
  322. /******/ if(err) throw err;
  323. /******/ };
  324. /******/ } else {
  325. /******/ options = {};
  326. /******/ callback = callback || function(err) {
  327. /******/ if(err) throw err;
  328. /******/ };
  329. /******/ }
  330. /******/
  331. /******/ function getAffectedStuff(module) {
  332. /******/ var outdatedModules = [module];
  333. /******/ var outdatedDependencies = {};
  334. /******/
  335. /******/ var queue = outdatedModules.slice();
  336. /******/ while(queue.length > 0) {
  337. /******/ var moduleId = queue.pop();
  338. /******/ var module = installedModules[moduleId];
  339. /******/ if(!module || module.hot._selfAccepted)
  340. /******/ continue;
  341. /******/ if(module.hot._selfDeclined) {
  342. /******/ return new Error("Aborted because of self decline: " + moduleId);
  343. /******/ }
  344. /******/ if(moduleId === 0) {
  345. /******/ return;
  346. /******/ }
  347. /******/ for(var i = 0; i < module.parents.length; i++) {
  348. /******/ var parentId = module.parents[i];
  349. /******/ var parent = installedModules[parentId];
  350. /******/ if(parent.hot._declinedDependencies[moduleId]) {
  351. /******/ return new Error("Aborted because of declined dependency: " + moduleId + " in " + parentId);
  352. /******/ }
  353. /******/ if(outdatedModules.indexOf(parentId) >= 0) continue;
  354. /******/ if(parent.hot._acceptedDependencies[moduleId]) {
  355. /******/ if(!outdatedDependencies[parentId])
  356. /******/ outdatedDependencies[parentId] = [];
  357. /******/ addAllToSet(outdatedDependencies[parentId], [moduleId]);
  358. /******/ continue;
  359. /******/ }
  360. /******/ delete outdatedDependencies[parentId];
  361. /******/ outdatedModules.push(parentId);
  362. /******/ queue.push(parentId);
  363. /******/ }
  364. /******/ }
  365. /******/
  366. /******/ return [outdatedModules, outdatedDependencies];
  367. /******/ }
  368. /******/
  369. /******/ function addAllToSet(a, b) {
  370. /******/ for(var i = 0; i < b.length; i++) {
  371. /******/ var item = b[i];
  372. /******/ if(a.indexOf(item) < 0)
  373. /******/ a.push(item);
  374. /******/ }
  375. /******/ }
  376. /******/
  377. /******/ // at begin all updates modules are outdated
  378. /******/ // the "outdated" status can propagate to parents if they don't accept the children
  379. /******/ var outdatedDependencies = {};
  380. /******/ var outdatedModules = [];
  381. /******/ var appliedUpdate = {};
  382. /******/ for(var id in hotUpdate) {
  383. /******/ if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
  384. /******/ var moduleId = toModuleId(id);
  385. /******/ var result = getAffectedStuff(moduleId);
  386. /******/ if(!result) {
  387. /******/ if(options.ignoreUnaccepted)
  388. /******/ continue;
  389. /******/ hotSetStatus("abort");
  390. /******/ return callback(new Error("Aborted because " + moduleId + " is not accepted"));
  391. /******/ }
  392. /******/ if(result instanceof Error) {
  393. /******/ hotSetStatus("abort");
  394. /******/ return callback(result);
  395. /******/ }
  396. /******/ appliedUpdate[moduleId] = hotUpdate[moduleId];
  397. /******/ addAllToSet(outdatedModules, result[0]);
  398. /******/ for(var moduleId in result[1]) {
  399. /******/ if(Object.prototype.hasOwnProperty.call(result[1], moduleId)) {
  400. /******/ if(!outdatedDependencies[moduleId])
  401. /******/ outdatedDependencies[moduleId] = [];
  402. /******/ addAllToSet(outdatedDependencies[moduleId], result[1][moduleId]);
  403. /******/ }
  404. /******/ }
  405. /******/ }
  406. /******/ }
  407. /******/
  408. /******/ // Store self accepted outdated modules to require them later by the module system
  409. /******/ var outdatedSelfAcceptedModules = [];
  410. /******/ for(var i = 0; i < outdatedModules.length; i++) {
  411. /******/ var moduleId = outdatedModules[i];
  412. /******/ if(installedModules[moduleId] && installedModules[moduleId].hot._selfAccepted)
  413. /******/ outdatedSelfAcceptedModules.push({
  414. /******/ module: moduleId,
  415. /******/ errorHandler: installedModules[moduleId].hot._selfAccepted
  416. /******/ });
  417. /******/ }
  418. /******/
  419. /******/ // Now in "dispose" phase
  420. /******/ hotSetStatus("dispose");
  421. /******/ var queue = outdatedModules.slice();
  422. /******/ while(queue.length > 0) {
  423. /******/ var moduleId = queue.pop();
  424. /******/ var module = installedModules[moduleId];
  425. /******/ if(!module) continue;
  426. /******/
  427. /******/ var data = {};
  428. /******/
  429. /******/ // Call dispose handlers
  430. /******/ var disposeHandlers = module.hot._disposeHandlers;
  431. /******/ for(var j = 0; j < disposeHandlers.length; j++) {
  432. /******/ var cb = disposeHandlers[j];
  433. /******/ cb(data);
  434. /******/ }
  435. /******/ hotCurrentModuleData[moduleId] = data;
  436. /******/
  437. /******/ // disable module (this disables requires from this module)
  438. /******/ module.hot.active = false;
  439. /******/
  440. /******/ // remove module from cache
  441. /******/ delete installedModules[moduleId];
  442. /******/
  443. /******/ // remove "parents" references from all children
  444. /******/ for(var j = 0; j < module.children.length; j++) {
  445. /******/ var child = installedModules[module.children[j]];
  446. /******/ if(!child) continue;
  447. /******/ var idx = child.parents.indexOf(moduleId);
  448. /******/ if(idx >= 0) {
  449. /******/ child.parents.splice(idx, 1);
  450. /******/ }
  451. /******/ }
  452. /******/ }
  453. /******/
  454. /******/ // remove outdated dependency from module children
  455. /******/ for(var moduleId in outdatedDependencies) {
  456. /******/ if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) {
  457. /******/ var module = installedModules[moduleId];
  458. /******/ var moduleOutdatedDependencies = outdatedDependencies[moduleId];
  459. /******/ for(var j = 0; j < moduleOutdatedDependencies.length; j++) {
  460. /******/ var dependency = moduleOutdatedDependencies[j];
  461. /******/ var idx = module.children.indexOf(dependency);
  462. /******/ if(idx >= 0) module.children.splice(idx, 1);
  463. /******/ }
  464. /******/ }
  465. /******/ }
  466. /******/
  467. /******/ // Not in "apply" phase
  468. /******/ hotSetStatus("apply");
  469. /******/
  470. /******/ hotCurrentHash = hotUpdateNewHash;
  471. /******/
  472. /******/ // insert new code
  473. /******/ for(var moduleId in appliedUpdate) {
  474. /******/ if(Object.prototype.hasOwnProperty.call(appliedUpdate, moduleId)) {
  475. /******/ modules[moduleId] = appliedUpdate[moduleId];
  476. /******/ }
  477. /******/ }
  478. /******/
  479. /******/ // call accept handlers
  480. /******/ var error = null;
  481. /******/ for(var moduleId in outdatedDependencies) {
  482. /******/ if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) {
  483. /******/ var module = installedModules[moduleId];
  484. /******/ var moduleOutdatedDependencies = outdatedDependencies[moduleId];
  485. /******/ var callbacks = [];
  486. /******/ for(var i = 0; i < moduleOutdatedDependencies.length; i++) {
  487. /******/ var dependency = moduleOutdatedDependencies[i];
  488. /******/ var cb = module.hot._acceptedDependencies[dependency];
  489. /******/ if(callbacks.indexOf(cb) >= 0) continue;
  490. /******/ callbacks.push(cb);
  491. /******/ }
  492. /******/ for(var i = 0; i < callbacks.length; i++) {
  493. /******/ var cb = callbacks[i];
  494. /******/ try {
  495. /******/ cb(outdatedDependencies);
  496. /******/ } catch(err) {
  497. /******/ if(!error)
  498. /******/ error = err;
  499. /******/ }
  500. /******/ }
  501. /******/ }
  502. /******/ }
  503. /******/
  504. /******/ // Load self accepted modules
  505. /******/ for(var i = 0; i < outdatedSelfAcceptedModules.length; i++) {
  506. /******/ var item = outdatedSelfAcceptedModules[i];
  507. /******/ var moduleId = item.module;
  508. /******/ hotCurrentParents = [moduleId];
  509. /******/ try {
  510. /******/ __webpack_require__(moduleId);
  511. /******/ } catch(err) {
  512. /******/ if(typeof item.errorHandler === "function") {
  513. /******/ try {
  514. /******/ item.errorHandler(err);
  515. /******/ } catch(err) {
  516. /******/ if(!error)
  517. /******/ error = err;
  518. /******/ }
  519. /******/ } else if(!error)
  520. /******/ error = err;
  521. /******/ }
  522. /******/ }
  523. /******/
  524. /******/ // handle errors in accept handlers and self accepted module load
  525. /******/ if(error) {
  526. /******/ hotSetStatus("fail");
  527. /******/ return callback(error);
  528. /******/ }
  529. /******/
  530. /******/ hotSetStatus("idle");
  531. /******/ callback(null, outdatedModules);
  532. /******/ }
  533. /******/ // The module cache
  534. /******/ var installedModules = {};
  535. /******/ // The require function
  536. /******/ function __webpack_require__(moduleId) {
  537. /******/ // Check if module is in cache
  538. /******/ if(installedModules[moduleId])
  539. /******/ return installedModules[moduleId].exports;
  540. /******/ // Create a new module (and put it into the cache)
  541. /******/ var module = installedModules[moduleId] = {
  542. /******/ exports: {},
  543. /******/ id: moduleId,
  544. /******/ loaded: false,
  545. /******/ hot: hotCreateModule(moduleId),
  546. /******/ parents: hotCurrentParents,
  547. /******/ children: []
  548. /******/ };
  549. /******/ // Execute the module function
  550. /******/ modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
  551. /******/ // Flag the module as loaded
  552. /******/ module.loaded = true;
  553. /******/ // Return the exports of the module
  554. /******/ return module.exports;
  555. /******/ }
  556. /******/ // expose the modules object (__webpack_modules__)
  557. /******/ __webpack_require__.m = modules;
  558. /******/ // expose the module cache
  559. /******/ __webpack_require__.c = installedModules;
  560. /******/ // __webpack_public_path__
  561. /******/ __webpack_require__.p = "";
  562. /******/ // __webpack_hash__
  563. /******/ __webpack_require__.h = function() { return hotCurrentHash; };
  564. /******/ // Load entry module and return exports
  565. /******/ return hotCreateRequire(0)(0);
  566. /******/ })
  567. /************************************************************************/
  568. /******/ ([
  569. /* 0 */
  570. /***/ function(module, exports, __webpack_require__) {
  571. module.exports = __webpack_require__(1);
  572. /***/ },
  573. /* 1 */
  574. /***/ function(module, exports, __webpack_require__) {
  575. /* WEBPACK VAR INJECTION */(function(fetch, Promise) {'use strict';
  576. __webpack_require__(3);
  577. __webpack_require__(7);
  578. window.lofig = {
  579. folder: 'config/default.json',
  580. get: function get(query, callback) {
  581. fetch(lofig.folder).then(function (response) {
  582. return response.json();
  583. }).then(function (json) {
  584. query = query.split('.');
  585. return Promise.each(query, function (property) {
  586. json = json[property];
  587. }).then(function () {
  588. callback(json);
  589. });
  590. }).catch(function (err) {
  591. console.log('parsing failed', err);
  592. });
  593. },
  594. has: function has(query, callback) {
  595. fetch(lofig.folder).then(function (response) {
  596. return response.json();
  597. }).then(function (json) {
  598. query = query.split('.');
  599. return Promise.each(query, function (property) {
  600. json = json[property];
  601. }).then(function () {
  602. if (json) callback(true);else callback(false);
  603. });
  604. }).catch(function (err) {
  605. console.log('parsing failed', err);
  606. });
  607. }
  608. };
  609. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(3)))
  610. /***/ },
  611. /* 2 */
  612. /***/ function(module, exports, __webpack_require__) {
  613. /* WEBPACK VAR INJECTION */(function(Promise, global) {/*** IMPORTS FROM imports-loader ***/
  614. (function() {
  615. (function(self) {
  616. 'use strict';
  617. if (self.fetch) {
  618. return
  619. }
  620. var support = {
  621. searchParams: 'URLSearchParams' in self,
  622. iterable: 'Symbol' in self && 'iterator' in Symbol,
  623. blob: 'FileReader' in self && 'Blob' in self && (function() {
  624. try {
  625. new Blob()
  626. return true
  627. } catch(e) {
  628. return false
  629. }
  630. })(),
  631. formData: 'FormData' in self,
  632. arrayBuffer: 'ArrayBuffer' in self
  633. }
  634. if (support.arrayBuffer) {
  635. var viewClasses = [
  636. '[object Int8Array]',
  637. '[object Uint8Array]',
  638. '[object Uint8ClampedArray]',
  639. '[object Int16Array]',
  640. '[object Uint16Array]',
  641. '[object Int32Array]',
  642. '[object Uint32Array]',
  643. '[object Float32Array]',
  644. '[object Float64Array]'
  645. ]
  646. var isDataView = function(obj) {
  647. return obj && DataView.prototype.isPrototypeOf(obj)
  648. }
  649. var isArrayBufferView = ArrayBuffer.isView || function(obj) {
  650. return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
  651. }
  652. }
  653. function normalizeName(name) {
  654. if (typeof name !== 'string') {
  655. name = String(name)
  656. }
  657. if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
  658. throw new TypeError('Invalid character in header field name')
  659. }
  660. return name.toLowerCase()
  661. }
  662. function normalizeValue(value) {
  663. if (typeof value !== 'string') {
  664. value = String(value)
  665. }
  666. return value
  667. }
  668. // Build a destructive iterator for the value list
  669. function iteratorFor(items) {
  670. var iterator = {
  671. next: function() {
  672. var value = items.shift()
  673. return {done: value === undefined, value: value}
  674. }
  675. }
  676. if (support.iterable) {
  677. iterator[Symbol.iterator] = function() {
  678. return iterator
  679. }
  680. }
  681. return iterator
  682. }
  683. function Headers(headers) {
  684. this.map = {}
  685. if (headers instanceof Headers) {
  686. headers.forEach(function(value, name) {
  687. this.append(name, value)
  688. }, this)
  689. } else if (headers) {
  690. Object.getOwnPropertyNames(headers).forEach(function(name) {
  691. this.append(name, headers[name])
  692. }, this)
  693. }
  694. }
  695. Headers.prototype.append = function(name, value) {
  696. name = normalizeName(name)
  697. value = normalizeValue(value)
  698. var oldValue = this.map[name]
  699. this.map[name] = oldValue ? oldValue+','+value : value
  700. }
  701. Headers.prototype['delete'] = function(name) {
  702. delete this.map[normalizeName(name)]
  703. }
  704. Headers.prototype.get = function(name) {
  705. name = normalizeName(name)
  706. return this.has(name) ? this.map[name] : null
  707. }
  708. Headers.prototype.has = function(name) {
  709. return this.map.hasOwnProperty(normalizeName(name))
  710. }
  711. Headers.prototype.set = function(name, value) {
  712. this.map[normalizeName(name)] = normalizeValue(value)
  713. }
  714. Headers.prototype.forEach = function(callback, thisArg) {
  715. for (var name in this.map) {
  716. if (this.map.hasOwnProperty(name)) {
  717. callback.call(thisArg, this.map[name], name, this)
  718. }
  719. }
  720. }
  721. Headers.prototype.keys = function() {
  722. var items = []
  723. this.forEach(function(value, name) { items.push(name) })
  724. return iteratorFor(items)
  725. }
  726. Headers.prototype.values = function() {
  727. var items = []
  728. this.forEach(function(value) { items.push(value) })
  729. return iteratorFor(items)
  730. }
  731. Headers.prototype.entries = function() {
  732. var items = []
  733. this.forEach(function(value, name) { items.push([name, value]) })
  734. return iteratorFor(items)
  735. }
  736. if (support.iterable) {
  737. Headers.prototype[Symbol.iterator] = Headers.prototype.entries
  738. }
  739. function consumed(body) {
  740. if (body.bodyUsed) {
  741. return Promise.reject(new TypeError('Already read'))
  742. }
  743. body.bodyUsed = true
  744. }
  745. function fileReaderReady(reader) {
  746. return new Promise(function(resolve, reject) {
  747. reader.onload = function() {
  748. resolve(reader.result)
  749. }
  750. reader.onerror = function() {
  751. reject(reader.error)
  752. }
  753. })
  754. }
  755. function readBlobAsArrayBuffer(blob) {
  756. var reader = new FileReader()
  757. var promise = fileReaderReady(reader)
  758. reader.readAsArrayBuffer(blob)
  759. return promise
  760. }
  761. function readBlobAsText(blob) {
  762. var reader = new FileReader()
  763. var promise = fileReaderReady(reader)
  764. reader.readAsText(blob)
  765. return promise
  766. }
  767. function readArrayBufferAsText(buf) {
  768. var view = new Uint8Array(buf)
  769. var chars = new Array(view.length)
  770. for (var i = 0; i < view.length; i++) {
  771. chars[i] = String.fromCharCode(view[i])
  772. }
  773. return chars.join('')
  774. }
  775. function bufferClone(buf) {
  776. if (buf.slice) {
  777. return buf.slice(0)
  778. } else {
  779. var view = new Uint8Array(buf.byteLength)
  780. view.set(new Uint8Array(buf))
  781. return view.buffer
  782. }
  783. }
  784. function Body() {
  785. this.bodyUsed = false
  786. this._initBody = function(body) {
  787. this._bodyInit = body
  788. if (!body) {
  789. this._bodyText = ''
  790. } else if (typeof body === 'string') {
  791. this._bodyText = body
  792. } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
  793. this._bodyBlob = body
  794. } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
  795. this._bodyFormData = body
  796. } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
  797. this._bodyText = body.toString()
  798. } else if (support.arrayBuffer && support.blob && isDataView(body)) {
  799. this._bodyArrayBuffer = bufferClone(body.buffer)
  800. // IE 10-11 can't handle a DataView body.
  801. this._bodyInit = new Blob([this._bodyArrayBuffer])
  802. } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
  803. this._bodyArrayBuffer = bufferClone(body)
  804. } else {
  805. throw new Error('unsupported BodyInit type')
  806. }
  807. if (!this.headers.get('content-type')) {
  808. if (typeof body === 'string') {
  809. this.headers.set('content-type', 'text/plain;charset=UTF-8')
  810. } else if (this._bodyBlob && this._bodyBlob.type) {
  811. this.headers.set('content-type', this._bodyBlob.type)
  812. } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
  813. this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8')
  814. }
  815. }
  816. }
  817. if (support.blob) {
  818. this.blob = function() {
  819. var rejected = consumed(this)
  820. if (rejected) {
  821. return rejected
  822. }
  823. if (this._bodyBlob) {
  824. return Promise.resolve(this._bodyBlob)
  825. } else if (this._bodyArrayBuffer) {
  826. return Promise.resolve(new Blob([this._bodyArrayBuffer]))
  827. } else if (this._bodyFormData) {
  828. throw new Error('could not read FormData body as blob')
  829. } else {
  830. return Promise.resolve(new Blob([this._bodyText]))
  831. }
  832. }
  833. this.arrayBuffer = function() {
  834. if (this._bodyArrayBuffer) {
  835. return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
  836. } else {
  837. return this.blob().then(readBlobAsArrayBuffer)
  838. }
  839. }
  840. }
  841. this.text = function() {
  842. var rejected = consumed(this)
  843. if (rejected) {
  844. return rejected
  845. }
  846. if (this._bodyBlob) {
  847. return readBlobAsText(this._bodyBlob)
  848. } else if (this._bodyArrayBuffer) {
  849. return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
  850. } else if (this._bodyFormData) {
  851. throw new Error('could not read FormData body as text')
  852. } else {
  853. return Promise.resolve(this._bodyText)
  854. }
  855. }
  856. if (support.formData) {
  857. this.formData = function() {
  858. return this.text().then(decode)
  859. }
  860. }
  861. this.json = function() {
  862. return this.text().then(JSON.parse)
  863. }
  864. return this
  865. }
  866. // HTTP methods whose capitalization should be normalized
  867. var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']
  868. function normalizeMethod(method) {
  869. var upcased = method.toUpperCase()
  870. return (methods.indexOf(upcased) > -1) ? upcased : method
  871. }
  872. function Request(input, options) {
  873. options = options || {}
  874. var body = options.body
  875. if (typeof input === 'string') {
  876. this.url = input
  877. } else {
  878. if (input.bodyUsed) {
  879. throw new TypeError('Already read')
  880. }
  881. this.url = input.url
  882. this.credentials = input.credentials
  883. if (!options.headers) {
  884. this.headers = new Headers(input.headers)
  885. }
  886. this.method = input.method
  887. this.mode = input.mode
  888. if (!body && input._bodyInit != null) {
  889. body = input._bodyInit
  890. input.bodyUsed = true
  891. }
  892. }
  893. this.credentials = options.credentials || this.credentials || 'omit'
  894. if (options.headers || !this.headers) {
  895. this.headers = new Headers(options.headers)
  896. }
  897. this.method = normalizeMethod(options.method || this.method || 'GET')
  898. this.mode = options.mode || this.mode || null
  899. this.referrer = null
  900. if ((this.method === 'GET' || this.method === 'HEAD') && body) {
  901. throw new TypeError('Body not allowed for GET or HEAD requests')
  902. }
  903. this._initBody(body)
  904. }
  905. Request.prototype.clone = function() {
  906. return new Request(this, { body: this._bodyInit })
  907. }
  908. function decode(body) {
  909. var form = new FormData()
  910. body.trim().split('&').forEach(function(bytes) {
  911. if (bytes) {
  912. var split = bytes.split('=')
  913. var name = split.shift().replace(/\+/g, ' ')
  914. var value = split.join('=').replace(/\+/g, ' ')
  915. form.append(decodeURIComponent(name), decodeURIComponent(value))
  916. }
  917. })
  918. return form
  919. }
  920. function parseHeaders(rawHeaders) {
  921. var headers = new Headers()
  922. rawHeaders.split('\r\n').forEach(function(line) {
  923. var parts = line.split(':')
  924. var key = parts.shift().trim()
  925. if (key) {
  926. var value = parts.join(':').trim()
  927. headers.append(key, value)
  928. }
  929. })
  930. return headers
  931. }
  932. Body.call(Request.prototype)
  933. function Response(bodyInit, options) {
  934. if (!options) {
  935. options = {}
  936. }
  937. this.type = 'default'
  938. this.status = 'status' in options ? options.status : 200
  939. this.ok = this.status >= 200 && this.status < 300
  940. this.statusText = 'statusText' in options ? options.statusText : 'OK'
  941. this.headers = new Headers(options.headers)
  942. this.url = options.url || ''
  943. this._initBody(bodyInit)
  944. }
  945. Body.call(Response.prototype)
  946. Response.prototype.clone = function() {
  947. return new Response(this._bodyInit, {
  948. status: this.status,
  949. statusText: this.statusText,
  950. headers: new Headers(this.headers),
  951. url: this.url
  952. })
  953. }
  954. Response.error = function() {
  955. var response = new Response(null, {status: 0, statusText: ''})
  956. response.type = 'error'
  957. return response
  958. }
  959. var redirectStatuses = [301, 302, 303, 307, 308]
  960. Response.redirect = function(url, status) {
  961. if (redirectStatuses.indexOf(status) === -1) {
  962. throw new RangeError('Invalid status code')
  963. }
  964. return new Response(null, {status: status, headers: {location: url}})
  965. }
  966. self.Headers = Headers
  967. self.Request = Request
  968. self.Response = Response
  969. self.fetch = function(input, init) {
  970. return new Promise(function(resolve, reject) {
  971. var request = new Request(input, init)
  972. var xhr = new XMLHttpRequest()
  973. xhr.onload = function() {
  974. var options = {
  975. status: xhr.status,
  976. statusText: xhr.statusText,
  977. headers: parseHeaders(xhr.getAllResponseHeaders() || '')
  978. }
  979. options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL')
  980. var body = 'response' in xhr ? xhr.response : xhr.responseText
  981. resolve(new Response(body, options))
  982. }
  983. xhr.onerror = function() {
  984. reject(new TypeError('Network request failed'))
  985. }
  986. xhr.ontimeout = function() {
  987. reject(new TypeError('Network request failed'))
  988. }
  989. xhr.open(request.method, request.url, true)
  990. if (request.credentials === 'include') {
  991. xhr.withCredentials = true
  992. }
  993. if ('responseType' in xhr && support.blob) {
  994. xhr.responseType = 'blob'
  995. }
  996. request.headers.forEach(function(value, name) {
  997. xhr.setRequestHeader(name, value)
  998. })
  999. xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit)
  1000. })
  1001. }
  1002. self.fetch.polyfill = true
  1003. })(typeof self !== 'undefined' ? self : this);
  1004. /*** EXPORTS FROM exports-loader ***/
  1005. module.exports = global.fetch;
  1006. }.call(global));
  1007. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3), (function() { return this; }())))
  1008. /***/ },
  1009. /* 3 */
  1010. /***/ function(module, exports, __webpack_require__) {
  1011. /* WEBPACK VAR INJECTION */(function(process, Promise, global, setImmediate) {/* @preserve
  1012. * The MIT License (MIT)
  1013. *
  1014. * Copyright (c) 2013-2015 Petka Antonov
  1015. *
  1016. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1017. * of this software and associated documentation files (the "Software"), to deal
  1018. * in the Software without restriction, including without limitation the rights
  1019. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1020. * copies of the Software, and to permit persons to whom the Software is
  1021. * furnished to do so, subject to the following conditions:
  1022. *
  1023. * The above copyright notice and this permission notice shall be included in
  1024. * all copies or substantial portions of the Software.
  1025. *
  1026. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1027. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1028. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1029. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1030. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1031. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1032. * THE SOFTWARE.
  1033. *
  1034. */
  1035. /**
  1036. * bluebird build version 3.4.6
  1037. * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each
  1038. */
  1039. !function(e){if(true)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){
  1040. "use strict";
  1041. module.exports = function(Promise) {
  1042. var SomePromiseArray = Promise._SomePromiseArray;
  1043. function any(promises) {
  1044. var ret = new SomePromiseArray(promises);
  1045. var promise = ret.promise();
  1046. ret.setHowMany(1);
  1047. ret.setUnwrap();
  1048. ret.init();
  1049. return promise;
  1050. }
  1051. Promise.any = function (promises) {
  1052. return any(promises);
  1053. };
  1054. Promise.prototype.any = function () {
  1055. return any(this);
  1056. };
  1057. };
  1058. },{}],2:[function(_dereq_,module,exports){
  1059. "use strict";
  1060. var firstLineError;
  1061. try {throw new Error(); } catch (e) {firstLineError = e;}
  1062. var schedule = _dereq_("./schedule");
  1063. var Queue = _dereq_("./queue");
  1064. var util = _dereq_("./util");
  1065. function Async() {
  1066. this._customScheduler = false;
  1067. this._isTickUsed = false;
  1068. this._lateQueue = new Queue(16);
  1069. this._normalQueue = new Queue(16);
  1070. this._haveDrainedQueues = false;
  1071. this._trampolineEnabled = true;
  1072. var self = this;
  1073. this.drainQueues = function () {
  1074. self._drainQueues();
  1075. };
  1076. this._schedule = schedule;
  1077. }
  1078. Async.prototype.setScheduler = function(fn) {
  1079. var prev = this._schedule;
  1080. this._schedule = fn;
  1081. this._customScheduler = true;
  1082. return prev;
  1083. };
  1084. Async.prototype.hasCustomScheduler = function() {
  1085. return this._customScheduler;
  1086. };
  1087. Async.prototype.enableTrampoline = function() {
  1088. this._trampolineEnabled = true;
  1089. };
  1090. Async.prototype.disableTrampolineIfNecessary = function() {
  1091. if (util.hasDevTools) {
  1092. this._trampolineEnabled = false;
  1093. }
  1094. };
  1095. Async.prototype.haveItemsQueued = function () {
  1096. return this._isTickUsed || this._haveDrainedQueues;
  1097. };
  1098. Async.prototype.fatalError = function(e, isNode) {
  1099. if (isNode) {
  1100. process.stderr.write("Fatal " + (e instanceof Error ? e.stack : e) +
  1101. "\n");
  1102. process.exit(2);
  1103. } else {
  1104. this.throwLater(e);
  1105. }
  1106. };
  1107. Async.prototype.throwLater = function(fn, arg) {
  1108. if (arguments.length === 1) {
  1109. arg = fn;
  1110. fn = function () { throw arg; };
  1111. }
  1112. if (typeof setTimeout !== "undefined") {
  1113. setTimeout(function() {
  1114. fn(arg);
  1115. }, 0);
  1116. } else try {
  1117. this._schedule(function() {
  1118. fn(arg);
  1119. });
  1120. } catch (e) {
  1121. throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  1122. }
  1123. };
  1124. function AsyncInvokeLater(fn, receiver, arg) {
  1125. this._lateQueue.push(fn, receiver, arg);
  1126. this._queueTick();
  1127. }
  1128. function AsyncInvoke(fn, receiver, arg) {
  1129. this._normalQueue.push(fn, receiver, arg);
  1130. this._queueTick();
  1131. }
  1132. function AsyncSettlePromises(promise) {
  1133. this._normalQueue._pushOne(promise);
  1134. this._queueTick();
  1135. }
  1136. if (!util.hasDevTools) {
  1137. Async.prototype.invokeLater = AsyncInvokeLater;
  1138. Async.prototype.invoke = AsyncInvoke;
  1139. Async.prototype.settlePromises = AsyncSettlePromises;
  1140. } else {
  1141. Async.prototype.invokeLater = function (fn, receiver, arg) {
  1142. if (this._trampolineEnabled) {
  1143. AsyncInvokeLater.call(this, fn, receiver, arg);
  1144. } else {
  1145. this._schedule(function() {
  1146. setTimeout(function() {
  1147. fn.call(receiver, arg);
  1148. }, 100);
  1149. });
  1150. }
  1151. };
  1152. Async.prototype.invoke = function (fn, receiver, arg) {
  1153. if (this._trampolineEnabled) {
  1154. AsyncInvoke.call(this, fn, receiver, arg);
  1155. } else {
  1156. this._schedule(function() {
  1157. fn.call(receiver, arg);
  1158. });
  1159. }
  1160. };
  1161. Async.prototype.settlePromises = function(promise) {
  1162. if (this._trampolineEnabled) {
  1163. AsyncSettlePromises.call(this, promise);
  1164. } else {
  1165. this._schedule(function() {
  1166. promise._settlePromises();
  1167. });
  1168. }
  1169. };
  1170. }
  1171. Async.prototype.invokeFirst = function (fn, receiver, arg) {
  1172. this._normalQueue.unshift(fn, receiver, arg);
  1173. this._queueTick();
  1174. };
  1175. Async.prototype._drainQueue = function(queue) {
  1176. while (queue.length() > 0) {
  1177. var fn = queue.shift();
  1178. if (typeof fn !== "function") {
  1179. fn._settlePromises();
  1180. continue;
  1181. }
  1182. var receiver = queue.shift();
  1183. var arg = queue.shift();
  1184. fn.call(receiver, arg);
  1185. }
  1186. };
  1187. Async.prototype._drainQueues = function () {
  1188. this._drainQueue(this._normalQueue);
  1189. this._reset();
  1190. this._haveDrainedQueues = true;
  1191. this._drainQueue(this._lateQueue);
  1192. };
  1193. Async.prototype._queueTick = function () {
  1194. if (!this._isTickUsed) {
  1195. this._isTickUsed = true;
  1196. this._schedule(this.drainQueues);
  1197. }
  1198. };
  1199. Async.prototype._reset = function () {
  1200. this._isTickUsed = false;
  1201. };
  1202. module.exports = Async;
  1203. module.exports.firstLineError = firstLineError;
  1204. },{"./queue":26,"./schedule":29,"./util":36}],3:[function(_dereq_,module,exports){
  1205. "use strict";
  1206. module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) {
  1207. var calledBind = false;
  1208. var rejectThis = function(_, e) {
  1209. this._reject(e);
  1210. };
  1211. var targetRejected = function(e, context) {
  1212. context.promiseRejectionQueued = true;
  1213. context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
  1214. };
  1215. var bindingResolved = function(thisArg, context) {
  1216. if (((this._bitField & 50397184) === 0)) {
  1217. this._resolveCallback(context.target);
  1218. }
  1219. };
  1220. var bindingRejected = function(e, context) {
  1221. if (!context.promiseRejectionQueued) this._reject(e);
  1222. };
  1223. Promise.prototype.bind = function (thisArg) {
  1224. if (!calledBind) {
  1225. calledBind = true;
  1226. Promise.prototype._propagateFrom = debug.propagateFromFunction();
  1227. Promise.prototype._boundValue = debug.boundValueFunction();
  1228. }
  1229. var maybePromise = tryConvertToPromise(thisArg);
  1230. var ret = new Promise(INTERNAL);
  1231. ret._propagateFrom(this, 1);
  1232. var target = this._target();
  1233. ret._setBoundTo(maybePromise);
  1234. if (maybePromise instanceof Promise) {
  1235. var context = {
  1236. promiseRejectionQueued: false,
  1237. promise: ret,
  1238. target: target,
  1239. bindingPromise: maybePromise
  1240. };
  1241. target._then(INTERNAL, targetRejected, undefined, ret, context);
  1242. maybePromise._then(
  1243. bindingResolved, bindingRejected, undefined, ret, context);
  1244. ret._setOnCancel(maybePromise);
  1245. } else {
  1246. ret._resolveCallback(target);
  1247. }
  1248. return ret;
  1249. };
  1250. Promise.prototype._setBoundTo = function (obj) {
  1251. if (obj !== undefined) {
  1252. this._bitField = this._bitField | 2097152;
  1253. this._boundTo = obj;
  1254. } else {
  1255. this._bitField = this._bitField & (~2097152);
  1256. }
  1257. };
  1258. Promise.prototype._isBound = function () {
  1259. return (this._bitField & 2097152) === 2097152;
  1260. };
  1261. Promise.bind = function (thisArg, value) {
  1262. return Promise.resolve(value).bind(thisArg);
  1263. };
  1264. };
  1265. },{}],4:[function(_dereq_,module,exports){
  1266. "use strict";
  1267. var old;
  1268. if (typeof Promise !== "undefined") old = Promise;
  1269. function noConflict() {
  1270. try { if (Promise === bluebird) Promise = old; }
  1271. catch (e) {}
  1272. return bluebird;
  1273. }
  1274. var bluebird = _dereq_("./promise")();
  1275. bluebird.noConflict = noConflict;
  1276. module.exports = bluebird;
  1277. },{"./promise":22}],5:[function(_dereq_,module,exports){
  1278. "use strict";
  1279. var cr = Object.create;
  1280. if (cr) {
  1281. var callerCache = cr(null);
  1282. var getterCache = cr(null);
  1283. callerCache[" size"] = getterCache[" size"] = 0;
  1284. }
  1285. module.exports = function(Promise) {
  1286. var util = _dereq_("./util");
  1287. var canEvaluate = util.canEvaluate;
  1288. var isIdentifier = util.isIdentifier;
  1289. var getMethodCaller;
  1290. var getGetter;
  1291. if (false) {
  1292. var makeMethodCaller = function (methodName) {
  1293. return new Function("ensureMethod", " \n\
  1294. return function(obj) { \n\
  1295. 'use strict' \n\
  1296. var len = this.length; \n\
  1297. ensureMethod(obj, 'methodName'); \n\
  1298. switch(len) { \n\
  1299. case 1: return obj.methodName(this[0]); \n\
  1300. case 2: return obj.methodName(this[0], this[1]); \n\
  1301. case 3: return obj.methodName(this[0], this[1], this[2]); \n\
  1302. case 0: return obj.methodName(); \n\
  1303. default: \n\
  1304. return obj.methodName.apply(obj, this); \n\
  1305. } \n\
  1306. }; \n\
  1307. ".replace(/methodName/g, methodName))(ensureMethod);
  1308. };
  1309. var makeGetter = function (propertyName) {
  1310. return new Function("obj", " \n\
  1311. 'use strict'; \n\
  1312. return obj.propertyName; \n\
  1313. ".replace("propertyName", propertyName));
  1314. };
  1315. var getCompiled = function(name, compiler, cache) {
  1316. var ret = cache[name];
  1317. if (typeof ret !== "function") {
  1318. if (!isIdentifier(name)) {
  1319. return null;
  1320. }
  1321. ret = compiler(name);
  1322. cache[name] = ret;
  1323. cache[" size"]++;
  1324. if (cache[" size"] > 512) {
  1325. var keys = Object.keys(cache);
  1326. for (var i = 0; i < 256; ++i) delete cache[keys[i]];
  1327. cache[" size"] = keys.length - 256;
  1328. }
  1329. }
  1330. return ret;
  1331. };
  1332. getMethodCaller = function(name) {
  1333. return getCompiled(name, makeMethodCaller, callerCache);
  1334. };
  1335. getGetter = function(name) {
  1336. return getCompiled(name, makeGetter, getterCache);
  1337. };
  1338. }
  1339. function ensureMethod(obj, methodName) {
  1340. var fn;
  1341. if (obj != null) fn = obj[methodName];
  1342. if (typeof fn !== "function") {
  1343. var message = "Object " + util.classString(obj) + " has no method '" +
  1344. util.toString(methodName) + "'";
  1345. throw new Promise.TypeError(message);
  1346. }
  1347. return fn;
  1348. }
  1349. function caller(obj) {
  1350. var methodName = this.pop();
  1351. var fn = ensureMethod(obj, methodName);
  1352. return fn.apply(obj, this);
  1353. }
  1354. Promise.prototype.call = function (methodName) {
  1355. var args = [].slice.call(arguments, 1);;
  1356. if (false) {
  1357. if (canEvaluate) {
  1358. var maybeCaller = getMethodCaller(methodName);
  1359. if (maybeCaller !== null) {
  1360. return this._then(
  1361. maybeCaller, undefined, undefined, args, undefined);
  1362. }
  1363. }
  1364. }
  1365. args.push(methodName);
  1366. return this._then(caller, undefined, undefined, args, undefined);
  1367. };
  1368. function namedGetter(obj) {
  1369. return obj[this];
  1370. }
  1371. function indexedGetter(obj) {
  1372. var index = +this;
  1373. if (index < 0) index = Math.max(0, index + obj.length);
  1374. return obj[index];
  1375. }
  1376. Promise.prototype.get = function (propertyName) {
  1377. var isIndex = (typeof propertyName === "number");
  1378. var getter;
  1379. if (!isIndex) {
  1380. if (canEvaluate) {
  1381. var maybeGetter = getGetter(propertyName);
  1382. getter = maybeGetter !== null ? maybeGetter : namedGetter;
  1383. } else {
  1384. getter = namedGetter;
  1385. }
  1386. } else {
  1387. getter = indexedGetter;
  1388. }
  1389. return this._then(getter, undefined, undefined, propertyName, undefined);
  1390. };
  1391. };
  1392. },{"./util":36}],6:[function(_dereq_,module,exports){
  1393. "use strict";
  1394. module.exports = function(Promise, PromiseArray, apiRejection, debug) {
  1395. var util = _dereq_("./util");
  1396. var tryCatch = util.tryCatch;
  1397. var errorObj = util.errorObj;
  1398. var async = Promise._async;
  1399. Promise.prototype["break"] = Promise.prototype.cancel = function() {
  1400. if (!debug.cancellation()) return this._warn("cancellation is disabled");
  1401. var promise = this;
  1402. var child = promise;
  1403. while (promise._isCancellable()) {
  1404. if (!promise._cancelBy(child)) {
  1405. if (child._isFollowing()) {
  1406. child._followee().cancel();
  1407. } else {
  1408. child._cancelBranched();
  1409. }
  1410. break;
  1411. }
  1412. var parent = promise._cancellationParent;
  1413. if (parent == null || !parent._isCancellable()) {
  1414. if (promise._isFollowing()) {
  1415. promise._followee().cancel();
  1416. } else {
  1417. promise._cancelBranched();
  1418. }
  1419. break;
  1420. } else {
  1421. if (promise._isFollowing()) promise._followee().cancel();
  1422. promise._setWillBeCancelled();
  1423. child = promise;
  1424. promise = parent;
  1425. }
  1426. }
  1427. };
  1428. Promise.prototype._branchHasCancelled = function() {
  1429. this._branchesRemainingToCancel--;
  1430. };
  1431. Promise.prototype._enoughBranchesHaveCancelled = function() {
  1432. return this._branchesRemainingToCancel === undefined ||
  1433. this._branchesRemainingToCancel <= 0;
  1434. };
  1435. Promise.prototype._cancelBy = function(canceller) {
  1436. if (canceller === this) {
  1437. this._branchesRemainingToCancel = 0;
  1438. this._invokeOnCancel();
  1439. return true;
  1440. } else {
  1441. this._branchHasCancelled();
  1442. if (this._enoughBranchesHaveCancelled()) {
  1443. this._invokeOnCancel();
  1444. return true;
  1445. }
  1446. }
  1447. return false;
  1448. };
  1449. Promise.prototype._cancelBranched = function() {
  1450. if (this._enoughBranchesHaveCancelled()) {
  1451. this._cancel();
  1452. }
  1453. };
  1454. Promise.prototype._cancel = function() {
  1455. if (!this._isCancellable()) return;
  1456. this._setCancelled();
  1457. async.invoke(this._cancelPromises, this, undefined);
  1458. };
  1459. Promise.prototype._cancelPromises = function() {
  1460. if (this._length() > 0) this._settlePromises();
  1461. };
  1462. Promise.prototype._unsetOnCancel = function() {
  1463. this._onCancelField = undefined;
  1464. };
  1465. Promise.prototype._isCancellable = function() {
  1466. return this.isPending() && !this._isCancelled();
  1467. };
  1468. Promise.prototype.isCancellable = function() {
  1469. return this.isPending() && !this.isCancelled();
  1470. };
  1471. Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) {
  1472. if (util.isArray(onCancelCallback)) {
  1473. for (var i = 0; i < onCancelCallback.length; ++i) {
  1474. this._doInvokeOnCancel(onCancelCallback[i], internalOnly);
  1475. }
  1476. } else if (onCancelCallback !== undefined) {
  1477. if (typeof onCancelCallback === "function") {
  1478. if (!internalOnly) {
  1479. var e = tryCatch(onCancelCallback).call(this._boundValue());
  1480. if (e === errorObj) {
  1481. this._attachExtraTrace(e.e);
  1482. async.throwLater(e.e);
  1483. }
  1484. }
  1485. } else {
  1486. onCancelCallback._resultCancelled(this);
  1487. }
  1488. }
  1489. };
  1490. Promise.prototype._invokeOnCancel = function() {
  1491. var onCancelCallback = this._onCancel();
  1492. this._unsetOnCancel();
  1493. async.invoke(this._doInvokeOnCancel, this, onCancelCallback);
  1494. };
  1495. Promise.prototype._invokeInternalOnCancel = function() {
  1496. if (this._isCancellable()) {
  1497. this._doInvokeOnCancel(this._onCancel(), true);
  1498. this._unsetOnCancel();
  1499. }
  1500. };
  1501. Promise.prototype._resultCancelled = function() {
  1502. this.cancel();
  1503. };
  1504. };
  1505. },{"./util":36}],7:[function(_dereq_,module,exports){
  1506. "use strict";
  1507. module.exports = function(NEXT_FILTER) {
  1508. var util = _dereq_("./util");
  1509. var getKeys = _dereq_("./es5").keys;
  1510. var tryCatch = util.tryCatch;
  1511. var errorObj = util.errorObj;
  1512. function catchFilter(instances, cb, promise) {
  1513. return function(e) {
  1514. var boundTo = promise._boundValue();
  1515. predicateLoop: for (var i = 0; i < instances.length; ++i) {
  1516. var item = instances[i];
  1517. if (item === Error ||
  1518. (item != null && item.prototype instanceof Error)) {
  1519. if (e instanceof item) {
  1520. return tryCatch(cb).call(boundTo, e);
  1521. }
  1522. } else if (typeof item === "function") {
  1523. var matchesPredicate = tryCatch(item).call(boundTo, e);
  1524. if (matchesPredicate === errorObj) {
  1525. return matchesPredicate;
  1526. } else if (matchesPredicate) {
  1527. return tryCatch(cb).call(boundTo, e);
  1528. }
  1529. } else if (util.isObject(e)) {
  1530. var keys = getKeys(item);
  1531. for (var j = 0; j < keys.length; ++j) {
  1532. var key = keys[j];
  1533. if (item[key] != e[key]) {
  1534. continue predicateLoop;
  1535. }
  1536. }
  1537. return tryCatch(cb).call(boundTo, e);
  1538. }
  1539. }
  1540. return NEXT_FILTER;
  1541. };
  1542. }
  1543. return catchFilter;
  1544. };
  1545. },{"./es5":13,"./util":36}],8:[function(_dereq_,module,exports){
  1546. "use strict";
  1547. module.exports = function(Promise) {
  1548. var longStackTraces = false;
  1549. var contextStack = [];
  1550. Promise.prototype._promiseCreated = function() {};
  1551. Promise.prototype._pushContext = function() {};
  1552. Promise.prototype._popContext = function() {return null;};
  1553. Promise._peekContext = Promise.prototype._peekContext = function() {};
  1554. function Context() {
  1555. this._trace = new Context.CapturedTrace(peekContext());
  1556. }
  1557. Context.prototype._pushContext = function () {
  1558. if (this._trace !== undefined) {
  1559. this._trace._promiseCreated = null;
  1560. contextStack.push(this._trace);
  1561. }
  1562. };
  1563. Context.prototype._popContext = function () {
  1564. if (this._trace !== undefined) {
  1565. var trace = contextStack.pop();
  1566. var ret = trace._promiseCreated;
  1567. trace._promiseCreated = null;
  1568. return ret;
  1569. }
  1570. return null;
  1571. };
  1572. function createContext() {
  1573. if (longStackTraces) return new Context();
  1574. }
  1575. function peekContext() {
  1576. var lastIndex = contextStack.length - 1;
  1577. if (lastIndex >= 0) {
  1578. return contextStack[lastIndex];
  1579. }
  1580. return undefined;
  1581. }
  1582. Context.CapturedTrace = null;
  1583. Context.create = createContext;
  1584. Context.deactivateLongStackTraces = function() {};
  1585. Context.activateLongStackTraces = function() {
  1586. var Promise_pushContext = Promise.prototype._pushContext;
  1587. var Promise_popContext = Promise.prototype._popContext;
  1588. var Promise_PeekContext = Promise._peekContext;
  1589. var Promise_peekContext = Promise.prototype._peekContext;
  1590. var Promise_promiseCreated = Promise.prototype._promiseCreated;
  1591. Context.deactivateLongStackTraces = function() {
  1592. Promise.prototype._pushContext = Promise_pushContext;
  1593. Promise.prototype._popContext = Promise_popContext;
  1594. Promise._peekContext = Promise_PeekContext;
  1595. Promise.prototype._peekContext = Promise_peekContext;
  1596. Promise.prototype._promiseCreated = Promise_promiseCreated;
  1597. longStackTraces = false;
  1598. };
  1599. longStackTraces = true;
  1600. Promise.prototype._pushContext = Context.prototype._pushContext;
  1601. Promise.prototype._popContext = Context.prototype._popContext;
  1602. Promise._peekContext = Promise.prototype._peekContext = peekContext;
  1603. Promise.prototype._promiseCreated = function() {
  1604. var ctx = this._peekContext();
  1605. if (ctx && ctx._promiseCreated == null) ctx._promiseCreated = this;
  1606. };
  1607. };
  1608. return Context;
  1609. };
  1610. },{}],9:[function(_dereq_,module,exports){
  1611. "use strict";
  1612. module.exports = function(Promise, Context) {
  1613. var getDomain = Promise._getDomain;
  1614. var async = Promise._async;
  1615. var Warning = _dereq_("./errors").Warning;
  1616. var util = _dereq_("./util");
  1617. var canAttachTrace = util.canAttachTrace;
  1618. var unhandledRejectionHandled;
  1619. var possiblyUnhandledRejection;
  1620. var bluebirdFramePattern =
  1621. /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/;
  1622. var nodeFramePattern = /\((?:timers\.js):\d+:\d+\)/;
  1623. var parseLinePattern = /[\/<\(](.+?):(\d+):(\d+)\)?\s*$/;
  1624. var stackFramePattern = null;
  1625. var formatStack = null;
  1626. var indentStackFrames = false;
  1627. var printWarning;
  1628. var debugging = !!(util.env("BLUEBIRD_DEBUG") != 0 &&
  1629. (true ||
  1630. util.env("BLUEBIRD_DEBUG") ||
  1631. util.env("NODE_ENV") === "development"));
  1632. var warnings = !!(util.env("BLUEBIRD_WARNINGS") != 0 &&
  1633. (debugging || util.env("BLUEBIRD_WARNINGS")));
  1634. var longStackTraces = !!(util.env("BLUEBIRD_LONG_STACK_TRACES") != 0 &&
  1635. (debugging || util.env("BLUEBIRD_LONG_STACK_TRACES")));
  1636. var wForgottenReturn = util.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 &&
  1637. (warnings || !!util.env("BLUEBIRD_W_FORGOTTEN_RETURN"));
  1638. Promise.prototype.suppressUnhandledRejections = function() {
  1639. var target = this._target();
  1640. target._bitField = ((target._bitField & (~1048576)) |
  1641. 524288);
  1642. };
  1643. Promise.prototype._ensurePossibleRejectionHandled = function () {
  1644. if ((this._bitField & 524288) !== 0) return;
  1645. this._setRejectionIsUnhandled();
  1646. async.invokeLater(this._notifyUnhandledRejection, this, undefined);
  1647. };
  1648. Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
  1649. fireRejectionEvent("rejectionHandled",
  1650. unhandledRejectionHandled, undefined, this);
  1651. };
  1652. Promise.prototype._setReturnedNonUndefined = function() {
  1653. this._bitField = this._bitField | 268435456;
  1654. };
  1655. Promise.prototype._returnedNonUndefined = function() {
  1656. return (this._bitField & 268435456) !== 0;
  1657. };
  1658. Promise.prototype._notifyUnhandledRejection = function () {
  1659. if (this._isRejectionUnhandled()) {
  1660. var reason = this._settledValue();
  1661. this._setUnhandledRejectionIsNotified();
  1662. fireRejectionEvent("unhandledRejection",
  1663. possiblyUnhandledRejection, reason, this);
  1664. }
  1665. };
  1666. Promise.prototype._setUnhandledRejectionIsNotified = function () {
  1667. this._bitField = this._bitField | 262144;
  1668. };
  1669. Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
  1670. this._bitField = this._bitField & (~262144);
  1671. };
  1672. Promise.prototype._isUnhandledRejectionNotified = function () {
  1673. return (this._bitField & 262144) > 0;
  1674. };
  1675. Promise.prototype._setRejectionIsUnhandled = function () {
  1676. this._bitField = this._bitField | 1048576;
  1677. };
  1678. Promise.prototype._unsetRejectionIsUnhandled = function () {
  1679. this._bitField = this._bitField & (~1048576);
  1680. if (this._isUnhandledRejectionNotified()) {
  1681. this._unsetUnhandledRejectionIsNotified();
  1682. this._notifyUnhandledRejectionIsHandled();
  1683. }
  1684. };
  1685. Promise.prototype._isRejectionUnhandled = function () {
  1686. return (this._bitField & 1048576) > 0;
  1687. };
  1688. Promise.prototype._warn = function(message, shouldUseOwnTrace, promise) {
  1689. return warn(message, shouldUseOwnTrace, promise || this);
  1690. };
  1691. Promise.onPossiblyUnhandledRejection = function (fn) {
  1692. var domain = getDomain();
  1693. possiblyUnhandledRejection =
  1694. typeof fn === "function" ? (domain === null ?
  1695. fn : util.domainBind(domain, fn))
  1696. : undefined;
  1697. };
  1698. Promise.onUnhandledRejectionHandled = function (fn) {
  1699. var domain = getDomain();
  1700. unhandledRejectionHandled =
  1701. typeof fn === "function" ? (domain === null ?
  1702. fn : util.domainBind(domain, fn))
  1703. : undefined;
  1704. };
  1705. var disableLongStackTraces = function() {};
  1706. Promise.longStackTraces = function () {
  1707. if (async.haveItemsQueued() && !config.longStackTraces) {
  1708. throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  1709. }
  1710. if (!config.longStackTraces && longStackTracesIsSupported()) {
  1711. var Promise_captureStackTrace = Promise.prototype._captureStackTrace;
  1712. var Promise_attachExtraTrace = Promise.prototype._attachExtraTrace;
  1713. config.longStackTraces = true;
  1714. disableLongStackTraces = function() {
  1715. if (async.haveItemsQueued() && !config.longStackTraces) {
  1716. throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  1717. }
  1718. Promise.prototype._captureStackTrace = Promise_captureStackTrace;
  1719. Promise.prototype._attachExtraTrace = Promise_attachExtraTrace;
  1720. Context.deactivateLongStackTraces();
  1721. async.enableTrampoline();
  1722. config.longStackTraces = false;
  1723. };
  1724. Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace;
  1725. Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace;
  1726. Context.activateLongStackTraces();
  1727. async.disableTrampolineIfNecessary();
  1728. }
  1729. };
  1730. Promise.hasLongStackTraces = function () {
  1731. return config.longStackTraces && longStackTracesIsSupported();
  1732. };
  1733. var fireDomEvent = (function() {
  1734. try {
  1735. if (typeof CustomEvent === "function") {
  1736. var event = new CustomEvent("CustomEvent");
  1737. util.global.dispatchEvent(event);
  1738. return function(name, event) {
  1739. var domEvent = new CustomEvent(name.toLowerCase(), {
  1740. detail: event,
  1741. cancelable: true
  1742. });
  1743. return !util.global.dispatchEvent(domEvent);
  1744. };
  1745. } else if (typeof Event === "function") {
  1746. var event = new Event("CustomEvent");
  1747. util.global.dispatchEvent(event);
  1748. return function(name, event) {
  1749. var domEvent = new Event(name.toLowerCase(), {
  1750. cancelable: true
  1751. });
  1752. domEvent.detail = event;
  1753. return !util.global.dispatchEvent(domEvent);
  1754. };
  1755. } else {
  1756. var event = document.createEvent("CustomEvent");
  1757. event.initCustomEvent("testingtheevent", false, true, {});
  1758. util.global.dispatchEvent(event);
  1759. return function(name, event) {
  1760. var domEvent = document.createEvent("CustomEvent");
  1761. domEvent.initCustomEvent(name.toLowerCase(), false, true,
  1762. event);
  1763. return !util.global.dispatchEvent(domEvent);
  1764. };
  1765. }
  1766. } catch (e) {}
  1767. return function() {
  1768. return false;
  1769. };
  1770. })();
  1771. var fireGlobalEvent = (function() {
  1772. if (util.isNode) {
  1773. return function() {
  1774. return process.emit.apply(process, arguments);
  1775. };
  1776. } else {
  1777. if (!util.global) {
  1778. return function() {
  1779. return false;
  1780. };
  1781. }
  1782. return function(name) {
  1783. var methodName = "on" + name.toLowerCase();
  1784. var method = util.global[methodName];
  1785. if (!method) return false;
  1786. method.apply(util.global, [].slice.call(arguments, 1));
  1787. return true;
  1788. };
  1789. }
  1790. })();
  1791. function generatePromiseLifecycleEventObject(name, promise) {
  1792. return {promise: promise};
  1793. }
  1794. var eventToObjectGenerator = {
  1795. promiseCreated: generatePromiseLifecycleEventObject,
  1796. promiseFulfilled: generatePromiseLifecycleEventObject,
  1797. promiseRejected: generatePromiseLifecycleEventObject,
  1798. promiseResolved: generatePromiseLifecycleEventObject,
  1799. promiseCancelled: generatePromiseLifecycleEventObject,
  1800. promiseChained: function(name, promise, child) {
  1801. return {promise: promise, child: child};
  1802. },
  1803. warning: function(name, warning) {
  1804. return {warning: warning};
  1805. },
  1806. unhandledRejection: function (name, reason, promise) {
  1807. return {reason: reason, promise: promise};
  1808. },
  1809. rejectionHandled: generatePromiseLifecycleEventObject
  1810. };
  1811. var activeFireEvent = function (name) {
  1812. var globalEventFired = false;
  1813. try {
  1814. globalEventFired = fireGlobalEvent.apply(null, arguments);
  1815. } catch (e) {
  1816. async.throwLater(e);
  1817. globalEventFired = true;
  1818. }
  1819. var domEventFired = false;
  1820. try {
  1821. domEventFired = fireDomEvent(name,
  1822. eventToObjectGenerator[name].apply(null, arguments));
  1823. } catch (e) {
  1824. async.throwLater(e);
  1825. domEventFired = true;
  1826. }
  1827. return domEventFired || globalEventFired;
  1828. };
  1829. Promise.config = function(opts) {
  1830. opts = Object(opts);
  1831. if ("longStackTraces" in opts) {
  1832. if (opts.longStackTraces) {
  1833. Promise.longStackTraces();
  1834. } else if (!opts.longStackTraces && Promise.hasLongStackTraces()) {
  1835. disableLongStackTraces();
  1836. }
  1837. }
  1838. if ("warnings" in opts) {
  1839. var warningsOption = opts.warnings;
  1840. config.warnings = !!warningsOption;
  1841. wForgottenReturn = config.warnings;
  1842. if (util.isObject(warningsOption)) {
  1843. if ("wForgottenReturn" in warningsOption) {
  1844. wForgottenReturn = !!warningsOption.wForgottenReturn;
  1845. }
  1846. }
  1847. }
  1848. if ("cancellation" in opts && opts.cancellation && !config.cancellation) {
  1849. if (async.haveItemsQueued()) {
  1850. throw new Error(
  1851. "cannot enable cancellation after promises are in use");
  1852. }
  1853. Promise.prototype._clearCancellationData =
  1854. cancellationClearCancellationData;
  1855. Promise.prototype._propagateFrom = cancellationPropagateFrom;
  1856. Promise.prototype._onCancel = cancellationOnCancel;
  1857. Promise.prototype._setOnCancel = cancellationSetOnCancel;
  1858. Promise.prototype._attachCancellationCallback =
  1859. cancellationAttachCancellationCallback;
  1860. Promise.prototype._execute = cancellationExecute;
  1861. propagateFromFunction = cancellationPropagateFrom;
  1862. config.cancellation = true;
  1863. }
  1864. if ("monitoring" in opts) {
  1865. if (opts.monitoring && !config.monitoring) {
  1866. config.monitoring = true;
  1867. Promise.prototype._fireEvent = activeFireEvent;
  1868. } else if (!opts.monitoring && config.monitoring) {
  1869. config.monitoring = false;
  1870. Promise.prototype._fireEvent = defaultFireEvent;
  1871. }
  1872. }
  1873. };
  1874. function defaultFireEvent() { return false; }
  1875. Promise.prototype._fireEvent = defaultFireEvent;
  1876. Promise.prototype._execute = function(executor, resolve, reject) {
  1877. try {
  1878. executor(resolve, reject);
  1879. } catch (e) {
  1880. return e;
  1881. }
  1882. };
  1883. Promise.prototype._onCancel = function () {};
  1884. Promise.prototype._setOnCancel = function (handler) { ; };
  1885. Promise.prototype._attachCancellationCallback = function(onCancel) {
  1886. ;
  1887. };
  1888. Promise.prototype._captureStackTrace = function () {};
  1889. Promise.prototype._attachExtraTrace = function () {};
  1890. Promise.prototype._clearCancellationData = function() {};
  1891. Promise.prototype._propagateFrom = function (parent, flags) {
  1892. ;
  1893. ;
  1894. };
  1895. function cancellationExecute(executor, resolve, reject) {
  1896. var promise = this;
  1897. try {
  1898. executor(resolve, reject, function(onCancel) {
  1899. if (typeof onCancel !== "function") {
  1900. throw new TypeError("onCancel must be a function, got: " +
  1901. util.toString(onCancel));
  1902. }
  1903. promise._attachCancellationCallback(onCancel);
  1904. });
  1905. } catch (e) {
  1906. return e;
  1907. }
  1908. }
  1909. function cancellationAttachCancellationCallback(onCancel) {
  1910. if (!this._isCancellable()) return this;
  1911. var previousOnCancel = this._onCancel();
  1912. if (previousOnCancel !== undefined) {
  1913. if (util.isArray(previousOnCancel)) {
  1914. previousOnCancel.push(onCancel);
  1915. } else {
  1916. this._setOnCancel([previousOnCancel, onCancel]);
  1917. }
  1918. } else {
  1919. this._setOnCancel(onCancel);
  1920. }
  1921. }
  1922. function cancellationOnCancel() {
  1923. return this._onCancelField;
  1924. }
  1925. function cancellationSetOnCancel(onCancel) {
  1926. this._onCancelField = onCancel;
  1927. }
  1928. function cancellationClearCancellationData() {
  1929. this._cancellationParent = undefined;
  1930. this._onCancelField = undefined;
  1931. }
  1932. function cancellationPropagateFrom(parent, flags) {
  1933. if ((flags & 1) !== 0) {
  1934. this._cancellationParent = parent;
  1935. var branchesRemainingToCancel = parent._branchesRemainingToCancel;
  1936. if (branchesRemainingToCancel === undefined) {
  1937. branchesRemainingToCancel = 0;
  1938. }
  1939. parent._branchesRemainingToCancel = branchesRemainingToCancel + 1;
  1940. }
  1941. if ((flags & 2) !== 0 && parent._isBound()) {
  1942. this._setBoundTo(parent._boundTo);
  1943. }
  1944. }
  1945. function bindingPropagateFrom(parent, flags) {
  1946. if ((flags & 2) !== 0 && parent._isBound()) {
  1947. this._setBoundTo(parent._boundTo);
  1948. }
  1949. }
  1950. var propagateFromFunction = bindingPropagateFrom;
  1951. function boundValueFunction() {
  1952. var ret = this._boundTo;
  1953. if (ret !== undefined) {
  1954. if (ret instanceof Promise) {
  1955. if (ret.isFulfilled()) {
  1956. return ret.value();
  1957. } else {
  1958. return undefined;
  1959. }
  1960. }
  1961. }
  1962. return ret;
  1963. }
  1964. function longStackTracesCaptureStackTrace() {
  1965. this._trace = new CapturedTrace(this._peekContext());
  1966. }
  1967. function longStackTracesAttachExtraTrace(error, ignoreSelf) {
  1968. if (canAttachTrace(error)) {
  1969. var trace = this._trace;
  1970. if (trace !== undefined) {
  1971. if (ignoreSelf) trace = trace._parent;
  1972. }
  1973. if (trace !== undefined) {
  1974. trace.attachExtraTrace(error);
  1975. } else if (!error.__stackCleaned__) {
  1976. var parsed = parseStackAndMessage(error);
  1977. util.notEnumerableProp(error, "stack",
  1978. parsed.message + "\n" + parsed.stack.join("\n"));
  1979. util.notEnumerableProp(error, "__stackCleaned__", true);
  1980. }
  1981. }
  1982. }
  1983. function checkForgottenReturns(returnValue, promiseCreated, name, promise,
  1984. parent) {
  1985. if (returnValue === undefined && promiseCreated !== null &&
  1986. wForgottenReturn) {
  1987. if (parent !== undefined && parent._returnedNonUndefined()) return;
  1988. if ((promise._bitField & 65535) === 0) return;
  1989. if (name) name = name + " ";
  1990. var handlerLine = "";
  1991. var creatorLine = "";
  1992. if (promiseCreated._trace) {
  1993. var traceLines = promiseCreated._trace.stack.split("\n");
  1994. var stack = cleanStack(traceLines);
  1995. for (var i = stack.length - 1; i >= 0; --i) {
  1996. var line = stack[i];
  1997. if (!nodeFramePattern.test(line)) {
  1998. var lineMatches = line.match(parseLinePattern);
  1999. if (lineMatches) {
  2000. handlerLine = "at " + lineMatches[1] +
  2001. ":" + lineMatches[2] + ":" + lineMatches[3] + " ";
  2002. }
  2003. break;
  2004. }
  2005. }
  2006. if (stack.length > 0) {
  2007. var firstUserLine = stack[0];
  2008. for (var i = 0; i < traceLines.length; ++i) {
  2009. if (traceLines[i] === firstUserLine) {
  2010. if (i > 0) {
  2011. creatorLine = "\n" + traceLines[i - 1];
  2012. }
  2013. break;
  2014. }
  2015. }
  2016. }
  2017. }
  2018. var msg = "a promise was created in a " + name +
  2019. "handler " + handlerLine + "but was not returned from it, " +
  2020. "see http://goo.gl/rRqMUw" +
  2021. creatorLine;
  2022. promise._warn(msg, true, promiseCreated);
  2023. }
  2024. }
  2025. function deprecated(name, replacement) {
  2026. var message = name +
  2027. " is deprecated and will be removed in a future version.";
  2028. if (replacement) message += " Use " + replacement + " instead.";
  2029. return warn(message);
  2030. }
  2031. function warn(message, shouldUseOwnTrace, promise) {
  2032. if (!config.warnings) return;
  2033. var warning = new Warning(message);
  2034. var ctx;
  2035. if (shouldUseOwnTrace) {
  2036. promise._attachExtraTrace(warning);
  2037. } else if (config.longStackTraces && (ctx = Promise._peekContext())) {
  2038. ctx.attachExtraTrace(warning);
  2039. } else {
  2040. var parsed = parseStackAndMessage(warning);
  2041. warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
  2042. }
  2043. if (!activeFireEvent("warning", warning)) {
  2044. formatAndLogError(warning, "", true);
  2045. }
  2046. }
  2047. function reconstructStack(message, stacks) {
  2048. for (var i = 0; i < stacks.length - 1; ++i) {
  2049. stacks[i].push("From previous event:");
  2050. stacks[i] = stacks[i].join("\n");
  2051. }
  2052. if (i < stacks.length) {
  2053. stacks[i] = stacks[i].join("\n");
  2054. }
  2055. return message + "\n" + stacks.join("\n");
  2056. }
  2057. function removeDuplicateOrEmptyJumps(stacks) {
  2058. for (var i = 0; i < stacks.length; ++i) {
  2059. if (stacks[i].length === 0 ||
  2060. ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
  2061. stacks.splice(i, 1);
  2062. i--;
  2063. }
  2064. }
  2065. }
  2066. function removeCommonRoots(stacks) {
  2067. var current = stacks[0];
  2068. for (var i = 1; i < stacks.length; ++i) {
  2069. var prev = stacks[i];
  2070. var currentLastIndex = current.length - 1;
  2071. var currentLastLine = current[currentLastIndex];
  2072. var commonRootMeetPoint = -1;
  2073. for (var j = prev.length - 1; j >= 0; --j) {
  2074. if (prev[j] === currentLastLine) {
  2075. commonRootMeetPoint = j;
  2076. break;
  2077. }
  2078. }
  2079. for (var j = commonRootMeetPoint; j >= 0; --j) {
  2080. var line = prev[j];
  2081. if (current[currentLastIndex] === line) {
  2082. current.pop();
  2083. currentLastIndex--;
  2084. } else {
  2085. break;
  2086. }
  2087. }
  2088. current = prev;
  2089. }
  2090. }
  2091. function cleanStack(stack) {
  2092. var ret = [];
  2093. for (var i = 0; i < stack.length; ++i) {
  2094. var line = stack[i];
  2095. var isTraceLine = " (No stack trace)" === line ||
  2096. stackFramePattern.test(line);
  2097. var isInternalFrame = isTraceLine && shouldIgnore(line);
  2098. if (isTraceLine && !isInternalFrame) {
  2099. if (indentStackFrames && line.charAt(0) !== " ") {
  2100. line = " " + line;
  2101. }
  2102. ret.push(line);
  2103. }
  2104. }
  2105. return ret;
  2106. }
  2107. function stackFramesAsArray(error) {
  2108. var stack = error.stack.replace(/\s+$/g, "").split("\n");
  2109. for (var i = 0; i < stack.length; ++i) {
  2110. var line = stack[i];
  2111. if (" (No stack trace)" === line || stackFramePattern.test(line)) {
  2112. break;
  2113. }
  2114. }
  2115. if (i > 0) {
  2116. stack = stack.slice(i);
  2117. }
  2118. return stack;
  2119. }
  2120. function parseStackAndMessage(error) {
  2121. var stack = error.stack;
  2122. var message = error.toString();
  2123. stack = typeof stack === "string" && stack.length > 0
  2124. ? stackFramesAsArray(error) : [" (No stack trace)"];
  2125. return {
  2126. message: message,
  2127. stack: cleanStack(stack)
  2128. };
  2129. }
  2130. function formatAndLogError(error, title, isSoft) {
  2131. if (typeof console !== "undefined") {
  2132. var message;
  2133. if (util.isObject(error)) {
  2134. var stack = error.stack;
  2135. message = title + formatStack(stack, error);
  2136. } else {
  2137. message = title + String(error);
  2138. }
  2139. if (typeof printWarning === "function") {
  2140. printWarning(message, isSoft);
  2141. } else if (typeof console.log === "function" ||
  2142. typeof console.log === "object") {
  2143. console.log(message);
  2144. }
  2145. }
  2146. }
  2147. function fireRejectionEvent(name, localHandler, reason, promise) {
  2148. var localEventFired = false;
  2149. try {
  2150. if (typeof localHandler === "function") {
  2151. localEventFired = true;
  2152. if (name === "rejectionHandled") {
  2153. localHandler(promise);
  2154. } else {
  2155. localHandler(reason, promise);
  2156. }
  2157. }
  2158. } catch (e) {
  2159. async.throwLater(e);
  2160. }
  2161. if (name === "unhandledRejection") {
  2162. if (!activeFireEvent(name, reason, promise) && !localEventFired) {
  2163. formatAndLogError(reason, "Unhandled rejection ");
  2164. }
  2165. } else {
  2166. activeFireEvent(name, promise);
  2167. }
  2168. }
  2169. function formatNonError(obj) {
  2170. var str;
  2171. if (typeof obj === "function") {
  2172. str = "[function " +
  2173. (obj.name || "anonymous") +
  2174. "]";
  2175. } else {
  2176. str = obj && typeof obj.toString === "function"
  2177. ? obj.toString() : util.toString(obj);
  2178. var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
  2179. if (ruselessToString.test(str)) {
  2180. try {
  2181. var newStr = JSON.stringify(obj);
  2182. str = newStr;
  2183. }
  2184. catch(e) {
  2185. }
  2186. }
  2187. if (str.length === 0) {
  2188. str = "(empty array)";
  2189. }
  2190. }
  2191. return ("(<" + snip(str) + ">, no stack trace)");
  2192. }
  2193. function snip(str) {
  2194. var maxChars = 41;
  2195. if (str.length < maxChars) {
  2196. return str;
  2197. }
  2198. return str.substr(0, maxChars - 3) + "...";
  2199. }
  2200. function longStackTracesIsSupported() {
  2201. return typeof captureStackTrace === "function";
  2202. }
  2203. var shouldIgnore = function() { return false; };
  2204. var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
  2205. function parseLineInfo(line) {
  2206. var matches = line.match(parseLineInfoRegex);
  2207. if (matches) {
  2208. return {
  2209. fileName: matches[1],
  2210. line: parseInt(matches[2], 10)
  2211. };
  2212. }
  2213. }
  2214. function setBounds(firstLineError, lastLineError) {
  2215. if (!longStackTracesIsSupported()) return;
  2216. var firstStackLines = firstLineError.stack.split("\n");
  2217. var lastStackLines = lastLineError.stack.split("\n");
  2218. var firstIndex = -1;
  2219. var lastIndex = -1;
  2220. var firstFileName;
  2221. var lastFileName;
  2222. for (var i = 0; i < firstStackLines.length; ++i) {
  2223. var result = parseLineInfo(firstStackLines[i]);
  2224. if (result) {
  2225. firstFileName = result.fileName;
  2226. firstIndex = result.line;
  2227. break;
  2228. }
  2229. }
  2230. for (var i = 0; i < lastStackLines.length; ++i) {
  2231. var result = parseLineInfo(lastStackLines[i]);
  2232. if (result) {
  2233. lastFileName = result.fileName;
  2234. lastIndex = result.line;
  2235. break;
  2236. }
  2237. }
  2238. if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
  2239. firstFileName !== lastFileName || firstIndex >= lastIndex) {
  2240. return;
  2241. }
  2242. shouldIgnore = function(line) {
  2243. if (bluebirdFramePattern.test(line)) return true;
  2244. var info = parseLineInfo(line);
  2245. if (info) {
  2246. if (info.fileName === firstFileName &&
  2247. (firstIndex <= info.line && info.line <= lastIndex)) {
  2248. return true;
  2249. }
  2250. }
  2251. return false;
  2252. };
  2253. }
  2254. function CapturedTrace(parent) {
  2255. this._parent = parent;
  2256. this._promisesCreated = 0;
  2257. var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
  2258. captureStackTrace(this, CapturedTrace);
  2259. if (length > 32) this.uncycle();
  2260. }
  2261. util.inherits(CapturedTrace, Error);
  2262. Context.CapturedTrace = CapturedTrace;
  2263. CapturedTrace.prototype.uncycle = function() {
  2264. var length = this._length;
  2265. if (length < 2) return;
  2266. var nodes = [];
  2267. var stackToIndex = {};
  2268. for (var i = 0, node = this; node !== undefined; ++i) {
  2269. nodes.push(node);
  2270. node = node._parent;
  2271. }
  2272. length = this._length = i;
  2273. for (var i = length - 1; i >= 0; --i) {
  2274. var stack = nodes[i].stack;
  2275. if (stackToIndex[stack] === undefined) {
  2276. stackToIndex[stack] = i;
  2277. }
  2278. }
  2279. for (var i = 0; i < length; ++i) {
  2280. var currentStack = nodes[i].stack;
  2281. var index = stackToIndex[currentStack];
  2282. if (index !== undefined && index !== i) {
  2283. if (index > 0) {
  2284. nodes[index - 1]._parent = undefined;
  2285. nodes[index - 1]._length = 1;
  2286. }
  2287. nodes[i]._parent = undefined;
  2288. nodes[i]._length = 1;
  2289. var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
  2290. if (index < length - 1) {
  2291. cycleEdgeNode._parent = nodes[index + 1];
  2292. cycleEdgeNode._parent.uncycle();
  2293. cycleEdgeNode._length =
  2294. cycleEdgeNode._parent._length + 1;
  2295. } else {
  2296. cycleEdgeNode._parent = undefined;
  2297. cycleEdgeNode._length = 1;
  2298. }
  2299. var currentChildLength = cycleEdgeNode._length + 1;
  2300. for (var j = i - 2; j >= 0; --j) {
  2301. nodes[j]._length = currentChildLength;
  2302. currentChildLength++;
  2303. }
  2304. return;
  2305. }
  2306. }
  2307. };
  2308. CapturedTrace.prototype.attachExtraTrace = function(error) {
  2309. if (error.__stackCleaned__) return;
  2310. this.uncycle();
  2311. var parsed = parseStackAndMessage(error);
  2312. var message = parsed.message;
  2313. var stacks = [parsed.stack];
  2314. var trace = this;
  2315. while (trace !== undefined) {
  2316. stacks.push(cleanStack(trace.stack.split("\n")));
  2317. trace = trace._parent;
  2318. }
  2319. removeCommonRoots(stacks);
  2320. removeDuplicateOrEmptyJumps(stacks);
  2321. util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
  2322. util.notEnumerableProp(error, "__stackCleaned__", true);
  2323. };
  2324. var captureStackTrace = (function stackDetection() {
  2325. var v8stackFramePattern = /^\s*at\s*/;
  2326. var v8stackFormatter = function(stack, error) {
  2327. if (typeof stack === "string") return stack;
  2328. if (error.name !== undefined &&
  2329. error.message !== undefined) {
  2330. return error.toString();
  2331. }
  2332. return formatNonError(error);
  2333. };
  2334. if (typeof Error.stackTraceLimit === "number" &&
  2335. typeof Error.captureStackTrace === "function") {
  2336. Error.stackTraceLimit += 6;
  2337. stackFramePattern = v8stackFramePattern;
  2338. formatStack = v8stackFormatter;
  2339. var captureStackTrace = Error.captureStackTrace;
  2340. shouldIgnore = function(line) {
  2341. return bluebirdFramePattern.test(line);
  2342. };
  2343. return function(receiver, ignoreUntil) {
  2344. Error.stackTraceLimit += 6;
  2345. captureStackTrace(receiver, ignoreUntil);
  2346. Error.stackTraceLimit -= 6;
  2347. };
  2348. }
  2349. var err = new Error();
  2350. if (typeof err.stack === "string" &&
  2351. err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
  2352. stackFramePattern = /@/;
  2353. formatStack = v8stackFormatter;
  2354. indentStackFrames = true;
  2355. return function captureStackTrace(o) {
  2356. o.stack = new Error().stack;
  2357. };
  2358. }
  2359. var hasStackAfterThrow;
  2360. try { throw new Error(); }
  2361. catch(e) {
  2362. hasStackAfterThrow = ("stack" in e);
  2363. }
  2364. if (!("stack" in err) && hasStackAfterThrow &&
  2365. typeof Error.stackTraceLimit === "number") {
  2366. stackFramePattern = v8stackFramePattern;
  2367. formatStack = v8stackFormatter;
  2368. return function captureStackTrace(o) {
  2369. Error.stackTraceLimit += 6;
  2370. try { throw new Error(); }
  2371. catch(e) { o.stack = e.stack; }
  2372. Error.stackTraceLimit -= 6;
  2373. };
  2374. }
  2375. formatStack = function(stack, error) {
  2376. if (typeof stack === "string") return stack;
  2377. if ((typeof error === "object" ||
  2378. typeof error === "function") &&
  2379. error.name !== undefined &&
  2380. error.message !== undefined) {
  2381. return error.toString();
  2382. }
  2383. return formatNonError(error);
  2384. };
  2385. return null;
  2386. })([]);
  2387. if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
  2388. printWarning = function (message) {
  2389. console.warn(message);
  2390. };
  2391. if (util.isNode && process.stderr.isTTY) {
  2392. printWarning = function(message, isSoft) {
  2393. var color = isSoft ? "\u001b[33m" : "\u001b[31m";
  2394. console.warn(color + message + "\u001b[0m\n");
  2395. };
  2396. } else if (!util.isNode && typeof (new Error().stack) === "string") {
  2397. printWarning = function(message, isSoft) {
  2398. console.warn("%c" + message,
  2399. isSoft ? "color: darkorange" : "color: red");
  2400. };
  2401. }
  2402. }
  2403. var config = {
  2404. warnings: warnings,
  2405. longStackTraces: false,
  2406. cancellation: false,
  2407. monitoring: false
  2408. };
  2409. if (longStackTraces) Promise.longStackTraces();
  2410. return {
  2411. longStackTraces: function() {
  2412. return config.longStackTraces;
  2413. },
  2414. warnings: function() {
  2415. return config.warnings;
  2416. },
  2417. cancellation: function() {
  2418. return config.cancellation;
  2419. },
  2420. monitoring: function() {
  2421. return config.monitoring;
  2422. },
  2423. propagateFromFunction: function() {
  2424. return propagateFromFunction;
  2425. },
  2426. boundValueFunction: function() {
  2427. return boundValueFunction;
  2428. },
  2429. checkForgottenReturns: checkForgottenReturns,
  2430. setBounds: setBounds,
  2431. warn: warn,
  2432. deprecated: deprecated,
  2433. CapturedTrace: CapturedTrace,
  2434. fireDomEvent: fireDomEvent,
  2435. fireGlobalEvent: fireGlobalEvent
  2436. };
  2437. };
  2438. },{"./errors":12,"./util":36}],10:[function(_dereq_,module,exports){
  2439. "use strict";
  2440. module.exports = function(Promise) {
  2441. function returner() {
  2442. return this.value;
  2443. }
  2444. function thrower() {
  2445. throw this.reason;
  2446. }
  2447. Promise.prototype["return"] =
  2448. Promise.prototype.thenReturn = function (value) {
  2449. if (value instanceof Promise) value.suppressUnhandledRejections();
  2450. return this._then(
  2451. returner, undefined, undefined, {value: value}, undefined);
  2452. };
  2453. Promise.prototype["throw"] =
  2454. Promise.prototype.thenThrow = function (reason) {
  2455. return this._then(
  2456. thrower, undefined, undefined, {reason: reason}, undefined);
  2457. };
  2458. Promise.prototype.catchThrow = function (reason) {
  2459. if (arguments.length <= 1) {
  2460. return this._then(
  2461. undefined, thrower, undefined, {reason: reason}, undefined);
  2462. } else {
  2463. var _reason = arguments[1];
  2464. var handler = function() {throw _reason;};
  2465. return this.caught(reason, handler);
  2466. }
  2467. };
  2468. Promise.prototype.catchReturn = function (value) {
  2469. if (arguments.length <= 1) {
  2470. if (value instanceof Promise) value.suppressUnhandledRejections();
  2471. return this._then(
  2472. undefined, returner, undefined, {value: value}, undefined);
  2473. } else {
  2474. var _value = arguments[1];
  2475. if (_value instanceof Promise) _value.suppressUnhandledRejections();
  2476. var handler = function() {return _value;};
  2477. return this.caught(value, handler);
  2478. }
  2479. };
  2480. };
  2481. },{}],11:[function(_dereq_,module,exports){
  2482. "use strict";
  2483. module.exports = function(Promise, INTERNAL) {
  2484. var PromiseReduce = Promise.reduce;
  2485. var PromiseAll = Promise.all;
  2486. function promiseAllThis() {
  2487. return PromiseAll(this);
  2488. }
  2489. function PromiseMapSeries(promises, fn) {
  2490. return PromiseReduce(promises, fn, INTERNAL, INTERNAL);
  2491. }
  2492. Promise.prototype.each = function (fn) {
  2493. return PromiseReduce(this, fn, INTERNAL, 0)
  2494. ._then(promiseAllThis, undefined, undefined, this, undefined);
  2495. };
  2496. Promise.prototype.mapSeries = function (fn) {
  2497. return PromiseReduce(this, fn, INTERNAL, INTERNAL);
  2498. };
  2499. Promise.each = function (promises, fn) {
  2500. return PromiseReduce(promises, fn, INTERNAL, 0)
  2501. ._then(promiseAllThis, undefined, undefined, promises, undefined);
  2502. };
  2503. Promise.mapSeries = PromiseMapSeries;
  2504. };
  2505. },{}],12:[function(_dereq_,module,exports){
  2506. "use strict";
  2507. var es5 = _dereq_("./es5");
  2508. var Objectfreeze = es5.freeze;
  2509. var util = _dereq_("./util");
  2510. var inherits = util.inherits;
  2511. var notEnumerableProp = util.notEnumerableProp;
  2512. function subError(nameProperty, defaultMessage) {
  2513. function SubError(message) {
  2514. if (!(this instanceof SubError)) return new SubError(message);
  2515. notEnumerableProp(this, "message",
  2516. typeof message === "string" ? message : defaultMessage);
  2517. notEnumerableProp(this, "name", nameProperty);
  2518. if (Error.captureStackTrace) {
  2519. Error.captureStackTrace(this, this.constructor);
  2520. } else {
  2521. Error.call(this);
  2522. }
  2523. }
  2524. inherits(SubError, Error);
  2525. return SubError;
  2526. }
  2527. var _TypeError, _RangeError;
  2528. var Warning = subError("Warning", "warning");
  2529. var CancellationError = subError("CancellationError", "cancellation error");
  2530. var TimeoutError = subError("TimeoutError", "timeout error");
  2531. var AggregateError = subError("AggregateError", "aggregate error");
  2532. try {
  2533. _TypeError = TypeError;
  2534. _RangeError = RangeError;
  2535. } catch(e) {
  2536. _TypeError = subError("TypeError", "type error");
  2537. _RangeError = subError("RangeError", "range error");
  2538. }
  2539. var methods = ("join pop push shift unshift slice filter forEach some " +
  2540. "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
  2541. for (var i = 0; i < methods.length; ++i) {
  2542. if (typeof Array.prototype[methods[i]] === "function") {
  2543. AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
  2544. }
  2545. }
  2546. es5.defineProperty(AggregateError.prototype, "length", {
  2547. value: 0,
  2548. configurable: false,
  2549. writable: true,
  2550. enumerable: true
  2551. });
  2552. AggregateError.prototype["isOperational"] = true;
  2553. var level = 0;
  2554. AggregateError.prototype.toString = function() {
  2555. var indent = Array(level * 4 + 1).join(" ");
  2556. var ret = "\n" + indent + "AggregateError of:" + "\n";
  2557. level++;
  2558. indent = Array(level * 4 + 1).join(" ");
  2559. for (var i = 0; i < this.length; ++i) {
  2560. var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
  2561. var lines = str.split("\n");
  2562. for (var j = 0; j < lines.length; ++j) {
  2563. lines[j] = indent + lines[j];
  2564. }
  2565. str = lines.join("\n");
  2566. ret += str + "\n";
  2567. }
  2568. level--;
  2569. return ret;
  2570. };
  2571. function OperationalError(message) {
  2572. if (!(this instanceof OperationalError))
  2573. return new OperationalError(message);
  2574. notEnumerableProp(this, "name", "OperationalError");
  2575. notEnumerableProp(this, "message", message);
  2576. this.cause = message;
  2577. this["isOperational"] = true;
  2578. if (message instanceof Error) {
  2579. notEnumerableProp(this, "message", message.message);
  2580. notEnumerableProp(this, "stack", message.stack);
  2581. } else if (Error.captureStackTrace) {
  2582. Error.captureStackTrace(this, this.constructor);
  2583. }
  2584. }
  2585. inherits(OperationalError, Error);
  2586. var errorTypes = Error["__BluebirdErrorTypes__"];
  2587. if (!errorTypes) {
  2588. errorTypes = Objectfreeze({
  2589. CancellationError: CancellationError,
  2590. TimeoutError: TimeoutError,
  2591. OperationalError: OperationalError,
  2592. RejectionError: OperationalError,
  2593. AggregateError: AggregateError
  2594. });
  2595. es5.defineProperty(Error, "__BluebirdErrorTypes__", {
  2596. value: errorTypes,
  2597. writable: false,
  2598. enumerable: false,
  2599. configurable: false
  2600. });
  2601. }
  2602. module.exports = {
  2603. Error: Error,
  2604. TypeError: _TypeError,
  2605. RangeError: _RangeError,
  2606. CancellationError: errorTypes.CancellationError,
  2607. OperationalError: errorTypes.OperationalError,
  2608. TimeoutError: errorTypes.TimeoutError,
  2609. AggregateError: errorTypes.AggregateError,
  2610. Warning: Warning
  2611. };
  2612. },{"./es5":13,"./util":36}],13:[function(_dereq_,module,exports){
  2613. var isES5 = (function(){
  2614. "use strict";
  2615. return this === undefined;
  2616. })();
  2617. if (isES5) {
  2618. module.exports = {
  2619. freeze: Object.freeze,
  2620. defineProperty: Object.defineProperty,
  2621. getDescriptor: Object.getOwnPropertyDescriptor,
  2622. keys: Object.keys,
  2623. names: Object.getOwnPropertyNames,
  2624. getPrototypeOf: Object.getPrototypeOf,
  2625. isArray: Array.isArray,
  2626. isES5: isES5,
  2627. propertyIsWritable: function(obj, prop) {
  2628. var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
  2629. return !!(!descriptor || descriptor.writable || descriptor.set);
  2630. }
  2631. };
  2632. } else {
  2633. var has = {}.hasOwnProperty;
  2634. var str = {}.toString;
  2635. var proto = {}.constructor.prototype;
  2636. var ObjectKeys = function (o) {
  2637. var ret = [];
  2638. for (var key in o) {
  2639. if (has.call(o, key)) {
  2640. ret.push(key);
  2641. }
  2642. }
  2643. return ret;
  2644. };
  2645. var ObjectGetDescriptor = function(o, key) {
  2646. return {value: o[key]};
  2647. };
  2648. var ObjectDefineProperty = function (o, key, desc) {
  2649. o[key] = desc.value;
  2650. return o;
  2651. };
  2652. var ObjectFreeze = function (obj) {
  2653. return obj;
  2654. };
  2655. var ObjectGetPrototypeOf = function (obj) {
  2656. try {
  2657. return Object(obj).constructor.prototype;
  2658. }
  2659. catch (e) {
  2660. return proto;
  2661. }
  2662. };
  2663. var ArrayIsArray = function (obj) {
  2664. try {
  2665. return str.call(obj) === "[object Array]";
  2666. }
  2667. catch(e) {
  2668. return false;
  2669. }
  2670. };
  2671. module.exports = {
  2672. isArray: ArrayIsArray,
  2673. keys: ObjectKeys,
  2674. names: ObjectKeys,
  2675. defineProperty: ObjectDefineProperty,
  2676. getDescriptor: ObjectGetDescriptor,
  2677. freeze: ObjectFreeze,
  2678. getPrototypeOf: ObjectGetPrototypeOf,
  2679. isES5: isES5,
  2680. propertyIsWritable: function() {
  2681. return true;
  2682. }
  2683. };
  2684. }
  2685. },{}],14:[function(_dereq_,module,exports){
  2686. "use strict";
  2687. module.exports = function(Promise, INTERNAL) {
  2688. var PromiseMap = Promise.map;
  2689. Promise.prototype.filter = function (fn, options) {
  2690. return PromiseMap(this, fn, options, INTERNAL);
  2691. };
  2692. Promise.filter = function (promises, fn, options) {
  2693. return PromiseMap(promises, fn, options, INTERNAL);
  2694. };
  2695. };
  2696. },{}],15:[function(_dereq_,module,exports){
  2697. "use strict";
  2698. module.exports = function(Promise, tryConvertToPromise) {
  2699. var util = _dereq_("./util");
  2700. var CancellationError = Promise.CancellationError;
  2701. var errorObj = util.errorObj;
  2702. function PassThroughHandlerContext(promise, type, handler) {
  2703. this.promise = promise;
  2704. this.type = type;
  2705. this.handler = handler;
  2706. this.called = false;
  2707. this.cancelPromise = null;
  2708. }
  2709. PassThroughHandlerContext.prototype.isFinallyHandler = function() {
  2710. return this.type === 0;
  2711. };
  2712. function FinallyHandlerCancelReaction(finallyHandler) {
  2713. this.finallyHandler = finallyHandler;
  2714. }
  2715. FinallyHandlerCancelReaction.prototype._resultCancelled = function() {
  2716. checkCancel(this.finallyHandler);
  2717. };
  2718. function checkCancel(ctx, reason) {
  2719. if (ctx.cancelPromise != null) {
  2720. if (arguments.length > 1) {
  2721. ctx.cancelPromise._reject(reason);
  2722. } else {
  2723. ctx.cancelPromise._cancel();
  2724. }
  2725. ctx.cancelPromise = null;
  2726. return true;
  2727. }
  2728. return false;
  2729. }
  2730. function succeed() {
  2731. return finallyHandler.call(this, this.promise._target()._settledValue());
  2732. }
  2733. function fail(reason) {
  2734. if (checkCancel(this, reason)) return;
  2735. errorObj.e = reason;
  2736. return errorObj;
  2737. }
  2738. function finallyHandler(reasonOrValue) {
  2739. var promise = this.promise;
  2740. var handler = this.handler;
  2741. if (!this.called) {
  2742. this.called = true;
  2743. var ret = this.isFinallyHandler()
  2744. ? handler.call(promise._boundValue())
  2745. : handler.call(promise._boundValue(), reasonOrValue);
  2746. if (ret !== undefined) {
  2747. promise._setReturnedNonUndefined();
  2748. var maybePromise = tryConvertToPromise(ret, promise);
  2749. if (maybePromise instanceof Promise) {
  2750. if (this.cancelPromise != null) {
  2751. if (maybePromise._isCancelled()) {
  2752. var reason =
  2753. new CancellationError("late cancellation observer");
  2754. promise._attachExtraTrace(reason);
  2755. errorObj.e = reason;
  2756. return errorObj;
  2757. } else if (maybePromise.isPending()) {
  2758. maybePromise._attachCancellationCallback(
  2759. new FinallyHandlerCancelReaction(this));
  2760. }
  2761. }
  2762. return maybePromise._then(
  2763. succeed, fail, undefined, this, undefined);
  2764. }
  2765. }
  2766. }
  2767. if (promise.isRejected()) {
  2768. checkCancel(this);
  2769. errorObj.e = reasonOrValue;
  2770. return errorObj;
  2771. } else {
  2772. checkCancel(this);
  2773. return reasonOrValue;
  2774. }
  2775. }
  2776. Promise.prototype._passThrough = function(handler, type, success, fail) {
  2777. if (typeof handler !== "function") return this.then();
  2778. return this._then(success,
  2779. fail,
  2780. undefined,
  2781. new PassThroughHandlerContext(this, type, handler),
  2782. undefined);
  2783. };
  2784. Promise.prototype.lastly =
  2785. Promise.prototype["finally"] = function (handler) {
  2786. return this._passThrough(handler,
  2787. 0,
  2788. finallyHandler,
  2789. finallyHandler);
  2790. };
  2791. Promise.prototype.tap = function (handler) {
  2792. return this._passThrough(handler, 1, finallyHandler);
  2793. };
  2794. return PassThroughHandlerContext;
  2795. };
  2796. },{"./util":36}],16:[function(_dereq_,module,exports){
  2797. "use strict";
  2798. module.exports = function(Promise,
  2799. apiRejection,
  2800. INTERNAL,
  2801. tryConvertToPromise,
  2802. Proxyable,
  2803. debug) {
  2804. var errors = _dereq_("./errors");
  2805. var TypeError = errors.TypeError;
  2806. var util = _dereq_("./util");
  2807. var errorObj = util.errorObj;
  2808. var tryCatch = util.tryCatch;
  2809. var yieldHandlers = [];
  2810. function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
  2811. for (var i = 0; i < yieldHandlers.length; ++i) {
  2812. traceParent._pushContext();
  2813. var result = tryCatch(yieldHandlers[i])(value);
  2814. traceParent._popContext();
  2815. if (result === errorObj) {
  2816. traceParent._pushContext();
  2817. var ret = Promise.reject(errorObj.e);
  2818. traceParent._popContext();
  2819. return ret;
  2820. }
  2821. var maybePromise = tryConvertToPromise(result, traceParent);
  2822. if (maybePromise instanceof Promise) return maybePromise;
  2823. }
  2824. return null;
  2825. }
  2826. function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
  2827. if (debug.cancellation()) {
  2828. var internal = new Promise(INTERNAL);
  2829. var _finallyPromise = this._finallyPromise = new Promise(INTERNAL);
  2830. this._promise = internal.lastly(function() {
  2831. return _finallyPromise;
  2832. });
  2833. internal._captureStackTrace();
  2834. internal._setOnCancel(this);
  2835. } else {
  2836. var promise = this._promise = new Promise(INTERNAL);
  2837. promise._captureStackTrace();
  2838. }
  2839. this._stack = stack;
  2840. this._generatorFunction = generatorFunction;
  2841. this._receiver = receiver;
  2842. this._generator = undefined;
  2843. this._yieldHandlers = typeof yieldHandler === "function"
  2844. ? [yieldHandler].concat(yieldHandlers)
  2845. : yieldHandlers;
  2846. this._yieldedPromise = null;
  2847. this._cancellationPhase = false;
  2848. }
  2849. util.inherits(PromiseSpawn, Proxyable);
  2850. PromiseSpawn.prototype._isResolved = function() {
  2851. return this._promise === null;
  2852. };
  2853. PromiseSpawn.prototype._cleanup = function() {
  2854. this._promise = this._generator = null;
  2855. if (debug.cancellation() && this._finallyPromise !== null) {
  2856. this._finallyPromise._fulfill();
  2857. this._finallyPromise = null;
  2858. }
  2859. };
  2860. PromiseSpawn.prototype._promiseCancelled = function() {
  2861. if (this._isResolved()) return;
  2862. var implementsReturn = typeof this._generator["return"] !== "undefined";
  2863. var result;
  2864. if (!implementsReturn) {
  2865. var reason = new Promise.CancellationError(
  2866. "generator .return() sentinel");
  2867. Promise.coroutine.returnSentinel = reason;
  2868. this._promise._attachExtraTrace(reason);
  2869. this._promise._pushContext();
  2870. result = tryCatch(this._generator["throw"]).call(this._generator,
  2871. reason);
  2872. this._promise._popContext();
  2873. } else {
  2874. this._promise._pushContext();
  2875. result = tryCatch(this._generator["return"]).call(this._generator,
  2876. undefined);
  2877. this._promise._popContext();
  2878. }
  2879. this._cancellationPhase = true;
  2880. this._yieldedPromise = null;
  2881. this._continue(result);
  2882. };
  2883. PromiseSpawn.prototype._promiseFulfilled = function(value) {
  2884. this._yieldedPromise = null;
  2885. this._promise._pushContext();
  2886. var result = tryCatch(this._generator.next).call(this._generator, value);
  2887. this._promise._popContext();
  2888. this._continue(result);
  2889. };
  2890. PromiseSpawn.prototype._promiseRejected = function(reason) {
  2891. this._yieldedPromise = null;
  2892. this._promise._attachExtraTrace(reason);
  2893. this._promise._pushContext();
  2894. var result = tryCatch(this._generator["throw"])
  2895. .call(this._generator, reason);
  2896. this._promise._popContext();
  2897. this._continue(result);
  2898. };
  2899. PromiseSpawn.prototype._resultCancelled = function() {
  2900. if (this._yieldedPromise instanceof Promise) {
  2901. var promise = this._yieldedPromise;
  2902. this._yieldedPromise = null;
  2903. promise.cancel();
  2904. }
  2905. };
  2906. PromiseSpawn.prototype.promise = function () {
  2907. return this._promise;
  2908. };
  2909. PromiseSpawn.prototype._run = function () {
  2910. this._generator = this._generatorFunction.call(this._receiver);
  2911. this._receiver =
  2912. this._generatorFunction = undefined;
  2913. this._promiseFulfilled(undefined);
  2914. };
  2915. PromiseSpawn.prototype._continue = function (result) {
  2916. var promise = this._promise;
  2917. if (result === errorObj) {
  2918. this._cleanup();
  2919. if (this._cancellationPhase) {
  2920. return promise.cancel();
  2921. } else {
  2922. return promise._rejectCallback(result.e, false);
  2923. }
  2924. }
  2925. var value = result.value;
  2926. if (result.done === true) {
  2927. this._cleanup();
  2928. if (this._cancellationPhase) {
  2929. return promise.cancel();
  2930. } else {
  2931. return promise._resolveCallback(value);
  2932. }
  2933. } else {
  2934. var maybePromise = tryConvertToPromise(value, this._promise);
  2935. if (!(maybePromise instanceof Promise)) {
  2936. maybePromise =
  2937. promiseFromYieldHandler(maybePromise,
  2938. this._yieldHandlers,
  2939. this._promise);
  2940. if (maybePromise === null) {
  2941. this._promiseRejected(
  2942. new TypeError(
  2943. "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", value) +
  2944. "From coroutine:\u000a" +
  2945. this._stack.split("\n").slice(1, -7).join("\n")
  2946. )
  2947. );
  2948. return;
  2949. }
  2950. }
  2951. maybePromise = maybePromise._target();
  2952. var bitField = maybePromise._bitField;
  2953. ;
  2954. if (((bitField & 50397184) === 0)) {
  2955. this._yieldedPromise = maybePromise;
  2956. maybePromise._proxy(this, null);
  2957. } else if (((bitField & 33554432) !== 0)) {
  2958. Promise._async.invoke(
  2959. this._promiseFulfilled, this, maybePromise._value()
  2960. );
  2961. } else if (((bitField & 16777216) !== 0)) {
  2962. Promise._async.invoke(
  2963. this._promiseRejected, this, maybePromise._reason()
  2964. );
  2965. } else {
  2966. this._promiseCancelled();
  2967. }
  2968. }
  2969. };
  2970. Promise.coroutine = function (generatorFunction, options) {
  2971. if (typeof generatorFunction !== "function") {
  2972. throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  2973. }
  2974. var yieldHandler = Object(options).yieldHandler;
  2975. var PromiseSpawn$ = PromiseSpawn;
  2976. var stack = new Error().stack;
  2977. return function () {
  2978. var generator = generatorFunction.apply(this, arguments);
  2979. var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
  2980. stack);
  2981. var ret = spawn.promise();
  2982. spawn._generator = generator;
  2983. spawn._promiseFulfilled(undefined);
  2984. return ret;
  2985. };
  2986. };
  2987. Promise.coroutine.addYieldHandler = function(fn) {
  2988. if (typeof fn !== "function") {
  2989. throw new TypeError("expecting a function but got " + util.classString(fn));
  2990. }
  2991. yieldHandlers.push(fn);
  2992. };
  2993. Promise.spawn = function (generatorFunction) {
  2994. debug.deprecated("Promise.spawn()", "Promise.coroutine()");
  2995. if (typeof generatorFunction !== "function") {
  2996. return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  2997. }
  2998. var spawn = new PromiseSpawn(generatorFunction, this);
  2999. var ret = spawn.promise();
  3000. spawn._run(Promise.spawn);
  3001. return ret;
  3002. };
  3003. };
  3004. },{"./errors":12,"./util":36}],17:[function(_dereq_,module,exports){
  3005. "use strict";
  3006. module.exports =
  3007. function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async,
  3008. getDomain) {
  3009. var util = _dereq_("./util");
  3010. var canEvaluate = util.canEvaluate;
  3011. var tryCatch = util.tryCatch;
  3012. var errorObj = util.errorObj;
  3013. var reject;
  3014. if (false) {
  3015. if (canEvaluate) {
  3016. var thenCallback = function(i) {
  3017. return new Function("value", "holder", " \n\
  3018. 'use strict'; \n\
  3019. holder.pIndex = value; \n\
  3020. holder.checkFulfillment(this); \n\
  3021. ".replace(/Index/g, i));
  3022. };
  3023. var promiseSetter = function(i) {
  3024. return new Function("promise", "holder", " \n\
  3025. 'use strict'; \n\
  3026. holder.pIndex = promise; \n\
  3027. ".replace(/Index/g, i));
  3028. };
  3029. var generateHolderClass = function(total) {
  3030. var props = new Array(total);
  3031. for (var i = 0; i < props.length; ++i) {
  3032. props[i] = "this.p" + (i+1);
  3033. }
  3034. var assignment = props.join(" = ") + " = null;";
  3035. var cancellationCode= "var promise;\n" + props.map(function(prop) {
  3036. return " \n\
  3037. promise = " + prop + "; \n\
  3038. if (promise instanceof Promise) { \n\
  3039. promise.cancel(); \n\
  3040. } \n\
  3041. ";
  3042. }).join("\n");
  3043. var passedArguments = props.join(", ");
  3044. var name = "Holder$" + total;
  3045. var code = "return function(tryCatch, errorObj, Promise, async) { \n\
  3046. 'use strict'; \n\
  3047. function [TheName](fn) { \n\
  3048. [TheProperties] \n\
  3049. this.fn = fn; \n\
  3050. this.asyncNeeded = true; \n\
  3051. this.now = 0; \n\
  3052. } \n\
  3053. \n\
  3054. [TheName].prototype._callFunction = function(promise) { \n\
  3055. promise._pushContext(); \n\
  3056. var ret = tryCatch(this.fn)([ThePassedArguments]); \n\
  3057. promise._popContext(); \n\
  3058. if (ret === errorObj) { \n\
  3059. promise._rejectCallback(ret.e, false); \n\
  3060. } else { \n\
  3061. promise._resolveCallback(ret); \n\
  3062. } \n\
  3063. }; \n\
  3064. \n\
  3065. [TheName].prototype.checkFulfillment = function(promise) { \n\
  3066. var now = ++this.now; \n\
  3067. if (now === [TheTotal]) { \n\
  3068. if (this.asyncNeeded) { \n\
  3069. async.invoke(this._callFunction, this, promise); \n\
  3070. } else { \n\
  3071. this._callFunction(promise); \n\
  3072. } \n\
  3073. \n\
  3074. } \n\
  3075. }; \n\
  3076. \n\
  3077. [TheName].prototype._resultCancelled = function() { \n\
  3078. [CancellationCode] \n\
  3079. }; \n\
  3080. \n\
  3081. return [TheName]; \n\
  3082. }(tryCatch, errorObj, Promise, async); \n\
  3083. ";
  3084. code = code.replace(/\[TheName\]/g, name)
  3085. .replace(/\[TheTotal\]/g, total)
  3086. .replace(/\[ThePassedArguments\]/g, passedArguments)
  3087. .replace(/\[TheProperties\]/g, assignment)
  3088. .replace(/\[CancellationCode\]/g, cancellationCode);
  3089. return new Function("tryCatch", "errorObj", "Promise", "async", code)
  3090. (tryCatch, errorObj, Promise, async);
  3091. };
  3092. var holderClasses = [];
  3093. var thenCallbacks = [];
  3094. var promiseSetters = [];
  3095. for (var i = 0; i < 8; ++i) {
  3096. holderClasses.push(generateHolderClass(i + 1));
  3097. thenCallbacks.push(thenCallback(i + 1));
  3098. promiseSetters.push(promiseSetter(i + 1));
  3099. }
  3100. reject = function (reason) {
  3101. this._reject(reason);
  3102. };
  3103. }}
  3104. Promise.join = function () {
  3105. var last = arguments.length - 1;
  3106. var fn;
  3107. if (last > 0 && typeof arguments[last] === "function") {
  3108. fn = arguments[last];
  3109. if (false) {
  3110. if (last <= 8 && canEvaluate) {
  3111. var ret = new Promise(INTERNAL);
  3112. ret._captureStackTrace();
  3113. var HolderClass = holderClasses[last - 1];
  3114. var holder = new HolderClass(fn);
  3115. var callbacks = thenCallbacks;
  3116. for (var i = 0; i < last; ++i) {
  3117. var maybePromise = tryConvertToPromise(arguments[i], ret);
  3118. if (maybePromise instanceof Promise) {
  3119. maybePromise = maybePromise._target();
  3120. var bitField = maybePromise._bitField;
  3121. ;
  3122. if (((bitField & 50397184) === 0)) {
  3123. maybePromise._then(callbacks[i], reject,
  3124. undefined, ret, holder);
  3125. promiseSetters[i](maybePromise, holder);
  3126. holder.asyncNeeded = false;
  3127. } else if (((bitField & 33554432) !== 0)) {
  3128. callbacks[i].call(ret,
  3129. maybePromise._value(), holder);
  3130. } else if (((bitField & 16777216) !== 0)) {
  3131. ret._reject(maybePromise._reason());
  3132. } else {
  3133. ret._cancel();
  3134. }
  3135. } else {
  3136. callbacks[i].call(ret, maybePromise, holder);
  3137. }
  3138. }
  3139. if (!ret._isFateSealed()) {
  3140. if (holder.asyncNeeded) {
  3141. var domain = getDomain();
  3142. if (domain !== null) {
  3143. holder.fn = util.domainBind(domain, holder.fn);
  3144. }
  3145. }
  3146. ret._setAsyncGuaranteed();
  3147. ret._setOnCancel(holder);
  3148. }
  3149. return ret;
  3150. }
  3151. }
  3152. }
  3153. var args = [].slice.call(arguments);;
  3154. if (fn) args.pop();
  3155. var ret = new PromiseArray(args).promise();
  3156. return fn !== undefined ? ret.spread(fn) : ret;
  3157. };
  3158. };
  3159. },{"./util":36}],18:[function(_dereq_,module,exports){
  3160. "use strict";
  3161. module.exports = function(Promise,
  3162. PromiseArray,
  3163. apiRejection,
  3164. tryConvertToPromise,
  3165. INTERNAL,
  3166. debug) {
  3167. var getDomain = Promise._getDomain;
  3168. var util = _dereq_("./util");
  3169. var tryCatch = util.tryCatch;
  3170. var errorObj = util.errorObj;
  3171. var async = Promise._async;
  3172. function MappingPromiseArray(promises, fn, limit, _filter) {
  3173. this.constructor$(promises);
  3174. this._promise._captureStackTrace();
  3175. var domain = getDomain();
  3176. this._callback = domain === null ? fn : util.domainBind(domain, fn);
  3177. this._preservedValues = _filter === INTERNAL
  3178. ? new Array(this.length())
  3179. : null;
  3180. this._limit = limit;
  3181. this._inFlight = 0;
  3182. this._queue = [];
  3183. async.invoke(this._asyncInit, this, undefined);
  3184. }
  3185. util.inherits(MappingPromiseArray, PromiseArray);
  3186. MappingPromiseArray.prototype._asyncInit = function() {
  3187. this._init$(undefined, -2);
  3188. };
  3189. MappingPromiseArray.prototype._init = function () {};
  3190. MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
  3191. var values = this._values;
  3192. var length = this.length();
  3193. var preservedValues = this._preservedValues;
  3194. var limit = this._limit;
  3195. if (index < 0) {
  3196. index = (index * -1) - 1;
  3197. values[index] = value;
  3198. if (limit >= 1) {
  3199. this._inFlight--;
  3200. this._drainQueue();
  3201. if (this._isResolved()) return true;
  3202. }
  3203. } else {
  3204. if (limit >= 1 && this._inFlight >= limit) {
  3205. values[index] = value;
  3206. this._queue.push(index);
  3207. return false;
  3208. }
  3209. if (preservedValues !== null) preservedValues[index] = value;
  3210. var promise = this._promise;
  3211. var callback = this._callback;
  3212. var receiver = promise._boundValue();
  3213. promise._pushContext();
  3214. var ret = tryCatch(callback).call(receiver, value, index, length);
  3215. var promiseCreated = promise._popContext();
  3216. debug.checkForgottenReturns(
  3217. ret,
  3218. promiseCreated,
  3219. preservedValues !== null ? "Promise.filter" : "Promise.map",
  3220. promise
  3221. );
  3222. if (ret === errorObj) {
  3223. this._reject(ret.e);
  3224. return true;
  3225. }
  3226. var maybePromise = tryConvertToPromise(ret, this._promise);
  3227. if (maybePromise instanceof Promise) {
  3228. maybePromise = maybePromise._target();
  3229. var bitField = maybePromise._bitField;
  3230. ;
  3231. if (((bitField & 50397184) === 0)) {
  3232. if (limit >= 1) this._inFlight++;
  3233. values[index] = maybePromise;
  3234. maybePromise._proxy(this, (index + 1) * -1);
  3235. return false;
  3236. } else if (((bitField & 33554432) !== 0)) {
  3237. ret = maybePromise._value();
  3238. } else if (((bitField & 16777216) !== 0)) {
  3239. this._reject(maybePromise._reason());
  3240. return true;
  3241. } else {
  3242. this._cancel();
  3243. return true;
  3244. }
  3245. }
  3246. values[index] = ret;
  3247. }
  3248. var totalResolved = ++this._totalResolved;
  3249. if (totalResolved >= length) {
  3250. if (preservedValues !== null) {
  3251. this._filter(values, preservedValues);
  3252. } else {
  3253. this._resolve(values);
  3254. }
  3255. return true;
  3256. }
  3257. return false;
  3258. };
  3259. MappingPromiseArray.prototype._drainQueue = function () {
  3260. var queue = this._queue;
  3261. var limit = this._limit;
  3262. var values = this._values;
  3263. while (queue.length > 0 && this._inFlight < limit) {
  3264. if (this._isResolved()) return;
  3265. var index = queue.pop();
  3266. this._promiseFulfilled(values[index], index);
  3267. }
  3268. };
  3269. MappingPromiseArray.prototype._filter = function (booleans, values) {
  3270. var len = values.length;
  3271. var ret = new Array(len);
  3272. var j = 0;
  3273. for (var i = 0; i < len; ++i) {
  3274. if (booleans[i]) ret[j++] = values[i];
  3275. }
  3276. ret.length = j;
  3277. this._resolve(ret);
  3278. };
  3279. MappingPromiseArray.prototype.preservedValues = function () {
  3280. return this._preservedValues;
  3281. };
  3282. function map(promises, fn, options, _filter) {
  3283. if (typeof fn !== "function") {
  3284. return apiRejection("expecting a function but got " + util.classString(fn));
  3285. }
  3286. var limit = 0;
  3287. if (options !== undefined) {
  3288. if (typeof options === "object" && options !== null) {
  3289. if (typeof options.concurrency !== "number") {
  3290. return Promise.reject(
  3291. new TypeError("'concurrency' must be a number but it is " +
  3292. util.classString(options.concurrency)));
  3293. }
  3294. limit = options.concurrency;
  3295. } else {
  3296. return Promise.reject(new TypeError(
  3297. "options argument must be an object but it is " +
  3298. util.classString(options)));
  3299. }
  3300. }
  3301. limit = typeof limit === "number" &&
  3302. isFinite(limit) && limit >= 1 ? limit : 0;
  3303. return new MappingPromiseArray(promises, fn, limit, _filter).promise();
  3304. }
  3305. Promise.prototype.map = function (fn, options) {
  3306. return map(this, fn, options, null);
  3307. };
  3308. Promise.map = function (promises, fn, options, _filter) {
  3309. return map(promises, fn, options, _filter);
  3310. };
  3311. };
  3312. },{"./util":36}],19:[function(_dereq_,module,exports){
  3313. "use strict";
  3314. module.exports =
  3315. function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) {
  3316. var util = _dereq_("./util");
  3317. var tryCatch = util.tryCatch;
  3318. Promise.method = function (fn) {
  3319. if (typeof fn !== "function") {
  3320. throw new Promise.TypeError("expecting a function but got " + util.classString(fn));
  3321. }
  3322. return function () {
  3323. var ret = new Promise(INTERNAL);
  3324. ret._captureStackTrace();
  3325. ret._pushContext();
  3326. var value = tryCatch(fn).apply(this, arguments);
  3327. var promiseCreated = ret._popContext();
  3328. debug.checkForgottenReturns(
  3329. value, promiseCreated, "Promise.method", ret);
  3330. ret._resolveFromSyncValue(value);
  3331. return ret;
  3332. };
  3333. };
  3334. Promise.attempt = Promise["try"] = function (fn) {
  3335. if (typeof fn !== "function") {
  3336. return apiRejection("expecting a function but got " + util.classString(fn));
  3337. }
  3338. var ret = new Promise(INTERNAL);
  3339. ret._captureStackTrace();
  3340. ret._pushContext();
  3341. var value;
  3342. if (arguments.length > 1) {
  3343. debug.deprecated("calling Promise.try with more than 1 argument");
  3344. var arg = arguments[1];
  3345. var ctx = arguments[2];
  3346. value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg)
  3347. : tryCatch(fn).call(ctx, arg);
  3348. } else {
  3349. value = tryCatch(fn)();
  3350. }
  3351. var promiseCreated = ret._popContext();
  3352. debug.checkForgottenReturns(
  3353. value, promiseCreated, "Promise.try", ret);
  3354. ret._resolveFromSyncValue(value);
  3355. return ret;
  3356. };
  3357. Promise.prototype._resolveFromSyncValue = function (value) {
  3358. if (value === util.errorObj) {
  3359. this._rejectCallback(value.e, false);
  3360. } else {
  3361. this._resolveCallback(value, true);
  3362. }
  3363. };
  3364. };
  3365. },{"./util":36}],20:[function(_dereq_,module,exports){
  3366. "use strict";
  3367. var util = _dereq_("./util");
  3368. var maybeWrapAsError = util.maybeWrapAsError;
  3369. var errors = _dereq_("./errors");
  3370. var OperationalError = errors.OperationalError;
  3371. var es5 = _dereq_("./es5");
  3372. function isUntypedError(obj) {
  3373. return obj instanceof Error &&
  3374. es5.getPrototypeOf(obj) === Error.prototype;
  3375. }
  3376. var rErrorKey = /^(?:name|message|stack|cause)$/;
  3377. function wrapAsOperationalError(obj) {
  3378. var ret;
  3379. if (isUntypedError(obj)) {
  3380. ret = new OperationalError(obj);
  3381. ret.name = obj.name;
  3382. ret.message = obj.message;
  3383. ret.stack = obj.stack;
  3384. var keys = es5.keys(obj);
  3385. for (var i = 0; i < keys.length; ++i) {
  3386. var key = keys[i];
  3387. if (!rErrorKey.test(key)) {
  3388. ret[key] = obj[key];
  3389. }
  3390. }
  3391. return ret;
  3392. }
  3393. util.markAsOriginatingFromRejection(obj);
  3394. return obj;
  3395. }
  3396. function nodebackForPromise(promise, multiArgs) {
  3397. return function(err, value) {
  3398. if (promise === null) return;
  3399. if (err) {
  3400. var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
  3401. promise._attachExtraTrace(wrapped);
  3402. promise._reject(wrapped);
  3403. } else if (!multiArgs) {
  3404. promise._fulfill(value);
  3405. } else {
  3406. var args = [].slice.call(arguments, 1);;
  3407. promise._fulfill(args);
  3408. }
  3409. promise = null;
  3410. };
  3411. }
  3412. module.exports = nodebackForPromise;
  3413. },{"./errors":12,"./es5":13,"./util":36}],21:[function(_dereq_,module,exports){
  3414. "use strict";
  3415. module.exports = function(Promise) {
  3416. var util = _dereq_("./util");
  3417. var async = Promise._async;
  3418. var tryCatch = util.tryCatch;
  3419. var errorObj = util.errorObj;
  3420. function spreadAdapter(val, nodeback) {
  3421. var promise = this;
  3422. if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
  3423. var ret =
  3424. tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
  3425. if (ret === errorObj) {
  3426. async.throwLater(ret.e);
  3427. }
  3428. }
  3429. function successAdapter(val, nodeback) {
  3430. var promise = this;
  3431. var receiver = promise._boundValue();
  3432. var ret = val === undefined
  3433. ? tryCatch(nodeback).call(receiver, null)
  3434. : tryCatch(nodeback).call(receiver, null, val);
  3435. if (ret === errorObj) {
  3436. async.throwLater(ret.e);
  3437. }
  3438. }
  3439. function errorAdapter(reason, nodeback) {
  3440. var promise = this;
  3441. if (!reason) {
  3442. var newReason = new Error(reason + "");
  3443. newReason.cause = reason;
  3444. reason = newReason;
  3445. }
  3446. var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
  3447. if (ret === errorObj) {
  3448. async.throwLater(ret.e);
  3449. }
  3450. }
  3451. Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback,
  3452. options) {
  3453. if (typeof nodeback == "function") {
  3454. var adapter = successAdapter;
  3455. if (options !== undefined && Object(options).spread) {
  3456. adapter = spreadAdapter;
  3457. }
  3458. this._then(
  3459. adapter,
  3460. errorAdapter,
  3461. undefined,
  3462. this,
  3463. nodeback
  3464. );
  3465. }
  3466. return this;
  3467. };
  3468. };
  3469. },{"./util":36}],22:[function(_dereq_,module,exports){
  3470. "use strict";
  3471. module.exports = function() {
  3472. var makeSelfResolutionError = function () {
  3473. return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  3474. };
  3475. var reflectHandler = function() {
  3476. return new Promise.PromiseInspection(this._target());
  3477. };
  3478. var apiRejection = function(msg) {
  3479. return Promise.reject(new TypeError(msg));
  3480. };
  3481. function Proxyable() {}
  3482. var UNDEFINED_BINDING = {};
  3483. var util = _dereq_("./util");
  3484. var getDomain;
  3485. if (util.isNode) {
  3486. getDomain = function() {
  3487. var ret = process.domain;
  3488. if (ret === undefined) ret = null;
  3489. return ret;
  3490. };
  3491. } else {
  3492. getDomain = function() {
  3493. return null;
  3494. };
  3495. }
  3496. util.notEnumerableProp(Promise, "_getDomain", getDomain);
  3497. var es5 = _dereq_("./es5");
  3498. var Async = _dereq_("./async");
  3499. var async = new Async();
  3500. es5.defineProperty(Promise, "_async", {value: async});
  3501. var errors = _dereq_("./errors");
  3502. var TypeError = Promise.TypeError = errors.TypeError;
  3503. Promise.RangeError = errors.RangeError;
  3504. var CancellationError = Promise.CancellationError = errors.CancellationError;
  3505. Promise.TimeoutError = errors.TimeoutError;
  3506. Promise.OperationalError = errors.OperationalError;
  3507. Promise.RejectionError = errors.OperationalError;
  3508. Promise.AggregateError = errors.AggregateError;
  3509. var INTERNAL = function(){};
  3510. var APPLY = {};
  3511. var NEXT_FILTER = {};
  3512. var tryConvertToPromise = _dereq_("./thenables")(Promise, INTERNAL);
  3513. var PromiseArray =
  3514. _dereq_("./promise_array")(Promise, INTERNAL,
  3515. tryConvertToPromise, apiRejection, Proxyable);
  3516. var Context = _dereq_("./context")(Promise);
  3517. /*jshint unused:false*/
  3518. var createContext = Context.create;
  3519. var debug = _dereq_("./debuggability")(Promise, Context);
  3520. var CapturedTrace = debug.CapturedTrace;
  3521. var PassThroughHandlerContext =
  3522. _dereq_("./finally")(Promise, tryConvertToPromise);
  3523. var catchFilter = _dereq_("./catch_filter")(NEXT_FILTER);
  3524. var nodebackForPromise = _dereq_("./nodeback");
  3525. var errorObj = util.errorObj;
  3526. var tryCatch = util.tryCatch;
  3527. function check(self, executor) {
  3528. if (typeof executor !== "function") {
  3529. throw new TypeError("expecting a function but got " + util.classString(executor));
  3530. }
  3531. if (self.constructor !== Promise) {
  3532. throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  3533. }
  3534. }
  3535. function Promise(executor) {
  3536. this._bitField = 0;
  3537. this._fulfillmentHandler0 = undefined;
  3538. this._rejectionHandler0 = undefined;
  3539. this._promise0 = undefined;
  3540. this._receiver0 = undefined;
  3541. if (executor !== INTERNAL) {
  3542. check(this, executor);
  3543. this._resolveFromExecutor(executor);
  3544. }
  3545. this._promiseCreated();
  3546. this._fireEvent("promiseCreated", this);
  3547. }
  3548. Promise.prototype.toString = function () {
  3549. return "[object Promise]";
  3550. };
  3551. Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
  3552. var len = arguments.length;
  3553. if (len > 1) {
  3554. var catchInstances = new Array(len - 1),
  3555. j = 0, i;
  3556. for (i = 0; i < len - 1; ++i) {
  3557. var item = arguments[i];
  3558. if (util.isObject(item)) {
  3559. catchInstances[j++] = item;
  3560. } else {
  3561. return apiRejection("expecting an object but got " +
  3562. "A catch statement predicate " + util.classString(item));
  3563. }
  3564. }
  3565. catchInstances.length = j;
  3566. fn = arguments[i];
  3567. return this.then(undefined, catchFilter(catchInstances, fn, this));
  3568. }
  3569. return this.then(undefined, fn);
  3570. };
  3571. Promise.prototype.reflect = function () {
  3572. return this._then(reflectHandler,
  3573. reflectHandler, undefined, this, undefined);
  3574. };
  3575. Promise.prototype.then = function (didFulfill, didReject) {
  3576. if (debug.warnings() && arguments.length > 0 &&
  3577. typeof didFulfill !== "function" &&
  3578. typeof didReject !== "function") {
  3579. var msg = ".then() only accepts functions but was passed: " +
  3580. util.classString(didFulfill);
  3581. if (arguments.length > 1) {
  3582. msg += ", " + util.classString(didReject);
  3583. }
  3584. this._warn(msg);
  3585. }
  3586. return this._then(didFulfill, didReject, undefined, undefined, undefined);
  3587. };
  3588. Promise.prototype.done = function (didFulfill, didReject) {
  3589. var promise =
  3590. this._then(didFulfill, didReject, undefined, undefined, undefined);
  3591. promise._setIsFinal();
  3592. };
  3593. Promise.prototype.spread = function (fn) {
  3594. if (typeof fn !== "function") {
  3595. return apiRejection("expecting a function but got " + util.classString(fn));
  3596. }
  3597. return this.all()._then(fn, undefined, undefined, APPLY, undefined);
  3598. };
  3599. Promise.prototype.toJSON = function () {
  3600. var ret = {
  3601. isFulfilled: false,
  3602. isRejected: false,
  3603. fulfillmentValue: undefined,
  3604. rejectionReason: undefined
  3605. };
  3606. if (this.isFulfilled()) {
  3607. ret.fulfillmentValue = this.value();
  3608. ret.isFulfilled = true;
  3609. } else if (this.isRejected()) {
  3610. ret.rejectionReason = this.reason();
  3611. ret.isRejected = true;
  3612. }
  3613. return ret;
  3614. };
  3615. Promise.prototype.all = function () {
  3616. if (arguments.length > 0) {
  3617. this._warn(".all() was passed arguments but it does not take any");
  3618. }
  3619. return new PromiseArray(this).promise();
  3620. };
  3621. Promise.prototype.error = function (fn) {
  3622. return this.caught(util.originatesFromRejection, fn);
  3623. };
  3624. Promise.getNewLibraryCopy = module.exports;
  3625. Promise.is = function (val) {
  3626. return val instanceof Promise;
  3627. };
  3628. Promise.fromNode = Promise.fromCallback = function(fn) {
  3629. var ret = new Promise(INTERNAL);
  3630. ret._captureStackTrace();
  3631. var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs
  3632. : false;
  3633. var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs));
  3634. if (result === errorObj) {
  3635. ret._rejectCallback(result.e, true);
  3636. }
  3637. if (!ret._isFateSealed()) ret._setAsyncGuaranteed();
  3638. return ret;
  3639. };
  3640. Promise.all = function (promises) {
  3641. return new PromiseArray(promises).promise();
  3642. };
  3643. Promise.cast = function (obj) {
  3644. var ret = tryConvertToPromise(obj);
  3645. if (!(ret instanceof Promise)) {
  3646. ret = new Promise(INTERNAL);
  3647. ret._captureStackTrace();
  3648. ret._setFulfilled();
  3649. ret._rejectionHandler0 = obj;
  3650. }
  3651. return ret;
  3652. };
  3653. Promise.resolve = Promise.fulfilled = Promise.cast;
  3654. Promise.reject = Promise.rejected = function (reason) {
  3655. var ret = new Promise(INTERNAL);
  3656. ret._captureStackTrace();
  3657. ret._rejectCallback(reason, true);
  3658. return ret;
  3659. };
  3660. Promise.setScheduler = function(fn) {
  3661. if (typeof fn !== "function") {
  3662. throw new TypeError("expecting a function but got " + util.classString(fn));
  3663. }
  3664. return async.setScheduler(fn);
  3665. };
  3666. Promise.prototype._then = function (
  3667. didFulfill,
  3668. didReject,
  3669. _, receiver,
  3670. internalData
  3671. ) {
  3672. var haveInternalData = internalData !== undefined;
  3673. var promise = haveInternalData ? internalData : new Promise(INTERNAL);
  3674. var target = this._target();
  3675. var bitField = target._bitField;
  3676. if (!haveInternalData) {
  3677. promise._propagateFrom(this, 3);
  3678. promise._captureStackTrace();
  3679. if (receiver === undefined &&
  3680. ((this._bitField & 2097152) !== 0)) {
  3681. if (!((bitField & 50397184) === 0)) {
  3682. receiver = this._boundValue();
  3683. } else {
  3684. receiver = target === this ? undefined : this._boundTo;
  3685. }
  3686. }
  3687. this._fireEvent("promiseChained", this, promise);
  3688. }
  3689. var domain = getDomain();
  3690. if (!((bitField & 50397184) === 0)) {
  3691. var handler, value, settler = target._settlePromiseCtx;
  3692. if (((bitField & 33554432) !== 0)) {
  3693. value = target._rejectionHandler0;
  3694. handler = didFulfill;
  3695. } else if (((bitField & 16777216) !== 0)) {
  3696. value = target._fulfillmentHandler0;
  3697. handler = didReject;
  3698. target._unsetRejectionIsUnhandled();
  3699. } else {
  3700. settler = target._settlePromiseLateCancellationObserver;
  3701. value = new CancellationError("late cancellation observer");
  3702. target._attachExtraTrace(value);
  3703. handler = didReject;
  3704. }
  3705. async.invoke(settler, target, {
  3706. handler: domain === null ? handler
  3707. : (typeof handler === "function" &&
  3708. util.domainBind(domain, handler)),
  3709. promise: promise,
  3710. receiver: receiver,
  3711. value: value
  3712. });
  3713. } else {
  3714. target._addCallbacks(didFulfill, didReject, promise, receiver, domain);
  3715. }
  3716. return promise;
  3717. };
  3718. Promise.prototype._length = function () {
  3719. return this._bitField & 65535;
  3720. };
  3721. Promise.prototype._isFateSealed = function () {
  3722. return (this._bitField & 117506048) !== 0;
  3723. };
  3724. Promise.prototype._isFollowing = function () {
  3725. return (this._bitField & 67108864) === 67108864;
  3726. };
  3727. Promise.prototype._setLength = function (len) {
  3728. this._bitField = (this._bitField & -65536) |
  3729. (len & 65535);
  3730. };
  3731. Promise.prototype._setFulfilled = function () {
  3732. this._bitField = this._bitField | 33554432;
  3733. this._fireEvent("promiseFulfilled", this);
  3734. };
  3735. Promise.prototype._setRejected = function () {
  3736. this._bitField = this._bitField | 16777216;
  3737. this._fireEvent("promiseRejected", this);
  3738. };
  3739. Promise.prototype._setFollowing = function () {
  3740. this._bitField = this._bitField | 67108864;
  3741. this._fireEvent("promiseResolved", this);
  3742. };
  3743. Promise.prototype._setIsFinal = function () {
  3744. this._bitField = this._bitField | 4194304;
  3745. };
  3746. Promise.prototype._isFinal = function () {
  3747. return (this._bitField & 4194304) > 0;
  3748. };
  3749. Promise.prototype._unsetCancelled = function() {
  3750. this._bitField = this._bitField & (~65536);
  3751. };
  3752. Promise.prototype._setCancelled = function() {
  3753. this._bitField = this._bitField | 65536;
  3754. this._fireEvent("promiseCancelled", this);
  3755. };
  3756. Promise.prototype._setWillBeCancelled = function() {
  3757. this._bitField = this._bitField | 8388608;
  3758. };
  3759. Promise.prototype._setAsyncGuaranteed = function() {
  3760. if (async.hasCustomScheduler()) return;
  3761. this._bitField = this._bitField | 134217728;
  3762. };
  3763. Promise.prototype._receiverAt = function (index) {
  3764. var ret = index === 0 ? this._receiver0 : this[
  3765. index * 4 - 4 + 3];
  3766. if (ret === UNDEFINED_BINDING) {
  3767. return undefined;
  3768. } else if (ret === undefined && this._isBound()) {
  3769. return this._boundValue();
  3770. }
  3771. return ret;
  3772. };
  3773. Promise.prototype._promiseAt = function (index) {
  3774. return this[
  3775. index * 4 - 4 + 2];
  3776. };
  3777. Promise.prototype._fulfillmentHandlerAt = function (index) {
  3778. return this[
  3779. index * 4 - 4 + 0];
  3780. };
  3781. Promise.prototype._rejectionHandlerAt = function (index) {
  3782. return this[
  3783. index * 4 - 4 + 1];
  3784. };
  3785. Promise.prototype._boundValue = function() {};
  3786. Promise.prototype._migrateCallback0 = function (follower) {
  3787. var bitField = follower._bitField;
  3788. var fulfill = follower._fulfillmentHandler0;
  3789. var reject = follower._rejectionHandler0;
  3790. var promise = follower._promise0;
  3791. var receiver = follower._receiverAt(0);
  3792. if (receiver === undefined) receiver = UNDEFINED_BINDING;
  3793. this._addCallbacks(fulfill, reject, promise, receiver, null);
  3794. };
  3795. Promise.prototype._migrateCallbackAt = function (follower, index) {
  3796. var fulfill = follower._fulfillmentHandlerAt(index);
  3797. var reject = follower._rejectionHandlerAt(index);
  3798. var promise = follower._promiseAt(index);
  3799. var receiver = follower._receiverAt(index);
  3800. if (receiver === undefined) receiver = UNDEFINED_BINDING;
  3801. this._addCallbacks(fulfill, reject, promise, receiver, null);
  3802. };
  3803. Promise.prototype._addCallbacks = function (
  3804. fulfill,
  3805. reject,
  3806. promise,
  3807. receiver,
  3808. domain
  3809. ) {
  3810. var index = this._length();
  3811. if (index >= 65535 - 4) {
  3812. index = 0;
  3813. this._setLength(0);
  3814. }
  3815. if (index === 0) {
  3816. this._promise0 = promise;
  3817. this._receiver0 = receiver;
  3818. if (typeof fulfill === "function") {
  3819. this._fulfillmentHandler0 =
  3820. domain === null ? fulfill : util.domainBind(domain, fulfill);
  3821. }
  3822. if (typeof reject === "function") {
  3823. this._rejectionHandler0 =
  3824. domain === null ? reject : util.domainBind(domain, reject);
  3825. }
  3826. } else {
  3827. var base = index * 4 - 4;
  3828. this[base + 2] = promise;
  3829. this[base + 3] = receiver;
  3830. if (typeof fulfill === "function") {
  3831. this[base + 0] =
  3832. domain === null ? fulfill : util.domainBind(domain, fulfill);
  3833. }
  3834. if (typeof reject === "function") {
  3835. this[base + 1] =
  3836. domain === null ? reject : util.domainBind(domain, reject);
  3837. }
  3838. }
  3839. this._setLength(index + 1);
  3840. return index;
  3841. };
  3842. Promise.prototype._proxy = function (proxyable, arg) {
  3843. this._addCallbacks(undefined, undefined, arg, proxyable, null);
  3844. };
  3845. Promise.prototype._resolveCallback = function(value, shouldBind) {
  3846. if (((this._bitField & 117506048) !== 0)) return;
  3847. if (value === this)
  3848. return this._rejectCallback(makeSelfResolutionError(), false);
  3849. var maybePromise = tryConvertToPromise(value, this);
  3850. if (!(maybePromise instanceof Promise)) return this._fulfill(value);
  3851. if (shouldBind) this._propagateFrom(maybePromise, 2);
  3852. var promise = maybePromise._target();
  3853. if (promise === this) {
  3854. this._reject(makeSelfResolutionError());
  3855. return;
  3856. }
  3857. var bitField = promise._bitField;
  3858. if (((bitField & 50397184) === 0)) {
  3859. var len = this._length();
  3860. if (len > 0) promise._migrateCallback0(this);
  3861. for (var i = 1; i < len; ++i) {
  3862. promise._migrateCallbackAt(this, i);
  3863. }
  3864. this._setFollowing();
  3865. this._setLength(0);
  3866. this._setFollowee(promise);
  3867. } else if (((bitField & 33554432) !== 0)) {
  3868. this._fulfill(promise._value());
  3869. } else if (((bitField & 16777216) !== 0)) {
  3870. this._reject(promise._reason());
  3871. } else {
  3872. var reason = new CancellationError("late cancellation observer");
  3873. promise._attachExtraTrace(reason);
  3874. this._reject(reason);
  3875. }
  3876. };
  3877. Promise.prototype._rejectCallback =
  3878. function(reason, synchronous, ignoreNonErrorWarnings) {
  3879. var trace = util.ensureErrorObject(reason);
  3880. var hasStack = trace === reason;
  3881. if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) {
  3882. var message = "a promise was rejected with a non-error: " +
  3883. util.classString(reason);
  3884. this._warn(message, true);
  3885. }
  3886. this._attachExtraTrace(trace, synchronous ? hasStack : false);
  3887. this._reject(reason);
  3888. };
  3889. Promise.prototype._resolveFromExecutor = function (executor) {
  3890. var promise = this;
  3891. this._captureStackTrace();
  3892. this._pushContext();
  3893. var synchronous = true;
  3894. var r = this._execute(executor, function(value) {
  3895. promise._resolveCallback(value);
  3896. }, function (reason) {
  3897. promise._rejectCallback(reason, synchronous);
  3898. });
  3899. synchronous = false;
  3900. this._popContext();
  3901. if (r !== undefined) {
  3902. promise._rejectCallback(r, true);
  3903. }
  3904. };
  3905. Promise.prototype._settlePromiseFromHandler = function (
  3906. handler, receiver, value, promise
  3907. ) {
  3908. var bitField = promise._bitField;
  3909. if (((bitField & 65536) !== 0)) return;
  3910. promise._pushContext();
  3911. var x;
  3912. if (receiver === APPLY) {
  3913. if (!value || typeof value.length !== "number") {
  3914. x = errorObj;
  3915. x.e = new TypeError("cannot .spread() a non-array: " +
  3916. util.classString(value));
  3917. } else {
  3918. x = tryCatch(handler).apply(this._boundValue(), value);
  3919. }
  3920. } else {
  3921. x = tryCatch(handler).call(receiver, value);
  3922. }
  3923. var promiseCreated = promise._popContext();
  3924. bitField = promise._bitField;
  3925. if (((bitField & 65536) !== 0)) return;
  3926. if (x === NEXT_FILTER) {
  3927. promise._reject(value);
  3928. } else if (x === errorObj) {
  3929. promise._rejectCallback(x.e, false);
  3930. } else {
  3931. debug.checkForgottenReturns(x, promiseCreated, "", promise, this);
  3932. promise._resolveCallback(x);
  3933. }
  3934. };
  3935. Promise.prototype._target = function() {
  3936. var ret = this;
  3937. while (ret._isFollowing()) ret = ret._followee();
  3938. return ret;
  3939. };
  3940. Promise.prototype._followee = function() {
  3941. return this._rejectionHandler0;
  3942. };
  3943. Promise.prototype._setFollowee = function(promise) {
  3944. this._rejectionHandler0 = promise;
  3945. };
  3946. Promise.prototype._settlePromise = function(promise, handler, receiver, value) {
  3947. var isPromise = promise instanceof Promise;
  3948. var bitField = this._bitField;
  3949. var asyncGuaranteed = ((bitField & 134217728) !== 0);
  3950. if (((bitField & 65536) !== 0)) {
  3951. if (isPromise) promise._invokeInternalOnCancel();
  3952. if (receiver instanceof PassThroughHandlerContext &&
  3953. receiver.isFinallyHandler()) {
  3954. receiver.cancelPromise = promise;
  3955. if (tryCatch(handler).call(receiver, value) === errorObj) {
  3956. promise._reject(errorObj.e);
  3957. }
  3958. } else if (handler === reflectHandler) {
  3959. promise._fulfill(reflectHandler.call(receiver));
  3960. } else if (receiver instanceof Proxyable) {
  3961. receiver._promiseCancelled(promise);
  3962. } else if (isPromise || promise instanceof PromiseArray) {
  3963. promise._cancel();
  3964. } else {
  3965. receiver.cancel();
  3966. }
  3967. } else if (typeof handler === "function") {
  3968. if (!isPromise) {
  3969. handler.call(receiver, value, promise);
  3970. } else {
  3971. if (asyncGuaranteed) promise._setAsyncGuaranteed();
  3972. this._settlePromiseFromHandler(handler, receiver, value, promise);
  3973. }
  3974. } else if (receiver instanceof Proxyable) {
  3975. if (!receiver._isResolved()) {
  3976. if (((bitField & 33554432) !== 0)) {
  3977. receiver._promiseFulfilled(value, promise);
  3978. } else {
  3979. receiver._promiseRejected(value, promise);
  3980. }
  3981. }
  3982. } else if (isPromise) {
  3983. if (asyncGuaranteed) promise._setAsyncGuaranteed();
  3984. if (((bitField & 33554432) !== 0)) {
  3985. promise._fulfill(value);
  3986. } else {
  3987. promise._reject(value);
  3988. }
  3989. }
  3990. };
  3991. Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) {
  3992. var handler = ctx.handler;
  3993. var promise = ctx.promise;
  3994. var receiver = ctx.receiver;
  3995. var value = ctx.value;
  3996. if (typeof handler === "function") {
  3997. if (!(promise instanceof Promise)) {
  3998. handler.call(receiver, value, promise);
  3999. } else {
  4000. this._settlePromiseFromHandler(handler, receiver, value, promise);
  4001. }
  4002. } else if (promise instanceof Promise) {
  4003. promise._reject(value);
  4004. }
  4005. };
  4006. Promise.prototype._settlePromiseCtx = function(ctx) {
  4007. this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value);
  4008. };
  4009. Promise.prototype._settlePromise0 = function(handler, value, bitField) {
  4010. var promise = this._promise0;
  4011. var receiver = this._receiverAt(0);
  4012. this._promise0 = undefined;
  4013. this._receiver0 = undefined;
  4014. this._settlePromise(promise, handler, receiver, value);
  4015. };
  4016. Promise.prototype._clearCallbackDataAtIndex = function(index) {
  4017. var base = index * 4 - 4;
  4018. this[base + 2] =
  4019. this[base + 3] =
  4020. this[base + 0] =
  4021. this[base + 1] = undefined;
  4022. };
  4023. Promise.prototype._fulfill = function (value) {
  4024. var bitField = this._bitField;
  4025. if (((bitField & 117506048) >>> 16)) return;
  4026. if (value === this) {
  4027. var err = makeSelfResolutionError();
  4028. this._attachExtraTrace(err);
  4029. return this._reject(err);
  4030. }
  4031. this._setFulfilled();
  4032. this._rejectionHandler0 = value;
  4033. if ((bitField & 65535) > 0) {
  4034. if (((bitField & 134217728) !== 0)) {
  4035. this._settlePromises();
  4036. } else {
  4037. async.settlePromises(this);
  4038. }
  4039. }
  4040. };
  4041. Promise.prototype._reject = function (reason) {
  4042. var bitField = this._bitField;
  4043. if (((bitField & 117506048) >>> 16)) return;
  4044. this._setRejected();
  4045. this._fulfillmentHandler0 = reason;
  4046. if (this._isFinal()) {
  4047. return async.fatalError(reason, util.isNode);
  4048. }
  4049. if ((bitField & 65535) > 0) {
  4050. async.settlePromises(this);
  4051. } else {
  4052. this._ensurePossibleRejectionHandled();
  4053. }
  4054. };
  4055. Promise.prototype._fulfillPromises = function (len, value) {
  4056. for (var i = 1; i < len; i++) {
  4057. var handler = this._fulfillmentHandlerAt(i);
  4058. var promise = this._promiseAt(i);
  4059. var receiver = this._receiverAt(i);
  4060. this._clearCallbackDataAtIndex(i);
  4061. this._settlePromise(promise, handler, receiver, value);
  4062. }
  4063. };
  4064. Promise.prototype._rejectPromises = function (len, reason) {
  4065. for (var i = 1; i < len; i++) {
  4066. var handler = this._rejectionHandlerAt(i);
  4067. var promise = this._promiseAt(i);
  4068. var receiver = this._receiverAt(i);
  4069. this._clearCallbackDataAtIndex(i);
  4070. this._settlePromise(promise, handler, receiver, reason);
  4071. }
  4072. };
  4073. Promise.prototype._settlePromises = function () {
  4074. var bitField = this._bitField;
  4075. var len = (bitField & 65535);
  4076. if (len > 0) {
  4077. if (((bitField & 16842752) !== 0)) {
  4078. var reason = this._fulfillmentHandler0;
  4079. this._settlePromise0(this._rejectionHandler0, reason, bitField);
  4080. this._rejectPromises(len, reason);
  4081. } else {
  4082. var value = this._rejectionHandler0;
  4083. this._settlePromise0(this._fulfillmentHandler0, value, bitField);
  4084. this._fulfillPromises(len, value);
  4085. }
  4086. this._setLength(0);
  4087. }
  4088. this._clearCancellationData();
  4089. };
  4090. Promise.prototype._settledValue = function() {
  4091. var bitField = this._bitField;
  4092. if (((bitField & 33554432) !== 0)) {
  4093. return this._rejectionHandler0;
  4094. } else if (((bitField & 16777216) !== 0)) {
  4095. return this._fulfillmentHandler0;
  4096. }
  4097. };
  4098. function deferResolve(v) {this.promise._resolveCallback(v);}
  4099. function deferReject(v) {this.promise._rejectCallback(v, false);}
  4100. Promise.defer = Promise.pending = function() {
  4101. debug.deprecated("Promise.defer", "new Promise");
  4102. var promise = new Promise(INTERNAL);
  4103. return {
  4104. promise: promise,
  4105. resolve: deferResolve,
  4106. reject: deferReject
  4107. };
  4108. };
  4109. util.notEnumerableProp(Promise,
  4110. "_makeSelfResolutionError",
  4111. makeSelfResolutionError);
  4112. _dereq_("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection,
  4113. debug);
  4114. _dereq_("./bind")(Promise, INTERNAL, tryConvertToPromise, debug);
  4115. _dereq_("./cancel")(Promise, PromiseArray, apiRejection, debug);
  4116. _dereq_("./direct_resolve")(Promise);
  4117. _dereq_("./synchronous_inspection")(Promise);
  4118. _dereq_("./join")(
  4119. Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, getDomain);
  4120. Promise.Promise = Promise;
  4121. Promise.version = "3.4.6";
  4122. _dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
  4123. _dereq_('./call_get.js')(Promise);
  4124. _dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
  4125. _dereq_('./timers.js')(Promise, INTERNAL, debug);
  4126. _dereq_('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
  4127. _dereq_('./nodeify.js')(Promise);
  4128. _dereq_('./promisify.js')(Promise, INTERNAL);
  4129. _dereq_('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
  4130. _dereq_('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
  4131. _dereq_('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
  4132. _dereq_('./settle.js')(Promise, PromiseArray, debug);
  4133. _dereq_('./some.js')(Promise, PromiseArray, apiRejection);
  4134. _dereq_('./filter.js')(Promise, INTERNAL);
  4135. _dereq_('./each.js')(Promise, INTERNAL);
  4136. _dereq_('./any.js')(Promise);
  4137. util.toFastProperties(Promise);
  4138. util.toFastProperties(Promise.prototype);
  4139. function fillTypes(value) {
  4140. var p = new Promise(INTERNAL);
  4141. p._fulfillmentHandler0 = value;
  4142. p._rejectionHandler0 = value;
  4143. p._promise0 = value;
  4144. p._receiver0 = value;
  4145. }
  4146. // Complete slack tracking, opt out of field-type tracking and
  4147. // stabilize map
  4148. fillTypes({a: 1});
  4149. fillTypes({b: 2});
  4150. fillTypes({c: 3});
  4151. fillTypes(1);
  4152. fillTypes(function(){});
  4153. fillTypes(undefined);
  4154. fillTypes(false);
  4155. fillTypes(new Promise(INTERNAL));
  4156. debug.setBounds(Async.firstLineError, util.lastLineError);
  4157. return Promise;
  4158. };
  4159. },{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(_dereq_,module,exports){
  4160. "use strict";
  4161. module.exports = function(Promise, INTERNAL, tryConvertToPromise,
  4162. apiRejection, Proxyable) {
  4163. var util = _dereq_("./util");
  4164. var isArray = util.isArray;
  4165. function toResolutionValue(val) {
  4166. switch(val) {
  4167. case -2: return [];
  4168. case -3: return {};
  4169. }
  4170. }
  4171. function PromiseArray(values) {
  4172. var promise = this._promise = new Promise(INTERNAL);
  4173. if (values instanceof Promise) {
  4174. promise._propagateFrom(values, 3);
  4175. }
  4176. promise._setOnCancel(this);
  4177. this._values = values;
  4178. this._length = 0;
  4179. this._totalResolved = 0;
  4180. this._init(undefined, -2);
  4181. }
  4182. util.inherits(PromiseArray, Proxyable);
  4183. PromiseArray.prototype.length = function () {
  4184. return this._length;
  4185. };
  4186. PromiseArray.prototype.promise = function () {
  4187. return this._promise;
  4188. };
  4189. PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
  4190. var values = tryConvertToPromise(this._values, this._promise);
  4191. if (values instanceof Promise) {
  4192. values = values._target();
  4193. var bitField = values._bitField;
  4194. ;
  4195. this._values = values;
  4196. if (((bitField & 50397184) === 0)) {
  4197. this._promise._setAsyncGuaranteed();
  4198. return values._then(
  4199. init,
  4200. this._reject,
  4201. undefined,
  4202. this,
  4203. resolveValueIfEmpty
  4204. );
  4205. } else if (((bitField & 33554432) !== 0)) {
  4206. values = values._value();
  4207. } else if (((bitField & 16777216) !== 0)) {
  4208. return this._reject(values._reason());
  4209. } else {
  4210. return this._cancel();
  4211. }
  4212. }
  4213. values = util.asArray(values);
  4214. if (values === null) {
  4215. var err = apiRejection(
  4216. "expecting an array or an iterable object but got " + util.classString(values)).reason();
  4217. this._promise._rejectCallback(err, false);
  4218. return;
  4219. }
  4220. if (values.length === 0) {
  4221. if (resolveValueIfEmpty === -5) {
  4222. this._resolveEmptyArray();
  4223. }
  4224. else {
  4225. this._resolve(toResolutionValue(resolveValueIfEmpty));
  4226. }
  4227. return;
  4228. }
  4229. this._iterate(values);
  4230. };
  4231. PromiseArray.prototype._iterate = function(values) {
  4232. var len = this.getActualLength(values.length);
  4233. this._length = len;
  4234. this._values = this.shouldCopyValues() ? new Array(len) : this._values;
  4235. var result = this._promise;
  4236. var isResolved = false;
  4237. var bitField = null;
  4238. for (var i = 0; i < len; ++i) {
  4239. var maybePromise = tryConvertToPromise(values[i], result);
  4240. if (maybePromise instanceof Promise) {
  4241. maybePromise = maybePromise._target();
  4242. bitField = maybePromise._bitField;
  4243. } else {
  4244. bitField = null;
  4245. }
  4246. if (isResolved) {
  4247. if (bitField !== null) {
  4248. maybePromise.suppressUnhandledRejections();
  4249. }
  4250. } else if (bitField !== null) {
  4251. if (((bitField & 50397184) === 0)) {
  4252. maybePromise._proxy(this, i);
  4253. this._values[i] = maybePromise;
  4254. } else if (((bitField & 33554432) !== 0)) {
  4255. isResolved = this._promiseFulfilled(maybePromise._value(), i);
  4256. } else if (((bitField & 16777216) !== 0)) {
  4257. isResolved = this._promiseRejected(maybePromise._reason(), i);
  4258. } else {
  4259. isResolved = this._promiseCancelled(i);
  4260. }
  4261. } else {
  4262. isResolved = this._promiseFulfilled(maybePromise, i);
  4263. }
  4264. }
  4265. if (!isResolved) result._setAsyncGuaranteed();
  4266. };
  4267. PromiseArray.prototype._isResolved = function () {
  4268. return this._values === null;
  4269. };
  4270. PromiseArray.prototype._resolve = function (value) {
  4271. this._values = null;
  4272. this._promise._fulfill(value);
  4273. };
  4274. PromiseArray.prototype._cancel = function() {
  4275. if (this._isResolved() || !this._promise._isCancellable()) return;
  4276. this._values = null;
  4277. this._promise._cancel();
  4278. };
  4279. PromiseArray.prototype._reject = function (reason) {
  4280. this._values = null;
  4281. this._promise._rejectCallback(reason, false);
  4282. };
  4283. PromiseArray.prototype._promiseFulfilled = function (value, index) {
  4284. this._values[index] = value;
  4285. var totalResolved = ++this._totalResolved;
  4286. if (totalResolved >= this._length) {
  4287. this._resolve(this._values);
  4288. return true;
  4289. }
  4290. return false;
  4291. };
  4292. PromiseArray.prototype._promiseCancelled = function() {
  4293. this._cancel();
  4294. return true;
  4295. };
  4296. PromiseArray.prototype._promiseRejected = function (reason) {
  4297. this._totalResolved++;
  4298. this._reject(reason);
  4299. return true;
  4300. };
  4301. PromiseArray.prototype._resultCancelled = function() {
  4302. if (this._isResolved()) return;
  4303. var values = this._values;
  4304. this._cancel();
  4305. if (values instanceof Promise) {
  4306. values.cancel();
  4307. } else {
  4308. for (var i = 0; i < values.length; ++i) {
  4309. if (values[i] instanceof Promise) {
  4310. values[i].cancel();
  4311. }
  4312. }
  4313. }
  4314. };
  4315. PromiseArray.prototype.shouldCopyValues = function () {
  4316. return true;
  4317. };
  4318. PromiseArray.prototype.getActualLength = function (len) {
  4319. return len;
  4320. };
  4321. return PromiseArray;
  4322. };
  4323. },{"./util":36}],24:[function(_dereq_,module,exports){
  4324. "use strict";
  4325. module.exports = function(Promise, INTERNAL) {
  4326. var THIS = {};
  4327. var util = _dereq_("./util");
  4328. var nodebackForPromise = _dereq_("./nodeback");
  4329. var withAppended = util.withAppended;
  4330. var maybeWrapAsError = util.maybeWrapAsError;
  4331. var canEvaluate = util.canEvaluate;
  4332. var TypeError = _dereq_("./errors").TypeError;
  4333. var defaultSuffix = "Async";
  4334. var defaultPromisified = {__isPromisified__: true};
  4335. var noCopyProps = [
  4336. "arity", "length",
  4337. "name",
  4338. "arguments",
  4339. "caller",
  4340. "callee",
  4341. "prototype",
  4342. "__isPromisified__"
  4343. ];
  4344. var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
  4345. var defaultFilter = function(name) {
  4346. return util.isIdentifier(name) &&
  4347. name.charAt(0) !== "_" &&
  4348. name !== "constructor";
  4349. };
  4350. function propsFilter(key) {
  4351. return !noCopyPropsPattern.test(key);
  4352. }
  4353. function isPromisified(fn) {
  4354. try {
  4355. return fn.__isPromisified__ === true;
  4356. }
  4357. catch (e) {
  4358. return false;
  4359. }
  4360. }
  4361. function hasPromisified(obj, key, suffix) {
  4362. var val = util.getDataPropertyOrDefault(obj, key + suffix,
  4363. defaultPromisified);
  4364. return val ? isPromisified(val) : false;
  4365. }
  4366. function checkValid(ret, suffix, suffixRegexp) {
  4367. for (var i = 0; i < ret.length; i += 2) {
  4368. var key = ret[i];
  4369. if (suffixRegexp.test(key)) {
  4370. var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
  4371. for (var j = 0; j < ret.length; j += 2) {
  4372. if (ret[j] === keyWithoutAsyncSuffix) {
  4373. throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/MqrFmX\u000a"
  4374. .replace("%s", suffix));
  4375. }
  4376. }
  4377. }
  4378. }
  4379. }
  4380. function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
  4381. var keys = util.inheritedDataKeys(obj);
  4382. var ret = [];
  4383. for (var i = 0; i < keys.length; ++i) {
  4384. var key = keys[i];
  4385. var value = obj[key];
  4386. var passesDefaultFilter = filter === defaultFilter
  4387. ? true : defaultFilter(key, value, obj);
  4388. if (typeof value === "function" &&
  4389. !isPromisified(value) &&
  4390. !hasPromisified(obj, key, suffix) &&
  4391. filter(key, value, obj, passesDefaultFilter)) {
  4392. ret.push(key, value);
  4393. }
  4394. }
  4395. checkValid(ret, suffix, suffixRegexp);
  4396. return ret;
  4397. }
  4398. var escapeIdentRegex = function(str) {
  4399. return str.replace(/([$])/, "\\$");
  4400. };
  4401. var makeNodePromisifiedEval;
  4402. if (false) {
  4403. var switchCaseArgumentOrder = function(likelyArgumentCount) {
  4404. var ret = [likelyArgumentCount];
  4405. var min = Math.max(0, likelyArgumentCount - 1 - 3);
  4406. for(var i = likelyArgumentCount - 1; i >= min; --i) {
  4407. ret.push(i);
  4408. }
  4409. for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
  4410. ret.push(i);
  4411. }
  4412. return ret;
  4413. };
  4414. var argumentSequence = function(argumentCount) {
  4415. return util.filledRange(argumentCount, "_arg", "");
  4416. };
  4417. var parameterDeclaration = function(parameterCount) {
  4418. return util.filledRange(
  4419. Math.max(parameterCount, 3), "_arg", "");
  4420. };
  4421. var parameterCount = function(fn) {
  4422. if (typeof fn.length === "number") {
  4423. return Math.max(Math.min(fn.length, 1023 + 1), 0);
  4424. }
  4425. return 0;
  4426. };
  4427. makeNodePromisifiedEval =
  4428. function(callback, receiver, originalName, fn, _, multiArgs) {
  4429. var newParameterCount = Math.max(0, parameterCount(fn) - 1);
  4430. var argumentOrder = switchCaseArgumentOrder(newParameterCount);
  4431. var shouldProxyThis = typeof callback === "string" || receiver === THIS;
  4432. function generateCallForArgumentCount(count) {
  4433. var args = argumentSequence(count).join(", ");
  4434. var comma = count > 0 ? ", " : "";
  4435. var ret;
  4436. if (shouldProxyThis) {
  4437. ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
  4438. } else {
  4439. ret = receiver === undefined
  4440. ? "ret = callback({{args}}, nodeback); break;\n"
  4441. : "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
  4442. }
  4443. return ret.replace("{{args}}", args).replace(", ", comma);
  4444. }
  4445. function generateArgumentSwitchCase() {
  4446. var ret = "";
  4447. for (var i = 0; i < argumentOrder.length; ++i) {
  4448. ret += "case " + argumentOrder[i] +":" +
  4449. generateCallForArgumentCount(argumentOrder[i]);
  4450. }
  4451. ret += " \n\
  4452. default: \n\
  4453. var args = new Array(len + 1); \n\
  4454. var i = 0; \n\
  4455. for (var i = 0; i < len; ++i) { \n\
  4456. args[i] = arguments[i]; \n\
  4457. } \n\
  4458. args[i] = nodeback; \n\
  4459. [CodeForCall] \n\
  4460. break; \n\
  4461. ".replace("[CodeForCall]", (shouldProxyThis
  4462. ? "ret = callback.apply(this, args);\n"
  4463. : "ret = callback.apply(receiver, args);\n"));
  4464. return ret;
  4465. }
  4466. var getFunctionCode = typeof callback === "string"
  4467. ? ("this != null ? this['"+callback+"'] : fn")
  4468. : "fn";
  4469. var body = "'use strict'; \n\
  4470. var ret = function (Parameters) { \n\
  4471. 'use strict'; \n\
  4472. var len = arguments.length; \n\
  4473. var promise = new Promise(INTERNAL); \n\
  4474. promise._captureStackTrace(); \n\
  4475. var nodeback = nodebackForPromise(promise, " + multiArgs + "); \n\
  4476. var ret; \n\
  4477. var callback = tryCatch([GetFunctionCode]); \n\
  4478. switch(len) { \n\
  4479. [CodeForSwitchCase] \n\
  4480. } \n\
  4481. if (ret === errorObj) { \n\
  4482. promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
  4483. } \n\
  4484. if (!promise._isFateSealed()) promise._setAsyncGuaranteed(); \n\
  4485. return promise; \n\
  4486. }; \n\
  4487. notEnumerableProp(ret, '__isPromisified__', true); \n\
  4488. return ret; \n\
  4489. ".replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
  4490. .replace("[GetFunctionCode]", getFunctionCode);
  4491. body = body.replace("Parameters", parameterDeclaration(newParameterCount));
  4492. return new Function("Promise",
  4493. "fn",
  4494. "receiver",
  4495. "withAppended",
  4496. "maybeWrapAsError",
  4497. "nodebackForPromise",
  4498. "tryCatch",
  4499. "errorObj",
  4500. "notEnumerableProp",
  4501. "INTERNAL",
  4502. body)(
  4503. Promise,
  4504. fn,
  4505. receiver,
  4506. withAppended,
  4507. maybeWrapAsError,
  4508. nodebackForPromise,
  4509. util.tryCatch,
  4510. util.errorObj,
  4511. util.notEnumerableProp,
  4512. INTERNAL);
  4513. };
  4514. }
  4515. function makeNodePromisifiedClosure(callback, receiver, _, fn, __, multiArgs) {
  4516. var defaultThis = (function() {return this;})();
  4517. var method = callback;
  4518. if (typeof method === "string") {
  4519. callback = fn;
  4520. }
  4521. function promisified() {
  4522. var _receiver = receiver;
  4523. if (receiver === THIS) _receiver = this;
  4524. var promise = new Promise(INTERNAL);
  4525. promise._captureStackTrace();
  4526. var cb = typeof method === "string" && this !== defaultThis
  4527. ? this[method] : callback;
  4528. var fn = nodebackForPromise(promise, multiArgs);
  4529. try {
  4530. cb.apply(_receiver, withAppended(arguments, fn));
  4531. } catch(e) {
  4532. promise._rejectCallback(maybeWrapAsError(e), true, true);
  4533. }
  4534. if (!promise._isFateSealed()) promise._setAsyncGuaranteed();
  4535. return promise;
  4536. }
  4537. util.notEnumerableProp(promisified, "__isPromisified__", true);
  4538. return promisified;
  4539. }
  4540. var makeNodePromisified = canEvaluate
  4541. ? makeNodePromisifiedEval
  4542. : makeNodePromisifiedClosure;
  4543. function promisifyAll(obj, suffix, filter, promisifier, multiArgs) {
  4544. var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
  4545. var methods =
  4546. promisifiableMethods(obj, suffix, suffixRegexp, filter);
  4547. for (var i = 0, len = methods.length; i < len; i+= 2) {
  4548. var key = methods[i];
  4549. var fn = methods[i+1];
  4550. var promisifiedKey = key + suffix;
  4551. if (promisifier === makeNodePromisified) {
  4552. obj[promisifiedKey] =
  4553. makeNodePromisified(key, THIS, key, fn, suffix, multiArgs);
  4554. } else {
  4555. var promisified = promisifier(fn, function() {
  4556. return makeNodePromisified(key, THIS, key,
  4557. fn, suffix, multiArgs);
  4558. });
  4559. util.notEnumerableProp(promisified, "__isPromisified__", true);
  4560. obj[promisifiedKey] = promisified;
  4561. }
  4562. }
  4563. util.toFastProperties(obj);
  4564. return obj;
  4565. }
  4566. function promisify(callback, receiver, multiArgs) {
  4567. return makeNodePromisified(callback, receiver, undefined,
  4568. callback, null, multiArgs);
  4569. }
  4570. Promise.promisify = function (fn, options) {
  4571. if (typeof fn !== "function") {
  4572. throw new TypeError("expecting a function but got " + util.classString(fn));
  4573. }
  4574. if (isPromisified(fn)) {
  4575. return fn;
  4576. }
  4577. options = Object(options);
  4578. var receiver = options.context === undefined ? THIS : options.context;
  4579. var multiArgs = !!options.multiArgs;
  4580. var ret = promisify(fn, receiver, multiArgs);
  4581. util.copyDescriptors(fn, ret, propsFilter);
  4582. return ret;
  4583. };
  4584. Promise.promisifyAll = function (target, options) {
  4585. if (typeof target !== "function" && typeof target !== "object") {
  4586. throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4587. }
  4588. options = Object(options);
  4589. var multiArgs = !!options.multiArgs;
  4590. var suffix = options.suffix;
  4591. if (typeof suffix !== "string") suffix = defaultSuffix;
  4592. var filter = options.filter;
  4593. if (typeof filter !== "function") filter = defaultFilter;
  4594. var promisifier = options.promisifier;
  4595. if (typeof promisifier !== "function") promisifier = makeNodePromisified;
  4596. if (!util.isIdentifier(suffix)) {
  4597. throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4598. }
  4599. var keys = util.inheritedDataKeys(target);
  4600. for (var i = 0; i < keys.length; ++i) {
  4601. var value = target[keys[i]];
  4602. if (keys[i] !== "constructor" &&
  4603. util.isClass(value)) {
  4604. promisifyAll(value.prototype, suffix, filter, promisifier,
  4605. multiArgs);
  4606. promisifyAll(value, suffix, filter, promisifier, multiArgs);
  4607. }
  4608. }
  4609. return promisifyAll(target, suffix, filter, promisifier, multiArgs);
  4610. };
  4611. };
  4612. },{"./errors":12,"./nodeback":20,"./util":36}],25:[function(_dereq_,module,exports){
  4613. "use strict";
  4614. module.exports = function(
  4615. Promise, PromiseArray, tryConvertToPromise, apiRejection) {
  4616. var util = _dereq_("./util");
  4617. var isObject = util.isObject;
  4618. var es5 = _dereq_("./es5");
  4619. var Es6Map;
  4620. if (typeof Map === "function") Es6Map = Map;
  4621. var mapToEntries = (function() {
  4622. var index = 0;
  4623. var size = 0;
  4624. function extractEntry(value, key) {
  4625. this[index] = value;
  4626. this[index + size] = key;
  4627. index++;
  4628. }
  4629. return function mapToEntries(map) {
  4630. size = map.size;
  4631. index = 0;
  4632. var ret = new Array(map.size * 2);
  4633. map.forEach(extractEntry, ret);
  4634. return ret;
  4635. };
  4636. })();
  4637. var entriesToMap = function(entries) {
  4638. var ret = new Es6Map();
  4639. var length = entries.length / 2 | 0;
  4640. for (var i = 0; i < length; ++i) {
  4641. var key = entries[length + i];
  4642. var value = entries[i];
  4643. ret.set(key, value);
  4644. }
  4645. return ret;
  4646. };
  4647. function PropertiesPromiseArray(obj) {
  4648. var isMap = false;
  4649. var entries;
  4650. if (Es6Map !== undefined && obj instanceof Es6Map) {
  4651. entries = mapToEntries(obj);
  4652. isMap = true;
  4653. } else {
  4654. var keys = es5.keys(obj);
  4655. var len = keys.length;
  4656. entries = new Array(len * 2);
  4657. for (var i = 0; i < len; ++i) {
  4658. var key = keys[i];
  4659. entries[i] = obj[key];
  4660. entries[i + len] = key;
  4661. }
  4662. }
  4663. this.constructor$(entries);
  4664. this._isMap = isMap;
  4665. this._init$(undefined, -3);
  4666. }
  4667. util.inherits(PropertiesPromiseArray, PromiseArray);
  4668. PropertiesPromiseArray.prototype._init = function () {};
  4669. PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
  4670. this._values[index] = value;
  4671. var totalResolved = ++this._totalResolved;
  4672. if (totalResolved >= this._length) {
  4673. var val;
  4674. if (this._isMap) {
  4675. val = entriesToMap(this._values);
  4676. } else {
  4677. val = {};
  4678. var keyOffset = this.length();
  4679. for (var i = 0, len = this.length(); i < len; ++i) {
  4680. val[this._values[i + keyOffset]] = this._values[i];
  4681. }
  4682. }
  4683. this._resolve(val);
  4684. return true;
  4685. }
  4686. return false;
  4687. };
  4688. PropertiesPromiseArray.prototype.shouldCopyValues = function () {
  4689. return false;
  4690. };
  4691. PropertiesPromiseArray.prototype.getActualLength = function (len) {
  4692. return len >> 1;
  4693. };
  4694. function props(promises) {
  4695. var ret;
  4696. var castValue = tryConvertToPromise(promises);
  4697. if (!isObject(castValue)) {
  4698. return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4699. } else if (castValue instanceof Promise) {
  4700. ret = castValue._then(
  4701. Promise.props, undefined, undefined, undefined, undefined);
  4702. } else {
  4703. ret = new PropertiesPromiseArray(castValue).promise();
  4704. }
  4705. if (castValue instanceof Promise) {
  4706. ret._propagateFrom(castValue, 2);
  4707. }
  4708. return ret;
  4709. }
  4710. Promise.prototype.props = function () {
  4711. return props(this);
  4712. };
  4713. Promise.props = function (promises) {
  4714. return props(promises);
  4715. };
  4716. };
  4717. },{"./es5":13,"./util":36}],26:[function(_dereq_,module,exports){
  4718. "use strict";
  4719. function arrayMove(src, srcIndex, dst, dstIndex, len) {
  4720. for (var j = 0; j < len; ++j) {
  4721. dst[j + dstIndex] = src[j + srcIndex];
  4722. src[j + srcIndex] = void 0;
  4723. }
  4724. }
  4725. function Queue(capacity) {
  4726. this._capacity = capacity;
  4727. this._length = 0;
  4728. this._front = 0;
  4729. }
  4730. Queue.prototype._willBeOverCapacity = function (size) {
  4731. return this._capacity < size;
  4732. };
  4733. Queue.prototype._pushOne = function (arg) {
  4734. var length = this.length();
  4735. this._checkCapacity(length + 1);
  4736. var i = (this._front + length) & (this._capacity - 1);
  4737. this[i] = arg;
  4738. this._length = length + 1;
  4739. };
  4740. Queue.prototype._unshiftOne = function(value) {
  4741. var capacity = this._capacity;
  4742. this._checkCapacity(this.length() + 1);
  4743. var front = this._front;
  4744. var i = (((( front - 1 ) &
  4745. ( capacity - 1) ) ^ capacity ) - capacity );
  4746. this[i] = value;
  4747. this._front = i;
  4748. this._length = this.length() + 1;
  4749. };
  4750. Queue.prototype.unshift = function(fn, receiver, arg) {
  4751. this._unshiftOne(arg);
  4752. this._unshiftOne(receiver);
  4753. this._unshiftOne(fn);
  4754. };
  4755. Queue.prototype.push = function (fn, receiver, arg) {
  4756. var length = this.length() + 3;
  4757. if (this._willBeOverCapacity(length)) {
  4758. this._pushOne(fn);
  4759. this._pushOne(receiver);
  4760. this._pushOne(arg);
  4761. return;
  4762. }
  4763. var j = this._front + length - 3;
  4764. this._checkCapacity(length);
  4765. var wrapMask = this._capacity - 1;
  4766. this[(j + 0) & wrapMask] = fn;
  4767. this[(j + 1) & wrapMask] = receiver;
  4768. this[(j + 2) & wrapMask] = arg;
  4769. this._length = length;
  4770. };
  4771. Queue.prototype.shift = function () {
  4772. var front = this._front,
  4773. ret = this[front];
  4774. this[front] = undefined;
  4775. this._front = (front + 1) & (this._capacity - 1);
  4776. this._length--;
  4777. return ret;
  4778. };
  4779. Queue.prototype.length = function () {
  4780. return this._length;
  4781. };
  4782. Queue.prototype._checkCapacity = function (size) {
  4783. if (this._capacity < size) {
  4784. this._resizeTo(this._capacity << 1);
  4785. }
  4786. };
  4787. Queue.prototype._resizeTo = function (capacity) {
  4788. var oldCapacity = this._capacity;
  4789. this._capacity = capacity;
  4790. var front = this._front;
  4791. var length = this._length;
  4792. var moveItemsCount = (front + length) & (oldCapacity - 1);
  4793. arrayMove(this, 0, this, oldCapacity, moveItemsCount);
  4794. };
  4795. module.exports = Queue;
  4796. },{}],27:[function(_dereq_,module,exports){
  4797. "use strict";
  4798. module.exports = function(
  4799. Promise, INTERNAL, tryConvertToPromise, apiRejection) {
  4800. var util = _dereq_("./util");
  4801. var raceLater = function (promise) {
  4802. return promise.then(function(array) {
  4803. return race(array, promise);
  4804. });
  4805. };
  4806. function race(promises, parent) {
  4807. var maybePromise = tryConvertToPromise(promises);
  4808. if (maybePromise instanceof Promise) {
  4809. return raceLater(maybePromise);
  4810. } else {
  4811. promises = util.asArray(promises);
  4812. if (promises === null)
  4813. return apiRejection("expecting an array or an iterable object but got " + util.classString(promises));
  4814. }
  4815. var ret = new Promise(INTERNAL);
  4816. if (parent !== undefined) {
  4817. ret._propagateFrom(parent, 3);
  4818. }
  4819. var fulfill = ret._fulfill;
  4820. var reject = ret._reject;
  4821. for (var i = 0, len = promises.length; i < len; ++i) {
  4822. var val = promises[i];
  4823. if (val === undefined && !(i in promises)) {
  4824. continue;
  4825. }
  4826. Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
  4827. }
  4828. return ret;
  4829. }
  4830. Promise.race = function (promises) {
  4831. return race(promises, undefined);
  4832. };
  4833. Promise.prototype.race = function () {
  4834. return race(this, undefined);
  4835. };
  4836. };
  4837. },{"./util":36}],28:[function(_dereq_,module,exports){
  4838. "use strict";
  4839. module.exports = function(Promise,
  4840. PromiseArray,
  4841. apiRejection,
  4842. tryConvertToPromise,
  4843. INTERNAL,
  4844. debug) {
  4845. var getDomain = Promise._getDomain;
  4846. var util = _dereq_("./util");
  4847. var tryCatch = util.tryCatch;
  4848. function ReductionPromiseArray(promises, fn, initialValue, _each) {
  4849. this.constructor$(promises);
  4850. var domain = getDomain();
  4851. this._fn = domain === null ? fn : util.domainBind(domain, fn);
  4852. if (initialValue !== undefined) {
  4853. initialValue = Promise.resolve(initialValue);
  4854. initialValue._attachCancellationCallback(this);
  4855. }
  4856. this._initialValue = initialValue;
  4857. this._currentCancellable = null;
  4858. if(_each === INTERNAL) {
  4859. this._eachValues = Array(this._length);
  4860. } else if (_each === 0) {
  4861. this._eachValues = null;
  4862. } else {
  4863. this._eachValues = undefined;
  4864. }
  4865. this._promise._captureStackTrace();
  4866. this._init$(undefined, -5);
  4867. }
  4868. util.inherits(ReductionPromiseArray, PromiseArray);
  4869. ReductionPromiseArray.prototype._gotAccum = function(accum) {
  4870. if (this._eachValues !== undefined &&
  4871. this._eachValues !== null &&
  4872. accum !== INTERNAL) {
  4873. this._eachValues.push(accum);
  4874. }
  4875. };
  4876. ReductionPromiseArray.prototype._eachComplete = function(value) {
  4877. if (this._eachValues !== null) {
  4878. this._eachValues.push(value);
  4879. }
  4880. return this._eachValues;
  4881. };
  4882. ReductionPromiseArray.prototype._init = function() {};
  4883. ReductionPromiseArray.prototype._resolveEmptyArray = function() {
  4884. this._resolve(this._eachValues !== undefined ? this._eachValues
  4885. : this._initialValue);
  4886. };
  4887. ReductionPromiseArray.prototype.shouldCopyValues = function () {
  4888. return false;
  4889. };
  4890. ReductionPromiseArray.prototype._resolve = function(value) {
  4891. this._promise._resolveCallback(value);
  4892. this._values = null;
  4893. };
  4894. ReductionPromiseArray.prototype._resultCancelled = function(sender) {
  4895. if (sender === this._initialValue) return this._cancel();
  4896. if (this._isResolved()) return;
  4897. this._resultCancelled$();
  4898. if (this._currentCancellable instanceof Promise) {
  4899. this._currentCancellable.cancel();
  4900. }
  4901. if (this._initialValue instanceof Promise) {
  4902. this._initialValue.cancel();
  4903. }
  4904. };
  4905. ReductionPromiseArray.prototype._iterate = function (values) {
  4906. this._values = values;
  4907. var value;
  4908. var i;
  4909. var length = values.length;
  4910. if (this._initialValue !== undefined) {
  4911. value = this._initialValue;
  4912. i = 0;
  4913. } else {
  4914. value = Promise.resolve(values[0]);
  4915. i = 1;
  4916. }
  4917. this._currentCancellable = value;
  4918. if (!value.isRejected()) {
  4919. for (; i < length; ++i) {
  4920. var ctx = {
  4921. accum: null,
  4922. value: values[i],
  4923. index: i,
  4924. length: length,
  4925. array: this
  4926. };
  4927. value = value._then(gotAccum, undefined, undefined, ctx, undefined);
  4928. }
  4929. }
  4930. if (this._eachValues !== undefined) {
  4931. value = value
  4932. ._then(this._eachComplete, undefined, undefined, this, undefined);
  4933. }
  4934. value._then(completed, completed, undefined, value, this);
  4935. };
  4936. Promise.prototype.reduce = function (fn, initialValue) {
  4937. return reduce(this, fn, initialValue, null);
  4938. };
  4939. Promise.reduce = function (promises, fn, initialValue, _each) {
  4940. return reduce(promises, fn, initialValue, _each);
  4941. };
  4942. function completed(valueOrReason, array) {
  4943. if (this.isFulfilled()) {
  4944. array._resolve(valueOrReason);
  4945. } else {
  4946. array._reject(valueOrReason);
  4947. }
  4948. }
  4949. function reduce(promises, fn, initialValue, _each) {
  4950. if (typeof fn !== "function") {
  4951. return apiRejection("expecting a function but got " + util.classString(fn));
  4952. }
  4953. var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
  4954. return array.promise();
  4955. }
  4956. function gotAccum(accum) {
  4957. this.accum = accum;
  4958. this.array._gotAccum(accum);
  4959. var value = tryConvertToPromise(this.value, this.array._promise);
  4960. if (value instanceof Promise) {
  4961. this.array._currentCancellable = value;
  4962. return value._then(gotValue, undefined, undefined, this, undefined);
  4963. } else {
  4964. return gotValue.call(this, value);
  4965. }
  4966. }
  4967. function gotValue(value) {
  4968. var array = this.array;
  4969. var promise = array._promise;
  4970. var fn = tryCatch(array._fn);
  4971. promise._pushContext();
  4972. var ret;
  4973. if (array._eachValues !== undefined) {
  4974. ret = fn.call(promise._boundValue(), value, this.index, this.length);
  4975. } else {
  4976. ret = fn.call(promise._boundValue(),
  4977. this.accum, value, this.index, this.length);
  4978. }
  4979. if (ret instanceof Promise) {
  4980. array._currentCancellable = ret;
  4981. }
  4982. var promiseCreated = promise._popContext();
  4983. debug.checkForgottenReturns(
  4984. ret,
  4985. promiseCreated,
  4986. array._eachValues !== undefined ? "Promise.each" : "Promise.reduce",
  4987. promise
  4988. );
  4989. return ret;
  4990. }
  4991. };
  4992. },{"./util":36}],29:[function(_dereq_,module,exports){
  4993. "use strict";
  4994. var util = _dereq_("./util");
  4995. var schedule;
  4996. var noAsyncScheduler = function() {
  4997. throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4998. };
  4999. var NativePromise = util.getNativePromise();
  5000. if (util.isNode && typeof MutationObserver === "undefined") {
  5001. var GlobalSetImmediate = global.setImmediate;
  5002. var ProcessNextTick = process.nextTick;
  5003. schedule = util.isRecentNode
  5004. ? function(fn) { GlobalSetImmediate.call(global, fn); }
  5005. : function(fn) { ProcessNextTick.call(process, fn); };
  5006. } else if (typeof NativePromise === "function" &&
  5007. typeof NativePromise.resolve === "function") {
  5008. var nativePromise = NativePromise.resolve();
  5009. schedule = function(fn) {
  5010. nativePromise.then(fn);
  5011. };
  5012. } else if ((typeof MutationObserver !== "undefined") &&
  5013. !(typeof window !== "undefined" &&
  5014. window.navigator &&
  5015. (window.navigator.standalone || window.cordova))) {
  5016. schedule = (function() {
  5017. var div = document.createElement("div");
  5018. var opts = {attributes: true};
  5019. var toggleScheduled = false;
  5020. var div2 = document.createElement("div");
  5021. var o2 = new MutationObserver(function() {
  5022. div.classList.toggle("foo");
  5023. toggleScheduled = false;
  5024. });
  5025. o2.observe(div2, opts);
  5026. var scheduleToggle = function() {
  5027. if (toggleScheduled) return;
  5028. toggleScheduled = true;
  5029. div2.classList.toggle("foo");
  5030. };
  5031. return function schedule(fn) {
  5032. var o = new MutationObserver(function() {
  5033. o.disconnect();
  5034. fn();
  5035. });
  5036. o.observe(div, opts);
  5037. scheduleToggle();
  5038. };
  5039. })();
  5040. } else if (typeof setImmediate !== "undefined") {
  5041. schedule = function (fn) {
  5042. setImmediate(fn);
  5043. };
  5044. } else if (typeof setTimeout !== "undefined") {
  5045. schedule = function (fn) {
  5046. setTimeout(fn, 0);
  5047. };
  5048. } else {
  5049. schedule = noAsyncScheduler;
  5050. }
  5051. module.exports = schedule;
  5052. },{"./util":36}],30:[function(_dereq_,module,exports){
  5053. "use strict";
  5054. module.exports =
  5055. function(Promise, PromiseArray, debug) {
  5056. var PromiseInspection = Promise.PromiseInspection;
  5057. var util = _dereq_("./util");
  5058. function SettledPromiseArray(values) {
  5059. this.constructor$(values);
  5060. }
  5061. util.inherits(SettledPromiseArray, PromiseArray);
  5062. SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
  5063. this._values[index] = inspection;
  5064. var totalResolved = ++this._totalResolved;
  5065. if (totalResolved >= this._length) {
  5066. this._resolve(this._values);
  5067. return true;
  5068. }
  5069. return false;
  5070. };
  5071. SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
  5072. var ret = new PromiseInspection();
  5073. ret._bitField = 33554432;
  5074. ret._settledValueField = value;
  5075. return this._promiseResolved(index, ret);
  5076. };
  5077. SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
  5078. var ret = new PromiseInspection();
  5079. ret._bitField = 16777216;
  5080. ret._settledValueField = reason;
  5081. return this._promiseResolved(index, ret);
  5082. };
  5083. Promise.settle = function (promises) {
  5084. debug.deprecated(".settle()", ".reflect()");
  5085. return new SettledPromiseArray(promises).promise();
  5086. };
  5087. Promise.prototype.settle = function () {
  5088. return Promise.settle(this);
  5089. };
  5090. };
  5091. },{"./util":36}],31:[function(_dereq_,module,exports){
  5092. "use strict";
  5093. module.exports =
  5094. function(Promise, PromiseArray, apiRejection) {
  5095. var util = _dereq_("./util");
  5096. var RangeError = _dereq_("./errors").RangeError;
  5097. var AggregateError = _dereq_("./errors").AggregateError;
  5098. var isArray = util.isArray;
  5099. var CANCELLATION = {};
  5100. function SomePromiseArray(values) {
  5101. this.constructor$(values);
  5102. this._howMany = 0;
  5103. this._unwrap = false;
  5104. this._initialized = false;
  5105. }
  5106. util.inherits(SomePromiseArray, PromiseArray);
  5107. SomePromiseArray.prototype._init = function () {
  5108. if (!this._initialized) {
  5109. return;
  5110. }
  5111. if (this._howMany === 0) {
  5112. this._resolve([]);
  5113. return;
  5114. }
  5115. this._init$(undefined, -5);
  5116. var isArrayResolved = isArray(this._values);
  5117. if (!this._isResolved() &&
  5118. isArrayResolved &&
  5119. this._howMany > this._canPossiblyFulfill()) {
  5120. this._reject(this._getRangeError(this.length()));
  5121. }
  5122. };
  5123. SomePromiseArray.prototype.init = function () {
  5124. this._initialized = true;
  5125. this._init();
  5126. };
  5127. SomePromiseArray.prototype.setUnwrap = function () {
  5128. this._unwrap = true;
  5129. };
  5130. SomePromiseArray.prototype.howMany = function () {
  5131. return this._howMany;
  5132. };
  5133. SomePromiseArray.prototype.setHowMany = function (count) {
  5134. this._howMany = count;
  5135. };
  5136. SomePromiseArray.prototype._promiseFulfilled = function (value) {
  5137. this._addFulfilled(value);
  5138. if (this._fulfilled() === this.howMany()) {
  5139. this._values.length = this.howMany();
  5140. if (this.howMany() === 1 && this._unwrap) {
  5141. this._resolve(this._values[0]);
  5142. } else {
  5143. this._resolve(this._values);
  5144. }
  5145. return true;
  5146. }
  5147. return false;
  5148. };
  5149. SomePromiseArray.prototype._promiseRejected = function (reason) {
  5150. this._addRejected(reason);
  5151. return this._checkOutcome();
  5152. };
  5153. SomePromiseArray.prototype._promiseCancelled = function () {
  5154. if (this._values instanceof Promise || this._values == null) {
  5155. return this._cancel();
  5156. }
  5157. this._addRejected(CANCELLATION);
  5158. return this._checkOutcome();
  5159. };
  5160. SomePromiseArray.prototype._checkOutcome = function() {
  5161. if (this.howMany() > this._canPossiblyFulfill()) {
  5162. var e = new AggregateError();
  5163. for (var i = this.length(); i < this._values.length; ++i) {
  5164. if (this._values[i] !== CANCELLATION) {
  5165. e.push(this._values[i]);
  5166. }
  5167. }
  5168. if (e.length > 0) {
  5169. this._reject(e);
  5170. } else {
  5171. this._cancel();
  5172. }
  5173. return true;
  5174. }
  5175. return false;
  5176. };
  5177. SomePromiseArray.prototype._fulfilled = function () {
  5178. return this._totalResolved;
  5179. };
  5180. SomePromiseArray.prototype._rejected = function () {
  5181. return this._values.length - this.length();
  5182. };
  5183. SomePromiseArray.prototype._addRejected = function (reason) {
  5184. this._values.push(reason);
  5185. };
  5186. SomePromiseArray.prototype._addFulfilled = function (value) {
  5187. this._values[this._totalResolved++] = value;
  5188. };
  5189. SomePromiseArray.prototype._canPossiblyFulfill = function () {
  5190. return this.length() - this._rejected();
  5191. };
  5192. SomePromiseArray.prototype._getRangeError = function (count) {
  5193. var message = "Input array must contain at least " +
  5194. this._howMany + " items but contains only " + count + " items";
  5195. return new RangeError(message);
  5196. };
  5197. SomePromiseArray.prototype._resolveEmptyArray = function () {
  5198. this._reject(this._getRangeError(0));
  5199. };
  5200. function some(promises, howMany) {
  5201. if ((howMany | 0) !== howMany || howMany < 0) {
  5202. return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  5203. }
  5204. var ret = new SomePromiseArray(promises);
  5205. var promise = ret.promise();
  5206. ret.setHowMany(howMany);
  5207. ret.init();
  5208. return promise;
  5209. }
  5210. Promise.some = function (promises, howMany) {
  5211. return some(promises, howMany);
  5212. };
  5213. Promise.prototype.some = function (howMany) {
  5214. return some(this, howMany);
  5215. };
  5216. Promise._SomePromiseArray = SomePromiseArray;
  5217. };
  5218. },{"./errors":12,"./util":36}],32:[function(_dereq_,module,exports){
  5219. "use strict";
  5220. module.exports = function(Promise) {
  5221. function PromiseInspection(promise) {
  5222. if (promise !== undefined) {
  5223. promise = promise._target();
  5224. this._bitField = promise._bitField;
  5225. this._settledValueField = promise._isFateSealed()
  5226. ? promise._settledValue() : undefined;
  5227. }
  5228. else {
  5229. this._bitField = 0;
  5230. this._settledValueField = undefined;
  5231. }
  5232. }
  5233. PromiseInspection.prototype._settledValue = function() {
  5234. return this._settledValueField;
  5235. };
  5236. var value = PromiseInspection.prototype.value = function () {
  5237. if (!this.isFulfilled()) {
  5238. throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  5239. }
  5240. return this._settledValue();
  5241. };
  5242. var reason = PromiseInspection.prototype.error =
  5243. PromiseInspection.prototype.reason = function () {
  5244. if (!this.isRejected()) {
  5245. throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  5246. }
  5247. return this._settledValue();
  5248. };
  5249. var isFulfilled = PromiseInspection.prototype.isFulfilled = function() {
  5250. return (this._bitField & 33554432) !== 0;
  5251. };
  5252. var isRejected = PromiseInspection.prototype.isRejected = function () {
  5253. return (this._bitField & 16777216) !== 0;
  5254. };
  5255. var isPending = PromiseInspection.prototype.isPending = function () {
  5256. return (this._bitField & 50397184) === 0;
  5257. };
  5258. var isResolved = PromiseInspection.prototype.isResolved = function () {
  5259. return (this._bitField & 50331648) !== 0;
  5260. };
  5261. PromiseInspection.prototype.isCancelled = function() {
  5262. return (this._bitField & 8454144) !== 0;
  5263. };
  5264. Promise.prototype.__isCancelled = function() {
  5265. return (this._bitField & 65536) === 65536;
  5266. };
  5267. Promise.prototype._isCancelled = function() {
  5268. return this._target().__isCancelled();
  5269. };
  5270. Promise.prototype.isCancelled = function() {
  5271. return (this._target()._bitField & 8454144) !== 0;
  5272. };
  5273. Promise.prototype.isPending = function() {
  5274. return isPending.call(this._target());
  5275. };
  5276. Promise.prototype.isRejected = function() {
  5277. return isRejected.call(this._target());
  5278. };
  5279. Promise.prototype.isFulfilled = function() {
  5280. return isFulfilled.call(this._target());
  5281. };
  5282. Promise.prototype.isResolved = function() {
  5283. return isResolved.call(this._target());
  5284. };
  5285. Promise.prototype.value = function() {
  5286. return value.call(this._target());
  5287. };
  5288. Promise.prototype.reason = function() {
  5289. var target = this._target();
  5290. target._unsetRejectionIsUnhandled();
  5291. return reason.call(target);
  5292. };
  5293. Promise.prototype._value = function() {
  5294. return this._settledValue();
  5295. };
  5296. Promise.prototype._reason = function() {
  5297. this._unsetRejectionIsUnhandled();
  5298. return this._settledValue();
  5299. };
  5300. Promise.PromiseInspection = PromiseInspection;
  5301. };
  5302. },{}],33:[function(_dereq_,module,exports){
  5303. "use strict";
  5304. module.exports = function(Promise, INTERNAL) {
  5305. var util = _dereq_("./util");
  5306. var errorObj = util.errorObj;
  5307. var isObject = util.isObject;
  5308. function tryConvertToPromise(obj, context) {
  5309. if (isObject(obj)) {
  5310. if (obj instanceof Promise) return obj;
  5311. var then = getThen(obj);
  5312. if (then === errorObj) {
  5313. if (context) context._pushContext();
  5314. var ret = Promise.reject(then.e);
  5315. if (context) context._popContext();
  5316. return ret;
  5317. } else if (typeof then === "function") {
  5318. if (isAnyBluebirdPromise(obj)) {
  5319. var ret = new Promise(INTERNAL);
  5320. obj._then(
  5321. ret._fulfill,
  5322. ret._reject,
  5323. undefined,
  5324. ret,
  5325. null
  5326. );
  5327. return ret;
  5328. }
  5329. return doThenable(obj, then, context);
  5330. }
  5331. }
  5332. return obj;
  5333. }
  5334. function doGetThen(obj) {
  5335. return obj.then;
  5336. }
  5337. function getThen(obj) {
  5338. try {
  5339. return doGetThen(obj);
  5340. } catch (e) {
  5341. errorObj.e = e;
  5342. return errorObj;
  5343. }
  5344. }
  5345. var hasProp = {}.hasOwnProperty;
  5346. function isAnyBluebirdPromise(obj) {
  5347. try {
  5348. return hasProp.call(obj, "_promise0");
  5349. } catch (e) {
  5350. return false;
  5351. }
  5352. }
  5353. function doThenable(x, then, context) {
  5354. var promise = new Promise(INTERNAL);
  5355. var ret = promise;
  5356. if (context) context._pushContext();
  5357. promise._captureStackTrace();
  5358. if (context) context._popContext();
  5359. var synchronous = true;
  5360. var result = util.tryCatch(then).call(x, resolve, reject);
  5361. synchronous = false;
  5362. if (promise && result === errorObj) {
  5363. promise._rejectCallback(result.e, true, true);
  5364. promise = null;
  5365. }
  5366. function resolve(value) {
  5367. if (!promise) return;
  5368. promise._resolveCallback(value);
  5369. promise = null;
  5370. }
  5371. function reject(reason) {
  5372. if (!promise) return;
  5373. promise._rejectCallback(reason, synchronous, true);
  5374. promise = null;
  5375. }
  5376. return ret;
  5377. }
  5378. return tryConvertToPromise;
  5379. };
  5380. },{"./util":36}],34:[function(_dereq_,module,exports){
  5381. "use strict";
  5382. module.exports = function(Promise, INTERNAL, debug) {
  5383. var util = _dereq_("./util");
  5384. var TimeoutError = Promise.TimeoutError;
  5385. function HandleWrapper(handle) {
  5386. this.handle = handle;
  5387. }
  5388. HandleWrapper.prototype._resultCancelled = function() {
  5389. clearTimeout(this.handle);
  5390. };
  5391. var afterValue = function(value) { return delay(+this).thenReturn(value); };
  5392. var delay = Promise.delay = function (ms, value) {
  5393. var ret;
  5394. var handle;
  5395. if (value !== undefined) {
  5396. ret = Promise.resolve(value)
  5397. ._then(afterValue, null, null, ms, undefined);
  5398. if (debug.cancellation() && value instanceof Promise) {
  5399. ret._setOnCancel(value);
  5400. }
  5401. } else {
  5402. ret = new Promise(INTERNAL);
  5403. handle = setTimeout(function() { ret._fulfill(); }, +ms);
  5404. if (debug.cancellation()) {
  5405. ret._setOnCancel(new HandleWrapper(handle));
  5406. }
  5407. ret._captureStackTrace();
  5408. }
  5409. ret._setAsyncGuaranteed();
  5410. return ret;
  5411. };
  5412. Promise.prototype.delay = function (ms) {
  5413. return delay(ms, this);
  5414. };
  5415. var afterTimeout = function (promise, message, parent) {
  5416. var err;
  5417. if (typeof message !== "string") {
  5418. if (message instanceof Error) {
  5419. err = message;
  5420. } else {
  5421. err = new TimeoutError("operation timed out");
  5422. }
  5423. } else {
  5424. err = new TimeoutError(message);
  5425. }
  5426. util.markAsOriginatingFromRejection(err);
  5427. promise._attachExtraTrace(err);
  5428. promise._reject(err);
  5429. if (parent != null) {
  5430. parent.cancel();
  5431. }
  5432. };
  5433. function successClear(value) {
  5434. clearTimeout(this.handle);
  5435. return value;
  5436. }
  5437. function failureClear(reason) {
  5438. clearTimeout(this.handle);
  5439. throw reason;
  5440. }
  5441. Promise.prototype.timeout = function (ms, message) {
  5442. ms = +ms;
  5443. var ret, parent;
  5444. var handleWrapper = new HandleWrapper(setTimeout(function timeoutTimeout() {
  5445. if (ret.isPending()) {
  5446. afterTimeout(ret, message, parent);
  5447. }
  5448. }, ms));
  5449. if (debug.cancellation()) {
  5450. parent = this.then();
  5451. ret = parent._then(successClear, failureClear,
  5452. undefined, handleWrapper, undefined);
  5453. ret._setOnCancel(handleWrapper);
  5454. } else {
  5455. ret = this._then(successClear, failureClear,
  5456. undefined, handleWrapper, undefined);
  5457. }
  5458. return ret;
  5459. };
  5460. };
  5461. },{"./util":36}],35:[function(_dereq_,module,exports){
  5462. "use strict";
  5463. module.exports = function (Promise, apiRejection, tryConvertToPromise,
  5464. createContext, INTERNAL, debug) {
  5465. var util = _dereq_("./util");
  5466. var TypeError = _dereq_("./errors").TypeError;
  5467. var inherits = _dereq_("./util").inherits;
  5468. var errorObj = util.errorObj;
  5469. var tryCatch = util.tryCatch;
  5470. var NULL = {};
  5471. function thrower(e) {
  5472. setTimeout(function(){throw e;}, 0);
  5473. }
  5474. function castPreservingDisposable(thenable) {
  5475. var maybePromise = tryConvertToPromise(thenable);
  5476. if (maybePromise !== thenable &&
  5477. typeof thenable._isDisposable === "function" &&
  5478. typeof thenable._getDisposer === "function" &&
  5479. thenable._isDisposable()) {
  5480. maybePromise._setDisposable(thenable._getDisposer());
  5481. }
  5482. return maybePromise;
  5483. }
  5484. function dispose(resources, inspection) {
  5485. var i = 0;
  5486. var len = resources.length;
  5487. var ret = new Promise(INTERNAL);
  5488. function iterator() {
  5489. if (i >= len) return ret._fulfill();
  5490. var maybePromise = castPreservingDisposable(resources[i++]);
  5491. if (maybePromise instanceof Promise &&
  5492. maybePromise._isDisposable()) {
  5493. try {
  5494. maybePromise = tryConvertToPromise(
  5495. maybePromise._getDisposer().tryDispose(inspection),
  5496. resources.promise);
  5497. } catch (e) {
  5498. return thrower(e);
  5499. }
  5500. if (maybePromise instanceof Promise) {
  5501. return maybePromise._then(iterator, thrower,
  5502. null, null, null);
  5503. }
  5504. }
  5505. iterator();
  5506. }
  5507. iterator();
  5508. return ret;
  5509. }
  5510. function Disposer(data, promise, context) {
  5511. this._data = data;
  5512. this._promise = promise;
  5513. this._context = context;
  5514. }
  5515. Disposer.prototype.data = function () {
  5516. return this._data;
  5517. };
  5518. Disposer.prototype.promise = function () {
  5519. return this._promise;
  5520. };
  5521. Disposer.prototype.resource = function () {
  5522. if (this.promise().isFulfilled()) {
  5523. return this.promise().value();
  5524. }
  5525. return NULL;
  5526. };
  5527. Disposer.prototype.tryDispose = function(inspection) {
  5528. var resource = this.resource();
  5529. var context = this._context;
  5530. if (context !== undefined) context._pushContext();
  5531. var ret = resource !== NULL
  5532. ? this.doDispose(resource, inspection) : null;
  5533. if (context !== undefined) context._popContext();
  5534. this._promise._unsetDisposable();
  5535. this._data = null;
  5536. return ret;
  5537. };
  5538. Disposer.isDisposer = function (d) {
  5539. return (d != null &&
  5540. typeof d.resource === "function" &&
  5541. typeof d.tryDispose === "function");
  5542. };
  5543. function FunctionDisposer(fn, promise, context) {
  5544. this.constructor$(fn, promise, context);
  5545. }
  5546. inherits(FunctionDisposer, Disposer);
  5547. FunctionDisposer.prototype.doDispose = function (resource, inspection) {
  5548. var fn = this.data();
  5549. return fn.call(resource, resource, inspection);
  5550. };
  5551. function maybeUnwrapDisposer(value) {
  5552. if (Disposer.isDisposer(value)) {
  5553. this.resources[this.index]._setDisposable(value);
  5554. return value.promise();
  5555. }
  5556. return value;
  5557. }
  5558. function ResourceList(length) {
  5559. this.length = length;
  5560. this.promise = null;
  5561. this[length-1] = null;
  5562. }
  5563. ResourceList.prototype._resultCancelled = function() {
  5564. var len = this.length;
  5565. for (var i = 0; i < len; ++i) {
  5566. var item = this[i];
  5567. if (item instanceof Promise) {
  5568. item.cancel();
  5569. }
  5570. }
  5571. };
  5572. Promise.using = function () {
  5573. var len = arguments.length;
  5574. if (len < 2) return apiRejection(
  5575. "you must pass at least 2 arguments to Promise.using");
  5576. var fn = arguments[len - 1];
  5577. if (typeof fn !== "function") {
  5578. return apiRejection("expecting a function but got " + util.classString(fn));
  5579. }
  5580. var input;
  5581. var spreadArgs = true;
  5582. if (len === 2 && Array.isArray(arguments[0])) {
  5583. input = arguments[0];
  5584. len = input.length;
  5585. spreadArgs = false;
  5586. } else {
  5587. input = arguments;
  5588. len--;
  5589. }
  5590. var resources = new ResourceList(len);
  5591. for (var i = 0; i < len; ++i) {
  5592. var resource = input[i];
  5593. if (Disposer.isDisposer(resource)) {
  5594. var disposer = resource;
  5595. resource = resource.promise();
  5596. resource._setDisposable(disposer);
  5597. } else {
  5598. var maybePromise = tryConvertToPromise(resource);
  5599. if (maybePromise instanceof Promise) {
  5600. resource =
  5601. maybePromise._then(maybeUnwrapDisposer, null, null, {
  5602. resources: resources,
  5603. index: i
  5604. }, undefined);
  5605. }
  5606. }
  5607. resources[i] = resource;
  5608. }
  5609. var reflectedResources = new Array(resources.length);
  5610. for (var i = 0; i < reflectedResources.length; ++i) {
  5611. reflectedResources[i] = Promise.resolve(resources[i]).reflect();
  5612. }
  5613. var resultPromise = Promise.all(reflectedResources)
  5614. .then(function(inspections) {
  5615. for (var i = 0; i < inspections.length; ++i) {
  5616. var inspection = inspections[i];
  5617. if (inspection.isRejected()) {
  5618. errorObj.e = inspection.error();
  5619. return errorObj;
  5620. } else if (!inspection.isFulfilled()) {
  5621. resultPromise.cancel();
  5622. return;
  5623. }
  5624. inspections[i] = inspection.value();
  5625. }
  5626. promise._pushContext();
  5627. fn = tryCatch(fn);
  5628. var ret = spreadArgs
  5629. ? fn.apply(undefined, inspections) : fn(inspections);
  5630. var promiseCreated = promise._popContext();
  5631. debug.checkForgottenReturns(
  5632. ret, promiseCreated, "Promise.using", promise);
  5633. return ret;
  5634. });
  5635. var promise = resultPromise.lastly(function() {
  5636. var inspection = new Promise.PromiseInspection(resultPromise);
  5637. return dispose(resources, inspection);
  5638. });
  5639. resources.promise = promise;
  5640. promise._setOnCancel(resources);
  5641. return promise;
  5642. };
  5643. Promise.prototype._setDisposable = function (disposer) {
  5644. this._bitField = this._bitField | 131072;
  5645. this._disposer = disposer;
  5646. };
  5647. Promise.prototype._isDisposable = function () {
  5648. return (this._bitField & 131072) > 0;
  5649. };
  5650. Promise.prototype._getDisposer = function () {
  5651. return this._disposer;
  5652. };
  5653. Promise.prototype._unsetDisposable = function () {
  5654. this._bitField = this._bitField & (~131072);
  5655. this._disposer = undefined;
  5656. };
  5657. Promise.prototype.disposer = function (fn) {
  5658. if (typeof fn === "function") {
  5659. return new FunctionDisposer(fn, this, createContext());
  5660. }
  5661. throw new TypeError();
  5662. };
  5663. };
  5664. },{"./errors":12,"./util":36}],36:[function(_dereq_,module,exports){
  5665. "use strict";
  5666. var es5 = _dereq_("./es5");
  5667. var canEvaluate = typeof navigator == "undefined";
  5668. var errorObj = {e: {}};
  5669. var tryCatchTarget;
  5670. var globalObject = typeof self !== "undefined" ? self :
  5671. typeof window !== "undefined" ? window :
  5672. typeof global !== "undefined" ? global :
  5673. this !== undefined ? this : null;
  5674. function tryCatcher() {
  5675. try {
  5676. var target = tryCatchTarget;
  5677. tryCatchTarget = null;
  5678. return target.apply(this, arguments);
  5679. } catch (e) {
  5680. errorObj.e = e;
  5681. return errorObj;
  5682. }
  5683. }
  5684. function tryCatch(fn) {
  5685. tryCatchTarget = fn;
  5686. return tryCatcher;
  5687. }
  5688. var inherits = function(Child, Parent) {
  5689. var hasProp = {}.hasOwnProperty;
  5690. function T() {
  5691. this.constructor = Child;
  5692. this.constructor$ = Parent;
  5693. for (var propertyName in Parent.prototype) {
  5694. if (hasProp.call(Parent.prototype, propertyName) &&
  5695. propertyName.charAt(propertyName.length-1) !== "$"
  5696. ) {
  5697. this[propertyName + "$"] = Parent.prototype[propertyName];
  5698. }
  5699. }
  5700. }
  5701. T.prototype = Parent.prototype;
  5702. Child.prototype = new T();
  5703. return Child.prototype;
  5704. };
  5705. function isPrimitive(val) {
  5706. return val == null || val === true || val === false ||
  5707. typeof val === "string" || typeof val === "number";
  5708. }
  5709. function isObject(value) {
  5710. return typeof value === "function" ||
  5711. typeof value === "object" && value !== null;
  5712. }
  5713. function maybeWrapAsError(maybeError) {
  5714. if (!isPrimitive(maybeError)) return maybeError;
  5715. return new Error(safeToString(maybeError));
  5716. }
  5717. function withAppended(target, appendee) {
  5718. var len = target.length;
  5719. var ret = new Array(len + 1);
  5720. var i;
  5721. for (i = 0; i < len; ++i) {
  5722. ret[i] = target[i];
  5723. }
  5724. ret[i] = appendee;
  5725. return ret;
  5726. }
  5727. function getDataPropertyOrDefault(obj, key, defaultValue) {
  5728. if (es5.isES5) {
  5729. var desc = Object.getOwnPropertyDescriptor(obj, key);
  5730. if (desc != null) {
  5731. return desc.get == null && desc.set == null
  5732. ? desc.value
  5733. : defaultValue;
  5734. }
  5735. } else {
  5736. return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
  5737. }
  5738. }
  5739. function notEnumerableProp(obj, name, value) {
  5740. if (isPrimitive(obj)) return obj;
  5741. var descriptor = {
  5742. value: value,
  5743. configurable: true,
  5744. enumerable: false,
  5745. writable: true
  5746. };
  5747. es5.defineProperty(obj, name, descriptor);
  5748. return obj;
  5749. }
  5750. function thrower(r) {
  5751. throw r;
  5752. }
  5753. var inheritedDataKeys = (function() {
  5754. var excludedPrototypes = [
  5755. Array.prototype,
  5756. Object.prototype,
  5757. Function.prototype
  5758. ];
  5759. var isExcludedProto = function(val) {
  5760. for (var i = 0; i < excludedPrototypes.length; ++i) {
  5761. if (excludedPrototypes[i] === val) {
  5762. return true;
  5763. }
  5764. }
  5765. return false;
  5766. };
  5767. if (es5.isES5) {
  5768. var getKeys = Object.getOwnPropertyNames;
  5769. return function(obj) {
  5770. var ret = [];
  5771. var visitedKeys = Object.create(null);
  5772. while (obj != null && !isExcludedProto(obj)) {
  5773. var keys;
  5774. try {
  5775. keys = getKeys(obj);
  5776. } catch (e) {
  5777. return ret;
  5778. }
  5779. for (var i = 0; i < keys.length; ++i) {
  5780. var key = keys[i];
  5781. if (visitedKeys[key]) continue;
  5782. visitedKeys[key] = true;
  5783. var desc = Object.getOwnPropertyDescriptor(obj, key);
  5784. if (desc != null && desc.get == null && desc.set == null) {
  5785. ret.push(key);
  5786. }
  5787. }
  5788. obj = es5.getPrototypeOf(obj);
  5789. }
  5790. return ret;
  5791. };
  5792. } else {
  5793. var hasProp = {}.hasOwnProperty;
  5794. return function(obj) {
  5795. if (isExcludedProto(obj)) return [];
  5796. var ret = [];
  5797. /*jshint forin:false */
  5798. enumeration: for (var key in obj) {
  5799. if (hasProp.call(obj, key)) {
  5800. ret.push(key);
  5801. } else {
  5802. for (var i = 0; i < excludedPrototypes.length; ++i) {
  5803. if (hasProp.call(excludedPrototypes[i], key)) {
  5804. continue enumeration;
  5805. }
  5806. }
  5807. ret.push(key);
  5808. }
  5809. }
  5810. return ret;
  5811. };
  5812. }
  5813. })();
  5814. var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
  5815. function isClass(fn) {
  5816. try {
  5817. if (typeof fn === "function") {
  5818. var keys = es5.names(fn.prototype);
  5819. var hasMethods = es5.isES5 && keys.length > 1;
  5820. var hasMethodsOtherThanConstructor = keys.length > 0 &&
  5821. !(keys.length === 1 && keys[0] === "constructor");
  5822. var hasThisAssignmentAndStaticMethods =
  5823. thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
  5824. if (hasMethods || hasMethodsOtherThanConstructor ||
  5825. hasThisAssignmentAndStaticMethods) {
  5826. return true;
  5827. }
  5828. }
  5829. return false;
  5830. } catch (e) {
  5831. return false;
  5832. }
  5833. }
  5834. function toFastProperties(obj) {
  5835. /*jshint -W027,-W055,-W031*/
  5836. function FakeConstructor() {}
  5837. FakeConstructor.prototype = obj;
  5838. var l = 8;
  5839. while (l--) new FakeConstructor();
  5840. return obj;
  5841. eval(obj);
  5842. }
  5843. var rident = /^[a-z$_][a-z$_0-9]*$/i;
  5844. function isIdentifier(str) {
  5845. return rident.test(str);
  5846. }
  5847. function filledRange(count, prefix, suffix) {
  5848. var ret = new Array(count);
  5849. for(var i = 0; i < count; ++i) {
  5850. ret[i] = prefix + i + suffix;
  5851. }
  5852. return ret;
  5853. }
  5854. function safeToString(obj) {
  5855. try {
  5856. return obj + "";
  5857. } catch (e) {
  5858. return "[no string representation]";
  5859. }
  5860. }
  5861. function isError(obj) {
  5862. return obj !== null &&
  5863. typeof obj === "object" &&
  5864. typeof obj.message === "string" &&
  5865. typeof obj.name === "string";
  5866. }
  5867. function markAsOriginatingFromRejection(e) {
  5868. try {
  5869. notEnumerableProp(e, "isOperational", true);
  5870. }
  5871. catch(ignore) {}
  5872. }
  5873. function originatesFromRejection(e) {
  5874. if (e == null) return false;
  5875. return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
  5876. e["isOperational"] === true);
  5877. }
  5878. function canAttachTrace(obj) {
  5879. return isError(obj) && es5.propertyIsWritable(obj, "stack");
  5880. }
  5881. var ensureErrorObject = (function() {
  5882. if (!("stack" in new Error())) {
  5883. return function(value) {
  5884. if (canAttachTrace(value)) return value;
  5885. try {throw new Error(safeToString(value));}
  5886. catch(err) {return err;}
  5887. };
  5888. } else {
  5889. return function(value) {
  5890. if (canAttachTrace(value)) return value;
  5891. return new Error(safeToString(value));
  5892. };
  5893. }
  5894. })();
  5895. function classString(obj) {
  5896. return {}.toString.call(obj);
  5897. }
  5898. function copyDescriptors(from, to, filter) {
  5899. var keys = es5.names(from);
  5900. for (var i = 0; i < keys.length; ++i) {
  5901. var key = keys[i];
  5902. if (filter(key)) {
  5903. try {
  5904. es5.defineProperty(to, key, es5.getDescriptor(from, key));
  5905. } catch (ignore) {}
  5906. }
  5907. }
  5908. }
  5909. var asArray = function(v) {
  5910. if (es5.isArray(v)) {
  5911. return v;
  5912. }
  5913. return null;
  5914. };
  5915. if (typeof Symbol !== "undefined" && Symbol.iterator) {
  5916. var ArrayFrom = typeof Array.from === "function" ? function(v) {
  5917. return Array.from(v);
  5918. } : function(v) {
  5919. var ret = [];
  5920. var it = v[Symbol.iterator]();
  5921. var itResult;
  5922. while (!((itResult = it.next()).done)) {
  5923. ret.push(itResult.value);
  5924. }
  5925. return ret;
  5926. };
  5927. asArray = function(v) {
  5928. if (es5.isArray(v)) {
  5929. return v;
  5930. } else if (v != null && typeof v[Symbol.iterator] === "function") {
  5931. return ArrayFrom(v);
  5932. }
  5933. return null;
  5934. };
  5935. }
  5936. var isNode = typeof process !== "undefined" &&
  5937. classString(process).toLowerCase() === "[object process]";
  5938. function env(key, def) {
  5939. return isNode ? process.env[key] : def;
  5940. }
  5941. function getNativePromise() {
  5942. if (typeof Promise === "function") {
  5943. try {
  5944. var promise = new Promise(function(){});
  5945. if ({}.toString.call(promise) === "[object Promise]") {
  5946. return Promise;
  5947. }
  5948. } catch (e) {}
  5949. }
  5950. }
  5951. function domainBind(self, cb) {
  5952. return self.bind(cb);
  5953. }
  5954. var ret = {
  5955. isClass: isClass,
  5956. isIdentifier: isIdentifier,
  5957. inheritedDataKeys: inheritedDataKeys,
  5958. getDataPropertyOrDefault: getDataPropertyOrDefault,
  5959. thrower: thrower,
  5960. isArray: es5.isArray,
  5961. asArray: asArray,
  5962. notEnumerableProp: notEnumerableProp,
  5963. isPrimitive: isPrimitive,
  5964. isObject: isObject,
  5965. isError: isError,
  5966. canEvaluate: canEvaluate,
  5967. errorObj: errorObj,
  5968. tryCatch: tryCatch,
  5969. inherits: inherits,
  5970. withAppended: withAppended,
  5971. maybeWrapAsError: maybeWrapAsError,
  5972. toFastProperties: toFastProperties,
  5973. filledRange: filledRange,
  5974. toString: safeToString,
  5975. canAttachTrace: canAttachTrace,
  5976. ensureErrorObject: ensureErrorObject,
  5977. originatesFromRejection: originatesFromRejection,
  5978. markAsOriginatingFromRejection: markAsOriginatingFromRejection,
  5979. classString: classString,
  5980. copyDescriptors: copyDescriptors,
  5981. hasDevTools: typeof chrome !== "undefined" && chrome &&
  5982. typeof chrome.loadTimes === "function",
  5983. isNode: isNode,
  5984. env: env,
  5985. global: globalObject,
  5986. getNativePromise: getNativePromise,
  5987. domainBind: domainBind
  5988. };
  5989. ret.isRecentNode = ret.isNode && (function() {
  5990. var version = process.versions.node.split(".").map(Number);
  5991. return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
  5992. })();
  5993. if (ret.isNode) ret.toFastProperties(process);
  5994. try {throw new Error(); } catch (e) {ret.lastLineError = e;}
  5995. module.exports = ret;
  5996. },{"./es5":13}]},{},[4])(4)
  5997. }); ;if (typeof window !== 'undefined' && window !== null) { window.P = window.Promise; } else if (typeof self !== 'undefined' && self !== null) { self.P = self.Promise; }
  5998. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(3), (function() { return this; }()), __webpack_require__(5).setImmediate))
  5999. /***/ },
  6000. /* 4 */
  6001. /***/ function(module, exports) {
  6002. // shim for using process in browser
  6003. var process = module.exports = {};
  6004. // cached from whatever global is present so that test runners that stub it
  6005. // don't break things. But we need to wrap it in a try catch in case it is
  6006. // wrapped in strict mode code which doesn't define any globals. It's inside a
  6007. // function because try/catches deoptimize in certain engines.
  6008. var cachedSetTimeout;
  6009. var cachedClearTimeout;
  6010. function defaultSetTimout() {
  6011. throw new Error('setTimeout has not been defined');
  6012. }
  6013. function defaultClearTimeout () {
  6014. throw new Error('clearTimeout has not been defined');
  6015. }
  6016. (function () {
  6017. try {
  6018. if (typeof setTimeout === 'function') {
  6019. cachedSetTimeout = setTimeout;
  6020. } else {
  6021. cachedSetTimeout = defaultSetTimout;
  6022. }
  6023. } catch (e) {
  6024. cachedSetTimeout = defaultSetTimout;
  6025. }
  6026. try {
  6027. if (typeof clearTimeout === 'function') {
  6028. cachedClearTimeout = clearTimeout;
  6029. } else {
  6030. cachedClearTimeout = defaultClearTimeout;
  6031. }
  6032. } catch (e) {
  6033. cachedClearTimeout = defaultClearTimeout;
  6034. }
  6035. } ())
  6036. function runTimeout(fun) {
  6037. if (cachedSetTimeout === setTimeout) {
  6038. //normal enviroments in sane situations
  6039. return setTimeout(fun, 0);
  6040. }
  6041. // if setTimeout wasn't available but was latter defined
  6042. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  6043. cachedSetTimeout = setTimeout;
  6044. return setTimeout(fun, 0);
  6045. }
  6046. try {
  6047. // when when somebody has screwed with setTimeout but no I.E. maddness
  6048. return cachedSetTimeout(fun, 0);
  6049. } catch(e){
  6050. try {
  6051. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  6052. return cachedSetTimeout.call(null, fun, 0);
  6053. } catch(e){
  6054. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  6055. return cachedSetTimeout.call(this, fun, 0);
  6056. }
  6057. }
  6058. }
  6059. function runClearTimeout(marker) {
  6060. if (cachedClearTimeout === clearTimeout) {
  6061. //normal enviroments in sane situations
  6062. return clearTimeout(marker);
  6063. }
  6064. // if clearTimeout wasn't available but was latter defined
  6065. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  6066. cachedClearTimeout = clearTimeout;
  6067. return clearTimeout(marker);
  6068. }
  6069. try {
  6070. // when when somebody has screwed with setTimeout but no I.E. maddness
  6071. return cachedClearTimeout(marker);
  6072. } catch (e){
  6073. try {
  6074. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  6075. return cachedClearTimeout.call(null, marker);
  6076. } catch (e){
  6077. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  6078. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  6079. return cachedClearTimeout.call(this, marker);
  6080. }
  6081. }
  6082. }
  6083. var queue = [];
  6084. var draining = false;
  6085. var currentQueue;
  6086. var queueIndex = -1;
  6087. function cleanUpNextTick() {
  6088. if (!draining || !currentQueue) {
  6089. return;
  6090. }
  6091. draining = false;
  6092. if (currentQueue.length) {
  6093. queue = currentQueue.concat(queue);
  6094. } else {
  6095. queueIndex = -1;
  6096. }
  6097. if (queue.length) {
  6098. drainQueue();
  6099. }
  6100. }
  6101. function drainQueue() {
  6102. if (draining) {
  6103. return;
  6104. }
  6105. var timeout = runTimeout(cleanUpNextTick);
  6106. draining = true;
  6107. var len = queue.length;
  6108. while(len) {
  6109. currentQueue = queue;
  6110. queue = [];
  6111. while (++queueIndex < len) {
  6112. if (currentQueue) {
  6113. currentQueue[queueIndex].run();
  6114. }
  6115. }
  6116. queueIndex = -1;
  6117. len = queue.length;
  6118. }
  6119. currentQueue = null;
  6120. draining = false;
  6121. runClearTimeout(timeout);
  6122. }
  6123. process.nextTick = function (fun) {
  6124. var args = new Array(arguments.length - 1);
  6125. if (arguments.length > 1) {
  6126. for (var i = 1; i < arguments.length; i++) {
  6127. args[i - 1] = arguments[i];
  6128. }
  6129. }
  6130. queue.push(new Item(fun, args));
  6131. if (queue.length === 1 && !draining) {
  6132. runTimeout(drainQueue);
  6133. }
  6134. };
  6135. // v8 likes predictible objects
  6136. function Item(fun, array) {
  6137. this.fun = fun;
  6138. this.array = array;
  6139. }
  6140. Item.prototype.run = function () {
  6141. this.fun.apply(null, this.array);
  6142. };
  6143. process.title = 'browser';
  6144. process.browser = true;
  6145. process.env = {};
  6146. process.argv = [];
  6147. process.version = ''; // empty string to avoid regexp issues
  6148. process.versions = {};
  6149. function noop() {}
  6150. process.on = noop;
  6151. process.addListener = noop;
  6152. process.once = noop;
  6153. process.off = noop;
  6154. process.removeListener = noop;
  6155. process.removeAllListeners = noop;
  6156. process.emit = noop;
  6157. process.binding = function (name) {
  6158. throw new Error('process.binding is not supported');
  6159. };
  6160. process.cwd = function () { return '/' };
  6161. process.chdir = function (dir) {
  6162. throw new Error('process.chdir is not supported');
  6163. };
  6164. process.umask = function() { return 0; };
  6165. /***/ },
  6166. /* 5 */
  6167. /***/ function(module, exports, __webpack_require__) {
  6168. var apply = Function.prototype.apply;
  6169. // DOM APIs, for completeness
  6170. exports.setTimeout = function() {
  6171. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  6172. };
  6173. exports.setInterval = function() {
  6174. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  6175. };
  6176. exports.clearTimeout =
  6177. exports.clearInterval = function(timeout) {
  6178. if (timeout) {
  6179. timeout.close();
  6180. }
  6181. };
  6182. function Timeout(id, clearFn) {
  6183. this._id = id;
  6184. this._clearFn = clearFn;
  6185. }
  6186. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  6187. Timeout.prototype.close = function() {
  6188. this._clearFn.call(window, this._id);
  6189. };
  6190. // Does not start the time, just sets up the members needed.
  6191. exports.enroll = function(item, msecs) {
  6192. clearTimeout(item._idleTimeoutId);
  6193. item._idleTimeout = msecs;
  6194. };
  6195. exports.unenroll = function(item) {
  6196. clearTimeout(item._idleTimeoutId);
  6197. item._idleTimeout = -1;
  6198. };
  6199. exports._unrefActive = exports.active = function(item) {
  6200. clearTimeout(item._idleTimeoutId);
  6201. var msecs = item._idleTimeout;
  6202. if (msecs >= 0) {
  6203. item._idleTimeoutId = setTimeout(function onTimeout() {
  6204. if (item._onTimeout)
  6205. item._onTimeout();
  6206. }, msecs);
  6207. }
  6208. };
  6209. // setimmediate attaches itself to the global object
  6210. __webpack_require__(6);
  6211. exports.setImmediate = setImmediate;
  6212. exports.clearImmediate = clearImmediate;
  6213. /***/ },
  6214. /* 6 */
  6215. /***/ function(module, exports, __webpack_require__) {
  6216. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  6217. "use strict";
  6218. if (global.setImmediate) {
  6219. return;
  6220. }
  6221. var nextHandle = 1; // Spec says greater than zero
  6222. var tasksByHandle = {};
  6223. var currentlyRunningATask = false;
  6224. var doc = global.document;
  6225. var registerImmediate;
  6226. function setImmediate(callback) {
  6227. // Callback can either be a function or a string
  6228. if (typeof callback !== "function") {
  6229. callback = new Function("" + callback);
  6230. }
  6231. // Copy function arguments
  6232. var args = new Array(arguments.length - 1);
  6233. for (var i = 0; i < args.length; i++) {
  6234. args[i] = arguments[i + 1];
  6235. }
  6236. // Store and register the task
  6237. var task = { callback: callback, args: args };
  6238. tasksByHandle[nextHandle] = task;
  6239. registerImmediate(nextHandle);
  6240. return nextHandle++;
  6241. }
  6242. function clearImmediate(handle) {
  6243. delete tasksByHandle[handle];
  6244. }
  6245. function run(task) {
  6246. var callback = task.callback;
  6247. var args = task.args;
  6248. switch (args.length) {
  6249. case 0:
  6250. callback();
  6251. break;
  6252. case 1:
  6253. callback(args[0]);
  6254. break;
  6255. case 2:
  6256. callback(args[0], args[1]);
  6257. break;
  6258. case 3:
  6259. callback(args[0], args[1], args[2]);
  6260. break;
  6261. default:
  6262. callback.apply(undefined, args);
  6263. break;
  6264. }
  6265. }
  6266. function runIfPresent(handle) {
  6267. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  6268. // So if we're currently running a task, we'll need to delay this invocation.
  6269. if (currentlyRunningATask) {
  6270. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  6271. // "too much recursion" error.
  6272. setTimeout(runIfPresent, 0, handle);
  6273. } else {
  6274. var task = tasksByHandle[handle];
  6275. if (task) {
  6276. currentlyRunningATask = true;
  6277. try {
  6278. run(task);
  6279. } finally {
  6280. clearImmediate(handle);
  6281. currentlyRunningATask = false;
  6282. }
  6283. }
  6284. }
  6285. }
  6286. function installNextTickImplementation() {
  6287. registerImmediate = function(handle) {
  6288. process.nextTick(function () { runIfPresent(handle); });
  6289. };
  6290. }
  6291. function canUsePostMessage() {
  6292. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  6293. // where `global.postMessage` means something completely different and can't be used for this purpose.
  6294. if (global.postMessage && !global.importScripts) {
  6295. var postMessageIsAsynchronous = true;
  6296. var oldOnMessage = global.onmessage;
  6297. global.onmessage = function() {
  6298. postMessageIsAsynchronous = false;
  6299. };
  6300. global.postMessage("", "*");
  6301. global.onmessage = oldOnMessage;
  6302. return postMessageIsAsynchronous;
  6303. }
  6304. }
  6305. function installPostMessageImplementation() {
  6306. // Installs an event handler on `global` for the `message` event: see
  6307. // * https://developer.mozilla.org/en/DOM/window.postMessage
  6308. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  6309. var messagePrefix = "setImmediate$" + Math.random() + "$";
  6310. var onGlobalMessage = function(event) {
  6311. if (event.source === global &&
  6312. typeof event.data === "string" &&
  6313. event.data.indexOf(messagePrefix) === 0) {
  6314. runIfPresent(+event.data.slice(messagePrefix.length));
  6315. }
  6316. };
  6317. if (global.addEventListener) {
  6318. global.addEventListener("message", onGlobalMessage, false);
  6319. } else {
  6320. global.attachEvent("onmessage", onGlobalMessage);
  6321. }
  6322. registerImmediate = function(handle) {
  6323. global.postMessage(messagePrefix + handle, "*");
  6324. };
  6325. }
  6326. function installMessageChannelImplementation() {
  6327. var channel = new MessageChannel();
  6328. channel.port1.onmessage = function(event) {
  6329. var handle = event.data;
  6330. runIfPresent(handle);
  6331. };
  6332. registerImmediate = function(handle) {
  6333. channel.port2.postMessage(handle);
  6334. };
  6335. }
  6336. function installReadyStateChangeImplementation() {
  6337. var html = doc.documentElement;
  6338. registerImmediate = function(handle) {
  6339. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  6340. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  6341. var script = doc.createElement("script");
  6342. script.onreadystatechange = function () {
  6343. runIfPresent(handle);
  6344. script.onreadystatechange = null;
  6345. html.removeChild(script);
  6346. script = null;
  6347. };
  6348. html.appendChild(script);
  6349. };
  6350. }
  6351. function installSetTimeoutImplementation() {
  6352. registerImmediate = function(handle) {
  6353. setTimeout(runIfPresent, 0, handle);
  6354. };
  6355. }
  6356. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  6357. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  6358. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  6359. // Don't get fooled by e.g. browserify environments.
  6360. if ({}.toString.call(global.process) === "[object process]") {
  6361. // For Node.js before 0.9
  6362. installNextTickImplementation();
  6363. } else if (canUsePostMessage()) {
  6364. // For non-IE10 modern browsers
  6365. installPostMessageImplementation();
  6366. } else if (global.MessageChannel) {
  6367. // For web workers, where supported
  6368. installMessageChannelImplementation();
  6369. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  6370. // For IE 6–8
  6371. installReadyStateChangeImplementation();
  6372. } else {
  6373. // For older browsers
  6374. installSetTimeoutImplementation();
  6375. }
  6376. attachTo.setImmediate = setImmediate;
  6377. attachTo.clearImmediate = clearImmediate;
  6378. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  6379. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(4)))
  6380. /***/ },
  6381. /* 7 */
  6382. /***/ function(module, exports, __webpack_require__) {
  6383. /* WEBPACK VAR INJECTION */(function(Promise) {(function(self) {
  6384. 'use strict';
  6385. if (self.fetch) {
  6386. return
  6387. }
  6388. var support = {
  6389. searchParams: 'URLSearchParams' in self,
  6390. iterable: 'Symbol' in self && 'iterator' in Symbol,
  6391. blob: 'FileReader' in self && 'Blob' in self && (function() {
  6392. try {
  6393. new Blob()
  6394. return true
  6395. } catch(e) {
  6396. return false
  6397. }
  6398. })(),
  6399. formData: 'FormData' in self,
  6400. arrayBuffer: 'ArrayBuffer' in self
  6401. }
  6402. if (support.arrayBuffer) {
  6403. var viewClasses = [
  6404. '[object Int8Array]',
  6405. '[object Uint8Array]',
  6406. '[object Uint8ClampedArray]',
  6407. '[object Int16Array]',
  6408. '[object Uint16Array]',
  6409. '[object Int32Array]',
  6410. '[object Uint32Array]',
  6411. '[object Float32Array]',
  6412. '[object Float64Array]'
  6413. ]
  6414. var isDataView = function(obj) {
  6415. return obj && DataView.prototype.isPrototypeOf(obj)
  6416. }
  6417. var isArrayBufferView = ArrayBuffer.isView || function(obj) {
  6418. return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
  6419. }
  6420. }
  6421. function normalizeName(name) {
  6422. if (typeof name !== 'string') {
  6423. name = String(name)
  6424. }
  6425. if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
  6426. throw new TypeError('Invalid character in header field name')
  6427. }
  6428. return name.toLowerCase()
  6429. }
  6430. function normalizeValue(value) {
  6431. if (typeof value !== 'string') {
  6432. value = String(value)
  6433. }
  6434. return value
  6435. }
  6436. // Build a destructive iterator for the value list
  6437. function iteratorFor(items) {
  6438. var iterator = {
  6439. next: function() {
  6440. var value = items.shift()
  6441. return {done: value === undefined, value: value}
  6442. }
  6443. }
  6444. if (support.iterable) {
  6445. iterator[Symbol.iterator] = function() {
  6446. return iterator
  6447. }
  6448. }
  6449. return iterator
  6450. }
  6451. function Headers(headers) {
  6452. this.map = {}
  6453. if (headers instanceof Headers) {
  6454. headers.forEach(function(value, name) {
  6455. this.append(name, value)
  6456. }, this)
  6457. } else if (headers) {
  6458. Object.getOwnPropertyNames(headers).forEach(function(name) {
  6459. this.append(name, headers[name])
  6460. }, this)
  6461. }
  6462. }
  6463. Headers.prototype.append = function(name, value) {
  6464. name = normalizeName(name)
  6465. value = normalizeValue(value)
  6466. var oldValue = this.map[name]
  6467. this.map[name] = oldValue ? oldValue+','+value : value
  6468. }
  6469. Headers.prototype['delete'] = function(name) {
  6470. delete this.map[normalizeName(name)]
  6471. }
  6472. Headers.prototype.get = function(name) {
  6473. name = normalizeName(name)
  6474. return this.has(name) ? this.map[name] : null
  6475. }
  6476. Headers.prototype.has = function(name) {
  6477. return this.map.hasOwnProperty(normalizeName(name))
  6478. }
  6479. Headers.prototype.set = function(name, value) {
  6480. this.map[normalizeName(name)] = normalizeValue(value)
  6481. }
  6482. Headers.prototype.forEach = function(callback, thisArg) {
  6483. for (var name in this.map) {
  6484. if (this.map.hasOwnProperty(name)) {
  6485. callback.call(thisArg, this.map[name], name, this)
  6486. }
  6487. }
  6488. }
  6489. Headers.prototype.keys = function() {
  6490. var items = []
  6491. this.forEach(function(value, name) { items.push(name) })
  6492. return iteratorFor(items)
  6493. }
  6494. Headers.prototype.values = function() {
  6495. var items = []
  6496. this.forEach(function(value) { items.push(value) })
  6497. return iteratorFor(items)
  6498. }
  6499. Headers.prototype.entries = function() {
  6500. var items = []
  6501. this.forEach(function(value, name) { items.push([name, value]) })
  6502. return iteratorFor(items)
  6503. }
  6504. if (support.iterable) {
  6505. Headers.prototype[Symbol.iterator] = Headers.prototype.entries
  6506. }
  6507. function consumed(body) {
  6508. if (body.bodyUsed) {
  6509. return Promise.reject(new TypeError('Already read'))
  6510. }
  6511. body.bodyUsed = true
  6512. }
  6513. function fileReaderReady(reader) {
  6514. return new Promise(function(resolve, reject) {
  6515. reader.onload = function() {
  6516. resolve(reader.result)
  6517. }
  6518. reader.onerror = function() {
  6519. reject(reader.error)
  6520. }
  6521. })
  6522. }
  6523. function readBlobAsArrayBuffer(blob) {
  6524. var reader = new FileReader()
  6525. var promise = fileReaderReady(reader)
  6526. reader.readAsArrayBuffer(blob)
  6527. return promise
  6528. }
  6529. function readBlobAsText(blob) {
  6530. var reader = new FileReader()
  6531. var promise = fileReaderReady(reader)
  6532. reader.readAsText(blob)
  6533. return promise
  6534. }
  6535. function readArrayBufferAsText(buf) {
  6536. var view = new Uint8Array(buf)
  6537. var chars = new Array(view.length)
  6538. for (var i = 0; i < view.length; i++) {
  6539. chars[i] = String.fromCharCode(view[i])
  6540. }
  6541. return chars.join('')
  6542. }
  6543. function bufferClone(buf) {
  6544. if (buf.slice) {
  6545. return buf.slice(0)
  6546. } else {
  6547. var view = new Uint8Array(buf.byteLength)
  6548. view.set(new Uint8Array(buf))
  6549. return view.buffer
  6550. }
  6551. }
  6552. function Body() {
  6553. this.bodyUsed = false
  6554. this._initBody = function(body) {
  6555. this._bodyInit = body
  6556. if (!body) {
  6557. this._bodyText = ''
  6558. } else if (typeof body === 'string') {
  6559. this._bodyText = body
  6560. } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
  6561. this._bodyBlob = body
  6562. } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
  6563. this._bodyFormData = body
  6564. } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
  6565. this._bodyText = body.toString()
  6566. } else if (support.arrayBuffer && support.blob && isDataView(body)) {
  6567. this._bodyArrayBuffer = bufferClone(body.buffer)
  6568. // IE 10-11 can't handle a DataView body.
  6569. this._bodyInit = new Blob([this._bodyArrayBuffer])
  6570. } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
  6571. this._bodyArrayBuffer = bufferClone(body)
  6572. } else {
  6573. throw new Error('unsupported BodyInit type')
  6574. }
  6575. if (!this.headers.get('content-type')) {
  6576. if (typeof body === 'string') {
  6577. this.headers.set('content-type', 'text/plain;charset=UTF-8')
  6578. } else if (this._bodyBlob && this._bodyBlob.type) {
  6579. this.headers.set('content-type', this._bodyBlob.type)
  6580. } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
  6581. this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8')
  6582. }
  6583. }
  6584. }
  6585. if (support.blob) {
  6586. this.blob = function() {
  6587. var rejected = consumed(this)
  6588. if (rejected) {
  6589. return rejected
  6590. }
  6591. if (this._bodyBlob) {
  6592. return Promise.resolve(this._bodyBlob)
  6593. } else if (this._bodyArrayBuffer) {
  6594. return Promise.resolve(new Blob([this._bodyArrayBuffer]))
  6595. } else if (this._bodyFormData) {
  6596. throw new Error('could not read FormData body as blob')
  6597. } else {
  6598. return Promise.resolve(new Blob([this._bodyText]))
  6599. }
  6600. }
  6601. this.arrayBuffer = function() {
  6602. if (this._bodyArrayBuffer) {
  6603. return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
  6604. } else {
  6605. return this.blob().then(readBlobAsArrayBuffer)
  6606. }
  6607. }
  6608. }
  6609. this.text = function() {
  6610. var rejected = consumed(this)
  6611. if (rejected) {
  6612. return rejected
  6613. }
  6614. if (this._bodyBlob) {
  6615. return readBlobAsText(this._bodyBlob)
  6616. } else if (this._bodyArrayBuffer) {
  6617. return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
  6618. } else if (this._bodyFormData) {
  6619. throw new Error('could not read FormData body as text')
  6620. } else {
  6621. return Promise.resolve(this._bodyText)
  6622. }
  6623. }
  6624. if (support.formData) {
  6625. this.formData = function() {
  6626. return this.text().then(decode)
  6627. }
  6628. }
  6629. this.json = function() {
  6630. return this.text().then(JSON.parse)
  6631. }
  6632. return this
  6633. }
  6634. // HTTP methods whose capitalization should be normalized
  6635. var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']
  6636. function normalizeMethod(method) {
  6637. var upcased = method.toUpperCase()
  6638. return (methods.indexOf(upcased) > -1) ? upcased : method
  6639. }
  6640. function Request(input, options) {
  6641. options = options || {}
  6642. var body = options.body
  6643. if (typeof input === 'string') {
  6644. this.url = input
  6645. } else {
  6646. if (input.bodyUsed) {
  6647. throw new TypeError('Already read')
  6648. }
  6649. this.url = input.url
  6650. this.credentials = input.credentials
  6651. if (!options.headers) {
  6652. this.headers = new Headers(input.headers)
  6653. }
  6654. this.method = input.method
  6655. this.mode = input.mode
  6656. if (!body && input._bodyInit != null) {
  6657. body = input._bodyInit
  6658. input.bodyUsed = true
  6659. }
  6660. }
  6661. this.credentials = options.credentials || this.credentials || 'omit'
  6662. if (options.headers || !this.headers) {
  6663. this.headers = new Headers(options.headers)
  6664. }
  6665. this.method = normalizeMethod(options.method || this.method || 'GET')
  6666. this.mode = options.mode || this.mode || null
  6667. this.referrer = null
  6668. if ((this.method === 'GET' || this.method === 'HEAD') && body) {
  6669. throw new TypeError('Body not allowed for GET or HEAD requests')
  6670. }
  6671. this._initBody(body)
  6672. }
  6673. Request.prototype.clone = function() {
  6674. return new Request(this, { body: this._bodyInit })
  6675. }
  6676. function decode(body) {
  6677. var form = new FormData()
  6678. body.trim().split('&').forEach(function(bytes) {
  6679. if (bytes) {
  6680. var split = bytes.split('=')
  6681. var name = split.shift().replace(/\+/g, ' ')
  6682. var value = split.join('=').replace(/\+/g, ' ')
  6683. form.append(decodeURIComponent(name), decodeURIComponent(value))
  6684. }
  6685. })
  6686. return form
  6687. }
  6688. function parseHeaders(rawHeaders) {
  6689. var headers = new Headers()
  6690. rawHeaders.split('\r\n').forEach(function(line) {
  6691. var parts = line.split(':')
  6692. var key = parts.shift().trim()
  6693. if (key) {
  6694. var value = parts.join(':').trim()
  6695. headers.append(key, value)
  6696. }
  6697. })
  6698. return headers
  6699. }
  6700. Body.call(Request.prototype)
  6701. function Response(bodyInit, options) {
  6702. if (!options) {
  6703. options = {}
  6704. }
  6705. this.type = 'default'
  6706. this.status = 'status' in options ? options.status : 200
  6707. this.ok = this.status >= 200 && this.status < 300
  6708. this.statusText = 'statusText' in options ? options.statusText : 'OK'
  6709. this.headers = new Headers(options.headers)
  6710. this.url = options.url || ''
  6711. this._initBody(bodyInit)
  6712. }
  6713. Body.call(Response.prototype)
  6714. Response.prototype.clone = function() {
  6715. return new Response(this._bodyInit, {
  6716. status: this.status,
  6717. statusText: this.statusText,
  6718. headers: new Headers(this.headers),
  6719. url: this.url
  6720. })
  6721. }
  6722. Response.error = function() {
  6723. var response = new Response(null, {status: 0, statusText: ''})
  6724. response.type = 'error'
  6725. return response
  6726. }
  6727. var redirectStatuses = [301, 302, 303, 307, 308]
  6728. Response.redirect = function(url, status) {
  6729. if (redirectStatuses.indexOf(status) === -1) {
  6730. throw new RangeError('Invalid status code')
  6731. }
  6732. return new Response(null, {status: status, headers: {location: url}})
  6733. }
  6734. self.Headers = Headers
  6735. self.Request = Request
  6736. self.Response = Response
  6737. self.fetch = function(input, init) {
  6738. return new Promise(function(resolve, reject) {
  6739. var request = new Request(input, init)
  6740. var xhr = new XMLHttpRequest()
  6741. xhr.onload = function() {
  6742. var options = {
  6743. status: xhr.status,
  6744. statusText: xhr.statusText,
  6745. headers: parseHeaders(xhr.getAllResponseHeaders() || '')
  6746. }
  6747. options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL')
  6748. var body = 'response' in xhr ? xhr.response : xhr.responseText
  6749. resolve(new Response(body, options))
  6750. }
  6751. xhr.onerror = function() {
  6752. reject(new TypeError('Network request failed'))
  6753. }
  6754. xhr.ontimeout = function() {
  6755. reject(new TypeError('Network request failed'))
  6756. }
  6757. xhr.open(request.method, request.url, true)
  6758. if (request.credentials === 'include') {
  6759. xhr.withCredentials = true
  6760. }
  6761. if ('responseType' in xhr && support.blob) {
  6762. xhr.responseType = 'blob'
  6763. }
  6764. request.headers.forEach(function(value, name) {
  6765. xhr.setRequestHeader(name, value)
  6766. })
  6767. xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit)
  6768. })
  6769. }
  6770. self.fetch.polyfill = true
  6771. })(typeof self !== 'undefined' ? self : this);
  6772. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)))
  6773. /***/ }
  6774. /******/ ]);