1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241 |
- /**
- @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 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 = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
-
- function isObject(x) {
- return x !== null && typeof x === 'object';
- }
-
- function UnsubscriptionErrorImpl(errors) {
- Error.call(this);
- this.message = errors ?
- errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
- this.name = 'UnsubscriptionError';
- this.errors = errors;
- return this;
- }
- UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
- var UnsubscriptionError = UnsubscriptionErrorImpl;
-
- var Subscription = (function () {
- function Subscription(unsubscribe) {
- this.closed = false;
- this._parentOrParents = null;
- this._subscriptions = null;
- if (unsubscribe) {
- this._unsubscribe = unsubscribe;
- }
- }
- Subscription.prototype.unsubscribe = function () {
- var errors;
- if (this.closed) {
- return;
- }
- var _a = this, _parentOrParents = _a._parentOrParents, _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)) {
- 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 = 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 = typeof Symbol === 'function' && Symbol.observable || '@@observable';
-
- function noop() { }
-
- function pipe() {
- var fns = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- fns[_i] = arguments[_i];
- }
- return pipeFromArray(fns);
- }
- function pipeFromArray(fns) {
- if (!fns) {
- return noop;
- }
- if (fns.length === 1) {
- return fns[0];
- }
- return function piped(input) {
- return fns.reduce(function (prev, fn) { return fn(prev); }, input);
- };
- }
-
- var Observable = (function () {
- function Observable(subscribe) {
- this._isScalar = false;
- if (subscribe) {
- this._subscribe = subscribe;
- }
- }
- Observable.prototype.lift = function (operator) {
- var observable$$1 = new Observable();
- observable$$1.source = this;
- observable$$1.operator = operator;
- return observable$$1;
- };
- Observable.prototype.subscribe = function (observerOrNext, error, complete) {
- var operator = this.operator;
- var sink = toSubscriber(observerOrNext, error, complete);
- if (operator) {
- 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;
- }
-
- function ObjectUnsubscribedErrorImpl() {
- Error.call(this);
- this.message = 'object unsubscribed';
- this.name = 'ObjectUnsubscribedError';
- return this;
- }
- ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
- var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
-
- var SubjectSubscription = (function (_super) {
- __extends(SubjectSubscription, _super);
- function SubjectSubscription(subject, subscriber) {
- var _this = _super.call(this) || this;
- _this.subject = subject;
- _this.subscriber = subscriber;
- _this.closed = false;
- return _this;
- }
- SubjectSubscription.prototype.unsubscribe = function () {
- if (this.closed) {
- return;
- }
- this.closed = true;
- var subject = this.subject;
- var observers = subject.observers;
- this.subject = null;
- if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
- return;
- }
- var subscriberIndex = observers.indexOf(this.subscriber);
- if (subscriberIndex !== -1) {
- observers.splice(subscriberIndex, 1);
- }
- };
- return SubjectSubscription;
- }(Subscription));
-
- var SubjectSubscriber = (function (_super) {
- __extends(SubjectSubscriber, _super);
- function SubjectSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- return _this;
- }
- return SubjectSubscriber;
- }(Subscriber));
- var Subject = (function (_super) {
- __extends(Subject, _super);
- function Subject() {
- var _this = _super.call(this) || this;
- _this.observers = [];
- _this.closed = false;
- _this.isStopped = false;
- _this.hasError = false;
- _this.thrownError = null;
- return _this;
- }
- Subject.prototype[rxSubscriber] = function () {
- return new SubjectSubscriber(this);
- };
- Subject.prototype.lift = function (operator) {
- var subject = new AnonymousSubject(this, this);
- subject.operator = operator;
- return subject;
- };
- Subject.prototype.next = function (value) {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- if (!this.isStopped) {
- var observers = this.observers;
- var len = observers.length;
- var copy = observers.slice();
- for (var i = 0; i < len; i++) {
- copy[i].next(value);
- }
- }
- };
- Subject.prototype.error = function (err) {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- this.hasError = true;
- this.thrownError = err;
- this.isStopped = true;
- var observers = this.observers;
- var len = observers.length;
- var copy = observers.slice();
- for (var i = 0; i < len; i++) {
- copy[i].error(err);
- }
- this.observers.length = 0;
- };
- Subject.prototype.complete = function () {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- this.isStopped = true;
- var observers = this.observers;
- var len = observers.length;
- var copy = observers.slice();
- for (var i = 0; i < len; i++) {
- copy[i].complete();
- }
- this.observers.length = 0;
- };
- Subject.prototype.unsubscribe = function () {
- this.isStopped = true;
- this.closed = true;
- this.observers = null;
- };
- Subject.prototype._trySubscribe = function (subscriber) {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- else {
- return _super.prototype._trySubscribe.call(this, subscriber);
- }
- };
- Subject.prototype._subscribe = function (subscriber) {
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- else if (this.hasError) {
- subscriber.error(this.thrownError);
- return Subscription.EMPTY;
- }
- else if (this.isStopped) {
- subscriber.complete();
- return Subscription.EMPTY;
- }
- else {
- this.observers.push(subscriber);
- return new SubjectSubscription(this, subscriber);
- }
- };
- Subject.prototype.asObservable = function () {
- var observable = new Observable();
- observable.source = this;
- return observable;
- };
- Subject.create = function (destination, source) {
- return new AnonymousSubject(destination, source);
- };
- return Subject;
- }(Observable));
- var AnonymousSubject = (function (_super) {
- __extends(AnonymousSubject, _super);
- function AnonymousSubject(destination, source) {
- var _this = _super.call(this) || this;
- _this.destination = destination;
- _this.source = source;
- return _this;
- }
- AnonymousSubject.prototype.next = function (value) {
- var destination = this.destination;
- if (destination && destination.next) {
- destination.next(value);
- }
- };
- AnonymousSubject.prototype.error = function (err) {
- var destination = this.destination;
- if (destination && destination.error) {
- this.destination.error(err);
- }
- };
- AnonymousSubject.prototype.complete = function () {
- var destination = this.destination;
- if (destination && destination.complete) {
- this.destination.complete();
- }
- };
- AnonymousSubject.prototype._subscribe = function (subscriber) {
- var source = this.source;
- if (source) {
- return this.source.subscribe(subscriber);
- }
- else {
- return Subscription.EMPTY;
- }
- };
- return AnonymousSubject;
- }(Subject));
-
- function refCount() {
- return function refCountOperatorFunction(source) {
- return source.lift(new RefCountOperator(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 connectableProto = ConnectableObservable.prototype;
- var connectableObservableDescriptor = {
- operator: { value: null },
- _refCount: { value: 0, writable: true },
- _subject: { value: null, writable: true },
- _connection: { value: null, writable: true },
- _subscribe: { value: connectableProto._subscribe },
- _isComplete: { value: connectableProto._isComplete, writable: true },
- getSubject: { value: connectableProto.getSubject },
- connect: { value: connectableProto.connect },
- refCount: { value: connectableProto.refCount }
- };
- var ConnectableSubscriber = (function (_super) {
- __extends(ConnectableSubscriber, _super);
- function ConnectableSubscriber(destination, connectable) {
- var _this = _super.call(this, destination) || this;
- _this.connectable = connectable;
- return _this;
- }
- ConnectableSubscriber.prototype._error = function (err) {
- this._unsubscribe();
- _super.prototype._error.call(this, err);
- };
- ConnectableSubscriber.prototype._complete = function () {
- this.connectable._isComplete = true;
- this._unsubscribe();
- _super.prototype._complete.call(this);
- };
- ConnectableSubscriber.prototype._unsubscribe = function () {
- var connectable = this.connectable;
- if (connectable) {
- this.connectable = null;
- var connection = connectable._connection;
- connectable._refCount = 0;
- connectable._subject = null;
- connectable._connection = null;
- if (connection) {
- connection.unsubscribe();
- }
- }
- };
- return ConnectableSubscriber;
- }(SubjectSubscriber));
- var RefCountSubscriber$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 queue = new QueueScheduler(QueueAction);
-
- var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
- function empty$1(scheduler) {
- return scheduler ? emptyScheduled(scheduler) : EMPTY;
- }
- function emptyScheduled(scheduler) {
- return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
- }
-
- function isScheduler(value) {
- return value && typeof value.schedule === 'function';
- }
-
- var subscribeToArray = function (array) { return function (subscriber) {
- for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
- subscriber.next(array[i]);
- }
- 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) {
- var _events = this._events;
- _events.push(value);
- if (_events.length > this._bufferSize) {
- _events.shift();
- }
- _super.prototype.next.call(this, value);
- };
- ReplaySubject.prototype.nextTimeWindow = function (value) {
- this._events.push(new ReplayEvent(this._getNow(), value));
- this._trimBufferThenGetEvents();
- _super.prototype.next.call(this, value);
- };
- ReplaySubject.prototype._subscribe = function (subscriber) {
- var _infiniteTimeWindow = this._infiniteTimeWindow;
- var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
- var scheduler = this.scheduler;
- var len = _events.length;
- var subscription;
- if (this.closed) {
- throw new ObjectUnsubscribedError();
- }
- else if (this.isStopped || this.hasError) {
- subscription = Subscription.EMPTY;
- }
- else {
- this.observers.push(subscriber);
- subscription = new SubjectSubscription(this, subscriber);
- }
- if (scheduler) {
- subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
- }
- if (_infiniteTimeWindow) {
- for (var i = 0; i < len && !subscriber.closed; i++) {
- subscriber.next(_events[i]);
- }
- }
- else {
- for (var i = 0; i < len && !subscriber.closed; i++) {
- subscriber.next(_events[i].value);
- }
- }
- if (this.hasError) {
- subscriber.error(this.thrownError);
- }
- else if (this.isStopped) {
- subscriber.complete();
- }
- return subscription;
- };
- ReplaySubject.prototype._getNow = function () {
- return (this.scheduler || queue).now();
- };
- ReplaySubject.prototype._trimBufferThenGetEvents = function () {
- var now = this._getNow();
- var _bufferSize = this._bufferSize;
- var _windowTime = this._windowTime;
- var _events = this._events;
- var eventsCount = _events.length;
- var spliceCount = 0;
- while (spliceCount < eventsCount) {
- if ((now - _events[spliceCount].time) < _windowTime) {
- break;
- }
- spliceCount++;
- }
- if (eventsCount > _bufferSize) {
- spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
- }
- if (spliceCount > 0) {
- _events.splice(0, spliceCount);
- }
- return _events;
- };
- return ReplaySubject;
- }(Subject));
- var ReplayEvent = (function () {
- function ReplayEvent(time, value) {
- this.time = time;
- this.value = value;
- }
- return ReplayEvent;
- }());
-
- var AsyncSubject = (function (_super) {
- __extends(AsyncSubject, _super);
- function AsyncSubject() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.value = null;
- _this.hasNext = false;
- _this.hasCompleted = false;
- return _this;
- }
- AsyncSubject.prototype._subscribe = function (subscriber) {
- if (this.hasError) {
- subscriber.error(this.thrownError);
- return Subscription.EMPTY;
- }
- else if (this.hasCompleted && this.hasNext) {
- subscriber.next(this.value);
- subscriber.complete();
- return Subscription.EMPTY;
- }
- return _super.prototype._subscribe.call(this, subscriber);
- };
- AsyncSubject.prototype.next = function (value) {
- if (!this.hasCompleted) {
- this.value = value;
- this.hasNext = true;
- }
- };
- AsyncSubject.prototype.error = function (error) {
- if (!this.hasCompleted) {
- _super.prototype.error.call(this, error);
- }
- };
- AsyncSubject.prototype.complete = function () {
- this.hasCompleted = true;
- if (this.hasNext) {
- _super.prototype.next.call(this, this.value);
- }
- _super.prototype.complete.call(this);
- };
- return AsyncSubject;
- }(Subject));
-
- var nextHandle = 1;
- var tasksByHandle = {};
- function runIfPresent(handle) {
- var cb = tasksByHandle[handle];
- if (cb) {
- cb();
- }
- }
- var Immediate = {
- setImmediate: function (cb) {
- var handle = nextHandle++;
- tasksByHandle[handle] = cb;
- Promise.resolve().then(function () { return runIfPresent(handle); });
- return handle;
- },
- clearImmediate: function (handle) {
- delete tasksByHandle[handle];
- },
- };
-
- var AsapAction = (function (_super) {
- __extends(AsapAction, _super);
- function AsapAction(scheduler, work) {
- var _this = _super.call(this, scheduler, work) || this;
- _this.scheduler = scheduler;
- _this.work = work;
- return _this;
- }
- AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if (delay !== null && delay > 0) {
- return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
- }
- scheduler.actions.push(this);
- return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
- };
- AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
- return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
- }
- if (scheduler.actions.length === 0) {
- Immediate.clearImmediate(id);
- scheduler.scheduled = undefined;
- }
- return undefined;
- };
- return AsapAction;
- }(AsyncAction));
-
- var AsapScheduler = (function (_super) {
- __extends(AsapScheduler, _super);
- function AsapScheduler() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AsapScheduler.prototype.flush = function (action) {
- this.active = true;
- this.scheduled = undefined;
- var actions = this.actions;
- var error;
- var index = -1;
- var count = actions.length;
- action = action || actions.shift();
- do {
- if (error = action.execute(action.state, action.delay)) {
- break;
- }
- } while (++index < count && (action = actions.shift()));
- this.active = false;
- if (error) {
- while (++index < count && (action = actions.shift())) {
- action.unsubscribe();
- }
- throw error;
- }
- };
- return AsapScheduler;
- }(AsyncScheduler));
-
- var asap = new AsapScheduler(AsapAction);
-
- var async = new AsyncScheduler(AsyncAction);
-
- var AnimationFrameAction = (function (_super) {
- __extends(AnimationFrameAction, _super);
- function AnimationFrameAction(scheduler, work) {
- var _this = _super.call(this, scheduler, work) || this;
- _this.scheduler = scheduler;
- _this.work = work;
- return _this;
- }
- AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if (delay !== null && delay > 0) {
- return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
- }
- scheduler.actions.push(this);
- return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
- };
- AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
- if (delay === void 0) { delay = 0; }
- if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
- return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
- }
- if (scheduler.actions.length === 0) {
- cancelAnimationFrame(id);
- scheduler.scheduled = undefined;
- }
- return undefined;
- };
- return AnimationFrameAction;
- }(AsyncAction));
-
- var AnimationFrameScheduler = (function (_super) {
- __extends(AnimationFrameScheduler, _super);
- function AnimationFrameScheduler() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AnimationFrameScheduler.prototype.flush = function (action) {
- this.active = true;
- this.scheduled = undefined;
- var actions = this.actions;
- var error;
- var index = -1;
- var count = actions.length;
- action = action || actions.shift();
- do {
- if (error = action.execute(action.state, action.delay)) {
- break;
- }
- } while (++index < count && (action = actions.shift()));
- this.active = false;
- if (error) {
- while (++index < count && (action = actions.shift())) {
- action.unsubscribe();
- }
- throw error;
- }
- };
- return AnimationFrameScheduler;
- }(AsyncScheduler));
-
- var animationFrame = new AnimationFrameScheduler(AnimationFrameAction);
-
- var VirtualTimeScheduler = (function (_super) {
- __extends(VirtualTimeScheduler, _super);
- function VirtualTimeScheduler(SchedulerAction, maxFrames) {
- if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
- if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
- var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
- _this.maxFrames = maxFrames;
- _this.frame = 0;
- _this.index = -1;
- return _this;
- }
- VirtualTimeScheduler.prototype.flush = function () {
- var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
- var error, action;
- while ((action = actions[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 identity(x) {
- return x;
- }
-
- function isObservable(obj) {
- return !!obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
- }
-
- function ArgumentOutOfRangeErrorImpl() {
- Error.call(this);
- this.message = 'argument out of range';
- this.name = 'ArgumentOutOfRangeError';
- return this;
- }
- ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
- var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
-
- function EmptyErrorImpl() {
- Error.call(this);
- this.message = 'no elements in sequence';
- this.name = 'EmptyError';
- return this;
- }
- EmptyErrorImpl.prototype = Object.create(Error.prototype);
- var EmptyError = EmptyErrorImpl;
-
- function TimeoutErrorImpl() {
- Error.call(this);
- this.message = 'Timeout has occurred';
- this.name = 'TimeoutError';
- return this;
- }
- TimeoutErrorImpl.prototype = Object.create(Error.prototype);
- var TimeoutError = TimeoutErrorImpl;
-
- function map(project, thisArg) {
- return function mapOperation(source) {
- if (typeof project !== 'function') {
- throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
- }
- return source.lift(new MapOperator(project, thisArg));
- };
- }
- var MapOperator = (function () {
- function MapOperator(project, thisArg) {
- this.project = project;
- this.thisArg = thisArg;
- }
- MapOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
- };
- return MapOperator;
- }());
- var MapSubscriber = (function (_super) {
- __extends(MapSubscriber, _super);
- function MapSubscriber(destination, project, thisArg) {
- var _this = _super.call(this, destination) || this;
- _this.project = project;
- _this.count = 0;
- _this.thisArg = thisArg || _this;
- return _this;
- }
- MapSubscriber.prototype._next = function (value) {
- var result;
- try {
- result = this.project.call(this.thisArg, value, this.count++);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(result);
- };
- return MapSubscriber;
- }(Subscriber));
-
- function bindCallback(callbackFunc, resultSelector, scheduler) {
- if (resultSelector) {
- if (isScheduler(resultSelector)) {
- scheduler = resultSelector;
- }
- else {
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
- };
- }
- }
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var context = this;
- var subject;
- var params = {
- context: context,
- subject: subject,
- callbackFunc: callbackFunc,
- scheduler: scheduler,
- };
- return new Observable(function (subscriber) {
- if (!scheduler) {
- if (!subject) {
- subject = new AsyncSubject();
- var handler = function () {
- var innerArgs = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- innerArgs[_i] = arguments[_i];
- }
- subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
- subject.complete();
- };
- try {
- callbackFunc.apply(context, args.concat([handler]));
- }
- catch (err) {
- if (canReportError(subject)) {
- subject.error(err);
- }
- else {
- console.warn(err);
- }
- }
- }
- return subject.subscribe(subscriber);
- }
- else {
- var state = {
- args: args, subscriber: subscriber, params: params,
- };
- return scheduler.schedule(dispatch$1, 0, state);
- }
- });
- };
- }
- function dispatch$1(state) {
- var _this = this;
- var args = state.args, subscriber = state.subscriber, params = state.params;
- var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
- var subject = params.subject;
- if (!subject) {
- subject = params.subject = new AsyncSubject();
- var handler = function () {
- var innerArgs = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- innerArgs[_i] = arguments[_i];
- }
- var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
- _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
- };
- try {
- callbackFunc.apply(context, args.concat([handler]));
- }
- catch (err) {
- subject.error(err);
- }
- }
- this.add(subject.subscribe(subscriber));
- }
- function dispatchNext(state) {
- var value = state.value, subject = state.subject;
- subject.next(value);
- subject.complete();
- }
-
- function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
- if (resultSelector) {
- if (isScheduler(resultSelector)) {
- scheduler = resultSelector;
- }
- else {
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return bindNodeCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
- };
- }
- }
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var params = {
- subject: undefined,
- args: args,
- callbackFunc: callbackFunc,
- scheduler: scheduler,
- context: this,
- };
- return new Observable(function (subscriber) {
- var context = params.context;
- var subject = params.subject;
- if (!scheduler) {
- if (!subject) {
- subject = params.subject = new AsyncSubject();
- var handler = function () {
- var innerArgs = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- innerArgs[_i] = arguments[_i];
- }
- var err = innerArgs.shift();
- if (err) {
- subject.error(err);
- return;
- }
- subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
- subject.complete();
- };
- try {
- callbackFunc.apply(context, args.concat([handler]));
- }
- catch (err) {
- if (canReportError(subject)) {
- subject.error(err);
- }
- else {
- console.warn(err);
- }
- }
- }
- return subject.subscribe(subscriber);
- }
- else {
- return scheduler.schedule(dispatch$2, 0, { params: params, subscriber: subscriber, context: context });
- }
- });
- };
- }
- function dispatch$2(state) {
- var _this = this;
- var params = state.params, subscriber = state.subscriber, context = state.context;
- var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
- var subject = params.subject;
- if (!subject) {
- subject = params.subject = new AsyncSubject();
- var handler = function () {
- var innerArgs = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- innerArgs[_i] = arguments[_i];
- }
- var err = innerArgs.shift();
- if (err) {
- _this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
- }
- else {
- var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
- _this.add(scheduler.schedule(dispatchNext$1, 0, { value: value, subject: subject }));
- }
- };
- try {
- callbackFunc.apply(context, args.concat([handler]));
- }
- catch (err) {
- this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
- }
- }
- this.add(subject.subscribe(subscriber));
- }
- function dispatchNext$1(arg) {
- var value = arg.value, subject = arg.subject;
- subject.next(value);
- subject.complete();
- }
- function dispatchError$1(arg) {
- var err = arg.err, subject = arg.subject;
- subject.error(err);
- }
-
- var OuterSubscriber = (function (_super) {
- __extends(OuterSubscriber, _super);
- function OuterSubscriber() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(innerValue);
- };
- OuterSubscriber.prototype.notifyError = function (error, innerSub) {
- this.destination.error(error);
- };
- OuterSubscriber.prototype.notifyComplete = function (innerSub) {
- this.destination.complete();
- };
- return OuterSubscriber;
- }(Subscriber));
-
- var InnerSubscriber = (function (_super) {
- __extends(InnerSubscriber, _super);
- function InnerSubscriber(parent, outerValue, outerIndex) {
- var _this = _super.call(this) || this;
- _this.parent = parent;
- _this.outerValue = outerValue;
- _this.outerIndex = outerIndex;
- _this.index = 0;
- return _this;
- }
- InnerSubscriber.prototype._next = function (value) {
- this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
- };
- InnerSubscriber.prototype._error = function (error) {
- this.parent.notifyError(error, this);
- this.unsubscribe();
- };
- InnerSubscriber.prototype._complete = function () {
- this.parent.notifyComplete(this);
- this.unsubscribe();
- };
- return InnerSubscriber;
- }(Subscriber));
-
- var subscribeToPromise = function (promise) { return function (subscriber) {
- promise.then(function (value) {
- if (!subscriber.closed) {
- subscriber.next(value);
- subscriber.complete();
- }
- }, function (err) { return subscriber.error(err); })
- .then(null, hostReportError);
- return subscriber;
- }; };
-
- function getSymbolIterator() {
- if (typeof Symbol !== 'function' || !Symbol.iterator) {
- return '@@iterator';
- }
- return Symbol.iterator;
- }
- var iterator = getSymbolIterator();
-
- var subscribeToIterable = function (iterable) { return function (subscriber) {
- var iterator$$1 = iterable[iterator]();
- do {
- var item = iterator$$1.next();
- if (item.done) {
- subscriber.complete();
- break;
- }
- subscriber.next(item.value);
- if (subscriber.closed) {
- break;
- }
- } while (true);
- if (typeof iterator$$1.return === 'function') {
- subscriber.add(function () {
- if (iterator$$1.return) {
- iterator$$1.return();
- }
- });
- }
- return subscriber;
- }; };
-
- var subscribeToObservable = function (obj) { return function (subscriber) {
- var obs = obj[observable]();
- if (typeof obs.subscribe !== 'function') {
- throw new TypeError('Provided object does not correctly implement Symbol.observable');
- }
- else {
- return obs.subscribe(subscriber);
- }
- }; };
-
- var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
-
- function isPromise(value) {
- return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
- }
-
- var subscribeTo = function (result) {
- if (!!result && typeof result[observable] === 'function') {
- return subscribeToObservable(result);
- }
- else if (isArrayLike(result)) {
- return subscribeToArray(result);
- }
- else if (isPromise(result)) {
- return subscribeToPromise(result);
- }
- else if (!!result && typeof result[iterator] === 'function') {
- return subscribeToIterable(result);
- }
- else {
- var value = isObject(result) ? 'an invalid object' : "'" + result + "'";
- var msg = "You provided " + value + " where a stream was expected."
- + ' You can provide an Observable, Promise, Array, or Iterable.';
- throw new TypeError(msg);
- }
- };
-
- function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, destination) {
- if (destination === void 0) { destination = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
- if (destination.closed) {
- return undefined;
- }
- if (result instanceof Observable) {
- return result.subscribe(destination);
- }
- return subscribeTo(result)(destination);
- }
-
- var NONE = {};
- function combineLatest() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- var resultSelector = null;
- var scheduler = null;
- if (isScheduler(observables[observables.length - 1])) {
- scheduler = observables.pop();
- }
- if (typeof observables[observables.length - 1] === 'function') {
- resultSelector = observables.pop();
- }
- if (observables.length === 1 && isArray(observables[0])) {
- observables = observables[0];
- }
- return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
- }
- var CombineLatestOperator = (function () {
- function CombineLatestOperator(resultSelector) {
- this.resultSelector = resultSelector;
- }
- CombineLatestOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
- };
- return CombineLatestOperator;
- }());
- var CombineLatestSubscriber = (function (_super) {
- __extends(CombineLatestSubscriber, _super);
- function CombineLatestSubscriber(destination, resultSelector) {
- var _this = _super.call(this, destination) || this;
- _this.resultSelector = resultSelector;
- _this.active = 0;
- _this.values = [];
- _this.observables = [];
- return _this;
- }
- CombineLatestSubscriber.prototype._next = function (observable) {
- this.values.push(NONE);
- this.observables.push(observable);
- };
- CombineLatestSubscriber.prototype._complete = function () {
- var observables = this.observables;
- var len = observables.length;
- if (len === 0) {
- this.destination.complete();
- }
- else {
- this.active = len;
- this.toRespond = len;
- for (var i = 0; i < len; i++) {
- var observable = observables[i];
- this.add(subscribeToResult(this, observable, observable, i));
- }
- }
- };
- CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
- if ((this.active -= 1) === 0) {
- this.destination.complete();
- }
- };
- CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- var values = this.values;
- var oldVal = values[outerIndex];
- var toRespond = !this.toRespond
- ? 0
- : oldVal === NONE ? --this.toRespond : this.toRespond;
- values[outerIndex] = innerValue;
- if (toRespond === 0) {
- if (this.resultSelector) {
- this._tryResultSelector(values);
- }
- else {
- this.destination.next(values.slice());
- }
- }
- };
- CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
- var result;
- try {
- result = this.resultSelector.apply(this, values);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(result);
- };
- return CombineLatestSubscriber;
- }(OuterSubscriber));
-
- function 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);
- }
- }
-
- function mergeMap(project, resultSelector, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- if (typeof resultSelector === 'function') {
- return function (source) { return source.pipe(mergeMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
- }
- else if (typeof resultSelector === 'number') {
- concurrent = resultSelector;
- }
- return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
- }
- var MergeMapOperator = (function () {
- function MergeMapOperator(project, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- this.project = project;
- this.concurrent = concurrent;
- }
- MergeMapOperator.prototype.call = function (observer, source) {
- return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
- };
- return MergeMapOperator;
- }());
- var MergeMapSubscriber = (function (_super) {
- __extends(MergeMapSubscriber, _super);
- function MergeMapSubscriber(destination, project, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- var _this = _super.call(this, destination) || this;
- _this.project = project;
- _this.concurrent = concurrent;
- _this.hasCompleted = false;
- _this.buffer = [];
- _this.active = 0;
- _this.index = 0;
- return _this;
- }
- MergeMapSubscriber.prototype._next = function (value) {
- if (this.active < this.concurrent) {
- this._tryNext(value);
- }
- else {
- this.buffer.push(value);
- }
- };
- MergeMapSubscriber.prototype._tryNext = function (value) {
- var result;
- var index = this.index++;
- try {
- result = this.project(value, index);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.active++;
- this._innerSub(result, value, index);
- };
- MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- subscribeToResult(this, ish, value, index, innerSubscriber);
- };
- MergeMapSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (this.active === 0 && this.buffer.length === 0) {
- this.destination.complete();
- }
- this.unsubscribe();
- };
- MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(innerValue);
- };
- MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
- var buffer = this.buffer;
- this.remove(innerSub);
- this.active--;
- if (buffer.length > 0) {
- this._next(buffer.shift());
- }
- else if (this.active === 0 && this.hasCompleted) {
- this.destination.complete();
- }
- };
- return MergeMapSubscriber;
- }(OuterSubscriber));
-
- function mergeAll(concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- return mergeMap(identity, concurrent);
- }
-
- function concatAll() {
- return mergeAll(1);
- }
-
- function concat() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- 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, observable, i);
- if (this.subscriptions) {
- this.subscriptions.push(subscription);
- }
- this.add(subscription);
- }
- this.observables = null;
- }
- };
- RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- if (!this.hasFirst) {
- this.hasFirst = true;
- for (var i = 0; i < this.subscriptions.length; i++) {
- if (i !== outerIndex) {
- var subscription = this.subscriptions[i];
- subscription.unsubscribe();
- this.remove(subscription);
- }
- }
- this.subscriptions = null;
- }
- this.destination.next(innerValue);
- };
- return RaceSubscriber;
- }(OuterSubscriber));
-
- function range(start, count, scheduler) {
- if (start === void 0) { start = 0; }
- 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.iterators = [];
- _this.active = 0;
- _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
- _this.values = values;
- return _this;
- }
- ZipSubscriber.prototype._next = function (value) {
- var iterators = this.iterators;
- if (isArray(value)) {
- iterators.push(new StaticArrayIterator(value));
- }
- else if (typeof value[iterator] === 'function') {
- iterators.push(new StaticIterator(value[iterator]()));
- }
- else {
- iterators.push(new ZipBufferIterator(this.destination, this, value));
- }
- };
- ZipSubscriber.prototype._complete = function () {
- var iterators = this.iterators;
- var len = iterators.length;
- this.unsubscribe();
- if (len === 0) {
- this.destination.complete();
- return;
- }
- this.active = len;
- for (var i = 0; i < len; i++) {
- var iterator$$1 = iterators[i];
- if (iterator$$1.stillUnsubscribed) {
- var destination = this.destination;
- destination.add(iterator$$1.subscribe(iterator$$1, i));
- }
- else {
- this.active--;
- }
- }
- };
- ZipSubscriber.prototype.notifyInactive = function () {
- this.active--;
- if (this.active === 0) {
- this.destination.complete();
- }
- };
- ZipSubscriber.prototype.checkIterators = function () {
- var iterators = this.iterators;
- var len = iterators.length;
- var destination = this.destination;
- for (var i = 0; i < len; i++) {
- var iterator$$1 = iterators[i];
- if (typeof iterator$$1.hasValue === 'function' && !iterator$$1.hasValue()) {
- return;
- }
- }
- var shouldComplete = false;
- var args = [];
- for (var i = 0; i < len; i++) {
- var iterator$$1 = iterators[i];
- var result = iterator$$1.next();
- if (iterator$$1.hasCompleted()) {
- shouldComplete = true;
- }
- if (result.done) {
- destination.complete();
- return;
- }
- args.push(result.value);
- }
- if (this.resultSelector) {
- this._tryresultSelector(args);
- }
- else {
- destination.next(args);
- }
- if (shouldComplete) {
- destination.complete();
- }
- };
- ZipSubscriber.prototype._tryresultSelector = function (args) {
- var result;
- try {
- result = this.resultSelector.apply(this, args);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(result);
- };
- return ZipSubscriber;
- }(Subscriber));
- var StaticIterator = (function () {
- function StaticIterator(iterator$$1) {
- this.iterator = iterator$$1;
- this.nextResult = iterator$$1.next();
- }
- StaticIterator.prototype.hasValue = function () {
- return true;
- };
- StaticIterator.prototype.next = function () {
- var result = this.nextResult;
- this.nextResult = this.iterator.next();
- return result;
- };
- StaticIterator.prototype.hasCompleted = function () {
- var nextResult = this.nextResult;
- return nextResult && nextResult.done;
- };
- return StaticIterator;
- }());
- var StaticArrayIterator = (function () {
- function StaticArrayIterator(array) {
- this.array = array;
- this.index = 0;
- this.length = 0;
- this.length = array.length;
- }
- StaticArrayIterator.prototype[iterator] = function () {
- return this;
- };
- StaticArrayIterator.prototype.next = function (value) {
- var i = this.index++;
- var array = this.array;
- return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
- };
- StaticArrayIterator.prototype.hasValue = function () {
- return this.array.length > this.index;
- };
- StaticArrayIterator.prototype.hasCompleted = function () {
- return this.array.length === this.index;
- };
- return StaticArrayIterator;
- }());
- var ZipBufferIterator = (function (_super) {
- __extends(ZipBufferIterator, _super);
- function ZipBufferIterator(destination, parent, observable) {
- var _this = _super.call(this, destination) || this;
- _this.parent = parent;
- _this.observable = observable;
- _this.stillUnsubscribed = true;
- _this.buffer = [];
- _this.isComplete = false;
- return _this;
- }
- ZipBufferIterator.prototype[iterator] = function () {
- return this;
- };
- ZipBufferIterator.prototype.next = function () {
- var buffer = this.buffer;
- if (buffer.length === 0 && this.isComplete) {
- return { value: null, done: true };
- }
- else {
- return { value: buffer.shift(), done: false };
- }
- };
- ZipBufferIterator.prototype.hasValue = function () {
- return this.buffer.length > 0;
- };
- ZipBufferIterator.prototype.hasCompleted = function () {
- return this.buffer.length === 0 && this.isComplete;
- };
- ZipBufferIterator.prototype.notifyComplete = function () {
- if (this.buffer.length > 0) {
- this.isComplete = true;
- this.parent.notifyInactive();
- }
- else {
- this.destination.complete();
- }
- };
- ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.buffer.push(innerValue);
- this.parent.checkIterators();
- };
- ZipBufferIterator.prototype.subscribe = function (value, index) {
- return subscribeToResult(this, this.observable, this, index);
- };
- return ZipBufferIterator;
- }(OuterSubscriber));
-
- function audit(durationSelector) {
- return function auditOperatorFunction(source) {
- return source.lift(new AuditOperator(durationSelector));
- };
- }
- var AuditOperator = (function () {
- function AuditOperator(durationSelector) {
- this.durationSelector = durationSelector;
- }
- AuditOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
- };
- return AuditOperator;
- }());
- var AuditSubscriber = (function (_super) {
- __extends(AuditSubscriber, _super);
- function AuditSubscriber(destination, durationSelector) {
- var _this = _super.call(this, destination) || this;
- _this.durationSelector = durationSelector;
- _this.hasValue = false;
- return _this;
- }
- AuditSubscriber.prototype._next = function (value) {
- this.value = value;
- this.hasValue = true;
- if (!this.throttled) {
- var duration = void 0;
- try {
- var durationSelector = this.durationSelector;
- duration = durationSelector(value);
- }
- catch (err) {
- return this.destination.error(err);
- }
- var innerSubscription = subscribeToResult(this, duration);
- if (!innerSubscription || innerSubscription.closed) {
- this.clearThrottle();
- }
- else {
- this.add(this.throttled = innerSubscription);
- }
- }
- };
- AuditSubscriber.prototype.clearThrottle = function () {
- var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
- if (throttled) {
- this.remove(throttled);
- this.throttled = null;
- throttled.unsubscribe();
- }
- if (hasValue) {
- this.value = null;
- this.hasValue = false;
- this.destination.next(value);
- }
- };
- AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
- this.clearThrottle();
- };
- AuditSubscriber.prototype.notifyComplete = function () {
- this.clearThrottle();
- };
- return AuditSubscriber;
- }(OuterSubscriber));
-
- function auditTime(duration, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return audit(function () { return timer(duration, scheduler); });
- }
-
- function buffer(closingNotifier) {
- return function bufferOperatorFunction(source) {
- return source.lift(new BufferOperator(closingNotifier));
- };
- }
- var BufferOperator = (function () {
- function BufferOperator(closingNotifier) {
- this.closingNotifier = closingNotifier;
- }
- BufferOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
- };
- return BufferOperator;
- }());
- var BufferSubscriber = (function (_super) {
- __extends(BufferSubscriber, _super);
- function BufferSubscriber(destination, closingNotifier) {
- var _this = _super.call(this, destination) || this;
- _this.buffer = [];
- _this.add(subscribeToResult(_this, closingNotifier));
- return _this;
- }
- BufferSubscriber.prototype._next = function (value) {
- this.buffer.push(value);
- };
- BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- var buffer = this.buffer;
- this.buffer = [];
- this.destination.next(buffer);
- };
- return BufferSubscriber;
- }(OuterSubscriber));
-
- function bufferCount(bufferSize, startBufferEvery) {
- if (startBufferEvery === void 0) { startBufferEvery = null; }
- return function bufferCountOperatorFunction(source) {
- return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
- };
- }
- var BufferCountOperator = (function () {
- function BufferCountOperator(bufferSize, startBufferEvery) {
- this.bufferSize = bufferSize;
- this.startBufferEvery = startBufferEvery;
- if (!startBufferEvery || bufferSize === startBufferEvery) {
- this.subscriberClass = BufferCountSubscriber;
- }
- else {
- this.subscriberClass = BufferSkipCountSubscriber;
- }
- }
- BufferCountOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
- };
- return BufferCountOperator;
- }());
- var BufferCountSubscriber = (function (_super) {
- __extends(BufferCountSubscriber, _super);
- function BufferCountSubscriber(destination, bufferSize) {
- var _this = _super.call(this, destination) || this;
- _this.bufferSize = bufferSize;
- _this.buffer = [];
- return _this;
- }
- BufferCountSubscriber.prototype._next = function (value) {
- var buffer = this.buffer;
- buffer.push(value);
- if (buffer.length == this.bufferSize) {
- this.destination.next(buffer);
- this.buffer = [];
- }
- };
- BufferCountSubscriber.prototype._complete = function () {
- var buffer = this.buffer;
- if (buffer.length > 0) {
- this.destination.next(buffer);
- }
- _super.prototype._complete.call(this);
- };
- return BufferCountSubscriber;
- }(Subscriber));
- var BufferSkipCountSubscriber = (function (_super) {
- __extends(BufferSkipCountSubscriber, _super);
- function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
- var _this = _super.call(this, destination) || this;
- _this.bufferSize = bufferSize;
- _this.startBufferEvery = startBufferEvery;
- _this.buffers = [];
- _this.count = 0;
- return _this;
- }
- BufferSkipCountSubscriber.prototype._next = function (value) {
- var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
- this.count++;
- if (count % startBufferEvery === 0) {
- buffers.push([]);
- }
- for (var i = buffers.length; i--;) {
- var buffer = buffers[i];
- buffer.push(value);
- if (buffer.length === bufferSize) {
- buffers.splice(i, 1);
- this.destination.next(buffer);
- }
- }
- };
- BufferSkipCountSubscriber.prototype._complete = function () {
- var _a = this, buffers = _a.buffers, destination = _a.destination;
- while (buffers.length > 0) {
- var buffer = buffers.shift();
- if (buffer.length > 0) {
- destination.next(buffer);
- }
- }
- _super.prototype._complete.call(this);
- };
- return BufferSkipCountSubscriber;
- }(Subscriber));
-
- function bufferTime(bufferTimeSpan) {
- var length = arguments.length;
- var scheduler = async;
- if (isScheduler(arguments[arguments.length - 1])) {
- scheduler = arguments[arguments.length - 1];
- length--;
- }
- var bufferCreationInterval = null;
- if (length >= 2) {
- bufferCreationInterval = arguments[1];
- }
- var maxBufferSize = Number.POSITIVE_INFINITY;
- if (length >= 3) {
- maxBufferSize = arguments[2];
- }
- return function bufferTimeOperatorFunction(source) {
- return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
- };
- }
- var BufferTimeOperator = (function () {
- function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
- this.bufferTimeSpan = bufferTimeSpan;
- this.bufferCreationInterval = bufferCreationInterval;
- this.maxBufferSize = maxBufferSize;
- this.scheduler = scheduler;
- }
- BufferTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
- };
- return BufferTimeOperator;
- }());
- var Context = (function () {
- function Context() {
- this.buffer = [];
- }
- return Context;
- }());
- var BufferTimeSubscriber = (function (_super) {
- __extends(BufferTimeSubscriber, _super);
- function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.bufferTimeSpan = bufferTimeSpan;
- _this.bufferCreationInterval = bufferCreationInterval;
- _this.maxBufferSize = maxBufferSize;
- _this.scheduler = scheduler;
- _this.contexts = [];
- var context = _this.openContext();
- _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
- if (_this.timespanOnly) {
- var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
- _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
- }
- else {
- var closeState = { subscriber: _this, context: context };
- var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
- _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
- _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
- }
- return _this;
- }
- BufferTimeSubscriber.prototype._next = function (value) {
- var contexts = this.contexts;
- var len = contexts.length;
- var filledBufferContext;
- for (var i = 0; i < len; i++) {
- var context_1 = contexts[i];
- var buffer = context_1.buffer;
- buffer.push(value);
- if (buffer.length == this.maxBufferSize) {
- filledBufferContext = context_1;
- }
- }
- if (filledBufferContext) {
- this.onBufferFull(filledBufferContext);
- }
- };
- BufferTimeSubscriber.prototype._error = function (err) {
- this.contexts.length = 0;
- _super.prototype._error.call(this, err);
- };
- BufferTimeSubscriber.prototype._complete = function () {
- var _a = this, contexts = _a.contexts, destination = _a.destination;
- while (contexts.length > 0) {
- var context_2 = contexts.shift();
- destination.next(context_2.buffer);
- }
- _super.prototype._complete.call(this);
- };
- BufferTimeSubscriber.prototype._unsubscribe = function () {
- this.contexts = null;
- };
- BufferTimeSubscriber.prototype.onBufferFull = function (context) {
- this.closeContext(context);
- var closeAction = context.closeAction;
- closeAction.unsubscribe();
- this.remove(closeAction);
- if (!this.closed && this.timespanOnly) {
- context = this.openContext();
- var bufferTimeSpan = this.bufferTimeSpan;
- var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
- this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
- }
- };
- BufferTimeSubscriber.prototype.openContext = function () {
- var context = new Context();
- this.contexts.push(context);
- return context;
- };
- BufferTimeSubscriber.prototype.closeContext = function (context) {
- this.destination.next(context.buffer);
- var contexts = this.contexts;
- var spliceIndex = contexts ? contexts.indexOf(context) : -1;
- if (spliceIndex >= 0) {
- contexts.splice(contexts.indexOf(context), 1);
- }
- };
- return BufferTimeSubscriber;
- }(Subscriber));
- function dispatchBufferTimeSpanOnly(state) {
- var subscriber = state.subscriber;
- var prevContext = state.context;
- if (prevContext) {
- subscriber.closeContext(prevContext);
- }
- if (!subscriber.closed) {
- state.context = subscriber.openContext();
- state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
- }
- }
- function dispatchBufferCreation(state) {
- var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
- var context = subscriber.openContext();
- var action = this;
- if (!subscriber.closed) {
- subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
- action.schedule(state, bufferCreationInterval);
- }
- }
- function dispatchBufferClose(arg) {
- var subscriber = arg.subscriber, context = arg.context;
- subscriber.closeContext(context);
- }
-
- function bufferToggle(openings, closingSelector) {
- return function bufferToggleOperatorFunction(source) {
- return source.lift(new BufferToggleOperator(openings, closingSelector));
- };
- }
- var BufferToggleOperator = (function () {
- function BufferToggleOperator(openings, closingSelector) {
- this.openings = openings;
- this.closingSelector = closingSelector;
- }
- BufferToggleOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
- };
- return BufferToggleOperator;
- }());
- var BufferToggleSubscriber = (function (_super) {
- __extends(BufferToggleSubscriber, _super);
- function BufferToggleSubscriber(destination, openings, closingSelector) {
- var _this = _super.call(this, destination) || this;
- _this.openings = openings;
- _this.closingSelector = closingSelector;
- _this.contexts = [];
- _this.add(subscribeToResult(_this, openings));
- return _this;
- }
- BufferToggleSubscriber.prototype._next = function (value) {
- var contexts = this.contexts;
- var len = contexts.length;
- for (var i = 0; i < len; i++) {
- contexts[i].buffer.push(value);
- }
- };
- BufferToggleSubscriber.prototype._error = function (err) {
- var contexts = this.contexts;
- while (contexts.length > 0) {
- var context_1 = contexts.shift();
- context_1.subscription.unsubscribe();
- context_1.buffer = null;
- context_1.subscription = null;
- }
- this.contexts = null;
- _super.prototype._error.call(this, err);
- };
- BufferToggleSubscriber.prototype._complete = function () {
- var contexts = this.contexts;
- while (contexts.length > 0) {
- var context_2 = contexts.shift();
- this.destination.next(context_2.buffer);
- context_2.subscription.unsubscribe();
- context_2.buffer = null;
- context_2.subscription = null;
- }
- this.contexts = null;
- _super.prototype._complete.call(this);
- };
- BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
- };
- BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
- this.closeBuffer(innerSub.context);
- };
- BufferToggleSubscriber.prototype.openBuffer = function (value) {
- try {
- var closingSelector = this.closingSelector;
- var closingNotifier = closingSelector.call(this, value);
- if (closingNotifier) {
- this.trySubscribe(closingNotifier);
- }
- }
- catch (err) {
- this._error(err);
- }
- };
- BufferToggleSubscriber.prototype.closeBuffer = function (context) {
- var contexts = this.contexts;
- if (contexts && context) {
- var buffer = context.buffer, subscription = context.subscription;
- this.destination.next(buffer);
- contexts.splice(contexts.indexOf(context), 1);
- this.remove(subscription);
- subscription.unsubscribe();
- }
- };
- BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
- var contexts = this.contexts;
- var buffer = [];
- var subscription = new Subscription();
- var context = { buffer: buffer, subscription: subscription };
- contexts.push(context);
- var innerSubscription = subscribeToResult(this, closingNotifier, context);
- if (!innerSubscription || innerSubscription.closed) {
- this.closeBuffer(context);
- }
- else {
- innerSubscription.context = context;
- this.add(innerSubscription);
- subscription.add(innerSubscription);
- }
- };
- return BufferToggleSubscriber;
- }(OuterSubscriber));
-
- function bufferWhen(closingSelector) {
- return function (source) {
- return source.lift(new BufferWhenOperator(closingSelector));
- };
- }
- var BufferWhenOperator = (function () {
- function BufferWhenOperator(closingSelector) {
- this.closingSelector = closingSelector;
- }
- BufferWhenOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
- };
- return BufferWhenOperator;
- }());
- var BufferWhenSubscriber = (function (_super) {
- __extends(BufferWhenSubscriber, _super);
- function BufferWhenSubscriber(destination, closingSelector) {
- var _this = _super.call(this, destination) || this;
- _this.closingSelector = closingSelector;
- _this.subscribing = false;
- _this.openBuffer();
- return _this;
- }
- BufferWhenSubscriber.prototype._next = function (value) {
- this.buffer.push(value);
- };
- BufferWhenSubscriber.prototype._complete = function () {
- var buffer = this.buffer;
- if (buffer) {
- this.destination.next(buffer);
- }
- _super.prototype._complete.call(this);
- };
- BufferWhenSubscriber.prototype._unsubscribe = function () {
- this.buffer = null;
- this.subscribing = false;
- };
- BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.openBuffer();
- };
- BufferWhenSubscriber.prototype.notifyComplete = function () {
- if (this.subscribing) {
- this.complete();
- }
- else {
- this.openBuffer();
- }
- };
- BufferWhenSubscriber.prototype.openBuffer = function () {
- var closingSubscription = this.closingSubscription;
- if (closingSubscription) {
- this.remove(closingSubscription);
- closingSubscription.unsubscribe();
- }
- var buffer = this.buffer;
- if (this.buffer) {
- this.destination.next(buffer);
- }
- this.buffer = [];
- var closingNotifier;
- 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(subscribeToResult(this, closingNotifier));
- this.subscribing = false;
- };
- return BufferWhenSubscriber;
- }(OuterSubscriber));
-
- function catchError(selector) {
- return function catchErrorOperatorFunction(source) {
- var operator = new CatchOperator(selector);
- var caught = source.lift(operator);
- return (operator.caught = caught);
- };
- }
- var CatchOperator = (function () {
- function CatchOperator(selector) {
- this.selector = selector;
- }
- CatchOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
- };
- return CatchOperator;
- }());
- var CatchSubscriber = (function (_super) {
- __extends(CatchSubscriber, _super);
- function CatchSubscriber(destination, selector, caught) {
- var _this = _super.call(this, destination) || this;
- _this.selector = selector;
- _this.caught = caught;
- return _this;
- }
- CatchSubscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- var result = void 0;
- try {
- result = this.selector(err, this.caught);
- }
- catch (err2) {
- _super.prototype.error.call(this, err2);
- return;
- }
- this._unsubscribeAndRecycle();
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- this.add(innerSubscriber);
- subscribeToResult(this, result, undefined, undefined, innerSubscriber);
- }
- };
- return CatchSubscriber;
- }(OuterSubscriber));
-
- function combineAll(project) {
- return function (source) { return source.lift(new CombineLatestOperator(project)); };
- }
-
- function combineLatest$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- var project = null;
- if (typeof observables[observables.length - 1] === 'function') {
- project = observables.pop();
- }
- if (observables.length === 1 && isArray(observables[0])) {
- observables = observables[0].slice();
- }
- return function (source) { return source.lift.call(from([source].concat(observables)), new CombineLatestOperator(project)); };
- }
-
- function concat$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- return function (source) { return source.lift.call(concat.apply(void 0, [source].concat(observables))); };
- }
-
- function concatMap(project, resultSelector) {
- return mergeMap(project, resultSelector, 1);
- }
-
- function concatMapTo(innerObservable, resultSelector) {
- return concatMap(function () { return innerObservable; }, resultSelector);
- }
-
- function count(predicate) {
- return function (source) { return source.lift(new CountOperator(predicate, source)); };
- }
- var CountOperator = (function () {
- function CountOperator(predicate, source) {
- this.predicate = predicate;
- this.source = source;
- }
- CountOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
- };
- return CountOperator;
- }());
- var CountSubscriber = (function (_super) {
- __extends(CountSubscriber, _super);
- function CountSubscriber(destination, predicate, source) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.source = source;
- _this.count = 0;
- _this.index = 0;
- return _this;
- }
- CountSubscriber.prototype._next = function (value) {
- if (this.predicate) {
- this._tryPredicate(value);
- }
- else {
- this.count++;
- }
- };
- CountSubscriber.prototype._tryPredicate = function (value) {
- var result;
- try {
- result = this.predicate(value, this.index++, this.source);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- if (result) {
- this.count++;
- }
- };
- CountSubscriber.prototype._complete = function () {
- this.destination.next(this.count);
- this.destination.complete();
- };
- return CountSubscriber;
- }(Subscriber));
-
- function debounce(durationSelector) {
- return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
- }
- var DebounceOperator = (function () {
- function DebounceOperator(durationSelector) {
- this.durationSelector = durationSelector;
- }
- DebounceOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
- };
- return DebounceOperator;
- }());
- var DebounceSubscriber = (function (_super) {
- __extends(DebounceSubscriber, _super);
- function DebounceSubscriber(destination, durationSelector) {
- var _this = _super.call(this, destination) || this;
- _this.durationSelector = durationSelector;
- _this.hasValue = false;
- _this.durationSubscription = null;
- return _this;
- }
- DebounceSubscriber.prototype._next = function (value) {
- try {
- var result = this.durationSelector.call(this, value);
- if (result) {
- this._tryNext(value, result);
- }
- }
- catch (err) {
- this.destination.error(err);
- }
- };
- DebounceSubscriber.prototype._complete = function () {
- this.emitValue();
- this.destination.complete();
- };
- DebounceSubscriber.prototype._tryNext = function (value, duration) {
- var subscription = this.durationSubscription;
- this.value = value;
- this.hasValue = true;
- if (subscription) {
- subscription.unsubscribe();
- this.remove(subscription);
- }
- subscription = subscribeToResult(this, duration);
- if (subscription && !subscription.closed) {
- this.add(this.durationSubscription = subscription);
- }
- };
- DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.emitValue();
- };
- DebounceSubscriber.prototype.notifyComplete = function () {
- this.emitValue();
- };
- DebounceSubscriber.prototype.emitValue = function () {
- if (this.hasValue) {
- var value = this.value;
- var subscription = this.durationSubscription;
- if (subscription) {
- this.durationSubscription = null;
- subscription.unsubscribe();
- this.remove(subscription);
- }
- this.value = null;
- this.hasValue = false;
- _super.prototype._next.call(this, value);
- }
- };
- return DebounceSubscriber;
- }(OuterSubscriber));
-
- function debounceTime(dueTime, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
- }
- var DebounceTimeOperator = (function () {
- function DebounceTimeOperator(dueTime, scheduler) {
- this.dueTime = dueTime;
- this.scheduler = scheduler;
- }
- DebounceTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
- };
- return DebounceTimeOperator;
- }());
- var DebounceTimeSubscriber = (function (_super) {
- __extends(DebounceTimeSubscriber, _super);
- function DebounceTimeSubscriber(destination, dueTime, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.dueTime = dueTime;
- _this.scheduler = scheduler;
- _this.debouncedSubscription = null;
- _this.lastValue = null;
- _this.hasValue = false;
- return _this;
- }
- DebounceTimeSubscriber.prototype._next = function (value) {
- this.clearDebounce();
- this.lastValue = value;
- this.hasValue = true;
- this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext$2, this.dueTime, this));
- };
- DebounceTimeSubscriber.prototype._complete = function () {
- this.debouncedNext();
- this.destination.complete();
- };
- DebounceTimeSubscriber.prototype.debouncedNext = function () {
- this.clearDebounce();
- if (this.hasValue) {
- var lastValue = this.lastValue;
- this.lastValue = null;
- this.hasValue = false;
- this.destination.next(lastValue);
- }
- };
- DebounceTimeSubscriber.prototype.clearDebounce = function () {
- var debouncedSubscription = this.debouncedSubscription;
- if (debouncedSubscription !== null) {
- this.remove(debouncedSubscription);
- debouncedSubscription.unsubscribe();
- this.debouncedSubscription = null;
- }
- };
- return DebounceTimeSubscriber;
- }(Subscriber));
- function dispatchNext$2(subscriber) {
- subscriber.debouncedNext();
- }
-
- function defaultIfEmpty(defaultValue) {
- if (defaultValue === void 0) { defaultValue = null; }
- return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
- }
- var DefaultIfEmptyOperator = (function () {
- function DefaultIfEmptyOperator(defaultValue) {
- this.defaultValue = defaultValue;
- }
- DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
- };
- return DefaultIfEmptyOperator;
- }());
- var DefaultIfEmptySubscriber = (function (_super) {
- __extends(DefaultIfEmptySubscriber, _super);
- function DefaultIfEmptySubscriber(destination, defaultValue) {
- var _this = _super.call(this, destination) || this;
- _this.defaultValue = defaultValue;
- _this.isEmpty = true;
- return _this;
- }
- DefaultIfEmptySubscriber.prototype._next = function (value) {
- this.isEmpty = false;
- this.destination.next(value);
- };
- DefaultIfEmptySubscriber.prototype._complete = function () {
- if (this.isEmpty) {
- this.destination.next(this.defaultValue);
- }
- this.destination.complete();
- };
- return DefaultIfEmptySubscriber;
- }(Subscriber));
-
- function isDate(value) {
- return value instanceof Date && !isNaN(+value);
- }
-
- function delay(delay, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- var absoluteDelay = isDate(delay);
- var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
- return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
- }
- var DelayOperator = (function () {
- function DelayOperator(delay, scheduler) {
- this.delay = delay;
- this.scheduler = scheduler;
- }
- DelayOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
- };
- return DelayOperator;
- }());
- var DelaySubscriber = (function (_super) {
- __extends(DelaySubscriber, _super);
- function DelaySubscriber(destination, delay, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.delay = delay;
- _this.scheduler = scheduler;
- _this.queue = [];
- _this.active = false;
- _this.errored = false;
- return _this;
- }
- DelaySubscriber.dispatch = function (state) {
- var source = state.source;
- var queue = source.queue;
- var scheduler = state.scheduler;
- var destination = state.destination;
- while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
- queue.shift().notification.observe(destination);
- }
- if (queue.length > 0) {
- var delay_1 = Math.max(0, queue[0].time - scheduler.now());
- this.schedule(state, delay_1);
- }
- else {
- this.unsubscribe();
- source.active = false;
- }
- };
- DelaySubscriber.prototype._schedule = function (scheduler) {
- this.active = true;
- var destination = this.destination;
- destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
- source: this, destination: this.destination, scheduler: scheduler
- }));
- };
- DelaySubscriber.prototype.scheduleNotification = function (notification) {
- if (this.errored === true) {
- return;
- }
- var scheduler = this.scheduler;
- var message = new DelayMessage(scheduler.now() + this.delay, notification);
- this.queue.push(message);
- if (this.active === false) {
- this._schedule(scheduler);
- }
- };
- DelaySubscriber.prototype._next = function (value) {
- this.scheduleNotification(Notification.createNext(value));
- };
- DelaySubscriber.prototype._error = function (err) {
- this.errored = true;
- this.queue = [];
- this.destination.error(err);
- this.unsubscribe();
- };
- DelaySubscriber.prototype._complete = function () {
- this.scheduleNotification(Notification.createComplete());
- this.unsubscribe();
- };
- return DelaySubscriber;
- }(Subscriber));
- var DelayMessage = (function () {
- function DelayMessage(time, notification) {
- this.time = time;
- this.notification = notification;
- }
- return DelayMessage;
- }());
-
- function delayWhen(delayDurationSelector, subscriptionDelay) {
- if (subscriptionDelay) {
- return function (source) {
- return new SubscriptionDelayObservable(source, subscriptionDelay)
- .lift(new DelayWhenOperator(delayDurationSelector));
- };
- }
- return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
- }
- var DelayWhenOperator = (function () {
- function DelayWhenOperator(delayDurationSelector) {
- this.delayDurationSelector = delayDurationSelector;
- }
- DelayWhenOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
- };
- return DelayWhenOperator;
- }());
- var DelayWhenSubscriber = (function (_super) {
- __extends(DelayWhenSubscriber, _super);
- function DelayWhenSubscriber(destination, delayDurationSelector) {
- var _this = _super.call(this, destination) || this;
- _this.delayDurationSelector = delayDurationSelector;
- _this.completed = false;
- _this.delayNotifierSubscriptions = [];
- _this.index = 0;
- return _this;
- }
- DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(outerValue);
- this.removeSubscription(innerSub);
- this.tryComplete();
- };
- DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
- this._error(error);
- };
- DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
- var value = this.removeSubscription(innerSub);
- if (value) {
- this.destination.next(value);
- }
- this.tryComplete();
- };
- DelayWhenSubscriber.prototype._next = function (value) {
- var index = this.index++;
- try {
- var delayNotifier = this.delayDurationSelector(value, index);
- if (delayNotifier) {
- this.tryDelay(delayNotifier, value);
- }
- }
- catch (err) {
- this.destination.error(err);
- }
- };
- DelayWhenSubscriber.prototype._complete = function () {
- this.completed = true;
- this.tryComplete();
- this.unsubscribe();
- };
- DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
- subscription.unsubscribe();
- var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
- if (subscriptionIdx !== -1) {
- this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
- }
- return subscription.outerValue;
- };
- DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
- var notifierSubscription = subscribeToResult(this, delayNotifier, value);
- if (notifierSubscription && !notifierSubscription.closed) {
- var destination = this.destination;
- destination.add(notifierSubscription);
- this.delayNotifierSubscriptions.push(notifierSubscription);
- }
- };
- DelayWhenSubscriber.prototype.tryComplete = function () {
- if (this.completed && this.delayNotifierSubscriptions.length === 0) {
- this.destination.complete();
- }
- };
- return DelayWhenSubscriber;
- }(OuterSubscriber));
- var SubscriptionDelayObservable = (function (_super) {
- __extends(SubscriptionDelayObservable, _super);
- function SubscriptionDelayObservable(source, subscriptionDelay) {
- var _this = _super.call(this) || this;
- _this.source = source;
- _this.subscriptionDelay = subscriptionDelay;
- return _this;
- }
- SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
- this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
- };
- return SubscriptionDelayObservable;
- }(Observable));
- var SubscriptionDelaySubscriber = (function (_super) {
- __extends(SubscriptionDelaySubscriber, _super);
- function SubscriptionDelaySubscriber(parent, source) {
- var _this = _super.call(this) || this;
- _this.parent = parent;
- _this.source = source;
- _this.sourceSubscribed = false;
- return _this;
- }
- SubscriptionDelaySubscriber.prototype._next = function (unused) {
- this.subscribeToSource();
- };
- SubscriptionDelaySubscriber.prototype._error = function (err) {
- this.unsubscribe();
- this.parent.error(err);
- };
- SubscriptionDelaySubscriber.prototype._complete = function () {
- this.unsubscribe();
- this.subscribeToSource();
- };
- SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
- if (!this.sourceSubscribed) {
- this.sourceSubscribed = true;
- this.unsubscribe();
- this.source.subscribe(this.parent);
- }
- };
- return SubscriptionDelaySubscriber;
- }(Subscriber));
-
- function dematerialize() {
- return function dematerializeOperatorFunction(source) {
- return source.lift(new DeMaterializeOperator());
- };
- }
- var DeMaterializeOperator = (function () {
- function DeMaterializeOperator() {
- }
- DeMaterializeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DeMaterializeSubscriber(subscriber));
- };
- return DeMaterializeOperator;
- }());
- var DeMaterializeSubscriber = (function (_super) {
- __extends(DeMaterializeSubscriber, _super);
- function DeMaterializeSubscriber(destination) {
- return _super.call(this, destination) || this;
- }
- DeMaterializeSubscriber.prototype._next = function (value) {
- value.observe(this.destination);
- };
- return DeMaterializeSubscriber;
- }(Subscriber));
-
- function distinct(keySelector, flushes) {
- return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
- }
- var DistinctOperator = (function () {
- function DistinctOperator(keySelector, flushes) {
- this.keySelector = keySelector;
- this.flushes = flushes;
- }
- DistinctOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
- };
- return DistinctOperator;
- }());
- var DistinctSubscriber = (function (_super) {
- __extends(DistinctSubscriber, _super);
- function DistinctSubscriber(destination, keySelector, flushes) {
- var _this = _super.call(this, destination) || this;
- _this.keySelector = keySelector;
- _this.values = new Set();
- if (flushes) {
- _this.add(subscribeToResult(_this, flushes));
- }
- return _this;
- }
- DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.values.clear();
- };
- DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
- this._error(error);
- };
- DistinctSubscriber.prototype._next = function (value) {
- if (this.keySelector) {
- this._useKeySelector(value);
- }
- else {
- this._finalizeNext(value, value);
- }
- };
- DistinctSubscriber.prototype._useKeySelector = function (value) {
- var key;
- var destination = this.destination;
- try {
- key = this.keySelector(value);
- }
- catch (err) {
- destination.error(err);
- return;
- }
- this._finalizeNext(key, value);
- };
- DistinctSubscriber.prototype._finalizeNext = function (key, value) {
- var values = this.values;
- if (!values.has(key)) {
- values.add(key);
- this.destination.next(value);
- }
- };
- return DistinctSubscriber;
- }(OuterSubscriber));
-
- function distinctUntilChanged(compare, keySelector) {
- return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
- }
- var DistinctUntilChangedOperator = (function () {
- function DistinctUntilChangedOperator(compare, keySelector) {
- this.compare = compare;
- this.keySelector = keySelector;
- }
- DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
- };
- return DistinctUntilChangedOperator;
- }());
- var DistinctUntilChangedSubscriber = (function (_super) {
- __extends(DistinctUntilChangedSubscriber, _super);
- function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
- var _this = _super.call(this, destination) || this;
- _this.keySelector = keySelector;
- _this.hasKey = false;
- if (typeof compare === 'function') {
- _this.compare = compare;
- }
- return _this;
- }
- DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
- return x === y;
- };
- DistinctUntilChangedSubscriber.prototype._next = function (value) {
- var 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(subscribeToResult(this, value));
- }
- };
- SwitchFirstSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (!this.hasSubscription) {
- this.destination.complete();
- }
- };
- SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
- this.remove(innerSub);
- this.hasSubscription = false;
- if (this.hasCompleted) {
- this.destination.complete();
- }
- };
- return SwitchFirstSubscriber;
- }(OuterSubscriber));
-
- function exhaustMap(project, resultSelector) {
- if (resultSelector) {
- return function (source) { return source.pipe(exhaustMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
- }
- return function (source) {
- return source.lift(new 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, value, index);
- };
- ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- subscribeToResult(this, result, value, index, innerSubscriber);
- };
- ExhaustMapSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (!this.hasSubscription) {
- this.destination.complete();
- }
- this.unsubscribe();
- };
- ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(innerValue);
- };
- ExhaustMapSubscriber.prototype.notifyError = function (err) {
- this.destination.error(err);
- };
- ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
- var destination = this.destination;
- destination.remove(innerSub);
- this.hasSubscription = false;
- if (this.hasCompleted) {
- this.destination.complete();
- }
- };
- return ExhaustMapSubscriber;
- }(OuterSubscriber));
-
- function expand(project, concurrent, scheduler) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- if (scheduler === void 0) { scheduler = undefined; }
- concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
- return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
- }
- var ExpandOperator = (function () {
- function ExpandOperator(project, concurrent, scheduler) {
- this.project = project;
- this.concurrent = concurrent;
- this.scheduler = scheduler;
- }
- ExpandOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
- };
- return ExpandOperator;
- }());
- var ExpandSubscriber = (function (_super) {
- __extends(ExpandSubscriber, _super);
- function ExpandSubscriber(destination, project, concurrent, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.project = project;
- _this.concurrent = concurrent;
- _this.scheduler = scheduler;
- _this.index = 0;
- _this.active = 0;
- _this.hasCompleted = false;
- if (concurrent < Number.POSITIVE_INFINITY) {
- _this.buffer = [];
- }
- return _this;
- }
- ExpandSubscriber.dispatch = function (arg) {
- var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
- subscriber.subscribeToProjection(result, value, index);
- };
- ExpandSubscriber.prototype._next = function (value) {
- var destination = this.destination;
- if (destination.closed) {
- this._complete();
- return;
- }
- var index = this.index++;
- if (this.active < this.concurrent) {
- destination.next(value);
- 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(subscribeToResult(this, result, value, index));
- };
- ExpandSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (this.hasCompleted && this.active === 0) {
- this.destination.complete();
- }
- this.unsubscribe();
- };
- ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this._next(innerValue);
- };
- ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
- var buffer = this.buffer;
- var destination = this.destination;
- destination.remove(innerSub);
- this.active--;
- if (buffer && buffer.length > 0) {
- this._next(buffer.shift());
- }
- if (this.hasCompleted && this.active === 0) {
- this.destination.complete();
- }
- };
- return ExpandSubscriber;
- }(OuterSubscriber));
-
- function finalize(callback) {
- return function (source) { return source.lift(new FinallyOperator(callback)); };
- }
- var FinallyOperator = (function () {
- function FinallyOperator(callback) {
- this.callback = callback;
- }
- FinallyOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new FinallySubscriber(subscriber, this.callback));
- };
- return FinallyOperator;
- }());
- var FinallySubscriber = (function (_super) {
- __extends(FinallySubscriber, _super);
- function FinallySubscriber(destination, callback) {
- var _this = _super.call(this, destination) || this;
- _this.add(new Subscription(callback));
- return _this;
- }
- return FinallySubscriber;
- }(Subscriber));
-
- function find(predicate, thisArg) {
- if (typeof predicate !== 'function') {
- throw new TypeError('predicate is not a function');
- }
- return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
- }
- var FindValueOperator = (function () {
- function FindValueOperator(predicate, source, yieldIndex, thisArg) {
- this.predicate = predicate;
- this.source = source;
- this.yieldIndex = yieldIndex;
- this.thisArg = thisArg;
- }
- FindValueOperator.prototype.call = function (observer, source) {
- return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
- };
- return FindValueOperator;
- }());
- var FindValueSubscriber = (function (_super) {
- __extends(FindValueSubscriber, _super);
- function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.source = source;
- _this.yieldIndex = yieldIndex;
- _this.thisArg = thisArg;
- _this.index = 0;
- return _this;
- }
- FindValueSubscriber.prototype.notifyComplete = function (value) {
- var destination = this.destination;
- destination.next(value);
- destination.complete();
- this.unsubscribe();
- };
- FindValueSubscriber.prototype._next = function (value) {
- var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
- var index = this.index++;
- try {
- var result = predicate.call(thisArg || this, value, index, this.source);
- if (result) {
- this.notifyComplete(this.yieldIndex ? index : value);
- }
- }
- catch (err) {
- this.destination.error(err);
- }
- };
- FindValueSubscriber.prototype._complete = function () {
- this.notifyComplete(this.yieldIndex ? -1 : undefined);
- };
- return FindValueSubscriber;
- }(Subscriber));
-
- function findIndex(predicate, thisArg) {
- return function (source) { return source.lift(new FindValueOperator(predicate, source, true, thisArg)); };
- }
-
- function first(predicate, defaultValue) {
- var hasDefaultValue = arguments.length >= 2;
- return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
- }
-
- function ignoreElements() {
- return function ignoreElementsOperatorFunction(source) {
- return source.lift(new IgnoreElementsOperator());
- };
- }
- var IgnoreElementsOperator = (function () {
- function IgnoreElementsOperator() {
- }
- IgnoreElementsOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new IgnoreElementsSubscriber(subscriber));
- };
- return IgnoreElementsOperator;
- }());
- var IgnoreElementsSubscriber = (function (_super) {
- __extends(IgnoreElementsSubscriber, _super);
- function IgnoreElementsSubscriber() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- IgnoreElementsSubscriber.prototype._next = function (unused) {
- };
- return IgnoreElementsSubscriber;
- }(Subscriber));
-
- function isEmpty() {
- return function (source) { return source.lift(new IsEmptyOperator()); };
- }
- var IsEmptyOperator = (function () {
- function IsEmptyOperator() {
- }
- IsEmptyOperator.prototype.call = function (observer, source) {
- return source.subscribe(new IsEmptySubscriber(observer));
- };
- return IsEmptyOperator;
- }());
- var IsEmptySubscriber = (function (_super) {
- __extends(IsEmptySubscriber, _super);
- function IsEmptySubscriber(destination) {
- return _super.call(this, destination) || this;
- }
- IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
- var destination = this.destination;
- destination.next(isEmpty);
- destination.complete();
- };
- IsEmptySubscriber.prototype._next = function (value) {
- this.notifyComplete(false);
- };
- IsEmptySubscriber.prototype._complete = function () {
- this.notifyComplete(true);
- };
- return IsEmptySubscriber;
- }(Subscriber));
-
- function takeLast(count) {
- return function takeLastOperatorFunction(source) {
- if (count === 0) {
- return empty$1();
- }
- else {
- return source.lift(new TakeLastOperator(count));
- }
- };
- }
- var TakeLastOperator = (function () {
- function TakeLastOperator(total) {
- this.total = total;
- if (this.total < 0) {
- throw new ArgumentOutOfRangeError;
- }
- }
- TakeLastOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
- };
- return TakeLastOperator;
- }());
- var TakeLastSubscriber = (function (_super) {
- __extends(TakeLastSubscriber, _super);
- function TakeLastSubscriber(destination, total) {
- var _this = _super.call(this, destination) || this;
- _this.total = total;
- _this.ring = new Array();
- _this.count = 0;
- return _this;
- }
- TakeLastSubscriber.prototype._next = function (value) {
- var ring = this.ring;
- var total = this.total;
- var count = this.count++;
- if (ring.length < total) {
- ring.push(value);
- }
- else {
- var index = count % total;
- ring[index] = value;
- }
- };
- TakeLastSubscriber.prototype._complete = function () {
- var destination = this.destination;
- var count = this.count;
- if (count > 0) {
- var total = this.count >= this.total ? this.total : this.count;
- var ring = this.ring;
- for (var i = 0; i < total; i++) {
- var idx = (count++) % total;
- destination.next(ring[idx]);
- }
- }
- destination.complete();
- };
- return TakeLastSubscriber;
- }(Subscriber));
-
- function last(predicate, defaultValue) {
- var hasDefaultValue = arguments.length >= 2;
- return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
- }
-
- function mapTo(value) {
- return function (source) { return source.lift(new MapToOperator(value)); };
- }
- var MapToOperator = (function () {
- function MapToOperator(value) {
- this.value = value;
- }
- MapToOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new MapToSubscriber(subscriber, this.value));
- };
- return MapToOperator;
- }());
- var MapToSubscriber = (function (_super) {
- __extends(MapToSubscriber, _super);
- function MapToSubscriber(destination, value) {
- var _this = _super.call(this, destination) || this;
- _this.value = value;
- return _this;
- }
- MapToSubscriber.prototype._next = function (x) {
- this.destination.next(this.value);
- };
- return MapToSubscriber;
- }(Subscriber));
-
- function materialize() {
- return function materializeOperatorFunction(source) {
- return source.lift(new MaterializeOperator());
- };
- }
- var MaterializeOperator = (function () {
- function MaterializeOperator() {
- }
- MaterializeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new MaterializeSubscriber(subscriber));
- };
- return MaterializeOperator;
- }());
- var MaterializeSubscriber = (function (_super) {
- __extends(MaterializeSubscriber, _super);
- function MaterializeSubscriber(destination) {
- return _super.call(this, destination) || this;
- }
- MaterializeSubscriber.prototype._next = function (value) {
- this.destination.next(Notification.createNext(value));
- };
- MaterializeSubscriber.prototype._error = function (err) {
- var destination = this.destination;
- destination.next(Notification.createError(err));
- destination.complete();
- };
- MaterializeSubscriber.prototype._complete = function () {
- var destination = this.destination;
- destination.next(Notification.createComplete());
- destination.complete();
- };
- return MaterializeSubscriber;
- }(Subscriber));
-
- function scan(accumulator, seed) {
- var hasSeed = false;
- if (arguments.length >= 2) {
- hasSeed = true;
- }
- return function scanOperatorFunction(source) {
- return source.lift(new ScanOperator(accumulator, seed, hasSeed));
- };
- }
- var ScanOperator = (function () {
- function ScanOperator(accumulator, seed, hasSeed) {
- if (hasSeed === void 0) { hasSeed = false; }
- this.accumulator = accumulator;
- this.seed = seed;
- this.hasSeed = hasSeed;
- }
- ScanOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
- };
- return ScanOperator;
- }());
- var ScanSubscriber = (function (_super) {
- __extends(ScanSubscriber, _super);
- function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
- var _this = _super.call(this, destination) || this;
- _this.accumulator = accumulator;
- _this._seed = _seed;
- _this.hasSeed = hasSeed;
- _this.index = 0;
- return _this;
- }
- Object.defineProperty(ScanSubscriber.prototype, "seed", {
- get: function () {
- return this._seed;
- },
- set: function (value) {
- this.hasSeed = true;
- this._seed = value;
- },
- enumerable: true,
- configurable: true
- });
- ScanSubscriber.prototype._next = function (value) {
- if (!this.hasSeed) {
- this.seed = value;
- this.destination.next(value);
- }
- else {
- return this._tryNext(value);
- }
- };
- ScanSubscriber.prototype._tryNext = function (value) {
- var index = this.index++;
- var result;
- try {
- result = this.accumulator(this.seed, value, index);
- }
- catch (err) {
- this.destination.error(err);
- }
- this.seed = result;
- this.destination.next(result);
- };
- return ScanSubscriber;
- }(Subscriber));
-
- function reduce(accumulator, seed) {
- if (arguments.length >= 2) {
- return function reduceOperatorFunctionWithSeed(source) {
- return pipe(scan(accumulator, seed), takeLast(1), defaultIfEmpty(seed))(source);
- };
- }
- return function reduceOperatorFunction(source) {
- return pipe(scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast(1))(source);
- };
- }
-
- function max(comparer) {
- var max = (typeof comparer === 'function')
- ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
- : function (x, y) { return x > y ? x : y; };
- return reduce(max);
- }
-
- function merge$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- return function (source) { return source.lift.call(merge.apply(void 0, [source].concat(observables))); };
- }
-
- function mergeMapTo(innerObservable, resultSelector, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- if (typeof resultSelector === 'function') {
- return mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
- }
- if (typeof resultSelector === 'number') {
- concurrent = resultSelector;
- }
- return mergeMap(function () { return innerObservable; }, concurrent);
- }
-
- function mergeScan(accumulator, seed, concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
- }
- var MergeScanOperator = (function () {
- function MergeScanOperator(accumulator, seed, concurrent) {
- this.accumulator = accumulator;
- this.seed = seed;
- this.concurrent = concurrent;
- }
- MergeScanOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
- };
- return MergeScanOperator;
- }());
- var MergeScanSubscriber = (function (_super) {
- __extends(MergeScanSubscriber, _super);
- function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
- var _this = _super.call(this, destination) || this;
- _this.accumulator = accumulator;
- _this.acc = acc;
- _this.concurrent = concurrent;
- _this.hasValue = false;
- _this.hasCompleted = false;
- _this.buffer = [];
- _this.active = 0;
- _this.index = 0;
- return _this;
- }
- MergeScanSubscriber.prototype._next = function (value) {
- if (this.active < this.concurrent) {
- var index = this.index++;
- var 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, value, index);
- }
- else {
- this.buffer.push(value);
- }
- };
- MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- subscribeToResult(this, ish, value, index, innerSubscriber);
- };
- MergeScanSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (this.active === 0 && this.buffer.length === 0) {
- if (this.hasValue === false) {
- this.destination.next(this.acc);
- }
- this.destination.complete();
- }
- this.unsubscribe();
- };
- MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- var destination = this.destination;
- this.acc = innerValue;
- this.hasValue = true;
- destination.next(innerValue);
- };
- MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
- var buffer = this.buffer;
- var destination = this.destination;
- destination.remove(innerSub);
- this.active--;
- if (buffer.length > 0) {
- this._next(buffer.shift());
- }
- else if (this.active === 0 && this.hasCompleted) {
- if (this.hasValue === false) {
- this.destination.next(this.acc);
- }
- this.destination.complete();
- }
- };
- return MergeScanSubscriber;
- }(OuterSubscriber));
-
- function min(comparer) {
- var min = (typeof comparer === 'function')
- ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
- : function (x, y) { return x < y ? x : y; };
- return reduce(min);
- }
-
- function multicast(subjectOrSubjectFactory, selector) {
- return function multicastOperatorFunction(source) {
- var subjectFactory;
- if (typeof subjectOrSubjectFactory === 'function') {
- subjectFactory = subjectOrSubjectFactory;
- }
- else {
- subjectFactory = function subjectFactory() {
- return subjectOrSubjectFactory;
- };
- }
- if (typeof selector === 'function') {
- return source.lift(new MulticastOperator(subjectFactory, selector));
- }
- var connectable = Object.create(source, connectableObservableDescriptor);
- connectable.source = source;
- connectable.subjectFactory = subjectFactory;
- return connectable;
- };
- }
- var MulticastOperator = (function () {
- function MulticastOperator(subjectFactory, selector) {
- this.subjectFactory = subjectFactory;
- this.selector = selector;
- }
- MulticastOperator.prototype.call = function (subscriber, source) {
- var selector = this.selector;
- var subject = this.subjectFactory();
- var subscription = selector(subject).subscribe(subscriber);
- subscription.add(source.subscribe(subject));
- return subscription;
- };
- return MulticastOperator;
- }());
-
- function onErrorResumeNext$1() {
- var nextSources = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- nextSources[_i] = arguments[_i];
- }
- if (nextSources.length === 1 && isArray(nextSources[0])) {
- nextSources = nextSources[0];
- }
- return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
- }
- var OnErrorResumeNextOperator = (function () {
- function OnErrorResumeNextOperator(nextSources) {
- this.nextSources = nextSources;
- }
- OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
- };
- return OnErrorResumeNextOperator;
- }());
- var OnErrorResumeNextSubscriber = (function (_super) {
- __extends(OnErrorResumeNextSubscriber, _super);
- function OnErrorResumeNextSubscriber(destination, nextSources) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- _this.nextSources = nextSources;
- return _this;
- }
- OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
- this.subscribeToNextSource();
- };
- OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
- this.subscribeToNextSource();
- };
- OnErrorResumeNextSubscriber.prototype._error = function (err) {
- this.subscribeToNextSource();
- this.unsubscribe();
- };
- OnErrorResumeNextSubscriber.prototype._complete = function () {
- this.subscribeToNextSource();
- this.unsubscribe();
- };
- OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
- var next = this.nextSources.shift();
- if (!!next) {
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- subscribeToResult(this, next, undefined, undefined, innerSubscriber);
- }
- else {
- this.destination.complete();
- }
- };
- return OnErrorResumeNextSubscriber;
- }(OuterSubscriber));
-
- function pairwise() {
- return function (source) { return source.lift(new PairwiseOperator()); };
- }
- var PairwiseOperator = (function () {
- function PairwiseOperator() {
- }
- PairwiseOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new PairwiseSubscriber(subscriber));
- };
- return PairwiseOperator;
- }());
- var PairwiseSubscriber = (function (_super) {
- __extends(PairwiseSubscriber, _super);
- function PairwiseSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.hasPrev = false;
- return _this;
- }
- PairwiseSubscriber.prototype._next = function (value) {
- 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[props[i]];
- if (typeof p !== 'undefined') {
- currentProp = p;
- }
- else {
- return undefined;
- }
- }
- return currentProp;
- };
- return mapper;
- }
-
- function publish(selector) {
- return selector ?
- multicast(function () { return new Subject(); }, selector) :
- multicast(new Subject());
- }
-
- function publishBehavior(value) {
- return function (source) { return multicast(new BehaviorSubject(value))(source); };
- }
-
- function publishLast() {
- return function (source) { return multicast(new AsyncSubject())(source); };
- }
-
- function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
- if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
- scheduler = selectorOrScheduler;
- }
- var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
- var subject = new ReplaySubject(bufferSize, windowTime, scheduler);
- return function (source) { return multicast(function () { return subject; }, selector)(source); };
- }
-
- function race$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- return function raceOperatorFunction(source) {
- if (observables.length === 1 && isArray(observables[0])) {
- observables = observables[0];
- }
- return source.lift.call(race.apply(void 0, [source].concat(observables)));
- };
- }
-
- function repeat(count) {
- if (count === void 0) { count = -1; }
- return function (source) {
- if (count === 0) {
- return empty$1();
- }
- else if (count < 0) {
- return source.lift(new RepeatOperator(-1, source));
- }
- else {
- return source.lift(new RepeatOperator(count - 1, source));
- }
- };
- }
- var RepeatOperator = (function () {
- function RepeatOperator(count, source) {
- this.count = count;
- this.source = source;
- }
- RepeatOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
- };
- return RepeatOperator;
- }());
- var RepeatSubscriber = (function (_super) {
- __extends(RepeatSubscriber, _super);
- function RepeatSubscriber(destination, count, source) {
- var _this = _super.call(this, destination) || this;
- _this.count = count;
- _this.source = source;
- return _this;
- }
- RepeatSubscriber.prototype.complete = function () {
- if (!this.isStopped) {
- var _a = this, source = _a.source, count = _a.count;
- if (count === 0) {
- return _super.prototype.complete.call(this);
- }
- else if (count > -1) {
- this.count = count - 1;
- }
- source.subscribe(this._unsubscribeAndRecycle());
- }
- };
- return RepeatSubscriber;
- }(Subscriber));
-
- function repeatWhen(notifier) {
- return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
- }
- var RepeatWhenOperator = (function () {
- function RepeatWhenOperator(notifier) {
- this.notifier = notifier;
- }
- RepeatWhenOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
- };
- return RepeatWhenOperator;
- }());
- var RepeatWhenSubscriber = (function (_super) {
- __extends(RepeatWhenSubscriber, _super);
- function RepeatWhenSubscriber(destination, notifier, source) {
- var _this = _super.call(this, destination) || this;
- _this.notifier = notifier;
- _this.source = source;
- _this.sourceIsBeingSubscribedTo = true;
- return _this;
- }
- RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.sourceIsBeingSubscribedTo = true;
- this.source.subscribe(this);
- };
- RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
- if (this.sourceIsBeingSubscribedTo === false) {
- return _super.prototype.complete.call(this);
- }
- };
- RepeatWhenSubscriber.prototype.complete = function () {
- this.sourceIsBeingSubscribedTo = false;
- if (!this.isStopped) {
- if (!this.retries) {
- this.subscribeToRetries();
- }
- if (!this.retriesSubscription || this.retriesSubscription.closed) {
- return _super.prototype.complete.call(this);
- }
- this._unsubscribeAndRecycle();
- this.notifications.next();
- }
- };
- RepeatWhenSubscriber.prototype._unsubscribe = function () {
- var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
- if (notifications) {
- notifications.unsubscribe();
- this.notifications = null;
- }
- if (retriesSubscription) {
- retriesSubscription.unsubscribe();
- this.retriesSubscription = null;
- }
- this.retries = null;
- };
- RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
- var _unsubscribe = this._unsubscribe;
- this._unsubscribe = null;
- _super.prototype._unsubscribeAndRecycle.call(this);
- this._unsubscribe = _unsubscribe;
- return this;
- };
- RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
- this.notifications = new Subject();
- var retries;
- try {
- var notifier = this.notifier;
- retries = notifier(this.notifications);
- }
- catch (e) {
- return _super.prototype.complete.call(this);
- }
- this.retries = retries;
- this.retriesSubscription = subscribeToResult(this, retries);
- };
- return RepeatWhenSubscriber;
- }(OuterSubscriber));
-
- function retry(count) {
- if (count === void 0) { count = -1; }
- return function (source) { return source.lift(new RetryOperator(count, source)); };
- }
- var RetryOperator = (function () {
- function RetryOperator(count, source) {
- this.count = count;
- this.source = source;
- }
- RetryOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
- };
- return RetryOperator;
- }());
- var RetrySubscriber = (function (_super) {
- __extends(RetrySubscriber, _super);
- function RetrySubscriber(destination, count, source) {
- var _this = _super.call(this, destination) || this;
- _this.count = count;
- _this.source = source;
- return _this;
- }
- RetrySubscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- var _a = this, source = _a.source, count = _a.count;
- if (count === 0) {
- return _super.prototype.error.call(this, err);
- }
- else if (count > -1) {
- this.count = count - 1;
- }
- source.subscribe(this._unsubscribeAndRecycle());
- }
- };
- return RetrySubscriber;
- }(Subscriber));
-
- function retryWhen(notifier) {
- return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
- }
- var RetryWhenOperator = (function () {
- function RetryWhenOperator(notifier, source) {
- this.notifier = notifier;
- this.source = source;
- }
- RetryWhenOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
- };
- return RetryWhenOperator;
- }());
- var RetryWhenSubscriber = (function (_super) {
- __extends(RetryWhenSubscriber, _super);
- function RetryWhenSubscriber(destination, notifier, source) {
- var _this = _super.call(this, destination) || this;
- _this.notifier = notifier;
- _this.source = source;
- return _this;
- }
- RetryWhenSubscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- var errors = this.errors;
- var retries = this.retries;
- var retriesSubscription = this.retriesSubscription;
- if (!retries) {
- errors = new Subject();
- try {
- var notifier = this.notifier;
- retries = notifier(errors);
- }
- catch (e) {
- return _super.prototype.error.call(this, e);
- }
- retriesSubscription = subscribeToResult(this, retries);
- }
- else {
- this.errors = null;
- this.retriesSubscription = null;
- }
- this._unsubscribeAndRecycle();
- this.errors = errors;
- this.retries = retries;
- this.retriesSubscription = retriesSubscription;
- errors.next(err);
- }
- };
- RetryWhenSubscriber.prototype._unsubscribe = function () {
- var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
- if (errors) {
- errors.unsubscribe();
- this.errors = null;
- }
- if (retriesSubscription) {
- retriesSubscription.unsubscribe();
- this.retriesSubscription = null;
- }
- this.retries = null;
- };
- RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- var _unsubscribe = this._unsubscribe;
- this._unsubscribe = null;
- this._unsubscribeAndRecycle();
- this._unsubscribe = _unsubscribe;
- this.source.subscribe(this);
- };
- return RetryWhenSubscriber;
- }(OuterSubscriber));
-
- function sample(notifier) {
- return function (source) { return source.lift(new SampleOperator(notifier)); };
- }
- var SampleOperator = (function () {
- function SampleOperator(notifier) {
- this.notifier = notifier;
- }
- SampleOperator.prototype.call = function (subscriber, source) {
- var sampleSubscriber = new SampleSubscriber(subscriber);
- var subscription = source.subscribe(sampleSubscriber);
- subscription.add(subscribeToResult(sampleSubscriber, this.notifier));
- return subscription;
- };
- return SampleOperator;
- }());
- var SampleSubscriber = (function (_super) {
- __extends(SampleSubscriber, _super);
- function SampleSubscriber() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.hasValue = false;
- return _this;
- }
- SampleSubscriber.prototype._next = function (value) {
- this.value = value;
- this.hasValue = true;
- };
- SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.emitValue();
- };
- SampleSubscriber.prototype.notifyComplete = function () {
- this.emitValue();
- };
- SampleSubscriber.prototype.emitValue = function () {
- if (this.hasValue) {
- this.hasValue = false;
- this.destination.next(this.value);
- }
- };
- return SampleSubscriber;
- }(OuterSubscriber));
-
- function sampleTime(period, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
- }
- var SampleTimeOperator = (function () {
- function SampleTimeOperator(period, scheduler) {
- this.period = period;
- this.scheduler = scheduler;
- }
- SampleTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
- };
- return SampleTimeOperator;
- }());
- var SampleTimeSubscriber = (function (_super) {
- __extends(SampleTimeSubscriber, _super);
- function SampleTimeSubscriber(destination, period, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.period = period;
- _this.scheduler = scheduler;
- _this.hasValue = false;
- _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
- return _this;
- }
- SampleTimeSubscriber.prototype._next = function (value) {
- this.lastValue = value;
- this.hasValue = true;
- };
- SampleTimeSubscriber.prototype.notifyNext = function () {
- if (this.hasValue) {
- this.hasValue = false;
- this.destination.next(this.lastValue);
- }
- };
- return SampleTimeSubscriber;
- }(Subscriber));
- function dispatchNotification(state) {
- var subscriber = state.subscriber, period = state.period;
- subscriber.notifyNext();
- this.schedule(state, period);
- }
-
- function sequenceEqual(compareTo, 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++;
- if (!subject || hasError) {
- hasError = false;
- subject = new ReplaySubject(bufferSize, windowTime, scheduler);
- subscription = source.subscribe({
- next: function (value) { subject.next(value); },
- error: function (err) {
- hasError = true;
- subject.error(err);
- },
- complete: function () {
- isComplete = true;
- subject.complete();
- },
- });
- }
- var innerSub = subject.subscribe(this);
- 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 InnerSubscriber(_this, undefined, undefined);
- _this.add(innerSubscriber);
- _this.innerSubscription = innerSubscriber;
- subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
- return _this;
- }
- SkipUntilSubscriber.prototype._next = function (value) {
- if (this.hasValue) {
- _super.prototype._next.call(this, value);
- }
- };
- SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.hasValue = true;
- if (this.innerSubscription) {
- this.innerSubscription.unsubscribe();
- }
- };
- SkipUntilSubscriber.prototype.notifyComplete = function () {
- };
- return SkipUntilSubscriber;
- }(OuterSubscriber));
-
- function skipWhile(predicate) {
- return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
- }
- var SkipWhileOperator = (function () {
- function SkipWhileOperator(predicate) {
- this.predicate = predicate;
- }
- SkipWhileOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
- };
- return SkipWhileOperator;
- }());
- var SkipWhileSubscriber = (function (_super) {
- __extends(SkipWhileSubscriber, _super);
- function SkipWhileSubscriber(destination, predicate) {
- var _this = _super.call(this, destination) || this;
- _this.predicate = predicate;
- _this.skipping = true;
- _this.index = 0;
- return _this;
- }
- SkipWhileSubscriber.prototype._next = function (value) {
- var destination = this.destination;
- if (this.skipping) {
- this.tryCallPredicate(value);
- }
- if (!this.skipping) {
- destination.next(value);
- }
- };
- SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
- try {
- var result = this.predicate(value, this.index++);
- this.skipping = Boolean(result);
- }
- catch (err) {
- this.destination.error(err);
- }
- };
- return SkipWhileSubscriber;
- }(Subscriber));
-
- function startWith() {
- var array = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- array[_i] = arguments[_i];
- }
- 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, value, index);
- };
- SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
- var innerSubscription = this.innerSubscription;
- if (innerSubscription) {
- innerSubscription.unsubscribe();
- }
- var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
- var destination = this.destination;
- destination.add(innerSubscriber);
- this.innerSubscription = subscribeToResult(this, result, value, index, innerSubscriber);
- };
- SwitchMapSubscriber.prototype._complete = function () {
- var innerSubscription = this.innerSubscription;
- if (!innerSubscription || innerSubscription.closed) {
- _super.prototype._complete.call(this);
- }
- this.unsubscribe();
- };
- SwitchMapSubscriber.prototype._unsubscribe = function () {
- this.innerSubscription = null;
- };
- SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
- var destination = this.destination;
- destination.remove(innerSub);
- this.innerSubscription = null;
- if (this.isStopped) {
- _super.prototype._complete.call(this);
- }
- };
- SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(innerValue);
- };
- return SwitchMapSubscriber;
- }(OuterSubscriber));
-
- function switchAll() {
- return switchMap(identity);
- }
-
- function switchMapTo(innerObservable, resultSelector) {
- return resultSelector ? switchMap(function () { return innerObservable; }, resultSelector) : switchMap(function () { return innerObservable; });
- }
-
- function takeUntil(notifier) {
- return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
- }
- var TakeUntilOperator = (function () {
- function TakeUntilOperator(notifier) {
- this.notifier = notifier;
- }
- TakeUntilOperator.prototype.call = function (subscriber, source) {
- var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
- var notifierSubscription = subscribeToResult(takeUntilSubscriber, this.notifier);
- if (notifierSubscription && !takeUntilSubscriber.seenValue) {
- takeUntilSubscriber.add(notifierSubscription);
- return source.subscribe(takeUntilSubscriber);
- }
- return takeUntilSubscriber;
- };
- return TakeUntilOperator;
- }());
- var TakeUntilSubscriber = (function (_super) {
- __extends(TakeUntilSubscriber, _super);
- function TakeUntilSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.seenValue = false;
- return _this;
- }
- TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.seenValue = true;
- this.complete();
- };
- TakeUntilSubscriber.prototype.notifyComplete = function () {
- };
- return TakeUntilSubscriber;
- }(OuterSubscriber));
-
- function takeWhile(predicate, 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 = null;
- };
- ThrottleSubscriber.prototype.throttle = function (value) {
- var duration = this.tryDurationSelector(value);
- if (!!duration) {
- this.add(this._throttled = subscribeToResult(this, duration));
- }
- };
- ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
- try {
- return this.durationSelector(value);
- }
- catch (err) {
- this.destination.error(err);
- return null;
- }
- };
- ThrottleSubscriber.prototype.throttlingDone = function () {
- var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
- if (_throttled) {
- _throttled.unsubscribe();
- }
- this._throttled = null;
- if (_trailing) {
- this.send();
- }
- };
- ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.throttlingDone();
- };
- ThrottleSubscriber.prototype.notifyComplete = function () {
- this.throttlingDone();
- };
- return ThrottleSubscriber;
- }(OuterSubscriber));
-
- function throttleTime(duration, scheduler, config) {
- if (scheduler === void 0) { scheduler = async; }
- if (config === void 0) { config = defaultThrottleConfig; }
- return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
- }
- var ThrottleTimeOperator = (function () {
- function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
- this.duration = duration;
- this.scheduler = scheduler;
- this.leading = leading;
- this.trailing = trailing;
- }
- ThrottleTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
- };
- return ThrottleTimeOperator;
- }());
- var ThrottleTimeSubscriber = (function (_super) {
- __extends(ThrottleTimeSubscriber, _super);
- function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
- var _this = _super.call(this, destination) || this;
- _this.duration = duration;
- _this.scheduler = scheduler;
- _this.leading = leading;
- _this.trailing = trailing;
- _this._hasTrailingValue = false;
- _this._trailingValue = null;
- return _this;
- }
- ThrottleTimeSubscriber.prototype._next = function (value) {
- if (this.throttled) {
- if (this.trailing) {
- this._trailingValue = value;
- this._hasTrailingValue = true;
- }
- }
- else {
- this.add(this.throttled = this.scheduler.schedule(dispatchNext$3, this.duration, { subscriber: this }));
- if (this.leading) {
- this.destination.next(value);
- }
- 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.action = null;
- _this.scheduleTimeout();
- return _this;
- }
- TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
- var withObservable = subscriber.withObservable;
- subscriber._unsubscribeAndRecycle();
- subscriber.add(subscribeToResult(subscriber, withObservable));
- };
- TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
- var action = this.action;
- if (action) {
- this.action = action.schedule(this, this.waitFor);
- }
- else {
- this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
- }
- };
- TimeoutWithSubscriber.prototype._next = function (value) {
- if (!this.absoluteTimeout) {
- this.scheduleTimeout();
- }
- _super.prototype._next.call(this, value);
- };
- TimeoutWithSubscriber.prototype._unsubscribe = function () {
- this.action = null;
- this.scheduler = null;
- this.withObservable = null;
- };
- return TimeoutWithSubscriber;
- }(OuterSubscriber));
-
- function timeout(due, scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return timeoutWith(due, throwError(new TimeoutError()), scheduler);
- }
-
- function timestamp(scheduler) {
- if (scheduler === void 0) { scheduler = async; }
- return map(function (value) { return new Timestamp(value, scheduler.now()); });
- }
- var Timestamp = (function () {
- function Timestamp(value, timestamp) {
- this.value = value;
- this.timestamp = timestamp;
- }
- return Timestamp;
- }());
-
- function toArrayReducer(arr, item, index) {
- if (index === 0) {
- return [item];
- }
- arr.push(item);
- return arr;
- }
- function toArray() {
- return reduce(toArrayReducer, []);
- }
-
- function window$1(windowBoundaries) {
- return function windowOperatorFunction(source) {
- return source.lift(new WindowOperator(windowBoundaries));
- };
- }
- var WindowOperator = (function () {
- function WindowOperator(windowBoundaries) {
- this.windowBoundaries = windowBoundaries;
- }
- WindowOperator.prototype.call = function (subscriber, source) {
- var windowSubscriber = new WindowSubscriber(subscriber);
- var sourceSubscription = source.subscribe(windowSubscriber);
- if (!sourceSubscription.closed) {
- windowSubscriber.add(subscribeToResult(windowSubscriber, this.windowBoundaries));
- }
- return sourceSubscription;
- };
- return WindowOperator;
- }());
- var WindowSubscriber = (function (_super) {
- __extends(WindowSubscriber, _super);
- function WindowSubscriber(destination) {
- var _this = _super.call(this, destination) || this;
- _this.window = new Subject();
- destination.next(_this.window);
- return _this;
- }
- WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.openWindow();
- };
- WindowSubscriber.prototype.notifyError = function (error, innerSub) {
- this._error(error);
- };
- WindowSubscriber.prototype.notifyComplete = function (innerSub) {
- this._complete();
- };
- WindowSubscriber.prototype._next = function (value) {
- this.window.next(value);
- };
- WindowSubscriber.prototype._error = function (err) {
- this.window.error(err);
- this.destination.error(err);
- };
- WindowSubscriber.prototype._complete = function () {
- this.window.complete();
- this.destination.complete();
- };
- WindowSubscriber.prototype._unsubscribe = function () {
- this.window = null;
- };
- WindowSubscriber.prototype.openWindow = function () {
- var prevWindow = this.window;
- if (prevWindow) {
- prevWindow.complete();
- }
- var destination = this.destination;
- var newWindow = this.window = new Subject();
- destination.next(newWindow);
- };
- return WindowSubscriber;
- }(OuterSubscriber));
-
- function windowCount(windowSize, startWindowEvery) {
- if (startWindowEvery === void 0) { startWindowEvery = 0; }
- return function windowCountOperatorFunction(source) {
- return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
- };
- }
- var WindowCountOperator = (function () {
- function WindowCountOperator(windowSize, startWindowEvery) {
- this.windowSize = windowSize;
- this.startWindowEvery = startWindowEvery;
- }
- WindowCountOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
- };
- return WindowCountOperator;
- }());
- var WindowCountSubscriber = (function (_super) {
- __extends(WindowCountSubscriber, _super);
- function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- _this.windowSize = windowSize;
- _this.startWindowEvery = startWindowEvery;
- _this.windows = [new Subject()];
- _this.count = 0;
- destination.next(_this.windows[0]);
- return _this;
- }
- WindowCountSubscriber.prototype._next = function (value) {
- var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
- var destination = this.destination;
- var windowSize = this.windowSize;
- var windows = this.windows;
- var len = windows.length;
- for (var i = 0; i < len && !this.closed; i++) {
- windows[i].next(value);
- }
- var c = this.count - windowSize + 1;
- if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
- windows.shift().complete();
- }
- if (++this.count % startWindowEvery === 0 && !this.closed) {
- var window_1 = new Subject();
- windows.push(window_1);
- destination.next(window_1);
- }
- };
- WindowCountSubscriber.prototype._error = function (err) {
- var windows = this.windows;
- if (windows) {
- while (windows.length > 0 && !this.closed) {
- windows.shift().error(err);
- }
- }
- this.destination.error(err);
- };
- WindowCountSubscriber.prototype._complete = function () {
- var windows = this.windows;
- if (windows) {
- while (windows.length > 0 && !this.closed) {
- windows.shift().complete();
- }
- }
- this.destination.complete();
- };
- WindowCountSubscriber.prototype._unsubscribe = function () {
- this.count = 0;
- this.windows = null;
- };
- return WindowCountSubscriber;
- }(Subscriber));
-
- function windowTime(windowTimeSpan) {
- var scheduler = async;
- var windowCreationInterval = null;
- var maxWindowSize = Number.POSITIVE_INFINITY;
- if (isScheduler(arguments[3])) {
- scheduler = arguments[3];
- }
- if (isScheduler(arguments[2])) {
- scheduler = arguments[2];
- }
- else if (isNumeric(arguments[2])) {
- maxWindowSize = arguments[2];
- }
- if (isScheduler(arguments[1])) {
- scheduler = arguments[1];
- }
- else if (isNumeric(arguments[1])) {
- windowCreationInterval = arguments[1];
- }
- return function windowTimeOperatorFunction(source) {
- return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
- };
- }
- var WindowTimeOperator = (function () {
- function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
- this.windowTimeSpan = windowTimeSpan;
- this.windowCreationInterval = windowCreationInterval;
- this.maxWindowSize = maxWindowSize;
- this.scheduler = scheduler;
- }
- WindowTimeOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
- };
- return WindowTimeOperator;
- }());
- var CountedSubject = (function (_super) {
- __extends(CountedSubject, _super);
- function CountedSubject() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this._numberOfNextedValues = 0;
- return _this;
- }
- CountedSubject.prototype.next = function (value) {
- this._numberOfNextedValues++;
- _super.prototype.next.call(this, value);
- };
- Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
- get: function () {
- return this._numberOfNextedValues;
- },
- enumerable: true,
- configurable: true
- });
- return CountedSubject;
- }(Subject));
- var WindowTimeSubscriber = (function (_super) {
- __extends(WindowTimeSubscriber, _super);
- function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
- var _this = _super.call(this, destination) || this;
- _this.destination = destination;
- _this.windowTimeSpan = windowTimeSpan;
- _this.windowCreationInterval = windowCreationInterval;
- _this.maxWindowSize = maxWindowSize;
- _this.scheduler = scheduler;
- _this.windows = [];
- var window = _this.openWindow();
- if (windowCreationInterval !== null && windowCreationInterval >= 0) {
- var closeState = { subscriber: _this, window: window, context: null };
- var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
- _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
- _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
- }
- else {
- var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
- _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
- }
- return _this;
- }
- WindowTimeSubscriber.prototype._next = function (value) {
- var windows = this.windows;
- var len = windows.length;
- for (var i = 0; i < len; i++) {
- var window_1 = windows[i];
- if (!window_1.closed) {
- window_1.next(value);
- if (window_1.numberOfNextedValues >= this.maxWindowSize) {
- this.closeWindow(window_1);
- }
- }
- }
- };
- WindowTimeSubscriber.prototype._error = function (err) {
- var windows = this.windows;
- while (windows.length > 0) {
- windows.shift().error(err);
- }
- this.destination.error(err);
- };
- WindowTimeSubscriber.prototype._complete = function () {
- var windows = this.windows;
- while (windows.length > 0) {
- var window_2 = windows.shift();
- if (!window_2.closed) {
- window_2.complete();
- }
- }
- this.destination.complete();
- };
- WindowTimeSubscriber.prototype.openWindow = function () {
- var window = new CountedSubject();
- this.windows.push(window);
- var destination = this.destination;
- destination.next(window);
- return window;
- };
- WindowTimeSubscriber.prototype.closeWindow = function (window) {
- window.complete();
- var windows = this.windows;
- windows.splice(windows.indexOf(window), 1);
- };
- return WindowTimeSubscriber;
- }(Subscriber));
- function dispatchWindowTimeSpanOnly(state) {
- var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
- if (window) {
- subscriber.closeWindow(window);
- }
- state.window = subscriber.openWindow();
- this.schedule(state, windowTimeSpan);
- }
- function dispatchWindowCreation(state) {
- var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
- var window = subscriber.openWindow();
- var action = this;
- var context = { action: action, subscription: null };
- var timeSpanState = { subscriber: subscriber, window: window, context: context };
- context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
- action.add(context.subscription);
- action.schedule(state, windowCreationInterval);
- }
- function dispatchWindowClose(state) {
- var subscriber = state.subscriber, window = state.window, context = state.context;
- if (context && context.action && context.subscription) {
- context.action.remove(context.subscription);
- }
- subscriber.closeWindow(window);
- }
-
- function windowToggle(openings, closingSelector) {
- return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
- }
- var WindowToggleOperator = (function () {
- function WindowToggleOperator(openings, closingSelector) {
- this.openings = openings;
- this.closingSelector = closingSelector;
- }
- WindowToggleOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
- };
- return WindowToggleOperator;
- }());
- var WindowToggleSubscriber = (function (_super) {
- __extends(WindowToggleSubscriber, _super);
- function WindowToggleSubscriber(destination, openings, closingSelector) {
- var _this = _super.call(this, destination) || this;
- _this.openings = openings;
- _this.closingSelector = closingSelector;
- _this.contexts = [];
- _this.add(_this.openSubscription = subscribeToResult(_this, openings, openings));
- return _this;
- }
- WindowToggleSubscriber.prototype._next = function (value) {
- var contexts = this.contexts;
- if (contexts) {
- var len = contexts.length;
- for (var i = 0; i < len; i++) {
- contexts[i].window.next(value);
- }
- }
- };
- WindowToggleSubscriber.prototype._error = function (err) {
- var contexts = this.contexts;
- this.contexts = null;
- if (contexts) {
- var len = contexts.length;
- var index = -1;
- while (++index < len) {
- var context_1 = contexts[index];
- context_1.window.error(err);
- context_1.subscription.unsubscribe();
- }
- }
- _super.prototype._error.call(this, err);
- };
- WindowToggleSubscriber.prototype._complete = function () {
- var contexts = this.contexts;
- this.contexts = null;
- if (contexts) {
- var len = contexts.length;
- var index = -1;
- while (++index < len) {
- var context_2 = contexts[index];
- context_2.window.complete();
- context_2.subscription.unsubscribe();
- }
- }
- _super.prototype._complete.call(this);
- };
- WindowToggleSubscriber.prototype._unsubscribe = function () {
- var contexts = this.contexts;
- this.contexts = null;
- if (contexts) {
- var len = contexts.length;
- var index = -1;
- while (++index < len) {
- var context_3 = contexts[index];
- context_3.window.unsubscribe();
- context_3.subscription.unsubscribe();
- }
- }
- };
- WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- if (outerValue === this.openings) {
- var 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, innerSub) {
- this._error(error);
- };
- WindowSubscriber.prototype.notifyComplete = function (innerSub) {
- this.openWindow(innerSub);
- };
- WindowSubscriber.prototype._next = function (value) {
- this.window.next(value);
- };
- WindowSubscriber.prototype._error = function (err) {
- this.window.error(err);
- this.destination.error(err);
- this.unsubscribeClosingNotification();
- };
- WindowSubscriber.prototype._complete = function () {
- this.window.complete();
- this.destination.complete();
- this.unsubscribeClosingNotification();
- };
- WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
- if (this.closingNotification) {
- this.closingNotification.unsubscribe();
- }
- };
- WindowSubscriber.prototype.openWindow = function (innerSub) {
- if (innerSub === void 0) { innerSub = null; }
- if (innerSub) {
- this.remove(innerSub);
- innerSub.unsubscribe();
- }
- var prevWindow = this.window;
- if (prevWindow) {
- prevWindow.complete();
- }
- var window = this.window = new Subject();
- this.destination.next(window);
- var closingNotifier;
- 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, observable, i));
- }
- return _this;
- }
- WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.values[outerIndex] = innerValue;
- var toRespond = this.toRespond;
- if (toRespond.length > 0) {
- var found = toRespond.indexOf(outerIndex);
- if (found !== -1) {
- toRespond.splice(found, 1);
- }
- }
- };
- WithLatestFromSubscriber.prototype.notifyComplete = function () {
- };
- WithLatestFromSubscriber.prototype._next = function (value) {
- if (this.toRespond.length === 0) {
- var args = [value].concat(this.values);
- if (this.project) {
- this._tryProject(args);
- }
- else {
- this.destination.next(args);
- }
- }
- };
- WithLatestFromSubscriber.prototype._tryProject = function (args) {
- var result;
- try {
- result = this.project.apply(this, args);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(result);
- };
- return WithLatestFromSubscriber;
- }(OuterSubscriber));
-
- function zip$1() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i] = arguments[_i];
- }
- return function zipOperatorFunction(source) {
- return source.lift.call(zip.apply(void 0, [source].concat(observables)));
- };
- }
-
- function zipAll(project) {
- return function (source) { return source.lift(new ZipOperator(project)); };
- }
-
-
-
- var _operators = /*#__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: mergeMap,
- 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;
- }());
- function AjaxErrorImpl(message, xhr, request) {
- Error.call(this);
- this.message = message;
- this.name = 'AjaxError';
- this.xhr = xhr;
- this.request = request;
- this.status = xhr.status;
- this.responseType = xhr.responseType || request.responseType;
- this.response = parseXhrResponse(this.responseType, xhr);
- return this;
- }
- AjaxErrorImpl.prototype = Object.create(Error.prototype);
- var AjaxError = AjaxErrorImpl;
- function parseJson(xhr) {
- if ('response' in xhr) {
- return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');
- }
- else {
- return JSON.parse(xhr.responseText || 'null');
- }
- }
- function parseXhrResponse(responseType, xhr) {
- switch (responseType) {
- case 'json':
- return 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 = 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, init) {
- return new Observable(function (subscriber) {
- var controller = new AbortController();
- var signal = controller.signal;
- var outerSignalHandler;
- var abortable = true;
- var unsubscribed = false;
- if (init) {
- if (init.signal) {
- outerSignalHandler = function () {
- if (!signal.aborted) {
- controller.abort();
- }
- };
- init.signal.addEventListener('abort', outerSignalHandler);
- }
- init.signal = signal;
- }
- else {
- init = { signal: signal };
- }
- fetch(input, init).then(function (response) {
- abortable = false;
- subscriber.next(response);
- subscriber.complete();
- }).catch(function (err) {
- abortable = false;
- if (!unsubscribed) {
- subscriber.error(err);
- }
- });
- return function () {
- unsubscribed = true;
- if (abortable) {
- controller.abort();
- }
- };
- });
- }
-
-
-
- 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.asapScheduler = asap;
- exports.asyncScheduler = async;
- exports.queueScheduler = queue;
- exports.animationFrameScheduler = animationFrame;
- exports.VirtualTimeScheduler = VirtualTimeScheduler;
- exports.VirtualAction = VirtualAction;
- exports.Scheduler = Scheduler;
- exports.Subscription = Subscription;
- exports.Subscriber = Subscriber;
- exports.Notification = Notification;
- exports.pipe = pipe;
- exports.noop = noop;
- exports.identity = identity;
- exports.isObservable = isObservable;
- exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
- exports.EmptyError = EmptyError;
- exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
- exports.UnsubscriptionError = UnsubscriptionError;
- exports.TimeoutError = TimeoutError;
- exports.bindCallback = bindCallback;
- exports.bindNodeCallback = bindNodeCallback;
- exports.combineLatest = combineLatest;
- exports.concat = concat;
- exports.defer = defer;
- exports.empty = empty$1;
- exports.forkJoin = forkJoin;
- exports.from = from;
- exports.fromEvent = fromEvent;
- exports.fromEventPattern = fromEventPattern;
- exports.generate = generate;
- exports.iif = iif;
- exports.interval = interval;
- exports.merge = merge;
- exports.never = never;
- exports.of = of;
- exports.onErrorResumeNext = onErrorResumeNext;
- exports.pairs = pairs;
- exports.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
|