12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221 |
- /**
- @license
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- **/
- /**
- @license
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- **/
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
- (factory((global.rxjs = global.rxjs || {})));
- }(this, (function (exports) { 'use strict';
-
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
-
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
-
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- /* global Reflect, Promise */
-
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-
- function __extends(d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- }
-
- var __assign = Object.assign || function __assign(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- return t;
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function __values(o) {
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
- if (m) return m.call(o);
- return {
- next: function () {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- }
-
- function __read(o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
- }
-
-
-
- function __await(v) {
- return this instanceof __await ? (this.v = v, this) : new __await(v);
- }
-
- function isFunction(x) {
- return typeof x === 'function';
- }
-
- var _enable_super_gross_mode_that_will_cause_bad_things = false;
- var config = {
- Promise: undefined,
- set useDeprecatedSynchronousErrorHandling(value) {
- if (value) {
- var error = new Error();
- console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
- }
- else if (_enable_super_gross_mode_that_will_cause_bad_things) {
- console.log('RxJS: Back to a better error behavior. Thank you. <3');
- }
- _enable_super_gross_mode_that_will_cause_bad_things = value;
- },
- get useDeprecatedSynchronousErrorHandling() {
- return _enable_super_gross_mode_that_will_cause_bad_things;
- },
- };
-
- function hostReportError(err) {
- setTimeout(function () { throw err; });
- }
-
- var empty = {
- closed: true,
- next: function (value) { },
- error: function (err) {
- if (config.useDeprecatedSynchronousErrorHandling) {
- throw err;
- }
- else {
- hostReportError(err);
- }
- },
- complete: function () { }
- };
-
- var isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
-
- function isObject(x) {
- return x != null && typeof x === 'object';
- }
-
- var errorObject = { e: {} };
-
- var tryCatchTarget;
- function tryCatcher() {
- try {
- return tryCatchTarget.apply(this, arguments);
- }
- catch (e) {
- errorObject.e = e;
- return errorObject;
- }
- }
- function tryCatch(fn) {
- tryCatchTarget = fn;
- return tryCatcher;
- }
-
- function UnsubscriptionErrorImpl(errors) {
- Error.call(this);
- this.message = errors ?
- errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
- this.name = 'UnsubscriptionError';
- this.errors = errors;
- return this;
- }
- UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
- var UnsubscriptionError = UnsubscriptionErrorImpl;
-
- var Subscription = (function () {
- function Subscription(unsubscribe) {
- this.closed = false;
- this._parent = null;
- this._parents = null;
- this._subscriptions = null;
- if (unsubscribe) {
- this._unsubscribe = unsubscribe;
- }
- }
- Subscription.prototype.unsubscribe = function () {
- var hasErrors = false;
- var errors;
- if (this.closed) {
- return;
- }
- var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
- this.closed = true;
- this._parent = null;
- this._parents = null;
- this._subscriptions = null;
- var index = -1;
- var len = _parents ? _parents.length : 0;
- while (_parent) {
- _parent.remove(this);
- _parent = ++index < len && _parents[index] || null;
- }
- if (isFunction(_unsubscribe)) {
- var trial = tryCatch(_unsubscribe).call(this);
- if (trial === errorObject) {
- hasErrors = true;
- errors = errors || (errorObject.e instanceof UnsubscriptionError ?
- flattenUnsubscriptionErrors(errorObject.e.errors) : [errorObject.e]);
- }
- }
- if (isArray(_subscriptions)) {
- index = -1;
- len = _subscriptions.length;
- while (++index < len) {
- var sub = _subscriptions[index];
- if (isObject(sub)) {
- var trial = tryCatch(sub.unsubscribe).call(sub);
- if (trial === errorObject) {
- hasErrors = true;
- errors = errors || [];
- var err = errorObject.e;
- if (err instanceof UnsubscriptionError) {
- errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
- }
- else {
- errors.push(err);
- }
- }
- }
- }
- }
- if (hasErrors) {
- throw new UnsubscriptionError(errors);
- }
- };
- Subscription.prototype.add = function (teardown) {
- if (!teardown || (teardown === Subscription.EMPTY)) {
- return Subscription.EMPTY;
- }
- if (teardown === this) {
- return this;
- }
- var subscription = teardown;
- switch (typeof teardown) {
- case 'function':
- subscription = new Subscription(teardown);
- case 'object':
- if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
- return subscription;
- }
- else if (this.closed) {
- subscription.unsubscribe();
- return subscription;
- }
- else if (typeof subscription._addParent !== 'function') {
- var tmp = subscription;
- subscription = new Subscription();
- subscription._subscriptions = [tmp];
- }
- break;
- default:
- throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
- }
- var subscriptions = this._subscriptions || (this._subscriptions = []);
- subscriptions.push(subscription);
- subscription._addParent(this);
- return subscription;
- };
- Subscription.prototype.remove = function (subscription) {
- var subscriptions = this._subscriptions;
- if (subscriptions) {
- var subscriptionIndex = subscriptions.indexOf(subscription);
- if (subscriptionIndex !== -1) {
- subscriptions.splice(subscriptionIndex, 1);
- }
- }
- };
- Subscription.prototype._addParent = function (parent) {
- var _a = this, _parent = _a._parent, _parents = _a._parents;
- if (!_parent || _parent === parent) {
- this._parent = parent;
- }
- else if (!_parents) {
- this._parents = [parent];
- }
- else if (_parents.indexOf(parent) === -1) {
- _parents.push(parent);
- }
- };
- Subscription.EMPTY = (function (empty) {
- empty.closed = true;
- return empty;
- }(new Subscription()));
- return Subscription;
- }());
- function flattenUnsubscriptionErrors(errors) {
- return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
- }
-
- var rxSubscriber = typeof Symbol === 'function'
- ? Symbol('rxSubscriber')
- : '@@rxSubscriber_' + Math.random();
-
- var Subscriber = (function (_super) {
- __extends(Subscriber, _super);
- function Subscriber(destinationOrNext, error, complete) {
- var _this = _super.call(this) || this;
- _this.syncErrorValue = null;
- _this.syncErrorThrown = false;
- _this.syncErrorThrowable = false;
- _this.isStopped = false;
- _this._parentSubscription = null;
- switch (arguments.length) {
- case 0:
- _this.destination = empty;
- break;
- case 1:
- if (!destinationOrNext) {
- _this.destination = empty;
- break;
- }
- if (typeof destinationOrNext === 'object') {
- if (destinationOrNext instanceof Subscriber) {
- _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
- _this.destination = destinationOrNext;
- destinationOrNext.add(_this);
- }
- else {
- _this.syncErrorThrowable = true;
- _this.destination = new SafeSubscriber(_this, destinationOrNext);
- }
- break;
- }
- default:
- _this.syncErrorThrowable = true;
- _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
- break;
- }
- return _this;
- }
- Subscriber.prototype[rxSubscriber] = function () { return this; };
- Subscriber.create = function (next, error, complete) {
- var subscriber = new Subscriber(next, error, complete);
- subscriber.syncErrorThrowable = false;
- return subscriber;
- };
- Subscriber.prototype.next = function (value) {
- if (!this.isStopped) {
- this._next(value);
- }
- };
- Subscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- this.isStopped = true;
- this._error(err);
- }
- };
- Subscriber.prototype.complete = function () {
- if (!this.isStopped) {
- this.isStopped = true;
- this._complete();
- }
- };
- Subscriber.prototype.unsubscribe = function () {
- if (this.closed) {
- return;
- }
- this.isStopped = true;
- _super.prototype.unsubscribe.call(this);
- };
- Subscriber.prototype._next = function (value) {
- this.destination.next(value);
- };
- Subscriber.prototype._error = function (err) {
- this.destination.error(err);
- this.unsubscribe();
- };
- Subscriber.prototype._complete = function () {
- this.destination.complete();
- this.unsubscribe();
- };
- Subscriber.prototype._unsubscribeAndRecycle = function () {
- var _a = this, _parent = _a._parent, _parents = _a._parents;
- this._parent = null;
- this._parents = null;
- this.unsubscribe();
- this.closed = false;
- this.isStopped = false;
- this._parent = _parent;
- this._parents = _parents;
- this._parentSubscription = null;
- return this;
- };
- return Subscriber;
- }(Subscription));
- var SafeSubscriber = (function (_super) {
- __extends(SafeSubscriber, _super);
- function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
- var _this = _super.call(this) || this;
- _this._parentSubscriber = _parentSubscriber;
- var next;
- var context = _this;
- if (isFunction(observerOrNext)) {
- next = observerOrNext;
- }
- else if (observerOrNext) {
- next = observerOrNext.next;
- error = observerOrNext.error;
- complete = observerOrNext.complete;
- if (observerOrNext !== empty) {
- context = Object.create(observerOrNext);
- if (isFunction(context.unsubscribe)) {
- _this.add(context.unsubscribe.bind(context));
- }
- context.unsubscribe = _this.unsubscribe.bind(_this);
- }
- }
- _this._context = context;
- _this._next = next;
- _this._error = error;
- _this._complete = complete;
- return _this;
- }
- SafeSubscriber.prototype.next = function (value) {
- if (!this.isStopped && this._next) {
- var _parentSubscriber = this._parentSubscriber;
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
- this.__tryOrUnsub(this._next, value);
- }
- else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
- this.unsubscribe();
- }
- }
- };
- SafeSubscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- var _parentSubscriber = this._parentSubscriber;
- var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
- if (this._error) {
- if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
- this.__tryOrUnsub(this._error, err);
- this.unsubscribe();
- }
- else {
- this.__tryOrSetError(_parentSubscriber, this._error, err);
- this.unsubscribe();
- }
- }
- else if (!_parentSubscriber.syncErrorThrowable) {
- this.unsubscribe();
- if (useDeprecatedSynchronousErrorHandling) {
- throw err;
- }
- hostReportError(err);
- }
- else {
- if (useDeprecatedSynchronousErrorHandling) {
- _parentSubscriber.syncErrorValue = err;
- _parentSubscriber.syncErrorThrown = true;
- }
- else {
- hostReportError(err);
- }
- this.unsubscribe();
- }
- }
- };
- SafeSubscriber.prototype.complete = function () {
- var _this = this;
- if (!this.isStopped) {
- var _parentSubscriber = this._parentSubscriber;
- if (this._complete) {
- var wrappedComplete = function () { return _this._complete.call(_this._context); };
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
- this.__tryOrUnsub(wrappedComplete);
- this.unsubscribe();
- }
- else {
- this.__tryOrSetError(_parentSubscriber, wrappedComplete);
- this.unsubscribe();
- }
- }
- else {
- this.unsubscribe();
- }
- }
- };
- SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
- try {
- fn.call(this._context, value);
- }
- catch (err) {
- this.unsubscribe();
- if (config.useDeprecatedSynchronousErrorHandling) {
- throw err;
- }
- else {
- hostReportError(err);
- }
- }
- };
- SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
- if (!config.useDeprecatedSynchronousErrorHandling) {
- throw new Error('bad call');
- }
- try {
- fn.call(this._context, value);
- }
- catch (err) {
- if (config.useDeprecatedSynchronousErrorHandling) {
- parent.syncErrorValue = err;
- parent.syncErrorThrown = true;
- return true;
- }
- else {
- hostReportError(err);
- return true;
- }
- }
- return false;
- };
- SafeSubscriber.prototype._unsubscribe = function () {
- var _parentSubscriber = this._parentSubscriber;
- this._context = null;
- this._parentSubscriber = null;
- _parentSubscriber.unsubscribe();
- };
- return SafeSubscriber;
- }(Subscriber));
-
- function canReportError(observer) {
- while (observer) {
- var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
- if (closed_1 || isStopped) {
- return false;
- }
- else if (destination && destination instanceof Subscriber) {
- observer = destination;
- }
- else {
- observer = null;
- }
- }
- return true;
- }
-
- function toSubscriber(nextOrObserver, error, complete) {
- if (nextOrObserver) {
- if (nextOrObserver instanceof Subscriber) {
- return nextOrObserver;
- }
- if (nextOrObserver[rxSubscriber]) {
- return nextOrObserver[rxSubscriber]();
- }
- }
- if (!nextOrObserver && !error && !complete) {
- return new Subscriber(empty);
- }
- return new Subscriber(nextOrObserver, error, complete);
- }
-
- var observable = typeof Symbol === 'function' && Symbol.observable || '@@observable';
-
- function noop() { }
-
- function pipe() {
- var fns = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- fns[_i] = arguments[_i];
- }
- return pipeFromArray(fns);
- }
- function pipeFromArray(fns) {
- if (!fns) {
- return noop;
- }
- if (fns.length === 1) {
- return fns[0];
- }
- return function piped(input) {
- return fns.reduce(function (prev, fn) { return fn(prev); }, input);
- };
- }
-
- var Observable = (function () {
- function Observable(subscribe) {
- this._isScalar = false;
- if (subscribe) {
- this._subscribe = subscribe;
- }
- }
- Observable.prototype.lift = function (operator) {
- var observable$$1 = new Observable();
- observable$$1.source = this;
- observable$$1.operator = operator;
- return observable$$1;
- };
- Observable.prototype.subscribe = function (observerOrNext, error, complete) {
- var operator = this.operator;
- var sink = toSubscriber(observerOrNext, error, complete);
- if (operator) {
- operator.call(sink, this.source);
- }
- else {
- sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
- this._subscribe(sink) :
- this._trySubscribe(sink));
- }
- if (config.useDeprecatedSynchronousErrorHandling) {
- if (sink.syncErrorThrowable) {
- sink.syncErrorThrowable = false;
- if (sink.syncErrorThrown) {
- throw sink.syncErrorValue;
- }
- }
- }
- return sink;
- };
- Observable.prototype._trySubscribe = function (sink) {
- try {
- return this._subscribe(sink);
- }
- catch (err) {
- if (config.useDeprecatedSynchronousErrorHandling) {
- sink.syncErrorThrown = true;
- sink.syncErrorValue = err;
- }
- if (canReportError(sink)) {
- sink.error(err);
- }
- else {
- console.warn(err);
- }
- }
- };
- Observable.prototype.forEach = function (next, promiseCtor) {
- var _this = this;
- promiseCtor = getPromiseCtor(promiseCtor);
- return new promiseCtor(function (resolve, reject) {
- var subscription;
- subscription = _this.subscribe(function (value) {
- try {
- next(value);
- }
- catch (err) {
- reject(err);
- if (subscription) {
- subscription.unsubscribe();
- }
- }
- }, reject, resolve);
- });
- };
- Observable.prototype._subscribe = function (subscriber) {
- var source = this.source;
- return source && source.subscribe(subscriber);
- };
- Observable.prototype[observable] = function () {
- return this;
- };
- Observable.prototype.pipe = function () {
- var operations = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- operations[_i] = arguments[_i];
- }
- if (operations.length === 0) {
- return this;
- }
- return pipeFromArray(operations)(this);
- };
- Observable.prototype.toPromise = function (promiseCtor) {
- var _this = this;
- promiseCtor = getPromiseCtor(promiseCtor);
- return new promiseCtor(function (resolve, reject) {
- var value;
- _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
- });
- };
- Observable.create = function (subscribe) {
- return new Observable(subscribe);
- };
- return Observable;
- }());
- function getPromiseCtor(promiseCtor) {
- if (!promiseCtor) {
- promiseCtor = config.Promise || Promise;
- }
- if (!promiseCtor) {
- throw new Error('no Promise impl found');
- }
- return promiseCtor;
- }
-
- function ObjectUnsubscribedErrorImpl() {
- Error.call(this);
- this.message = 'object unsubscribed';
- this.name = 'ObjectUnsubscribedError';
- return this;
- }
- ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
- var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
-
- var SubjectSubscription = (function (_super) {
- __extends(SubjectSubscription, _super);
- function SubjectSubscription(subject, subscriber) {
- var _this = _super.call(this) || this;
- _this.subject = subject;
- _this.subscriber = subscriber;
- _this.closed = false;
- return _this;
- }
- SubjectSubscription.prototype.unsubscribe = function () {
- if (this.closed) {
- return;
- }
- this.closed = true;
- var subject = this.subject;
- var observers = subject.observers;
- this.subject = null;
- if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
- return;
- }
- var subscriberIndex = observers.indexOf(this.subscriber);
- if (subscriberIndex !== -1) {
- observers.splice(subscriberIndex, 1);
- }
- };
- return SubjectSubscription;
- }(Subscription));
-
- var SubjectSubscriber = (function (_super) {
- __extends(SubjectSubscriber, _super);
- function SubjectSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- return _this;
- }
- return SubjectSubscriber;
- }(Subscriber));
- var Subject = (function (_super) {
- __extends(Subject, _super);
- function Subject() {
- var _this = _super.call(this) || this;
- _this.observers = [];
- _this.closed = false;
- _this.isStopped = false;
- _this.hasError = false;
- _this.thrownError = null;
- return _this;
- }
- Subject.prototype[rxSubscriber] = function () {
- return new SubjectSubscriber(this);
- };
- Subject.prototype.lift = function (operator) {
- var subject = new AnonymousSubject(this, this);
- subject.operator = operator;
- return subject;
- };
- Subject.prototype.next = function (value) {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- if (!this.isStopped) {
- var observers = this.observers;
- var len = observers.length;
- var copy = observers.slice();
- for (var i = 0; i < len; i++) {
- copy[i].next(value);
- }
- }
- };
- Subject.prototype.error = function (err) {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- this.hasError = true;
- this.thrownError = err;
- this.isStopped = true;
- var observers = this.observers;
- var len = observers.length;
- var copy = observers.slice();
- for (var i = 0; i < len; i++) {
- copy[i].error(err);
- }
- this.observers.length = 0;
- };
- Subject.prototype.complete = function () {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- this.isStopped = true;
- var observers = this.observers;
- var len = observers.length;
- var copy = observers.slice();
- for (var i = 0; i < len; i++) {
- copy[i].complete();
- }
- this.observers.length = 0;
- };
- Subject.prototype.unsubscribe = function () {
- this.isStopped = true;
- this.closed = true;
- this.observers = null;
- };
- Subject.prototype._trySubscribe = function (subscriber) {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- else {
- return _super.prototype._trySubscribe.call(this, subscriber);
- }
- };
- Subject.prototype._subscribe = function (subscriber) {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- else if (this.hasError) {
- subscriber.error(this.thrownError);
- return Subscription.EMPTY;
- }
- else if (this.isStopped) {
- subscriber.complete();
- return Subscription.EMPTY;
- }
- else {
- this.observers.push(subscriber);
- return new SubjectSubscription(this, subscriber);
- }
- };
- Subject.prototype.asObservable = function () {
- var observable = new Observable();
- observable.source = this;
- return observable;
- };
- Subject.create = function (destination, source) {
- return new AnonymousSubject(destination, source);
- };
- return Subject;
- }(Observable));
- var AnonymousSubject = (function (_super) {
- __extends(AnonymousSubject, _super);
- function AnonymousSubject(destination, source) {
- var _this = _super.call(this) || this;
- _this.destination = destination;
- _this.source = source;
- return _this;
- }
- AnonymousSubject.prototype.next = function (value) {
- var destination = this.destination;
- if (destination && destination.next) {
- destination.next(value);
- }
- };
- AnonymousSubject.prototype.error = function (err) {
- var destination = this.destination;
- if (destination && destination.error) {
- this.destination.error(err);
- }
- };
- AnonymousSubject.prototype.complete = function () {
- var destination = this.destination;
- if (destination && destination.complete) {
- this.destination.complete();
- }
- };
- AnonymousSubject.prototype._subscribe = function (subscriber) {
- var source = this.source;
- if (source) {
- return this.source.subscribe(subscriber);
- }
- else {
- return Subscription.EMPTY;
- }
- };
- return AnonymousSubject;
- }(Subject));
-
- function refCount() {
- return function refCountOperatorFunction(source) {
- return source.lift(new RefCountOperator$1(source));
- };
- }
- var RefCountOperator$1 = (function () {
- function RefCountOperator(connectable) {
- this.connectable = connectable;
- }
- RefCountOperator.prototype.call = function (subscriber, source) {
- var connectable = this.connectable;
- connectable._refCount++;
- var refCounter = new RefCountSubscriber$1(subscriber, connectable);
- var subscription = source.subscribe(refCounter);
- if (!refCounter.closed) {
- refCounter.connection = connectable.connect();
- }
- return subscription;
- };
- return RefCountOperator;
- }());
- var RefCountSubscriber$1 = (function (_super) {
- __extends(RefCountSubscriber, _super);
- function RefCountSubscriber(destination, connectable) {
- var _this = _super.call(this, destination) || this;
- _this.connectable = connectable;
- return _this;
- }
- RefCountSubscriber.prototype._unsubscribe = function () {
- var connectable = this.connectable;
- if (!connectable) {
- this.connection = null;
- return;
- }
- this.connectable = null;
- var refCount = connectable._refCount;
- if (refCount <= 0) {
- this.connection = null;
- return;
- }
- connectable._refCount = refCount - 1;
- if (refCount > 1) {
- this.connection = null;
- return;
- }
- var connection = this.connection;
- var sharedConnection = connectable._connection;
- this.connection = null;
- if (sharedConnection && (!connection || sharedConnection === connection)) {
- sharedConnection.unsubscribe();
- }
- };
- return RefCountSubscriber;
- }(Subscriber));
-
- var ConnectableObservable = (function (_super) {
- __extends(ConnectableObservable, _super);
- function ConnectableObservable(source, subjectFactory) {
- var _this = _super.call(this) || this;
- _this.source = source;
- _this.subjectFactory = subjectFactory;
- _this._refCount = 0;
- _this._isComplete = false;
- return _this;
- }
- ConnectableObservable.prototype._subscribe = function (subscriber) {
- return this.getSubject().subscribe(subscriber);
- };
- ConnectableObservable.prototype.getSubject = function () {
- var subject = this._subject;
- if (!subject || subject.isStopped) {
- this._subject = this.subjectFactory();
- }
- return this._subject;
- };
- ConnectableObservable.prototype.connect = function () {
- var connection = this._connection;
- if (!connection) {
- this._isComplete = false;
- connection = this._connection = new Subscription();
- connection.add(this.source
- .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
- if (connection.closed) {
- this._connection = null;
- connection = Subscription.EMPTY;
- }
- else {
- this._connection = connection;
- }
- }
- return connection;
- };
- ConnectableObservable.prototype.refCount = function () {
- return refCount()(this);
- };
- return ConnectableObservable;
- }(Observable));
- var connectableProto = ConnectableObservable.prototype;
- var connectableObservableDescriptor = {
- operator: { value: null },
- _refCount: { value: 0, writable: true },
- _subject: { value: null, writable: true },
- _connection: { value: null, writable: true },
- _subscribe: { value: connectableProto._subscribe },
- _isComplete: { value: connectableProto._isComplete, writable: true },
- getSubject: { value: connectableProto.getSubject },
- connect: { value: connectableProto.connect },
- refCount: { value: connectableProto.refCount }
- };
- var ConnectableSubscriber = (function (_super) {
- __extends(ConnectableSubscriber, _super);
- function ConnectableSubscriber(destination, connectable) {
- var _this = _super.call(this, destination) || this;
- _this.connectable = connectable;
- return _this;
- }
- ConnectableSubscriber.prototype._error = function (err) {
- this._unsubscribe();
- _super.prototype._error.call(this, err);
- };
- ConnectableSubscriber.prototype._complete = function () {
- this.connectable._isComplete = true;
- this._unsubscribe();
- _super.prototype._complete.call(this);
- };
- ConnectableSubscriber.prototype._unsubscribe = function () {
- var connectable = this.connectable;
- if (connectable) {
- this.connectable = null;
- var connection = connectable._connection;
- connectable._refCount = 0;
- connectable._subject = null;
- connectable._connection = null;
- if (connection) {
- connection.unsubscribe();
- }
- }
- };
- return ConnectableSubscriber;
- }(SubjectSubscriber));
- var RefCountSubscriber = (function (_super) {
- __extends(RefCountSubscriber, _super);
- function RefCountSubscriber(destination, connectable) {
- var _this = _super.call(this, destination) || this;
- _this.connectable = connectable;
- return _this;
- }
- RefCountSubscriber.prototype._unsubscribe = function () {
- var connectable = this.connectable;
- if (!connectable) {
- this.connection = null;
- return;
- }
- this.connectable = null;
- var refCount$$1 = connectable._refCount;
- if (refCount$$1 <= 0) {
- this.connection = null;
- return;
- }
- connectable._refCount = refCount$$1 - 1;
- if (refCount$$1 > 1) {
- this.connection = null;
- return;
- }
- var connection = this.connection;
- var sharedConnection = connectable._connection;
- this.connection = null;
- if (sharedConnection && (!connection || sharedConnection === connection)) {
- sharedConnection.unsubscribe();
- }
- };
- return RefCountSubscriber;
- }(Subscriber));
-
- function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
- return function (source) {
- return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
- };
- }
- var GroupByOperator = (function () {
- function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
- this.keySelector = keySelector;
- this.elementSelector = elementSelector;
- this.durationSelector = durationSelector;
- this.subjectSelector = subjectSelector;
- }
- GroupByOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
- };
- return GroupByOperator;
- }());
- var GroupBySubscriber = (function (_super) {
- __extends(GroupBySubscriber, _super);
- function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
- var _this = _super.call(this, destination) || this;
- _this.keySelector = keySelector;
- _this.elementSelector = elementSelector;
- _this.durationSelector = durationSelector;
- _this.subjectSelector = subjectSelector;
- _this.groups = null;
- _this.attemptedToUnsubscribe = false;
- _this.count = 0;
- return _this;
- }
- GroupBySubscriber.prototype._next = function (value) {
- var key;
- try {
- key = this.keySelector(value);
- }
- catch (err) {
- this.error(err);
- return;
- }
- this._group(value, key);
- };
- GroupBySubscriber.prototype._group = function (value, key) {
- var groups = this.groups;
- if (!groups) {
- groups = this.groups = new Map();
- }
- var group = groups.get(key);
- var element;
- if (this.elementSelector) {
- try {
- element = this.elementSelector(value);
- }
- catch (err) {
- this.error(err);
- }
- }
- else {
- element = value;
- }
- if (!group) {
- group = (this.subjectSelector ? this.subjectSelector() : new Subject());
- groups.set(key, group);
- var groupedObservable = new GroupedObservable(key, group, this);
- this.destination.next(groupedObservable);
- if (this.durationSelector) {
- var duration = void 0;
- try {
- duration = this.durationSelector(new GroupedObservable(key, group));
- }
- catch (err) {
- this.error(err);
- return;
- }
- this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
- }
- }
- if (!group.closed) {
- group.next(element);
- }
- };
- GroupBySubscriber.prototype._error = function (err) {
- var groups = this.groups;
- if (groups) {
- groups.forEach(function (group, key) {
- group.error(err);
- });
- groups.clear();
- }
- this.destination.error(err);
- };
- GroupBySubscriber.prototype._complete = function () {
- var groups = this.groups;
- if (groups) {
- groups.forEach(function (group, key) {
- group.complete();
- });
- groups.clear();
- }
- this.destination.complete();
- };
- GroupBySubscriber.prototype.removeGroup = function (key) {
- this.groups.delete(key);
- };
- GroupBySubscriber.prototype.unsubscribe = function () {
- if (!this.closed) {
- this.attemptedToUnsubscribe = true;
- if (this.count === 0) {
- _super.prototype.unsubscribe.call(this);
- }
- }
- };
- return GroupBySubscriber;
- }(Subscriber));
- var GroupDurationSubscriber = (function (_super) {
- __extends(GroupDurationSubscriber, _super);
- function GroupDurationSubscriber(key, group, parent) {
- var _this = _super.call(this, group) || this;
- _this.key = key;
- _this.group = group;
- _this.parent = parent;
- return _this;
- }
- GroupDurationSubscriber.prototype._next = function (value) {
- this.complete();
- };
- GroupDurationSubscriber.prototype._unsubscribe = function () {
- var _a = this, parent = _a.parent, key = _a.key;
- this.key = this.parent = null;
- if (parent) {
- parent.removeGroup(key);
- }
- };
- return GroupDurationSubscriber;
- }(Subscriber));
- var GroupedObservable = (function (_super) {
- __extends(GroupedObservable, _super);
- function GroupedObservable(key, groupSubject, refCountSubscription) {
- var _this = _super.call(this) || this;
- _this.key = key;
- _this.groupSubject = groupSubject;
- _this.refCountSubscription = refCountSubscription;
- return _this;
- }
- GroupedObservable.prototype._subscribe = function (subscriber) {
- var subscription = new Subscription();
- var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
- if (refCountSubscription && !refCountSubscription.closed) {
- subscription.add(new InnerRefCountSubscription(refCountSubscription));
- }
- subscription.add(groupSubject.subscribe(subscriber));
- return subscription;
- };
- return GroupedObservable;
- }(Observable));
- var InnerRefCountSubscription = (function (_super) {
- __extends(InnerRefCountSubscription, _super);
- function InnerRefCountSubscription(parent) {
- var _this = _super.call(this) || this;
- _this.parent = parent;
- parent.count++;
- return _this;
- }
- InnerRefCountSubscription.prototype.unsubscribe = function () {
- var parent = this.parent;
- if (!parent.closed && !this.closed) {
- _super.prototype.unsubscribe.call(this);
- parent.count -= 1;
- if (parent.count === 0 && parent.attemptedToUnsubscribe) {
- parent.unsubscribe();
- }
- }
- };
- return InnerRefCountSubscription;
- }(Subscription));
-
- var BehaviorSubject = (function (_super) {
- __extends(BehaviorSubject, _super);
- function BehaviorSubject(_value) {
- var _this = _super.call(this) || this;
- _this._value = _value;
- return _this;
- }
- Object.defineProperty(BehaviorSubject.prototype, "value", {
- get: function () {
- return this.getValue();
- },
- enumerable: true,
- configurable: true
- });
- BehaviorSubject.prototype._subscribe = function (subscriber) {
- var subscription = _super.prototype._subscribe.call(this, subscriber);
- if (subscription && !subscription.closed) {
- subscriber.next(this._value);
- }
- return subscription;
- };
- BehaviorSubject.prototype.getValue = function () {
- if (this.hasError) {
- throw this.thrownError;
- }
- else if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- else {
- return this._value;
- }
- };
- BehaviorSubject.prototype.next = function (value) {
- _super.prototype.next.call(this, this._value = value);
- };
- return BehaviorSubject;
- }(Subject));
-
- var Action = (function (_super) {
- __extends(Action, _super);
- function Action(scheduler, work) {
- return _super.call(this) || this;
- }
- Action.prototype.schedule = function (state, delay) {
- if (delay === void 0) { delay = 0; }
- return this;
- };
- return Action;
- }(Subscription));
-
- var AsyncAction = (function (_super) {
- __extends(AsyncAction, _super);
- function AsyncAction(scheduler, work) {
- var _this = _super.call(this, scheduler, work) || this;
- _this.scheduler = scheduler;
- _this.work = work;
- _this.pending = false;
- return _this;
- }
- AsyncAction.prototype.schedule = function (state, delay) {
- if (delay === void 0) { delay = 0; }
- if (this.closed) {
- return this;
- }
- this.state = state;
- var id = this.id;
- var scheduler = this.scheduler;
- if (id != null) {
- this.id = this.recycleAsyncId(scheduler, id, delay);
- }
- this.pending = true;
- this.delay = delay;
- this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
- return this;
- };
- AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- return setInterval(scheduler.flush.bind(scheduler, this), delay);
- };
- AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if (delay !== null && this.delay === delay && this.pending === false) {
- return id;
- }
- clearInterval(id);
- };
- AsyncAction.prototype.execute = function (state, delay) {
- if (this.closed) {
- return new Error('executing a cancelled action');
- }
- this.pending = false;
- var error = this._execute(state, delay);
- if (error) {
- return error;
- }
- else if (this.pending === false && this.id != null) {
- this.id = this.recycleAsyncId(this.scheduler, this.id, null);
- }
- };
- AsyncAction.prototype._execute = function (state, delay) {
- var errored = false;
- var errorValue = undefined;
- try {
- this.work(state);
- }
- catch (e) {
- errored = true;
- errorValue = !!e && e || new Error(e);
- }
- if (errored) {
- this.unsubscribe();
- return errorValue;
- }
- };
- AsyncAction.prototype._unsubscribe = function () {
- var id = this.id;
- var scheduler = this.scheduler;
- var actions = scheduler.actions;
- var index = actions.indexOf(this);
- this.work = null;
- this.state = null;
- this.pending = false;
- this.scheduler = null;
- if (index !== -1) {
- actions.splice(index, 1);
- }
- if (id != null) {
- this.id = this.recycleAsyncId(scheduler, id, null);
- }
- this.delay = null;
- };
- return AsyncAction;
- }(Action));
-
- var QueueAction = (function (_super) {
- __extends(QueueAction, _super);
- function QueueAction(scheduler, work) {
- var _this = _super.call(this, scheduler, work) || this;
- _this.scheduler = scheduler;
- _this.work = work;
- return _this;
- }
- QueueAction.prototype.schedule = function (state, delay) {
- if (delay === void 0) { delay = 0; }
- if (delay > 0) {
- return _super.prototype.schedule.call(this, state, delay);
- }
- this.delay = delay;
- this.state = state;
- this.scheduler.flush(this);
- return this;
- };
- QueueAction.prototype.execute = function (state, delay) {
- return (delay > 0 || this.closed) ?
- _super.prototype.execute.call(this, state, delay) :
- this._execute(state, delay);
- };
- QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
- return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
- }
- return scheduler.flush(this);
- };
- return QueueAction;
- }(AsyncAction));
-
- var Scheduler = (function () {
- function Scheduler(SchedulerAction, now) {
- if (now === void 0) { now = Scheduler.now; }
- this.SchedulerAction = SchedulerAction;
- this.now = now;
- }
- Scheduler.prototype.schedule = function (work, delay, state) {
- if (delay === void 0) { delay = 0; }
- return new this.SchedulerAction(this, work).schedule(state, delay);
- };
- Scheduler.now = function () { return Date.now(); };
- return Scheduler;
- }());
-
- var AsyncScheduler = (function (_super) {
- __extends(AsyncScheduler, _super);
- function AsyncScheduler(SchedulerAction, now) {
- if (now === void 0) { now = Scheduler.now; }
- var _this = _super.call(this, SchedulerAction, function () {
- if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
- return AsyncScheduler.delegate.now();
- }
- else {
- return now();
- }
- }) || this;
- _this.actions = [];
- _this.active = false;
- _this.scheduled = undefined;
- return _this;
- }
- AsyncScheduler.prototype.schedule = function (work, delay, state) {
- if (delay === void 0) { delay = 0; }
- if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
- return AsyncScheduler.delegate.schedule(work, delay, state);
- }
- else {
- return _super.prototype.schedule.call(this, work, delay, state);
- }
- };
- AsyncScheduler.prototype.flush = function (action) {
- var actions = this.actions;
- if (this.active) {
- actions.push(action);
- return;
- }
- var error;
- this.active = true;
- do {
- if (error = action.execute(action.state, action.delay)) {
- break;
- }
- } while (action = actions.shift());
- this.active = false;
- if (error) {
- while (action = actions.shift()) {
- action.unsubscribe();
- }
- throw error;
- }
- };
- return AsyncScheduler;
- }(Scheduler));
-
- var QueueScheduler = (function (_super) {
- __extends(QueueScheduler, _super);
- function QueueScheduler() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- return QueueScheduler;
- }(AsyncScheduler));
-
- var queue = new QueueScheduler(QueueAction);
-
- var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
- function empty$1(scheduler) {
- return scheduler ? emptyScheduled(scheduler) : EMPTY;
- }
- function emptyScheduled(scheduler) {
- return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
- }
-
- function isScheduler(value) {
- return value && typeof value.schedule === 'function';
- }
-
- var subscribeToArray = function (array) { return function (subscriber) {
- for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
- subscriber.next(array[i]);
- }
- if (!subscriber.closed) {
- subscriber.complete();
- }
- }; };
-
- function fromArray(input, scheduler) {
- if (!scheduler) {
- return new Observable(subscribeToArray(input));
- }
- else {
- return new Observable(function (subscriber) {
- var sub = new Subscription();
- var i = 0;
- sub.add(scheduler.schedule(function () {
- if (i === input.length) {
- subscriber.complete();
- return;
- }
- subscriber.next(input[i++]);
- if (!subscriber.closed) {
- sub.add(this.schedule());
- }
- }));
- return sub;
- });
- }
- }
-
- function scalar(value) {
- var result = new Observable(function (subscriber) {
- subscriber.next(value);
- subscriber.complete();
- });
- result._isScalar = true;
- result.value = value;
- return result;
- }
-
- function of() {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var scheduler = args[args.length - 1];
- if (isScheduler(scheduler)) {
- args.pop();
- }
- else {
- scheduler = undefined;
- }
- switch (args.length) {
- case 0:
- return empty$1(scheduler);
- case 1:
- return scheduler ? fromArray(args, scheduler) : scalar(args[0]);
- default:
- return fromArray(args, scheduler);
- }
- }
-
- function throwError(error, scheduler) {
- if (!scheduler) {
- return new Observable(function (subscriber) { return subscriber.error(error); });
- }
- else {
- return new Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
- }
- }
- function dispatch(_a) {
- var error = _a.error, subscriber = _a.subscriber;
- subscriber.error(error);
- }
-
- var Notification = (function () {
- function Notification(kind, value, error) {
- this.kind = kind;
- this.value = value;
- this.error = error;
- this.hasValue = kind === 'N';
- }
- Notification.prototype.observe = function (observer) {
- switch (this.kind) {
- case 'N':
- return observer.next && observer.next(this.value);
- case 'E':
- return observer.error && observer.error(this.error);
- case 'C':
- return observer.complete && observer.complete();
- }
- };
- Notification.prototype.do = function (next, error, complete) {
- var kind = this.kind;
- switch (kind) {
- case 'N':
- return next && next(this.value);
- case 'E':
- return error && error(this.error);
- case 'C':
- return complete && complete();
- }
- };
- Notification.prototype.accept = function (nextOrObserver, error, complete) {
- if (nextOrObserver && typeof nextOrObserver.next === 'function') {
- return this.observe(nextOrObserver);
- }
- else {
- return this.do(nextOrObserver, error, complete);
- }
- };
- Notification.prototype.toObservable = function () {
- var kind = this.kind;
- switch (kind) {
- case 'N':
- return of(this.value);
- case 'E':
- return throwError(this.error);
- case 'C':
- return empty$1();
- }
- throw new Error('unexpected notification kind value');
- };
- Notification.createNext = function (value) {
- if (typeof value !== 'undefined') {
- return new Notification('N', value);
- }
- return Notification.undefinedValueNotification;
- };
- Notification.createError = function (err) {
- return new Notification('E', undefined, err);
- };
- Notification.createComplete = function () {
- return Notification.completeNotification;
- };
- Notification.completeNotification = new Notification('C');
- Notification.undefinedValueNotification = new Notification('N', undefined);
- return Notification;
- }());
-
- function observeOn(scheduler, delay) {
- if (delay === void 0) { delay = 0; }
- return function observeOnOperatorFunction(source) {
- return source.lift(new ObserveOnOperator(scheduler, delay));
- };
- }
- var ObserveOnOperator = (function () {
- function ObserveOnOperator(scheduler, delay) {
- if (delay === void 0) { delay = 0; }
- this.scheduler = scheduler;
- this.delay = delay;
- }
- ObserveOnOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
- };
- return ObserveOnOperator;
- }());
- var ObserveOnSubscriber = (function (_super) {
- __extends(ObserveOnSubscriber, _super);
- function ObserveOnSubscriber(destination, scheduler, delay) {
- if (delay === void 0) { delay = 0; }
- var _this = _super.call(this, destination) || this;
- _this.scheduler = scheduler;
- _this.delay = delay;
- return _this;
- }
- ObserveOnSubscriber.dispatch = function (arg) {
- var notification = arg.notification, destination = arg.destination;
- notification.observe(destination);
- this.unsubscribe();
- };
- ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
- var destination = this.destination;
- destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
- };
- ObserveOnSubscriber.prototype._next = function (value) {
- this.scheduleMessage(Notification.createNext(value));
- };
- ObserveOnSubscriber.prototype._error = function (err) {
- this.scheduleMessage(Notification.createError(err));
- this.unsubscribe();
- };
- ObserveOnSubscriber.prototype._complete = function () {
- this.scheduleMessage(Notification.createComplete());
- this.unsubscribe();
- };
- return ObserveOnSubscriber;
- }(Subscriber));
- var ObserveOnMessage = (function () {
- function ObserveOnMessage(notification, destination) {
- this.notification = notification;
- this.destination = destination;
- }
- return ObserveOnMessage;
- }());
-
- var ReplaySubject = (function (_super) {
- __extends(ReplaySubject, _super);
- function ReplaySubject(bufferSize, windowTime, scheduler) {
- if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
- if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
- var _this = _super.call(this) || this;
- _this.scheduler = scheduler;
- _this._events = [];
- _this._infiniteTimeWindow = false;
- _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
- _this._windowTime = windowTime < 1 ? 1 : windowTime;
- if (windowTime === Number.POSITIVE_INFINITY) {
- _this._infiniteTimeWindow = true;
- _this.next = _this.nextInfiniteTimeWindow;
- }
- else {
- _this.next = _this.nextTimeWindow;
- }
- return _this;
- }
- ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
- var _events = this._events;
- _events.push(value);
- if (_events.length > this._bufferSize) {
- _events.shift();
- }
- _super.prototype.next.call(this, value);
- };
- ReplaySubject.prototype.nextTimeWindow = function (value) {
- this._events.push(new ReplayEvent(this._getNow(), value));
- this._trimBufferThenGetEvents();
- _super.prototype.next.call(this, value);
- };
- ReplaySubject.prototype._subscribe = function (subscriber) {
- var _infiniteTimeWindow = this._infiniteTimeWindow;
- var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
- var scheduler = this.scheduler;
- var len = _events.length;
- var subscription;
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- else if (this.isStopped || this.hasError) {
- subscription = Subscription.EMPTY;
- }
- else {
- this.observers.push(subscriber);
- subscription = new SubjectSubscription(this, subscriber);
- }
- if (scheduler) {
- subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
- }
- if (_infiniteTimeWindow) {
- for (var i = 0; i < len && !subscriber.closed; i++) {
- subscriber.next(_events[i]);
- }
- }
- else {
- for (var i = 0; i < len && !subscriber.closed; i++) {
- subscriber.next(_events[i].value);
- }
- }
- if (this.hasError) {
- subscriber.error(this.thrownError);
- }
- else if (this.isStopped) {
- subscriber.complete();
- }
- return subscription;
- };
- ReplaySubject.prototype._getNow = function () {
- return (this.scheduler || queue).now();
- };
- ReplaySubject.prototype._trimBufferThenGetEvents = function () {
- var now = this._getNow();
- var _bufferSize = this._bufferSize;
- var _windowTime = this._windowTime;
- var _events = this._events;
- var eventsCount = _events.length;
- var spliceCount = 0;
- while (spliceCount < eventsCount) {
- if ((now - _events[spliceCount].time) < _windowTime) {
- break;
- }
- spliceCount++;
- }
- if (eventsCount > _bufferSize) {
- spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
- }
- if (spliceCount > 0) {
- _events.splice(0, spliceCount);
- }
- return _events;
- };
- return ReplaySubject;
- }(Subject));
- var ReplayEvent = (function () {
- function ReplayEvent(time, value) {
- this.time = time;
- this.value = value;
- }
- return ReplayEvent;
- }());
-
- var AsyncSubject = (function (_super) {
- __extends(AsyncSubject, _super);
- function AsyncSubject() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.value = null;
- _this.hasNext = false;
- _this.hasCompleted = false;
- return _this;
- }
- AsyncSubject.prototype._subscribe = function (subscriber) {
- if (this.hasError) {
- subscriber.error(this.thrownError);
- return Subscription.EMPTY;
- }
- else if (this.hasCompleted && this.hasNext) {
- subscriber.next(this.value);
- subscriber.complete();
- return Subscription.EMPTY;
- }
- return _super.prototype._subscribe.call(this, subscriber);
- };
- AsyncSubject.prototype.next = function (value) {
- if (!this.hasCompleted) {
- this.value = value;
- this.hasNext = true;
- }
- };
- AsyncSubject.prototype.error = function (error) {
- if (!this.hasCompleted) {
- _super.prototype.error.call(this, error);
- }
- };
- AsyncSubject.prototype.complete = function () {
- this.hasCompleted = true;
- if (this.hasNext) {
- _super.prototype.next.call(this, this.value);
- }
- _super.prototype.complete.call(this);
- };
- return AsyncSubject;
- }(Subject));
-
- var nextHandle = 1;
- var tasksByHandle = {};
- function runIfPresent(handle) {
- var cb = tasksByHandle[handle];
- if (cb) {
- cb();
- }
- }
- var Immediate = {
- setImmediate: function (cb) {
- var handle = nextHandle++;
- tasksByHandle[handle] = cb;
- Promise.resolve().then(function () { return runIfPresent(handle); });
- return handle;
- },
- clearImmediate: function (handle) {
- delete tasksByHandle[handle];
- },
- };
-
- var AsapAction = (function (_super) {
- __extends(AsapAction, _super);
- function AsapAction(scheduler, work) {
- var _this = _super.call(this, scheduler, work) || this;
- _this.scheduler = scheduler;
- _this.work = work;
- return _this;
- }
- AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if (delay !== null && delay > 0) {
- return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
- }
- scheduler.actions.push(this);
- return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
- };
- AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
- return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
- }
- if (scheduler.actions.length === 0) {
- Immediate.clearImmediate(id);
- scheduler.scheduled = undefined;
- }
- return undefined;
- };
- return AsapAction;
- }(AsyncAction));
-
- var AsapScheduler = (function (_super) {
- __extends(AsapScheduler, _super);
- function AsapScheduler() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AsapScheduler.prototype.flush = function (action) {
- this.active = true;
- this.scheduled = undefined;
- var actions = this.actions;
- var error;
- var index = -1;
- var count = actions.length;
- action = action || actions.shift();
- do {
- if (error = action.execute(action.state, action.delay)) {
- break;
- }
- } while (++index < count && (action = actions.shift()));
- this.active = false;
- if (error) {
- while (++index < count && (action = actions.shift())) {
- action.unsubscribe();
- }
- throw error;
- }
- };
- return AsapScheduler;
- }(AsyncScheduler));
-
- var asap = new AsapScheduler(AsapAction);
-
- var async = new AsyncScheduler(AsyncAction);
-
- var AnimationFrameAction = (function (_super) {
- __extends(AnimationFrameAction, _super);
- function AnimationFrameAction(scheduler, work) {
- var _this = _super.call(this, scheduler, work) || this;
- _this.scheduler = scheduler;
- _this.work = work;
- return _this;
- }
- AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if (delay !== null && delay > 0) {
- return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
- }
- scheduler.actions.push(this);
- return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
- };
- AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
- return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
- }
- if (scheduler.actions.length === 0) {
- cancelAnimationFrame(id);
- scheduler.scheduled = undefined;
- }
- return undefined;
- };
- return AnimationFrameAction;
- }(AsyncAction));
-
- var AnimationFrameScheduler = (function (_super) {
- __extends(AnimationFrameScheduler, _super);
- function AnimationFrameScheduler() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AnimationFrameScheduler.prototype.flush = function (action) {
- this.active = true;
- this.scheduled = undefined;
- var actions = this.actions;
- var error;
- var index = -1;
- var count = actions.length;
- action = action || actions.shift();
- do {
- if (error = action.execute(action.state, action.delay)) {
- break;
- }
- } while (++index < count && (action = actions.shift()));
- this.active = false;
- if (error) {
- while (++index < count && (action = actions.shift())) {
- action.unsubscribe();
- }
- throw error;
- }
- };
- return AnimationFrameScheduler;
- }(AsyncScheduler));
-
- var animationFrame = new AnimationFrameScheduler(AnimationFrameAction);
-
- var VirtualTimeScheduler = (function (_super) {
- __extends(VirtualTimeScheduler, _super);
- function VirtualTimeScheduler(SchedulerAction, maxFrames) {
- if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
- if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
- var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
- _this.maxFrames = maxFrames;
- _this.frame = 0;
- _this.index = -1;
- return _this;
- }
- VirtualTimeScheduler.prototype.flush = function () {
- var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
- var error, action;
- while ((action = actions.shift()) && (this.frame = action.delay) <= maxFrames) {
- if (error = action.execute(action.state, action.delay)) {
- break;
- }
- }
- if (error) {
- while (action = actions.shift()) {
- action.unsubscribe();
- }
- throw error;
- }
- };
- VirtualTimeScheduler.frameTimeFactor = 10;
- return VirtualTimeScheduler;
- }(AsyncScheduler));
- var VirtualAction = (function (_super) {
- __extends(VirtualAction, _super);
- function VirtualAction(scheduler, work, index) {
- if (index === void 0) { index = scheduler.index += 1; }
- var _this = _super.call(this, scheduler, work) || this;
- _this.scheduler = scheduler;
- _this.work = work;
- _this.index = index;
- _this.active = true;
- _this.index = scheduler.index = index;
- return _this;
- }
- VirtualAction.prototype.schedule = function (state, delay) {
- if (delay === void 0) { delay = 0; }
- if (!this.id) {
- return _super.prototype.schedule.call(this, state, delay);
- }
- this.active = false;
- var action = new VirtualAction(this.scheduler, this.work);
- this.add(action);
- return action.schedule(state, delay);
- };
- VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- this.delay = scheduler.frame + delay;
- var actions = scheduler.actions;
- actions.push(this);
- actions.sort(VirtualAction.sortActions);
- return true;
- };
- VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- return undefined;
- };
- VirtualAction.prototype._execute = function (state, delay) {
- if (this.active === true) {
- return _super.prototype._execute.call(this, state, delay);
- }
- };
- VirtualAction.sortActions = function (a, b) {
- if (a.delay === b.delay) {
- if (a.index === b.index) {
- return 0;
- }
- else if (a.index > b.index) {
- return 1;
- }
- else {
- return -1;
- }
- }
- else if (a.delay > b.delay) {
- return 1;
- }
- else {
- return -1;
- }
- };
- return VirtualAction;
- }(AsyncAction));
-
- function identity(x) {
- return x;
- }
-
- function isObservable(obj) {
- return !!obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
- }
-
- function ArgumentOutOfRangeErrorImpl() {
- Error.call(this);
- this.message = 'argument out of range';
- this.name = 'ArgumentOutOfRangeError';
- return this;
- }
- ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
- var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
-
- function EmptyErrorImpl() {
- Error.call(this);
- this.message = 'no elements in sequence';
- this.name = 'EmptyError';
- return this;
- }
- EmptyErrorImpl.prototype = Object.create(Error.prototype);
- var EmptyError = EmptyErrorImpl;
-
- function TimeoutErrorImpl() {
- Error.call(this);
- this.message = 'Timeout has occurred';
- this.name = 'TimeoutError';
- return this;
- }
- TimeoutErrorImpl.prototype = Object.create(Error.prototype);
- var TimeoutError = TimeoutErrorImpl;
-
- function map(project, thisArg) {
- return function mapOperation(source) {
- if (typeof project !== 'function') {
- throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
- }
- return source.lift(new MapOperator(project, thisArg));
- };
- }
- var MapOperator = (function () {
- function MapOperator(project, thisArg) {
- this.project = project;
- this.thisArg = thisArg;
- }
- MapOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
- };
- return MapOperator;
- }());
- var MapSubscriber = (function (_super) {
- __extends(MapSubscriber, _super);
- function MapSubscriber(destination, project, thisArg) {
- var _this = _super.call(this, destination) || this;
- _this.project = project;
- _this.count = 0;
- _this.thisArg = thisArg || _this;
- return _this;
- }
- MapSubscriber.prototype._next = function (value) {
- var result;
- try {
- result = this.project.call(this.thisArg, value, this.count++);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(result);
- };
- return MapSubscriber;
- }(Subscriber));
-
- function bindCallback(callbackFunc, resultSelector, scheduler) {
- if (resultSelector) {
- if (isScheduler(resultSelector)) {
- scheduler = resultSelector;
- }
- else {
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
- };
- }
- }
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var context = this;
- var subject;
- var params = {
- context: context,
- subject: subject,
- callbackFunc: callbackFunc,
- scheduler: scheduler,
- };
- return new Observable(function (subscriber) {
- if (!scheduler) {
- if (!subject) {
- subject = new AsyncSubject();
- var handler = function () {
- var innerArgs = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- innerArgs[_i] = arguments[_i];
- }
- subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
- subject.complete();
- };
- try {
- callbackFunc.apply(context, args.concat([handler]));
- }
- catch (err) {
- if (canReportError(subject)) {
- subject.error(err);
- }
- else {
- console.warn(err);
- }
- }
- }
- return subject.subscribe(subscriber);
- }
- else {
- var state = {
- args: args, subscriber: subscriber, params: params,
- };
- return scheduler.schedule(dispatch$1, 0, state);
- }
- });
- };
- }
- function dispatch$1(state) {
- var _this = this;
- var self = this;
- var args = state.args, subscriber = state.subscriber, params = state.params;
- var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
- var subject = params.subject;
- if (!subject) {
- subject = params.subject = new AsyncSubject();
- var handler = function () {
- var innerArgs = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- innerArgs[_i] = arguments[_i];
- }
- var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
- _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
- };
- try {
- callbackFunc.apply(context, args.concat([handler]));
- }
- catch (err) {
- subject.error(err);
- }
- }
- this.add(subject.subscribe(subscriber));
- }
- function dispatchNext(state) {
- var value = state.value, subject = state.subject;
- subject.next(value);
- subject.complete();
- }
-
- function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
- if (resultSelector) {
- if (isScheduler(resultSelector)) {
- scheduler = resultSelector;
- }
- else {
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return bindNodeCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
- };
- }
- }
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var params = {
- subject: undefined,
- args: args,
- callbackFunc: callbackFunc,
- scheduler: scheduler,
- context: this,
- };
- return new Observable(function (subscriber) {
- var context = params.context;
- var subject = params.subject;
- if (!scheduler) {
- if (!subject) {
- subject = params.subject = new AsyncSubject();
- var handler = function () {
- var innerArgs = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- innerArgs[_i] = arguments[_i];
- }
- var err = innerArgs.shift();
- if (err) {
- subject.error(err);
- return;
- }
- subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
- subject.complete();
- };
- try {
- callbackFunc.apply(context, args.concat([handler]));
- }
- catch (err) {
- if (canReportError(subject)) {
- subject.error(err);
- }
- else {
- console.warn(err);
- }
- }
- }
- return subject.subscribe(subscriber);
- }
- else {
- return scheduler.schedule(dispatch$2, 0, { params: params, subscriber: subscriber, context: context });
- }
- });
- };
- }
- function dispatch$2(state) {
- var _this = this;
- var params = state.params, subscriber = state.subscriber, context = state.context;
- var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
- var subject = params.subject;
- if (!subject) {
- subject = params.subject = new AsyncSubject();
- var handler = function () {
- var innerArgs = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- innerArgs[_i] = arguments[_i];
- }
- var err = innerArgs.shift();
- if (err) {
- _this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
- }
- else {
- var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
- _this.add(scheduler.schedule(dispatchNext$1, 0, { value: value, subject: subject }));
- }
- };
- try {
- callbackFunc.apply(context, args.concat([handler]));
- }
- catch (err) {
- this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
- }
- }
- this.add(subject.subscribe(subscriber));
- }
- function dispatchNext$1(arg) {
- var value = arg.value, subject = arg.subject;
- subject.next(value);
- subject.complete();
- }
- function dispatchError$1(arg) {
- var err = arg.err, subject = arg.subject;
- subject.error(err);
- }
-
- var OuterSubscriber = (function (_super) {
- __extends(OuterSubscriber, _super);
- function OuterSubscriber() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(innerValue);
- };
- OuterSubscriber.prototype.notifyError = function (error, innerSub) {
- this.destination.error(error);
- };
- OuterSubscriber.prototype.notifyComplete = function (innerSub) {
- this.destination.complete();
- };
- return OuterSubscriber;
- }(Subscriber));
-
- var InnerSubscriber = (function (_super) {
- __extends(InnerSubscriber, _super);
- function InnerSubscriber(parent, outerValue, outerIndex) {
- var _this = _super.call(this) || this;
- _this.parent = parent;
- _this.outerValue = outerValue;
- _this.outerIndex = outerIndex;
- _this.index = 0;
- return _this;
- }
- InnerSubscriber.prototype._next = function (value) {
- this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
- };
- InnerSubscriber.prototype._error = function (error) {
- this.parent.notifyError(error, this);
- this.unsubscribe();
- };
- InnerSubscriber.prototype._complete = function () {
- this.parent.notifyComplete(this);
- this.unsubscribe();
- };
- return InnerSubscriber;
- }(Subscriber));
-
- var subscribeToPromise = function (promise) { return function (subscriber) {
- promise.then(function (value) {
- if (!subscriber.closed) {
- subscriber.next(value);
- subscriber.complete();
- }
- }, function (err) { return subscriber.error(err); })
- .then(null, hostReportError);
- return subscriber;
- }; };
-
- function getSymbolIterator() {
- if (typeof Symbol !== 'function' || !Symbol.iterator) {
- return '@@iterator';
- }
- return Symbol.iterator;
- }
- var iterator = getSymbolIterator();
-
- var subscribeToIterable = function (iterable) { return function (subscriber) {
- var iterator$$1 = iterable[iterator]();
- do {
- var item = iterator$$1.next();
- if (item.done) {
- subscriber.complete();
- break;
- }
- subscriber.next(item.value);
- if (subscriber.closed) {
- break;
- }
- } while (true);
- if (typeof iterator$$1.return === 'function') {
- subscriber.add(function () {
- if (iterator$$1.return) {
- iterator$$1.return();
- }
- });
- }
- return subscriber;
- }; };
-
- var subscribeToObservable = function (obj) { return function (subscriber) {
- var obs = obj[observable]();
- if (typeof obs.subscribe !== 'function') {
- throw new TypeError('Provided object does not correctly implement Symbol.observable');
- }
- else {
- return obs.subscribe(subscriber);
- }
- }; };
-
- var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
-
- function isPromise(value) {
- return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
- }
-
- var subscribeTo = function (result) {
- if (result instanceof Observable) {
- return function (subscriber) {
- if (result._isScalar) {
- subscriber.next(result.value);
- subscriber.complete();
- return undefined;
- }
- else {
- return result.subscribe(subscriber);
- }
- };
- }
- else if (result && typeof result[observable] === 'function') {
- return subscribeToObservable(result);
- }
- else if (isArrayLike(result)) {
- return subscribeToArray(result);
- }
- else if (isPromise(result)) {
- return subscribeToPromise(result);
- }
- else if (result && typeof result[iterator] === 'function') {
- return subscribeToIterable(result);
- }
- else {
- var value = isObject(result) ? 'an invalid object' : "'" + result + "'";
- var msg = "You provided " + value + " where a stream was expected."
- + ' You can provide an Observable, Promise, Array, or Iterable.';
- throw new TypeError(msg);
- }
- };
-
- function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, destination) {
- if (destination === void 0) { destination = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
- if (destination.closed) {
- return;
- }
- return subscribeTo(result)(destination);
- }
-
- var NONE = {};
- function combineLatest() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- var resultSelector = null;
- var scheduler = null;
- if (isScheduler(observables[observables.length - 1])) {
- scheduler = observables.pop();
- }
- if (typeof observables[observables.length - 1] === 'function') {
- resultSelector = observables.pop();
- }
- if (observables.length === 1 && isArray(observables[0])) {
- observables = observables[0];
- }
- return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
- }
- var CombineLatestOperator = (function () {
- function CombineLatestOperator(resultSelector) {
- this.resultSelector = resultSelector;
- }
- CombineLatestOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
- };
- return CombineLatestOperator;
- }());
- var CombineLatestSubscriber = (function (_super) {
- __extends(CombineLatestSubscriber, _super);
- function CombineLatestSubscriber(destination, resultSelector) {
- var _this = _super.call(this, destination) || this;
- _this.resultSelector = resultSelector;
- _this.active = 0;
- _this.values = [];
- _this.observables = [];
- return _this;
- }
- CombineLatestSubscriber.prototype._next = function (observable) {
- this.values.push(NONE);
- this.observables.push(observable);
- };
- CombineLatestSubscriber.prototype._complete = function () {
- var observables = this.observables;
- var len = observables.length;
- if (len === 0) {
- this.destination.complete();
- }
- else {
- this.active = len;
- this.toRespond = len;
- for (var i = 0; i < len; i++) {
- var observable = observables[i];
- this.add(subscribeToResult(this, observable, observable, i));
- }
- }
- };
- CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
- if ((this.active -= 1) === 0) {
- this.destination.complete();
- }
- };
- CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- var values = this.values;
- var oldVal = values[outerIndex];
- var toRespond = !this.toRespond
- ? 0
- : oldVal === NONE ? --this.toRespond : this.toRespond;
- values[outerIndex] = innerValue;
- if (toRespond === 0) {
- if (this.resultSelector) {
- this._tryResultSelector(values);
- }
- else {
- this.destination.next(values.slice());
- }
- }
- };
- CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
- var result;
- try {
- result = this.resultSelector.apply(this, values);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(result);
- };
- return CombineLatestSubscriber;
- }(OuterSubscriber));
-
- function isInteropObservable(input) {
- return input && typeof input[observable] === 'function';
- }
-
- function isIterable(input) {
- return input && typeof input[iterator] === 'function';
- }
-
- function fromPromise(input, scheduler) {
- if (!scheduler) {
- return new Observable(subscribeToPromise(input));
- }
- else {
- return new Observable(function (subscriber) {
- var sub = new Subscription();
- sub.add(scheduler.schedule(function () { return input.then(function (value) {
- sub.add(scheduler.schedule(function () {
- subscriber.next(value);
- sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
- }));
- }, function (err) {
- sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
- }); }));
- return sub;
- });
- }
- }
-
- function fromIterable(input, scheduler) {
- if (!input) {
- throw new Error('Iterable cannot be null');
- }
- if (!scheduler) {
- return new Observable(subscribeToIterable(input));
- }
- else {
- return new Observable(function (subscriber) {
- var sub = new Subscription();
- var iterator$$1;
- sub.add(function () {
- if (iterator$$1 && typeof iterator$$1.return === 'function') {
- iterator$$1.return();
- }
- });
- sub.add(scheduler.schedule(function () {
- iterator$$1 = input[iterator]();
- sub.add(scheduler.schedule(function () {
- if (subscriber.closed) {
- return;
- }
- var value;
- var done;
- try {
- var result = iterator$$1.next();
- value = result.value;
- done = result.done;
- }
- catch (err) {
- subscriber.error(err);
- return;
- }
- if (done) {
- subscriber.complete();
- }
- else {
- subscriber.next(value);
- this.schedule();
- }
- }));
- }));
- return sub;
- });
- }
- }
-
- function fromObservable(input, scheduler) {
- if (!scheduler) {
- return new Observable(subscribeToObservable(input));
- }
- else {
- return new Observable(function (subscriber) {
- var sub = new Subscription();
- sub.add(scheduler.schedule(function () {
- var observable$$1 = input[observable]();
- sub.add(observable$$1.subscribe({
- next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
- error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
- complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
- }));
- }));
- return sub;
- });
- }
- }
-
- function from(input, scheduler) {
- if (!scheduler) {
- if (input instanceof Observable) {
- return input;
- }
- return new Observable(subscribeTo(input));
- }
- if (input != null) {
- if (isInteropObservable(input)) {
- return fromObservable(input, scheduler);
- }
- else if (isPromise(input)) {
- return fromPromise(input, scheduler);
- }
- else if (isArrayLike(input)) {
- return fromArray(input, scheduler);
- }
- else if (isIterable(input) || typeof input === 'string') {
- return fromIterable(input, scheduler);
- }
- }
- throw new TypeError((input !== null && typeof input || input) + ' is not observable');
- }
-
- function mergeMap(project, resultSelector, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- if (typeof resultSelector === 'function') {
- return function (source) { return source.pipe(mergeMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
- }
- else if (typeof resultSelector === 'number') {
- concurrent = resultSelector;
- }
- return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
- }
- var MergeMapOperator = (function () {
- function MergeMapOperator(project, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- this.project = project;
- this.concurrent = concurrent;
- }
- MergeMapOperator.prototype.call = function (observer, source) {
- return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
- };
- return MergeMapOperator;
- }());
- var MergeMapSubscriber = (function (_super) {
- __extends(MergeMapSubscriber, _super);
- function MergeMapSubscriber(destination, project, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- var _this = _super.call(this, destination) || this;
- _this.project = project;
- _this.concurrent = concurrent;
- _this.hasCompleted = false;
- _this.buffer = [];
- _this.active = 0;
- _this.index = 0;
- return _this;
- }
- MergeMapSubscriber.prototype._next = function (value) {
- if (this.active < this.concurrent) {
- this._tryNext(value);
- }
- else {
- this.buffer.push(value);
- }
- };
- MergeMapSubscriber.prototype._tryNext = function (value) {
- var result;
- var index = this.index++;
- try {
- result = this.project(value, index);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.active++;
- this._innerSub(result, value, index);
- };
- MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- subscribeToResult(this, ish, value, index, innerSubscriber);
- };
- MergeMapSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (this.active === 0 && this.buffer.length === 0) {
- this.destination.complete();
- }
- this.unsubscribe();
- };
- MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(innerValue);
- };
- MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
- var buffer = this.buffer;
- this.remove(innerSub);
- this.active--;
- if (buffer.length > 0) {
- this._next(buffer.shift());
- }
- else if (this.active === 0 && this.hasCompleted) {
- this.destination.complete();
- }
- };
- return MergeMapSubscriber;
- }(OuterSubscriber));
-
- function mergeAll(concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- return mergeMap(identity, concurrent);
- }
-
- function concatAll() {
- return mergeAll(1);
- }
-
- function concat() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- if (observables.length === 1 || (observables.length === 2 && isScheduler(observables[1]))) {
- return from(observables[0]);
- }
- return concatAll()(of.apply(void 0, observables));
- }
-
- function defer(observableFactory) {
- return new Observable(function (subscriber) {
- var input;
- try {
- input = observableFactory();
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- var source = input ? from(input) : empty$1();
- return source.subscribe(subscriber);
- });
- }
-
- function forkJoin() {
- var sources = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- sources[_i] = arguments[_i];
- }
- var resultSelector;
- if (typeof sources[sources.length - 1] === 'function') {
- resultSelector = sources.pop();
- }
- if (sources.length === 1 && isArray(sources[0])) {
- sources = sources[0];
- }
- if (sources.length === 0) {
- return EMPTY;
- }
- if (resultSelector) {
- return forkJoin(sources).pipe(map(function (args) { return resultSelector.apply(void 0, args); }));
- }
- return new Observable(function (subscriber) {
- return new ForkJoinSubscriber(subscriber, sources);
- });
- }
- var ForkJoinSubscriber = (function (_super) {
- __extends(ForkJoinSubscriber, _super);
- function ForkJoinSubscriber(destination, sources) {
- var _this = _super.call(this, destination) || this;
- _this.sources = sources;
- _this.completed = 0;
- _this.haveValues = 0;
- var len = sources.length;
- _this.values = new Array(len);
- for (var i = 0; i < len; i++) {
- var source = sources[i];
- var innerSubscription = subscribeToResult(_this, source, null, i);
- if (innerSubscription) {
- _this.add(innerSubscription);
- }
- }
- return _this;
- }
- ForkJoinSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.values[outerIndex] = innerValue;
- if (!innerSub._hasValue) {
- innerSub._hasValue = true;
- this.haveValues++;
- }
- };
- ForkJoinSubscriber.prototype.notifyComplete = function (innerSub) {
- var _a = this, destination = _a.destination, haveValues = _a.haveValues, values = _a.values;
- var len = values.length;
- if (!innerSub._hasValue) {
- destination.complete();
- return;
- }
- this.completed++;
- if (this.completed !== len) {
- return;
- }
- if (haveValues === len) {
- destination.next(values);
- }
- destination.complete();
- };
- return ForkJoinSubscriber;
- }(OuterSubscriber));
-
- function fromEvent(target, eventName, options, resultSelector) {
- if (isFunction(options)) {
- resultSelector = options;
- options = undefined;
- }
- if (resultSelector) {
- return fromEvent(target, eventName, options).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
- }
- return new Observable(function (subscriber) {
- function handler(e) {
- if (arguments.length > 1) {
- subscriber.next(Array.prototype.slice.call(arguments));
- }
- else {
- subscriber.next(e);
- }
- }
- setupSubscription(target, eventName, handler, subscriber, options);
- });
- }
- function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
- var unsubscribe;
- if (isEventTarget(sourceObj)) {
- var source_1 = sourceObj;
- sourceObj.addEventListener(eventName, handler, options);
- unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
- }
- else if (isJQueryStyleEventEmitter(sourceObj)) {
- var source_2 = sourceObj;
- sourceObj.on(eventName, handler);
- unsubscribe = function () { return source_2.off(eventName, handler); };
- }
- else if (isNodeStyleEventEmitter(sourceObj)) {
- var source_3 = sourceObj;
- sourceObj.addListener(eventName, handler);
- unsubscribe = function () { return source_3.removeListener(eventName, handler); };
- }
- else if (sourceObj && sourceObj.length) {
- for (var i = 0, len = sourceObj.length; i < len; i++) {
- setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
- }
- }
- else {
- throw new TypeError('Invalid event target');
- }
- subscriber.add(unsubscribe);
- }
- function isNodeStyleEventEmitter(sourceObj) {
- return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
- }
- function isJQueryStyleEventEmitter(sourceObj) {
- return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
- }
- function isEventTarget(sourceObj) {
- return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
- }
-
- function fromEventPattern(addHandler, removeHandler, resultSelector) {
- if (resultSelector) {
- return fromEventPattern(addHandler, removeHandler).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
- }
- return new Observable(function (subscriber) {
- var handler = function () {
- var e = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- e[_i] = arguments[_i];
- }
- return subscriber.next(e.length === 1 ? e[0] : e);
- };
- var retValue;
- try {
- retValue = addHandler(handler);
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- if (!isFunction(removeHandler)) {
- return undefined;
- }
- return function () { return removeHandler(handler, retValue); };
- });
- }
-
- function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
- var resultSelector;
- var initialState;
- if (arguments.length == 1) {
- var options = initialStateOrOptions;
- initialState = options.initialState;
- condition = options.condition;
- iterate = options.iterate;
- resultSelector = options.resultSelector || identity;
- scheduler = options.scheduler;
- }
- else if (resultSelectorOrObservable === undefined || isScheduler(resultSelectorOrObservable)) {
- initialState = initialStateOrOptions;
- resultSelector = identity;
- scheduler = resultSelectorOrObservable;
- }
- else {
- initialState = initialStateOrOptions;
- resultSelector = resultSelectorOrObservable;
- }
- return new Observable(function (subscriber) {
- var state = initialState;
- if (scheduler) {
- return scheduler.schedule(dispatch$3, 0, {
- subscriber: subscriber,
- iterate: iterate,
- condition: condition,
- resultSelector: resultSelector,
- state: state
- });
- }
- do {
- if (condition) {
- var conditionResult = void 0;
- try {
- conditionResult = condition(state);
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- if (!conditionResult) {
- subscriber.complete();
- break;
- }
- }
- var value = void 0;
- try {
- value = resultSelector(state);
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- subscriber.next(value);
- if (subscriber.closed) {
- break;
- }
- try {
- state = iterate(state);
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- } while (true);
- return undefined;
- });
- }
- function dispatch$3(state) {
- var subscriber = state.subscriber, condition = state.condition;
- if (subscriber.closed) {
- return undefined;
- }
- if (state.needIterate) {
- try {
- state.state = state.iterate(state.state);
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- }
- else {
- state.needIterate = true;
- }
- if (condition) {
- var conditionResult = void 0;
- try {
- conditionResult = condition(state.state);
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- if (!conditionResult) {
- subscriber.complete();
- return undefined;
- }
- if (subscriber.closed) {
- return undefined;
- }
- }
- var value;
- try {
- value = state.resultSelector(state.state);
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- if (subscriber.closed) {
- return undefined;
- }
- subscriber.next(value);
- if (subscriber.closed) {
- return undefined;
- }
- return this.schedule(state);
- }
-
- function iif(condition, trueResult, falseResult) {
- if (trueResult === void 0) { trueResult = EMPTY; }
- if (falseResult === void 0) { falseResult = EMPTY; }
- return defer(function () { return condition() ? trueResult : falseResult; });
- }
-
- function isNumeric(val) {
- return !isArray(val) && (val - parseFloat(val) + 1) >= 0;
- }
-
- function interval(period, scheduler) {
- if (period === void 0) { period = 0; }
- if (scheduler === void 0) { scheduler = async; }
- if (!isNumeric(period) || period < 0) {
- period = 0;
- }
- if (!scheduler || typeof scheduler.schedule !== 'function') {
- scheduler = async;
- }
- return new Observable(function (subscriber) {
- subscriber.add(scheduler.schedule(dispatch$4, period, { subscriber: subscriber, counter: 0, period: period }));
- return subscriber;
- });
- }
- function dispatch$4(state) {
- var subscriber = state.subscriber, counter = state.counter, period = state.period;
- subscriber.next(counter);
- this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
- }
-
- function merge() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- var concurrent = Number.POSITIVE_INFINITY;
- var scheduler = null;
- var last = observables[observables.length - 1];
- if (isScheduler(last)) {
- scheduler = observables.pop();
- if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
- concurrent = observables.pop();
- }
- }
- else if (typeof last === 'number') {
- concurrent = observables.pop();
- }
- if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) {
- return observables[0];
- }
- return mergeAll(concurrent)(fromArray(observables, scheduler));
- }
-
- var NEVER = new Observable(noop);
- function never() {
- return NEVER;
- }
-
- function onErrorResumeNext() {
- var sources = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- sources[_i] = arguments[_i];
- }
- if (sources.length === 0) {
- return EMPTY;
- }
- var first = sources[0], remainder = sources.slice(1);
- if (sources.length === 1 && isArray(first)) {
- return onErrorResumeNext.apply(void 0, first);
- }
- return new Observable(function (subscriber) {
- var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
- return from(first).subscribe({
- next: function (value) { subscriber.next(value); },
- error: subNext,
- complete: subNext,
- });
- });
- }
-
- function pairs(obj, scheduler) {
- if (!scheduler) {
- return new Observable(function (subscriber) {
- var keys = Object.keys(obj);
- for (var i = 0; i < keys.length && !subscriber.closed; i++) {
- var key = keys[i];
- if (obj.hasOwnProperty(key)) {
- subscriber.next([key, obj[key]]);
- }
- }
- subscriber.complete();
- });
- }
- else {
- return new Observable(function (subscriber) {
- var keys = Object.keys(obj);
- var subscription = new Subscription();
- subscription.add(scheduler.schedule(dispatch$5, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
- return subscription;
- });
- }
- }
- function dispatch$5(state) {
- var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
- if (!subscriber.closed) {
- if (index < keys.length) {
- var key = keys[index];
- subscriber.next([key, obj[key]]);
- subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
- }
- else {
- subscriber.complete();
- }
- }
- }
-
- function race() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- if (observables.length === 1) {
- if (isArray(observables[0])) {
- observables = observables[0];
- }
- else {
- return observables[0];
- }
- }
- return fromArray(observables, undefined).lift(new RaceOperator());
- }
- var RaceOperator = (function () {
- function RaceOperator() {
- }
- RaceOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new RaceSubscriber(subscriber));
- };
- return RaceOperator;
- }());
- var RaceSubscriber = (function (_super) {
- __extends(RaceSubscriber, _super);
- function RaceSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.hasFirst = false;
- _this.observables = [];
- _this.subscriptions = [];
- return _this;
- }
- RaceSubscriber.prototype._next = function (observable) {
- this.observables.push(observable);
- };
- RaceSubscriber.prototype._complete = function () {
- var observables = this.observables;
- var len = observables.length;
- if (len === 0) {
- this.destination.complete();
- }
- else {
- for (var i = 0; i < len && !this.hasFirst; i++) {
- var observable = observables[i];
- var subscription = subscribeToResult(this, observable, observable, i);
- if (this.subscriptions) {
- this.subscriptions.push(subscription);
- }
- this.add(subscription);
- }
- this.observables = null;
- }
- };
- RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- if (!this.hasFirst) {
- this.hasFirst = true;
- for (var i = 0; i < this.subscriptions.length; i++) {
- if (i !== outerIndex) {
- var subscription = this.subscriptions[i];
- subscription.unsubscribe();
- this.remove(subscription);
- }
- }
- this.subscriptions = null;
- }
- this.destination.next(innerValue);
- };
- return RaceSubscriber;
- }(OuterSubscriber));
-
- function range(start, count, scheduler) {
- if (start === void 0) { start = 0; }
- if (count === void 0) { count = 0; }
- return new Observable(function (subscriber) {
- var index = 0;
- var current = start;
- if (scheduler) {
- return scheduler.schedule(dispatch$6, 0, {
- index: index, count: count, start: start, subscriber: subscriber
- });
- }
- else {
- do {
- if (index++ >= count) {
- subscriber.complete();
- break;
- }
- subscriber.next(current++);
- if (subscriber.closed) {
- break;
- }
- } while (true);
- }
- return undefined;
- });
- }
- function dispatch$6(state) {
- var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
- if (index >= count) {
- subscriber.complete();
- return;
- }
- subscriber.next(start);
- if (subscriber.closed) {
- return;
- }
- state.index = index + 1;
- state.start = start + 1;
- this.schedule(state);
- }
-
- function timer(dueTime, periodOrScheduler, scheduler) {
- if (dueTime === void 0) { dueTime = 0; }
- var period = -1;
- if (isNumeric(periodOrScheduler)) {
- period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
- }
- else if (isScheduler(periodOrScheduler)) {
- scheduler = periodOrScheduler;
- }
- if (!isScheduler(scheduler)) {
- scheduler = async;
- }
- return new Observable(function (subscriber) {
- var due = isNumeric(dueTime)
- ? dueTime
- : (+dueTime - scheduler.now());
- return scheduler.schedule(dispatch$7, due, {
- index: 0, period: period, subscriber: subscriber
- });
- });
- }
- function dispatch$7(state) {
- var index = state.index, period = state.period, subscriber = state.subscriber;
- subscriber.next(index);
- if (subscriber.closed) {
- return;
- }
- else if (period === -1) {
- return subscriber.complete();
- }
- state.index = index + 1;
- this.schedule(state, period);
- }
-
- function using(resourceFactory, observableFactory) {
- return new Observable(function (subscriber) {
- var resource;
- try {
- resource = resourceFactory();
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- var result;
- try {
- result = observableFactory(resource);
- }
- catch (err) {
- subscriber.error(err);
- return undefined;
- }
- var source = result ? from(result) : EMPTY;
- var subscription = source.subscribe(subscriber);
- return function () {
- subscription.unsubscribe();
- if (resource) {
- resource.unsubscribe();
- }
- };
- });
- }
-
- function zip() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- var resultSelector = observables[observables.length - 1];
- if (typeof resultSelector === 'function') {
- observables.pop();
- }
- return fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
- }
- var ZipOperator = (function () {
- function ZipOperator(resultSelector) {
- this.resultSelector = resultSelector;
- }
- ZipOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
- };
- return ZipOperator;
- }());
- var ZipSubscriber = (function (_super) {
- __extends(ZipSubscriber, _super);
- function ZipSubscriber(destination, resultSelector, values) {
- if (values === void 0) { values = Object.create(null); }
- var _this = _super.call(this, destination) || this;
- _this.iterators = [];
- _this.active = 0;
- _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
- _this.values = values;
- return _this;
- }
- ZipSubscriber.prototype._next = function (value) {
- var iterators = this.iterators;
- if (isArray(value)) {
- iterators.push(new StaticArrayIterator(value));
- }
- else if (typeof value[iterator] === 'function') {
- iterators.push(new StaticIterator(value[iterator]()));
- }
- else {
- iterators.push(new ZipBufferIterator(this.destination, this, value));
- }
- };
- ZipSubscriber.prototype._complete = function () {
- var iterators = this.iterators;
- var len = iterators.length;
- this.unsubscribe();
- if (len === 0) {
- this.destination.complete();
- return;
- }
- this.active = len;
- for (var i = 0; i < len; i++) {
- var iterator$$1 = iterators[i];
- if (iterator$$1.stillUnsubscribed) {
- var destination = this.destination;
- destination.add(iterator$$1.subscribe(iterator$$1, i));
- }
- else {
- this.active--;
- }
- }
- };
- ZipSubscriber.prototype.notifyInactive = function () {
- this.active--;
- if (this.active === 0) {
- this.destination.complete();
- }
- };
- ZipSubscriber.prototype.checkIterators = function () {
- var iterators = this.iterators;
- var len = iterators.length;
- var destination = this.destination;
- for (var i = 0; i < len; i++) {
- var iterator$$1 = iterators[i];
- if (typeof iterator$$1.hasValue === 'function' && !iterator$$1.hasValue()) {
- return;
- }
- }
- var shouldComplete = false;
- var args = [];
- for (var i = 0; i < len; i++) {
- var iterator$$1 = iterators[i];
- var result = iterator$$1.next();
- if (iterator$$1.hasCompleted()) {
- shouldComplete = true;
- }
- if (result.done) {
- destination.complete();
- return;
- }
- args.push(result.value);
- }
- if (this.resultSelector) {
- this._tryresultSelector(args);
- }
- else {
- destination.next(args);
- }
- if (shouldComplete) {
- destination.complete();
- }
- };
- ZipSubscriber.prototype._tryresultSelector = function (args) {
- var result;
- try {
- result = this.resultSelector.apply(this, args);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(result);
- };
- return ZipSubscriber;
- }(Subscriber));
- var StaticIterator = (function () {
- function StaticIterator(iterator$$1) {
- this.iterator = iterator$$1;
- this.nextResult = iterator$$1.next();
- }
- StaticIterator.prototype.hasValue = function () {
- return true;
- };
- StaticIterator.prototype.next = function () {
- var result = this.nextResult;
- this.nextResult = this.iterator.next();
- return result;
- };
- StaticIterator.prototype.hasCompleted = function () {
- var nextResult = this.nextResult;
- return nextResult && nextResult.done;
- };
- return StaticIterator;
- }());
- var StaticArrayIterator = (function () {
- function StaticArrayIterator(array) {
- this.array = array;
- this.index = 0;
- this.length = 0;
- this.length = array.length;
- }
- StaticArrayIterator.prototype[iterator] = function () {
- return this;
- };
- StaticArrayIterator.prototype.next = function (value) {
- var i = this.index++;
- var array = this.array;
- return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
- };
- StaticArrayIterator.prototype.hasValue = function () {
- return this.array.length > this.index;
- };
- StaticArrayIterator.prototype.hasCompleted = function () {
- return this.array.length === this.index;
- };
- return StaticArrayIterator;
- }());
- var ZipBufferIterator = (function (_super) {
- __extends(ZipBufferIterator, _super);
- function ZipBufferIterator(destination, parent, observable) {
- var _this = _super.call(this, destination) || this;
- _this.parent = parent;
- _this.observable = observable;
- _this.stillUnsubscribed = true;
- _this.buffer = [];
- _this.isComplete = false;
- return _this;
- }
- ZipBufferIterator.prototype[iterator] = function () {
- return this;
- };
- ZipBufferIterator.prototype.next = function () {
- var buffer = this.buffer;
- if (buffer.length === 0 && this.isComplete) {
- return { value: null, done: true };
- }
- else {
- return { value: buffer.shift(), done: false };
- }
- };
- ZipBufferIterator.prototype.hasValue = function () {
- return this.buffer.length > 0;
- };
- ZipBufferIterator.prototype.hasCompleted = function () {
- return this.buffer.length === 0 && this.isComplete;
- };
- ZipBufferIterator.prototype.notifyComplete = function () {
- if (this.buffer.length > 0) {
- this.isComplete = true;
- this.parent.notifyInactive();
- }
- else {
- this.destination.complete();
- }
- };
- ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.buffer.push(innerValue);
- this.parent.checkIterators();
- };
- ZipBufferIterator.prototype.subscribe = function (value, index) {
- return subscribeToResult(this, this.observable, this, index);
- };
- return ZipBufferIterator;
- }(OuterSubscriber));
-
- function audit(durationSelector) {
- return function auditOperatorFunction(source) {
- return source.lift(new AuditOperator(durationSelector));
- };
- }
- var AuditOperator = (function () {
- function AuditOperator(durationSelector) {
- this.durationSelector = durationSelector;
- }
- AuditOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
- };
- return AuditOperator;
- }());
- var AuditSubscriber = (function (_super) {
- __extends(AuditSubscriber, _super);
- function AuditSubscriber(destination, durationSelector) {
- var _this = _super.call(this, destination) || this;
- _this.durationSelector = durationSelector;
- _this.hasValue = false;
- return _this;
- }
- AuditSubscriber.prototype._next = function (value) {
- this.value = value;
- this.hasValue = true;
- if (!this.throttled) {
- var duration = tryCatch(this.durationSelector)(value);
- if (duration === errorObject) {
- this.destination.error(errorObject.e);
- }
- else {
- var innerSubscription = subscribeToResult(this, duration);
- if (!innerSubscription || innerSubscription.closed) {
- this.clearThrottle();
- }
- else {
- this.add(this.throttled = innerSubscription);
- }
- }
- }
- };
- AuditSubscriber.prototype.clearThrottle = function () {
- var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
- if (throttled) {
- this.remove(throttled);
- this.throttled = null;
- throttled.unsubscribe();
- }
- if (hasValue) {
- this.value = null;
- this.hasValue = false;
- this.destination.next(value);
- }
- };
- AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
- this.clearThrottle();
- };
- AuditSubscriber.prototype.notifyComplete = function () {
- this.clearThrottle();
- };
- return AuditSubscriber;
- }(OuterSubscriber));
-
- function auditTime(duration, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return audit(function () { return timer(duration, scheduler); });
- }
-
- function buffer(closingNotifier) {
- return function bufferOperatorFunction(source) {
- return source.lift(new BufferOperator(closingNotifier));
- };
- }
- var BufferOperator = (function () {
- function BufferOperator(closingNotifier) {
- this.closingNotifier = closingNotifier;
- }
- BufferOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
- };
- return BufferOperator;
- }());
- var BufferSubscriber = (function (_super) {
- __extends(BufferSubscriber, _super);
- function BufferSubscriber(destination, closingNotifier) {
- var _this = _super.call(this, destination) || this;
- _this.buffer = [];
- _this.add(subscribeToResult(_this, closingNotifier));
- return _this;
- }
- BufferSubscriber.prototype._next = function (value) {
- this.buffer.push(value);
- };
- BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- var buffer = this.buffer;
- this.buffer = [];
- this.destination.next(buffer);
- };
- return BufferSubscriber;
- }(OuterSubscriber));
-
- function bufferCount(bufferSize, startBufferEvery) {
- if (startBufferEvery === void 0) { startBufferEvery = null; }
- return function bufferCountOperatorFunction(source) {
- return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
- };
- }
- var BufferCountOperator = (function () {
- function BufferCountOperator(bufferSize, startBufferEvery) {
- this.bufferSize = bufferSize;
- this.startBufferEvery = startBufferEvery;
- if (!startBufferEvery || bufferSize === startBufferEvery) {
- this.subscriberClass = BufferCountSubscriber;
- }
- else {
- this.subscriberClass = BufferSkipCountSubscriber;
- }
- }
- BufferCountOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
- };
- return BufferCountOperator;
- }());
- var BufferCountSubscriber = (function (_super) {
- __extends(BufferCountSubscriber, _super);
- function BufferCountSubscriber(destination, bufferSize) {
- var _this = _super.call(this, destination) || this;
- _this.bufferSize = bufferSize;
- _this.buffer = [];
- return _this;
- }
- BufferCountSubscriber.prototype._next = function (value) {
- var buffer = this.buffer;
- buffer.push(value);
- if (buffer.length == this.bufferSize) {
- this.destination.next(buffer);
- this.buffer = [];
- }
- };
- BufferCountSubscriber.prototype._complete = function () {
- var buffer = this.buffer;
- if (buffer.length > 0) {
- this.destination.next(buffer);
- }
- _super.prototype._complete.call(this);
- };
- return BufferCountSubscriber;
- }(Subscriber));
- var BufferSkipCountSubscriber = (function (_super) {
- __extends(BufferSkipCountSubscriber, _super);
- function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
- var _this = _super.call(this, destination) || this;
- _this.bufferSize = bufferSize;
- _this.startBufferEvery = startBufferEvery;
- _this.buffers = [];
- _this.count = 0;
- return _this;
- }
- BufferSkipCountSubscriber.prototype._next = function (value) {
- var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
- this.count++;
- if (count % startBufferEvery === 0) {
- buffers.push([]);
- }
- for (var i = buffers.length; i--;) {
- var buffer = buffers[i];
- buffer.push(value);
- if (buffer.length === bufferSize) {
- buffers.splice(i, 1);
- this.destination.next(buffer);
- }
- }
- };
- BufferSkipCountSubscriber.prototype._complete = function () {
- var _a = this, buffers = _a.buffers, destination = _a.destination;
- while (buffers.length > 0) {
- var buffer = buffers.shift();
- if (buffer.length > 0) {
- destination.next(buffer);
- }
- }
- _super.prototype._complete.call(this);
- };
- return BufferSkipCountSubscriber;
- }(Subscriber));
-
- function bufferTime(bufferTimeSpan) {
- var length = arguments.length;
- var scheduler = async;
- if (isScheduler(arguments[arguments.length - 1])) {
- scheduler = arguments[arguments.length - 1];
- length--;
- }
- var bufferCreationInterval = null;
- if (length >= 2) {
- bufferCreationInterval = arguments[1];
- }
- var maxBufferSize = Number.POSITIVE_INFINITY;
- if (length >= 3) {
- maxBufferSize = arguments[2];
- }
- return function bufferTimeOperatorFunction(source) {
- return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
- };
- }
- var BufferTimeOperator = (function () {
- function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
- this.bufferTimeSpan = bufferTimeSpan;
- this.bufferCreationInterval = bufferCreationInterval;
- this.maxBufferSize = maxBufferSize;
- this.scheduler = scheduler;
- }
- BufferTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
- };
- return BufferTimeOperator;
- }());
- var Context = (function () {
- function Context() {
- this.buffer = [];
- }
- return Context;
- }());
- var BufferTimeSubscriber = (function (_super) {
- __extends(BufferTimeSubscriber, _super);
- function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.bufferTimeSpan = bufferTimeSpan;
- _this.bufferCreationInterval = bufferCreationInterval;
- _this.maxBufferSize = maxBufferSize;
- _this.scheduler = scheduler;
- _this.contexts = [];
- var context = _this.openContext();
- _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
- if (_this.timespanOnly) {
- var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
- _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
- }
- else {
- var closeState = { subscriber: _this, context: context };
- var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
- _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
- _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
- }
- return _this;
- }
- BufferTimeSubscriber.prototype._next = function (value) {
- var contexts = this.contexts;
- var len = contexts.length;
- var filledBufferContext;
- for (var i = 0; i < len; i++) {
- var context_1 = contexts[i];
- var buffer = context_1.buffer;
- buffer.push(value);
- if (buffer.length == this.maxBufferSize) {
- filledBufferContext = context_1;
- }
- }
- if (filledBufferContext) {
- this.onBufferFull(filledBufferContext);
- }
- };
- BufferTimeSubscriber.prototype._error = function (err) {
- this.contexts.length = 0;
- _super.prototype._error.call(this, err);
- };
- BufferTimeSubscriber.prototype._complete = function () {
- var _a = this, contexts = _a.contexts, destination = _a.destination;
- while (contexts.length > 0) {
- var context_2 = contexts.shift();
- destination.next(context_2.buffer);
- }
- _super.prototype._complete.call(this);
- };
- BufferTimeSubscriber.prototype._unsubscribe = function () {
- this.contexts = null;
- };
- BufferTimeSubscriber.prototype.onBufferFull = function (context) {
- this.closeContext(context);
- var closeAction = context.closeAction;
- closeAction.unsubscribe();
- this.remove(closeAction);
- if (!this.closed && this.timespanOnly) {
- context = this.openContext();
- var bufferTimeSpan = this.bufferTimeSpan;
- var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
- this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
- }
- };
- BufferTimeSubscriber.prototype.openContext = function () {
- var context = new Context();
- this.contexts.push(context);
- return context;
- };
- BufferTimeSubscriber.prototype.closeContext = function (context) {
- this.destination.next(context.buffer);
- var contexts = this.contexts;
- var spliceIndex = contexts ? contexts.indexOf(context) : -1;
- if (spliceIndex >= 0) {
- contexts.splice(contexts.indexOf(context), 1);
- }
- };
- return BufferTimeSubscriber;
- }(Subscriber));
- function dispatchBufferTimeSpanOnly(state) {
- var subscriber = state.subscriber;
- var prevContext = state.context;
- if (prevContext) {
- subscriber.closeContext(prevContext);
- }
- if (!subscriber.closed) {
- state.context = subscriber.openContext();
- state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
- }
- }
- function dispatchBufferCreation(state) {
- var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
- var context = subscriber.openContext();
- var action = this;
- if (!subscriber.closed) {
- subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
- action.schedule(state, bufferCreationInterval);
- }
- }
- function dispatchBufferClose(arg) {
- var subscriber = arg.subscriber, context = arg.context;
- subscriber.closeContext(context);
- }
-
- function bufferToggle(openings, closingSelector) {
- return function bufferToggleOperatorFunction(source) {
- return source.lift(new BufferToggleOperator(openings, closingSelector));
- };
- }
- var BufferToggleOperator = (function () {
- function BufferToggleOperator(openings, closingSelector) {
- this.openings = openings;
- this.closingSelector = closingSelector;
- }
- BufferToggleOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
- };
- return BufferToggleOperator;
- }());
- var BufferToggleSubscriber = (function (_super) {
- __extends(BufferToggleSubscriber, _super);
- function BufferToggleSubscriber(destination, openings, closingSelector) {
- var _this = _super.call(this, destination) || this;
- _this.openings = openings;
- _this.closingSelector = closingSelector;
- _this.contexts = [];
- _this.add(subscribeToResult(_this, openings));
- return _this;
- }
- BufferToggleSubscriber.prototype._next = function (value) {
- var contexts = this.contexts;
- var len = contexts.length;
- for (var i = 0; i < len; i++) {
- contexts[i].buffer.push(value);
- }
- };
- BufferToggleSubscriber.prototype._error = function (err) {
- var contexts = this.contexts;
- while (contexts.length > 0) {
- var context_1 = contexts.shift();
- context_1.subscription.unsubscribe();
- context_1.buffer = null;
- context_1.subscription = null;
- }
- this.contexts = null;
- _super.prototype._error.call(this, err);
- };
- BufferToggleSubscriber.prototype._complete = function () {
- var contexts = this.contexts;
- while (contexts.length > 0) {
- var context_2 = contexts.shift();
- this.destination.next(context_2.buffer);
- context_2.subscription.unsubscribe();
- context_2.buffer = null;
- context_2.subscription = null;
- }
- this.contexts = null;
- _super.prototype._complete.call(this);
- };
- BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
- };
- BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
- this.closeBuffer(innerSub.context);
- };
- BufferToggleSubscriber.prototype.openBuffer = function (value) {
- try {
- var closingSelector = this.closingSelector;
- var closingNotifier = closingSelector.call(this, value);
- if (closingNotifier) {
- this.trySubscribe(closingNotifier);
- }
- }
- catch (err) {
- this._error(err);
- }
- };
- BufferToggleSubscriber.prototype.closeBuffer = function (context) {
- var contexts = this.contexts;
- if (contexts && context) {
- var buffer = context.buffer, subscription = context.subscription;
- this.destination.next(buffer);
- contexts.splice(contexts.indexOf(context), 1);
- this.remove(subscription);
- subscription.unsubscribe();
- }
- };
- BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
- var contexts = this.contexts;
- var buffer = [];
- var subscription = new Subscription();
- var context = { buffer: buffer, subscription: subscription };
- contexts.push(context);
- var innerSubscription = subscribeToResult(this, closingNotifier, context);
- if (!innerSubscription || innerSubscription.closed) {
- this.closeBuffer(context);
- }
- else {
- innerSubscription.context = context;
- this.add(innerSubscription);
- subscription.add(innerSubscription);
- }
- };
- return BufferToggleSubscriber;
- }(OuterSubscriber));
-
- function bufferWhen(closingSelector) {
- return function (source) {
- return source.lift(new BufferWhenOperator(closingSelector));
- };
- }
- var BufferWhenOperator = (function () {
- function BufferWhenOperator(closingSelector) {
- this.closingSelector = closingSelector;
- }
- BufferWhenOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
- };
- return BufferWhenOperator;
- }());
- var BufferWhenSubscriber = (function (_super) {
- __extends(BufferWhenSubscriber, _super);
- function BufferWhenSubscriber(destination, closingSelector) {
- var _this = _super.call(this, destination) || this;
- _this.closingSelector = closingSelector;
- _this.subscribing = false;
- _this.openBuffer();
- return _this;
- }
- BufferWhenSubscriber.prototype._next = function (value) {
- this.buffer.push(value);
- };
- BufferWhenSubscriber.prototype._complete = function () {
- var buffer = this.buffer;
- if (buffer) {
- this.destination.next(buffer);
- }
- _super.prototype._complete.call(this);
- };
- BufferWhenSubscriber.prototype._unsubscribe = function () {
- this.buffer = null;
- this.subscribing = false;
- };
- BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.openBuffer();
- };
- BufferWhenSubscriber.prototype.notifyComplete = function () {
- if (this.subscribing) {
- this.complete();
- }
- else {
- this.openBuffer();
- }
- };
- BufferWhenSubscriber.prototype.openBuffer = function () {
- var closingSubscription = this.closingSubscription;
- if (closingSubscription) {
- this.remove(closingSubscription);
- closingSubscription.unsubscribe();
- }
- var buffer = this.buffer;
- if (this.buffer) {
- this.destination.next(buffer);
- }
- this.buffer = [];
- var closingNotifier = tryCatch(this.closingSelector)();
- if (closingNotifier === errorObject) {
- this.error(errorObject.e);
- }
- else {
- closingSubscription = new Subscription();
- this.closingSubscription = closingSubscription;
- this.add(closingSubscription);
- this.subscribing = true;
- closingSubscription.add(subscribeToResult(this, closingNotifier));
- this.subscribing = false;
- }
- };
- return BufferWhenSubscriber;
- }(OuterSubscriber));
-
- function catchError(selector) {
- return function catchErrorOperatorFunction(source) {
- var operator = new CatchOperator(selector);
- var caught = source.lift(operator);
- return (operator.caught = caught);
- };
- }
- var CatchOperator = (function () {
- function CatchOperator(selector) {
- this.selector = selector;
- }
- CatchOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
- };
- return CatchOperator;
- }());
- var CatchSubscriber = (function (_super) {
- __extends(CatchSubscriber, _super);
- function CatchSubscriber(destination, selector, caught) {
- var _this = _super.call(this, destination) || this;
- _this.selector = selector;
- _this.caught = caught;
- return _this;
- }
- CatchSubscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- var result = void 0;
- try {
- result = this.selector(err, this.caught);
- }
- catch (err2) {
- _super.prototype.error.call(this, err2);
- return;
- }
- this._unsubscribeAndRecycle();
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- this.add(innerSubscriber);
- subscribeToResult(this, result, undefined, undefined, innerSubscriber);
- }
- };
- return CatchSubscriber;
- }(OuterSubscriber));
-
- function combineAll(project) {
- return function (source) { return source.lift(new CombineLatestOperator(project)); };
- }
-
- function combineLatest$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- var project = null;
- if (typeof observables[observables.length - 1] === 'function') {
- project = observables.pop();
- }
- if (observables.length === 1 && isArray(observables[0])) {
- observables = observables[0].slice();
- }
- return function (source) { return source.lift.call(from([source].concat(observables)), new CombineLatestOperator(project)); };
- }
-
- function concat$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- return function (source) { return source.lift.call(concat.apply(void 0, [source].concat(observables))); };
- }
-
- function concatMap(project, resultSelector) {
- return mergeMap(project, resultSelector, 1);
- }
-
- function concatMapTo(innerObservable, resultSelector) {
- return concatMap(function () { return innerObservable; }, resultSelector);
- }
-
- function count(predicate) {
- return function (source) { return source.lift(new CountOperator(predicate, source)); };
- }
- var CountOperator = (function () {
- function CountOperator(predicate, source) {
- this.predicate = predicate;
- this.source = source;
- }
- CountOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
- };
- return CountOperator;
- }());
- var CountSubscriber = (function (_super) {
- __extends(CountSubscriber, _super);
- function CountSubscriber(destination, predicate, source) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.source = source;
- _this.count = 0;
- _this.index = 0;
- return _this;
- }
- CountSubscriber.prototype._next = function (value) {
- if (this.predicate) {
- this._tryPredicate(value);
- }
- else {
- this.count++;
- }
- };
- CountSubscriber.prototype._tryPredicate = function (value) {
- var result;
- try {
- result = this.predicate(value, this.index++, this.source);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- if (result) {
- this.count++;
- }
- };
- CountSubscriber.prototype._complete = function () {
- this.destination.next(this.count);
- this.destination.complete();
- };
- return CountSubscriber;
- }(Subscriber));
-
- function debounce(durationSelector) {
- return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
- }
- var DebounceOperator = (function () {
- function DebounceOperator(durationSelector) {
- this.durationSelector = durationSelector;
- }
- DebounceOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
- };
- return DebounceOperator;
- }());
- var DebounceSubscriber = (function (_super) {
- __extends(DebounceSubscriber, _super);
- function DebounceSubscriber(destination, durationSelector) {
- var _this = _super.call(this, destination) || this;
- _this.durationSelector = durationSelector;
- _this.hasValue = false;
- _this.durationSubscription = null;
- return _this;
- }
- DebounceSubscriber.prototype._next = function (value) {
- try {
- var result = this.durationSelector.call(this, value);
- if (result) {
- this._tryNext(value, result);
- }
- }
- catch (err) {
- this.destination.error(err);
- }
- };
- DebounceSubscriber.prototype._complete = function () {
- this.emitValue();
- this.destination.complete();
- };
- DebounceSubscriber.prototype._tryNext = function (value, duration) {
- var subscription = this.durationSubscription;
- this.value = value;
- this.hasValue = true;
- if (subscription) {
- subscription.unsubscribe();
- this.remove(subscription);
- }
- subscription = subscribeToResult(this, duration);
- if (subscription && !subscription.closed) {
- this.add(this.durationSubscription = subscription);
- }
- };
- DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.emitValue();
- };
- DebounceSubscriber.prototype.notifyComplete = function () {
- this.emitValue();
- };
- DebounceSubscriber.prototype.emitValue = function () {
- if (this.hasValue) {
- var value = this.value;
- var subscription = this.durationSubscription;
- if (subscription) {
- this.durationSubscription = null;
- subscription.unsubscribe();
- this.remove(subscription);
- }
- this.value = null;
- this.hasValue = false;
- _super.prototype._next.call(this, value);
- }
- };
- return DebounceSubscriber;
- }(OuterSubscriber));
-
- function debounceTime(dueTime, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
- }
- var DebounceTimeOperator = (function () {
- function DebounceTimeOperator(dueTime, scheduler) {
- this.dueTime = dueTime;
- this.scheduler = scheduler;
- }
- DebounceTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
- };
- return DebounceTimeOperator;
- }());
- var DebounceTimeSubscriber = (function (_super) {
- __extends(DebounceTimeSubscriber, _super);
- function DebounceTimeSubscriber(destination, dueTime, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.dueTime = dueTime;
- _this.scheduler = scheduler;
- _this.debouncedSubscription = null;
- _this.lastValue = null;
- _this.hasValue = false;
- return _this;
- }
- DebounceTimeSubscriber.prototype._next = function (value) {
- this.clearDebounce();
- this.lastValue = value;
- this.hasValue = true;
- this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext$2, this.dueTime, this));
- };
- DebounceTimeSubscriber.prototype._complete = function () {
- this.debouncedNext();
- this.destination.complete();
- };
- DebounceTimeSubscriber.prototype.debouncedNext = function () {
- this.clearDebounce();
- if (this.hasValue) {
- var lastValue = this.lastValue;
- this.lastValue = null;
- this.hasValue = false;
- this.destination.next(lastValue);
- }
- };
- DebounceTimeSubscriber.prototype.clearDebounce = function () {
- var debouncedSubscription = this.debouncedSubscription;
- if (debouncedSubscription !== null) {
- this.remove(debouncedSubscription);
- debouncedSubscription.unsubscribe();
- this.debouncedSubscription = null;
- }
- };
- return DebounceTimeSubscriber;
- }(Subscriber));
- function dispatchNext$2(subscriber) {
- subscriber.debouncedNext();
- }
-
- function defaultIfEmpty(defaultValue) {
- if (defaultValue === void 0) { defaultValue = null; }
- return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
- }
- var DefaultIfEmptyOperator = (function () {
- function DefaultIfEmptyOperator(defaultValue) {
- this.defaultValue = defaultValue;
- }
- DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
- };
- return DefaultIfEmptyOperator;
- }());
- var DefaultIfEmptySubscriber = (function (_super) {
- __extends(DefaultIfEmptySubscriber, _super);
- function DefaultIfEmptySubscriber(destination, defaultValue) {
- var _this = _super.call(this, destination) || this;
- _this.defaultValue = defaultValue;
- _this.isEmpty = true;
- return _this;
- }
- DefaultIfEmptySubscriber.prototype._next = function (value) {
- this.isEmpty = false;
- this.destination.next(value);
- };
- DefaultIfEmptySubscriber.prototype._complete = function () {
- if (this.isEmpty) {
- this.destination.next(this.defaultValue);
- }
- this.destination.complete();
- };
- return DefaultIfEmptySubscriber;
- }(Subscriber));
-
- function isDate(value) {
- return value instanceof Date && !isNaN(+value);
- }
-
- function delay(delay, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- var absoluteDelay = isDate(delay);
- var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
- return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
- }
- var DelayOperator = (function () {
- function DelayOperator(delay, scheduler) {
- this.delay = delay;
- this.scheduler = scheduler;
- }
- DelayOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
- };
- return DelayOperator;
- }());
- var DelaySubscriber = (function (_super) {
- __extends(DelaySubscriber, _super);
- function DelaySubscriber(destination, delay, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.delay = delay;
- _this.scheduler = scheduler;
- _this.queue = [];
- _this.active = false;
- _this.errored = false;
- return _this;
- }
- DelaySubscriber.dispatch = function (state) {
- var source = state.source;
- var queue = source.queue;
- var scheduler = state.scheduler;
- var destination = state.destination;
- while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
- queue.shift().notification.observe(destination);
- }
- if (queue.length > 0) {
- var delay_1 = Math.max(0, queue[0].time - scheduler.now());
- this.schedule(state, delay_1);
- }
- else {
- this.unsubscribe();
- source.active = false;
- }
- };
- DelaySubscriber.prototype._schedule = function (scheduler) {
- this.active = true;
- var destination = this.destination;
- destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
- source: this, destination: this.destination, scheduler: scheduler
- }));
- };
- DelaySubscriber.prototype.scheduleNotification = function (notification) {
- if (this.errored === true) {
- return;
- }
- var scheduler = this.scheduler;
- var message = new DelayMessage(scheduler.now() + this.delay, notification);
- this.queue.push(message);
- if (this.active === false) {
- this._schedule(scheduler);
- }
- };
- DelaySubscriber.prototype._next = function (value) {
- this.scheduleNotification(Notification.createNext(value));
- };
- DelaySubscriber.prototype._error = function (err) {
- this.errored = true;
- this.queue = [];
- this.destination.error(err);
- this.unsubscribe();
- };
- DelaySubscriber.prototype._complete = function () {
- this.scheduleNotification(Notification.createComplete());
- this.unsubscribe();
- };
- return DelaySubscriber;
- }(Subscriber));
- var DelayMessage = (function () {
- function DelayMessage(time, notification) {
- this.time = time;
- this.notification = notification;
- }
- return DelayMessage;
- }());
-
- function delayWhen(delayDurationSelector, subscriptionDelay) {
- if (subscriptionDelay) {
- return function (source) {
- return new SubscriptionDelayObservable(source, subscriptionDelay)
- .lift(new DelayWhenOperator(delayDurationSelector));
- };
- }
- return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
- }
- var DelayWhenOperator = (function () {
- function DelayWhenOperator(delayDurationSelector) {
- this.delayDurationSelector = delayDurationSelector;
- }
- DelayWhenOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
- };
- return DelayWhenOperator;
- }());
- var DelayWhenSubscriber = (function (_super) {
- __extends(DelayWhenSubscriber, _super);
- function DelayWhenSubscriber(destination, delayDurationSelector) {
- var _this = _super.call(this, destination) || this;
- _this.delayDurationSelector = delayDurationSelector;
- _this.completed = false;
- _this.delayNotifierSubscriptions = [];
- _this.index = 0;
- return _this;
- }
- DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(outerValue);
- this.removeSubscription(innerSub);
- this.tryComplete();
- };
- DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
- this._error(error);
- };
- DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
- var value = this.removeSubscription(innerSub);
- if (value) {
- this.destination.next(value);
- }
- this.tryComplete();
- };
- DelayWhenSubscriber.prototype._next = function (value) {
- var index = this.index++;
- try {
- var delayNotifier = this.delayDurationSelector(value, index);
- if (delayNotifier) {
- this.tryDelay(delayNotifier, value);
- }
- }
- catch (err) {
- this.destination.error(err);
- }
- };
- DelayWhenSubscriber.prototype._complete = function () {
- this.completed = true;
- this.tryComplete();
- this.unsubscribe();
- };
- DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
- subscription.unsubscribe();
- var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
- if (subscriptionIdx !== -1) {
- this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
- }
- return subscription.outerValue;
- };
- DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
- var notifierSubscription = subscribeToResult(this, delayNotifier, value);
- if (notifierSubscription && !notifierSubscription.closed) {
- var destination = this.destination;
- destination.add(notifierSubscription);
- this.delayNotifierSubscriptions.push(notifierSubscription);
- }
- };
- DelayWhenSubscriber.prototype.tryComplete = function () {
- if (this.completed && this.delayNotifierSubscriptions.length === 0) {
- this.destination.complete();
- }
- };
- return DelayWhenSubscriber;
- }(OuterSubscriber));
- var SubscriptionDelayObservable = (function (_super) {
- __extends(SubscriptionDelayObservable, _super);
- function SubscriptionDelayObservable(source, subscriptionDelay) {
- var _this = _super.call(this) || this;
- _this.source = source;
- _this.subscriptionDelay = subscriptionDelay;
- return _this;
- }
- SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
- this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
- };
- return SubscriptionDelayObservable;
- }(Observable));
- var SubscriptionDelaySubscriber = (function (_super) {
- __extends(SubscriptionDelaySubscriber, _super);
- function SubscriptionDelaySubscriber(parent, source) {
- var _this = _super.call(this) || this;
- _this.parent = parent;
- _this.source = source;
- _this.sourceSubscribed = false;
- return _this;
- }
- SubscriptionDelaySubscriber.prototype._next = function (unused) {
- this.subscribeToSource();
- };
- SubscriptionDelaySubscriber.prototype._error = function (err) {
- this.unsubscribe();
- this.parent.error(err);
- };
- SubscriptionDelaySubscriber.prototype._complete = function () {
- this.unsubscribe();
- this.subscribeToSource();
- };
- SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
- if (!this.sourceSubscribed) {
- this.sourceSubscribed = true;
- this.unsubscribe();
- this.source.subscribe(this.parent);
- }
- };
- return SubscriptionDelaySubscriber;
- }(Subscriber));
-
- function dematerialize() {
- return function dematerializeOperatorFunction(source) {
- return source.lift(new DeMaterializeOperator());
- };
- }
- var DeMaterializeOperator = (function () {
- function DeMaterializeOperator() {
- }
- DeMaterializeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DeMaterializeSubscriber(subscriber));
- };
- return DeMaterializeOperator;
- }());
- var DeMaterializeSubscriber = (function (_super) {
- __extends(DeMaterializeSubscriber, _super);
- function DeMaterializeSubscriber(destination) {
- return _super.call(this, destination) || this;
- }
- DeMaterializeSubscriber.prototype._next = function (value) {
- value.observe(this.destination);
- };
- return DeMaterializeSubscriber;
- }(Subscriber));
-
- function distinct(keySelector, flushes) {
- return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
- }
- var DistinctOperator = (function () {
- function DistinctOperator(keySelector, flushes) {
- this.keySelector = keySelector;
- this.flushes = flushes;
- }
- DistinctOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
- };
- return DistinctOperator;
- }());
- var DistinctSubscriber = (function (_super) {
- __extends(DistinctSubscriber, _super);
- function DistinctSubscriber(destination, keySelector, flushes) {
- var _this = _super.call(this, destination) || this;
- _this.keySelector = keySelector;
- _this.values = new Set();
- if (flushes) {
- _this.add(subscribeToResult(_this, flushes));
- }
- return _this;
- }
- DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.values.clear();
- };
- DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
- this._error(error);
- };
- DistinctSubscriber.prototype._next = function (value) {
- if (this.keySelector) {
- this._useKeySelector(value);
- }
- else {
- this._finalizeNext(value, value);
- }
- };
- DistinctSubscriber.prototype._useKeySelector = function (value) {
- var key;
- var destination = this.destination;
- try {
- key = this.keySelector(value);
- }
- catch (err) {
- destination.error(err);
- return;
- }
- this._finalizeNext(key, value);
- };
- DistinctSubscriber.prototype._finalizeNext = function (key, value) {
- var values = this.values;
- if (!values.has(key)) {
- values.add(key);
- this.destination.next(value);
- }
- };
- return DistinctSubscriber;
- }(OuterSubscriber));
-
- function distinctUntilChanged(compare, keySelector) {
- return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
- }
- var DistinctUntilChangedOperator = (function () {
- function DistinctUntilChangedOperator(compare, keySelector) {
- this.compare = compare;
- this.keySelector = keySelector;
- }
- DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
- };
- return DistinctUntilChangedOperator;
- }());
- var DistinctUntilChangedSubscriber = (function (_super) {
- __extends(DistinctUntilChangedSubscriber, _super);
- function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
- var _this = _super.call(this, destination) || this;
- _this.keySelector = keySelector;
- _this.hasKey = false;
- if (typeof compare === 'function') {
- _this.compare = compare;
- }
- return _this;
- }
- DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
- return x === y;
- };
- DistinctUntilChangedSubscriber.prototype._next = function (value) {
- var keySelector = this.keySelector;
- var key = value;
- if (keySelector) {
- key = tryCatch(this.keySelector)(value);
- if (key === errorObject) {
- return this.destination.error(errorObject.e);
- }
- }
- var result = false;
- if (this.hasKey) {
- result = tryCatch(this.compare)(this.key, key);
- if (result === errorObject) {
- return this.destination.error(errorObject.e);
- }
- }
- else {
- this.hasKey = true;
- }
- if (Boolean(result) === false) {
- this.key = key;
- this.destination.next(value);
- }
- };
- return DistinctUntilChangedSubscriber;
- }(Subscriber));
-
- function distinctUntilKeyChanged(key, compare) {
- return distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
- }
-
- function filter(predicate, thisArg) {
- return function filterOperatorFunction(source) {
- return source.lift(new FilterOperator(predicate, thisArg));
- };
- }
- var FilterOperator = (function () {
- function FilterOperator(predicate, thisArg) {
- this.predicate = predicate;
- this.thisArg = thisArg;
- }
- FilterOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
- };
- return FilterOperator;
- }());
- var FilterSubscriber = (function (_super) {
- __extends(FilterSubscriber, _super);
- function FilterSubscriber(destination, predicate, thisArg) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.thisArg = thisArg;
- _this.count = 0;
- return _this;
- }
- FilterSubscriber.prototype._next = function (value) {
- var result;
- try {
- result = this.predicate.call(this.thisArg, value, this.count++);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- if (result) {
- this.destination.next(value);
- }
- };
- return FilterSubscriber;
- }(Subscriber));
-
- function tap(nextOrObserver, error, complete) {
- return function tapOperatorFunction(source) {
- return source.lift(new DoOperator(nextOrObserver, error, complete));
- };
- }
- var DoOperator = (function () {
- function DoOperator(nextOrObserver, error, complete) {
- this.nextOrObserver = nextOrObserver;
- this.error = error;
- this.complete = complete;
- }
- DoOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
- };
- return DoOperator;
- }());
- var TapSubscriber = (function (_super) {
- __extends(TapSubscriber, _super);
- function TapSubscriber(destination, observerOrNext, error, complete) {
- var _this = _super.call(this, destination) || this;
- _this._tapNext = noop;
- _this._tapError = noop;
- _this._tapComplete = noop;
- _this._tapError = error || noop;
- _this._tapComplete = complete || noop;
- if (isFunction(observerOrNext)) {
- _this._context = _this;
- _this._tapNext = observerOrNext;
- }
- else if (observerOrNext) {
- _this._context = observerOrNext;
- _this._tapNext = observerOrNext.next || noop;
- _this._tapError = observerOrNext.error || noop;
- _this._tapComplete = observerOrNext.complete || noop;
- }
- return _this;
- }
- TapSubscriber.prototype._next = function (value) {
- try {
- this._tapNext.call(this._context, value);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(value);
- };
- TapSubscriber.prototype._error = function (err) {
- try {
- this._tapError.call(this._context, err);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.error(err);
- };
- TapSubscriber.prototype._complete = function () {
- try {
- this._tapComplete.call(this._context);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- return this.destination.complete();
- };
- return TapSubscriber;
- }(Subscriber));
-
- var throwIfEmpty = function (errorFactory) {
- if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
- return tap({
- hasValue: false,
- next: function () { this.hasValue = true; },
- complete: function () {
- if (!this.hasValue) {
- throw errorFactory();
- }
- }
- });
- };
- function defaultErrorFactory() {
- return new EmptyError();
- }
-
- function take(count) {
- return function (source) {
- if (count === 0) {
- return empty$1();
- }
- else {
- return source.lift(new TakeOperator(count));
- }
- };
- }
- var TakeOperator = (function () {
- function TakeOperator(total) {
- this.total = total;
- if (this.total < 0) {
- throw new ArgumentOutOfRangeError;
- }
- }
- TakeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new TakeSubscriber(subscriber, this.total));
- };
- return TakeOperator;
- }());
- var TakeSubscriber = (function (_super) {
- __extends(TakeSubscriber, _super);
- function TakeSubscriber(destination, total) {
- var _this = _super.call(this, destination) || this;
- _this.total = total;
- _this.count = 0;
- return _this;
- }
- TakeSubscriber.prototype._next = function (value) {
- var total = this.total;
- var count = ++this.count;
- if (count <= total) {
- this.destination.next(value);
- if (count === total) {
- this.destination.complete();
- this.unsubscribe();
- }
- }
- };
- return TakeSubscriber;
- }(Subscriber));
-
- function elementAt(index, defaultValue) {
- if (index < 0) {
- throw new ArgumentOutOfRangeError();
- }
- var hasDefaultValue = arguments.length >= 2;
- return function (source) { return source.pipe(filter(function (v, i) { return i === index; }), take(1), hasDefaultValue
- ? defaultIfEmpty(defaultValue)
- : throwIfEmpty(function () { return new ArgumentOutOfRangeError(); })); };
- }
-
- function endWith() {
- var array = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- array[_i] = arguments[_i];
- }
- return function (source) {
- var scheduler = array[array.length - 1];
- if (isScheduler(scheduler)) {
- array.pop();
- }
- else {
- scheduler = null;
- }
- var len = array.length;
- if (len === 1 && !scheduler) {
- return concat(source, scalar(array[0]));
- }
- else if (len > 0) {
- return concat(source, fromArray(array, scheduler));
- }
- else {
- return concat(source, empty$1(scheduler));
- }
- };
- }
-
- function every(predicate, thisArg) {
- return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
- }
- var EveryOperator = (function () {
- function EveryOperator(predicate, thisArg, source) {
- this.predicate = predicate;
- this.thisArg = thisArg;
- this.source = source;
- }
- EveryOperator.prototype.call = function (observer, source) {
- return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
- };
- return EveryOperator;
- }());
- var EverySubscriber = (function (_super) {
- __extends(EverySubscriber, _super);
- function EverySubscriber(destination, predicate, thisArg, source) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.thisArg = thisArg;
- _this.source = source;
- _this.index = 0;
- _this.thisArg = thisArg || _this;
- return _this;
- }
- EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
- this.destination.next(everyValueMatch);
- this.destination.complete();
- };
- EverySubscriber.prototype._next = function (value) {
- var result = false;
- try {
- result = this.predicate.call(this.thisArg, value, this.index++, this.source);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- if (!result) {
- this.notifyComplete(false);
- }
- };
- EverySubscriber.prototype._complete = function () {
- this.notifyComplete(true);
- };
- return EverySubscriber;
- }(Subscriber));
-
- function exhaust() {
- return function (source) { return source.lift(new SwitchFirstOperator()); };
- }
- var SwitchFirstOperator = (function () {
- function SwitchFirstOperator() {
- }
- SwitchFirstOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SwitchFirstSubscriber(subscriber));
- };
- return SwitchFirstOperator;
- }());
- var SwitchFirstSubscriber = (function (_super) {
- __extends(SwitchFirstSubscriber, _super);
- function SwitchFirstSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.hasCompleted = false;
- _this.hasSubscription = false;
- return _this;
- }
- SwitchFirstSubscriber.prototype._next = function (value) {
- if (!this.hasSubscription) {
- this.hasSubscription = true;
- this.add(subscribeToResult(this, value));
- }
- };
- SwitchFirstSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (!this.hasSubscription) {
- this.destination.complete();
- }
- };
- SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
- this.remove(innerSub);
- this.hasSubscription = false;
- if (this.hasCompleted) {
- this.destination.complete();
- }
- };
- return SwitchFirstSubscriber;
- }(OuterSubscriber));
-
- function exhaustMap(project, resultSelector) {
- if (resultSelector) {
- return function (source) { return source.pipe(exhaustMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
- }
- return function (source) {
- return source.lift(new ExhauseMapOperator(project));
- };
- }
- var ExhauseMapOperator = (function () {
- function ExhauseMapOperator(project) {
- this.project = project;
- }
- ExhauseMapOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
- };
- return ExhauseMapOperator;
- }());
- var ExhaustMapSubscriber = (function (_super) {
- __extends(ExhaustMapSubscriber, _super);
- function ExhaustMapSubscriber(destination, project) {
- var _this = _super.call(this, destination) || this;
- _this.project = project;
- _this.hasSubscription = false;
- _this.hasCompleted = false;
- _this.index = 0;
- return _this;
- }
- ExhaustMapSubscriber.prototype._next = function (value) {
- if (!this.hasSubscription) {
- this.tryNext(value);
- }
- };
- ExhaustMapSubscriber.prototype.tryNext = function (value) {
- var result;
- var index = this.index++;
- try {
- result = this.project(value, index);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.hasSubscription = true;
- this._innerSub(result, value, index);
- };
- ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- subscribeToResult(this, result, value, index, innerSubscriber);
- };
- ExhaustMapSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (!this.hasSubscription) {
- this.destination.complete();
- }
- this.unsubscribe();
- };
- ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(innerValue);
- };
- ExhaustMapSubscriber.prototype.notifyError = function (err) {
- this.destination.error(err);
- };
- ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
- var destination = this.destination;
- destination.remove(innerSub);
- this.hasSubscription = false;
- if (this.hasCompleted) {
- this.destination.complete();
- }
- };
- return ExhaustMapSubscriber;
- }(OuterSubscriber));
-
- function expand(project, concurrent, scheduler) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- if (scheduler === void 0) { scheduler = undefined; }
- concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
- return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
- }
- var ExpandOperator = (function () {
- function ExpandOperator(project, concurrent, scheduler) {
- this.project = project;
- this.concurrent = concurrent;
- this.scheduler = scheduler;
- }
- ExpandOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
- };
- return ExpandOperator;
- }());
- var ExpandSubscriber = (function (_super) {
- __extends(ExpandSubscriber, _super);
- function ExpandSubscriber(destination, project, concurrent, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.project = project;
- _this.concurrent = concurrent;
- _this.scheduler = scheduler;
- _this.index = 0;
- _this.active = 0;
- _this.hasCompleted = false;
- if (concurrent < Number.POSITIVE_INFINITY) {
- _this.buffer = [];
- }
- return _this;
- }
- ExpandSubscriber.dispatch = function (arg) {
- var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
- subscriber.subscribeToProjection(result, value, index);
- };
- ExpandSubscriber.prototype._next = function (value) {
- var destination = this.destination;
- if (destination.closed) {
- this._complete();
- return;
- }
- var index = this.index++;
- if (this.active < this.concurrent) {
- destination.next(value);
- var result = tryCatch(this.project)(value, index);
- if (result === errorObject) {
- destination.error(errorObject.e);
- }
- else if (!this.scheduler) {
- this.subscribeToProjection(result, value, index);
- }
- else {
- var state = { subscriber: this, result: result, value: value, index: index };
- var destination_1 = this.destination;
- destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
- }
- }
- else {
- this.buffer.push(value);
- }
- };
- ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
- this.active++;
- var destination = this.destination;
- destination.add(subscribeToResult(this, result, value, index));
- };
- ExpandSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (this.hasCompleted && this.active === 0) {
- this.destination.complete();
- }
- this.unsubscribe();
- };
- ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this._next(innerValue);
- };
- ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
- var buffer = this.buffer;
- var destination = this.destination;
- destination.remove(innerSub);
- this.active--;
- if (buffer && buffer.length > 0) {
- this._next(buffer.shift());
- }
- if (this.hasCompleted && this.active === 0) {
- this.destination.complete();
- }
- };
- return ExpandSubscriber;
- }(OuterSubscriber));
-
- function finalize(callback) {
- return function (source) { return source.lift(new FinallyOperator(callback)); };
- }
- var FinallyOperator = (function () {
- function FinallyOperator(callback) {
- this.callback = callback;
- }
- FinallyOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new FinallySubscriber(subscriber, this.callback));
- };
- return FinallyOperator;
- }());
- var FinallySubscriber = (function (_super) {
- __extends(FinallySubscriber, _super);
- function FinallySubscriber(destination, callback) {
- var _this = _super.call(this, destination) || this;
- _this.add(new Subscription(callback));
- return _this;
- }
- return FinallySubscriber;
- }(Subscriber));
-
- function find(predicate, thisArg) {
- if (typeof predicate !== 'function') {
- throw new TypeError('predicate is not a function');
- }
- return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
- }
- var FindValueOperator = (function () {
- function FindValueOperator(predicate, source, yieldIndex, thisArg) {
- this.predicate = predicate;
- this.source = source;
- this.yieldIndex = yieldIndex;
- this.thisArg = thisArg;
- }
- FindValueOperator.prototype.call = function (observer, source) {
- return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
- };
- return FindValueOperator;
- }());
- var FindValueSubscriber = (function (_super) {
- __extends(FindValueSubscriber, _super);
- function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.source = source;
- _this.yieldIndex = yieldIndex;
- _this.thisArg = thisArg;
- _this.index = 0;
- return _this;
- }
- FindValueSubscriber.prototype.notifyComplete = function (value) {
- var destination = this.destination;
- destination.next(value);
- destination.complete();
- this.unsubscribe();
- };
- FindValueSubscriber.prototype._next = function (value) {
- var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
- var index = this.index++;
- try {
- var result = predicate.call(thisArg || this, value, index, this.source);
- if (result) {
- this.notifyComplete(this.yieldIndex ? index : value);
- }
- }
- catch (err) {
- this.destination.error(err);
- }
- };
- FindValueSubscriber.prototype._complete = function () {
- this.notifyComplete(this.yieldIndex ? -1 : undefined);
- };
- return FindValueSubscriber;
- }(Subscriber));
-
- function findIndex(predicate, thisArg) {
- return function (source) { return source.lift(new FindValueOperator(predicate, source, true, thisArg)); };
- }
-
- function first(predicate, defaultValue) {
- var hasDefaultValue = arguments.length >= 2;
- return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
- }
-
- function ignoreElements() {
- return function ignoreElementsOperatorFunction(source) {
- return source.lift(new IgnoreElementsOperator());
- };
- }
- var IgnoreElementsOperator = (function () {
- function IgnoreElementsOperator() {
- }
- IgnoreElementsOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new IgnoreElementsSubscriber(subscriber));
- };
- return IgnoreElementsOperator;
- }());
- var IgnoreElementsSubscriber = (function (_super) {
- __extends(IgnoreElementsSubscriber, _super);
- function IgnoreElementsSubscriber() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- IgnoreElementsSubscriber.prototype._next = function (unused) {
- };
- return IgnoreElementsSubscriber;
- }(Subscriber));
-
- function isEmpty() {
- return function (source) { return source.lift(new IsEmptyOperator()); };
- }
- var IsEmptyOperator = (function () {
- function IsEmptyOperator() {
- }
- IsEmptyOperator.prototype.call = function (observer, source) {
- return source.subscribe(new IsEmptySubscriber(observer));
- };
- return IsEmptyOperator;
- }());
- var IsEmptySubscriber = (function (_super) {
- __extends(IsEmptySubscriber, _super);
- function IsEmptySubscriber(destination) {
- return _super.call(this, destination) || this;
- }
- IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
- var destination = this.destination;
- destination.next(isEmpty);
- destination.complete();
- };
- IsEmptySubscriber.prototype._next = function (value) {
- this.notifyComplete(false);
- };
- IsEmptySubscriber.prototype._complete = function () {
- this.notifyComplete(true);
- };
- return IsEmptySubscriber;
- }(Subscriber));
-
- function takeLast(count) {
- return function takeLastOperatorFunction(source) {
- if (count === 0) {
- return empty$1();
- }
- else {
- return source.lift(new TakeLastOperator(count));
- }
- };
- }
- var TakeLastOperator = (function () {
- function TakeLastOperator(total) {
- this.total = total;
- if (this.total < 0) {
- throw new ArgumentOutOfRangeError;
- }
- }
- TakeLastOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
- };
- return TakeLastOperator;
- }());
- var TakeLastSubscriber = (function (_super) {
- __extends(TakeLastSubscriber, _super);
- function TakeLastSubscriber(destination, total) {
- var _this = _super.call(this, destination) || this;
- _this.total = total;
- _this.ring = new Array();
- _this.count = 0;
- return _this;
- }
- TakeLastSubscriber.prototype._next = function (value) {
- var ring = this.ring;
- var total = this.total;
- var count = this.count++;
- if (ring.length < total) {
- ring.push(value);
- }
- else {
- var index = count % total;
- ring[index] = value;
- }
- };
- TakeLastSubscriber.prototype._complete = function () {
- var destination = this.destination;
- var count = this.count;
- if (count > 0) {
- var total = this.count >= this.total ? this.total : this.count;
- var ring = this.ring;
- for (var i = 0; i < total; i++) {
- var idx = (count++) % total;
- destination.next(ring[idx]);
- }
- }
- destination.complete();
- };
- return TakeLastSubscriber;
- }(Subscriber));
-
- function last(predicate, defaultValue) {
- var hasDefaultValue = arguments.length >= 2;
- return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
- }
-
- function mapTo(value) {
- return function (source) { return source.lift(new MapToOperator(value)); };
- }
- var MapToOperator = (function () {
- function MapToOperator(value) {
- this.value = value;
- }
- MapToOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new MapToSubscriber(subscriber, this.value));
- };
- return MapToOperator;
- }());
- var MapToSubscriber = (function (_super) {
- __extends(MapToSubscriber, _super);
- function MapToSubscriber(destination, value) {
- var _this = _super.call(this, destination) || this;
- _this.value = value;
- return _this;
- }
- MapToSubscriber.prototype._next = function (x) {
- this.destination.next(this.value);
- };
- return MapToSubscriber;
- }(Subscriber));
-
- function materialize() {
- return function materializeOperatorFunction(source) {
- return source.lift(new MaterializeOperator());
- };
- }
- var MaterializeOperator = (function () {
- function MaterializeOperator() {
- }
- MaterializeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new MaterializeSubscriber(subscriber));
- };
- return MaterializeOperator;
- }());
- var MaterializeSubscriber = (function (_super) {
- __extends(MaterializeSubscriber, _super);
- function MaterializeSubscriber(destination) {
- return _super.call(this, destination) || this;
- }
- MaterializeSubscriber.prototype._next = function (value) {
- this.destination.next(Notification.createNext(value));
- };
- MaterializeSubscriber.prototype._error = function (err) {
- var destination = this.destination;
- destination.next(Notification.createError(err));
- destination.complete();
- };
- MaterializeSubscriber.prototype._complete = function () {
- var destination = this.destination;
- destination.next(Notification.createComplete());
- destination.complete();
- };
- return MaterializeSubscriber;
- }(Subscriber));
-
- function scan(accumulator, seed) {
- var hasSeed = false;
- if (arguments.length >= 2) {
- hasSeed = true;
- }
- return function scanOperatorFunction(source) {
- return source.lift(new ScanOperator(accumulator, seed, hasSeed));
- };
- }
- var ScanOperator = (function () {
- function ScanOperator(accumulator, seed, hasSeed) {
- if (hasSeed === void 0) { hasSeed = false; }
- this.accumulator = accumulator;
- this.seed = seed;
- this.hasSeed = hasSeed;
- }
- ScanOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
- };
- return ScanOperator;
- }());
- var ScanSubscriber = (function (_super) {
- __extends(ScanSubscriber, _super);
- function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
- var _this = _super.call(this, destination) || this;
- _this.accumulator = accumulator;
- _this._seed = _seed;
- _this.hasSeed = hasSeed;
- _this.index = 0;
- return _this;
- }
- Object.defineProperty(ScanSubscriber.prototype, "seed", {
- get: function () {
- return this._seed;
- },
- set: function (value) {
- this.hasSeed = true;
- this._seed = value;
- },
- enumerable: true,
- configurable: true
- });
- ScanSubscriber.prototype._next = function (value) {
- if (!this.hasSeed) {
- this.seed = value;
- this.destination.next(value);
- }
- else {
- return this._tryNext(value);
- }
- };
- ScanSubscriber.prototype._tryNext = function (value) {
- var index = this.index++;
- var result;
- try {
- result = this.accumulator(this.seed, value, index);
- }
- catch (err) {
- this.destination.error(err);
- }
- this.seed = result;
- this.destination.next(result);
- };
- return ScanSubscriber;
- }(Subscriber));
-
- function reduce(accumulator, seed) {
- if (arguments.length >= 2) {
- return function reduceOperatorFunctionWithSeed(source) {
- return pipe(scan(accumulator, seed), takeLast(1), defaultIfEmpty(seed))(source);
- };
- }
- return function reduceOperatorFunction(source) {
- return pipe(scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast(1))(source);
- };
- }
-
- function max(comparer) {
- var max = (typeof comparer === 'function')
- ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
- : function (x, y) { return x > y ? x : y; };
- return reduce(max);
- }
-
- function merge$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- return function (source) { return source.lift.call(merge.apply(void 0, [source].concat(observables))); };
- }
-
- function mergeMapTo(innerObservable, resultSelector, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- if (typeof resultSelector === 'function') {
- return mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
- }
- if (typeof resultSelector === 'number') {
- concurrent = resultSelector;
- }
- return mergeMap(function () { return innerObservable; }, concurrent);
- }
-
- function mergeScan(accumulator, seed, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
- }
- var MergeScanOperator = (function () {
- function MergeScanOperator(accumulator, seed, concurrent) {
- this.accumulator = accumulator;
- this.seed = seed;
- this.concurrent = concurrent;
- }
- MergeScanOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
- };
- return MergeScanOperator;
- }());
- var MergeScanSubscriber = (function (_super) {
- __extends(MergeScanSubscriber, _super);
- function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
- var _this = _super.call(this, destination) || this;
- _this.accumulator = accumulator;
- _this.acc = acc;
- _this.concurrent = concurrent;
- _this.hasValue = false;
- _this.hasCompleted = false;
- _this.buffer = [];
- _this.active = 0;
- _this.index = 0;
- return _this;
- }
- MergeScanSubscriber.prototype._next = function (value) {
- if (this.active < this.concurrent) {
- var index = this.index++;
- var ish = tryCatch(this.accumulator)(this.acc, value);
- var destination = this.destination;
- if (ish === errorObject) {
- destination.error(errorObject.e);
- }
- else {
- this.active++;
- this._innerSub(ish, value, index);
- }
- }
- else {
- this.buffer.push(value);
- }
- };
- MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- subscribeToResult(this, ish, value, index, innerSubscriber);
- };
- MergeScanSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (this.active === 0 && this.buffer.length === 0) {
- if (this.hasValue === false) {
- this.destination.next(this.acc);
- }
- this.destination.complete();
- }
- this.unsubscribe();
- };
- MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- var destination = this.destination;
- this.acc = innerValue;
- this.hasValue = true;
- destination.next(innerValue);
- };
- MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
- var buffer = this.buffer;
- var destination = this.destination;
- destination.remove(innerSub);
- this.active--;
- if (buffer.length > 0) {
- this._next(buffer.shift());
- }
- else if (this.active === 0 && this.hasCompleted) {
- if (this.hasValue === false) {
- this.destination.next(this.acc);
- }
- this.destination.complete();
- }
- };
- return MergeScanSubscriber;
- }(OuterSubscriber));
-
- function min(comparer) {
- var min = (typeof comparer === 'function')
- ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
- : function (x, y) { return x < y ? x : y; };
- return reduce(min);
- }
-
- function multicast(subjectOrSubjectFactory, selector) {
- return function multicastOperatorFunction(source) {
- var subjectFactory;
- if (typeof subjectOrSubjectFactory === 'function') {
- subjectFactory = subjectOrSubjectFactory;
- }
- else {
- subjectFactory = function subjectFactory() {
- return subjectOrSubjectFactory;
- };
- }
- if (typeof selector === 'function') {
- return source.lift(new MulticastOperator(subjectFactory, selector));
- }
- var connectable = Object.create(source, connectableObservableDescriptor);
- connectable.source = source;
- connectable.subjectFactory = subjectFactory;
- return connectable;
- };
- }
- var MulticastOperator = (function () {
- function MulticastOperator(subjectFactory, selector) {
- this.subjectFactory = subjectFactory;
- this.selector = selector;
- }
- MulticastOperator.prototype.call = function (subscriber, source) {
- var selector = this.selector;
- var subject = this.subjectFactory();
- var subscription = selector(subject).subscribe(subscriber);
- subscription.add(source.subscribe(subject));
- return subscription;
- };
- return MulticastOperator;
- }());
-
- function onErrorResumeNext$1() {
- var nextSources = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- nextSources[_i] = arguments[_i];
- }
- if (nextSources.length === 1 && isArray(nextSources[0])) {
- nextSources = nextSources[0];
- }
- return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
- }
-
- var OnErrorResumeNextOperator = (function () {
- function OnErrorResumeNextOperator(nextSources) {
- this.nextSources = nextSources;
- }
- OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
- };
- return OnErrorResumeNextOperator;
- }());
- var OnErrorResumeNextSubscriber = (function (_super) {
- __extends(OnErrorResumeNextSubscriber, _super);
- function OnErrorResumeNextSubscriber(destination, nextSources) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- _this.nextSources = nextSources;
- return _this;
- }
- OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
- this.subscribeToNextSource();
- };
- OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
- this.subscribeToNextSource();
- };
- OnErrorResumeNextSubscriber.prototype._error = function (err) {
- this.subscribeToNextSource();
- this.unsubscribe();
- };
- OnErrorResumeNextSubscriber.prototype._complete = function () {
- this.subscribeToNextSource();
- this.unsubscribe();
- };
- OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
- var next = this.nextSources.shift();
- if (next) {
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- subscribeToResult(this, next, undefined, undefined, innerSubscriber);
- }
- else {
- this.destination.complete();
- }
- };
- return OnErrorResumeNextSubscriber;
- }(OuterSubscriber));
-
- function pairwise() {
- return function (source) { return source.lift(new PairwiseOperator()); };
- }
- var PairwiseOperator = (function () {
- function PairwiseOperator() {
- }
- PairwiseOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new PairwiseSubscriber(subscriber));
- };
- return PairwiseOperator;
- }());
- var PairwiseSubscriber = (function (_super) {
- __extends(PairwiseSubscriber, _super);
- function PairwiseSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.hasPrev = false;
- return _this;
- }
- PairwiseSubscriber.prototype._next = function (value) {
- if (this.hasPrev) {
- this.destination.next([this.prev, value]);
- }
- else {
- this.hasPrev = true;
- }
- this.prev = value;
- };
- return PairwiseSubscriber;
- }(Subscriber));
-
- function not(pred, thisArg) {
- function notPred() {
- return !(notPred.pred.apply(notPred.thisArg, arguments));
- }
- notPred.pred = pred;
- notPred.thisArg = thisArg;
- return notPred;
- }
-
- function partition(predicate, thisArg) {
- return function (source) { return [
- filter(predicate, thisArg)(source),
- filter(not(predicate, thisArg))(source)
- ]; };
- }
-
- function pluck() {
- var properties = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- properties[_i] = arguments[_i];
- }
- var length = properties.length;
- if (length === 0) {
- throw new Error('list of properties cannot be empty.');
- }
- return function (source) { return map(plucker(properties, length))(source); };
- }
- function plucker(props, length) {
- var mapper = function (x) {
- var currentProp = x;
- for (var i = 0; i < length; i++) {
- var p = currentProp[props[i]];
- if (typeof p !== 'undefined') {
- currentProp = p;
- }
- else {
- return undefined;
- }
- }
- return currentProp;
- };
- return mapper;
- }
-
- function publish(selector) {
- return selector ?
- multicast(function () { return new Subject(); }, selector) :
- multicast(new Subject());
- }
-
- function publishBehavior(value) {
- return function (source) { return multicast(new BehaviorSubject(value))(source); };
- }
-
- function publishLast() {
- return function (source) { return multicast(new AsyncSubject())(source); };
- }
-
- function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
- if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
- scheduler = selectorOrScheduler;
- }
- var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
- var subject = new ReplaySubject(bufferSize, windowTime, scheduler);
- return function (source) { return multicast(function () { return subject; }, selector)(source); };
- }
-
- function race$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- return function raceOperatorFunction(source) {
- if (observables.length === 1 && isArray(observables[0])) {
- observables = observables[0];
- }
- return source.lift.call(race.apply(void 0, [source].concat(observables)));
- };
- }
-
- function repeat(count) {
- if (count === void 0) { count = -1; }
- return function (source) {
- if (count === 0) {
- return empty$1();
- }
- else if (count < 0) {
- return source.lift(new RepeatOperator(-1, source));
- }
- else {
- return source.lift(new RepeatOperator(count - 1, source));
- }
- };
- }
- var RepeatOperator = (function () {
- function RepeatOperator(count, source) {
- this.count = count;
- this.source = source;
- }
- RepeatOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
- };
- return RepeatOperator;
- }());
- var RepeatSubscriber = (function (_super) {
- __extends(RepeatSubscriber, _super);
- function RepeatSubscriber(destination, count, source) {
- var _this = _super.call(this, destination) || this;
- _this.count = count;
- _this.source = source;
- return _this;
- }
- RepeatSubscriber.prototype.complete = function () {
- if (!this.isStopped) {
- var _a = this, source = _a.source, count = _a.count;
- if (count === 0) {
- return _super.prototype.complete.call(this);
- }
- else if (count > -1) {
- this.count = count - 1;
- }
- source.subscribe(this._unsubscribeAndRecycle());
- }
- };
- return RepeatSubscriber;
- }(Subscriber));
-
- function repeatWhen(notifier) {
- return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
- }
- var RepeatWhenOperator = (function () {
- function RepeatWhenOperator(notifier) {
- this.notifier = notifier;
- }
- RepeatWhenOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
- };
- return RepeatWhenOperator;
- }());
- var RepeatWhenSubscriber = (function (_super) {
- __extends(RepeatWhenSubscriber, _super);
- function RepeatWhenSubscriber(destination, notifier, source) {
- var _this = _super.call(this, destination) || this;
- _this.notifier = notifier;
- _this.source = source;
- _this.sourceIsBeingSubscribedTo = true;
- return _this;
- }
- RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.sourceIsBeingSubscribedTo = true;
- this.source.subscribe(this);
- };
- RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
- if (this.sourceIsBeingSubscribedTo === false) {
- return _super.prototype.complete.call(this);
- }
- };
- RepeatWhenSubscriber.prototype.complete = function () {
- this.sourceIsBeingSubscribedTo = false;
- if (!this.isStopped) {
- if (!this.retries) {
- this.subscribeToRetries();
- }
- if (!this.retriesSubscription || this.retriesSubscription.closed) {
- return _super.prototype.complete.call(this);
- }
- this._unsubscribeAndRecycle();
- this.notifications.next();
- }
- };
- RepeatWhenSubscriber.prototype._unsubscribe = function () {
- var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
- if (notifications) {
- notifications.unsubscribe();
- this.notifications = null;
- }
- if (retriesSubscription) {
- retriesSubscription.unsubscribe();
- this.retriesSubscription = null;
- }
- this.retries = null;
- };
- RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
- var _unsubscribe = this._unsubscribe;
- this._unsubscribe = null;
- _super.prototype._unsubscribeAndRecycle.call(this);
- this._unsubscribe = _unsubscribe;
- return this;
- };
- RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
- this.notifications = new Subject();
- var retries = tryCatch(this.notifier)(this.notifications);
- if (retries === errorObject) {
- return _super.prototype.complete.call(this);
- }
- this.retries = retries;
- this.retriesSubscription = subscribeToResult(this, retries);
- };
- return RepeatWhenSubscriber;
- }(OuterSubscriber));
-
- function retry(count) {
- if (count === void 0) { count = -1; }
- return function (source) { return source.lift(new RetryOperator(count, source)); };
- }
- var RetryOperator = (function () {
- function RetryOperator(count, source) {
- this.count = count;
- this.source = source;
- }
- RetryOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
- };
- return RetryOperator;
- }());
- var RetrySubscriber = (function (_super) {
- __extends(RetrySubscriber, _super);
- function RetrySubscriber(destination, count, source) {
- var _this = _super.call(this, destination) || this;
- _this.count = count;
- _this.source = source;
- return _this;
- }
- RetrySubscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- var _a = this, source = _a.source, count = _a.count;
- if (count === 0) {
- return _super.prototype.error.call(this, err);
- }
- else if (count > -1) {
- this.count = count - 1;
- }
- source.subscribe(this._unsubscribeAndRecycle());
- }
- };
- return RetrySubscriber;
- }(Subscriber));
-
- function retryWhen(notifier) {
- return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
- }
- var RetryWhenOperator = (function () {
- function RetryWhenOperator(notifier, source) {
- this.notifier = notifier;
- this.source = source;
- }
- RetryWhenOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
- };
- return RetryWhenOperator;
- }());
- var RetryWhenSubscriber = (function (_super) {
- __extends(RetryWhenSubscriber, _super);
- function RetryWhenSubscriber(destination, notifier, source) {
- var _this = _super.call(this, destination) || this;
- _this.notifier = notifier;
- _this.source = source;
- return _this;
- }
- RetryWhenSubscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- var errors = this.errors;
- var retries = this.retries;
- var retriesSubscription = this.retriesSubscription;
- if (!retries) {
- errors = new Subject();
- retries = tryCatch(this.notifier)(errors);
- if (retries === errorObject) {
- return _super.prototype.error.call(this, errorObject.e);
- }
- retriesSubscription = subscribeToResult(this, retries);
- }
- else {
- this.errors = null;
- this.retriesSubscription = null;
- }
- this._unsubscribeAndRecycle();
- this.errors = errors;
- this.retries = retries;
- this.retriesSubscription = retriesSubscription;
- errors.next(err);
- }
- };
- RetryWhenSubscriber.prototype._unsubscribe = function () {
- var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
- if (errors) {
- errors.unsubscribe();
- this.errors = null;
- }
- if (retriesSubscription) {
- retriesSubscription.unsubscribe();
- this.retriesSubscription = null;
- }
- this.retries = null;
- };
- RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- var _unsubscribe = this._unsubscribe;
- this._unsubscribe = null;
- this._unsubscribeAndRecycle();
- this._unsubscribe = _unsubscribe;
- this.source.subscribe(this);
- };
- return RetryWhenSubscriber;
- }(OuterSubscriber));
-
- function sample(notifier) {
- return function (source) { return source.lift(new SampleOperator(notifier)); };
- }
- var SampleOperator = (function () {
- function SampleOperator(notifier) {
- this.notifier = notifier;
- }
- SampleOperator.prototype.call = function (subscriber, source) {
- var sampleSubscriber = new SampleSubscriber(subscriber);
- var subscription = source.subscribe(sampleSubscriber);
- subscription.add(subscribeToResult(sampleSubscriber, this.notifier));
- return subscription;
- };
- return SampleOperator;
- }());
- var SampleSubscriber = (function (_super) {
- __extends(SampleSubscriber, _super);
- function SampleSubscriber() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.hasValue = false;
- return _this;
- }
- SampleSubscriber.prototype._next = function (value) {
- this.value = value;
- this.hasValue = true;
- };
- SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.emitValue();
- };
- SampleSubscriber.prototype.notifyComplete = function () {
- this.emitValue();
- };
- SampleSubscriber.prototype.emitValue = function () {
- if (this.hasValue) {
- this.hasValue = false;
- this.destination.next(this.value);
- }
- };
- return SampleSubscriber;
- }(OuterSubscriber));
-
- function sampleTime(period, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
- }
- var SampleTimeOperator = (function () {
- function SampleTimeOperator(period, scheduler) {
- this.period = period;
- this.scheduler = scheduler;
- }
- SampleTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
- };
- return SampleTimeOperator;
- }());
- var SampleTimeSubscriber = (function (_super) {
- __extends(SampleTimeSubscriber, _super);
- function SampleTimeSubscriber(destination, period, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.period = period;
- _this.scheduler = scheduler;
- _this.hasValue = false;
- _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
- return _this;
- }
- SampleTimeSubscriber.prototype._next = function (value) {
- this.lastValue = value;
- this.hasValue = true;
- };
- SampleTimeSubscriber.prototype.notifyNext = function () {
- if (this.hasValue) {
- this.hasValue = false;
- this.destination.next(this.lastValue);
- }
- };
- return SampleTimeSubscriber;
- }(Subscriber));
- function dispatchNotification(state) {
- var subscriber = state.subscriber, period = state.period;
- subscriber.notifyNext();
- this.schedule(state, period);
- }
-
- function sequenceEqual(compareTo, comparor) {
- return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparor)); };
- }
- var SequenceEqualOperator = (function () {
- function SequenceEqualOperator(compareTo, comparor) {
- this.compareTo = compareTo;
- this.comparor = comparor;
- }
- SequenceEqualOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparor));
- };
- return SequenceEqualOperator;
- }());
- var SequenceEqualSubscriber = (function (_super) {
- __extends(SequenceEqualSubscriber, _super);
- function SequenceEqualSubscriber(destination, compareTo, comparor) {
- var _this = _super.call(this, destination) || this;
- _this.compareTo = compareTo;
- _this.comparor = comparor;
- _this._a = [];
- _this._b = [];
- _this._oneComplete = false;
- _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
- return _this;
- }
- SequenceEqualSubscriber.prototype._next = function (value) {
- if (this._oneComplete && this._b.length === 0) {
- this.emit(false);
- }
- else {
- this._a.push(value);
- this.checkValues();
- }
- };
- SequenceEqualSubscriber.prototype._complete = function () {
- if (this._oneComplete) {
- this.emit(this._a.length === 0 && this._b.length === 0);
- }
- else {
- this._oneComplete = true;
- }
- this.unsubscribe();
- };
- SequenceEqualSubscriber.prototype.checkValues = function () {
- var _c = this, _a = _c._a, _b = _c._b, comparor = _c.comparor;
- while (_a.length > 0 && _b.length > 0) {
- var a = _a.shift();
- var b = _b.shift();
- var areEqual = false;
- if (comparor) {
- areEqual = tryCatch(comparor)(a, b);
- if (areEqual === errorObject) {
- this.destination.error(errorObject.e);
- }
- }
- else {
- areEqual = a === b;
- }
- if (!areEqual) {
- this.emit(false);
- }
- }
- };
- SequenceEqualSubscriber.prototype.emit = function (value) {
- var destination = this.destination;
- destination.next(value);
- destination.complete();
- };
- SequenceEqualSubscriber.prototype.nextB = function (value) {
- if (this._oneComplete && this._a.length === 0) {
- this.emit(false);
- }
- else {
- this._b.push(value);
- this.checkValues();
- }
- };
- SequenceEqualSubscriber.prototype.completeB = function () {
- if (this._oneComplete) {
- this.emit(this._a.length === 0 && this._b.length === 0);
- }
- else {
- this._oneComplete = true;
- }
- };
- return SequenceEqualSubscriber;
- }(Subscriber));
- var SequenceEqualCompareToSubscriber = (function (_super) {
- __extends(SequenceEqualCompareToSubscriber, _super);
- function SequenceEqualCompareToSubscriber(destination, parent) {
- var _this = _super.call(this, destination) || this;
- _this.parent = parent;
- return _this;
- }
- SequenceEqualCompareToSubscriber.prototype._next = function (value) {
- this.parent.nextB(value);
- };
- SequenceEqualCompareToSubscriber.prototype._error = function (err) {
- this.parent.error(err);
- this.unsubscribe();
- };
- SequenceEqualCompareToSubscriber.prototype._complete = function () {
- this.parent.completeB();
- this.unsubscribe();
- };
- return SequenceEqualCompareToSubscriber;
- }(Subscriber));
-
- function shareSubjectFactory() {
- return new Subject();
- }
- function share() {
- return function (source) { return refCount()(multicast(shareSubjectFactory)(source)); };
- }
-
- function shareReplay(bufferSize, windowTime, scheduler) {
- if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
- if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
- return function (source) { return source.lift(shareReplayOperator(bufferSize, windowTime, scheduler)); };
- }
- function shareReplayOperator(bufferSize, windowTime, scheduler) {
- var subject;
- var refCount = 0;
- var subscription;
- var hasError = false;
- var isComplete = false;
- return function shareReplayOperation(source) {
- refCount++;
- if (!subject || hasError) {
- hasError = false;
- subject = new ReplaySubject(bufferSize, windowTime, scheduler);
- subscription = source.subscribe({
- next: function (value) { subject.next(value); },
- error: function (err) {
- hasError = true;
- subject.error(err);
- },
- complete: function () {
- isComplete = true;
- subject.complete();
- },
- });
- }
- var innerSub = subject.subscribe(this);
- return function () {
- refCount--;
- innerSub.unsubscribe();
- if (subscription && refCount === 0 && isComplete) {
- subscription.unsubscribe();
- }
- };
- };
- }
-
- function single(predicate) {
- return function (source) { return source.lift(new SingleOperator(predicate, source)); };
- }
- var SingleOperator = (function () {
- function SingleOperator(predicate, source) {
- this.predicate = predicate;
- this.source = source;
- }
- SingleOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
- };
- return SingleOperator;
- }());
- var SingleSubscriber = (function (_super) {
- __extends(SingleSubscriber, _super);
- function SingleSubscriber(destination, predicate, source) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.source = source;
- _this.seenValue = false;
- _this.index = 0;
- return _this;
- }
- SingleSubscriber.prototype.applySingleValue = function (value) {
- if (this.seenValue) {
- this.destination.error('Sequence contains more than one element');
- }
- else {
- this.seenValue = true;
- this.singleValue = value;
- }
- };
- SingleSubscriber.prototype._next = function (value) {
- var index = this.index++;
- if (this.predicate) {
- this.tryNext(value, index);
- }
- else {
- this.applySingleValue(value);
- }
- };
- SingleSubscriber.prototype.tryNext = function (value, index) {
- try {
- if (this.predicate(value, index, this.source)) {
- this.applySingleValue(value);
- }
- }
- catch (err) {
- this.destination.error(err);
- }
- };
- SingleSubscriber.prototype._complete = function () {
- var destination = this.destination;
- if (this.index > 0) {
- destination.next(this.seenValue ? this.singleValue : undefined);
- destination.complete();
- }
- else {
- destination.error(new EmptyError);
- }
- };
- return SingleSubscriber;
- }(Subscriber));
-
- function skip(count) {
- return function (source) { return source.lift(new SkipOperator(count)); };
- }
- var SkipOperator = (function () {
- function SkipOperator(total) {
- this.total = total;
- }
- SkipOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SkipSubscriber(subscriber, this.total));
- };
- return SkipOperator;
- }());
- var SkipSubscriber = (function (_super) {
- __extends(SkipSubscriber, _super);
- function SkipSubscriber(destination, total) {
- var _this = _super.call(this, destination) || this;
- _this.total = total;
- _this.count = 0;
- return _this;
- }
- SkipSubscriber.prototype._next = function (x) {
- if (++this.count > this.total) {
- this.destination.next(x);
- }
- };
- return SkipSubscriber;
- }(Subscriber));
-
- function skipLast(count) {
- return function (source) { return source.lift(new SkipLastOperator(count)); };
- }
- var SkipLastOperator = (function () {
- function SkipLastOperator(_skipCount) {
- this._skipCount = _skipCount;
- if (this._skipCount < 0) {
- throw new ArgumentOutOfRangeError;
- }
- }
- SkipLastOperator.prototype.call = function (subscriber, source) {
- if (this._skipCount === 0) {
- return source.subscribe(new Subscriber(subscriber));
- }
- else {
- return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
- }
- };
- return SkipLastOperator;
- }());
- var SkipLastSubscriber = (function (_super) {
- __extends(SkipLastSubscriber, _super);
- function SkipLastSubscriber(destination, _skipCount) {
- var _this = _super.call(this, destination) || this;
- _this._skipCount = _skipCount;
- _this._count = 0;
- _this._ring = new Array(_skipCount);
- return _this;
- }
- SkipLastSubscriber.prototype._next = function (value) {
- var skipCount = this._skipCount;
- var count = this._count++;
- if (count < skipCount) {
- this._ring[count] = value;
- }
- else {
- var currentIndex = count % skipCount;
- var ring = this._ring;
- var oldValue = ring[currentIndex];
- ring[currentIndex] = value;
- this.destination.next(oldValue);
- }
- };
- return SkipLastSubscriber;
- }(Subscriber));
-
- function skipUntil(notifier) {
- return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
- }
- var SkipUntilOperator = (function () {
- function SkipUntilOperator(notifier) {
- this.notifier = notifier;
- }
- SkipUntilOperator.prototype.call = function (destination, source) {
- return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
- };
- return SkipUntilOperator;
- }());
- var SkipUntilSubscriber = (function (_super) {
- __extends(SkipUntilSubscriber, _super);
- function SkipUntilSubscriber(destination, notifier) {
- var _this = _super.call(this, destination) || this;
- _this.hasValue = false;
- var innerSubscriber = new InnerSubscriber(_this, undefined, undefined);
- _this.add(innerSubscriber);
- _this.innerSubscription = innerSubscriber;
- subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
- return _this;
- }
- SkipUntilSubscriber.prototype._next = function (value) {
- if (this.hasValue) {
- _super.prototype._next.call(this, value);
- }
- };
- SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.hasValue = true;
- if (this.innerSubscription) {
- this.innerSubscription.unsubscribe();
- }
- };
- SkipUntilSubscriber.prototype.notifyComplete = function () {
- };
- return SkipUntilSubscriber;
- }(OuterSubscriber));
-
- function skipWhile(predicate) {
- return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
- }
- var SkipWhileOperator = (function () {
- function SkipWhileOperator(predicate) {
- this.predicate = predicate;
- }
- SkipWhileOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
- };
- return SkipWhileOperator;
- }());
- var SkipWhileSubscriber = (function (_super) {
- __extends(SkipWhileSubscriber, _super);
- function SkipWhileSubscriber(destination, predicate) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.skipping = true;
- _this.index = 0;
- return _this;
- }
- SkipWhileSubscriber.prototype._next = function (value) {
- var destination = this.destination;
- if (this.skipping) {
- this.tryCallPredicate(value);
- }
- if (!this.skipping) {
- destination.next(value);
- }
- };
- SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
- try {
- var result = this.predicate(value, this.index++);
- this.skipping = Boolean(result);
- }
- catch (err) {
- this.destination.error(err);
- }
- };
- return SkipWhileSubscriber;
- }(Subscriber));
-
- function startWith() {
- var array = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- array[_i] = arguments[_i];
- }
- return function (source) {
- var scheduler = array[array.length - 1];
- if (isScheduler(scheduler)) {
- array.pop();
- }
- else {
- scheduler = null;
- }
- var len = array.length;
- if (len === 1 && !scheduler) {
- return concat(scalar(array[0]), source);
- }
- else if (len > 0) {
- return concat(fromArray(array, scheduler), source);
- }
- else {
- return concat(empty$1(scheduler), source);
- }
- };
- }
-
- var SubscribeOnObservable = (function (_super) {
- __extends(SubscribeOnObservable, _super);
- function SubscribeOnObservable(source, delayTime, scheduler) {
- if (delayTime === void 0) { delayTime = 0; }
- if (scheduler === void 0) { scheduler = asap; }
- var _this = _super.call(this) || this;
- _this.source = source;
- _this.delayTime = delayTime;
- _this.scheduler = scheduler;
- if (!isNumeric(delayTime) || delayTime < 0) {
- _this.delayTime = 0;
- }
- if (!scheduler || typeof scheduler.schedule !== 'function') {
- _this.scheduler = asap;
- }
- return _this;
- }
- SubscribeOnObservable.create = function (source, delay, scheduler) {
- if (delay === void 0) { delay = 0; }
- if (scheduler === void 0) { scheduler = asap; }
- return new SubscribeOnObservable(source, delay, scheduler);
- };
- SubscribeOnObservable.dispatch = function (arg) {
- var source = arg.source, subscriber = arg.subscriber;
- return this.add(source.subscribe(subscriber));
- };
- SubscribeOnObservable.prototype._subscribe = function (subscriber) {
- var delay = this.delayTime;
- var source = this.source;
- var scheduler = this.scheduler;
- return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
- source: source, subscriber: subscriber
- });
- };
- return SubscribeOnObservable;
- }(Observable));
-
- function subscribeOn(scheduler, delay) {
- if (delay === void 0) { delay = 0; }
- return function subscribeOnOperatorFunction(source) {
- return source.lift(new SubscribeOnOperator(scheduler, delay));
- };
- }
- var SubscribeOnOperator = (function () {
- function SubscribeOnOperator(scheduler, delay) {
- this.scheduler = scheduler;
- this.delay = delay;
- }
- SubscribeOnOperator.prototype.call = function (subscriber, source) {
- return new SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
- };
- return SubscribeOnOperator;
- }());
-
- function switchMap(project, resultSelector) {
- if (typeof resultSelector === 'function') {
- return function (source) { return source.pipe(switchMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
- }
- return function (source) { return source.lift(new SwitchMapOperator(project)); };
- }
- var SwitchMapOperator = (function () {
- function SwitchMapOperator(project) {
- this.project = project;
- }
- SwitchMapOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
- };
- return SwitchMapOperator;
- }());
- var SwitchMapSubscriber = (function (_super) {
- __extends(SwitchMapSubscriber, _super);
- function SwitchMapSubscriber(destination, project) {
- var _this = _super.call(this, destination) || this;
- _this.project = project;
- _this.index = 0;
- return _this;
- }
- SwitchMapSubscriber.prototype._next = function (value) {
- var result;
- var index = this.index++;
- try {
- result = this.project(value, index);
- }
- catch (error) {
- this.destination.error(error);
- return;
- }
- this._innerSub(result, value, index);
- };
- SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
- var innerSubscription = this.innerSubscription;
- if (innerSubscription) {
- innerSubscription.unsubscribe();
- }
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- this.innerSubscription = subscribeToResult(this, result, value, index, innerSubscriber);
- };
- SwitchMapSubscriber.prototype._complete = function () {
- var innerSubscription = this.innerSubscription;
- if (!innerSubscription || innerSubscription.closed) {
- _super.prototype._complete.call(this);
- }
- this.unsubscribe();
- };
- SwitchMapSubscriber.prototype._unsubscribe = function () {
- this.innerSubscription = null;
- };
- SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
- var destination = this.destination;
- destination.remove(innerSub);
- this.innerSubscription = null;
- if (this.isStopped) {
- _super.prototype._complete.call(this);
- }
- };
- SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(innerValue);
- };
- return SwitchMapSubscriber;
- }(OuterSubscriber));
-
- function switchAll() {
- return switchMap(identity);
- }
-
- function switchMapTo(innerObservable, resultSelector) {
- return resultSelector ? switchMap(function () { return innerObservable; }, resultSelector) : switchMap(function () { return innerObservable; });
- }
-
- function takeUntil(notifier) {
- return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
- }
- var TakeUntilOperator = (function () {
- function TakeUntilOperator(notifier) {
- this.notifier = notifier;
- }
- TakeUntilOperator.prototype.call = function (subscriber, source) {
- var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
- var notifierSubscription = subscribeToResult(takeUntilSubscriber, this.notifier);
- if (notifierSubscription && !takeUntilSubscriber.seenValue) {
- takeUntilSubscriber.add(notifierSubscription);
- return source.subscribe(takeUntilSubscriber);
- }
- return takeUntilSubscriber;
- };
- return TakeUntilOperator;
- }());
- var TakeUntilSubscriber = (function (_super) {
- __extends(TakeUntilSubscriber, _super);
- function TakeUntilSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.seenValue = false;
- return _this;
- }
- TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.seenValue = true;
- this.complete();
- };
- TakeUntilSubscriber.prototype.notifyComplete = function () {
- };
- return TakeUntilSubscriber;
- }(OuterSubscriber));
-
- function takeWhile(predicate) {
- return function (source) { return source.lift(new TakeWhileOperator(predicate)); };
- }
- var TakeWhileOperator = (function () {
- function TakeWhileOperator(predicate) {
- this.predicate = predicate;
- }
- TakeWhileOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate));
- };
- return TakeWhileOperator;
- }());
- var TakeWhileSubscriber = (function (_super) {
- __extends(TakeWhileSubscriber, _super);
- function TakeWhileSubscriber(destination, predicate) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.index = 0;
- return _this;
- }
- TakeWhileSubscriber.prototype._next = function (value) {
- var destination = this.destination;
- var result;
- try {
- result = this.predicate(value, this.index++);
- }
- catch (err) {
- destination.error(err);
- return;
- }
- this.nextOrComplete(value, result);
- };
- TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
- var destination = this.destination;
- if (Boolean(predicateResult)) {
- destination.next(value);
- }
- else {
- destination.complete();
- }
- };
- return TakeWhileSubscriber;
- }(Subscriber));
-
- var defaultThrottleConfig = {
- leading: true,
- trailing: false
- };
- function throttle(durationSelector, config) {
- if (config === void 0) { config = defaultThrottleConfig; }
- return function (source) { return source.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); };
- }
- var ThrottleOperator = (function () {
- function ThrottleOperator(durationSelector, leading, trailing) {
- this.durationSelector = durationSelector;
- this.leading = leading;
- this.trailing = trailing;
- }
- ThrottleOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
- };
- return ThrottleOperator;
- }());
- var ThrottleSubscriber = (function (_super) {
- __extends(ThrottleSubscriber, _super);
- function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- _this.durationSelector = durationSelector;
- _this._leading = _leading;
- _this._trailing = _trailing;
- _this._hasValue = false;
- return _this;
- }
- ThrottleSubscriber.prototype._next = function (value) {
- this._hasValue = true;
- this._sendValue = value;
- if (!this._throttled) {
- if (this._leading) {
- this.send();
- }
- else {
- this.throttle(value);
- }
- }
- };
- ThrottleSubscriber.prototype.send = function () {
- var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
- if (_hasValue) {
- this.destination.next(_sendValue);
- this.throttle(_sendValue);
- }
- this._hasValue = false;
- this._sendValue = null;
- };
- ThrottleSubscriber.prototype.throttle = function (value) {
- var duration = this.tryDurationSelector(value);
- if (duration) {
- this.add(this._throttled = subscribeToResult(this, duration));
- }
- };
- ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
- try {
- return this.durationSelector(value);
- }
- catch (err) {
- this.destination.error(err);
- return null;
- }
- };
- ThrottleSubscriber.prototype.throttlingDone = function () {
- var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
- if (_throttled) {
- _throttled.unsubscribe();
- }
- this._throttled = null;
- if (_trailing) {
- this.send();
- }
- };
- ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.throttlingDone();
- };
- ThrottleSubscriber.prototype.notifyComplete = function () {
- this.throttlingDone();
- };
- return ThrottleSubscriber;
- }(OuterSubscriber));
-
- function throttleTime(duration, scheduler, config) {
- if (scheduler === void 0) { scheduler = async; }
- if (config === void 0) { config = defaultThrottleConfig; }
- return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
- }
- var ThrottleTimeOperator = (function () {
- function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
- this.duration = duration;
- this.scheduler = scheduler;
- this.leading = leading;
- this.trailing = trailing;
- }
- ThrottleTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
- };
- return ThrottleTimeOperator;
- }());
- var ThrottleTimeSubscriber = (function (_super) {
- __extends(ThrottleTimeSubscriber, _super);
- function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
- var _this = _super.call(this, destination) || this;
- _this.duration = duration;
- _this.scheduler = scheduler;
- _this.leading = leading;
- _this.trailing = trailing;
- _this._hasTrailingValue = false;
- _this._trailingValue = null;
- return _this;
- }
- ThrottleTimeSubscriber.prototype._next = function (value) {
- if (this.throttled) {
- if (this.trailing) {
- this._trailingValue = value;
- this._hasTrailingValue = true;
- }
- }
- else {
- this.add(this.throttled = this.scheduler.schedule(dispatchNext$3, this.duration, { subscriber: this }));
- if (this.leading) {
- this.destination.next(value);
- }
- }
- };
- ThrottleTimeSubscriber.prototype._complete = function () {
- if (this._hasTrailingValue) {
- this.destination.next(this._trailingValue);
- this.destination.complete();
- }
- else {
- this.destination.complete();
- }
- };
- ThrottleTimeSubscriber.prototype.clearThrottle = function () {
- var throttled = this.throttled;
- if (throttled) {
- if (this.trailing && this._hasTrailingValue) {
- this.destination.next(this._trailingValue);
- this._trailingValue = null;
- this._hasTrailingValue = false;
- }
- throttled.unsubscribe();
- this.remove(throttled);
- this.throttled = null;
- }
- };
- return ThrottleTimeSubscriber;
- }(Subscriber));
- function dispatchNext$3(arg) {
- var subscriber = arg.subscriber;
- subscriber.clearThrottle();
- }
-
- function timeInterval(scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return function (source) { return defer(function () {
- return source.pipe(scan(function (_a, value) {
- var current = _a.current;
- return ({ value: value, current: scheduler.now(), last: current });
- }, { current: scheduler.now(), value: undefined, last: undefined }), map(function (_a) {
- var current = _a.current, last = _a.last, value = _a.value;
- return new TimeInterval(value, current - last);
- }));
- }); };
- }
- var TimeInterval = (function () {
- function TimeInterval(value, interval) {
- this.value = value;
- this.interval = interval;
- }
- return TimeInterval;
- }());
-
- function timeoutWith(due, withObservable, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return function (source) {
- var absoluteTimeout = isDate(due);
- var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
- return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
- };
- }
- var TimeoutWithOperator = (function () {
- function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
- this.waitFor = waitFor;
- this.absoluteTimeout = absoluteTimeout;
- this.withObservable = withObservable;
- this.scheduler = scheduler;
- }
- TimeoutWithOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
- };
- return TimeoutWithOperator;
- }());
- var TimeoutWithSubscriber = (function (_super) {
- __extends(TimeoutWithSubscriber, _super);
- function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.absoluteTimeout = absoluteTimeout;
- _this.waitFor = waitFor;
- _this.withObservable = withObservable;
- _this.scheduler = scheduler;
- _this.action = null;
- _this.scheduleTimeout();
- return _this;
- }
- TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
- var withObservable = subscriber.withObservable;
- subscriber._unsubscribeAndRecycle();
- subscriber.add(subscribeToResult(subscriber, withObservable));
- };
- TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
- var action = this.action;
- if (action) {
- this.action = action.schedule(this, this.waitFor);
- }
- else {
- this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
- }
- };
- TimeoutWithSubscriber.prototype._next = function (value) {
- if (!this.absoluteTimeout) {
- this.scheduleTimeout();
- }
- _super.prototype._next.call(this, value);
- };
- TimeoutWithSubscriber.prototype._unsubscribe = function () {
- this.action = null;
- this.scheduler = null;
- this.withObservable = null;
- };
- return TimeoutWithSubscriber;
- }(OuterSubscriber));
-
- function timeout(due, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return timeoutWith(due, throwError(new TimeoutError()), scheduler);
- }
-
- function timestamp(scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return map(function (value) { return new Timestamp(value, scheduler.now()); });
- }
- var Timestamp = (function () {
- function Timestamp(value, timestamp) {
- this.value = value;
- this.timestamp = timestamp;
- }
- return Timestamp;
- }());
-
- function toArrayReducer(arr, item, index) {
- if (index === 0) {
- return [item];
- }
- arr.push(item);
- return arr;
- }
- function toArray() {
- return reduce(toArrayReducer, []);
- }
-
- function window$1(windowBoundaries) {
- return function windowOperatorFunction(source) {
- return source.lift(new WindowOperator(windowBoundaries));
- };
- }
- var WindowOperator = (function () {
- function WindowOperator(windowBoundaries) {
- this.windowBoundaries = windowBoundaries;
- }
- WindowOperator.prototype.call = function (subscriber, source) {
- var windowSubscriber = new WindowSubscriber(subscriber);
- var sourceSubscription = source.subscribe(windowSubscriber);
- if (!sourceSubscription.closed) {
- windowSubscriber.add(subscribeToResult(windowSubscriber, this.windowBoundaries));
- }
- return sourceSubscription;
- };
- return WindowOperator;
- }());
- var WindowSubscriber = (function (_super) {
- __extends(WindowSubscriber, _super);
- function WindowSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.window = new Subject();
- destination.next(_this.window);
- return _this;
- }
- WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.openWindow();
- };
- WindowSubscriber.prototype.notifyError = function (error, innerSub) {
- this._error(error);
- };
- WindowSubscriber.prototype.notifyComplete = function (innerSub) {
- this._complete();
- };
- WindowSubscriber.prototype._next = function (value) {
- this.window.next(value);
- };
- WindowSubscriber.prototype._error = function (err) {
- this.window.error(err);
- this.destination.error(err);
- };
- WindowSubscriber.prototype._complete = function () {
- this.window.complete();
- this.destination.complete();
- };
- WindowSubscriber.prototype._unsubscribe = function () {
- this.window = null;
- };
- WindowSubscriber.prototype.openWindow = function () {
- var prevWindow = this.window;
- if (prevWindow) {
- prevWindow.complete();
- }
- var destination = this.destination;
- var newWindow = this.window = new Subject();
- destination.next(newWindow);
- };
- return WindowSubscriber;
- }(OuterSubscriber));
-
- function windowCount(windowSize, startWindowEvery) {
- if (startWindowEvery === void 0) { startWindowEvery = 0; }
- return function windowCountOperatorFunction(source) {
- return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
- };
- }
- var WindowCountOperator = (function () {
- function WindowCountOperator(windowSize, startWindowEvery) {
- this.windowSize = windowSize;
- this.startWindowEvery = startWindowEvery;
- }
- WindowCountOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
- };
- return WindowCountOperator;
- }());
- var WindowCountSubscriber = (function (_super) {
- __extends(WindowCountSubscriber, _super);
- function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- _this.windowSize = windowSize;
- _this.startWindowEvery = startWindowEvery;
- _this.windows = [new Subject()];
- _this.count = 0;
- destination.next(_this.windows[0]);
- return _this;
- }
- WindowCountSubscriber.prototype._next = function (value) {
- var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
- var destination = this.destination;
- var windowSize = this.windowSize;
- var windows = this.windows;
- var len = windows.length;
- for (var i = 0; i < len && !this.closed; i++) {
- windows[i].next(value);
- }
- var c = this.count - windowSize + 1;
- if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
- windows.shift().complete();
- }
- if (++this.count % startWindowEvery === 0 && !this.closed) {
- var window_1 = new Subject();
- windows.push(window_1);
- destination.next(window_1);
- }
- };
- WindowCountSubscriber.prototype._error = function (err) {
- var windows = this.windows;
- if (windows) {
- while (windows.length > 0 && !this.closed) {
- windows.shift().error(err);
- }
- }
- this.destination.error(err);
- };
- WindowCountSubscriber.prototype._complete = function () {
- var windows = this.windows;
- if (windows) {
- while (windows.length > 0 && !this.closed) {
- windows.shift().complete();
- }
- }
- this.destination.complete();
- };
- WindowCountSubscriber.prototype._unsubscribe = function () {
- this.count = 0;
- this.windows = null;
- };
- return WindowCountSubscriber;
- }(Subscriber));
-
- function windowTime(windowTimeSpan) {
- var scheduler = async;
- var windowCreationInterval = null;
- var maxWindowSize = Number.POSITIVE_INFINITY;
- if (isScheduler(arguments[3])) {
- scheduler = arguments[3];
- }
- if (isScheduler(arguments[2])) {
- scheduler = arguments[2];
- }
- else if (isNumeric(arguments[2])) {
- maxWindowSize = arguments[2];
- }
- if (isScheduler(arguments[1])) {
- scheduler = arguments[1];
- }
- else if (isNumeric(arguments[1])) {
- windowCreationInterval = arguments[1];
- }
- return function windowTimeOperatorFunction(source) {
- return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
- };
- }
- var WindowTimeOperator = (function () {
- function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
- this.windowTimeSpan = windowTimeSpan;
- this.windowCreationInterval = windowCreationInterval;
- this.maxWindowSize = maxWindowSize;
- this.scheduler = scheduler;
- }
- WindowTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
- };
- return WindowTimeOperator;
- }());
- var CountedSubject = (function (_super) {
- __extends(CountedSubject, _super);
- function CountedSubject() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this._numberOfNextedValues = 0;
- return _this;
- }
- CountedSubject.prototype.next = function (value) {
- this._numberOfNextedValues++;
- _super.prototype.next.call(this, value);
- };
- Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
- get: function () {
- return this._numberOfNextedValues;
- },
- enumerable: true,
- configurable: true
- });
- return CountedSubject;
- }(Subject));
- var WindowTimeSubscriber = (function (_super) {
- __extends(WindowTimeSubscriber, _super);
- function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- _this.windowTimeSpan = windowTimeSpan;
- _this.windowCreationInterval = windowCreationInterval;
- _this.maxWindowSize = maxWindowSize;
- _this.scheduler = scheduler;
- _this.windows = [];
- var window = _this.openWindow();
- if (windowCreationInterval !== null && windowCreationInterval >= 0) {
- var closeState = { subscriber: _this, window: window, context: null };
- var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
- _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
- _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
- }
- else {
- var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
- _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
- }
- return _this;
- }
- WindowTimeSubscriber.prototype._next = function (value) {
- var windows = this.windows;
- var len = windows.length;
- for (var i = 0; i < len; i++) {
- var window_1 = windows[i];
- if (!window_1.closed) {
- window_1.next(value);
- if (window_1.numberOfNextedValues >= this.maxWindowSize) {
- this.closeWindow(window_1);
- }
- }
- }
- };
- WindowTimeSubscriber.prototype._error = function (err) {
- var windows = this.windows;
- while (windows.length > 0) {
- windows.shift().error(err);
- }
- this.destination.error(err);
- };
- WindowTimeSubscriber.prototype._complete = function () {
- var windows = this.windows;
- while (windows.length > 0) {
- var window_2 = windows.shift();
- if (!window_2.closed) {
- window_2.complete();
- }
- }
- this.destination.complete();
- };
- WindowTimeSubscriber.prototype.openWindow = function () {
- var window = new CountedSubject();
- this.windows.push(window);
- var destination = this.destination;
- destination.next(window);
- return window;
- };
- WindowTimeSubscriber.prototype.closeWindow = function (window) {
- window.complete();
- var windows = this.windows;
- windows.splice(windows.indexOf(window), 1);
- };
- return WindowTimeSubscriber;
- }(Subscriber));
- function dispatchWindowTimeSpanOnly(state) {
- var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
- if (window) {
- subscriber.closeWindow(window);
- }
- state.window = subscriber.openWindow();
- this.schedule(state, windowTimeSpan);
- }
- function dispatchWindowCreation(state) {
- var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
- var window = subscriber.openWindow();
- var action = this;
- var context = { action: action, subscription: null };
- var timeSpanState = { subscriber: subscriber, window: window, context: context };
- context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
- action.add(context.subscription);
- action.schedule(state, windowCreationInterval);
- }
- function dispatchWindowClose(state) {
- var subscriber = state.subscriber, window = state.window, context = state.context;
- if (context && context.action && context.subscription) {
- context.action.remove(context.subscription);
- }
- subscriber.closeWindow(window);
- }
-
- function windowToggle(openings, closingSelector) {
- return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
- }
- var WindowToggleOperator = (function () {
- function WindowToggleOperator(openings, closingSelector) {
- this.openings = openings;
- this.closingSelector = closingSelector;
- }
- WindowToggleOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
- };
- return WindowToggleOperator;
- }());
- var WindowToggleSubscriber = (function (_super) {
- __extends(WindowToggleSubscriber, _super);
- function WindowToggleSubscriber(destination, openings, closingSelector) {
- var _this = _super.call(this, destination) || this;
- _this.openings = openings;
- _this.closingSelector = closingSelector;
- _this.contexts = [];
- _this.add(_this.openSubscription = subscribeToResult(_this, openings, openings));
- return _this;
- }
- WindowToggleSubscriber.prototype._next = function (value) {
- var contexts = this.contexts;
- if (contexts) {
- var len = contexts.length;
- for (var i = 0; i < len; i++) {
- contexts[i].window.next(value);
- }
- }
- };
- WindowToggleSubscriber.prototype._error = function (err) {
- var contexts = this.contexts;
- this.contexts = null;
- if (contexts) {
- var len = contexts.length;
- var index = -1;
- while (++index < len) {
- var context_1 = contexts[index];
- context_1.window.error(err);
- context_1.subscription.unsubscribe();
- }
- }
- _super.prototype._error.call(this, err);
- };
- WindowToggleSubscriber.prototype._complete = function () {
- var contexts = this.contexts;
- this.contexts = null;
- if (contexts) {
- var len = contexts.length;
- var index = -1;
- while (++index < len) {
- var context_2 = contexts[index];
- context_2.window.complete();
- context_2.subscription.unsubscribe();
- }
- }
- _super.prototype._complete.call(this);
- };
- WindowToggleSubscriber.prototype._unsubscribe = function () {
- var contexts = this.contexts;
- this.contexts = null;
- if (contexts) {
- var len = contexts.length;
- var index = -1;
- while (++index < len) {
- var context_3 = contexts[index];
- context_3.window.unsubscribe();
- context_3.subscription.unsubscribe();
- }
- }
- };
- WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- if (outerValue === this.openings) {
- var closingSelector = this.closingSelector;
- var closingNotifier = tryCatch(closingSelector)(innerValue);
- if (closingNotifier === errorObject) {
- return this.error(errorObject.e);
- }
- else {
- var window_1 = new Subject();
- var subscription = new Subscription();
- var context_4 = { window: window_1, subscription: subscription };
- this.contexts.push(context_4);
- var innerSubscription = subscribeToResult(this, closingNotifier, context_4);
- if (innerSubscription.closed) {
- this.closeWindow(this.contexts.length - 1);
- }
- else {
- innerSubscription.context = context_4;
- subscription.add(innerSubscription);
- }
- this.destination.next(window_1);
- }
- }
- else {
- this.closeWindow(this.contexts.indexOf(outerValue));
- }
- };
- WindowToggleSubscriber.prototype.notifyError = function (err) {
- this.error(err);
- };
- WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
- if (inner !== this.openSubscription) {
- this.closeWindow(this.contexts.indexOf(inner.context));
- }
- };
- WindowToggleSubscriber.prototype.closeWindow = function (index) {
- if (index === -1) {
- return;
- }
- var contexts = this.contexts;
- var context = contexts[index];
- var window = context.window, subscription = context.subscription;
- contexts.splice(index, 1);
- window.complete();
- subscription.unsubscribe();
- };
- return WindowToggleSubscriber;
- }(OuterSubscriber));
-
- function windowWhen(closingSelector) {
- return function windowWhenOperatorFunction(source) {
- return source.lift(new WindowOperator$1(closingSelector));
- };
- }
- var WindowOperator$1 = (function () {
- function WindowOperator(closingSelector) {
- this.closingSelector = closingSelector;
- }
- WindowOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new WindowSubscriber$1(subscriber, this.closingSelector));
- };
- return WindowOperator;
- }());
- var WindowSubscriber$1 = (function (_super) {
- __extends(WindowSubscriber, _super);
- function WindowSubscriber(destination, closingSelector) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- _this.closingSelector = closingSelector;
- _this.openWindow();
- return _this;
- }
- WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.openWindow(innerSub);
- };
- WindowSubscriber.prototype.notifyError = function (error, innerSub) {
- this._error(error);
- };
- WindowSubscriber.prototype.notifyComplete = function (innerSub) {
- this.openWindow(innerSub);
- };
- WindowSubscriber.prototype._next = function (value) {
- this.window.next(value);
- };
- WindowSubscriber.prototype._error = function (err) {
- this.window.error(err);
- this.destination.error(err);
- this.unsubscribeClosingNotification();
- };
- WindowSubscriber.prototype._complete = function () {
- this.window.complete();
- this.destination.complete();
- this.unsubscribeClosingNotification();
- };
- WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
- if (this.closingNotification) {
- this.closingNotification.unsubscribe();
- }
- };
- WindowSubscriber.prototype.openWindow = function (innerSub) {
- if (innerSub === void 0) { innerSub = null; }
- if (innerSub) {
- this.remove(innerSub);
- innerSub.unsubscribe();
- }
- var prevWindow = this.window;
- if (prevWindow) {
- prevWindow.complete();
- }
- var window = this.window = new Subject();
- this.destination.next(window);
- var closingNotifier = tryCatch(this.closingSelector)();
- if (closingNotifier === errorObject) {
- var err = errorObject.e;
- this.destination.error(err);
- this.window.error(err);
- }
- else {
- this.add(this.closingNotification = subscribeToResult(this, closingNotifier));
- }
- };
- return WindowSubscriber;
- }(OuterSubscriber));
-
- function withLatestFrom() {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return function (source) {
- var project;
- if (typeof args[args.length - 1] === 'function') {
- project = args.pop();
- }
- var observables = args;
- return source.lift(new WithLatestFromOperator(observables, project));
- };
- }
- var WithLatestFromOperator = (function () {
- function WithLatestFromOperator(observables, project) {
- this.observables = observables;
- this.project = project;
- }
- WithLatestFromOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
- };
- return WithLatestFromOperator;
- }());
- var WithLatestFromSubscriber = (function (_super) {
- __extends(WithLatestFromSubscriber, _super);
- function WithLatestFromSubscriber(destination, observables, project) {
- var _this = _super.call(this, destination) || this;
- _this.observables = observables;
- _this.project = project;
- _this.toRespond = [];
- var len = observables.length;
- _this.values = new Array(len);
- for (var i = 0; i < len; i++) {
- _this.toRespond.push(i);
- }
- for (var i = 0; i < len; i++) {
- var observable = observables[i];
- _this.add(subscribeToResult(_this, observable, observable, i));
- }
- return _this;
- }
- WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.values[outerIndex] = innerValue;
- var toRespond = this.toRespond;
- if (toRespond.length > 0) {
- var found = toRespond.indexOf(outerIndex);
- if (found !== -1) {
- toRespond.splice(found, 1);
- }
- }
- };
- WithLatestFromSubscriber.prototype.notifyComplete = function () {
- };
- WithLatestFromSubscriber.prototype._next = function (value) {
- if (this.toRespond.length === 0) {
- var args = [value].concat(this.values);
- if (this.project) {
- this._tryProject(args);
- }
- else {
- this.destination.next(args);
- }
- }
- };
- WithLatestFromSubscriber.prototype._tryProject = function (args) {
- var result;
- try {
- result = this.project.apply(this, args);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(result);
- };
- return WithLatestFromSubscriber;
- }(OuterSubscriber));
-
- function zip$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- return function zipOperatorFunction(source) {
- return source.lift.call(zip.apply(void 0, [source].concat(observables)));
- };
- }
-
- function zipAll(project) {
- return function (source) { return source.lift(new ZipOperator(project)); };
- }
-
-
-
- var _operators = Object.freeze({
- audit: audit,
- auditTime: auditTime,
- buffer: buffer,
- bufferCount: bufferCount,
- bufferTime: bufferTime,
- bufferToggle: bufferToggle,
- bufferWhen: bufferWhen,
- catchError: catchError,
- combineAll: combineAll,
- combineLatest: combineLatest$1,
- concat: concat$1,
- concatAll: concatAll,
- concatMap: concatMap,
- concatMapTo: concatMapTo,
- count: count,
- debounce: debounce,
- debounceTime: debounceTime,
- defaultIfEmpty: defaultIfEmpty,
- delay: delay,
- delayWhen: delayWhen,
- dematerialize: dematerialize,
- distinct: distinct,
- distinctUntilChanged: distinctUntilChanged,
- distinctUntilKeyChanged: distinctUntilKeyChanged,
- elementAt: elementAt,
- endWith: endWith,
- every: every,
- exhaust: exhaust,
- exhaustMap: exhaustMap,
- expand: expand,
- filter: filter,
- finalize: finalize,
- find: find,
- findIndex: findIndex,
- first: first,
- groupBy: groupBy,
- ignoreElements: ignoreElements,
- isEmpty: isEmpty,
- last: last,
- map: map,
- mapTo: mapTo,
- materialize: materialize,
- max: max,
- merge: merge$1,
- mergeAll: mergeAll,
- mergeMap: mergeMap,
- flatMap: mergeMap,
- mergeMapTo: mergeMapTo,
- mergeScan: mergeScan,
- min: min,
- multicast: multicast,
- observeOn: observeOn,
- onErrorResumeNext: onErrorResumeNext$1,
- pairwise: pairwise,
- partition: partition,
- pluck: pluck,
- publish: publish,
- publishBehavior: publishBehavior,
- publishLast: publishLast,
- publishReplay: publishReplay,
- race: race$1,
- reduce: reduce,
- repeat: repeat,
- repeatWhen: repeatWhen,
- retry: retry,
- retryWhen: retryWhen,
- refCount: refCount,
- sample: sample,
- sampleTime: sampleTime,
- scan: scan,
- sequenceEqual: sequenceEqual,
- share: share,
- shareReplay: shareReplay,
- single: single,
- skip: skip,
- skipLast: skipLast,
- skipUntil: skipUntil,
- skipWhile: skipWhile,
- startWith: startWith,
- subscribeOn: subscribeOn,
- switchAll: switchAll,
- switchMap: switchMap,
- switchMapTo: switchMapTo,
- take: take,
- takeLast: takeLast,
- takeUntil: takeUntil,
- takeWhile: takeWhile,
- tap: tap,
- throttle: throttle,
- throttleTime: throttleTime,
- throwIfEmpty: throwIfEmpty,
- timeInterval: timeInterval,
- timeout: timeout,
- timeoutWith: timeoutWith,
- timestamp: timestamp,
- toArray: toArray,
- window: window$1,
- windowCount: windowCount,
- windowTime: windowTime,
- windowToggle: windowToggle,
- windowWhen: windowWhen,
- withLatestFrom: withLatestFrom,
- zip: zip$1,
- zipAll: zipAll
- });
-
- var SubscriptionLog = (function () {
- function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
- if (unsubscribedFrame === void 0) { unsubscribedFrame = Number.POSITIVE_INFINITY; }
- this.subscribedFrame = subscribedFrame;
- this.unsubscribedFrame = unsubscribedFrame;
- }
- return SubscriptionLog;
- }());
-
- var SubscriptionLoggable = (function () {
- function SubscriptionLoggable() {
- this.subscriptions = [];
- }
- SubscriptionLoggable.prototype.logSubscribedFrame = function () {
- this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));
- return this.subscriptions.length - 1;
- };
- SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) {
- var subscriptionLogs = this.subscriptions;
- var oldSubscriptionLog = subscriptionLogs[index];
- subscriptionLogs[index] = new SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
- };
- return SubscriptionLoggable;
- }());
-
- function applyMixins(derivedCtor, baseCtors) {
- for (var i = 0, len = baseCtors.length; i < len; i++) {
- var baseCtor = baseCtors[i];
- var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype);
- for (var j = 0, len2 = propertyKeys.length; j < len2; j++) {
- var name_1 = propertyKeys[j];
- derivedCtor.prototype[name_1] = baseCtor.prototype[name_1];
- }
- }
- }
-
- var ColdObservable = (function (_super) {
- __extends(ColdObservable, _super);
- function ColdObservable(messages, scheduler) {
- var _this = _super.call(this, function (subscriber) {
- var observable = this;
- var index = observable.logSubscribedFrame();
- var subscription = new Subscription();
- subscription.add(new Subscription(function () {
- observable.logUnsubscribedFrame(index);
- }));
- observable.scheduleMessages(subscriber);
- return subscription;
- }) || this;
- _this.messages = messages;
- _this.subscriptions = [];
- _this.scheduler = scheduler;
- return _this;
- }
- ColdObservable.prototype.scheduleMessages = function (subscriber) {
- var messagesLength = this.messages.length;
- for (var i = 0; i < messagesLength; i++) {
- var message = this.messages[i];
- subscriber.add(this.scheduler.schedule(function (_a) {
- var message = _a.message, subscriber = _a.subscriber;
- message.notification.observe(subscriber);
- }, message.frame, { message: message, subscriber: subscriber }));
- }
- };
- return ColdObservable;
- }(Observable));
- applyMixins(ColdObservable, [SubscriptionLoggable]);
-
- var HotObservable = (function (_super) {
- __extends(HotObservable, _super);
- function HotObservable(messages, scheduler) {
- var _this = _super.call(this) || this;
- _this.messages = messages;
- _this.subscriptions = [];
- _this.scheduler = scheduler;
- return _this;
- }
- HotObservable.prototype._subscribe = function (subscriber) {
- var subject = this;
- var index = subject.logSubscribedFrame();
- var subscription = new Subscription();
- subscription.add(new Subscription(function () {
- subject.logUnsubscribedFrame(index);
- }));
- subscription.add(_super.prototype._subscribe.call(this, subscriber));
- return subscription;
- };
- HotObservable.prototype.setup = function () {
- var subject = this;
- var messagesLength = subject.messages.length;
- for (var i = 0; i < messagesLength; i++) {
- (function () {
- var message = subject.messages[i];
- subject.scheduler.schedule(function () { message.notification.observe(subject); }, message.frame);
- })();
- }
- };
- return HotObservable;
- }(Subject));
- applyMixins(HotObservable, [SubscriptionLoggable]);
-
- var defaultMaxFrame = 750;
- var TestScheduler = (function (_super) {
- __extends(TestScheduler, _super);
- function TestScheduler(assertDeepEqual) {
- var _this = _super.call(this, VirtualAction, defaultMaxFrame) || this;
- _this.assertDeepEqual = assertDeepEqual;
- _this.hotObservables = [];
- _this.coldObservables = [];
- _this.flushTests = [];
- _this.runMode = false;
- return _this;
- }
- TestScheduler.prototype.createTime = function (marbles) {
- var indexOf = marbles.indexOf('|');
- if (indexOf === -1) {
- throw new Error('marble diagram for time should have a completion marker "|"');
- }
- return indexOf * TestScheduler.frameTimeFactor;
- };
- TestScheduler.prototype.createColdObservable = function (marbles, values, error) {
- if (marbles.indexOf('^') !== -1) {
- throw new Error('cold observable cannot have subscription offset "^"');
- }
- if (marbles.indexOf('!') !== -1) {
- throw new Error('cold observable cannot have unsubscription marker "!"');
- }
- var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
- var cold = new ColdObservable(messages, this);
- this.coldObservables.push(cold);
- return cold;
- };
- TestScheduler.prototype.createHotObservable = function (marbles, values, error) {
- if (marbles.indexOf('!') !== -1) {
- throw new Error('hot observable cannot have unsubscription marker "!"');
- }
- var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
- var subject = new HotObservable(messages, this);
- this.hotObservables.push(subject);
- return subject;
- };
- TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) {
- var _this = this;
- var messages = [];
- observable.subscribe(function (value) {
- messages.push({ frame: _this.frame - outerFrame, notification: Notification.createNext(value) });
- }, function (err) {
- messages.push({ frame: _this.frame - outerFrame, notification: Notification.createError(err) });
- }, function () {
- messages.push({ frame: _this.frame - outerFrame, notification: Notification.createComplete() });
- });
- return messages;
- };
- TestScheduler.prototype.expectObservable = function (observable, subscriptionMarbles) {
- var _this = this;
- if (subscriptionMarbles === void 0) { subscriptionMarbles = null; }
- var actual = [];
- var flushTest = { actual: actual, ready: false };
- var subscriptionParsed = TestScheduler.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode);
- var subscriptionFrame = subscriptionParsed.subscribedFrame === Number.POSITIVE_INFINITY ?
- 0 : subscriptionParsed.subscribedFrame;
- var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame;
- var subscription;
- this.schedule(function () {
- subscription = observable.subscribe(function (x) {
- var value = x;
- if (x instanceof Observable) {
- value = _this.materializeInnerObservable(value, _this.frame);
- }
- actual.push({ frame: _this.frame, notification: Notification.createNext(value) });
- }, function (err) {
- actual.push({ frame: _this.frame, notification: Notification.createError(err) });
- }, function () {
- actual.push({ frame: _this.frame, notification: Notification.createComplete() });
- });
- }, subscriptionFrame);
- if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
- this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame);
- }
- this.flushTests.push(flushTest);
- var runMode = this.runMode;
- return {
- toBe: function (marbles, values, errorValue) {
- flushTest.ready = true;
- flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true, runMode);
- }
- };
- };
- TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) {
- var flushTest = { actual: actualSubscriptionLogs, ready: false };
- this.flushTests.push(flushTest);
- var runMode = this.runMode;
- return {
- toBe: function (marbles) {
- var marblesArray = (typeof marbles === 'string') ? [marbles] : marbles;
- flushTest.ready = true;
- flushTest.expected = marblesArray.map(function (marbles) {
- return TestScheduler.parseMarblesAsSubscriptions(marbles, runMode);
- });
- }
- };
- };
- TestScheduler.prototype.flush = function () {
- var _this = this;
- var hotObservables = this.hotObservables;
- while (hotObservables.length > 0) {
- hotObservables.shift().setup();
- }
- _super.prototype.flush.call(this);
- this.flushTests = this.flushTests.filter(function (test) {
- if (test.ready) {
- _this.assertDeepEqual(test.actual, test.expected);
- return false;
- }
- return true;
- });
- };
- TestScheduler.parseMarblesAsSubscriptions = function (marbles, runMode) {
- var _this = this;
- if (runMode === void 0) { runMode = false; }
- if (typeof marbles !== 'string') {
- return new SubscriptionLog(Number.POSITIVE_INFINITY);
- }
- var len = marbles.length;
- var groupStart = -1;
- var subscriptionFrame = Number.POSITIVE_INFINITY;
- var unsubscriptionFrame = Number.POSITIVE_INFINITY;
- var frame = 0;
- var _loop_1 = function (i) {
- var nextFrame = frame;
- var advanceFrameBy = function (count) {
- nextFrame += count * _this.frameTimeFactor;
- };
- var c = marbles[i];
- switch (c) {
- case ' ':
- if (!runMode) {
- advanceFrameBy(1);
- }
- break;
- case '-':
- advanceFrameBy(1);
- break;
- case '(':
- groupStart = frame;
- advanceFrameBy(1);
- break;
- case ')':
- groupStart = -1;
- advanceFrameBy(1);
- break;
- case '^':
- if (subscriptionFrame !== Number.POSITIVE_INFINITY) {
- throw new Error('found a second subscription point \'^\' in a ' +
- 'subscription marble diagram. There can only be one.');
- }
- subscriptionFrame = groupStart > -1 ? groupStart : frame;
- advanceFrameBy(1);
- break;
- case '!':
- if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
- throw new Error('found a second subscription point \'^\' in a ' +
- 'subscription marble diagram. There can only be one.');
- }
- unsubscriptionFrame = groupStart > -1 ? groupStart : frame;
- break;
- default:
- if (runMode && c.match(/^[0-9]$/)) {
- if (i === 0 || marbles[i - 1] === ' ') {
- var buffer = marbles.slice(i);
- var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
- if (match) {
- i += match[0].length - 1;
- var duration = parseFloat(match[1]);
- var unit = match[2];
- var durationInMs = void 0;
- switch (unit) {
- case 'ms':
- durationInMs = duration;
- break;
- case 's':
- durationInMs = duration * 1000;
- break;
- case 'm':
- durationInMs = duration * 1000 * 60;
- break;
- default:
- break;
- }
- advanceFrameBy(durationInMs / this_1.frameTimeFactor);
- break;
- }
- }
- }
- throw new Error('there can only be \'^\' and \'!\' markers in a ' +
- 'subscription marble diagram. Found instead \'' + c + '\'.');
- }
- frame = nextFrame;
- out_i_1 = i;
- };
- var this_1 = this, out_i_1;
- for (var i = 0; i < len; i++) {
- _loop_1(i);
- i = out_i_1;
- }
- if (unsubscriptionFrame < 0) {
- return new SubscriptionLog(subscriptionFrame);
- }
- else {
- return new SubscriptionLog(subscriptionFrame, unsubscriptionFrame);
- }
- };
- TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables, runMode) {
- var _this = this;
- if (materializeInnerObservables === void 0) { materializeInnerObservables = false; }
- if (runMode === void 0) { runMode = false; }
- if (marbles.indexOf('!') !== -1) {
- throw new Error('conventional marble diagrams cannot have the ' +
- 'unsubscription marker "!"');
- }
- var len = marbles.length;
- var testMessages = [];
- var subIndex = runMode ? marbles.replace(/^[ ]+/, '').indexOf('^') : marbles.indexOf('^');
- var frame = subIndex === -1 ? 0 : (subIndex * -this.frameTimeFactor);
- var getValue = typeof values !== 'object' ?
- function (x) { return x; } :
- function (x) {
- if (materializeInnerObservables && values[x] instanceof ColdObservable) {
- return values[x].messages;
- }
- return values[x];
- };
- var groupStart = -1;
- var _loop_2 = function (i) {
- var nextFrame = frame;
- var advanceFrameBy = function (count) {
- nextFrame += count * _this.frameTimeFactor;
- };
- var notification = void 0;
- var c = marbles[i];
- switch (c) {
- case ' ':
- if (!runMode) {
- advanceFrameBy(1);
- }
- break;
- case '-':
- advanceFrameBy(1);
- break;
- case '(':
- groupStart = frame;
- advanceFrameBy(1);
- break;
- case ')':
- groupStart = -1;
- advanceFrameBy(1);
- break;
- case '|':
- notification = Notification.createComplete();
- advanceFrameBy(1);
- break;
- case '^':
- advanceFrameBy(1);
- break;
- case '#':
- notification = Notification.createError(errorValue || 'error');
- advanceFrameBy(1);
- break;
- default:
- if (runMode && c.match(/^[0-9]$/)) {
- if (i === 0 || marbles[i - 1] === ' ') {
- var buffer = marbles.slice(i);
- var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
- if (match) {
- i += match[0].length - 1;
- var duration = parseFloat(match[1]);
- var unit = match[2];
- var durationInMs = void 0;
- switch (unit) {
- case 'ms':
- durationInMs = duration;
- break;
- case 's':
- durationInMs = duration * 1000;
- break;
- case 'm':
- durationInMs = duration * 1000 * 60;
- break;
- default:
- break;
- }
- advanceFrameBy(durationInMs / this_2.frameTimeFactor);
- break;
- }
- }
- }
- notification = Notification.createNext(getValue(c));
- advanceFrameBy(1);
- break;
- }
- if (notification) {
- testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification });
- }
- frame = nextFrame;
- out_i_2 = i;
- };
- var this_2 = this, out_i_2;
- for (var i = 0; i < len; i++) {
- _loop_2(i);
- i = out_i_2;
- }
- return testMessages;
- };
- TestScheduler.prototype.run = function (callback) {
- var prevFrameTimeFactor = TestScheduler.frameTimeFactor;
- var prevMaxFrames = this.maxFrames;
- TestScheduler.frameTimeFactor = 1;
- this.maxFrames = Number.POSITIVE_INFINITY;
- this.runMode = true;
- AsyncScheduler.delegate = this;
- var helpers = {
- cold: this.createColdObservable.bind(this),
- hot: this.createHotObservable.bind(this),
- flush: this.flush.bind(this),
- expectObservable: this.expectObservable.bind(this),
- expectSubscriptions: this.expectSubscriptions.bind(this),
- };
- try {
- var ret = callback(helpers);
- this.flush();
- return ret;
- }
- finally {
- TestScheduler.frameTimeFactor = prevFrameTimeFactor;
- this.maxFrames = prevMaxFrames;
- this.runMode = false;
- AsyncScheduler.delegate = undefined;
- }
- };
- return TestScheduler;
- }(VirtualTimeScheduler));
-
-
-
- var _testing = Object.freeze({
- TestScheduler: TestScheduler
- });
-
- var __window = typeof window !== 'undefined' && window;
- var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
- self instanceof WorkerGlobalScope && self;
- var __global = typeof global !== 'undefined' && global;
- var _root = __window || __global || __self;
- (function () {
- if (!_root) {
- throw new Error('RxJS could not find any global context (window, self, global)');
- }
- })();
-
- function getCORSRequest() {
- if (_root.XMLHttpRequest) {
- return new _root.XMLHttpRequest();
- }
- else if (!!_root.XDomainRequest) {
- return new _root.XDomainRequest();
- }
- else {
- throw new Error('CORS is not supported by your browser');
- }
- }
- function getXMLHttpRequest() {
- if (_root.XMLHttpRequest) {
- return new _root.XMLHttpRequest();
- }
- else {
- var progId = void 0;
- try {
- var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
- for (var i = 0; i < 3; i++) {
- try {
- progId = progIds[i];
- if (new _root.ActiveXObject(progId)) {
- break;
- }
- }
- catch (e) {
- }
- }
- return new _root.ActiveXObject(progId);
- }
- catch (e) {
- throw new Error('XMLHttpRequest is not supported by your browser');
- }
- }
- }
- function ajaxGet(url, headers) {
- if (headers === void 0) { headers = null; }
- return new AjaxObservable({ method: 'GET', url: url, headers: headers });
- }
- function ajaxPost(url, body, headers) {
- return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers });
- }
- function ajaxDelete(url, headers) {
- return new AjaxObservable({ method: 'DELETE', url: url, headers: headers });
- }
- function ajaxPut(url, body, headers) {
- return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers });
- }
- function ajaxPatch(url, body, headers) {
- return new AjaxObservable({ method: 'PATCH', url: url, body: body, headers: headers });
- }
- var mapResponse = map(function (x, index) { return x.response; });
- function ajaxGetJSON(url, headers) {
- return mapResponse(new AjaxObservable({
- method: 'GET',
- url: url,
- responseType: 'json',
- headers: headers
- }));
- }
- var AjaxObservable = (function (_super) {
- __extends(AjaxObservable, _super);
- function AjaxObservable(urlOrRequest) {
- var _this = _super.call(this) || this;
- var request = {
- async: true,
- createXHR: function () {
- return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();
- },
- crossDomain: true,
- withCredentials: false,
- headers: {},
- method: 'GET',
- responseType: 'json',
- timeout: 0
- };
- if (typeof urlOrRequest === 'string') {
- request.url = urlOrRequest;
- }
- else {
- for (var prop in urlOrRequest) {
- if (urlOrRequest.hasOwnProperty(prop)) {
- request[prop] = urlOrRequest[prop];
- }
- }
- }
- _this.request = request;
- return _this;
- }
- AjaxObservable.prototype._subscribe = function (subscriber) {
- return new AjaxSubscriber(subscriber, this.request);
- };
- AjaxObservable.create = (function () {
- var create = function (urlOrRequest) {
- return new AjaxObservable(urlOrRequest);
- };
- create.get = ajaxGet;
- create.post = ajaxPost;
- create.delete = ajaxDelete;
- create.put = ajaxPut;
- create.patch = ajaxPatch;
- create.getJSON = ajaxGetJSON;
- return create;
- })();
- return AjaxObservable;
- }(Observable));
- var AjaxSubscriber = (function (_super) {
- __extends(AjaxSubscriber, _super);
- function AjaxSubscriber(destination, request) {
- var _this = _super.call(this, destination) || this;
- _this.request = request;
- _this.done = false;
- var headers = request.headers = request.headers || {};
- if (!request.crossDomain && !headers['X-Requested-With']) {
- headers['X-Requested-With'] = 'XMLHttpRequest';
- }
- if (!('Content-Type' in headers) && !(_root.FormData && request.body instanceof _root.FormData) && typeof request.body !== 'undefined') {
- headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
- }
- request.body = _this.serializeBody(request.body, request.headers['Content-Type']);
- _this.send();
- return _this;
- }
- AjaxSubscriber.prototype.next = function (e) {
- this.done = true;
- var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination;
- var response = new AjaxResponse(e, xhr, request);
- if (response.response === errorObject) {
- destination.error(errorObject.e);
- }
- else {
- destination.next(response);
- }
- };
- AjaxSubscriber.prototype.send = function () {
- var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body;
- var createXHR = request.createXHR;
- var xhr = tryCatch(createXHR).call(request);
- if (xhr === errorObject) {
- this.error(errorObject.e);
- }
- else {
- this.xhr = xhr;
- this.setupEvents(xhr, request);
- var result = void 0;
- if (user) {
- result = tryCatch(xhr.open).call(xhr, method, url, async, user, password);
- }
- else {
- result = tryCatch(xhr.open).call(xhr, method, url, async);
- }
- if (result === errorObject) {
- this.error(errorObject.e);
- return null;
- }
- if (async) {
- xhr.timeout = request.timeout;
- xhr.responseType = request.responseType;
- }
- if ('withCredentials' in xhr) {
- xhr.withCredentials = !!request.withCredentials;
- }
- this.setHeaders(xhr, headers);
- result = body ? tryCatch(xhr.send).call(xhr, body) : tryCatch(xhr.send).call(xhr);
- if (result === errorObject) {
- this.error(errorObject.e);
- return null;
- }
- }
- return xhr;
- };
- AjaxSubscriber.prototype.serializeBody = function (body, contentType) {
- if (!body || typeof body === 'string') {
- return body;
- }
- else if (_root.FormData && body instanceof _root.FormData) {
- return body;
- }
- if (contentType) {
- var splitIndex = contentType.indexOf(';');
- if (splitIndex !== -1) {
- contentType = contentType.substring(0, splitIndex);
- }
- }
- switch (contentType) {
- case 'application/x-www-form-urlencoded':
- return Object.keys(body).map(function (key) { return encodeURIComponent(key) + "=" + encodeURIComponent(body[key]); }).join('&');
- case 'application/json':
- return JSON.stringify(body);
- default:
- return body;
- }
- };
- AjaxSubscriber.prototype.setHeaders = function (xhr, headers) {
- for (var key in headers) {
- if (headers.hasOwnProperty(key)) {
- xhr.setRequestHeader(key, headers[key]);
- }
- }
- };
- AjaxSubscriber.prototype.setupEvents = function (xhr, request) {
- var progressSubscriber = request.progressSubscriber;
- function xhrTimeout(e) {
- var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
- if (progressSubscriber) {
- progressSubscriber.error(e);
- }
- var ajaxTimeoutError = new AjaxTimeoutError(this, request);
- if (ajaxTimeoutError.response === errorObject) {
- subscriber.error(errorObject.e);
- }
- else {
- subscriber.error(ajaxTimeoutError);
- }
- }
- xhr.ontimeout = xhrTimeout;
- xhrTimeout.request = request;
- xhrTimeout.subscriber = this;
- xhrTimeout.progressSubscriber = progressSubscriber;
- if (xhr.upload && 'withCredentials' in xhr) {
- if (progressSubscriber) {
- var xhrProgress_1;
- xhrProgress_1 = function (e) {
- var progressSubscriber = xhrProgress_1.progressSubscriber;
- progressSubscriber.next(e);
- };
- if (_root.XDomainRequest) {
- xhr.onprogress = xhrProgress_1;
- }
- else {
- xhr.upload.onprogress = xhrProgress_1;
- }
- xhrProgress_1.progressSubscriber = progressSubscriber;
- }
- var xhrError_1;
- xhrError_1 = function (e) {
- var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request;
- if (progressSubscriber) {
- progressSubscriber.error(e);
- }
- var ajaxError = new AjaxError('ajax error', this, request);
- if (ajaxError.response === errorObject) {
- subscriber.error(errorObject.e);
- }
- else {
- subscriber.error(ajaxError);
- }
- };
- xhr.onerror = xhrError_1;
- xhrError_1.request = request;
- xhrError_1.subscriber = this;
- xhrError_1.progressSubscriber = progressSubscriber;
- }
- function xhrReadyStateChange(e) {
- return;
- }
- xhr.onreadystatechange = xhrReadyStateChange;
- xhrReadyStateChange.subscriber = this;
- xhrReadyStateChange.progressSubscriber = progressSubscriber;
- xhrReadyStateChange.request = request;
- function xhrLoad(e) {
- var _a = xhrLoad, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
- if (this.readyState === 4) {
- var status_1 = this.status === 1223 ? 204 : this.status;
- var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response);
- if (status_1 === 0) {
- status_1 = response ? 200 : 0;
- }
- if (status_1 < 400) {
- if (progressSubscriber) {
- progressSubscriber.complete();
- }
- subscriber.next(e);
- subscriber.complete();
- }
- else {
- if (progressSubscriber) {
- progressSubscriber.error(e);
- }
- var ajaxError = new AjaxError('ajax error ' + status_1, this, request);
- if (ajaxError.response === errorObject) {
- subscriber.error(errorObject.e);
- }
- else {
- subscriber.error(ajaxError);
- }
- }
- }
- }
- xhr.onload = xhrLoad;
- xhrLoad.subscriber = this;
- xhrLoad.progressSubscriber = progressSubscriber;
- xhrLoad.request = request;
- };
- AjaxSubscriber.prototype.unsubscribe = function () {
- var _a = this, done = _a.done, xhr = _a.xhr;
- if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') {
- xhr.abort();
- }
- _super.prototype.unsubscribe.call(this);
- };
- return AjaxSubscriber;
- }(Subscriber));
- var AjaxResponse = (function () {
- function AjaxResponse(originalEvent, xhr, request) {
- this.originalEvent = originalEvent;
- this.xhr = xhr;
- this.request = request;
- this.status = xhr.status;
- this.responseType = xhr.responseType || request.responseType;
- this.response = parseXhrResponse(this.responseType, xhr);
- }
- return AjaxResponse;
- }());
- function AjaxErrorImpl(message, xhr, request) {
- Error.call(this);
- this.message = message;
- this.name = 'AjaxError';
- this.xhr = xhr;
- this.request = request;
- this.status = xhr.status;
- this.responseType = xhr.responseType || request.responseType;
- this.response = parseXhrResponse(this.responseType, xhr);
- return this;
- }
- AjaxErrorImpl.prototype = Object.create(Error.prototype);
- var AjaxError = AjaxErrorImpl;
- function parseJson(xhr) {
- if ('response' in xhr) {
- return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');
- }
- else {
- return JSON.parse(xhr.responseText || 'null');
- }
- }
- function parseXhrResponse(responseType, xhr) {
- switch (responseType) {
- case 'json':
- return tryCatch(parseJson)(xhr);
- case 'xml':
- return xhr.responseXML;
- case 'text':
- default:
- return ('response' in xhr) ? xhr.response : xhr.responseText;
- }
- }
- function AjaxTimeoutErrorImpl(xhr, request) {
- AjaxError.call(this, 'ajax timeout', xhr, request);
- this.name = 'AjaxTimeoutError';
- return this;
- }
- var AjaxTimeoutError = AjaxTimeoutErrorImpl;
-
- var ajax$1 = AjaxObservable.create;
-
-
-
- var _ajax = Object.freeze({
- ajax: ajax$1,
- AjaxResponse: AjaxResponse,
- AjaxError: AjaxError,
- AjaxTimeoutError: AjaxTimeoutError
- });
-
- var DEFAULT_WEBSOCKET_CONFIG = {
- url: '',
- deserializer: function (e) { return JSON.parse(e.data); },
- serializer: function (value) { return JSON.stringify(value); },
- };
- var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';
- var WebSocketSubject = (function (_super) {
- __extends(WebSocketSubject, _super);
- function WebSocketSubject(urlConfigOrSource, destination) {
- var _this = _super.call(this) || this;
- if (urlConfigOrSource instanceof Observable) {
- _this.destination = destination;
- _this.source = urlConfigOrSource;
- }
- else {
- var config = _this._config = __assign({}, DEFAULT_WEBSOCKET_CONFIG);
- _this._output = new Subject();
- if (typeof urlConfigOrSource === 'string') {
- config.url = urlConfigOrSource;
- }
- else {
- for (var key in urlConfigOrSource) {
- if (urlConfigOrSource.hasOwnProperty(key)) {
- config[key] = urlConfigOrSource[key];
- }
- }
- }
- if (!config.WebSocketCtor && WebSocket) {
- config.WebSocketCtor = WebSocket;
- }
- else if (!config.WebSocketCtor) {
- throw new Error('no WebSocket constructor can be found');
- }
- _this.destination = new ReplaySubject();
- }
- return _this;
- }
- WebSocketSubject.prototype.lift = function (operator) {
- var sock = new WebSocketSubject(this._config, this.destination);
- sock.operator = operator;
- sock.source = this;
- return sock;
- };
- WebSocketSubject.prototype._resetState = function () {
- this._socket = null;
- if (!this.source) {
- this.destination = new ReplaySubject();
- }
- this._output = new Subject();
- };
- WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) {
- var self = this;
- return new Observable(function (observer) {
- var result = tryCatch(subMsg)();
- if (result === errorObject) {
- observer.error(errorObject.e);
- }
- else {
- self.next(result);
- }
- var subscription = self.subscribe(function (x) {
- var result = tryCatch(messageFilter)(x);
- if (result === errorObject) {
- observer.error(errorObject.e);
- }
- else if (result) {
- observer.next(x);
- }
- }, function (err) { return observer.error(err); }, function () { return observer.complete(); });
- return function () {
- var result = tryCatch(unsubMsg)();
- if (result === errorObject) {
- observer.error(errorObject.e);
- }
- else {
- self.next(result);
- }
- subscription.unsubscribe();
- };
- });
- };
- WebSocketSubject.prototype._connectSocket = function () {
- var _this = this;
- var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType;
- var observer = this._output;
- var socket = null;
- try {
- socket = protocol ?
- new WebSocketCtor(url, protocol) :
- new WebSocketCtor(url);
- this._socket = socket;
- if (binaryType) {
- this._socket.binaryType = binaryType;
- }
- }
- catch (e) {
- observer.error(e);
- return;
- }
- var subscription = new Subscription(function () {
- _this._socket = null;
- if (socket && socket.readyState === 1) {
- socket.close();
- }
- });
- socket.onopen = function (e) {
- var openObserver = _this._config.openObserver;
- if (openObserver) {
- openObserver.next(e);
- }
- var queue = _this.destination;
- _this.destination = Subscriber.create(function (x) {
- if (socket.readyState === 1) {
- var serializer = _this._config.serializer;
- var msg = tryCatch(serializer)(x);
- if (msg === errorObject) {
- _this.destination.error(errorObject.e);
- return;
- }
- socket.send(msg);
- }
- }, function (e) {
- var closingObserver = _this._config.closingObserver;
- if (closingObserver) {
- closingObserver.next(undefined);
- }
- if (e && e.code) {
- socket.close(e.code, e.reason);
- }
- else {
- observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
- }
- _this._resetState();
- }, function () {
- var closingObserver = _this._config.closingObserver;
- if (closingObserver) {
- closingObserver.next(undefined);
- }
- socket.close();
- _this._resetState();
- });
- if (queue && queue instanceof ReplaySubject) {
- subscription.add(queue.subscribe(_this.destination));
- }
- };
- socket.onerror = function (e) {
- _this._resetState();
- observer.error(e);
- };
- socket.onclose = function (e) {
- _this._resetState();
- var closeObserver = _this._config.closeObserver;
- if (closeObserver) {
- closeObserver.next(e);
- }
- if (e.wasClean) {
- observer.complete();
- }
- else {
- observer.error(e);
- }
- };
- socket.onmessage = function (e) {
- var deserializer = _this._config.deserializer;
- var result = tryCatch(deserializer)(e);
- if (result === errorObject) {
- observer.error(errorObject.e);
- }
- else {
- observer.next(result);
- }
- };
- };
- WebSocketSubject.prototype._subscribe = function (subscriber) {
- var _this = this;
- var source = this.source;
- if (source) {
- return source.subscribe(subscriber);
- }
- if (!this._socket) {
- this._connectSocket();
- }
- this._output.subscribe(subscriber);
- subscriber.add(function () {
- var _socket = _this._socket;
- if (_this._output.observers.length === 0) {
- if (_socket && _socket.readyState === 1) {
- _socket.close();
- }
- _this._resetState();
- }
- });
- return subscriber;
- };
- WebSocketSubject.prototype.unsubscribe = function () {
- var _a = this, source = _a.source, _socket = _a._socket;
- if (_socket && _socket.readyState === 1) {
- _socket.close();
- this._resetState();
- }
- _super.prototype.unsubscribe.call(this);
- if (!source) {
- this.destination = new ReplaySubject();
- }
- };
- return WebSocketSubject;
- }(AnonymousSubject));
-
- function webSocket$1(urlConfigOrSource) {
- return new WebSocketSubject(urlConfigOrSource);
- }
-
-
-
- var _webSocket = Object.freeze({
- webSocket: webSocket$1,
- WebSocketSubject: WebSocketSubject
- });
-
- var operators = _operators;
- var testing = _testing;
- var ajax$$1 = _ajax;
- var webSocket$$1 = _webSocket;
-
- exports.operators = operators;
- exports.testing = testing;
- exports.ajax = ajax$$1;
- exports.webSocket = webSocket$$1;
- exports.Observable = Observable;
- exports.ConnectableObservable = ConnectableObservable;
- exports.GroupedObservable = GroupedObservable;
- exports.observable = observable;
- exports.Subject = Subject;
- exports.BehaviorSubject = BehaviorSubject;
- exports.ReplaySubject = ReplaySubject;
- exports.AsyncSubject = AsyncSubject;
- exports.asapScheduler = asap;
- exports.asyncScheduler = async;
- exports.queueScheduler = queue;
- exports.animationFrameScheduler = animationFrame;
- exports.VirtualTimeScheduler = VirtualTimeScheduler;
- exports.VirtualAction = VirtualAction;
- exports.Scheduler = Scheduler;
- exports.Subscription = Subscription;
- exports.Subscriber = Subscriber;
- exports.Notification = Notification;
- exports.pipe = pipe;
- exports.noop = noop;
- exports.identity = identity;
- exports.isObservable = isObservable;
- exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
- exports.EmptyError = EmptyError;
- exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
- exports.UnsubscriptionError = UnsubscriptionError;
- exports.TimeoutError = TimeoutError;
- exports.bindCallback = bindCallback;
- exports.bindNodeCallback = bindNodeCallback;
- exports.combineLatest = combineLatest;
- exports.concat = concat;
- exports.defer = defer;
- exports.empty = empty$1;
- exports.forkJoin = forkJoin;
- exports.from = from;
- exports.fromEvent = fromEvent;
- exports.fromEventPattern = fromEventPattern;
- exports.generate = generate;
- exports.iif = iif;
- exports.interval = interval;
- exports.merge = merge;
- exports.never = never;
- exports.of = of;
- exports.onErrorResumeNext = onErrorResumeNext;
- exports.pairs = pairs;
- exports.race = race;
- exports.range = range;
- exports.throwError = throwError;
- exports.timer = timer;
- exports.using = using;
- exports.zip = zip;
- exports.EMPTY = EMPTY;
- exports.NEVER = NEVER;
- exports.config = config;
-
- Object.defineProperty(exports, '__esModule', { value: true });
-
- })));
-
|