123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420 |
- /**
- @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('rxjs', ['exports'], factory) :
- (factory((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 __rest(s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
- t[p[i]] = s[p[i]];
- return t;
- }
-
- 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; }, 0);
- }
-
- var empty = {
- closed: true,
- next: function (value) { },
- error: function (err) {
- if (config.useDeprecatedSynchronousErrorHandling) {
- throw err;
- }
- else {
- hostReportError(err);
- }
- },
- complete: function () { }
- };
-
- var isArray = (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
-
- function isObject(x) {
- return x !== null && typeof x === 'object';
- }
-
- var UnsubscriptionErrorImpl = (function () {
- 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);
- return UnsubscriptionErrorImpl;
- })();
- var UnsubscriptionError = UnsubscriptionErrorImpl;
-
- var Subscription = (function () {
- function Subscription(unsubscribe) {
- this.closed = false;
- this._parentOrParents = null;
- this._subscriptions = null;
- if (unsubscribe) {
- this._ctorUnsubscribe = true;
- this._unsubscribe = unsubscribe;
- }
- }
- Subscription.prototype.unsubscribe = function () {
- var errors;
- if (this.closed) {
- return;
- }
- var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
- this.closed = true;
- this._parentOrParents = null;
- this._subscriptions = null;
- if (_parentOrParents instanceof Subscription) {
- _parentOrParents.remove(this);
- }
- else if (_parentOrParents !== null) {
- for (var index = 0; index < _parentOrParents.length; ++index) {
- var parent_1 = _parentOrParents[index];
- parent_1.remove(this);
- }
- }
- if (isFunction(_unsubscribe)) {
- if (_ctorUnsubscribe) {
- this._unsubscribe = undefined;
- }
- try {
- _unsubscribe.call(this);
- }
- catch (e) {
- errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
- }
- }
- if (isArray(_subscriptions)) {
- var index = -1;
- var len = _subscriptions.length;
- while (++index < len) {
- var sub = _subscriptions[index];
- if (isObject(sub)) {
- try {
- sub.unsubscribe();
- }
- catch (e) {
- errors = errors || [];
- if (e instanceof UnsubscriptionError) {
- errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
- }
- else {
- errors.push(e);
- }
- }
- }
- }
- }
- if (errors) {
- throw new UnsubscriptionError(errors);
- }
- };
- Subscription.prototype.add = function (teardown) {
- var subscription = teardown;
- if (!teardown) {
- return Subscription.EMPTY;
- }
- switch (typeof teardown) {
- case 'function':
- subscription = new Subscription(teardown);
- case 'object':
- if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
- return subscription;
- }
- else if (this.closed) {
- subscription.unsubscribe();
- return subscription;
- }
- else if (!(subscription instanceof Subscription)) {
- var tmp = subscription;
- subscription = new Subscription();
- subscription._subscriptions = [tmp];
- }
- break;
- default: {
- throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
- }
- }
- var _parentOrParents = subscription._parentOrParents;
- if (_parentOrParents === null) {
- subscription._parentOrParents = this;
- }
- else if (_parentOrParents instanceof Subscription) {
- if (_parentOrParents === this) {
- return subscription;
- }
- subscription._parentOrParents = [_parentOrParents, this];
- }
- else if (_parentOrParents.indexOf(this) === -1) {
- _parentOrParents.push(this);
- }
- else {
- return subscription;
- }
- var subscriptions = this._subscriptions;
- if (subscriptions === null) {
- this._subscriptions = [subscription];
- }
- else {
- subscriptions.push(subscription);
- }
- 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.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 = (function () {
- return 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;
- 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 _parentOrParents = this._parentOrParents;
- this._parentOrParents = null;
- this.unsubscribe();
- this.closed = false;
- this.isStopped = false;
- this._parentOrParents = _parentOrParents;
- 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 = (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
-
- function identity(x) {
- return x;
- }
-
- function pipe() {
- var fns = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- fns[_i] = arguments[_i];
- }
- return pipeFromArray(fns);
- }
- function pipeFromArray(fns) {
- if (fns.length === 0) {
- return identity;
- }
- 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) {
- sink.add(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;
- }
-
- var ObjectUnsubscribedErrorImpl = (function () {
- function ObjectUnsubscribedErrorImpl() {
- Error.call(this);
- this.message = 'object unsubscribed';
- this.name = 'ObjectUnsubscribedError';
- return this;
- }
- ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
- return ObjectUnsubscribedErrorImpl;
- })();
- 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(source));
- };
- }
- var RefCountOperator = (function () {
- function RefCountOperator(connectable) {
- this.connectable = connectable;
- }
- RefCountOperator.prototype.call = function (subscriber, source) {
- var connectable = this.connectable;
- connectable._refCount++;
- var refCounter = new RefCountSubscriber(subscriber, connectable);
- var subscription = source.subscribe(refCounter);
- if (!refCounter.closed) {
- refCounter.connection = connectable.connect();
- }
- return subscription;
- };
- return RefCountOperator;
- }());
- 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 = 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;
- }
- }
- return connection;
- };
- ConnectableObservable.prototype.refCount = function () {
- return refCount()(this);
- };
- return ConnectableObservable;
- }(Observable));
- var connectableObservableDescriptor = (function () {
- var connectableProto = ConnectableObservable.prototype;
- return {
- 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$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$$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);
- return undefined;
- };
- 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 queueScheduler = new QueueScheduler(QueueAction);
- var queue = queueScheduler;
-
- 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]);
- }
- subscriber.complete();
- }; };
-
- function scheduleArray(input, scheduler) {
- 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 fromArray(input, scheduler) {
- if (!scheduler) {
- return new Observable(subscribeToArray(input));
- }
- else {
- return scheduleArray(input, scheduler);
- }
- }
-
- 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();
- return scheduleArray(args, scheduler);
- }
- else {
- return fromArray(args);
- }
- }
-
- 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);
- }
-
- (function (NotificationKind) {
- NotificationKind["NEXT"] = "N";
- NotificationKind["ERROR"] = "E";
- NotificationKind["COMPLETE"] = "C";
- })(exports.NotificationKind || (exports.NotificationKind = {}));
- 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) {
- if (!this.isStopped) {
- 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) {
- if (!this.isStopped) {
- 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 RESOLVED = (function () { return Promise.resolve(); })();
- var activeHandles = {};
- function findAndClearHandle(handle) {
- if (handle in activeHandles) {
- delete activeHandles[handle];
- return true;
- }
- return false;
- }
- var Immediate = {
- setImmediate: function (cb) {
- var handle = nextHandle++;
- activeHandles[handle] = true;
- RESOLVED.then(function () { return findAndClearHandle(handle) && cb(); });
- return handle;
- },
- clearImmediate: function (handle) {
- findAndClearHandle(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 asapScheduler = new AsapScheduler(AsapAction);
- var asap = asapScheduler;
-
- var asyncScheduler = new AsyncScheduler(AsyncAction);
- var async = asyncScheduler;
-
- 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 animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction);
- var animationFrame = animationFrameScheduler;
-
- 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[0]) && action.delay <= maxFrames) {
- actions.shift();
- this.frame = action.delay;
- 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 noop() { }
-
- function isObservable(obj) {
- return !!obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
- }
-
- var ArgumentOutOfRangeErrorImpl = (function () {
- function ArgumentOutOfRangeErrorImpl() {
- Error.call(this);
- this.message = 'argument out of range';
- this.name = 'ArgumentOutOfRangeError';
- return this;
- }
- ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
- return ArgumentOutOfRangeErrorImpl;
- })();
- var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
-
- var EmptyErrorImpl = (function () {
- function EmptyErrorImpl() {
- Error.call(this);
- this.message = 'no elements in sequence';
- this.name = 'EmptyError';
- return this;
- }
- EmptyErrorImpl.prototype = Object.create(Error.prototype);
- return EmptyErrorImpl;
- })();
- var EmptyError = EmptyErrorImpl;
-
- var TimeoutErrorImpl = (function () {
- function TimeoutErrorImpl() {
- Error.call(this);
- this.message = 'Timeout has occurred';
- this.name = 'TimeoutError';
- return this;
- }
- TimeoutErrorImpl.prototype = Object.create(Error.prototype);
- return TimeoutErrorImpl;
- })();
- 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 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 = void 0;
- try {
- item = iterator$$1.next();
- }
- catch (err) {
- subscriber.error(err);
- return subscriber;
- }
- 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 && 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, innerSubscriber) {
- if (innerSubscriber === void 0) { innerSubscriber = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
- if (innerSubscriber.closed) {
- return undefined;
- }
- if (result instanceof Observable) {
- return result.subscribe(innerSubscriber);
- }
- return subscribeTo(result)(innerSubscriber);
- }
-
- var NONE = {};
- function combineLatest() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- var resultSelector = undefined;
- var scheduler = undefined;
- 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, undefined, i));
- }
- }
- };
- CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
- if ((this.active -= 1) === 0) {
- this.destination.complete();
- }
- };
- CombineLatestSubscriber.prototype.notifyNext = function (_outerValue, innerValue, outerIndex) {
- 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 scheduleObservable(input, scheduler) {
- 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 schedulePromise(input, scheduler) {
- 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 scheduleIterable(input, scheduler) {
- if (!input) {
- throw new Error('Iterable cannot be null');
- }
- 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 isInteropObservable(input) {
- return input && typeof input[observable] === 'function';
- }
-
- function isIterable(input) {
- return input && typeof input[iterator] === 'function';
- }
-
- function scheduled(input, scheduler) {
- if (input != null) {
- if (isInteropObservable(input)) {
- return scheduleObservable(input, scheduler);
- }
- else if (isPromise(input)) {
- return schedulePromise(input, scheduler);
- }
- else if (isArrayLike(input)) {
- return scheduleArray(input, scheduler);
- }
- else if (isIterable(input) || typeof input === 'string') {
- return scheduleIterable(input, scheduler);
- }
- }
- throw new TypeError((input !== null && typeof input || input) + ' is not observable');
- }
-
- function from(input, scheduler) {
- if (!scheduler) {
- if (input instanceof Observable) {
- return input;
- }
- return new Observable(subscribeTo(input));
- }
- else {
- return scheduled(input, scheduler);
- }
- }
-
- var SimpleInnerSubscriber = (function (_super) {
- __extends(SimpleInnerSubscriber, _super);
- function SimpleInnerSubscriber(parent) {
- var _this = _super.call(this) || this;
- _this.parent = parent;
- return _this;
- }
- SimpleInnerSubscriber.prototype._next = function (value) {
- this.parent.notifyNext(value);
- };
- SimpleInnerSubscriber.prototype._error = function (error) {
- this.parent.notifyError(error);
- this.unsubscribe();
- };
- SimpleInnerSubscriber.prototype._complete = function () {
- this.parent.notifyComplete();
- this.unsubscribe();
- };
- return SimpleInnerSubscriber;
- }(Subscriber));
- var ComplexInnerSubscriber = (function (_super) {
- __extends(ComplexInnerSubscriber, _super);
- function ComplexInnerSubscriber(parent, outerValue, outerIndex) {
- var _this = _super.call(this) || this;
- _this.parent = parent;
- _this.outerValue = outerValue;
- _this.outerIndex = outerIndex;
- return _this;
- }
- ComplexInnerSubscriber.prototype._next = function (value) {
- this.parent.notifyNext(this.outerValue, value, this.outerIndex, this);
- };
- ComplexInnerSubscriber.prototype._error = function (error) {
- this.parent.notifyError(error);
- this.unsubscribe();
- };
- ComplexInnerSubscriber.prototype._complete = function () {
- this.parent.notifyComplete(this);
- this.unsubscribe();
- };
- return ComplexInnerSubscriber;
- }(Subscriber));
- var SimpleOuterSubscriber = (function (_super) {
- __extends(SimpleOuterSubscriber, _super);
- function SimpleOuterSubscriber() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- SimpleOuterSubscriber.prototype.notifyNext = function (innerValue) {
- this.destination.next(innerValue);
- };
- SimpleOuterSubscriber.prototype.notifyError = function (err) {
- this.destination.error(err);
- };
- SimpleOuterSubscriber.prototype.notifyComplete = function () {
- this.destination.complete();
- };
- return SimpleOuterSubscriber;
- }(Subscriber));
- var ComplexOuterSubscriber = (function (_super) {
- __extends(ComplexOuterSubscriber, _super);
- function ComplexOuterSubscriber() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ComplexOuterSubscriber.prototype.notifyNext = function (_outerValue, innerValue, _outerIndex, _innerSub) {
- this.destination.next(innerValue);
- };
- ComplexOuterSubscriber.prototype.notifyError = function (error) {
- this.destination.error(error);
- };
- ComplexOuterSubscriber.prototype.notifyComplete = function (_innerSub) {
- this.destination.complete();
- };
- return ComplexOuterSubscriber;
- }(Subscriber));
- function innerSubscribe(result, innerSubscriber) {
- if (innerSubscriber.closed) {
- return undefined;
- }
- if (result instanceof Observable) {
- return result.subscribe(innerSubscriber);
- }
- return subscribeTo(result)(innerSubscriber);
- }
-
- 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);
- };
- MergeMapSubscriber.prototype._innerSub = function (ish) {
- var innerSubscriber = new SimpleInnerSubscriber(this);
- var destination = this.destination;
- destination.add(innerSubscriber);
- var innerSubscription = innerSubscribe(ish, innerSubscriber);
- if (innerSubscription !== innerSubscriber) {
- destination.add(innerSubscription);
- }
- };
- MergeMapSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (this.active === 0 && this.buffer.length === 0) {
- this.destination.complete();
- }
- this.unsubscribe();
- };
- MergeMapSubscriber.prototype.notifyNext = function (innerValue) {
- this.destination.next(innerValue);
- };
- MergeMapSubscriber.prototype.notifyComplete = function () {
- var buffer = this.buffer;
- this.active--;
- if (buffer.length > 0) {
- this._next(buffer.shift());
- }
- else if (this.active === 0 && this.hasCompleted) {
- this.destination.complete();
- }
- };
- return MergeMapSubscriber;
- }(SimpleOuterSubscriber));
- var flatMap = mergeMap;
-
- 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];
- }
- 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];
- }
- if (sources.length === 1) {
- var first_1 = sources[0];
- if (isArray(first_1)) {
- return forkJoinInternal(first_1, null);
- }
- if (isObject(first_1) && Object.getPrototypeOf(first_1) === Object.prototype) {
- var keys = Object.keys(first_1);
- return forkJoinInternal(keys.map(function (key) { return first_1[key]; }), keys);
- }
- }
- if (typeof sources[sources.length - 1] === 'function') {
- var resultSelector_1 = sources.pop();
- sources = (sources.length === 1 && isArray(sources[0])) ? sources[0] : sources;
- return forkJoinInternal(sources, null).pipe(map(function (args) { return resultSelector_1.apply(void 0, args); }));
- }
- return forkJoinInternal(sources, null);
- }
- function forkJoinInternal(sources, keys) {
- return new Observable(function (subscriber) {
- var len = sources.length;
- if (len === 0) {
- subscriber.complete();
- return;
- }
- var values = new Array(len);
- var completed = 0;
- var emitted = 0;
- var _loop_1 = function (i) {
- var source = from(sources[i]);
- var hasValue = false;
- subscriber.add(source.subscribe({
- next: function (value) {
- if (!hasValue) {
- hasValue = true;
- emitted++;
- }
- values[i] = value;
- },
- error: function (err) { return subscriber.error(err); },
- complete: function () {
- completed++;
- if (completed === len || !hasValue) {
- if (emitted === len) {
- subscriber.next(keys ?
- keys.reduce(function (result, key, i) { return (result[key] = values[i], result); }, {}) :
- values);
- }
- subscriber.complete();
- }
- }
- }));
- };
- for (var i = 0; i < len; i++) {
- _loop_1(i);
- }
- });
- }
-
- 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 not(pred, thisArg) {
- function notPred() {
- return !(notPred.pred.apply(notPred.thisArg, arguments));
- }
- notPred.pred = pred;
- notPred.thisArg = thisArg;
- return notPred;
- }
-
- 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 partition(source, predicate, thisArg) {
- return [
- filter(predicate, thisArg)(new Observable(subscribeTo(source))),
- filter(not(predicate, thisArg))(new Observable(subscribeTo(source)))
- ];
- }
-
- 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, undefined, i);
- if (this.subscriptions) {
- this.subscriptions.push(subscription);
- }
- this.add(subscription);
- }
- this.observables = null;
- }
- };
- RaceSubscriber.prototype.notifyNext = function (_outerValue, innerValue, outerIndex) {
- 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; }
- return new Observable(function (subscriber) {
- if (count === undefined) {
- count = start;
- start = 0;
- }
- 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.resultSelector = resultSelector;
- _this.iterators = [];
- _this.active = 0;
- _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : undefined;
- 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());
- }
- 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 Boolean(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 (innerValue) {
- this.buffer.push(innerValue);
- this.parent.checkIterators();
- };
- ZipBufferIterator.prototype.subscribe = function () {
- return innerSubscribe(this.observable, new SimpleInnerSubscriber(this));
- };
- return ZipBufferIterator;
- }(SimpleOuterSubscriber));
-
- 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 = void 0;
- try {
- var durationSelector = this.durationSelector;
- duration = durationSelector(value);
- }
- catch (err) {
- return this.destination.error(err);
- }
- var innerSubscription = innerSubscribe(duration, new SimpleInnerSubscriber(this));
- 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 = undefined;
- throttled.unsubscribe();
- }
- if (hasValue) {
- this.value = undefined;
- this.hasValue = false;
- this.destination.next(value);
- }
- };
- AuditSubscriber.prototype.notifyNext = function () {
- this.clearThrottle();
- };
- AuditSubscriber.prototype.notifyComplete = function () {
- this.clearThrottle();
- };
- return AuditSubscriber;
- }(SimpleOuterSubscriber));
-
- 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(innerSubscribe(closingNotifier, new SimpleInnerSubscriber(_this)));
- return _this;
- }
- BufferSubscriber.prototype._next = function (value) {
- this.buffer.push(value);
- };
- BufferSubscriber.prototype.notifyNext = function () {
- var buffer = this.buffer;
- this.buffer = [];
- this.destination.next(buffer);
- };
- return BufferSubscriber;
- }(SimpleOuterSubscriber));
-
- 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.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) {
- 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 = undefined;
- this.subscribing = false;
- };
- BufferWhenSubscriber.prototype.notifyNext = function () {
- 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;
- try {
- var closingSelector = this.closingSelector;
- closingNotifier = closingSelector();
- }
- catch (err) {
- return this.error(err);
- }
- closingSubscription = new Subscription();
- this.closingSubscription = closingSubscription;
- this.add(closingSubscription);
- this.subscribing = true;
- closingSubscription.add(innerSubscribe(closingNotifier, new SimpleInnerSubscriber(this)));
- this.subscribing = false;
- };
- return BufferWhenSubscriber;
- }(SimpleOuterSubscriber));
-
- 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 SimpleInnerSubscriber(this);
- this.add(innerSubscriber);
- var innerSubscription = innerSubscribe(result, innerSubscriber);
- if (innerSubscription !== innerSubscriber) {
- this.add(innerSubscription);
- }
- }
- };
- return CatchSubscriber;
- }(SimpleOuterSubscriber));
-
- 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;
- 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 = innerSubscribe(duration, new SimpleInnerSubscriber(this));
- if (subscription && !subscription.closed) {
- this.add(this.durationSubscription = subscription);
- }
- };
- DebounceSubscriber.prototype.notifyNext = function () {
- 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 = undefined;
- subscription.unsubscribe();
- this.remove(subscription);
- }
- this.value = undefined;
- this.hasValue = false;
- _super.prototype._next.call(this, value);
- }
- };
- return DebounceSubscriber;
- }(SimpleOuterSubscriber));
-
- 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(innerSubscribe(flushes, new SimpleInnerSubscriber(_this)));
- }
- return _this;
- }
- DistinctSubscriber.prototype.notifyNext = function () {
- this.values.clear();
- };
- DistinctSubscriber.prototype.notifyError = function (error) {
- 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;
- }(SimpleOuterSubscriber));
-
- 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 key;
- try {
- var keySelector = this.keySelector;
- key = keySelector ? keySelector(value) : value;
- }
- catch (err) {
- return this.destination.error(err);
- }
- var result = false;
- if (this.hasKey) {
- try {
- var compare = this.compare;
- result = compare(this.key, key);
- }
- catch (err) {
- return this.destination.error(err);
- }
- }
- else {
- this.hasKey = true;
- }
- if (!result) {
- 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 throwIfEmpty(errorFactory) {
- if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
- return function (source) {
- return source.lift(new ThrowIfEmptyOperator(errorFactory));
- };
- }
- var ThrowIfEmptyOperator = (function () {
- function ThrowIfEmptyOperator(errorFactory) {
- this.errorFactory = errorFactory;
- }
- ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
- };
- return ThrowIfEmptyOperator;
- }());
- var ThrowIfEmptySubscriber = (function (_super) {
- __extends(ThrowIfEmptySubscriber, _super);
- function ThrowIfEmptySubscriber(destination, errorFactory) {
- var _this = _super.call(this, destination) || this;
- _this.errorFactory = errorFactory;
- _this.hasValue = false;
- return _this;
- }
- ThrowIfEmptySubscriber.prototype._next = function (value) {
- this.hasValue = true;
- this.destination.next(value);
- };
- ThrowIfEmptySubscriber.prototype._complete = function () {
- if (!this.hasValue) {
- var err = void 0;
- try {
- err = this.errorFactory();
- }
- catch (e) {
- err = e;
- }
- this.destination.error(err);
- }
- else {
- return this.destination.complete();
- }
- };
- return ThrowIfEmptySubscriber;
- }(Subscriber));
- 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) { return concat(source, of.apply(void 0, array)); };
- }
-
- 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(innerSubscribe(value, new SimpleInnerSubscriber(this)));
- }
- };
- SwitchFirstSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (!this.hasSubscription) {
- this.destination.complete();
- }
- };
- SwitchFirstSubscriber.prototype.notifyComplete = function () {
- this.hasSubscription = false;
- if (this.hasCompleted) {
- this.destination.complete();
- }
- };
- return SwitchFirstSubscriber;
- }(SimpleOuterSubscriber));
-
- 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 ExhaustMapOperator(project));
- };
- }
- var ExhaustMapOperator = (function () {
- function ExhaustMapOperator(project) {
- this.project = project;
- }
- ExhaustMapOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
- };
- return ExhaustMapOperator;
- }());
- 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);
- };
- ExhaustMapSubscriber.prototype._innerSub = function (result) {
- var innerSubscriber = new SimpleInnerSubscriber(this);
- var destination = this.destination;
- destination.add(innerSubscriber);
- var innerSubscription = innerSubscribe(result, innerSubscriber);
- if (innerSubscription !== innerSubscriber) {
- destination.add(innerSubscription);
- }
- };
- ExhaustMapSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (!this.hasSubscription) {
- this.destination.complete();
- }
- this.unsubscribe();
- };
- ExhaustMapSubscriber.prototype.notifyNext = function (innerValue) {
- this.destination.next(innerValue);
- };
- ExhaustMapSubscriber.prototype.notifyError = function (err) {
- this.destination.error(err);
- };
- ExhaustMapSubscriber.prototype.notifyComplete = function () {
- this.hasSubscription = false;
- if (this.hasCompleted) {
- this.destination.complete();
- }
- };
- return ExhaustMapSubscriber;
- }(SimpleOuterSubscriber));
-
- function expand(project, concurrent, scheduler) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- 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);
- try {
- var project = this.project;
- var result = project(value, index);
- 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));
- }
- }
- catch (e) {
- destination.error(e);
- }
- }
- else {
- this.buffer.push(value);
- }
- };
- ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
- this.active++;
- var destination = this.destination;
- destination.add(innerSubscribe(result, new SimpleInnerSubscriber(this)));
- };
- ExpandSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (this.hasCompleted && this.active === 0) {
- this.destination.complete();
- }
- this.unsubscribe();
- };
- ExpandSubscriber.prototype.notifyNext = function (innerValue) {
- this._next(innerValue);
- };
- ExpandSubscriber.prototype.notifyComplete = function () {
- var buffer = this.buffer;
- this.active--;
- if (buffer && buffer.length > 0) {
- this._next(buffer.shift());
- }
- if (this.hasCompleted && this.active === 0) {
- this.destination.complete();
- }
- };
- return ExpandSubscriber;
- }(SimpleOuterSubscriber));
-
- 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 destination = this.destination;
- var ish = void 0;
- try {
- var accumulator = this.accumulator;
- ish = accumulator(this.acc, value, index);
- }
- catch (e) {
- return destination.error(e);
- }
- this.active++;
- this._innerSub(ish);
- }
- else {
- this.buffer.push(value);
- }
- };
- MergeScanSubscriber.prototype._innerSub = function (ish) {
- var innerSubscriber = new SimpleInnerSubscriber(this);
- var destination = this.destination;
- destination.add(innerSubscriber);
- var innerSubscription = innerSubscribe(ish, innerSubscriber);
- if (innerSubscription !== innerSubscriber) {
- destination.add(innerSubscription);
- }
- };
- 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 (innerValue) {
- var destination = this.destination;
- this.acc = innerValue;
- this.hasValue = true;
- destination.next(innerValue);
- };
- MergeScanSubscriber.prototype.notifyComplete = function () {
- var buffer = this.buffer;
- 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;
- }(SimpleOuterSubscriber));
-
- 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 () {
- this.subscribeToNextSource();
- };
- OnErrorResumeNextSubscriber.prototype.notifyComplete = function () {
- 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 SimpleInnerSubscriber(this);
- var destination = this.destination;
- destination.add(innerSubscriber);
- var innerSubscription = innerSubscribe(next, innerSubscriber);
- if (innerSubscription !== innerSubscriber) {
- destination.add(innerSubscription);
- }
- }
- else {
- this.destination.complete();
- }
- };
- return OnErrorResumeNextSubscriber;
- }(SimpleOuterSubscriber));
-
- 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) {
- var pair;
- if (this.hasPrev) {
- pair = [this.prev, value];
- }
- else {
- this.hasPrev = true;
- }
- this.prev = value;
- if (pair) {
- this.destination.next(pair);
- }
- };
- return PairwiseSubscriber;
- }(Subscriber));
-
- function partition$1(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 != null ? currentProp[props[i]] : undefined;
- if (p !== void 0) {
- 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 () {
- this.sourceIsBeingSubscribedTo = true;
- this.source.subscribe(this);
- };
- RepeatWhenSubscriber.prototype.notifyComplete = function () {
- 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(undefined);
- }
- };
- RepeatWhenSubscriber.prototype._unsubscribe = function () {
- var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
- if (notifications) {
- notifications.unsubscribe();
- this.notifications = undefined;
- }
- if (retriesSubscription) {
- retriesSubscription.unsubscribe();
- this.retriesSubscription = undefined;
- }
- this.retries = undefined;
- };
- 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;
- try {
- var notifier = this.notifier;
- retries = notifier(this.notifications);
- }
- catch (e) {
- return _super.prototype.complete.call(this);
- }
- this.retries = retries;
- this.retriesSubscription = innerSubscribe(retries, new SimpleInnerSubscriber(this));
- };
- return RepeatWhenSubscriber;
- }(SimpleOuterSubscriber));
-
- 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();
- try {
- var notifier = this.notifier;
- retries = notifier(errors);
- }
- catch (e) {
- return _super.prototype.error.call(this, e);
- }
- retriesSubscription = innerSubscribe(retries, new SimpleInnerSubscriber(this));
- }
- else {
- this.errors = undefined;
- this.retriesSubscription = undefined;
- }
- 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 = undefined;
- }
- if (retriesSubscription) {
- retriesSubscription.unsubscribe();
- this.retriesSubscription = undefined;
- }
- this.retries = undefined;
- };
- RetryWhenSubscriber.prototype.notifyNext = function () {
- var _unsubscribe = this._unsubscribe;
- this._unsubscribe = null;
- this._unsubscribeAndRecycle();
- this._unsubscribe = _unsubscribe;
- this.source.subscribe(this);
- };
- return RetryWhenSubscriber;
- }(SimpleOuterSubscriber));
-
- 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(innerSubscribe(this.notifier, new SimpleInnerSubscriber(sampleSubscriber)));
- 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 () {
- 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;
- }(SimpleOuterSubscriber));
-
- 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, comparator) {
- return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparator)); };
- }
- var SequenceEqualOperator = (function () {
- function SequenceEqualOperator(compareTo, comparator) {
- this.compareTo = compareTo;
- this.comparator = comparator;
- }
- SequenceEqualOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparator));
- };
- return SequenceEqualOperator;
- }());
- var SequenceEqualSubscriber = (function (_super) {
- __extends(SequenceEqualSubscriber, _super);
- function SequenceEqualSubscriber(destination, compareTo, comparator) {
- var _this = _super.call(this, destination) || this;
- _this.compareTo = compareTo;
- _this.comparator = comparator;
- _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, comparator = _c.comparator;
- while (_a.length > 0 && _b.length > 0) {
- var a = _a.shift();
- var b = _b.shift();
- var areEqual = false;
- try {
- areEqual = comparator ? comparator(a, b) : a === b;
- }
- catch (e) {
- this.destination.error(e);
- }
- 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(configOrBufferSize, windowTime, scheduler) {
- var config;
- if (configOrBufferSize && typeof configOrBufferSize === 'object') {
- config = configOrBufferSize;
- }
- else {
- config = {
- bufferSize: configOrBufferSize,
- windowTime: windowTime,
- refCount: false,
- scheduler: scheduler
- };
- }
- return function (source) { return source.lift(shareReplayOperator(config)); };
- }
- function shareReplayOperator(_a) {
- var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;
- var subject;
- var refCount = 0;
- var subscription;
- var hasError = false;
- var isComplete = false;
- return function shareReplayOperation(source) {
- refCount++;
- var innerSub;
- if (!subject || hasError) {
- hasError = false;
- subject = new ReplaySubject(bufferSize, windowTime, scheduler);
- innerSub = subject.subscribe(this);
- subscription = source.subscribe({
- next: function (value) { subject.next(value); },
- error: function (err) {
- hasError = true;
- subject.error(err);
- },
- complete: function () {
- isComplete = true;
- subscription = undefined;
- subject.complete();
- },
- });
- }
- else {
- innerSub = subject.subscribe(this);
- }
- this.add(function () {
- refCount--;
- innerSub.unsubscribe();
- if (subscription && !isComplete && useRefCount && refCount === 0) {
- subscription.unsubscribe();
- subscription = undefined;
- subject = undefined;
- }
- });
- };
- }
-
- 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 SimpleInnerSubscriber(_this);
- _this.add(innerSubscriber);
- _this.innerSubscription = innerSubscriber;
- var innerSubscription = innerSubscribe(notifier, innerSubscriber);
- if (innerSubscription !== innerSubscriber) {
- _this.add(innerSubscription);
- _this.innerSubscription = innerSubscription;
- }
- return _this;
- }
- SkipUntilSubscriber.prototype._next = function (value) {
- if (this.hasValue) {
- _super.prototype._next.call(this, value);
- }
- };
- SkipUntilSubscriber.prototype.notifyNext = function () {
- this.hasValue = true;
- if (this.innerSubscription) {
- this.innerSubscription.unsubscribe();
- }
- };
- SkipUntilSubscriber.prototype.notifyComplete = function () {
- };
- return SkipUntilSubscriber;
- }(SimpleOuterSubscriber));
-
- 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];
- }
- var scheduler = array[array.length - 1];
- if (isScheduler(scheduler)) {
- array.pop();
- return function (source) { return concat(array, source, scheduler); };
- }
- else {
- return function (source) { return concat(array, 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);
- };
- SwitchMapSubscriber.prototype._innerSub = function (result) {
- var innerSubscription = this.innerSubscription;
- if (innerSubscription) {
- innerSubscription.unsubscribe();
- }
- var innerSubscriber = new SimpleInnerSubscriber(this);
- var destination = this.destination;
- destination.add(innerSubscriber);
- this.innerSubscription = innerSubscribe(result, innerSubscriber);
- if (this.innerSubscription !== innerSubscriber) {
- destination.add(this.innerSubscription);
- }
- };
- 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 = undefined;
- };
- SwitchMapSubscriber.prototype.notifyComplete = function () {
- this.innerSubscription = undefined;
- if (this.isStopped) {
- _super.prototype._complete.call(this);
- }
- };
- SwitchMapSubscriber.prototype.notifyNext = function (innerValue) {
- this.destination.next(innerValue);
- };
- return SwitchMapSubscriber;
- }(SimpleOuterSubscriber));
-
- 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 = innerSubscribe(this.notifier, new SimpleInnerSubscriber(takeUntilSubscriber));
- 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 () {
- this.seenValue = true;
- this.complete();
- };
- TakeUntilSubscriber.prototype.notifyComplete = function () {
- };
- return TakeUntilSubscriber;
- }(SimpleOuterSubscriber));
-
- function takeWhile(predicate, inclusive) {
- if (inclusive === void 0) { inclusive = false; }
- return function (source) {
- return source.lift(new TakeWhileOperator(predicate, inclusive));
- };
- }
- var TakeWhileOperator = (function () {
- function TakeWhileOperator(predicate, inclusive) {
- this.predicate = predicate;
- this.inclusive = inclusive;
- }
- TakeWhileOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate, this.inclusive));
- };
- return TakeWhileOperator;
- }());
- var TakeWhileSubscriber = (function (_super) {
- __extends(TakeWhileSubscriber, _super);
- function TakeWhileSubscriber(destination, predicate, inclusive) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.inclusive = inclusive;
- _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 {
- if (this.inclusive) {
- destination.next(value);
- }
- destination.complete();
- }
- };
- return TakeWhileSubscriber;
- }(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 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 = undefined;
- };
- ThrottleSubscriber.prototype.throttle = function (value) {
- var duration = this.tryDurationSelector(value);
- if (!!duration) {
- this.add(this._throttled = innerSubscribe(duration, new SimpleInnerSubscriber(this)));
- }
- };
- 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 = undefined;
- if (_trailing) {
- this.send();
- }
- };
- ThrottleSubscriber.prototype.notifyNext = function () {
- this.throttlingDone();
- };
- ThrottleSubscriber.prototype.notifyComplete = function () {
- this.throttlingDone();
- };
- return ThrottleSubscriber;
- }(SimpleOuterSubscriber));
-
- 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);
- }
- else if (this.trailing) {
- this._trailingValue = value;
- this._hasTrailingValue = true;
- }
- }
- };
- 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.scheduleTimeout();
- return _this;
- }
- TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
- var withObservable = subscriber.withObservable;
- subscriber._unsubscribeAndRecycle();
- subscriber.add(innerSubscribe(withObservable, new SimpleInnerSubscriber(subscriber)));
- };
- 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 = undefined;
- this.scheduler = null;
- this.withObservable = null;
- };
- return TimeoutWithSubscriber;
- }(SimpleOuterSubscriber));
-
- 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(innerSubscribe(this.windowBoundaries, new SimpleInnerSubscriber(windowSubscriber)));
- }
- 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 () {
- this.openWindow();
- };
- WindowSubscriber.prototype.notifyError = function (error) {
- this._error(error);
- };
- WindowSubscriber.prototype.notifyComplete = function () {
- 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;
- }(SimpleOuterSubscriber));
-
- 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 = Number(arguments[2]);
- }
- if (isScheduler(arguments[1])) {
- scheduler = arguments[1];
- }
- else if (isNumeric(arguments[1])) {
- windowCreationInterval = Number(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 closingNotifier = void 0;
- try {
- var closingSelector = this.closingSelector;
- closingNotifier = closingSelector(innerValue);
- }
- catch (e) {
- return this.error(e);
- }
- 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) {
- 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;
- try {
- var closingSelector = this.closingSelector;
- closingNotifier = closingSelector();
- }
- catch (e) {
- this.destination.error(e);
- this.window.error(e);
- return;
- }
- 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, undefined, i));
- }
- return _this;
- }
- WithLatestFromSubscriber.prototype.notifyNext = function (_outerValue, innerValue, outerIndex) {
- 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 = /*#__PURE__*/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: flatMap,
- mergeMapTo: mergeMapTo,
- mergeScan: mergeScan,
- min: min,
- multicast: multicast,
- observeOn: observeOn,
- onErrorResumeNext: onErrorResumeNext$1,
- pairwise: pairwise,
- partition: partition$1,
- 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 = /*#__PURE__*/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 && !_this.getHeader(headers, 'X-Requested-With')) {
- headers['X-Requested-With'] = 'XMLHttpRequest';
- }
- var contentTypeHeader = _this.getHeader(headers, 'Content-Type');
- if (!contentTypeHeader && !(_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, _this.getHeader(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 result;
- try {
- result = new AjaxResponse(e, xhr, request);
- }
- catch (err) {
- return destination.error(err);
- }
- destination.next(result);
- };
- 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;
- try {
- var xhr = this.xhr = request.createXHR();
- this.setupEvents(xhr, request);
- if (user) {
- xhr.open(method, url, async, user, password);
- }
- else {
- xhr.open(method, url, async);
- }
- if (async) {
- xhr.timeout = request.timeout;
- xhr.responseType = request.responseType;
- }
- if ('withCredentials' in xhr) {
- xhr.withCredentials = !!request.withCredentials;
- }
- this.setHeaders(xhr, headers);
- if (body) {
- xhr.send(body);
- }
- else {
- xhr.send();
- }
- }
- catch (err) {
- this.error(err);
- }
- };
- 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.getHeader = function (headers, headerName) {
- for (var key in headers) {
- if (key.toLowerCase() === headerName.toLowerCase()) {
- return headers[key];
- }
- }
- return undefined;
- };
- 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 error;
- try {
- error = new AjaxTimeoutError(this, request);
- }
- catch (err) {
- error = err;
- }
- subscriber.error(error);
- }
- 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 error;
- try {
- error = new AjaxError('ajax error', this, request);
- }
- catch (err) {
- error = err;
- }
- subscriber.error(error);
- };
- 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 error = void 0;
- try {
- error = new AjaxError('ajax error ' + status_1, this, request);
- }
- catch (err) {
- error = err;
- }
- subscriber.error(error);
- }
- }
- }
- 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;
- }());
- var AjaxErrorImpl = (function () {
- 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);
- return AjaxErrorImpl;
- })();
- 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 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 = (function () { return AjaxObservable.create; })();
-
-
-
- var _ajax = /*#__PURE__*/Object.freeze({
- ajax: ajax,
- 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) {
- try {
- self.next(subMsg());
- }
- catch (err) {
- observer.error(err);
- }
- var subscription = self.subscribe(function (x) {
- try {
- if (messageFilter(x)) {
- observer.next(x);
- }
- }
- catch (err) {
- observer.error(err);
- }
- }, function (err) { return observer.error(err); }, function () { return observer.complete(); });
- return function () {
- try {
- self.next(unsubMsg());
- }
- catch (err) {
- observer.error(err);
- }
- 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 _socket = _this._socket;
- if (!_socket) {
- socket.close();
- _this._resetState();
- return;
- }
- var openObserver = _this._config.openObserver;
- if (openObserver) {
- openObserver.next(e);
- }
- var queue = _this.destination;
- _this.destination = Subscriber.create(function (x) {
- if (socket.readyState === 1) {
- try {
- var serializer = _this._config.serializer;
- socket.send(serializer(x));
- }
- catch (e) {
- _this.destination.error(e);
- }
- }
- }, 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) {
- try {
- var deserializer = _this._config.deserializer;
- observer.next(deserializer(e));
- }
- catch (err) {
- observer.error(err);
- }
- };
- };
- 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 _socket = this._socket;
- if (_socket && _socket.readyState === 1) {
- _socket.close();
- }
- this._resetState();
- _super.prototype.unsubscribe.call(this);
- };
- return WebSocketSubject;
- }(AnonymousSubject));
-
- function webSocket(urlConfigOrSource) {
- return new WebSocketSubject(urlConfigOrSource);
- }
-
-
-
- var _webSocket = /*#__PURE__*/Object.freeze({
- webSocket: webSocket,
- WebSocketSubject: WebSocketSubject
- });
-
- function fromFetch(input, initWithSelector) {
- if (initWithSelector === void 0) { initWithSelector = {}; }
- var selector = initWithSelector.selector, init = __rest(initWithSelector, ["selector"]);
- return new Observable(function (subscriber) {
- var controller = new AbortController();
- var signal = controller.signal;
- var abortable = true;
- var unsubscribed = false;
- var subscription = new Subscription();
- subscription.add(function () {
- unsubscribed = true;
- if (abortable) {
- controller.abort();
- }
- });
- var perSubscriberInit;
- if (init) {
- if (init.signal) {
- if (init.signal.aborted) {
- controller.abort();
- }
- else {
- var outerSignal_1 = init.signal;
- var outerSignalHandler_1 = function () {
- if (!signal.aborted) {
- controller.abort();
- }
- };
- outerSignal_1.addEventListener('abort', outerSignalHandler_1);
- subscription.add(function () { return outerSignal_1.removeEventListener('abort', outerSignalHandler_1); });
- }
- }
- perSubscriberInit = __assign({}, init, { signal: signal });
- }
- else {
- perSubscriberInit = { signal: signal };
- }
- fetch(input, perSubscriberInit).then(function (response) {
- if (selector) {
- subscription.add(from(selector(response)).subscribe(function (value) { return subscriber.next(value); }, function (err) {
- abortable = false;
- if (!unsubscribed) {
- subscriber.error(err);
- }
- }, function () {
- abortable = false;
- subscriber.complete();
- }));
- }
- else {
- abortable = false;
- subscriber.next(response);
- subscriber.complete();
- }
- }).catch(function (err) {
- abortable = false;
- if (!unsubscribed) {
- subscriber.error(err);
- }
- });
- return subscription;
- });
- }
-
-
-
- var _fetch = /*#__PURE__*/Object.freeze({
- fromFetch: fromFetch
- });
-
- var operators = _operators;
- var testing = _testing;
- var ajax$1 = _ajax;
- var webSocket$1 = _webSocket;
- var fetch$1 = _fetch;
-
- exports.operators = operators;
- exports.testing = testing;
- exports.ajax = ajax$1;
- exports.webSocket = webSocket$1;
- exports.fetch = fetch$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.asap = asap;
- exports.asapScheduler = asapScheduler;
- exports.async = async;
- exports.asyncScheduler = asyncScheduler;
- exports.queue = queue;
- exports.queueScheduler = queueScheduler;
- exports.animationFrame = animationFrame;
- exports.animationFrameScheduler = animationFrameScheduler;
- 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.partition = partition;
- exports.race = race;
- exports.range = range;
- exports.throwError = throwError;
- exports.timer = timer;
- exports.using = using;
- exports.zip = zip;
- exports.scheduled = scheduled;
- exports.EMPTY = EMPTY;
- exports.NEVER = NEVER;
- exports.config = config;
-
- Object.defineProperty(exports, '__esModule', { value: true });
-
- })));
-
- //# sourceMappingURL=rxjs.umd.js.map
|