test.html 1.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458
  1. <!doctype html><html><head><meta charset="utf-8"></head><body><pre id="__testling_output"></pre><script>(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. (function (process){
  3. var xws = require('xhr-write-stream');
  4. var Stream = require('stream');
  5. var inspect = require('object-inspect');
  6. process.on = function () {};
  7. var ws = xws('/__testling/sock');
  8. ws.write(window.location.hash + '\n');
  9. function createChannel (writeListen) {
  10. var c = new Stream;
  11. c.writable = true;
  12. c.write = function (buf) {
  13. if (writeListen) writeListen(buf);
  14. return ws.write(String(buf));
  15. };
  16. c.destroy = function () {};
  17. c.end = function (buf) {
  18. c.emit('close');
  19. };
  20. return c;
  21. }
  22. var lastTestId = 0;
  23. process.stdout = createChannel(function (buf) {
  24. var m = /^(?:not )? ok (\d+)/.exec(String(buf));
  25. if (m) lastTestId = m[1];
  26. });
  27. process.stderr = createChannel();
  28. process.stdout.on('close', function () { ws.end() });
  29. process.exit = function () { ws.end() };
  30. var oldError = window.onerror;
  31. window.onerror = function (err, url, lineNum) {
  32. var type = err && err.name || 'Error';
  33. process.stdout.write(
  34. 'not ok ' + (lastTestId + 1) + ' ' + type + ': '
  35. + (err && err.message || String(err))
  36. + (lineNum ? ' on line ' + lineNum : '')
  37. + '\n'
  38. );
  39. if (err && err.stack) {
  40. var lines = String(err.stack).split('\n');
  41. var xs = [];
  42. for (var i = 0; i < lines.length; i++) {
  43. xs.push(' ' + lines[i]);
  44. }
  45. process.stdout.write([
  46. ' ---',
  47. ' stack:',
  48. xs.join('\n'),
  49. ' ...'
  50. ].join('\n') + '\n');
  51. }
  52. ws.end();
  53. if (typeof oldError === 'function') {
  54. return oldError.apply(this, arguments);
  55. }
  56. };
  57. window.__testlingErrorHandler = onerror;
  58. if (typeof console === 'undefined') {
  59. console = {};
  60. }
  61. var params = (function () {
  62. var unesc = typeof decodeURIComponent !== 'undefined'
  63. ? decodeURIComponent : unescape
  64. ;
  65. var parts = (window.location.search || '').replace(/^\?/, '').split('&');
  66. var opts = {};
  67. for (var i = 0; i < parts.length; i++) {
  68. var x = parts[i].split('=');
  69. opts[unesc(x[0])] = unesc(x[1]);
  70. }
  71. return opts;
  72. })();
  73. var originalLog = console.log;
  74. console.log = function (msg) {
  75. var index = 1;
  76. var args = arguments;
  77. if (typeof msg === 'string') {
  78. msg = msg.replace(/(^|[^%])%[sd]/g, function (_, s) {
  79. return s + args[index++];
  80. });
  81. }
  82. else msg = inspect(msg);
  83. for (var i = index; i < args.length; i++) {
  84. msg += ' ' + inspect(args[i]);
  85. }
  86. if (params.show === undefined || parseBoolean(params.show)) {
  87. var elem = document.getElementById('__testling_output');
  88. if (elem) {
  89. var txt = document.createTextNode(msg + '\n');
  90. elem.appendChild(txt);
  91. }
  92. }
  93. process.stdout.write(msg + '\n');
  94. if (typeof originalLog === 'function') {
  95. return originalLog.apply(this, arguments);
  96. }
  97. else if (originalLog) return originalLog(arguments[0]);
  98. };
  99. window.__testlingConsole = console;
  100. function parseBoolean (x) {
  101. if (x === 'false' || x === '0') return false;
  102. return true;
  103. }
  104. }).call(this,require("g5I+bs"))
  105. },{"g5I+bs":13,"object-inspect":11,"stream":19,"xhr-write-stream":30}],2:[function(require,module,exports){
  106. ;(function () {
  107. var object = typeof exports != 'undefined' ? exports : this; // #8: web workers
  108. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  109. function InvalidCharacterError(message) {
  110. this.message = message;
  111. }
  112. InvalidCharacterError.prototype = new Error;
  113. InvalidCharacterError.prototype.name = 'InvalidCharacterError';
  114. // encoder
  115. // [https://gist.github.com/999166] by [https://github.com/nignag]
  116. object.btoa || (
  117. object.btoa = function (input) {
  118. for (
  119. // initialize result and counter
  120. var block, charCode, idx = 0, map = chars, output = '';
  121. // if the next input index does not exist:
  122. // change the mapping table to "="
  123. // check if d has no fractional digits
  124. input.charAt(idx | 0) || (map = '=', idx % 1);
  125. // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
  126. output += map.charAt(63 & block >> 8 - idx % 1 * 8)
  127. ) {
  128. charCode = input.charCodeAt(idx += 3/4);
  129. if (charCode > 0xFF) {
  130. throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
  131. }
  132. block = block << 8 | charCode;
  133. }
  134. return output;
  135. });
  136. // decoder
  137. // [https://gist.github.com/1020396] by [https://github.com/atk]
  138. object.atob || (
  139. object.atob = function (input) {
  140. input = input.replace(/=+$/, '');
  141. if (input.length % 4 == 1) {
  142. throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
  143. }
  144. for (
  145. // initialize result and counters
  146. var bc = 0, bs, buffer, idx = 0, output = '';
  147. // get next character
  148. buffer = input.charAt(idx++);
  149. // character found in table? initialize bit storage and add its ascii value;
  150. ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
  151. // and if not first of each 4 characters,
  152. // convert the first 8 bits to one ascii character
  153. bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
  154. ) {
  155. // try to find character in table (0-63, not found => -1)
  156. buffer = chars.indexOf(buffer);
  157. }
  158. return output;
  159. });
  160. }());
  161. },{}],3:[function(require,module,exports){
  162. /*!
  163. * The buffer module from node.js, for the browser.
  164. *
  165. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  166. * @license MIT
  167. */
  168. var base64 = require('base64-js')
  169. var ieee754 = require('ieee754')
  170. exports.Buffer = Buffer
  171. exports.SlowBuffer = Buffer
  172. exports.INSPECT_MAX_BYTES = 50
  173. Buffer.poolSize = 8192
  174. /**
  175. * If `Buffer._useTypedArrays`:
  176. * === true Use Uint8Array implementation (fastest)
  177. * === false Use Object implementation (compatible down to IE6)
  178. */
  179. Buffer._useTypedArrays = (function () {
  180. // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
  181. // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
  182. // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
  183. // because we need to be able to add all the node Buffer API methods. This is an issue
  184. // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
  185. try {
  186. var buf = new ArrayBuffer(0)
  187. var arr = new Uint8Array(buf)
  188. arr.foo = function () { return 42 }
  189. return 42 === arr.foo() &&
  190. typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
  191. } catch (e) {
  192. return false
  193. }
  194. })()
  195. /**
  196. * Class: Buffer
  197. * =============
  198. *
  199. * The Buffer constructor returns instances of `Uint8Array` that are augmented
  200. * with function properties for all the node `Buffer` API functions. We use
  201. * `Uint8Array` so that square bracket notation works as expected -- it returns
  202. * a single octet.
  203. *
  204. * By augmenting the instances, we can avoid modifying the `Uint8Array`
  205. * prototype.
  206. */
  207. function Buffer (subject, encoding, noZero) {
  208. if (!(this instanceof Buffer))
  209. return new Buffer(subject, encoding, noZero)
  210. var type = typeof subject
  211. // Workaround: node's base64 implementation allows for non-padded strings
  212. // while base64-js does not.
  213. if (encoding === 'base64' && type === 'string') {
  214. subject = stringtrim(subject)
  215. while (subject.length % 4 !== 0) {
  216. subject = subject + '='
  217. }
  218. }
  219. // Find the length
  220. var length
  221. if (type === 'number')
  222. length = coerce(subject)
  223. else if (type === 'string')
  224. length = Buffer.byteLength(subject, encoding)
  225. else if (type === 'object')
  226. length = coerce(subject.length) // assume that object is array-like
  227. else
  228. throw new Error('First argument needs to be a number, array or string.')
  229. var buf
  230. if (Buffer._useTypedArrays) {
  231. // Preferred: Return an augmented `Uint8Array` instance for best performance
  232. buf = Buffer._augment(new Uint8Array(length))
  233. } else {
  234. // Fallback: Return THIS instance of Buffer (created by `new`)
  235. buf = this
  236. buf.length = length
  237. buf._isBuffer = true
  238. }
  239. var i
  240. if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
  241. // Speed optimization -- use set if we're copying from a typed array
  242. buf._set(subject)
  243. } else if (isArrayish(subject)) {
  244. // Treat array-ish objects as a byte array
  245. for (i = 0; i < length; i++) {
  246. if (Buffer.isBuffer(subject))
  247. buf[i] = subject.readUInt8(i)
  248. else
  249. buf[i] = subject[i]
  250. }
  251. } else if (type === 'string') {
  252. buf.write(subject, 0, encoding)
  253. } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
  254. for (i = 0; i < length; i++) {
  255. buf[i] = 0
  256. }
  257. }
  258. return buf
  259. }
  260. // STATIC METHODS
  261. // ==============
  262. Buffer.isEncoding = function (encoding) {
  263. switch (String(encoding).toLowerCase()) {
  264. case 'hex':
  265. case 'utf8':
  266. case 'utf-8':
  267. case 'ascii':
  268. case 'binary':
  269. case 'base64':
  270. case 'raw':
  271. case 'ucs2':
  272. case 'ucs-2':
  273. case 'utf16le':
  274. case 'utf-16le':
  275. return true
  276. default:
  277. return false
  278. }
  279. }
  280. Buffer.isBuffer = function (b) {
  281. return !!(b !== null && b !== undefined && b._isBuffer)
  282. }
  283. Buffer.byteLength = function (str, encoding) {
  284. var ret
  285. str = str + ''
  286. switch (encoding || 'utf8') {
  287. case 'hex':
  288. ret = str.length / 2
  289. break
  290. case 'utf8':
  291. case 'utf-8':
  292. ret = utf8ToBytes(str).length
  293. break
  294. case 'ascii':
  295. case 'binary':
  296. case 'raw':
  297. ret = str.length
  298. break
  299. case 'base64':
  300. ret = base64ToBytes(str).length
  301. break
  302. case 'ucs2':
  303. case 'ucs-2':
  304. case 'utf16le':
  305. case 'utf-16le':
  306. ret = str.length * 2
  307. break
  308. default:
  309. throw new Error('Unknown encoding')
  310. }
  311. return ret
  312. }
  313. Buffer.concat = function (list, totalLength) {
  314. assert(isArray(list), 'Usage: Buffer.concat(list, [totalLength])\n' +
  315. 'list should be an Array.')
  316. if (list.length === 0) {
  317. return new Buffer(0)
  318. } else if (list.length === 1) {
  319. return list[0]
  320. }
  321. var i
  322. if (typeof totalLength !== 'number') {
  323. totalLength = 0
  324. for (i = 0; i < list.length; i++) {
  325. totalLength += list[i].length
  326. }
  327. }
  328. var buf = new Buffer(totalLength)
  329. var pos = 0
  330. for (i = 0; i < list.length; i++) {
  331. var item = list[i]
  332. item.copy(buf, pos)
  333. pos += item.length
  334. }
  335. return buf
  336. }
  337. // BUFFER INSTANCE METHODS
  338. // =======================
  339. function _hexWrite (buf, string, offset, length) {
  340. offset = Number(offset) || 0
  341. var remaining = buf.length - offset
  342. if (!length) {
  343. length = remaining
  344. } else {
  345. length = Number(length)
  346. if (length > remaining) {
  347. length = remaining
  348. }
  349. }
  350. // must be an even number of digits
  351. var strLen = string.length
  352. assert(strLen % 2 === 0, 'Invalid hex string')
  353. if (length > strLen / 2) {
  354. length = strLen / 2
  355. }
  356. for (var i = 0; i < length; i++) {
  357. var byte = parseInt(string.substr(i * 2, 2), 16)
  358. assert(!isNaN(byte), 'Invalid hex string')
  359. buf[offset + i] = byte
  360. }
  361. Buffer._charsWritten = i * 2
  362. return i
  363. }
  364. function _utf8Write (buf, string, offset, length) {
  365. var charsWritten = Buffer._charsWritten =
  366. blitBuffer(utf8ToBytes(string), buf, offset, length)
  367. return charsWritten
  368. }
  369. function _asciiWrite (buf, string, offset, length) {
  370. var charsWritten = Buffer._charsWritten =
  371. blitBuffer(asciiToBytes(string), buf, offset, length)
  372. return charsWritten
  373. }
  374. function _binaryWrite (buf, string, offset, length) {
  375. return _asciiWrite(buf, string, offset, length)
  376. }
  377. function _base64Write (buf, string, offset, length) {
  378. var charsWritten = Buffer._charsWritten =
  379. blitBuffer(base64ToBytes(string), buf, offset, length)
  380. return charsWritten
  381. }
  382. function _utf16leWrite (buf, string, offset, length) {
  383. var charsWritten = Buffer._charsWritten =
  384. blitBuffer(utf16leToBytes(string), buf, offset, length)
  385. return charsWritten
  386. }
  387. Buffer.prototype.write = function (string, offset, length, encoding) {
  388. // Support both (string, offset, length, encoding)
  389. // and the legacy (string, encoding, offset, length)
  390. if (isFinite(offset)) {
  391. if (!isFinite(length)) {
  392. encoding = length
  393. length = undefined
  394. }
  395. } else { // legacy
  396. var swap = encoding
  397. encoding = offset
  398. offset = length
  399. length = swap
  400. }
  401. offset = Number(offset) || 0
  402. var remaining = this.length - offset
  403. if (!length) {
  404. length = remaining
  405. } else {
  406. length = Number(length)
  407. if (length > remaining) {
  408. length = remaining
  409. }
  410. }
  411. encoding = String(encoding || 'utf8').toLowerCase()
  412. var ret
  413. switch (encoding) {
  414. case 'hex':
  415. ret = _hexWrite(this, string, offset, length)
  416. break
  417. case 'utf8':
  418. case 'utf-8':
  419. ret = _utf8Write(this, string, offset, length)
  420. break
  421. case 'ascii':
  422. ret = _asciiWrite(this, string, offset, length)
  423. break
  424. case 'binary':
  425. ret = _binaryWrite(this, string, offset, length)
  426. break
  427. case 'base64':
  428. ret = _base64Write(this, string, offset, length)
  429. break
  430. case 'ucs2':
  431. case 'ucs-2':
  432. case 'utf16le':
  433. case 'utf-16le':
  434. ret = _utf16leWrite(this, string, offset, length)
  435. break
  436. default:
  437. throw new Error('Unknown encoding')
  438. }
  439. return ret
  440. }
  441. Buffer.prototype.toString = function (encoding, start, end) {
  442. var self = this
  443. encoding = String(encoding || 'utf8').toLowerCase()
  444. start = Number(start) || 0
  445. end = (end !== undefined)
  446. ? Number(end)
  447. : end = self.length
  448. // Fastpath empty strings
  449. if (end === start)
  450. return ''
  451. var ret
  452. switch (encoding) {
  453. case 'hex':
  454. ret = _hexSlice(self, start, end)
  455. break
  456. case 'utf8':
  457. case 'utf-8':
  458. ret = _utf8Slice(self, start, end)
  459. break
  460. case 'ascii':
  461. ret = _asciiSlice(self, start, end)
  462. break
  463. case 'binary':
  464. ret = _binarySlice(self, start, end)
  465. break
  466. case 'base64':
  467. ret = _base64Slice(self, start, end)
  468. break
  469. case 'ucs2':
  470. case 'ucs-2':
  471. case 'utf16le':
  472. case 'utf-16le':
  473. ret = _utf16leSlice(self, start, end)
  474. break
  475. default:
  476. throw new Error('Unknown encoding')
  477. }
  478. return ret
  479. }
  480. Buffer.prototype.toJSON = function () {
  481. return {
  482. type: 'Buffer',
  483. data: Array.prototype.slice.call(this._arr || this, 0)
  484. }
  485. }
  486. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  487. Buffer.prototype.copy = function (target, target_start, start, end) {
  488. var source = this
  489. if (!start) start = 0
  490. if (!end && end !== 0) end = this.length
  491. if (!target_start) target_start = 0
  492. // Copy 0 bytes; we're done
  493. if (end === start) return
  494. if (target.length === 0 || source.length === 0) return
  495. // Fatal error conditions
  496. assert(end >= start, 'sourceEnd < sourceStart')
  497. assert(target_start >= 0 && target_start < target.length,
  498. 'targetStart out of bounds')
  499. assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
  500. assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
  501. // Are we oob?
  502. if (end > this.length)
  503. end = this.length
  504. if (target.length - target_start < end - start)
  505. end = target.length - target_start + start
  506. var len = end - start
  507. if (len < 100 || !Buffer._useTypedArrays) {
  508. for (var i = 0; i < len; i++)
  509. target[i + target_start] = this[i + start]
  510. } else {
  511. target._set(this.subarray(start, start + len), target_start)
  512. }
  513. }
  514. function _base64Slice (buf, start, end) {
  515. if (start === 0 && end === buf.length) {
  516. return base64.fromByteArray(buf)
  517. } else {
  518. return base64.fromByteArray(buf.slice(start, end))
  519. }
  520. }
  521. function _utf8Slice (buf, start, end) {
  522. var res = ''
  523. var tmp = ''
  524. end = Math.min(buf.length, end)
  525. for (var i = start; i < end; i++) {
  526. if (buf[i] <= 0x7F) {
  527. res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
  528. tmp = ''
  529. } else {
  530. tmp += '%' + buf[i].toString(16)
  531. }
  532. }
  533. return res + decodeUtf8Char(tmp)
  534. }
  535. function _asciiSlice (buf, start, end) {
  536. var ret = ''
  537. end = Math.min(buf.length, end)
  538. for (var i = start; i < end; i++)
  539. ret += String.fromCharCode(buf[i])
  540. return ret
  541. }
  542. function _binarySlice (buf, start, end) {
  543. return _asciiSlice(buf, start, end)
  544. }
  545. function _hexSlice (buf, start, end) {
  546. var len = buf.length
  547. if (!start || start < 0) start = 0
  548. if (!end || end < 0 || end > len) end = len
  549. var out = ''
  550. for (var i = start; i < end; i++) {
  551. out += toHex(buf[i])
  552. }
  553. return out
  554. }
  555. function _utf16leSlice (buf, start, end) {
  556. var bytes = buf.slice(start, end)
  557. var res = ''
  558. for (var i = 0; i < bytes.length; i += 2) {
  559. res += String.fromCharCode(bytes[i] + bytes[i+1] * 256)
  560. }
  561. return res
  562. }
  563. Buffer.prototype.slice = function (start, end) {
  564. var len = this.length
  565. start = clamp(start, len, 0)
  566. end = clamp(end, len, len)
  567. if (Buffer._useTypedArrays) {
  568. return Buffer._augment(this.subarray(start, end))
  569. } else {
  570. var sliceLen = end - start
  571. var newBuf = new Buffer(sliceLen, undefined, true)
  572. for (var i = 0; i < sliceLen; i++) {
  573. newBuf[i] = this[i + start]
  574. }
  575. return newBuf
  576. }
  577. }
  578. // `get` will be removed in Node 0.13+
  579. Buffer.prototype.get = function (offset) {
  580. console.log('.get() is deprecated. Access using array indexes instead.')
  581. return this.readUInt8(offset)
  582. }
  583. // `set` will be removed in Node 0.13+
  584. Buffer.prototype.set = function (v, offset) {
  585. console.log('.set() is deprecated. Access using array indexes instead.')
  586. return this.writeUInt8(v, offset)
  587. }
  588. Buffer.prototype.readUInt8 = function (offset, noAssert) {
  589. if (!noAssert) {
  590. assert(offset !== undefined && offset !== null, 'missing offset')
  591. assert(offset < this.length, 'Trying to read beyond buffer length')
  592. }
  593. if (offset >= this.length)
  594. return
  595. return this[offset]
  596. }
  597. function _readUInt16 (buf, offset, littleEndian, noAssert) {
  598. if (!noAssert) {
  599. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  600. assert(offset !== undefined && offset !== null, 'missing offset')
  601. assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
  602. }
  603. var len = buf.length
  604. if (offset >= len)
  605. return
  606. var val
  607. if (littleEndian) {
  608. val = buf[offset]
  609. if (offset + 1 < len)
  610. val |= buf[offset + 1] << 8
  611. } else {
  612. val = buf[offset] << 8
  613. if (offset + 1 < len)
  614. val |= buf[offset + 1]
  615. }
  616. return val
  617. }
  618. Buffer.prototype.readUInt16LE = function (offset, noAssert) {
  619. return _readUInt16(this, offset, true, noAssert)
  620. }
  621. Buffer.prototype.readUInt16BE = function (offset, noAssert) {
  622. return _readUInt16(this, offset, false, noAssert)
  623. }
  624. function _readUInt32 (buf, offset, littleEndian, noAssert) {
  625. if (!noAssert) {
  626. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  627. assert(offset !== undefined && offset !== null, 'missing offset')
  628. assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
  629. }
  630. var len = buf.length
  631. if (offset >= len)
  632. return
  633. var val
  634. if (littleEndian) {
  635. if (offset + 2 < len)
  636. val = buf[offset + 2] << 16
  637. if (offset + 1 < len)
  638. val |= buf[offset + 1] << 8
  639. val |= buf[offset]
  640. if (offset + 3 < len)
  641. val = val + (buf[offset + 3] << 24 >>> 0)
  642. } else {
  643. if (offset + 1 < len)
  644. val = buf[offset + 1] << 16
  645. if (offset + 2 < len)
  646. val |= buf[offset + 2] << 8
  647. if (offset + 3 < len)
  648. val |= buf[offset + 3]
  649. val = val + (buf[offset] << 24 >>> 0)
  650. }
  651. return val
  652. }
  653. Buffer.prototype.readUInt32LE = function (offset, noAssert) {
  654. return _readUInt32(this, offset, true, noAssert)
  655. }
  656. Buffer.prototype.readUInt32BE = function (offset, noAssert) {
  657. return _readUInt32(this, offset, false, noAssert)
  658. }
  659. Buffer.prototype.readInt8 = function (offset, noAssert) {
  660. if (!noAssert) {
  661. assert(offset !== undefined && offset !== null,
  662. 'missing offset')
  663. assert(offset < this.length, 'Trying to read beyond buffer length')
  664. }
  665. if (offset >= this.length)
  666. return
  667. var neg = this[offset] & 0x80
  668. if (neg)
  669. return (0xff - this[offset] + 1) * -1
  670. else
  671. return this[offset]
  672. }
  673. function _readInt16 (buf, offset, littleEndian, noAssert) {
  674. if (!noAssert) {
  675. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  676. assert(offset !== undefined && offset !== null, 'missing offset')
  677. assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
  678. }
  679. var len = buf.length
  680. if (offset >= len)
  681. return
  682. var val = _readUInt16(buf, offset, littleEndian, true)
  683. var neg = val & 0x8000
  684. if (neg)
  685. return (0xffff - val + 1) * -1
  686. else
  687. return val
  688. }
  689. Buffer.prototype.readInt16LE = function (offset, noAssert) {
  690. return _readInt16(this, offset, true, noAssert)
  691. }
  692. Buffer.prototype.readInt16BE = function (offset, noAssert) {
  693. return _readInt16(this, offset, false, noAssert)
  694. }
  695. function _readInt32 (buf, offset, littleEndian, noAssert) {
  696. if (!noAssert) {
  697. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  698. assert(offset !== undefined && offset !== null, 'missing offset')
  699. assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
  700. }
  701. var len = buf.length
  702. if (offset >= len)
  703. return
  704. var val = _readUInt32(buf, offset, littleEndian, true)
  705. var neg = val & 0x80000000
  706. if (neg)
  707. return (0xffffffff - val + 1) * -1
  708. else
  709. return val
  710. }
  711. Buffer.prototype.readInt32LE = function (offset, noAssert) {
  712. return _readInt32(this, offset, true, noAssert)
  713. }
  714. Buffer.prototype.readInt32BE = function (offset, noAssert) {
  715. return _readInt32(this, offset, false, noAssert)
  716. }
  717. function _readFloat (buf, offset, littleEndian, noAssert) {
  718. if (!noAssert) {
  719. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  720. assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
  721. }
  722. return ieee754.read(buf, offset, littleEndian, 23, 4)
  723. }
  724. Buffer.prototype.readFloatLE = function (offset, noAssert) {
  725. return _readFloat(this, offset, true, noAssert)
  726. }
  727. Buffer.prototype.readFloatBE = function (offset, noAssert) {
  728. return _readFloat(this, offset, false, noAssert)
  729. }
  730. function _readDouble (buf, offset, littleEndian, noAssert) {
  731. if (!noAssert) {
  732. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  733. assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
  734. }
  735. return ieee754.read(buf, offset, littleEndian, 52, 8)
  736. }
  737. Buffer.prototype.readDoubleLE = function (offset, noAssert) {
  738. return _readDouble(this, offset, true, noAssert)
  739. }
  740. Buffer.prototype.readDoubleBE = function (offset, noAssert) {
  741. return _readDouble(this, offset, false, noAssert)
  742. }
  743. Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
  744. if (!noAssert) {
  745. assert(value !== undefined && value !== null, 'missing value')
  746. assert(offset !== undefined && offset !== null, 'missing offset')
  747. assert(offset < this.length, 'trying to write beyond buffer length')
  748. verifuint(value, 0xff)
  749. }
  750. if (offset >= this.length) return
  751. this[offset] = value
  752. }
  753. function _writeUInt16 (buf, value, offset, littleEndian, noAssert) {
  754. if (!noAssert) {
  755. assert(value !== undefined && value !== null, 'missing value')
  756. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  757. assert(offset !== undefined && offset !== null, 'missing offset')
  758. assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
  759. verifuint(value, 0xffff)
  760. }
  761. var len = buf.length
  762. if (offset >= len)
  763. return
  764. for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
  765. buf[offset + i] =
  766. (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  767. (littleEndian ? i : 1 - i) * 8
  768. }
  769. }
  770. Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
  771. _writeUInt16(this, value, offset, true, noAssert)
  772. }
  773. Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
  774. _writeUInt16(this, value, offset, false, noAssert)
  775. }
  776. function _writeUInt32 (buf, value, offset, littleEndian, noAssert) {
  777. if (!noAssert) {
  778. assert(value !== undefined && value !== null, 'missing value')
  779. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  780. assert(offset !== undefined && offset !== null, 'missing offset')
  781. assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
  782. verifuint(value, 0xffffffff)
  783. }
  784. var len = buf.length
  785. if (offset >= len)
  786. return
  787. for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
  788. buf[offset + i] =
  789. (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  790. }
  791. }
  792. Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
  793. _writeUInt32(this, value, offset, true, noAssert)
  794. }
  795. Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
  796. _writeUInt32(this, value, offset, false, noAssert)
  797. }
  798. Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
  799. if (!noAssert) {
  800. assert(value !== undefined && value !== null, 'missing value')
  801. assert(offset !== undefined && offset !== null, 'missing offset')
  802. assert(offset < this.length, 'Trying to write beyond buffer length')
  803. verifsint(value, 0x7f, -0x80)
  804. }
  805. if (offset >= this.length)
  806. return
  807. if (value >= 0)
  808. this.writeUInt8(value, offset, noAssert)
  809. else
  810. this.writeUInt8(0xff + value + 1, offset, noAssert)
  811. }
  812. function _writeInt16 (buf, value, offset, littleEndian, noAssert) {
  813. if (!noAssert) {
  814. assert(value !== undefined && value !== null, 'missing value')
  815. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  816. assert(offset !== undefined && offset !== null, 'missing offset')
  817. assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
  818. verifsint(value, 0x7fff, -0x8000)
  819. }
  820. var len = buf.length
  821. if (offset >= len)
  822. return
  823. if (value >= 0)
  824. _writeUInt16(buf, value, offset, littleEndian, noAssert)
  825. else
  826. _writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
  827. }
  828. Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
  829. _writeInt16(this, value, offset, true, noAssert)
  830. }
  831. Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
  832. _writeInt16(this, value, offset, false, noAssert)
  833. }
  834. function _writeInt32 (buf, value, offset, littleEndian, noAssert) {
  835. if (!noAssert) {
  836. assert(value !== undefined && value !== null, 'missing value')
  837. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  838. assert(offset !== undefined && offset !== null, 'missing offset')
  839. assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
  840. verifsint(value, 0x7fffffff, -0x80000000)
  841. }
  842. var len = buf.length
  843. if (offset >= len)
  844. return
  845. if (value >= 0)
  846. _writeUInt32(buf, value, offset, littleEndian, noAssert)
  847. else
  848. _writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
  849. }
  850. Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
  851. _writeInt32(this, value, offset, true, noAssert)
  852. }
  853. Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
  854. _writeInt32(this, value, offset, false, noAssert)
  855. }
  856. function _writeFloat (buf, value, offset, littleEndian, noAssert) {
  857. if (!noAssert) {
  858. assert(value !== undefined && value !== null, 'missing value')
  859. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  860. assert(offset !== undefined && offset !== null, 'missing offset')
  861. assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
  862. verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
  863. }
  864. var len = buf.length
  865. if (offset >= len)
  866. return
  867. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  868. }
  869. Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
  870. _writeFloat(this, value, offset, true, noAssert)
  871. }
  872. Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
  873. _writeFloat(this, value, offset, false, noAssert)
  874. }
  875. function _writeDouble (buf, value, offset, littleEndian, noAssert) {
  876. if (!noAssert) {
  877. assert(value !== undefined && value !== null, 'missing value')
  878. assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
  879. assert(offset !== undefined && offset !== null, 'missing offset')
  880. assert(offset + 7 < buf.length,
  881. 'Trying to write beyond buffer length')
  882. verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
  883. }
  884. var len = buf.length
  885. if (offset >= len)
  886. return
  887. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  888. }
  889. Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
  890. _writeDouble(this, value, offset, true, noAssert)
  891. }
  892. Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
  893. _writeDouble(this, value, offset, false, noAssert)
  894. }
  895. // fill(value, start=0, end=buffer.length)
  896. Buffer.prototype.fill = function (value, start, end) {
  897. if (!value) value = 0
  898. if (!start) start = 0
  899. if (!end) end = this.length
  900. if (typeof value === 'string') {
  901. value = value.charCodeAt(0)
  902. }
  903. assert(typeof value === 'number' && !isNaN(value), 'value is not a number')
  904. assert(end >= start, 'end < start')
  905. // Fill 0 bytes; we're done
  906. if (end === start) return
  907. if (this.length === 0) return
  908. assert(start >= 0 && start < this.length, 'start out of bounds')
  909. assert(end >= 0 && end <= this.length, 'end out of bounds')
  910. for (var i = start; i < end; i++) {
  911. this[i] = value
  912. }
  913. }
  914. Buffer.prototype.inspect = function () {
  915. var out = []
  916. var len = this.length
  917. for (var i = 0; i < len; i++) {
  918. out[i] = toHex(this[i])
  919. if (i === exports.INSPECT_MAX_BYTES) {
  920. out[i + 1] = '...'
  921. break
  922. }
  923. }
  924. return '<Buffer ' + out.join(' ') + '>'
  925. }
  926. /**
  927. * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
  928. * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
  929. */
  930. Buffer.prototype.toArrayBuffer = function () {
  931. if (typeof Uint8Array !== 'undefined') {
  932. if (Buffer._useTypedArrays) {
  933. return (new Buffer(this)).buffer
  934. } else {
  935. var buf = new Uint8Array(this.length)
  936. for (var i = 0, len = buf.length; i < len; i += 1)
  937. buf[i] = this[i]
  938. return buf.buffer
  939. }
  940. } else {
  941. throw new Error('Buffer.toArrayBuffer not supported in this browser')
  942. }
  943. }
  944. // HELPER FUNCTIONS
  945. // ================
  946. function stringtrim (str) {
  947. if (str.trim) return str.trim()
  948. return str.replace(/^\s+|\s+$/g, '')
  949. }
  950. var BP = Buffer.prototype
  951. /**
  952. * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
  953. */
  954. Buffer._augment = function (arr) {
  955. arr._isBuffer = true
  956. // save reference to original Uint8Array get/set methods before overwriting
  957. arr._get = arr.get
  958. arr._set = arr.set
  959. // deprecated, will be removed in node 0.13+
  960. arr.get = BP.get
  961. arr.set = BP.set
  962. arr.write = BP.write
  963. arr.toString = BP.toString
  964. arr.toLocaleString = BP.toString
  965. arr.toJSON = BP.toJSON
  966. arr.copy = BP.copy
  967. arr.slice = BP.slice
  968. arr.readUInt8 = BP.readUInt8
  969. arr.readUInt16LE = BP.readUInt16LE
  970. arr.readUInt16BE = BP.readUInt16BE
  971. arr.readUInt32LE = BP.readUInt32LE
  972. arr.readUInt32BE = BP.readUInt32BE
  973. arr.readInt8 = BP.readInt8
  974. arr.readInt16LE = BP.readInt16LE
  975. arr.readInt16BE = BP.readInt16BE
  976. arr.readInt32LE = BP.readInt32LE
  977. arr.readInt32BE = BP.readInt32BE
  978. arr.readFloatLE = BP.readFloatLE
  979. arr.readFloatBE = BP.readFloatBE
  980. arr.readDoubleLE = BP.readDoubleLE
  981. arr.readDoubleBE = BP.readDoubleBE
  982. arr.writeUInt8 = BP.writeUInt8
  983. arr.writeUInt16LE = BP.writeUInt16LE
  984. arr.writeUInt16BE = BP.writeUInt16BE
  985. arr.writeUInt32LE = BP.writeUInt32LE
  986. arr.writeUInt32BE = BP.writeUInt32BE
  987. arr.writeInt8 = BP.writeInt8
  988. arr.writeInt16LE = BP.writeInt16LE
  989. arr.writeInt16BE = BP.writeInt16BE
  990. arr.writeInt32LE = BP.writeInt32LE
  991. arr.writeInt32BE = BP.writeInt32BE
  992. arr.writeFloatLE = BP.writeFloatLE
  993. arr.writeFloatBE = BP.writeFloatBE
  994. arr.writeDoubleLE = BP.writeDoubleLE
  995. arr.writeDoubleBE = BP.writeDoubleBE
  996. arr.fill = BP.fill
  997. arr.inspect = BP.inspect
  998. arr.toArrayBuffer = BP.toArrayBuffer
  999. return arr
  1000. }
  1001. // slice(start, end)
  1002. function clamp (index, len, defaultValue) {
  1003. if (typeof index !== 'number') return defaultValue
  1004. index = ~~index; // Coerce to integer.
  1005. if (index >= len) return len
  1006. if (index >= 0) return index
  1007. index += len
  1008. if (index >= 0) return index
  1009. return 0
  1010. }
  1011. function coerce (length) {
  1012. // Coerce length to a number (possibly NaN), round up
  1013. // in case it's fractional (e.g. 123.456) then do a
  1014. // double negate to coerce a NaN to 0. Easy, right?
  1015. length = ~~Math.ceil(+length)
  1016. return length < 0 ? 0 : length
  1017. }
  1018. function isArray (subject) {
  1019. return (Array.isArray || function (subject) {
  1020. return Object.prototype.toString.call(subject) === '[object Array]'
  1021. })(subject)
  1022. }
  1023. function isArrayish (subject) {
  1024. return isArray(subject) || Buffer.isBuffer(subject) ||
  1025. subject && typeof subject === 'object' &&
  1026. typeof subject.length === 'number'
  1027. }
  1028. function toHex (n) {
  1029. if (n < 16) return '0' + n.toString(16)
  1030. return n.toString(16)
  1031. }
  1032. function utf8ToBytes (str) {
  1033. var byteArray = []
  1034. for (var i = 0; i < str.length; i++) {
  1035. var b = str.charCodeAt(i)
  1036. if (b <= 0x7F)
  1037. byteArray.push(str.charCodeAt(i))
  1038. else {
  1039. var start = i
  1040. if (b >= 0xD800 && b <= 0xDFFF) i++
  1041. var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
  1042. for (var j = 0; j < h.length; j++)
  1043. byteArray.push(parseInt(h[j], 16))
  1044. }
  1045. }
  1046. return byteArray
  1047. }
  1048. function asciiToBytes (str) {
  1049. var byteArray = []
  1050. for (var i = 0; i < str.length; i++) {
  1051. // Node's code seems to be doing this and not & 0x7F..
  1052. byteArray.push(str.charCodeAt(i) & 0xFF)
  1053. }
  1054. return byteArray
  1055. }
  1056. function utf16leToBytes (str) {
  1057. var c, hi, lo
  1058. var byteArray = []
  1059. for (var i = 0; i < str.length; i++) {
  1060. c = str.charCodeAt(i)
  1061. hi = c >> 8
  1062. lo = c % 256
  1063. byteArray.push(lo)
  1064. byteArray.push(hi)
  1065. }
  1066. return byteArray
  1067. }
  1068. function base64ToBytes (str) {
  1069. return base64.toByteArray(str)
  1070. }
  1071. function blitBuffer (src, dst, offset, length) {
  1072. var pos
  1073. for (var i = 0; i < length; i++) {
  1074. if ((i + offset >= dst.length) || (i >= src.length))
  1075. break
  1076. dst[i + offset] = src[i]
  1077. }
  1078. return i
  1079. }
  1080. function decodeUtf8Char (str) {
  1081. try {
  1082. return decodeURIComponent(str)
  1083. } catch (err) {
  1084. return String.fromCharCode(0xFFFD) // UTF 8 invalid char
  1085. }
  1086. }
  1087. /*
  1088. * We have to make sure that the value is a valid integer. This means that it
  1089. * is non-negative. It has no fractional component and that it does not
  1090. * exceed the maximum allowed value.
  1091. */
  1092. function verifuint (value, max) {
  1093. assert(typeof value === 'number', 'cannot write a non-number as a number')
  1094. assert(value >= 0, 'specified a negative value for writing an unsigned value')
  1095. assert(value <= max, 'value is larger than maximum value for type')
  1096. assert(Math.floor(value) === value, 'value has a fractional component')
  1097. }
  1098. function verifsint (value, max, min) {
  1099. assert(typeof value === 'number', 'cannot write a non-number as a number')
  1100. assert(value <= max, 'value larger than maximum allowed value')
  1101. assert(value >= min, 'value smaller than minimum allowed value')
  1102. assert(Math.floor(value) === value, 'value has a fractional component')
  1103. }
  1104. function verifIEEE754 (value, max, min) {
  1105. assert(typeof value === 'number', 'cannot write a non-number as a number')
  1106. assert(value <= max, 'value larger than maximum allowed value')
  1107. assert(value >= min, 'value smaller than minimum allowed value')
  1108. }
  1109. function assert (test, message) {
  1110. if (!test) throw new Error(message || 'Failed assertion')
  1111. }
  1112. },{"base64-js":4,"ieee754":9}],4:[function(require,module,exports){
  1113. var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  1114. ;(function (exports) {
  1115. 'use strict';
  1116. var Arr = (typeof Uint8Array !== 'undefined')
  1117. ? Uint8Array
  1118. : Array
  1119. var PLUS = '+'.charCodeAt(0)
  1120. var SLASH = '/'.charCodeAt(0)
  1121. var NUMBER = '0'.charCodeAt(0)
  1122. var LOWER = 'a'.charCodeAt(0)
  1123. var UPPER = 'A'.charCodeAt(0)
  1124. var PLUS_URL_SAFE = '-'.charCodeAt(0)
  1125. var SLASH_URL_SAFE = '_'.charCodeAt(0)
  1126. function decode (elt) {
  1127. var code = elt.charCodeAt(0)
  1128. if (code === PLUS ||
  1129. code === PLUS_URL_SAFE)
  1130. return 62 // '+'
  1131. if (code === SLASH ||
  1132. code === SLASH_URL_SAFE)
  1133. return 63 // '/'
  1134. if (code < NUMBER)
  1135. return -1 //no match
  1136. if (code < NUMBER + 10)
  1137. return code - NUMBER + 26 + 26
  1138. if (code < UPPER + 26)
  1139. return code - UPPER
  1140. if (code < LOWER + 26)
  1141. return code - LOWER + 26
  1142. }
  1143. function b64ToByteArray (b64) {
  1144. var i, j, l, tmp, placeHolders, arr
  1145. if (b64.length % 4 > 0) {
  1146. throw new Error('Invalid string. Length must be a multiple of 4')
  1147. }
  1148. // the number of equal signs (place holders)
  1149. // if there are two placeholders, than the two characters before it
  1150. // represent one byte
  1151. // if there is only one, then the three characters before it represent 2 bytes
  1152. // this is just a cheap hack to not do indexOf twice
  1153. var len = b64.length
  1154. placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
  1155. // base64 is 4/3 + up to two characters of the original data
  1156. arr = new Arr(b64.length * 3 / 4 - placeHolders)
  1157. // if there are placeholders, only get up to the last complete 4 chars
  1158. l = placeHolders > 0 ? b64.length - 4 : b64.length
  1159. var L = 0
  1160. function push (v) {
  1161. arr[L++] = v
  1162. }
  1163. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  1164. tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
  1165. push((tmp & 0xFF0000) >> 16)
  1166. push((tmp & 0xFF00) >> 8)
  1167. push(tmp & 0xFF)
  1168. }
  1169. if (placeHolders === 2) {
  1170. tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
  1171. push(tmp & 0xFF)
  1172. } else if (placeHolders === 1) {
  1173. tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
  1174. push((tmp >> 8) & 0xFF)
  1175. push(tmp & 0xFF)
  1176. }
  1177. return arr
  1178. }
  1179. function uint8ToBase64 (uint8) {
  1180. var i,
  1181. extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
  1182. output = "",
  1183. temp, length
  1184. function encode (num) {
  1185. return lookup.charAt(num)
  1186. }
  1187. function tripletToBase64 (num) {
  1188. return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
  1189. }
  1190. // go through the array every three bytes, we'll deal with trailing stuff later
  1191. for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
  1192. temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  1193. output += tripletToBase64(temp)
  1194. }
  1195. // pad the end with zeros, but make sure to not forget the extra bytes
  1196. switch (extraBytes) {
  1197. case 1:
  1198. temp = uint8[uint8.length - 1]
  1199. output += encode(temp >> 2)
  1200. output += encode((temp << 4) & 0x3F)
  1201. output += '=='
  1202. break
  1203. case 2:
  1204. temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
  1205. output += encode(temp >> 10)
  1206. output += encode((temp >> 4) & 0x3F)
  1207. output += encode((temp << 2) & 0x3F)
  1208. output += '='
  1209. break
  1210. }
  1211. return output
  1212. }
  1213. exports.toByteArray = b64ToByteArray
  1214. exports.fromByteArray = uint8ToBase64
  1215. }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
  1216. },{}],5:[function(require,module,exports){
  1217. // Copyright Joyent, Inc. and other Node contributors.
  1218. //
  1219. // Permission is hereby granted, free of charge, to any person obtaining a
  1220. // copy of this software and associated documentation files (the
  1221. // "Software"), to deal in the Software without restriction, including
  1222. // without limitation the rights to use, copy, modify, merge, publish,
  1223. // distribute, sublicense, and/or sell copies of the Software, and to permit
  1224. // persons to whom the Software is furnished to do so, subject to the
  1225. // following conditions:
  1226. //
  1227. // The above copyright notice and this permission notice shall be included
  1228. // in all copies or substantial portions of the Software.
  1229. //
  1230. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  1231. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1232. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  1233. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  1234. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  1235. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  1236. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  1237. function EventEmitter() {
  1238. this._events = this._events || {};
  1239. this._maxListeners = this._maxListeners || undefined;
  1240. }
  1241. module.exports = EventEmitter;
  1242. // Backwards-compat with node 0.10.x
  1243. EventEmitter.EventEmitter = EventEmitter;
  1244. EventEmitter.prototype._events = undefined;
  1245. EventEmitter.prototype._maxListeners = undefined;
  1246. // By default EventEmitters will print a warning if more than 10 listeners are
  1247. // added to it. This is a useful default which helps finding memory leaks.
  1248. EventEmitter.defaultMaxListeners = 10;
  1249. // Obviously not all Emitters should be limited to 10. This function allows
  1250. // that to be increased. Set to zero for unlimited.
  1251. EventEmitter.prototype.setMaxListeners = function(n) {
  1252. if (!isNumber(n) || n < 0 || isNaN(n))
  1253. throw TypeError('n must be a positive number');
  1254. this._maxListeners = n;
  1255. return this;
  1256. };
  1257. EventEmitter.prototype.emit = function(type) {
  1258. var er, handler, len, args, i, listeners;
  1259. if (!this._events)
  1260. this._events = {};
  1261. // If there is no 'error' event listener then throw.
  1262. if (type === 'error') {
  1263. if (!this._events.error ||
  1264. (isObject(this._events.error) && !this._events.error.length)) {
  1265. er = arguments[1];
  1266. if (er instanceof Error) {
  1267. throw er; // Unhandled 'error' event
  1268. }
  1269. throw TypeError('Uncaught, unspecified "error" event.');
  1270. }
  1271. }
  1272. handler = this._events[type];
  1273. if (isUndefined(handler))
  1274. return false;
  1275. if (isFunction(handler)) {
  1276. switch (arguments.length) {
  1277. // fast cases
  1278. case 1:
  1279. handler.call(this);
  1280. break;
  1281. case 2:
  1282. handler.call(this, arguments[1]);
  1283. break;
  1284. case 3:
  1285. handler.call(this, arguments[1], arguments[2]);
  1286. break;
  1287. // slower
  1288. default:
  1289. len = arguments.length;
  1290. args = new Array(len - 1);
  1291. for (i = 1; i < len; i++)
  1292. args[i - 1] = arguments[i];
  1293. handler.apply(this, args);
  1294. }
  1295. } else if (isObject(handler)) {
  1296. len = arguments.length;
  1297. args = new Array(len - 1);
  1298. for (i = 1; i < len; i++)
  1299. args[i - 1] = arguments[i];
  1300. listeners = handler.slice();
  1301. len = listeners.length;
  1302. for (i = 0; i < len; i++)
  1303. listeners[i].apply(this, args);
  1304. }
  1305. return true;
  1306. };
  1307. EventEmitter.prototype.addListener = function(type, listener) {
  1308. var m;
  1309. if (!isFunction(listener))
  1310. throw TypeError('listener must be a function');
  1311. if (!this._events)
  1312. this._events = {};
  1313. // To avoid recursion in the case that type === "newListener"! Before
  1314. // adding it to the listeners, first emit "newListener".
  1315. if (this._events.newListener)
  1316. this.emit('newListener', type,
  1317. isFunction(listener.listener) ?
  1318. listener.listener : listener);
  1319. if (!this._events[type])
  1320. // Optimize the case of one listener. Don't need the extra array object.
  1321. this._events[type] = listener;
  1322. else if (isObject(this._events[type]))
  1323. // If we've already got an array, just append.
  1324. this._events[type].push(listener);
  1325. else
  1326. // Adding the second element, need to change to array.
  1327. this._events[type] = [this._events[type], listener];
  1328. // Check for listener leak
  1329. if (isObject(this._events[type]) && !this._events[type].warned) {
  1330. var m;
  1331. if (!isUndefined(this._maxListeners)) {
  1332. m = this._maxListeners;
  1333. } else {
  1334. m = EventEmitter.defaultMaxListeners;
  1335. }
  1336. if (m && m > 0 && this._events[type].length > m) {
  1337. this._events[type].warned = true;
  1338. console.error('(node) warning: possible EventEmitter memory ' +
  1339. 'leak detected. %d listeners added. ' +
  1340. 'Use emitter.setMaxListeners() to increase limit.',
  1341. this._events[type].length);
  1342. if (typeof console.trace === 'function') {
  1343. // not supported in IE 10
  1344. console.trace();
  1345. }
  1346. }
  1347. }
  1348. return this;
  1349. };
  1350. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  1351. EventEmitter.prototype.once = function(type, listener) {
  1352. if (!isFunction(listener))
  1353. throw TypeError('listener must be a function');
  1354. var fired = false;
  1355. function g() {
  1356. this.removeListener(type, g);
  1357. if (!fired) {
  1358. fired = true;
  1359. listener.apply(this, arguments);
  1360. }
  1361. }
  1362. g.listener = listener;
  1363. this.on(type, g);
  1364. return this;
  1365. };
  1366. // emits a 'removeListener' event iff the listener was removed
  1367. EventEmitter.prototype.removeListener = function(type, listener) {
  1368. var list, position, length, i;
  1369. if (!isFunction(listener))
  1370. throw TypeError('listener must be a function');
  1371. if (!this._events || !this._events[type])
  1372. return this;
  1373. list = this._events[type];
  1374. length = list.length;
  1375. position = -1;
  1376. if (list === listener ||
  1377. (isFunction(list.listener) && list.listener === listener)) {
  1378. delete this._events[type];
  1379. if (this._events.removeListener)
  1380. this.emit('removeListener', type, listener);
  1381. } else if (isObject(list)) {
  1382. for (i = length; i-- > 0;) {
  1383. if (list[i] === listener ||
  1384. (list[i].listener && list[i].listener === listener)) {
  1385. position = i;
  1386. break;
  1387. }
  1388. }
  1389. if (position < 0)
  1390. return this;
  1391. if (list.length === 1) {
  1392. list.length = 0;
  1393. delete this._events[type];
  1394. } else {
  1395. list.splice(position, 1);
  1396. }
  1397. if (this._events.removeListener)
  1398. this.emit('removeListener', type, listener);
  1399. }
  1400. return this;
  1401. };
  1402. EventEmitter.prototype.removeAllListeners = function(type) {
  1403. var key, listeners;
  1404. if (!this._events)
  1405. return this;
  1406. // not listening for removeListener, no need to emit
  1407. if (!this._events.removeListener) {
  1408. if (arguments.length === 0)
  1409. this._events = {};
  1410. else if (this._events[type])
  1411. delete this._events[type];
  1412. return this;
  1413. }
  1414. // emit removeListener for all listeners on all events
  1415. if (arguments.length === 0) {
  1416. for (key in this._events) {
  1417. if (key === 'removeListener') continue;
  1418. this.removeAllListeners(key);
  1419. }
  1420. this.removeAllListeners('removeListener');
  1421. this._events = {};
  1422. return this;
  1423. }
  1424. listeners = this._events[type];
  1425. if (isFunction(listeners)) {
  1426. this.removeListener(type, listeners);
  1427. } else {
  1428. // LIFO order
  1429. while (listeners.length)
  1430. this.removeListener(type, listeners[listeners.length - 1]);
  1431. }
  1432. delete this._events[type];
  1433. return this;
  1434. };
  1435. EventEmitter.prototype.listeners = function(type) {
  1436. var ret;
  1437. if (!this._events || !this._events[type])
  1438. ret = [];
  1439. else if (isFunction(this._events[type]))
  1440. ret = [this._events[type]];
  1441. else
  1442. ret = this._events[type].slice();
  1443. return ret;
  1444. };
  1445. EventEmitter.listenerCount = function(emitter, type) {
  1446. var ret;
  1447. if (!emitter._events || !emitter._events[type])
  1448. ret = 0;
  1449. else if (isFunction(emitter._events[type]))
  1450. ret = 1;
  1451. else
  1452. ret = emitter._events[type].length;
  1453. return ret;
  1454. };
  1455. function isFunction(arg) {
  1456. return typeof arg === 'function';
  1457. }
  1458. function isNumber(arg) {
  1459. return typeof arg === 'number';
  1460. }
  1461. function isObject(arg) {
  1462. return typeof arg === 'object' && arg !== null;
  1463. }
  1464. function isUndefined(arg) {
  1465. return arg === void 0;
  1466. }
  1467. },{}],6:[function(require,module,exports){
  1468. var http = module.exports;
  1469. var EventEmitter = require('events').EventEmitter;
  1470. var Request = require('./lib/request');
  1471. var url = require('url')
  1472. http.request = function (params, cb) {
  1473. if (typeof params === 'string') {
  1474. params = url.parse(params)
  1475. }
  1476. if (!params) params = {};
  1477. if (!params.host && !params.port) {
  1478. params.port = parseInt(window.location.port, 10);
  1479. }
  1480. if (!params.host && params.hostname) {
  1481. params.host = params.hostname;
  1482. }
  1483. if (!params.scheme) params.scheme = window.location.protocol.split(':')[0];
  1484. if (!params.host) {
  1485. params.host = window.location.hostname || window.location.host;
  1486. }
  1487. if (/:/.test(params.host)) {
  1488. if (!params.port) {
  1489. params.port = params.host.split(':')[1];
  1490. }
  1491. params.host = params.host.split(':')[0];
  1492. }
  1493. if (!params.port) params.port = params.scheme == 'https' ? 443 : 80;
  1494. var req = new Request(new xhrHttp, params);
  1495. if (cb) req.on('response', cb);
  1496. return req;
  1497. };
  1498. http.get = function (params, cb) {
  1499. params.method = 'GET';
  1500. var req = http.request(params, cb);
  1501. req.end();
  1502. return req;
  1503. };
  1504. http.Agent = function () {};
  1505. http.Agent.defaultMaxSockets = 4;
  1506. var xhrHttp = (function () {
  1507. if (typeof window === 'undefined') {
  1508. throw new Error('no window object present');
  1509. }
  1510. else if (window.XMLHttpRequest) {
  1511. return window.XMLHttpRequest;
  1512. }
  1513. else if (window.ActiveXObject) {
  1514. var axs = [
  1515. 'Msxml2.XMLHTTP.6.0',
  1516. 'Msxml2.XMLHTTP.3.0',
  1517. 'Microsoft.XMLHTTP'
  1518. ];
  1519. for (var i = 0; i < axs.length; i++) {
  1520. try {
  1521. var ax = new(window.ActiveXObject)(axs[i]);
  1522. return function () {
  1523. if (ax) {
  1524. var ax_ = ax;
  1525. ax = null;
  1526. return ax_;
  1527. }
  1528. else {
  1529. return new(window.ActiveXObject)(axs[i]);
  1530. }
  1531. };
  1532. }
  1533. catch (e) {}
  1534. }
  1535. throw new Error('ajax not supported in this browser')
  1536. }
  1537. else {
  1538. throw new Error('ajax not supported in this browser');
  1539. }
  1540. })();
  1541. http.STATUS_CODES = {
  1542. 100 : 'Continue',
  1543. 101 : 'Switching Protocols',
  1544. 102 : 'Processing', // RFC 2518, obsoleted by RFC 4918
  1545. 200 : 'OK',
  1546. 201 : 'Created',
  1547. 202 : 'Accepted',
  1548. 203 : 'Non-Authoritative Information',
  1549. 204 : 'No Content',
  1550. 205 : 'Reset Content',
  1551. 206 : 'Partial Content',
  1552. 207 : 'Multi-Status', // RFC 4918
  1553. 300 : 'Multiple Choices',
  1554. 301 : 'Moved Permanently',
  1555. 302 : 'Moved Temporarily',
  1556. 303 : 'See Other',
  1557. 304 : 'Not Modified',
  1558. 305 : 'Use Proxy',
  1559. 307 : 'Temporary Redirect',
  1560. 400 : 'Bad Request',
  1561. 401 : 'Unauthorized',
  1562. 402 : 'Payment Required',
  1563. 403 : 'Forbidden',
  1564. 404 : 'Not Found',
  1565. 405 : 'Method Not Allowed',
  1566. 406 : 'Not Acceptable',
  1567. 407 : 'Proxy Authentication Required',
  1568. 408 : 'Request Time-out',
  1569. 409 : 'Conflict',
  1570. 410 : 'Gone',
  1571. 411 : 'Length Required',
  1572. 412 : 'Precondition Failed',
  1573. 413 : 'Request Entity Too Large',
  1574. 414 : 'Request-URI Too Large',
  1575. 415 : 'Unsupported Media Type',
  1576. 416 : 'Requested Range Not Satisfiable',
  1577. 417 : 'Expectation Failed',
  1578. 418 : 'I\'m a teapot', // RFC 2324
  1579. 422 : 'Unprocessable Entity', // RFC 4918
  1580. 423 : 'Locked', // RFC 4918
  1581. 424 : 'Failed Dependency', // RFC 4918
  1582. 425 : 'Unordered Collection', // RFC 4918
  1583. 426 : 'Upgrade Required', // RFC 2817
  1584. 428 : 'Precondition Required', // RFC 6585
  1585. 429 : 'Too Many Requests', // RFC 6585
  1586. 431 : 'Request Header Fields Too Large',// RFC 6585
  1587. 500 : 'Internal Server Error',
  1588. 501 : 'Not Implemented',
  1589. 502 : 'Bad Gateway',
  1590. 503 : 'Service Unavailable',
  1591. 504 : 'Gateway Time-out',
  1592. 505 : 'HTTP Version Not Supported',
  1593. 506 : 'Variant Also Negotiates', // RFC 2295
  1594. 507 : 'Insufficient Storage', // RFC 4918
  1595. 509 : 'Bandwidth Limit Exceeded',
  1596. 510 : 'Not Extended', // RFC 2774
  1597. 511 : 'Network Authentication Required' // RFC 6585
  1598. };
  1599. },{"./lib/request":7,"events":5,"url":26}],7:[function(require,module,exports){
  1600. var Stream = require('stream');
  1601. var Response = require('./response');
  1602. var Base64 = require('Base64');
  1603. var inherits = require('inherits');
  1604. var Request = module.exports = function (xhr, params) {
  1605. var self = this;
  1606. self.writable = true;
  1607. self.xhr = xhr;
  1608. self.body = [];
  1609. self.uri = (params.scheme || 'http') + '://'
  1610. + params.host
  1611. + (params.port ? ':' + params.port : '')
  1612. + (params.path || '/')
  1613. ;
  1614. if (typeof params.withCredentials === 'undefined') {
  1615. params.withCredentials = true;
  1616. }
  1617. try { xhr.withCredentials = params.withCredentials }
  1618. catch (e) {}
  1619. xhr.open(
  1620. params.method || 'GET',
  1621. self.uri,
  1622. true
  1623. );
  1624. self._headers = {};
  1625. if (params.headers) {
  1626. var keys = objectKeys(params.headers);
  1627. for (var i = 0; i < keys.length; i++) {
  1628. var key = keys[i];
  1629. if (!self.isSafeRequestHeader(key)) continue;
  1630. var value = params.headers[key];
  1631. self.setHeader(key, value);
  1632. }
  1633. }
  1634. if (params.auth) {
  1635. //basic auth
  1636. this.setHeader('Authorization', 'Basic ' + Base64.btoa(params.auth));
  1637. }
  1638. var res = new Response;
  1639. res.on('close', function () {
  1640. self.emit('close');
  1641. });
  1642. res.on('ready', function () {
  1643. self.emit('response', res);
  1644. });
  1645. xhr.onreadystatechange = function () {
  1646. // Fix for IE9 bug
  1647. // SCRIPT575: Could not complete the operation due to error c00c023f
  1648. // It happens when a request is aborted, calling the success callback anyway with readyState === 4
  1649. if (xhr.__aborted) return;
  1650. res.handle(xhr);
  1651. };
  1652. };
  1653. inherits(Request, Stream);
  1654. Request.prototype.setHeader = function (key, value) {
  1655. this._headers[key.toLowerCase()] = value
  1656. };
  1657. Request.prototype.getHeader = function (key) {
  1658. return this._headers[key.toLowerCase()]
  1659. };
  1660. Request.prototype.removeHeader = function (key) {
  1661. delete this._headers[key.toLowerCase()]
  1662. };
  1663. Request.prototype.write = function (s) {
  1664. this.body.push(s);
  1665. };
  1666. Request.prototype.destroy = function (s) {
  1667. this.xhr.__aborted = true;
  1668. this.xhr.abort();
  1669. this.emit('close');
  1670. };
  1671. Request.prototype.end = function (s) {
  1672. if (s !== undefined) this.body.push(s);
  1673. var keys = objectKeys(this._headers);
  1674. for (var i = 0; i < keys.length; i++) {
  1675. var key = keys[i];
  1676. var value = this._headers[key];
  1677. if (isArray(value)) {
  1678. for (var j = 0; j < value.length; j++) {
  1679. this.xhr.setRequestHeader(key, value[j]);
  1680. }
  1681. }
  1682. else this.xhr.setRequestHeader(key, value)
  1683. }
  1684. if (this.body.length === 0) {
  1685. this.xhr.send('');
  1686. }
  1687. else if (typeof this.body[0] === 'string') {
  1688. this.xhr.send(this.body.join(''));
  1689. }
  1690. else if (isArray(this.body[0])) {
  1691. var body = [];
  1692. for (var i = 0; i < this.body.length; i++) {
  1693. body.push.apply(body, this.body[i]);
  1694. }
  1695. this.xhr.send(body);
  1696. }
  1697. else if (/Array/.test(Object.prototype.toString.call(this.body[0]))) {
  1698. var len = 0;
  1699. for (var i = 0; i < this.body.length; i++) {
  1700. len += this.body[i].length;
  1701. }
  1702. var body = new(this.body[0].constructor)(len);
  1703. var k = 0;
  1704. for (var i = 0; i < this.body.length; i++) {
  1705. var b = this.body[i];
  1706. for (var j = 0; j < b.length; j++) {
  1707. body[k++] = b[j];
  1708. }
  1709. }
  1710. this.xhr.send(body);
  1711. }
  1712. else {
  1713. var body = '';
  1714. for (var i = 0; i < this.body.length; i++) {
  1715. body += this.body[i].toString();
  1716. }
  1717. this.xhr.send(body);
  1718. }
  1719. };
  1720. // Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html
  1721. Request.unsafeHeaders = [
  1722. "accept-charset",
  1723. "accept-encoding",
  1724. "access-control-request-headers",
  1725. "access-control-request-method",
  1726. "connection",
  1727. "content-length",
  1728. "cookie",
  1729. "cookie2",
  1730. "content-transfer-encoding",
  1731. "date",
  1732. "expect",
  1733. "host",
  1734. "keep-alive",
  1735. "origin",
  1736. "referer",
  1737. "te",
  1738. "trailer",
  1739. "transfer-encoding",
  1740. "upgrade",
  1741. "user-agent",
  1742. "via"
  1743. ];
  1744. Request.prototype.isSafeRequestHeader = function (headerName) {
  1745. if (!headerName) return false;
  1746. return indexOf(Request.unsafeHeaders, headerName.toLowerCase()) === -1;
  1747. };
  1748. var objectKeys = Object.keys || function (obj) {
  1749. var keys = [];
  1750. for (var key in obj) keys.push(key);
  1751. return keys;
  1752. };
  1753. var isArray = Array.isArray || function (xs) {
  1754. return Object.prototype.toString.call(xs) === '[object Array]';
  1755. };
  1756. var indexOf = function (xs, x) {
  1757. if (xs.indexOf) return xs.indexOf(x);
  1758. for (var i = 0; i < xs.length; i++) {
  1759. if (xs[i] === x) return i;
  1760. }
  1761. return -1;
  1762. };
  1763. },{"./response":8,"Base64":2,"inherits":10,"stream":19}],8:[function(require,module,exports){
  1764. var Stream = require('stream');
  1765. var util = require('util');
  1766. var Response = module.exports = function (res) {
  1767. this.offset = 0;
  1768. this.readable = true;
  1769. };
  1770. util.inherits(Response, Stream);
  1771. var capable = {
  1772. streaming : true,
  1773. status2 : true
  1774. };
  1775. function parseHeaders (res) {
  1776. var lines = res.getAllResponseHeaders().split(/\r?\n/);
  1777. var headers = {};
  1778. for (var i = 0; i < lines.length; i++) {
  1779. var line = lines[i];
  1780. if (line === '') continue;
  1781. var m = line.match(/^([^:]+):\s*(.*)/);
  1782. if (m) {
  1783. var key = m[1].toLowerCase(), value = m[2];
  1784. if (headers[key] !== undefined) {
  1785. if (isArray(headers[key])) {
  1786. headers[key].push(value);
  1787. }
  1788. else {
  1789. headers[key] = [ headers[key], value ];
  1790. }
  1791. }
  1792. else {
  1793. headers[key] = value;
  1794. }
  1795. }
  1796. else {
  1797. headers[line] = true;
  1798. }
  1799. }
  1800. return headers;
  1801. }
  1802. Response.prototype.getResponse = function (xhr) {
  1803. var respType = String(xhr.responseType).toLowerCase();
  1804. if (respType === 'blob') return xhr.responseBlob || xhr.response;
  1805. if (respType === 'arraybuffer') return xhr.response;
  1806. return xhr.responseText;
  1807. }
  1808. Response.prototype.getHeader = function (key) {
  1809. return this.headers[key.toLowerCase()];
  1810. };
  1811. Response.prototype.handle = function (res) {
  1812. if (res.readyState === 2 && capable.status2) {
  1813. try {
  1814. this.statusCode = res.status;
  1815. this.headers = parseHeaders(res);
  1816. }
  1817. catch (err) {
  1818. capable.status2 = false;
  1819. }
  1820. if (capable.status2) {
  1821. this.emit('ready');
  1822. }
  1823. }
  1824. else if (capable.streaming && res.readyState === 3) {
  1825. try {
  1826. if (!this.statusCode) {
  1827. this.statusCode = res.status;
  1828. this.headers = parseHeaders(res);
  1829. this.emit('ready');
  1830. }
  1831. }
  1832. catch (err) {}
  1833. try {
  1834. this._emitData(res);
  1835. }
  1836. catch (err) {
  1837. capable.streaming = false;
  1838. }
  1839. }
  1840. else if (res.readyState === 4) {
  1841. if (!this.statusCode) {
  1842. this.statusCode = res.status;
  1843. this.emit('ready');
  1844. }
  1845. this._emitData(res);
  1846. if (res.error) {
  1847. this.emit('error', this.getResponse(res));
  1848. }
  1849. else this.emit('end');
  1850. this.emit('close');
  1851. }
  1852. };
  1853. Response.prototype._emitData = function (res) {
  1854. var respBody = this.getResponse(res);
  1855. if (respBody.toString().match(/ArrayBuffer/)) {
  1856. this.emit('data', new Uint8Array(respBody, this.offset));
  1857. this.offset = respBody.byteLength;
  1858. return;
  1859. }
  1860. if (respBody.length > this.offset) {
  1861. this.emit('data', respBody.slice(this.offset));
  1862. this.offset = respBody.length;
  1863. }
  1864. };
  1865. var isArray = Array.isArray || function (xs) {
  1866. return Object.prototype.toString.call(xs) === '[object Array]';
  1867. };
  1868. },{"stream":19,"util":29}],9:[function(require,module,exports){
  1869. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  1870. var e, m
  1871. var eLen = (nBytes * 8) - mLen - 1
  1872. var eMax = (1 << eLen) - 1
  1873. var eBias = eMax >> 1
  1874. var nBits = -7
  1875. var i = isLE ? (nBytes - 1) : 0
  1876. var d = isLE ? -1 : 1
  1877. var s = buffer[offset + i]
  1878. i += d
  1879. e = s & ((1 << (-nBits)) - 1)
  1880. s >>= (-nBits)
  1881. nBits += eLen
  1882. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  1883. m = e & ((1 << (-nBits)) - 1)
  1884. e >>= (-nBits)
  1885. nBits += mLen
  1886. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  1887. if (e === 0) {
  1888. e = 1 - eBias
  1889. } else if (e === eMax) {
  1890. return m ? NaN : ((s ? -1 : 1) * Infinity)
  1891. } else {
  1892. m = m + Math.pow(2, mLen)
  1893. e = e - eBias
  1894. }
  1895. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  1896. }
  1897. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  1898. var e, m, c
  1899. var eLen = (nBytes * 8) - mLen - 1
  1900. var eMax = (1 << eLen) - 1
  1901. var eBias = eMax >> 1
  1902. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  1903. var i = isLE ? 0 : (nBytes - 1)
  1904. var d = isLE ? 1 : -1
  1905. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  1906. value = Math.abs(value)
  1907. if (isNaN(value) || value === Infinity) {
  1908. m = isNaN(value) ? 1 : 0
  1909. e = eMax
  1910. } else {
  1911. e = Math.floor(Math.log(value) / Math.LN2)
  1912. if (value * (c = Math.pow(2, -e)) < 1) {
  1913. e--
  1914. c *= 2
  1915. }
  1916. if (e + eBias >= 1) {
  1917. value += rt / c
  1918. } else {
  1919. value += rt * Math.pow(2, 1 - eBias)
  1920. }
  1921. if (value * c >= 2) {
  1922. e++
  1923. c /= 2
  1924. }
  1925. if (e + eBias >= eMax) {
  1926. m = 0
  1927. e = eMax
  1928. } else if (e + eBias >= 1) {
  1929. m = ((value * c) - 1) * Math.pow(2, mLen)
  1930. e = e + eBias
  1931. } else {
  1932. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  1933. e = 0
  1934. }
  1935. }
  1936. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  1937. e = (e << mLen) | m
  1938. eLen += mLen
  1939. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  1940. buffer[offset + i - d] |= s * 128
  1941. }
  1942. },{}],10:[function(require,module,exports){
  1943. if (typeof Object.create === 'function') {
  1944. // implementation from standard node.js 'util' module
  1945. module.exports = function inherits(ctor, superCtor) {
  1946. if (superCtor) {
  1947. ctor.super_ = superCtor
  1948. ctor.prototype = Object.create(superCtor.prototype, {
  1949. constructor: {
  1950. value: ctor,
  1951. enumerable: false,
  1952. writable: true,
  1953. configurable: true
  1954. }
  1955. })
  1956. }
  1957. };
  1958. } else {
  1959. // old school shim for old browsers
  1960. module.exports = function inherits(ctor, superCtor) {
  1961. if (superCtor) {
  1962. ctor.super_ = superCtor
  1963. var TempCtor = function () {}
  1964. TempCtor.prototype = superCtor.prototype
  1965. ctor.prototype = new TempCtor()
  1966. ctor.prototype.constructor = ctor
  1967. }
  1968. }
  1969. }
  1970. },{}],11:[function(require,module,exports){
  1971. var hasMap = typeof Map === 'function' && Map.prototype;
  1972. var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
  1973. var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
  1974. var mapForEach = hasMap && Map.prototype.forEach;
  1975. var hasSet = typeof Set === 'function' && Set.prototype;
  1976. var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
  1977. var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
  1978. var setForEach = hasSet && Set.prototype.forEach;
  1979. var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
  1980. var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
  1981. var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
  1982. var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
  1983. var booleanValueOf = Boolean.prototype.valueOf;
  1984. var objectToString = Object.prototype.toString;
  1985. var match = String.prototype.match;
  1986. var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
  1987. var inspectCustom = require('./util.inspect').custom;
  1988. var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
  1989. module.exports = function inspect_(obj, options, depth, seen) {
  1990. var opts = options || {};
  1991. if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
  1992. throw new TypeError('option "quoteStyle" must be "single" or "double"');
  1993. }
  1994. if (typeof obj === 'undefined') {
  1995. return 'undefined';
  1996. }
  1997. if (obj === null) {
  1998. return 'null';
  1999. }
  2000. if (typeof obj === 'boolean') {
  2001. return obj ? 'true' : 'false';
  2002. }
  2003. if (typeof obj === 'string') {
  2004. return inspectString(obj, opts);
  2005. }
  2006. if (typeof obj === 'number') {
  2007. if (obj === 0) {
  2008. return Infinity / obj > 0 ? '0' : '-0';
  2009. }
  2010. return String(obj);
  2011. }
  2012. if (typeof obj === 'bigint') { // eslint-disable-line valid-typeof
  2013. return String(obj) + 'n';
  2014. }
  2015. var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
  2016. if (typeof depth === 'undefined') { depth = 0; }
  2017. if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
  2018. return '[Object]';
  2019. }
  2020. if (typeof seen === 'undefined') {
  2021. seen = [];
  2022. } else if (indexOf(seen, obj) >= 0) {
  2023. return '[Circular]';
  2024. }
  2025. function inspect(value, from) {
  2026. if (from) {
  2027. seen = seen.slice();
  2028. seen.push(from);
  2029. }
  2030. return inspect_(value, opts, depth + 1, seen);
  2031. }
  2032. if (typeof obj === 'function') {
  2033. var name = nameOf(obj);
  2034. return '[Function' + (name ? ': ' + name : '') + ']';
  2035. }
  2036. if (isSymbol(obj)) {
  2037. var symString = Symbol.prototype.toString.call(obj);
  2038. return typeof obj === 'object' ? markBoxed(symString) : symString;
  2039. }
  2040. if (isElement(obj)) {
  2041. var s = '<' + String(obj.nodeName).toLowerCase();
  2042. var attrs = obj.attributes || [];
  2043. for (var i = 0; i < attrs.length; i++) {
  2044. s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
  2045. }
  2046. s += '>';
  2047. if (obj.childNodes && obj.childNodes.length) { s += '...'; }
  2048. s += '</' + String(obj.nodeName).toLowerCase() + '>';
  2049. return s;
  2050. }
  2051. if (isArray(obj)) {
  2052. if (obj.length === 0) { return '[]'; }
  2053. return '[ ' + arrObjKeys(obj, inspect).join(', ') + ' ]';
  2054. }
  2055. if (isError(obj)) {
  2056. var parts = arrObjKeys(obj, inspect);
  2057. if (parts.length === 0) { return '[' + String(obj) + ']'; }
  2058. return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }';
  2059. }
  2060. if (typeof obj === 'object') {
  2061. if (inspectSymbol && typeof obj[inspectSymbol] === 'function') {
  2062. return obj[inspectSymbol]();
  2063. } else if (typeof obj.inspect === 'function') {
  2064. return obj.inspect();
  2065. }
  2066. }
  2067. if (isMap(obj)) {
  2068. var mapParts = [];
  2069. mapForEach.call(obj, function (value, key) {
  2070. mapParts.push(inspect(key, obj) + ' => ' + inspect(value, obj));
  2071. });
  2072. return collectionOf('Map', mapSize.call(obj), mapParts);
  2073. }
  2074. if (isSet(obj)) {
  2075. var setParts = [];
  2076. setForEach.call(obj, function (value) {
  2077. setParts.push(inspect(value, obj));
  2078. });
  2079. return collectionOf('Set', setSize.call(obj), setParts);
  2080. }
  2081. if (isWeakMap(obj)) {
  2082. return weakCollectionOf('WeakMap');
  2083. }
  2084. if (isWeakSet(obj)) {
  2085. return weakCollectionOf('WeakSet');
  2086. }
  2087. if (isNumber(obj)) {
  2088. return markBoxed(inspect(Number(obj)));
  2089. }
  2090. if (isBigInt(obj)) {
  2091. return markBoxed(inspect(bigIntValueOf.call(obj)));
  2092. }
  2093. if (isBoolean(obj)) {
  2094. return markBoxed(booleanValueOf.call(obj));
  2095. }
  2096. if (isString(obj)) {
  2097. return markBoxed(inspect(String(obj)));
  2098. }
  2099. if (!isDate(obj) && !isRegExp(obj)) {
  2100. var xs = arrObjKeys(obj, inspect);
  2101. if (xs.length === 0) { return '{}'; }
  2102. return '{ ' + xs.join(', ') + ' }';
  2103. }
  2104. return String(obj);
  2105. };
  2106. function wrapQuotes(s, defaultStyle, opts) {
  2107. var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
  2108. return quoteChar + s + quoteChar;
  2109. }
  2110. function quote(s) {
  2111. return String(s).replace(/"/g, '&quot;');
  2112. }
  2113. function isArray(obj) { return toStr(obj) === '[object Array]'; }
  2114. function isDate(obj) { return toStr(obj) === '[object Date]'; }
  2115. function isRegExp(obj) { return toStr(obj) === '[object RegExp]'; }
  2116. function isError(obj) { return toStr(obj) === '[object Error]'; }
  2117. function isSymbol(obj) { return toStr(obj) === '[object Symbol]'; }
  2118. function isString(obj) { return toStr(obj) === '[object String]'; }
  2119. function isNumber(obj) { return toStr(obj) === '[object Number]'; }
  2120. function isBigInt(obj) { return toStr(obj) === '[object BigInt]'; }
  2121. function isBoolean(obj) { return toStr(obj) === '[object Boolean]'; }
  2122. var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
  2123. function has(obj, key) {
  2124. return hasOwn.call(obj, key);
  2125. }
  2126. function toStr(obj) {
  2127. return objectToString.call(obj);
  2128. }
  2129. function nameOf(f) {
  2130. if (f.name) { return f.name; }
  2131. var m = match.call(f, /^function\s*([\w$]+)/);
  2132. if (m) { return m[1]; }
  2133. return null;
  2134. }
  2135. function indexOf(xs, x) {
  2136. if (xs.indexOf) { return xs.indexOf(x); }
  2137. for (var i = 0, l = xs.length; i < l; i++) {
  2138. if (xs[i] === x) { return i; }
  2139. }
  2140. return -1;
  2141. }
  2142. function isMap(x) {
  2143. if (!mapSize || !x || typeof x !== 'object') {
  2144. return false;
  2145. }
  2146. try {
  2147. mapSize.call(x);
  2148. try {
  2149. setSize.call(x);
  2150. } catch (s) {
  2151. return true;
  2152. }
  2153. return x instanceof Map; // core-js workaround, pre-v2.5.0
  2154. } catch (e) {}
  2155. return false;
  2156. }
  2157. function isWeakMap(x) {
  2158. if (!weakMapHas || !x || typeof x !== 'object') {
  2159. return false;
  2160. }
  2161. try {
  2162. weakMapHas.call(x, weakMapHas);
  2163. try {
  2164. weakSetHas.call(x, weakSetHas);
  2165. } catch (s) {
  2166. return true;
  2167. }
  2168. return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
  2169. } catch (e) {}
  2170. return false;
  2171. }
  2172. function isSet(x) {
  2173. if (!setSize || !x || typeof x !== 'object') {
  2174. return false;
  2175. }
  2176. try {
  2177. setSize.call(x);
  2178. try {
  2179. mapSize.call(x);
  2180. } catch (m) {
  2181. return true;
  2182. }
  2183. return x instanceof Set; // core-js workaround, pre-v2.5.0
  2184. } catch (e) {}
  2185. return false;
  2186. }
  2187. function isWeakSet(x) {
  2188. if (!weakSetHas || !x || typeof x !== 'object') {
  2189. return false;
  2190. }
  2191. try {
  2192. weakSetHas.call(x, weakSetHas);
  2193. try {
  2194. weakMapHas.call(x, weakMapHas);
  2195. } catch (s) {
  2196. return true;
  2197. }
  2198. return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
  2199. } catch (e) {}
  2200. return false;
  2201. }
  2202. function isElement(x) {
  2203. if (!x || typeof x !== 'object') { return false; }
  2204. if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
  2205. return true;
  2206. }
  2207. return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
  2208. }
  2209. function inspectString(str, opts) {
  2210. // eslint-disable-next-line no-control-regex
  2211. var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte);
  2212. return wrapQuotes(s, 'single', opts);
  2213. }
  2214. function lowbyte(c) {
  2215. var n = c.charCodeAt(0);
  2216. var x = {
  2217. 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r'
  2218. }[n];
  2219. if (x) { return '\\' + x; }
  2220. return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
  2221. }
  2222. function markBoxed(str) {
  2223. return 'Object(' + str + ')';
  2224. }
  2225. function weakCollectionOf(type) {
  2226. return type + ' { ? }';
  2227. }
  2228. function collectionOf(type, size, entries) {
  2229. return type + ' (' + size + ') {' + entries.join(', ') + '}';
  2230. }
  2231. function arrObjKeys(obj, inspect) {
  2232. var isArr = isArray(obj);
  2233. var xs = [];
  2234. if (isArr) {
  2235. xs.length = obj.length;
  2236. for (var i = 0; i < obj.length; i++) {
  2237. xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
  2238. }
  2239. }
  2240. for (var key in obj) { // eslint-disable-line no-restricted-syntax
  2241. if (!has(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
  2242. if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
  2243. if ((/[^\w$]/).test(key)) {
  2244. xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
  2245. } else {
  2246. xs.push(key + ': ' + inspect(obj[key], obj));
  2247. }
  2248. }
  2249. return xs;
  2250. }
  2251. },{"./util.inspect":12}],12:[function(require,module,exports){
  2252. module.exports = require('util').inspect;
  2253. },{"util":29}],13:[function(require,module,exports){
  2254. // shim for using process in browser
  2255. var process = module.exports = {};
  2256. process.nextTick = (function () {
  2257. var canSetImmediate = typeof window !== 'undefined'
  2258. && window.setImmediate;
  2259. var canPost = typeof window !== 'undefined'
  2260. && window.postMessage && window.addEventListener
  2261. ;
  2262. if (canSetImmediate) {
  2263. return function (f) { return window.setImmediate(f) };
  2264. }
  2265. if (canPost) {
  2266. var queue = [];
  2267. window.addEventListener('message', function (ev) {
  2268. var source = ev.source;
  2269. if ((source === window || source === null) && ev.data === 'process-tick') {
  2270. ev.stopPropagation();
  2271. if (queue.length > 0) {
  2272. var fn = queue.shift();
  2273. fn();
  2274. }
  2275. }
  2276. }, true);
  2277. return function nextTick(fn) {
  2278. queue.push(fn);
  2279. window.postMessage('process-tick', '*');
  2280. };
  2281. }
  2282. return function nextTick(fn) {
  2283. setTimeout(fn, 0);
  2284. };
  2285. })();
  2286. process.title = 'browser';
  2287. process.browser = true;
  2288. process.env = {};
  2289. process.argv = [];
  2290. function noop() {}
  2291. process.on = noop;
  2292. process.addListener = noop;
  2293. process.once = noop;
  2294. process.off = noop;
  2295. process.removeListener = noop;
  2296. process.removeAllListeners = noop;
  2297. process.emit = noop;
  2298. process.binding = function (name) {
  2299. throw new Error('process.binding is not supported');
  2300. }
  2301. // TODO(shtylman)
  2302. process.cwd = function () { return '/' };
  2303. process.chdir = function (dir) {
  2304. throw new Error('process.chdir is not supported');
  2305. };
  2306. },{}],14:[function(require,module,exports){
  2307. (function (global){
  2308. /*! http://mths.be/punycode v1.2.4 by @mathias */
  2309. ;(function(root) {
  2310. /** Detect free variables */
  2311. var freeExports = typeof exports == 'object' && exports;
  2312. var freeModule = typeof module == 'object' && module &&
  2313. module.exports == freeExports && module;
  2314. var freeGlobal = typeof global == 'object' && global;
  2315. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
  2316. root = freeGlobal;
  2317. }
  2318. /**
  2319. * The `punycode` object.
  2320. * @name punycode
  2321. * @type Object
  2322. */
  2323. var punycode,
  2324. /** Highest positive signed 32-bit float value */
  2325. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  2326. /** Bootstring parameters */
  2327. base = 36,
  2328. tMin = 1,
  2329. tMax = 26,
  2330. skew = 38,
  2331. damp = 700,
  2332. initialBias = 72,
  2333. initialN = 128, // 0x80
  2334. delimiter = '-', // '\x2D'
  2335. /** Regular expressions */
  2336. regexPunycode = /^xn--/,
  2337. regexNonASCII = /[^ -~]/, // unprintable ASCII chars + non-ASCII chars
  2338. regexSeparators = /\x2E|\u3002|\uFF0E|\uFF61/g, // RFC 3490 separators
  2339. /** Error messages */
  2340. errors = {
  2341. 'overflow': 'Overflow: input needs wider integers to process',
  2342. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  2343. 'invalid-input': 'Invalid input'
  2344. },
  2345. /** Convenience shortcuts */
  2346. baseMinusTMin = base - tMin,
  2347. floor = Math.floor,
  2348. stringFromCharCode = String.fromCharCode,
  2349. /** Temporary variable */
  2350. key;
  2351. /*--------------------------------------------------------------------------*/
  2352. /**
  2353. * A generic error utility function.
  2354. * @private
  2355. * @param {String} type The error type.
  2356. * @returns {Error} Throws a `RangeError` with the applicable error message.
  2357. */
  2358. function error(type) {
  2359. throw RangeError(errors[type]);
  2360. }
  2361. /**
  2362. * A generic `Array#map` utility function.
  2363. * @private
  2364. * @param {Array} array The array to iterate over.
  2365. * @param {Function} callback The function that gets called for every array
  2366. * item.
  2367. * @returns {Array} A new array of values returned by the callback function.
  2368. */
  2369. function map(array, fn) {
  2370. var length = array.length;
  2371. while (length--) {
  2372. array[length] = fn(array[length]);
  2373. }
  2374. return array;
  2375. }
  2376. /**
  2377. * A simple `Array#map`-like wrapper to work with domain name strings.
  2378. * @private
  2379. * @param {String} domain The domain name.
  2380. * @param {Function} callback The function that gets called for every
  2381. * character.
  2382. * @returns {Array} A new string of characters returned by the callback
  2383. * function.
  2384. */
  2385. function mapDomain(string, fn) {
  2386. return map(string.split(regexSeparators), fn).join('.');
  2387. }
  2388. /**
  2389. * Creates an array containing the numeric code points of each Unicode
  2390. * character in the string. While JavaScript uses UCS-2 internally,
  2391. * this function will convert a pair of surrogate halves (each of which
  2392. * UCS-2 exposes as separate characters) into a single code point,
  2393. * matching UTF-16.
  2394. * @see `punycode.ucs2.encode`
  2395. * @see <http://mathiasbynens.be/notes/javascript-encoding>
  2396. * @memberOf punycode.ucs2
  2397. * @name decode
  2398. * @param {String} string The Unicode input string (UCS-2).
  2399. * @returns {Array} The new array of code points.
  2400. */
  2401. function ucs2decode(string) {
  2402. var output = [],
  2403. counter = 0,
  2404. length = string.length,
  2405. value,
  2406. extra;
  2407. while (counter < length) {
  2408. value = string.charCodeAt(counter++);
  2409. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  2410. // high surrogate, and there is a next character
  2411. extra = string.charCodeAt(counter++);
  2412. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  2413. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  2414. } else {
  2415. // unmatched surrogate; only append this code unit, in case the next
  2416. // code unit is the high surrogate of a surrogate pair
  2417. output.push(value);
  2418. counter--;
  2419. }
  2420. } else {
  2421. output.push(value);
  2422. }
  2423. }
  2424. return output;
  2425. }
  2426. /**
  2427. * Creates a string based on an array of numeric code points.
  2428. * @see `punycode.ucs2.decode`
  2429. * @memberOf punycode.ucs2
  2430. * @name encode
  2431. * @param {Array} codePoints The array of numeric code points.
  2432. * @returns {String} The new Unicode string (UCS-2).
  2433. */
  2434. function ucs2encode(array) {
  2435. return map(array, function(value) {
  2436. var output = '';
  2437. if (value > 0xFFFF) {
  2438. value -= 0x10000;
  2439. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  2440. value = 0xDC00 | value & 0x3FF;
  2441. }
  2442. output += stringFromCharCode(value);
  2443. return output;
  2444. }).join('');
  2445. }
  2446. /**
  2447. * Converts a basic code point into a digit/integer.
  2448. * @see `digitToBasic()`
  2449. * @private
  2450. * @param {Number} codePoint The basic numeric code point value.
  2451. * @returns {Number} The numeric value of a basic code point (for use in
  2452. * representing integers) in the range `0` to `base - 1`, or `base` if
  2453. * the code point does not represent a value.
  2454. */
  2455. function basicToDigit(codePoint) {
  2456. if (codePoint - 48 < 10) {
  2457. return codePoint - 22;
  2458. }
  2459. if (codePoint - 65 < 26) {
  2460. return codePoint - 65;
  2461. }
  2462. if (codePoint - 97 < 26) {
  2463. return codePoint - 97;
  2464. }
  2465. return base;
  2466. }
  2467. /**
  2468. * Converts a digit/integer into a basic code point.
  2469. * @see `basicToDigit()`
  2470. * @private
  2471. * @param {Number} digit The numeric value of a basic code point.
  2472. * @returns {Number} The basic code point whose value (when used for
  2473. * representing integers) is `digit`, which needs to be in the range
  2474. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  2475. * used; else, the lowercase form is used. The behavior is undefined
  2476. * if `flag` is non-zero and `digit` has no uppercase form.
  2477. */
  2478. function digitToBasic(digit, flag) {
  2479. // 0..25 map to ASCII a..z or A..Z
  2480. // 26..35 map to ASCII 0..9
  2481. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  2482. }
  2483. /**
  2484. * Bias adaptation function as per section 3.4 of RFC 3492.
  2485. * http://tools.ietf.org/html/rfc3492#section-3.4
  2486. * @private
  2487. */
  2488. function adapt(delta, numPoints, firstTime) {
  2489. var k = 0;
  2490. delta = firstTime ? floor(delta / damp) : delta >> 1;
  2491. delta += floor(delta / numPoints);
  2492. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  2493. delta = floor(delta / baseMinusTMin);
  2494. }
  2495. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  2496. }
  2497. /**
  2498. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  2499. * symbols.
  2500. * @memberOf punycode
  2501. * @param {String} input The Punycode string of ASCII-only symbols.
  2502. * @returns {String} The resulting string of Unicode symbols.
  2503. */
  2504. function decode(input) {
  2505. // Don't use UCS-2
  2506. var output = [],
  2507. inputLength = input.length,
  2508. out,
  2509. i = 0,
  2510. n = initialN,
  2511. bias = initialBias,
  2512. basic,
  2513. j,
  2514. index,
  2515. oldi,
  2516. w,
  2517. k,
  2518. digit,
  2519. t,
  2520. /** Cached calculation results */
  2521. baseMinusT;
  2522. // Handle the basic code points: let `basic` be the number of input code
  2523. // points before the last delimiter, or `0` if there is none, then copy
  2524. // the first basic code points to the output.
  2525. basic = input.lastIndexOf(delimiter);
  2526. if (basic < 0) {
  2527. basic = 0;
  2528. }
  2529. for (j = 0; j < basic; ++j) {
  2530. // if it's not a basic code point
  2531. if (input.charCodeAt(j) >= 0x80) {
  2532. error('not-basic');
  2533. }
  2534. output.push(input.charCodeAt(j));
  2535. }
  2536. // Main decoding loop: start just after the last delimiter if any basic code
  2537. // points were copied; start at the beginning otherwise.
  2538. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  2539. // `index` is the index of the next character to be consumed.
  2540. // Decode a generalized variable-length integer into `delta`,
  2541. // which gets added to `i`. The overflow checking is easier
  2542. // if we increase `i` as we go, then subtract off its starting
  2543. // value at the end to obtain `delta`.
  2544. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  2545. if (index >= inputLength) {
  2546. error('invalid-input');
  2547. }
  2548. digit = basicToDigit(input.charCodeAt(index++));
  2549. if (digit >= base || digit > floor((maxInt - i) / w)) {
  2550. error('overflow');
  2551. }
  2552. i += digit * w;
  2553. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  2554. if (digit < t) {
  2555. break;
  2556. }
  2557. baseMinusT = base - t;
  2558. if (w > floor(maxInt / baseMinusT)) {
  2559. error('overflow');
  2560. }
  2561. w *= baseMinusT;
  2562. }
  2563. out = output.length + 1;
  2564. bias = adapt(i - oldi, out, oldi == 0);
  2565. // `i` was supposed to wrap around from `out` to `0`,
  2566. // incrementing `n` each time, so we'll fix that now:
  2567. if (floor(i / out) > maxInt - n) {
  2568. error('overflow');
  2569. }
  2570. n += floor(i / out);
  2571. i %= out;
  2572. // Insert `n` at position `i` of the output
  2573. output.splice(i++, 0, n);
  2574. }
  2575. return ucs2encode(output);
  2576. }
  2577. /**
  2578. * Converts a string of Unicode symbols to a Punycode string of ASCII-only
  2579. * symbols.
  2580. * @memberOf punycode
  2581. * @param {String} input The string of Unicode symbols.
  2582. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  2583. */
  2584. function encode(input) {
  2585. var n,
  2586. delta,
  2587. handledCPCount,
  2588. basicLength,
  2589. bias,
  2590. j,
  2591. m,
  2592. q,
  2593. k,
  2594. t,
  2595. currentValue,
  2596. output = [],
  2597. /** `inputLength` will hold the number of code points in `input`. */
  2598. inputLength,
  2599. /** Cached calculation results */
  2600. handledCPCountPlusOne,
  2601. baseMinusT,
  2602. qMinusT;
  2603. // Convert the input in UCS-2 to Unicode
  2604. input = ucs2decode(input);
  2605. // Cache the length
  2606. inputLength = input.length;
  2607. // Initialize the state
  2608. n = initialN;
  2609. delta = 0;
  2610. bias = initialBias;
  2611. // Handle the basic code points
  2612. for (j = 0; j < inputLength; ++j) {
  2613. currentValue = input[j];
  2614. if (currentValue < 0x80) {
  2615. output.push(stringFromCharCode(currentValue));
  2616. }
  2617. }
  2618. handledCPCount = basicLength = output.length;
  2619. // `handledCPCount` is the number of code points that have been handled;
  2620. // `basicLength` is the number of basic code points.
  2621. // Finish the basic string - if it is not empty - with a delimiter
  2622. if (basicLength) {
  2623. output.push(delimiter);
  2624. }
  2625. // Main encoding loop:
  2626. while (handledCPCount < inputLength) {
  2627. // All non-basic code points < n have been handled already. Find the next
  2628. // larger one:
  2629. for (m = maxInt, j = 0; j < inputLength; ++j) {
  2630. currentValue = input[j];
  2631. if (currentValue >= n && currentValue < m) {
  2632. m = currentValue;
  2633. }
  2634. }
  2635. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  2636. // but guard against overflow
  2637. handledCPCountPlusOne = handledCPCount + 1;
  2638. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  2639. error('overflow');
  2640. }
  2641. delta += (m - n) * handledCPCountPlusOne;
  2642. n = m;
  2643. for (j = 0; j < inputLength; ++j) {
  2644. currentValue = input[j];
  2645. if (currentValue < n && ++delta > maxInt) {
  2646. error('overflow');
  2647. }
  2648. if (currentValue == n) {
  2649. // Represent delta as a generalized variable-length integer
  2650. for (q = delta, k = base; /* no condition */; k += base) {
  2651. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  2652. if (q < t) {
  2653. break;
  2654. }
  2655. qMinusT = q - t;
  2656. baseMinusT = base - t;
  2657. output.push(
  2658. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  2659. );
  2660. q = floor(qMinusT / baseMinusT);
  2661. }
  2662. output.push(stringFromCharCode(digitToBasic(q, 0)));
  2663. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  2664. delta = 0;
  2665. ++handledCPCount;
  2666. }
  2667. }
  2668. ++delta;
  2669. ++n;
  2670. }
  2671. return output.join('');
  2672. }
  2673. /**
  2674. * Converts a Punycode string representing a domain name to Unicode. Only the
  2675. * Punycoded parts of the domain name will be converted, i.e. it doesn't
  2676. * matter if you call it on a string that has already been converted to
  2677. * Unicode.
  2678. * @memberOf punycode
  2679. * @param {String} domain The Punycode domain name to convert to Unicode.
  2680. * @returns {String} The Unicode representation of the given Punycode
  2681. * string.
  2682. */
  2683. function toUnicode(domain) {
  2684. return mapDomain(domain, function(string) {
  2685. return regexPunycode.test(string)
  2686. ? decode(string.slice(4).toLowerCase())
  2687. : string;
  2688. });
  2689. }
  2690. /**
  2691. * Converts a Unicode string representing a domain name to Punycode. Only the
  2692. * non-ASCII parts of the domain name will be converted, i.e. it doesn't
  2693. * matter if you call it with a domain that's already in ASCII.
  2694. * @memberOf punycode
  2695. * @param {String} domain The domain name to convert, as a Unicode string.
  2696. * @returns {String} The Punycode representation of the given domain name.
  2697. */
  2698. function toASCII(domain) {
  2699. return mapDomain(domain, function(string) {
  2700. return regexNonASCII.test(string)
  2701. ? 'xn--' + encode(string)
  2702. : string;
  2703. });
  2704. }
  2705. /*--------------------------------------------------------------------------*/
  2706. /** Define the public API */
  2707. punycode = {
  2708. /**
  2709. * A string representing the current Punycode.js version number.
  2710. * @memberOf punycode
  2711. * @type String
  2712. */
  2713. 'version': '1.2.4',
  2714. /**
  2715. * An object of methods to convert from JavaScript's internal character
  2716. * representation (UCS-2) to Unicode code points, and back.
  2717. * @see <http://mathiasbynens.be/notes/javascript-encoding>
  2718. * @memberOf punycode
  2719. * @type Object
  2720. */
  2721. 'ucs2': {
  2722. 'decode': ucs2decode,
  2723. 'encode': ucs2encode
  2724. },
  2725. 'decode': decode,
  2726. 'encode': encode,
  2727. 'toASCII': toASCII,
  2728. 'toUnicode': toUnicode
  2729. };
  2730. /** Expose `punycode` */
  2731. // Some AMD build optimizers, like r.js, check for specific condition patterns
  2732. // like the following:
  2733. if (
  2734. typeof define == 'function' &&
  2735. typeof define.amd == 'object' &&
  2736. define.amd
  2737. ) {
  2738. define('punycode', function() {
  2739. return punycode;
  2740. });
  2741. } else if (freeExports && !freeExports.nodeType) {
  2742. if (freeModule) { // in Node.js or RingoJS v0.8.0+
  2743. freeModule.exports = punycode;
  2744. } else { // in Narwhal or RingoJS v0.7.0-
  2745. for (key in punycode) {
  2746. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  2747. }
  2748. }
  2749. } else { // in Rhino or a web browser
  2750. root.punycode = punycode;
  2751. }
  2752. }(this));
  2753. }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2754. },{}],15:[function(require,module,exports){
  2755. // Copyright Joyent, Inc. and other Node contributors.
  2756. //
  2757. // Permission is hereby granted, free of charge, to any person obtaining a
  2758. // copy of this software and associated documentation files (the
  2759. // "Software"), to deal in the Software without restriction, including
  2760. // without limitation the rights to use, copy, modify, merge, publish,
  2761. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2762. // persons to whom the Software is furnished to do so, subject to the
  2763. // following conditions:
  2764. //
  2765. // The above copyright notice and this permission notice shall be included
  2766. // in all copies or substantial portions of the Software.
  2767. //
  2768. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2769. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2770. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2771. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2772. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2773. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2774. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2775. 'use strict';
  2776. // If obj.hasOwnProperty has been overridden, then calling
  2777. // obj.hasOwnProperty(prop) will break.
  2778. // See: https://github.com/joyent/node/issues/1707
  2779. function hasOwnProperty(obj, prop) {
  2780. return Object.prototype.hasOwnProperty.call(obj, prop);
  2781. }
  2782. module.exports = function(qs, sep, eq, options) {
  2783. sep = sep || '&';
  2784. eq = eq || '=';
  2785. var obj = {};
  2786. if (typeof qs !== 'string' || qs.length === 0) {
  2787. return obj;
  2788. }
  2789. var regexp = /\+/g;
  2790. qs = qs.split(sep);
  2791. var maxKeys = 1000;
  2792. if (options && typeof options.maxKeys === 'number') {
  2793. maxKeys = options.maxKeys;
  2794. }
  2795. var len = qs.length;
  2796. // maxKeys <= 0 means that we should not limit keys count
  2797. if (maxKeys > 0 && len > maxKeys) {
  2798. len = maxKeys;
  2799. }
  2800. for (var i = 0; i < len; ++i) {
  2801. var x = qs[i].replace(regexp, '%20'),
  2802. idx = x.indexOf(eq),
  2803. kstr, vstr, k, v;
  2804. if (idx >= 0) {
  2805. kstr = x.substr(0, idx);
  2806. vstr = x.substr(idx + 1);
  2807. } else {
  2808. kstr = x;
  2809. vstr = '';
  2810. }
  2811. k = decodeURIComponent(kstr);
  2812. v = decodeURIComponent(vstr);
  2813. if (!hasOwnProperty(obj, k)) {
  2814. obj[k] = v;
  2815. } else if (isArray(obj[k])) {
  2816. obj[k].push(v);
  2817. } else {
  2818. obj[k] = [obj[k], v];
  2819. }
  2820. }
  2821. return obj;
  2822. };
  2823. var isArray = Array.isArray || function (xs) {
  2824. return Object.prototype.toString.call(xs) === '[object Array]';
  2825. };
  2826. },{}],16:[function(require,module,exports){
  2827. // Copyright Joyent, Inc. and other Node contributors.
  2828. //
  2829. // Permission is hereby granted, free of charge, to any person obtaining a
  2830. // copy of this software and associated documentation files (the
  2831. // "Software"), to deal in the Software without restriction, including
  2832. // without limitation the rights to use, copy, modify, merge, publish,
  2833. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2834. // persons to whom the Software is furnished to do so, subject to the
  2835. // following conditions:
  2836. //
  2837. // The above copyright notice and this permission notice shall be included
  2838. // in all copies or substantial portions of the Software.
  2839. //
  2840. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2841. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2842. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2843. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2844. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2845. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2846. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2847. 'use strict';
  2848. var stringifyPrimitive = function(v) {
  2849. switch (typeof v) {
  2850. case 'string':
  2851. return v;
  2852. case 'boolean':
  2853. return v ? 'true' : 'false';
  2854. case 'number':
  2855. return isFinite(v) ? v : '';
  2856. default:
  2857. return '';
  2858. }
  2859. };
  2860. module.exports = function(obj, sep, eq, name) {
  2861. sep = sep || '&';
  2862. eq = eq || '=';
  2863. if (obj === null) {
  2864. obj = undefined;
  2865. }
  2866. if (typeof obj === 'object') {
  2867. return map(objectKeys(obj), function(k) {
  2868. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  2869. if (isArray(obj[k])) {
  2870. return obj[k].map(function(v) {
  2871. return ks + encodeURIComponent(stringifyPrimitive(v));
  2872. }).join(sep);
  2873. } else {
  2874. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  2875. }
  2876. }).join(sep);
  2877. }
  2878. if (!name) return '';
  2879. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  2880. encodeURIComponent(stringifyPrimitive(obj));
  2881. };
  2882. var isArray = Array.isArray || function (xs) {
  2883. return Object.prototype.toString.call(xs) === '[object Array]';
  2884. };
  2885. function map (xs, f) {
  2886. if (xs.map) return xs.map(f);
  2887. var res = [];
  2888. for (var i = 0; i < xs.length; i++) {
  2889. res.push(f(xs[i], i));
  2890. }
  2891. return res;
  2892. }
  2893. var objectKeys = Object.keys || function (obj) {
  2894. var res = [];
  2895. for (var key in obj) {
  2896. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  2897. }
  2898. return res;
  2899. };
  2900. },{}],17:[function(require,module,exports){
  2901. 'use strict';
  2902. exports.decode = exports.parse = require('./decode');
  2903. exports.encode = exports.stringify = require('./encode');
  2904. },{"./decode":15,"./encode":16}],18:[function(require,module,exports){
  2905. // Copyright Joyent, Inc. and other Node contributors.
  2906. //
  2907. // Permission is hereby granted, free of charge, to any person obtaining a
  2908. // copy of this software and associated documentation files (the
  2909. // "Software"), to deal in the Software without restriction, including
  2910. // without limitation the rights to use, copy, modify, merge, publish,
  2911. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2912. // persons to whom the Software is furnished to do so, subject to the
  2913. // following conditions:
  2914. //
  2915. // The above copyright notice and this permission notice shall be included
  2916. // in all copies or substantial portions of the Software.
  2917. //
  2918. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2919. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2920. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2921. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2922. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2923. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2924. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2925. // a duplex stream is just a stream that is both readable and writable.
  2926. // Since JS doesn't have multiple prototypal inheritance, this class
  2927. // prototypally inherits from Readable, and then parasitically from
  2928. // Writable.
  2929. module.exports = Duplex;
  2930. var inherits = require('inherits');
  2931. var setImmediate = require('process/browser.js').nextTick;
  2932. var Readable = require('./readable.js');
  2933. var Writable = require('./writable.js');
  2934. inherits(Duplex, Readable);
  2935. Duplex.prototype.write = Writable.prototype.write;
  2936. Duplex.prototype.end = Writable.prototype.end;
  2937. Duplex.prototype._write = Writable.prototype._write;
  2938. function Duplex(options) {
  2939. if (!(this instanceof Duplex))
  2940. return new Duplex(options);
  2941. Readable.call(this, options);
  2942. Writable.call(this, options);
  2943. if (options && options.readable === false)
  2944. this.readable = false;
  2945. if (options && options.writable === false)
  2946. this.writable = false;
  2947. this.allowHalfOpen = true;
  2948. if (options && options.allowHalfOpen === false)
  2949. this.allowHalfOpen = false;
  2950. this.once('end', onend);
  2951. }
  2952. // the no-half-open enforcer
  2953. function onend() {
  2954. // if we allow half-open state, or if the writable side ended,
  2955. // then we're ok.
  2956. if (this.allowHalfOpen || this._writableState.ended)
  2957. return;
  2958. // no more data can be written.
  2959. // But allow more writes to happen in this tick.
  2960. var self = this;
  2961. setImmediate(function () {
  2962. self.end();
  2963. });
  2964. }
  2965. },{"./readable.js":22,"./writable.js":24,"inherits":10,"process/browser.js":20}],19:[function(require,module,exports){
  2966. // Copyright Joyent, Inc. and other Node contributors.
  2967. //
  2968. // Permission is hereby granted, free of charge, to any person obtaining a
  2969. // copy of this software and associated documentation files (the
  2970. // "Software"), to deal in the Software without restriction, including
  2971. // without limitation the rights to use, copy, modify, merge, publish,
  2972. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2973. // persons to whom the Software is furnished to do so, subject to the
  2974. // following conditions:
  2975. //
  2976. // The above copyright notice and this permission notice shall be included
  2977. // in all copies or substantial portions of the Software.
  2978. //
  2979. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2980. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2981. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2982. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2983. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2984. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2985. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2986. module.exports = Stream;
  2987. var EE = require('events').EventEmitter;
  2988. var inherits = require('inherits');
  2989. inherits(Stream, EE);
  2990. Stream.Readable = require('./readable.js');
  2991. Stream.Writable = require('./writable.js');
  2992. Stream.Duplex = require('./duplex.js');
  2993. Stream.Transform = require('./transform.js');
  2994. Stream.PassThrough = require('./passthrough.js');
  2995. // Backwards-compat with node 0.4.x
  2996. Stream.Stream = Stream;
  2997. // old-style streams. Note that the pipe method (the only relevant
  2998. // part of this class) is overridden in the Readable class.
  2999. function Stream() {
  3000. EE.call(this);
  3001. }
  3002. Stream.prototype.pipe = function(dest, options) {
  3003. var source = this;
  3004. function ondata(chunk) {
  3005. if (dest.writable) {
  3006. if (false === dest.write(chunk) && source.pause) {
  3007. source.pause();
  3008. }
  3009. }
  3010. }
  3011. source.on('data', ondata);
  3012. function ondrain() {
  3013. if (source.readable && source.resume) {
  3014. source.resume();
  3015. }
  3016. }
  3017. dest.on('drain', ondrain);
  3018. // If the 'end' option is not supplied, dest.end() will be called when
  3019. // source gets the 'end' or 'close' events. Only dest.end() once.
  3020. if (!dest._isStdio && (!options || options.end !== false)) {
  3021. source.on('end', onend);
  3022. source.on('close', onclose);
  3023. }
  3024. var didOnEnd = false;
  3025. function onend() {
  3026. if (didOnEnd) return;
  3027. didOnEnd = true;
  3028. dest.end();
  3029. }
  3030. function onclose() {
  3031. if (didOnEnd) return;
  3032. didOnEnd = true;
  3033. if (typeof dest.destroy === 'function') dest.destroy();
  3034. }
  3035. // don't leave dangling pipes when there are errors.
  3036. function onerror(er) {
  3037. cleanup();
  3038. if (EE.listenerCount(this, 'error') === 0) {
  3039. throw er; // Unhandled stream error in pipe.
  3040. }
  3041. }
  3042. source.on('error', onerror);
  3043. dest.on('error', onerror);
  3044. // remove all the event listeners that were added.
  3045. function cleanup() {
  3046. source.removeListener('data', ondata);
  3047. dest.removeListener('drain', ondrain);
  3048. source.removeListener('end', onend);
  3049. source.removeListener('close', onclose);
  3050. source.removeListener('error', onerror);
  3051. dest.removeListener('error', onerror);
  3052. source.removeListener('end', cleanup);
  3053. source.removeListener('close', cleanup);
  3054. dest.removeListener('close', cleanup);
  3055. }
  3056. source.on('end', cleanup);
  3057. source.on('close', cleanup);
  3058. dest.on('close', cleanup);
  3059. dest.emit('pipe', source);
  3060. // Allow for unix-like usage: A.pipe(B).pipe(C)
  3061. return dest;
  3062. };
  3063. },{"./duplex.js":18,"./passthrough.js":21,"./readable.js":22,"./transform.js":23,"./writable.js":24,"events":5,"inherits":10}],20:[function(require,module,exports){
  3064. // shim for using process in browser
  3065. var process = module.exports = {};
  3066. process.nextTick = (function () {
  3067. var canSetImmediate = typeof window !== 'undefined'
  3068. && window.setImmediate;
  3069. var canPost = typeof window !== 'undefined'
  3070. && window.postMessage && window.addEventListener
  3071. ;
  3072. if (canSetImmediate) {
  3073. return function (f) { return window.setImmediate(f) };
  3074. }
  3075. if (canPost) {
  3076. var queue = [];
  3077. window.addEventListener('message', function (ev) {
  3078. var source = ev.source;
  3079. if ((source === window || source === null) && ev.data === 'process-tick') {
  3080. ev.stopPropagation();
  3081. if (queue.length > 0) {
  3082. var fn = queue.shift();
  3083. fn();
  3084. }
  3085. }
  3086. }, true);
  3087. return function nextTick(fn) {
  3088. queue.push(fn);
  3089. window.postMessage('process-tick', '*');
  3090. };
  3091. }
  3092. return function nextTick(fn) {
  3093. setTimeout(fn, 0);
  3094. };
  3095. })();
  3096. process.title = 'browser';
  3097. process.browser = true;
  3098. process.env = {};
  3099. process.argv = [];
  3100. process.binding = function (name) {
  3101. throw new Error('process.binding is not supported');
  3102. }
  3103. // TODO(shtylman)
  3104. process.cwd = function () { return '/' };
  3105. process.chdir = function (dir) {
  3106. throw new Error('process.chdir is not supported');
  3107. };
  3108. },{}],21:[function(require,module,exports){
  3109. // Copyright Joyent, Inc. and other Node contributors.
  3110. //
  3111. // Permission is hereby granted, free of charge, to any person obtaining a
  3112. // copy of this software and associated documentation files (the
  3113. // "Software"), to deal in the Software without restriction, including
  3114. // without limitation the rights to use, copy, modify, merge, publish,
  3115. // distribute, sublicense, and/or sell copies of the Software, and to permit
  3116. // persons to whom the Software is furnished to do so, subject to the
  3117. // following conditions:
  3118. //
  3119. // The above copyright notice and this permission notice shall be included
  3120. // in all copies or substantial portions of the Software.
  3121. //
  3122. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3123. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3124. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  3125. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  3126. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  3127. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  3128. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  3129. // a passthrough stream.
  3130. // basically just the most minimal sort of Transform stream.
  3131. // Every written chunk gets output as-is.
  3132. module.exports = PassThrough;
  3133. var Transform = require('./transform.js');
  3134. var inherits = require('inherits');
  3135. inherits(PassThrough, Transform);
  3136. function PassThrough(options) {
  3137. if (!(this instanceof PassThrough))
  3138. return new PassThrough(options);
  3139. Transform.call(this, options);
  3140. }
  3141. PassThrough.prototype._transform = function(chunk, encoding, cb) {
  3142. cb(null, chunk);
  3143. };
  3144. },{"./transform.js":23,"inherits":10}],22:[function(require,module,exports){
  3145. (function (process){
  3146. // Copyright Joyent, Inc. and other Node contributors.
  3147. //
  3148. // Permission is hereby granted, free of charge, to any person obtaining a
  3149. // copy of this software and associated documentation files (the
  3150. // "Software"), to deal in the Software without restriction, including
  3151. // without limitation the rights to use, copy, modify, merge, publish,
  3152. // distribute, sublicense, and/or sell copies of the Software, and to permit
  3153. // persons to whom the Software is furnished to do so, subject to the
  3154. // following conditions:
  3155. //
  3156. // The above copyright notice and this permission notice shall be included
  3157. // in all copies or substantial portions of the Software.
  3158. //
  3159. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3160. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3161. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  3162. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  3163. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  3164. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  3165. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  3166. module.exports = Readable;
  3167. Readable.ReadableState = ReadableState;
  3168. var EE = require('events').EventEmitter;
  3169. var Stream = require('./index.js');
  3170. var Buffer = require('buffer').Buffer;
  3171. var setImmediate = require('process/browser.js').nextTick;
  3172. var StringDecoder;
  3173. var inherits = require('inherits');
  3174. inherits(Readable, Stream);
  3175. function ReadableState(options, stream) {
  3176. options = options || {};
  3177. // the point at which it stops calling _read() to fill the buffer
  3178. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  3179. var hwm = options.highWaterMark;
  3180. this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
  3181. // cast to ints.
  3182. this.highWaterMark = ~~this.highWaterMark;
  3183. this.buffer = [];
  3184. this.length = 0;
  3185. this.pipes = null;
  3186. this.pipesCount = 0;
  3187. this.flowing = false;
  3188. this.ended = false;
  3189. this.endEmitted = false;
  3190. this.reading = false;
  3191. // In streams that never have any data, and do push(null) right away,
  3192. // the consumer can miss the 'end' event if they do some I/O before
  3193. // consuming the stream. So, we don't emit('end') until some reading
  3194. // happens.
  3195. this.calledRead = false;
  3196. // a flag to be able to tell if the onwrite cb is called immediately,
  3197. // or on a later tick. We set this to true at first, becuase any
  3198. // actions that shouldn't happen until "later" should generally also
  3199. // not happen before the first write call.
  3200. this.sync = true;
  3201. // whenever we return null, then we set a flag to say
  3202. // that we're awaiting a 'readable' event emission.
  3203. this.needReadable = false;
  3204. this.emittedReadable = false;
  3205. this.readableListening = false;
  3206. // object stream flag. Used to make read(n) ignore n and to
  3207. // make all the buffer merging and length checks go away
  3208. this.objectMode = !!options.objectMode;
  3209. // Crypto is kind of old and crusty. Historically, its default string
  3210. // encoding is 'binary' so we have to make this configurable.
  3211. // Everything else in the universe uses 'utf8', though.
  3212. this.defaultEncoding = options.defaultEncoding || 'utf8';
  3213. // when piping, we only care about 'readable' events that happen
  3214. // after read()ing all the bytes and not getting any pushback.
  3215. this.ranOut = false;
  3216. // the number of writers that are awaiting a drain event in .pipe()s
  3217. this.awaitDrain = 0;
  3218. // if true, a maybeReadMore has been scheduled
  3219. this.readingMore = false;
  3220. this.decoder = null;
  3221. this.encoding = null;
  3222. if (options.encoding) {
  3223. if (!StringDecoder)
  3224. StringDecoder = require('string_decoder').StringDecoder;
  3225. this.decoder = new StringDecoder(options.encoding);
  3226. this.encoding = options.encoding;
  3227. }
  3228. }
  3229. function Readable(options) {
  3230. if (!(this instanceof Readable))
  3231. return new Readable(options);
  3232. this._readableState = new ReadableState(options, this);
  3233. // legacy
  3234. this.readable = true;
  3235. Stream.call(this);
  3236. }
  3237. // Manually shove something into the read() buffer.
  3238. // This returns true if the highWaterMark has not been hit yet,
  3239. // similar to how Writable.write() returns true if you should
  3240. // write() some more.
  3241. Readable.prototype.push = function(chunk, encoding) {
  3242. var state = this._readableState;
  3243. if (typeof chunk === 'string' && !state.objectMode) {
  3244. encoding = encoding || state.defaultEncoding;
  3245. if (encoding !== state.encoding) {
  3246. chunk = new Buffer(chunk, encoding);
  3247. encoding = '';
  3248. }
  3249. }
  3250. return readableAddChunk(this, state, chunk, encoding, false);
  3251. };
  3252. // Unshift should *always* be something directly out of read()
  3253. Readable.prototype.unshift = function(chunk) {
  3254. var state = this._readableState;
  3255. return readableAddChunk(this, state, chunk, '', true);
  3256. };
  3257. function readableAddChunk(stream, state, chunk, encoding, addToFront) {
  3258. var er = chunkInvalid(state, chunk);
  3259. if (er) {
  3260. stream.emit('error', er);
  3261. } else if (chunk === null || chunk === undefined) {
  3262. state.reading = false;
  3263. if (!state.ended)
  3264. onEofChunk(stream, state);
  3265. } else if (state.objectMode || chunk && chunk.length > 0) {
  3266. if (state.ended && !addToFront) {
  3267. var e = new Error('stream.push() after EOF');
  3268. stream.emit('error', e);
  3269. } else if (state.endEmitted && addToFront) {
  3270. var e = new Error('stream.unshift() after end event');
  3271. stream.emit('error', e);
  3272. } else {
  3273. if (state.decoder && !addToFront && !encoding)
  3274. chunk = state.decoder.write(chunk);
  3275. // update the buffer info.
  3276. state.length += state.objectMode ? 1 : chunk.length;
  3277. if (addToFront) {
  3278. state.buffer.unshift(chunk);
  3279. } else {
  3280. state.reading = false;
  3281. state.buffer.push(chunk);
  3282. }
  3283. if (state.needReadable)
  3284. emitReadable(stream);
  3285. maybeReadMore(stream, state);
  3286. }
  3287. } else if (!addToFront) {
  3288. state.reading = false;
  3289. }
  3290. return needMoreData(state);
  3291. }
  3292. // if it's past the high water mark, we can push in some more.
  3293. // Also, if we have no data yet, we can stand some
  3294. // more bytes. This is to work around cases where hwm=0,
  3295. // such as the repl. Also, if the push() triggered a
  3296. // readable event, and the user called read(largeNumber) such that
  3297. // needReadable was set, then we ought to push more, so that another
  3298. // 'readable' event will be triggered.
  3299. function needMoreData(state) {
  3300. return !state.ended &&
  3301. (state.needReadable ||
  3302. state.length < state.highWaterMark ||
  3303. state.length === 0);
  3304. }
  3305. // backwards compatibility.
  3306. Readable.prototype.setEncoding = function(enc) {
  3307. if (!StringDecoder)
  3308. StringDecoder = require('string_decoder').StringDecoder;
  3309. this._readableState.decoder = new StringDecoder(enc);
  3310. this._readableState.encoding = enc;
  3311. };
  3312. // Don't raise the hwm > 128MB
  3313. var MAX_HWM = 0x800000;
  3314. function roundUpToNextPowerOf2(n) {
  3315. if (n >= MAX_HWM) {
  3316. n = MAX_HWM;
  3317. } else {
  3318. // Get the next highest power of 2
  3319. n--;
  3320. for (var p = 1; p < 32; p <<= 1) n |= n >> p;
  3321. n++;
  3322. }
  3323. return n;
  3324. }
  3325. function howMuchToRead(n, state) {
  3326. if (state.length === 0 && state.ended)
  3327. return 0;
  3328. if (state.objectMode)
  3329. return n === 0 ? 0 : 1;
  3330. if (isNaN(n) || n === null) {
  3331. // only flow one buffer at a time
  3332. if (state.flowing && state.buffer.length)
  3333. return state.buffer[0].length;
  3334. else
  3335. return state.length;
  3336. }
  3337. if (n <= 0)
  3338. return 0;
  3339. // If we're asking for more than the target buffer level,
  3340. // then raise the water mark. Bump up to the next highest
  3341. // power of 2, to prevent increasing it excessively in tiny
  3342. // amounts.
  3343. if (n > state.highWaterMark)
  3344. state.highWaterMark = roundUpToNextPowerOf2(n);
  3345. // don't have that much. return null, unless we've ended.
  3346. if (n > state.length) {
  3347. if (!state.ended) {
  3348. state.needReadable = true;
  3349. return 0;
  3350. } else
  3351. return state.length;
  3352. }
  3353. return n;
  3354. }
  3355. // you can override either this method, or the async _read(n) below.
  3356. Readable.prototype.read = function(n) {
  3357. var state = this._readableState;
  3358. state.calledRead = true;
  3359. var nOrig = n;
  3360. if (typeof n !== 'number' || n > 0)
  3361. state.emittedReadable = false;
  3362. // if we're doing read(0) to trigger a readable event, but we
  3363. // already have a bunch of data in the buffer, then just trigger
  3364. // the 'readable' event and move on.
  3365. if (n === 0 &&
  3366. state.needReadable &&
  3367. (state.length >= state.highWaterMark || state.ended)) {
  3368. emitReadable(this);
  3369. return null;
  3370. }
  3371. n = howMuchToRead(n, state);
  3372. // if we've ended, and we're now clear, then finish it up.
  3373. if (n === 0 && state.ended) {
  3374. if (state.length === 0)
  3375. endReadable(this);
  3376. return null;
  3377. }
  3378. // All the actual chunk generation logic needs to be
  3379. // *below* the call to _read. The reason is that in certain
  3380. // synthetic stream cases, such as passthrough streams, _read
  3381. // may be a completely synchronous operation which may change
  3382. // the state of the read buffer, providing enough data when
  3383. // before there was *not* enough.
  3384. //
  3385. // So, the steps are:
  3386. // 1. Figure out what the state of things will be after we do
  3387. // a read from the buffer.
  3388. //
  3389. // 2. If that resulting state will trigger a _read, then call _read.
  3390. // Note that this may be asynchronous, or synchronous. Yes, it is
  3391. // deeply ugly to write APIs this way, but that still doesn't mean
  3392. // that the Readable class should behave improperly, as streams are
  3393. // designed to be sync/async agnostic.
  3394. // Take note if the _read call is sync or async (ie, if the read call
  3395. // has returned yet), so that we know whether or not it's safe to emit
  3396. // 'readable' etc.
  3397. //
  3398. // 3. Actually pull the requested chunks out of the buffer and return.
  3399. // if we need a readable event, then we need to do some reading.
  3400. var doRead = state.needReadable;
  3401. // if we currently have less than the highWaterMark, then also read some
  3402. if (state.length - n <= state.highWaterMark)
  3403. doRead = true;
  3404. // however, if we've ended, then there's no point, and if we're already
  3405. // reading, then it's unnecessary.
  3406. if (state.ended || state.reading)
  3407. doRead = false;
  3408. if (doRead) {
  3409. state.reading = true;
  3410. state.sync = true;
  3411. // if the length is currently zero, then we *need* a readable event.
  3412. if (state.length === 0)
  3413. state.needReadable = true;
  3414. // call internal read method
  3415. this._read(state.highWaterMark);
  3416. state.sync = false;
  3417. }
  3418. // If _read called its callback synchronously, then `reading`
  3419. // will be false, and we need to re-evaluate how much data we
  3420. // can return to the user.
  3421. if (doRead && !state.reading)
  3422. n = howMuchToRead(nOrig, state);
  3423. var ret;
  3424. if (n > 0)
  3425. ret = fromList(n, state);
  3426. else
  3427. ret = null;
  3428. if (ret === null) {
  3429. state.needReadable = true;
  3430. n = 0;
  3431. }
  3432. state.length -= n;
  3433. // If we have nothing in the buffer, then we want to know
  3434. // as soon as we *do* get something into the buffer.
  3435. if (state.length === 0 && !state.ended)
  3436. state.needReadable = true;
  3437. // If we happened to read() exactly the remaining amount in the
  3438. // buffer, and the EOF has been seen at this point, then make sure
  3439. // that we emit 'end' on the very next tick.
  3440. if (state.ended && !state.endEmitted && state.length === 0)
  3441. endReadable(this);
  3442. return ret;
  3443. };
  3444. function chunkInvalid(state, chunk) {
  3445. var er = null;
  3446. if (!Buffer.isBuffer(chunk) &&
  3447. 'string' !== typeof chunk &&
  3448. chunk !== null &&
  3449. chunk !== undefined &&
  3450. !state.objectMode &&
  3451. !er) {
  3452. er = new TypeError('Invalid non-string/buffer chunk');
  3453. }
  3454. return er;
  3455. }
  3456. function onEofChunk(stream, state) {
  3457. if (state.decoder && !state.ended) {
  3458. var chunk = state.decoder.end();
  3459. if (chunk && chunk.length) {
  3460. state.buffer.push(chunk);
  3461. state.length += state.objectMode ? 1 : chunk.length;
  3462. }
  3463. }
  3464. state.ended = true;
  3465. // if we've ended and we have some data left, then emit
  3466. // 'readable' now to make sure it gets picked up.
  3467. if (state.length > 0)
  3468. emitReadable(stream);
  3469. else
  3470. endReadable(stream);
  3471. }
  3472. // Don't emit readable right away in sync mode, because this can trigger
  3473. // another read() call => stack overflow. This way, it might trigger
  3474. // a nextTick recursion warning, but that's not so bad.
  3475. function emitReadable(stream) {
  3476. var state = stream._readableState;
  3477. state.needReadable = false;
  3478. if (state.emittedReadable)
  3479. return;
  3480. state.emittedReadable = true;
  3481. if (state.sync)
  3482. setImmediate(function() {
  3483. emitReadable_(stream);
  3484. });
  3485. else
  3486. emitReadable_(stream);
  3487. }
  3488. function emitReadable_(stream) {
  3489. stream.emit('readable');
  3490. }
  3491. // at this point, the user has presumably seen the 'readable' event,
  3492. // and called read() to consume some data. that may have triggered
  3493. // in turn another _read(n) call, in which case reading = true if
  3494. // it's in progress.
  3495. // However, if we're not ended, or reading, and the length < hwm,
  3496. // then go ahead and try to read some more preemptively.
  3497. function maybeReadMore(stream, state) {
  3498. if (!state.readingMore) {
  3499. state.readingMore = true;
  3500. setImmediate(function() {
  3501. maybeReadMore_(stream, state);
  3502. });
  3503. }
  3504. }
  3505. function maybeReadMore_(stream, state) {
  3506. var len = state.length;
  3507. while (!state.reading && !state.flowing && !state.ended &&
  3508. state.length < state.highWaterMark) {
  3509. stream.read(0);
  3510. if (len === state.length)
  3511. // didn't get any data, stop spinning.
  3512. break;
  3513. else
  3514. len = state.length;
  3515. }
  3516. state.readingMore = false;
  3517. }
  3518. // abstract method. to be overridden in specific implementation classes.
  3519. // call cb(er, data) where data is <= n in length.
  3520. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  3521. // arbitrary, and perhaps not very meaningful.
  3522. Readable.prototype._read = function(n) {
  3523. this.emit('error', new Error('not implemented'));
  3524. };
  3525. Readable.prototype.pipe = function(dest, pipeOpts) {
  3526. var src = this;
  3527. var state = this._readableState;
  3528. switch (state.pipesCount) {
  3529. case 0:
  3530. state.pipes = dest;
  3531. break;
  3532. case 1:
  3533. state.pipes = [state.pipes, dest];
  3534. break;
  3535. default:
  3536. state.pipes.push(dest);
  3537. break;
  3538. }
  3539. state.pipesCount += 1;
  3540. var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
  3541. dest !== process.stdout &&
  3542. dest !== process.stderr;
  3543. var endFn = doEnd ? onend : cleanup;
  3544. if (state.endEmitted)
  3545. setImmediate(endFn);
  3546. else
  3547. src.once('end', endFn);
  3548. dest.on('unpipe', onunpipe);
  3549. function onunpipe(readable) {
  3550. if (readable !== src) return;
  3551. cleanup();
  3552. }
  3553. function onend() {
  3554. dest.end();
  3555. }
  3556. // when the dest drains, it reduces the awaitDrain counter
  3557. // on the source. This would be more elegant with a .once()
  3558. // handler in flow(), but adding and removing repeatedly is
  3559. // too slow.
  3560. var ondrain = pipeOnDrain(src);
  3561. dest.on('drain', ondrain);
  3562. function cleanup() {
  3563. // cleanup event handlers once the pipe is broken
  3564. dest.removeListener('close', onclose);
  3565. dest.removeListener('finish', onfinish);
  3566. dest.removeListener('drain', ondrain);
  3567. dest.removeListener('error', onerror);
  3568. dest.removeListener('unpipe', onunpipe);
  3569. src.removeListener('end', onend);
  3570. src.removeListener('end', cleanup);
  3571. // if the reader is waiting for a drain event from this
  3572. // specific writer, then it would cause it to never start
  3573. // flowing again.
  3574. // So, if this is awaiting a drain, then we just call it now.
  3575. // If we don't know, then assume that we are waiting for one.
  3576. if (!dest._writableState || dest._writableState.needDrain)
  3577. ondrain();
  3578. }
  3579. // if the dest has an error, then stop piping into it.
  3580. // however, don't suppress the throwing behavior for this.
  3581. // check for listeners before emit removes one-time listeners.
  3582. var errListeners = EE.listenerCount(dest, 'error');
  3583. function onerror(er) {
  3584. unpipe();
  3585. if (errListeners === 0 && EE.listenerCount(dest, 'error') === 0)
  3586. dest.emit('error', er);
  3587. }
  3588. dest.once('error', onerror);
  3589. // Both close and finish should trigger unpipe, but only once.
  3590. function onclose() {
  3591. dest.removeListener('finish', onfinish);
  3592. unpipe();
  3593. }
  3594. dest.once('close', onclose);
  3595. function onfinish() {
  3596. dest.removeListener('close', onclose);
  3597. unpipe();
  3598. }
  3599. dest.once('finish', onfinish);
  3600. function unpipe() {
  3601. src.unpipe(dest);
  3602. }
  3603. // tell the dest that it's being piped to
  3604. dest.emit('pipe', src);
  3605. // start the flow if it hasn't been started already.
  3606. if (!state.flowing) {
  3607. // the handler that waits for readable events after all
  3608. // the data gets sucked out in flow.
  3609. // This would be easier to follow with a .once() handler
  3610. // in flow(), but that is too slow.
  3611. this.on('readable', pipeOnReadable);
  3612. state.flowing = true;
  3613. setImmediate(function() {
  3614. flow(src);
  3615. });
  3616. }
  3617. return dest;
  3618. };
  3619. function pipeOnDrain(src) {
  3620. return function() {
  3621. var dest = this;
  3622. var state = src._readableState;
  3623. state.awaitDrain--;
  3624. if (state.awaitDrain === 0)
  3625. flow(src);
  3626. };
  3627. }
  3628. function flow(src) {
  3629. var state = src._readableState;
  3630. var chunk;
  3631. state.awaitDrain = 0;
  3632. function write(dest, i, list) {
  3633. var written = dest.write(chunk);
  3634. if (false === written) {
  3635. state.awaitDrain++;
  3636. }
  3637. }
  3638. while (state.pipesCount && null !== (chunk = src.read())) {
  3639. if (state.pipesCount === 1)
  3640. write(state.pipes, 0, null);
  3641. else
  3642. forEach(state.pipes, write);
  3643. src.emit('data', chunk);
  3644. // if anyone needs a drain, then we have to wait for that.
  3645. if (state.awaitDrain > 0)
  3646. return;
  3647. }
  3648. // if every destination was unpiped, either before entering this
  3649. // function, or in the while loop, then stop flowing.
  3650. //
  3651. // NB: This is a pretty rare edge case.
  3652. if (state.pipesCount === 0) {
  3653. state.flowing = false;
  3654. // if there were data event listeners added, then switch to old mode.
  3655. if (EE.listenerCount(src, 'data') > 0)
  3656. emitDataEvents(src);
  3657. return;
  3658. }
  3659. // at this point, no one needed a drain, so we just ran out of data
  3660. // on the next readable event, start it over again.
  3661. state.ranOut = true;
  3662. }
  3663. function pipeOnReadable() {
  3664. if (this._readableState.ranOut) {
  3665. this._readableState.ranOut = false;
  3666. flow(this);
  3667. }
  3668. }
  3669. Readable.prototype.unpipe = function(dest) {
  3670. var state = this._readableState;
  3671. // if we're not piping anywhere, then do nothing.
  3672. if (state.pipesCount === 0)
  3673. return this;
  3674. // just one destination. most common case.
  3675. if (state.pipesCount === 1) {
  3676. // passed in one, but it's not the right one.
  3677. if (dest && dest !== state.pipes)
  3678. return this;
  3679. if (!dest)
  3680. dest = state.pipes;
  3681. // got a match.
  3682. state.pipes = null;
  3683. state.pipesCount = 0;
  3684. this.removeListener('readable', pipeOnReadable);
  3685. state.flowing = false;
  3686. if (dest)
  3687. dest.emit('unpipe', this);
  3688. return this;
  3689. }
  3690. // slow case. multiple pipe destinations.
  3691. if (!dest) {
  3692. // remove all.
  3693. var dests = state.pipes;
  3694. var len = state.pipesCount;
  3695. state.pipes = null;
  3696. state.pipesCount = 0;
  3697. this.removeListener('readable', pipeOnReadable);
  3698. state.flowing = false;
  3699. for (var i = 0; i < len; i++)
  3700. dests[i].emit('unpipe', this);
  3701. return this;
  3702. }
  3703. // try to find the right one.
  3704. var i = indexOf(state.pipes, dest);
  3705. if (i === -1)
  3706. return this;
  3707. state.pipes.splice(i, 1);
  3708. state.pipesCount -= 1;
  3709. if (state.pipesCount === 1)
  3710. state.pipes = state.pipes[0];
  3711. dest.emit('unpipe', this);
  3712. return this;
  3713. };
  3714. // set up data events if they are asked for
  3715. // Ensure readable listeners eventually get something
  3716. Readable.prototype.on = function(ev, fn) {
  3717. var res = Stream.prototype.on.call(this, ev, fn);
  3718. if (ev === 'data' && !this._readableState.flowing)
  3719. emitDataEvents(this);
  3720. if (ev === 'readable' && this.readable) {
  3721. var state = this._readableState;
  3722. if (!state.readableListening) {
  3723. state.readableListening = true;
  3724. state.emittedReadable = false;
  3725. state.needReadable = true;
  3726. if (!state.reading) {
  3727. this.read(0);
  3728. } else if (state.length) {
  3729. emitReadable(this, state);
  3730. }
  3731. }
  3732. }
  3733. return res;
  3734. };
  3735. Readable.prototype.addListener = Readable.prototype.on;
  3736. // pause() and resume() are remnants of the legacy readable stream API
  3737. // If the user uses them, then switch into old mode.
  3738. Readable.prototype.resume = function() {
  3739. emitDataEvents(this);
  3740. this.read(0);
  3741. this.emit('resume');
  3742. };
  3743. Readable.prototype.pause = function() {
  3744. emitDataEvents(this, true);
  3745. this.emit('pause');
  3746. };
  3747. function emitDataEvents(stream, startPaused) {
  3748. var state = stream._readableState;
  3749. if (state.flowing) {
  3750. // https://github.com/isaacs/readable-stream/issues/16
  3751. throw new Error('Cannot switch to old mode now.');
  3752. }
  3753. var paused = startPaused || false;
  3754. var readable = false;
  3755. // convert to an old-style stream.
  3756. stream.readable = true;
  3757. stream.pipe = Stream.prototype.pipe;
  3758. stream.on = stream.addListener = Stream.prototype.on;
  3759. stream.on('readable', function() {
  3760. readable = true;
  3761. var c;
  3762. while (!paused && (null !== (c = stream.read())))
  3763. stream.emit('data', c);
  3764. if (c === null) {
  3765. readable = false;
  3766. stream._readableState.needReadable = true;
  3767. }
  3768. });
  3769. stream.pause = function() {
  3770. paused = true;
  3771. this.emit('pause');
  3772. };
  3773. stream.resume = function() {
  3774. paused = false;
  3775. if (readable)
  3776. setImmediate(function() {
  3777. stream.emit('readable');
  3778. });
  3779. else
  3780. this.read(0);
  3781. this.emit('resume');
  3782. };
  3783. // now make it start, just in case it hadn't already.
  3784. stream.emit('readable');
  3785. }
  3786. // wrap an old-style stream as the async data source.
  3787. // This is *not* part of the readable stream interface.
  3788. // It is an ugly unfortunate mess of history.
  3789. Readable.prototype.wrap = function(stream) {
  3790. var state = this._readableState;
  3791. var paused = false;
  3792. var self = this;
  3793. stream.on('end', function() {
  3794. if (state.decoder && !state.ended) {
  3795. var chunk = state.decoder.end();
  3796. if (chunk && chunk.length)
  3797. self.push(chunk);
  3798. }
  3799. self.push(null);
  3800. });
  3801. stream.on('data', function(chunk) {
  3802. if (state.decoder)
  3803. chunk = state.decoder.write(chunk);
  3804. if (!chunk || !state.objectMode && !chunk.length)
  3805. return;
  3806. var ret = self.push(chunk);
  3807. if (!ret) {
  3808. paused = true;
  3809. stream.pause();
  3810. }
  3811. });
  3812. // proxy all the other methods.
  3813. // important when wrapping filters and duplexes.
  3814. for (var i in stream) {
  3815. if (typeof stream[i] === 'function' &&
  3816. typeof this[i] === 'undefined') {
  3817. this[i] = function(method) { return function() {
  3818. return stream[method].apply(stream, arguments);
  3819. }}(i);
  3820. }
  3821. }
  3822. // proxy certain important events.
  3823. var events = ['error', 'close', 'destroy', 'pause', 'resume'];
  3824. forEach(events, function(ev) {
  3825. stream.on(ev, function (x) {
  3826. return self.emit.apply(self, ev, x);
  3827. });
  3828. });
  3829. // when we try to consume some more bytes, simply unpause the
  3830. // underlying stream.
  3831. self._read = function(n) {
  3832. if (paused) {
  3833. paused = false;
  3834. stream.resume();
  3835. }
  3836. };
  3837. return self;
  3838. };
  3839. // exposed for testing purposes only.
  3840. Readable._fromList = fromList;
  3841. // Pluck off n bytes from an array of buffers.
  3842. // Length is the combined lengths of all the buffers in the list.
  3843. function fromList(n, state) {
  3844. var list = state.buffer;
  3845. var length = state.length;
  3846. var stringMode = !!state.decoder;
  3847. var objectMode = !!state.objectMode;
  3848. var ret;
  3849. // nothing in the list, definitely empty.
  3850. if (list.length === 0)
  3851. return null;
  3852. if (length === 0)
  3853. ret = null;
  3854. else if (objectMode)
  3855. ret = list.shift();
  3856. else if (!n || n >= length) {
  3857. // read it all, truncate the array.
  3858. if (stringMode)
  3859. ret = list.join('');
  3860. else
  3861. ret = Buffer.concat(list, length);
  3862. list.length = 0;
  3863. } else {
  3864. // read just some of it.
  3865. if (n < list[0].length) {
  3866. // just take a part of the first list item.
  3867. // slice is the same for buffers and strings.
  3868. var buf = list[0];
  3869. ret = buf.slice(0, n);
  3870. list[0] = buf.slice(n);
  3871. } else if (n === list[0].length) {
  3872. // first list is a perfect match
  3873. ret = list.shift();
  3874. } else {
  3875. // complex case.
  3876. // we have enough to cover it, but it spans past the first buffer.
  3877. if (stringMode)
  3878. ret = '';
  3879. else
  3880. ret = new Buffer(n);
  3881. var c = 0;
  3882. for (var i = 0, l = list.length; i < l && c < n; i++) {
  3883. var buf = list[0];
  3884. var cpy = Math.min(n - c, buf.length);
  3885. if (stringMode)
  3886. ret += buf.slice(0, cpy);
  3887. else
  3888. buf.copy(ret, c, 0, cpy);
  3889. if (cpy < buf.length)
  3890. list[0] = buf.slice(cpy);
  3891. else
  3892. list.shift();
  3893. c += cpy;
  3894. }
  3895. }
  3896. }
  3897. return ret;
  3898. }
  3899. function endReadable(stream) {
  3900. var state = stream._readableState;
  3901. // If we get here before consuming all the bytes, then that is a
  3902. // bug in node. Should never happen.
  3903. if (state.length > 0)
  3904. throw new Error('endReadable called on non-empty stream');
  3905. if (!state.endEmitted && state.calledRead) {
  3906. state.ended = true;
  3907. setImmediate(function() {
  3908. // Check that we didn't get one last unshift.
  3909. if (!state.endEmitted && state.length === 0) {
  3910. state.endEmitted = true;
  3911. stream.readable = false;
  3912. stream.emit('end');
  3913. }
  3914. });
  3915. }
  3916. }
  3917. function forEach (xs, f) {
  3918. for (var i = 0, l = xs.length; i < l; i++) {
  3919. f(xs[i], i);
  3920. }
  3921. }
  3922. function indexOf (xs, x) {
  3923. for (var i = 0, l = xs.length; i < l; i++) {
  3924. if (xs[i] === x) return i;
  3925. }
  3926. return -1;
  3927. }
  3928. }).call(this,require("g5I+bs"))
  3929. },{"./index.js":19,"buffer":3,"events":5,"g5I+bs":13,"inherits":10,"process/browser.js":20,"string_decoder":25}],23:[function(require,module,exports){
  3930. // Copyright Joyent, Inc. and other Node contributors.
  3931. //
  3932. // Permission is hereby granted, free of charge, to any person obtaining a
  3933. // copy of this software and associated documentation files (the
  3934. // "Software"), to deal in the Software without restriction, including
  3935. // without limitation the rights to use, copy, modify, merge, publish,
  3936. // distribute, sublicense, and/or sell copies of the Software, and to permit
  3937. // persons to whom the Software is furnished to do so, subject to the
  3938. // following conditions:
  3939. //
  3940. // The above copyright notice and this permission notice shall be included
  3941. // in all copies or substantial portions of the Software.
  3942. //
  3943. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3944. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3945. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  3946. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  3947. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  3948. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  3949. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  3950. // a transform stream is a readable/writable stream where you do
  3951. // something with the data. Sometimes it's called a "filter",
  3952. // but that's not a great name for it, since that implies a thing where
  3953. // some bits pass through, and others are simply ignored. (That would
  3954. // be a valid example of a transform, of course.)
  3955. //
  3956. // While the output is causally related to the input, it's not a
  3957. // necessarily symmetric or synchronous transformation. For example,
  3958. // a zlib stream might take multiple plain-text writes(), and then
  3959. // emit a single compressed chunk some time in the future.
  3960. //
  3961. // Here's how this works:
  3962. //
  3963. // The Transform stream has all the aspects of the readable and writable
  3964. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  3965. // internally, and returns false if there's a lot of pending writes
  3966. // buffered up. When you call read(), that calls _read(n) until
  3967. // there's enough pending readable data buffered up.
  3968. //
  3969. // In a transform stream, the written data is placed in a buffer. When
  3970. // _read(n) is called, it transforms the queued up data, calling the
  3971. // buffered _write cb's as it consumes chunks. If consuming a single
  3972. // written chunk would result in multiple output chunks, then the first
  3973. // outputted bit calls the readcb, and subsequent chunks just go into
  3974. // the read buffer, and will cause it to emit 'readable' if necessary.
  3975. //
  3976. // This way, back-pressure is actually determined by the reading side,
  3977. // since _read has to be called to start processing a new chunk. However,
  3978. // a pathological inflate type of transform can cause excessive buffering
  3979. // here. For example, imagine a stream where every byte of input is
  3980. // interpreted as an integer from 0-255, and then results in that many
  3981. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  3982. // 1kb of data being output. In this case, you could write a very small
  3983. // amount of input, and end up with a very large amount of output. In
  3984. // such a pathological inflating mechanism, there'd be no way to tell
  3985. // the system to stop doing the transform. A single 4MB write could
  3986. // cause the system to run out of memory.
  3987. //
  3988. // However, even in such a pathological case, only a single written chunk
  3989. // would be consumed, and then the rest would wait (un-transformed) until
  3990. // the results of the previous transformed chunk were consumed.
  3991. module.exports = Transform;
  3992. var Duplex = require('./duplex.js');
  3993. var inherits = require('inherits');
  3994. inherits(Transform, Duplex);
  3995. function TransformState(options, stream) {
  3996. this.afterTransform = function(er, data) {
  3997. return afterTransform(stream, er, data);
  3998. };
  3999. this.needTransform = false;
  4000. this.transforming = false;
  4001. this.writecb = null;
  4002. this.writechunk = null;
  4003. }
  4004. function afterTransform(stream, er, data) {
  4005. var ts = stream._transformState;
  4006. ts.transforming = false;
  4007. var cb = ts.writecb;
  4008. if (!cb)
  4009. return stream.emit('error', new Error('no writecb in Transform class'));
  4010. ts.writechunk = null;
  4011. ts.writecb = null;
  4012. if (data !== null && data !== undefined)
  4013. stream.push(data);
  4014. if (cb)
  4015. cb(er);
  4016. var rs = stream._readableState;
  4017. rs.reading = false;
  4018. if (rs.needReadable || rs.length < rs.highWaterMark) {
  4019. stream._read(rs.highWaterMark);
  4020. }
  4021. }
  4022. function Transform(options) {
  4023. if (!(this instanceof Transform))
  4024. return new Transform(options);
  4025. Duplex.call(this, options);
  4026. var ts = this._transformState = new TransformState(options, this);
  4027. // when the writable side finishes, then flush out anything remaining.
  4028. var stream = this;
  4029. // start out asking for a readable event once data is transformed.
  4030. this._readableState.needReadable = true;
  4031. // we have implemented the _read method, and done the other things
  4032. // that Readable wants before the first _read call, so unset the
  4033. // sync guard flag.
  4034. this._readableState.sync = false;
  4035. this.once('finish', function() {
  4036. if ('function' === typeof this._flush)
  4037. this._flush(function(er) {
  4038. done(stream, er);
  4039. });
  4040. else
  4041. done(stream);
  4042. });
  4043. }
  4044. Transform.prototype.push = function(chunk, encoding) {
  4045. this._transformState.needTransform = false;
  4046. return Duplex.prototype.push.call(this, chunk, encoding);
  4047. };
  4048. // This is the part where you do stuff!
  4049. // override this function in implementation classes.
  4050. // 'chunk' is an input chunk.
  4051. //
  4052. // Call `push(newChunk)` to pass along transformed output
  4053. // to the readable side. You may call 'push' zero or more times.
  4054. //
  4055. // Call `cb(err)` when you are done with this chunk. If you pass
  4056. // an error, then that'll put the hurt on the whole operation. If you
  4057. // never call cb(), then you'll never get another chunk.
  4058. Transform.prototype._transform = function(chunk, encoding, cb) {
  4059. throw new Error('not implemented');
  4060. };
  4061. Transform.prototype._write = function(chunk, encoding, cb) {
  4062. var ts = this._transformState;
  4063. ts.writecb = cb;
  4064. ts.writechunk = chunk;
  4065. ts.writeencoding = encoding;
  4066. if (!ts.transforming) {
  4067. var rs = this._readableState;
  4068. if (ts.needTransform ||
  4069. rs.needReadable ||
  4070. rs.length < rs.highWaterMark)
  4071. this._read(rs.highWaterMark);
  4072. }
  4073. };
  4074. // Doesn't matter what the args are here.
  4075. // _transform does all the work.
  4076. // That we got here means that the readable side wants more data.
  4077. Transform.prototype._read = function(n) {
  4078. var ts = this._transformState;
  4079. if (ts.writechunk && ts.writecb && !ts.transforming) {
  4080. ts.transforming = true;
  4081. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  4082. } else {
  4083. // mark that we need a transform, so that any data that comes in
  4084. // will get processed, now that we've asked for it.
  4085. ts.needTransform = true;
  4086. }
  4087. };
  4088. function done(stream, er) {
  4089. if (er)
  4090. return stream.emit('error', er);
  4091. // if there's nothing in the write buffer, then that means
  4092. // that nothing more will ever be provided
  4093. var ws = stream._writableState;
  4094. var rs = stream._readableState;
  4095. var ts = stream._transformState;
  4096. if (ws.length)
  4097. throw new Error('calling transform done when ws.length != 0');
  4098. if (ts.transforming)
  4099. throw new Error('calling transform done when still transforming');
  4100. return stream.push(null);
  4101. }
  4102. },{"./duplex.js":18,"inherits":10}],24:[function(require,module,exports){
  4103. // Copyright Joyent, Inc. and other Node contributors.
  4104. //
  4105. // Permission is hereby granted, free of charge, to any person obtaining a
  4106. // copy of this software and associated documentation files (the
  4107. // "Software"), to deal in the Software without restriction, including
  4108. // without limitation the rights to use, copy, modify, merge, publish,
  4109. // distribute, sublicense, and/or sell copies of the Software, and to permit
  4110. // persons to whom the Software is furnished to do so, subject to the
  4111. // following conditions:
  4112. //
  4113. // The above copyright notice and this permission notice shall be included
  4114. // in all copies or substantial portions of the Software.
  4115. //
  4116. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  4117. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  4118. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  4119. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  4120. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  4121. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  4122. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  4123. // A bit simpler than readable streams.
  4124. // Implement an async ._write(chunk, cb), and it'll handle all
  4125. // the drain event emission and buffering.
  4126. module.exports = Writable;
  4127. Writable.WritableState = WritableState;
  4128. var isUint8Array = typeof Uint8Array !== 'undefined'
  4129. ? function (x) { return x instanceof Uint8Array }
  4130. : function (x) {
  4131. return x && x.constructor && x.constructor.name === 'Uint8Array'
  4132. }
  4133. ;
  4134. var isArrayBuffer = typeof ArrayBuffer !== 'undefined'
  4135. ? function (x) { return x instanceof ArrayBuffer }
  4136. : function (x) {
  4137. return x && x.constructor && x.constructor.name === 'ArrayBuffer'
  4138. }
  4139. ;
  4140. var inherits = require('inherits');
  4141. var Stream = require('./index.js');
  4142. var setImmediate = require('process/browser.js').nextTick;
  4143. var Buffer = require('buffer').Buffer;
  4144. inherits(Writable, Stream);
  4145. function WriteReq(chunk, encoding, cb) {
  4146. this.chunk = chunk;
  4147. this.encoding = encoding;
  4148. this.callback = cb;
  4149. }
  4150. function WritableState(options, stream) {
  4151. options = options || {};
  4152. // the point at which write() starts returning false
  4153. // Note: 0 is a valid value, means that we always return false if
  4154. // the entire buffer is not flushed immediately on write()
  4155. var hwm = options.highWaterMark;
  4156. this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
  4157. // object stream flag to indicate whether or not this stream
  4158. // contains buffers or objects.
  4159. this.objectMode = !!options.objectMode;
  4160. // cast to ints.
  4161. this.highWaterMark = ~~this.highWaterMark;
  4162. this.needDrain = false;
  4163. // at the start of calling end()
  4164. this.ending = false;
  4165. // when end() has been called, and returned
  4166. this.ended = false;
  4167. // when 'finish' is emitted
  4168. this.finished = false;
  4169. // should we decode strings into buffers before passing to _write?
  4170. // this is here so that some node-core streams can optimize string
  4171. // handling at a lower level.
  4172. var noDecode = options.decodeStrings === false;
  4173. this.decodeStrings = !noDecode;
  4174. // Crypto is kind of old and crusty. Historically, its default string
  4175. // encoding is 'binary' so we have to make this configurable.
  4176. // Everything else in the universe uses 'utf8', though.
  4177. this.defaultEncoding = options.defaultEncoding || 'utf8';
  4178. // not an actual buffer we keep track of, but a measurement
  4179. // of how much we're waiting to get pushed to some underlying
  4180. // socket or file.
  4181. this.length = 0;
  4182. // a flag to see when we're in the middle of a write.
  4183. this.writing = false;
  4184. // a flag to be able to tell if the onwrite cb is called immediately,
  4185. // or on a later tick. We set this to true at first, becuase any
  4186. // actions that shouldn't happen until "later" should generally also
  4187. // not happen before the first write call.
  4188. this.sync = true;
  4189. // a flag to know if we're processing previously buffered items, which
  4190. // may call the _write() callback in the same tick, so that we don't
  4191. // end up in an overlapped onwrite situation.
  4192. this.bufferProcessing = false;
  4193. // the callback that's passed to _write(chunk,cb)
  4194. this.onwrite = function(er) {
  4195. onwrite(stream, er);
  4196. };
  4197. // the callback that the user supplies to write(chunk,encoding,cb)
  4198. this.writecb = null;
  4199. // the amount that is being written when _write is called.
  4200. this.writelen = 0;
  4201. this.buffer = [];
  4202. }
  4203. function Writable(options) {
  4204. // Writable ctor is applied to Duplexes, though they're not
  4205. // instanceof Writable, they're instanceof Readable.
  4206. if (!(this instanceof Writable) && !(this instanceof Stream.Duplex))
  4207. return new Writable(options);
  4208. this._writableState = new WritableState(options, this);
  4209. // legacy.
  4210. this.writable = true;
  4211. Stream.call(this);
  4212. }
  4213. // Otherwise people can pipe Writable streams, which is just wrong.
  4214. Writable.prototype.pipe = function() {
  4215. this.emit('error', new Error('Cannot pipe. Not readable.'));
  4216. };
  4217. function writeAfterEnd(stream, state, cb) {
  4218. var er = new Error('write after end');
  4219. // TODO: defer error events consistently everywhere, not just the cb
  4220. stream.emit('error', er);
  4221. setImmediate(function() {
  4222. cb(er);
  4223. });
  4224. }
  4225. // If we get something that is not a buffer, string, null, or undefined,
  4226. // and we're not in objectMode, then that's an error.
  4227. // Otherwise stream chunks are all considered to be of length=1, and the
  4228. // watermarks determine how many objects to keep in the buffer, rather than
  4229. // how many bytes or characters.
  4230. function validChunk(stream, state, chunk, cb) {
  4231. var valid = true;
  4232. if (!Buffer.isBuffer(chunk) &&
  4233. 'string' !== typeof chunk &&
  4234. chunk !== null &&
  4235. chunk !== undefined &&
  4236. !state.objectMode) {
  4237. var er = new TypeError('Invalid non-string/buffer chunk');
  4238. stream.emit('error', er);
  4239. setImmediate(function() {
  4240. cb(er);
  4241. });
  4242. valid = false;
  4243. }
  4244. return valid;
  4245. }
  4246. Writable.prototype.write = function(chunk, encoding, cb) {
  4247. var state = this._writableState;
  4248. var ret = false;
  4249. if (typeof encoding === 'function') {
  4250. cb = encoding;
  4251. encoding = null;
  4252. }
  4253. if (!Buffer.isBuffer(chunk) && isUint8Array(chunk))
  4254. chunk = new Buffer(chunk);
  4255. if (isArrayBuffer(chunk) && typeof Uint8Array !== 'undefined')
  4256. chunk = new Buffer(new Uint8Array(chunk));
  4257. if (Buffer.isBuffer(chunk))
  4258. encoding = 'buffer';
  4259. else if (!encoding)
  4260. encoding = state.defaultEncoding;
  4261. if (typeof cb !== 'function')
  4262. cb = function() {};
  4263. if (state.ended)
  4264. writeAfterEnd(this, state, cb);
  4265. else if (validChunk(this, state, chunk, cb))
  4266. ret = writeOrBuffer(this, state, chunk, encoding, cb);
  4267. return ret;
  4268. };
  4269. function decodeChunk(state, chunk, encoding) {
  4270. if (!state.objectMode &&
  4271. state.decodeStrings !== false &&
  4272. typeof chunk === 'string') {
  4273. chunk = new Buffer(chunk, encoding);
  4274. }
  4275. return chunk;
  4276. }
  4277. // if we're already writing something, then just put this
  4278. // in the queue, and wait our turn. Otherwise, call _write
  4279. // If we return false, then we need a drain event, so set that flag.
  4280. function writeOrBuffer(stream, state, chunk, encoding, cb) {
  4281. chunk = decodeChunk(state, chunk, encoding);
  4282. var len = state.objectMode ? 1 : chunk.length;
  4283. state.length += len;
  4284. var ret = state.length < state.highWaterMark;
  4285. state.needDrain = !ret;
  4286. if (state.writing)
  4287. state.buffer.push(new WriteReq(chunk, encoding, cb));
  4288. else
  4289. doWrite(stream, state, len, chunk, encoding, cb);
  4290. return ret;
  4291. }
  4292. function doWrite(stream, state, len, chunk, encoding, cb) {
  4293. state.writelen = len;
  4294. state.writecb = cb;
  4295. state.writing = true;
  4296. state.sync = true;
  4297. stream._write(chunk, encoding, state.onwrite);
  4298. state.sync = false;
  4299. }
  4300. function onwriteError(stream, state, sync, er, cb) {
  4301. if (sync)
  4302. setImmediate(function() {
  4303. cb(er);
  4304. });
  4305. else
  4306. cb(er);
  4307. stream.emit('error', er);
  4308. }
  4309. function onwriteStateUpdate(state) {
  4310. state.writing = false;
  4311. state.writecb = null;
  4312. state.length -= state.writelen;
  4313. state.writelen = 0;
  4314. }
  4315. function onwrite(stream, er) {
  4316. var state = stream._writableState;
  4317. var sync = state.sync;
  4318. var cb = state.writecb;
  4319. onwriteStateUpdate(state);
  4320. if (er)
  4321. onwriteError(stream, state, sync, er, cb);
  4322. else {
  4323. // Check if we're actually ready to finish, but don't emit yet
  4324. var finished = needFinish(stream, state);
  4325. if (!finished && !state.bufferProcessing && state.buffer.length)
  4326. clearBuffer(stream, state);
  4327. if (sync) {
  4328. setImmediate(function() {
  4329. afterWrite(stream, state, finished, cb);
  4330. });
  4331. } else {
  4332. afterWrite(stream, state, finished, cb);
  4333. }
  4334. }
  4335. }
  4336. function afterWrite(stream, state, finished, cb) {
  4337. if (!finished)
  4338. onwriteDrain(stream, state);
  4339. cb();
  4340. if (finished)
  4341. finishMaybe(stream, state);
  4342. }
  4343. // Must force callback to be called on nextTick, so that we don't
  4344. // emit 'drain' before the write() consumer gets the 'false' return
  4345. // value, and has a chance to attach a 'drain' listener.
  4346. function onwriteDrain(stream, state) {
  4347. if (state.length === 0 && state.needDrain) {
  4348. state.needDrain = false;
  4349. stream.emit('drain');
  4350. }
  4351. }
  4352. // if there's something in the buffer waiting, then process it
  4353. function clearBuffer(stream, state) {
  4354. state.bufferProcessing = true;
  4355. for (var c = 0; c < state.buffer.length; c++) {
  4356. var entry = state.buffer[c];
  4357. var chunk = entry.chunk;
  4358. var encoding = entry.encoding;
  4359. var cb = entry.callback;
  4360. var len = state.objectMode ? 1 : chunk.length;
  4361. doWrite(stream, state, len, chunk, encoding, cb);
  4362. // if we didn't call the onwrite immediately, then
  4363. // it means that we need to wait until it does.
  4364. // also, that means that the chunk and cb are currently
  4365. // being processed, so move the buffer counter past them.
  4366. if (state.writing) {
  4367. c++;
  4368. break;
  4369. }
  4370. }
  4371. state.bufferProcessing = false;
  4372. if (c < state.buffer.length)
  4373. state.buffer = state.buffer.slice(c);
  4374. else
  4375. state.buffer.length = 0;
  4376. }
  4377. Writable.prototype._write = function(chunk, encoding, cb) {
  4378. cb(new Error('not implemented'));
  4379. };
  4380. Writable.prototype.end = function(chunk, encoding, cb) {
  4381. var state = this._writableState;
  4382. if (typeof chunk === 'function') {
  4383. cb = chunk;
  4384. chunk = null;
  4385. encoding = null;
  4386. } else if (typeof encoding === 'function') {
  4387. cb = encoding;
  4388. encoding = null;
  4389. }
  4390. if (typeof chunk !== 'undefined' && chunk !== null)
  4391. this.write(chunk, encoding);
  4392. // ignore unnecessary end() calls.
  4393. if (!state.ending && !state.finished)
  4394. endWritable(this, state, cb);
  4395. };
  4396. function needFinish(stream, state) {
  4397. return (state.ending &&
  4398. state.length === 0 &&
  4399. !state.finished &&
  4400. !state.writing);
  4401. }
  4402. function finishMaybe(stream, state) {
  4403. var need = needFinish(stream, state);
  4404. if (need) {
  4405. state.finished = true;
  4406. stream.emit('finish');
  4407. }
  4408. return need;
  4409. }
  4410. function endWritable(stream, state, cb) {
  4411. state.ending = true;
  4412. finishMaybe(stream, state);
  4413. if (cb) {
  4414. if (state.finished)
  4415. setImmediate(cb);
  4416. else
  4417. stream.once('finish', cb);
  4418. }
  4419. state.ended = true;
  4420. }
  4421. },{"./index.js":19,"buffer":3,"inherits":10,"process/browser.js":20}],25:[function(require,module,exports){
  4422. // Copyright Joyent, Inc. and other Node contributors.
  4423. //
  4424. // Permission is hereby granted, free of charge, to any person obtaining a
  4425. // copy of this software and associated documentation files (the
  4426. // "Software"), to deal in the Software without restriction, including
  4427. // without limitation the rights to use, copy, modify, merge, publish,
  4428. // distribute, sublicense, and/or sell copies of the Software, and to permit
  4429. // persons to whom the Software is furnished to do so, subject to the
  4430. // following conditions:
  4431. //
  4432. // The above copyright notice and this permission notice shall be included
  4433. // in all copies or substantial portions of the Software.
  4434. //
  4435. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  4436. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  4437. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  4438. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  4439. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  4440. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  4441. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  4442. var Buffer = require('buffer').Buffer;
  4443. function assertEncoding(encoding) {
  4444. if (encoding && !Buffer.isEncoding(encoding)) {
  4445. throw new Error('Unknown encoding: ' + encoding);
  4446. }
  4447. }
  4448. var StringDecoder = exports.StringDecoder = function(encoding) {
  4449. this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
  4450. assertEncoding(encoding);
  4451. switch (this.encoding) {
  4452. case 'utf8':
  4453. // CESU-8 represents each of Surrogate Pair by 3-bytes
  4454. this.surrogateSize = 3;
  4455. break;
  4456. case 'ucs2':
  4457. case 'utf16le':
  4458. // UTF-16 represents each of Surrogate Pair by 2-bytes
  4459. this.surrogateSize = 2;
  4460. this.detectIncompleteChar = utf16DetectIncompleteChar;
  4461. break;
  4462. case 'base64':
  4463. // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
  4464. this.surrogateSize = 3;
  4465. this.detectIncompleteChar = base64DetectIncompleteChar;
  4466. break;
  4467. default:
  4468. this.write = passThroughWrite;
  4469. return;
  4470. }
  4471. this.charBuffer = new Buffer(6);
  4472. this.charReceived = 0;
  4473. this.charLength = 0;
  4474. };
  4475. StringDecoder.prototype.write = function(buffer) {
  4476. var charStr = '';
  4477. var offset = 0;
  4478. // if our last write ended with an incomplete multibyte character
  4479. while (this.charLength) {
  4480. // determine how many remaining bytes this buffer has to offer for this char
  4481. var i = (buffer.length >= this.charLength - this.charReceived) ?
  4482. this.charLength - this.charReceived :
  4483. buffer.length;
  4484. // add the new bytes to the char buffer
  4485. buffer.copy(this.charBuffer, this.charReceived, offset, i);
  4486. this.charReceived += (i - offset);
  4487. offset = i;
  4488. if (this.charReceived < this.charLength) {
  4489. // still not enough chars in this buffer? wait for more ...
  4490. return '';
  4491. }
  4492. // get the character that was split
  4493. charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
  4494. // lead surrogate (D800-DBFF) is also the incomplete character
  4495. var charCode = charStr.charCodeAt(charStr.length - 1);
  4496. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  4497. this.charLength += this.surrogateSize;
  4498. charStr = '';
  4499. continue;
  4500. }
  4501. this.charReceived = this.charLength = 0;
  4502. // if there are no more bytes in this buffer, just emit our char
  4503. if (i == buffer.length) return charStr;
  4504. // otherwise cut off the characters end from the beginning of this buffer
  4505. buffer = buffer.slice(i, buffer.length);
  4506. break;
  4507. }
  4508. var lenIncomplete = this.detectIncompleteChar(buffer);
  4509. var end = buffer.length;
  4510. if (this.charLength) {
  4511. // buffer the incomplete character bytes we got
  4512. buffer.copy(this.charBuffer, 0, buffer.length - lenIncomplete, end);
  4513. this.charReceived = lenIncomplete;
  4514. end -= lenIncomplete;
  4515. }
  4516. charStr += buffer.toString(this.encoding, 0, end);
  4517. var end = charStr.length - 1;
  4518. var charCode = charStr.charCodeAt(end);
  4519. // lead surrogate (D800-DBFF) is also the incomplete character
  4520. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  4521. var size = this.surrogateSize;
  4522. this.charLength += size;
  4523. this.charReceived += size;
  4524. this.charBuffer.copy(this.charBuffer, size, 0, size);
  4525. this.charBuffer.write(charStr.charAt(charStr.length - 1), this.encoding);
  4526. return charStr.substring(0, end);
  4527. }
  4528. // or just emit the charStr
  4529. return charStr;
  4530. };
  4531. StringDecoder.prototype.detectIncompleteChar = function(buffer) {
  4532. // determine how many bytes we have to check at the end of this buffer
  4533. var i = (buffer.length >= 3) ? 3 : buffer.length;
  4534. // Figure out if one of the last i bytes of our buffer announces an
  4535. // incomplete char.
  4536. for (; i > 0; i--) {
  4537. var c = buffer[buffer.length - i];
  4538. // See http://en.wikipedia.org/wiki/UTF-8#Description
  4539. // 110XXXXX
  4540. if (i == 1 && c >> 5 == 0x06) {
  4541. this.charLength = 2;
  4542. break;
  4543. }
  4544. // 1110XXXX
  4545. if (i <= 2 && c >> 4 == 0x0E) {
  4546. this.charLength = 3;
  4547. break;
  4548. }
  4549. // 11110XXX
  4550. if (i <= 3 && c >> 3 == 0x1E) {
  4551. this.charLength = 4;
  4552. break;
  4553. }
  4554. }
  4555. return i;
  4556. };
  4557. StringDecoder.prototype.end = function(buffer) {
  4558. var res = '';
  4559. if (buffer && buffer.length)
  4560. res = this.write(buffer);
  4561. if (this.charReceived) {
  4562. var cr = this.charReceived;
  4563. var buf = this.charBuffer;
  4564. var enc = this.encoding;
  4565. res += buf.slice(0, cr).toString(enc);
  4566. }
  4567. return res;
  4568. };
  4569. function passThroughWrite(buffer) {
  4570. return buffer.toString(this.encoding);
  4571. }
  4572. function utf16DetectIncompleteChar(buffer) {
  4573. var incomplete = this.charReceived = buffer.length % 2;
  4574. this.charLength = incomplete ? 2 : 0;
  4575. return incomplete;
  4576. }
  4577. function base64DetectIncompleteChar(buffer) {
  4578. var incomplete = this.charReceived = buffer.length % 3;
  4579. this.charLength = incomplete ? 3 : 0;
  4580. return incomplete;
  4581. }
  4582. },{"buffer":3}],26:[function(require,module,exports){
  4583. // Copyright Joyent, Inc. and other Node contributors.
  4584. //
  4585. // Permission is hereby granted, free of charge, to any person obtaining a
  4586. // copy of this software and associated documentation files (the
  4587. // "Software"), to deal in the Software without restriction, including
  4588. // without limitation the rights to use, copy, modify, merge, publish,
  4589. // distribute, sublicense, and/or sell copies of the Software, and to permit
  4590. // persons to whom the Software is furnished to do so, subject to the
  4591. // following conditions:
  4592. //
  4593. // The above copyright notice and this permission notice shall be included
  4594. // in all copies or substantial portions of the Software.
  4595. //
  4596. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  4597. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  4598. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  4599. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  4600. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  4601. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  4602. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  4603. var punycode = require('punycode');
  4604. exports.parse = urlParse;
  4605. exports.resolve = urlResolve;
  4606. exports.resolveObject = urlResolveObject;
  4607. exports.format = urlFormat;
  4608. exports.Url = Url;
  4609. function Url() {
  4610. this.protocol = null;
  4611. this.slashes = null;
  4612. this.auth = null;
  4613. this.host = null;
  4614. this.port = null;
  4615. this.hostname = null;
  4616. this.hash = null;
  4617. this.search = null;
  4618. this.query = null;
  4619. this.pathname = null;
  4620. this.path = null;
  4621. this.href = null;
  4622. }
  4623. // Reference: RFC 3986, RFC 1808, RFC 2396
  4624. // define these here so at least they only have to be
  4625. // compiled once on the first module load.
  4626. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  4627. portPattern = /:[0-9]*$/,
  4628. // RFC 2396: characters reserved for delimiting URLs.
  4629. // We actually just auto-escape these.
  4630. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  4631. // RFC 2396: characters not allowed for various reasons.
  4632. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  4633. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  4634. autoEscape = ['\''].concat(unwise),
  4635. // Characters that are never ever allowed in a hostname.
  4636. // Note that any invalid chars are also handled, but these
  4637. // are the ones that are *expected* to be seen, so we fast-path
  4638. // them.
  4639. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  4640. hostEndingChars = ['/', '?', '#'],
  4641. hostnameMaxLen = 255,
  4642. hostnamePartPattern = /^[a-z0-9A-Z_-]{0,63}$/,
  4643. hostnamePartStart = /^([a-z0-9A-Z_-]{0,63})(.*)$/,
  4644. // protocols that can allow "unsafe" and "unwise" chars.
  4645. unsafeProtocol = {
  4646. 'javascript': true,
  4647. 'javascript:': true
  4648. },
  4649. // protocols that never have a hostname.
  4650. hostlessProtocol = {
  4651. 'javascript': true,
  4652. 'javascript:': true
  4653. },
  4654. // protocols that always contain a // bit.
  4655. slashedProtocol = {
  4656. 'http': true,
  4657. 'https': true,
  4658. 'ftp': true,
  4659. 'gopher': true,
  4660. 'file': true,
  4661. 'http:': true,
  4662. 'https:': true,
  4663. 'ftp:': true,
  4664. 'gopher:': true,
  4665. 'file:': true
  4666. },
  4667. querystring = require('querystring');
  4668. function urlParse(url, parseQueryString, slashesDenoteHost) {
  4669. if (url && isObject(url) && url instanceof Url) return url;
  4670. var u = new Url;
  4671. u.parse(url, parseQueryString, slashesDenoteHost);
  4672. return u;
  4673. }
  4674. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  4675. if (!isString(url)) {
  4676. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  4677. }
  4678. var rest = url;
  4679. // trim before proceeding.
  4680. // This is to support parse stuff like " http://foo.com \n"
  4681. rest = rest.trim();
  4682. var proto = protocolPattern.exec(rest);
  4683. if (proto) {
  4684. proto = proto[0];
  4685. var lowerProto = proto.toLowerCase();
  4686. this.protocol = lowerProto;
  4687. rest = rest.substr(proto.length);
  4688. }
  4689. // figure out if it's got a host
  4690. // user@server is *always* interpreted as a hostname, and url
  4691. // resolution will treat //foo/bar as host=foo,path=bar because that's
  4692. // how the browser resolves relative URLs.
  4693. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  4694. var slashes = rest.substr(0, 2) === '//';
  4695. if (slashes && !(proto && hostlessProtocol[proto])) {
  4696. rest = rest.substr(2);
  4697. this.slashes = true;
  4698. }
  4699. }
  4700. if (!hostlessProtocol[proto] &&
  4701. (slashes || (proto && !slashedProtocol[proto]))) {
  4702. // there's a hostname.
  4703. // the first instance of /, ?, ;, or # ends the host.
  4704. //
  4705. // If there is an @ in the hostname, then non-host chars *are* allowed
  4706. // to the left of the last @ sign, unless some host-ending character
  4707. // comes *before* the @-sign.
  4708. // URLs are obnoxious.
  4709. //
  4710. // ex:
  4711. // http://a@b@c/ => user:a@b host:c
  4712. // http://a@b?@c => user:a host:c path:/?@c
  4713. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  4714. // Review our test case against browsers more comprehensively.
  4715. // find the first instance of any hostEndingChars
  4716. var hostEnd = -1;
  4717. for (var i = 0; i < hostEndingChars.length; i++) {
  4718. var hec = rest.indexOf(hostEndingChars[i]);
  4719. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  4720. hostEnd = hec;
  4721. }
  4722. // at this point, either we have an explicit point where the
  4723. // auth portion cannot go past, or the last @ char is the decider.
  4724. var auth, atSign;
  4725. if (hostEnd === -1) {
  4726. // atSign can be anywhere.
  4727. atSign = rest.lastIndexOf('@');
  4728. } else {
  4729. // atSign must be in auth portion.
  4730. // http://a@b/c@d => host:b auth:a path:/c@d
  4731. atSign = rest.lastIndexOf('@', hostEnd);
  4732. }
  4733. // Now we have a portion which is definitely the auth.
  4734. // Pull that off.
  4735. if (atSign !== -1) {
  4736. auth = rest.slice(0, atSign);
  4737. rest = rest.slice(atSign + 1);
  4738. this.auth = decodeURIComponent(auth);
  4739. }
  4740. // the host is the remaining to the left of the first non-host char
  4741. hostEnd = -1;
  4742. for (var i = 0; i < nonHostChars.length; i++) {
  4743. var hec = rest.indexOf(nonHostChars[i]);
  4744. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  4745. hostEnd = hec;
  4746. }
  4747. // if we still have not hit it, then the entire thing is a host.
  4748. if (hostEnd === -1)
  4749. hostEnd = rest.length;
  4750. this.host = rest.slice(0, hostEnd);
  4751. rest = rest.slice(hostEnd);
  4752. // pull out port.
  4753. this.parseHost();
  4754. // we've indicated that there is a hostname,
  4755. // so even if it's empty, it has to be present.
  4756. this.hostname = this.hostname || '';
  4757. // if hostname begins with [ and ends with ]
  4758. // assume that it's an IPv6 address.
  4759. var ipv6Hostname = this.hostname[0] === '[' &&
  4760. this.hostname[this.hostname.length - 1] === ']';
  4761. // validate a little.
  4762. if (!ipv6Hostname) {
  4763. var hostparts = this.hostname.split(/\./);
  4764. for (var i = 0, l = hostparts.length; i < l; i++) {
  4765. var part = hostparts[i];
  4766. if (!part) continue;
  4767. if (!part.match(hostnamePartPattern)) {
  4768. var newpart = '';
  4769. for (var j = 0, k = part.length; j < k; j++) {
  4770. if (part.charCodeAt(j) > 127) {
  4771. // we replace non-ASCII char with a temporary placeholder
  4772. // we need this to make sure size of hostname is not
  4773. // broken by replacing non-ASCII by nothing
  4774. newpart += 'x';
  4775. } else {
  4776. newpart += part[j];
  4777. }
  4778. }
  4779. // we test again with ASCII char only
  4780. if (!newpart.match(hostnamePartPattern)) {
  4781. var validParts = hostparts.slice(0, i);
  4782. var notHost = hostparts.slice(i + 1);
  4783. var bit = part.match(hostnamePartStart);
  4784. if (bit) {
  4785. validParts.push(bit[1]);
  4786. notHost.unshift(bit[2]);
  4787. }
  4788. if (notHost.length) {
  4789. rest = '/' + notHost.join('.') + rest;
  4790. }
  4791. this.hostname = validParts.join('.');
  4792. break;
  4793. }
  4794. }
  4795. }
  4796. }
  4797. if (this.hostname.length > hostnameMaxLen) {
  4798. this.hostname = '';
  4799. } else {
  4800. // hostnames are always lower case.
  4801. this.hostname = this.hostname.toLowerCase();
  4802. }
  4803. if (!ipv6Hostname) {
  4804. // IDNA Support: Returns a puny coded representation of "domain".
  4805. // It only converts the part of the domain name that
  4806. // has non ASCII characters. I.e. it dosent matter if
  4807. // you call it with a domain that already is in ASCII.
  4808. var domainArray = this.hostname.split('.');
  4809. var newOut = [];
  4810. for (var i = 0; i < domainArray.length; ++i) {
  4811. var s = domainArray[i];
  4812. newOut.push(s.match(/[^A-Za-z0-9_-]/) ?
  4813. 'xn--' + punycode.encode(s) : s);
  4814. }
  4815. this.hostname = newOut.join('.');
  4816. }
  4817. var p = this.port ? ':' + this.port : '';
  4818. var h = this.hostname || '';
  4819. this.host = h + p;
  4820. this.href += this.host;
  4821. // strip [ and ] from the hostname
  4822. // the host field still retains them, though
  4823. if (ipv6Hostname) {
  4824. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  4825. if (rest[0] !== '/') {
  4826. rest = '/' + rest;
  4827. }
  4828. }
  4829. }
  4830. // now rest is set to the post-host stuff.
  4831. // chop off any delim chars.
  4832. if (!unsafeProtocol[lowerProto]) {
  4833. // First, make 100% sure that any "autoEscape" chars get
  4834. // escaped, even if encodeURIComponent doesn't think they
  4835. // need to be.
  4836. for (var i = 0, l = autoEscape.length; i < l; i++) {
  4837. var ae = autoEscape[i];
  4838. var esc = encodeURIComponent(ae);
  4839. if (esc === ae) {
  4840. esc = escape(ae);
  4841. }
  4842. rest = rest.split(ae).join(esc);
  4843. }
  4844. }
  4845. // chop off from the tail first.
  4846. var hash = rest.indexOf('#');
  4847. if (hash !== -1) {
  4848. // got a fragment string.
  4849. this.hash = rest.substr(hash);
  4850. rest = rest.slice(0, hash);
  4851. }
  4852. var qm = rest.indexOf('?');
  4853. if (qm !== -1) {
  4854. this.search = rest.substr(qm);
  4855. this.query = rest.substr(qm + 1);
  4856. if (parseQueryString) {
  4857. this.query = querystring.parse(this.query);
  4858. }
  4859. rest = rest.slice(0, qm);
  4860. } else if (parseQueryString) {
  4861. // no query string, but parseQueryString still requested
  4862. this.search = '';
  4863. this.query = {};
  4864. }
  4865. if (rest) this.pathname = rest;
  4866. if (slashedProtocol[lowerProto] &&
  4867. this.hostname && !this.pathname) {
  4868. this.pathname = '/';
  4869. }
  4870. //to support http.request
  4871. if (this.pathname || this.search) {
  4872. var p = this.pathname || '';
  4873. var s = this.search || '';
  4874. this.path = p + s;
  4875. }
  4876. // finally, reconstruct the href based on what has been validated.
  4877. this.href = this.format();
  4878. return this;
  4879. };
  4880. // format a parsed object into a url string
  4881. function urlFormat(obj) {
  4882. // ensure it's an object, and not a string url.
  4883. // If it's an obj, this is a no-op.
  4884. // this way, you can call url_format() on strings
  4885. // to clean up potentially wonky urls.
  4886. if (isString(obj)) obj = urlParse(obj);
  4887. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  4888. return obj.format();
  4889. }
  4890. Url.prototype.format = function() {
  4891. var auth = this.auth || '';
  4892. if (auth) {
  4893. auth = encodeURIComponent(auth);
  4894. auth = auth.replace(/%3A/i, ':');
  4895. auth += '@';
  4896. }
  4897. var protocol = this.protocol || '',
  4898. pathname = this.pathname || '',
  4899. hash = this.hash || '',
  4900. host = false,
  4901. query = '';
  4902. if (this.host) {
  4903. host = auth + this.host;
  4904. } else if (this.hostname) {
  4905. host = auth + (this.hostname.indexOf(':') === -1 ?
  4906. this.hostname :
  4907. '[' + this.hostname + ']');
  4908. if (this.port) {
  4909. host += ':' + this.port;
  4910. }
  4911. }
  4912. if (this.query &&
  4913. isObject(this.query) &&
  4914. Object.keys(this.query).length) {
  4915. query = querystring.stringify(this.query);
  4916. }
  4917. var search = this.search || (query && ('?' + query)) || '';
  4918. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  4919. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  4920. // unless they had them to begin with.
  4921. if (this.slashes ||
  4922. (!protocol || slashedProtocol[protocol]) && host !== false) {
  4923. host = '//' + (host || '');
  4924. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  4925. } else if (!host) {
  4926. host = '';
  4927. }
  4928. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  4929. if (search && search.charAt(0) !== '?') search = '?' + search;
  4930. pathname = pathname.replace(/[?#]/g, function(match) {
  4931. return encodeURIComponent(match);
  4932. });
  4933. search = search.replace('#', '%23');
  4934. return protocol + host + pathname + search + hash;
  4935. };
  4936. function urlResolve(source, relative) {
  4937. return urlParse(source, false, true).resolve(relative);
  4938. }
  4939. Url.prototype.resolve = function(relative) {
  4940. return this.resolveObject(urlParse(relative, false, true)).format();
  4941. };
  4942. function urlResolveObject(source, relative) {
  4943. if (!source) return relative;
  4944. return urlParse(source, false, true).resolveObject(relative);
  4945. }
  4946. Url.prototype.resolveObject = function(relative) {
  4947. if (isString(relative)) {
  4948. var rel = new Url();
  4949. rel.parse(relative, false, true);
  4950. relative = rel;
  4951. }
  4952. var result = new Url();
  4953. Object.keys(this).forEach(function(k) {
  4954. result[k] = this[k];
  4955. }, this);
  4956. // hash is always overridden, no matter what.
  4957. // even href="" will remove it.
  4958. result.hash = relative.hash;
  4959. // if the relative url is empty, then there's nothing left to do here.
  4960. if (relative.href === '') {
  4961. result.href = result.format();
  4962. return result;
  4963. }
  4964. // hrefs like //foo/bar always cut to the protocol.
  4965. if (relative.slashes && !relative.protocol) {
  4966. // take everything except the protocol from relative
  4967. Object.keys(relative).forEach(function(k) {
  4968. if (k !== 'protocol')
  4969. result[k] = relative[k];
  4970. });
  4971. //urlParse appends trailing / to urls like http://www.example.com
  4972. if (slashedProtocol[result.protocol] &&
  4973. result.hostname && !result.pathname) {
  4974. result.path = result.pathname = '/';
  4975. }
  4976. result.href = result.format();
  4977. return result;
  4978. }
  4979. if (relative.protocol && relative.protocol !== result.protocol) {
  4980. // if it's a known url protocol, then changing
  4981. // the protocol does weird things
  4982. // first, if it's not file:, then we MUST have a host,
  4983. // and if there was a path
  4984. // to begin with, then we MUST have a path.
  4985. // if it is file:, then the host is dropped,
  4986. // because that's known to be hostless.
  4987. // anything else is assumed to be absolute.
  4988. if (!slashedProtocol[relative.protocol]) {
  4989. Object.keys(relative).forEach(function(k) {
  4990. result[k] = relative[k];
  4991. });
  4992. result.href = result.format();
  4993. return result;
  4994. }
  4995. result.protocol = relative.protocol;
  4996. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  4997. var relPath = (relative.pathname || '').split('/');
  4998. while (relPath.length && !(relative.host = relPath.shift()));
  4999. if (!relative.host) relative.host = '';
  5000. if (!relative.hostname) relative.hostname = '';
  5001. if (relPath[0] !== '') relPath.unshift('');
  5002. if (relPath.length < 2) relPath.unshift('');
  5003. result.pathname = relPath.join('/');
  5004. } else {
  5005. result.pathname = relative.pathname;
  5006. }
  5007. result.search = relative.search;
  5008. result.query = relative.query;
  5009. result.host = relative.host || '';
  5010. result.auth = relative.auth;
  5011. result.hostname = relative.hostname || relative.host;
  5012. result.port = relative.port;
  5013. // to support http.request
  5014. if (result.pathname || result.search) {
  5015. var p = result.pathname || '';
  5016. var s = result.search || '';
  5017. result.path = p + s;
  5018. }
  5019. result.slashes = result.slashes || relative.slashes;
  5020. result.href = result.format();
  5021. return result;
  5022. }
  5023. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  5024. isRelAbs = (
  5025. relative.host ||
  5026. relative.pathname && relative.pathname.charAt(0) === '/'
  5027. ),
  5028. mustEndAbs = (isRelAbs || isSourceAbs ||
  5029. (result.host && relative.pathname)),
  5030. removeAllDots = mustEndAbs,
  5031. srcPath = result.pathname && result.pathname.split('/') || [],
  5032. relPath = relative.pathname && relative.pathname.split('/') || [],
  5033. psychotic = result.protocol && !slashedProtocol[result.protocol];
  5034. // if the url is a non-slashed url, then relative
  5035. // links like ../.. should be able
  5036. // to crawl up to the hostname, as well. This is strange.
  5037. // result.protocol has already been set by now.
  5038. // Later on, put the first path part into the host field.
  5039. if (psychotic) {
  5040. result.hostname = '';
  5041. result.port = null;
  5042. if (result.host) {
  5043. if (srcPath[0] === '') srcPath[0] = result.host;
  5044. else srcPath.unshift(result.host);
  5045. }
  5046. result.host = '';
  5047. if (relative.protocol) {
  5048. relative.hostname = null;
  5049. relative.port = null;
  5050. if (relative.host) {
  5051. if (relPath[0] === '') relPath[0] = relative.host;
  5052. else relPath.unshift(relative.host);
  5053. }
  5054. relative.host = null;
  5055. }
  5056. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  5057. }
  5058. if (isRelAbs) {
  5059. // it's absolute.
  5060. result.host = (relative.host || relative.host === '') ?
  5061. relative.host : result.host;
  5062. result.hostname = (relative.hostname || relative.hostname === '') ?
  5063. relative.hostname : result.hostname;
  5064. result.search = relative.search;
  5065. result.query = relative.query;
  5066. srcPath = relPath;
  5067. // fall through to the dot-handling below.
  5068. } else if (relPath.length) {
  5069. // it's relative
  5070. // throw away the existing file, and take the new path instead.
  5071. if (!srcPath) srcPath = [];
  5072. srcPath.pop();
  5073. srcPath = srcPath.concat(relPath);
  5074. result.search = relative.search;
  5075. result.query = relative.query;
  5076. } else if (!isNullOrUndefined(relative.search)) {
  5077. // just pull out the search.
  5078. // like href='?foo'.
  5079. // Put this after the other two cases because it simplifies the booleans
  5080. if (psychotic) {
  5081. result.hostname = result.host = srcPath.shift();
  5082. //occationaly the auth can get stuck only in host
  5083. //this especialy happens in cases like
  5084. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  5085. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  5086. result.host.split('@') : false;
  5087. if (authInHost) {
  5088. result.auth = authInHost.shift();
  5089. result.host = result.hostname = authInHost.shift();
  5090. }
  5091. }
  5092. result.search = relative.search;
  5093. result.query = relative.query;
  5094. //to support http.request
  5095. if (!isNull(result.pathname) || !isNull(result.search)) {
  5096. result.path = (result.pathname ? result.pathname : '') +
  5097. (result.search ? result.search : '');
  5098. }
  5099. result.href = result.format();
  5100. return result;
  5101. }
  5102. if (!srcPath.length) {
  5103. // no path at all. easy.
  5104. // we've already handled the other stuff above.
  5105. result.pathname = null;
  5106. //to support http.request
  5107. if (result.search) {
  5108. result.path = '/' + result.search;
  5109. } else {
  5110. result.path = null;
  5111. }
  5112. result.href = result.format();
  5113. return result;
  5114. }
  5115. // if a url ENDs in . or .., then it must get a trailing slash.
  5116. // however, if it ends in anything else non-slashy,
  5117. // then it must NOT get a trailing slash.
  5118. var last = srcPath.slice(-1)[0];
  5119. var hasTrailingSlash = (
  5120. (result.host || relative.host) && (last === '.' || last === '..') ||
  5121. last === '');
  5122. // strip single dots, resolve double dots to parent dir
  5123. // if the path tries to go above the root, `up` ends up > 0
  5124. var up = 0;
  5125. for (var i = srcPath.length; i >= 0; i--) {
  5126. last = srcPath[i];
  5127. if (last == '.') {
  5128. srcPath.splice(i, 1);
  5129. } else if (last === '..') {
  5130. srcPath.splice(i, 1);
  5131. up++;
  5132. } else if (up) {
  5133. srcPath.splice(i, 1);
  5134. up--;
  5135. }
  5136. }
  5137. // if the path is allowed to go above the root, restore leading ..s
  5138. if (!mustEndAbs && !removeAllDots) {
  5139. for (; up--; up) {
  5140. srcPath.unshift('..');
  5141. }
  5142. }
  5143. if (mustEndAbs && srcPath[0] !== '' &&
  5144. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  5145. srcPath.unshift('');
  5146. }
  5147. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  5148. srcPath.push('');
  5149. }
  5150. var isAbsolute = srcPath[0] === '' ||
  5151. (srcPath[0] && srcPath[0].charAt(0) === '/');
  5152. // put the host back
  5153. if (psychotic) {
  5154. result.hostname = result.host = isAbsolute ? '' :
  5155. srcPath.length ? srcPath.shift() : '';
  5156. //occationaly the auth can get stuck only in host
  5157. //this especialy happens in cases like
  5158. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  5159. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  5160. result.host.split('@') : false;
  5161. if (authInHost) {
  5162. result.auth = authInHost.shift();
  5163. result.host = result.hostname = authInHost.shift();
  5164. }
  5165. }
  5166. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  5167. if (mustEndAbs && !isAbsolute) {
  5168. srcPath.unshift('');
  5169. }
  5170. if (!srcPath.length) {
  5171. result.pathname = null;
  5172. result.path = null;
  5173. } else {
  5174. result.pathname = srcPath.join('/');
  5175. }
  5176. //to support request.http
  5177. if (!isNull(result.pathname) || !isNull(result.search)) {
  5178. result.path = (result.pathname ? result.pathname : '') +
  5179. (result.search ? result.search : '');
  5180. }
  5181. result.auth = relative.auth || result.auth;
  5182. result.slashes = result.slashes || relative.slashes;
  5183. result.href = result.format();
  5184. return result;
  5185. };
  5186. Url.prototype.parseHost = function() {
  5187. var host = this.host;
  5188. var port = portPattern.exec(host);
  5189. if (port) {
  5190. port = port[0];
  5191. if (port !== ':') {
  5192. this.port = port.substr(1);
  5193. }
  5194. host = host.substr(0, host.length - port.length);
  5195. }
  5196. if (host) this.hostname = host;
  5197. };
  5198. function isString(arg) {
  5199. return typeof arg === "string";
  5200. }
  5201. function isObject(arg) {
  5202. return typeof arg === 'object' && arg !== null;
  5203. }
  5204. function isNull(arg) {
  5205. return arg === null;
  5206. }
  5207. function isNullOrUndefined(arg) {
  5208. return arg == null;
  5209. }
  5210. },{"punycode":14,"querystring":17}],27:[function(require,module,exports){
  5211. if (typeof Object.create === 'function') {
  5212. // implementation from standard node.js 'util' module
  5213. module.exports = function inherits(ctor, superCtor) {
  5214. ctor.super_ = superCtor
  5215. ctor.prototype = Object.create(superCtor.prototype, {
  5216. constructor: {
  5217. value: ctor,
  5218. enumerable: false,
  5219. writable: true,
  5220. configurable: true
  5221. }
  5222. });
  5223. };
  5224. } else {
  5225. // old school shim for old browsers
  5226. module.exports = function inherits(ctor, superCtor) {
  5227. ctor.super_ = superCtor
  5228. var TempCtor = function () {}
  5229. TempCtor.prototype = superCtor.prototype
  5230. ctor.prototype = new TempCtor()
  5231. ctor.prototype.constructor = ctor
  5232. }
  5233. }
  5234. },{}],28:[function(require,module,exports){
  5235. module.exports = function isBuffer(arg) {
  5236. return arg && typeof arg === 'object'
  5237. && typeof arg.copy === 'function'
  5238. && typeof arg.fill === 'function'
  5239. && typeof arg.readUInt8 === 'function';
  5240. }
  5241. },{}],29:[function(require,module,exports){
  5242. (function (process,global){
  5243. // Copyright Joyent, Inc. and other Node contributors.
  5244. //
  5245. // Permission is hereby granted, free of charge, to any person obtaining a
  5246. // copy of this software and associated documentation files (the
  5247. // "Software"), to deal in the Software without restriction, including
  5248. // without limitation the rights to use, copy, modify, merge, publish,
  5249. // distribute, sublicense, and/or sell copies of the Software, and to permit
  5250. // persons to whom the Software is furnished to do so, subject to the
  5251. // following conditions:
  5252. //
  5253. // The above copyright notice and this permission notice shall be included
  5254. // in all copies or substantial portions of the Software.
  5255. //
  5256. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  5257. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  5258. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  5259. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  5260. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  5261. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  5262. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  5263. var formatRegExp = /%[sdj%]/g;
  5264. exports.format = function(f) {
  5265. if (!isString(f)) {
  5266. var objects = [];
  5267. for (var i = 0; i < arguments.length; i++) {
  5268. objects.push(inspect(arguments[i]));
  5269. }
  5270. return objects.join(' ');
  5271. }
  5272. var i = 1;
  5273. var args = arguments;
  5274. var len = args.length;
  5275. var str = String(f).replace(formatRegExp, function(x) {
  5276. if (x === '%%') return '%';
  5277. if (i >= len) return x;
  5278. switch (x) {
  5279. case '%s': return String(args[i++]);
  5280. case '%d': return Number(args[i++]);
  5281. case '%j':
  5282. try {
  5283. return JSON.stringify(args[i++]);
  5284. } catch (_) {
  5285. return '[Circular]';
  5286. }
  5287. default:
  5288. return x;
  5289. }
  5290. });
  5291. for (var x = args[i]; i < len; x = args[++i]) {
  5292. if (isNull(x) || !isObject(x)) {
  5293. str += ' ' + x;
  5294. } else {
  5295. str += ' ' + inspect(x);
  5296. }
  5297. }
  5298. return str;
  5299. };
  5300. // Mark that a method should not be used.
  5301. // Returns a modified function which warns once by default.
  5302. // If --no-deprecation is set, then it is a no-op.
  5303. exports.deprecate = function(fn, msg) {
  5304. // Allow for deprecating things in the process of starting up.
  5305. if (isUndefined(global.process)) {
  5306. return function() {
  5307. return exports.deprecate(fn, msg).apply(this, arguments);
  5308. };
  5309. }
  5310. if (process.noDeprecation === true) {
  5311. return fn;
  5312. }
  5313. var warned = false;
  5314. function deprecated() {
  5315. if (!warned) {
  5316. if (process.throwDeprecation) {
  5317. throw new Error(msg);
  5318. } else if (process.traceDeprecation) {
  5319. console.trace(msg);
  5320. } else {
  5321. console.error(msg);
  5322. }
  5323. warned = true;
  5324. }
  5325. return fn.apply(this, arguments);
  5326. }
  5327. return deprecated;
  5328. };
  5329. var debugs = {};
  5330. var debugEnviron;
  5331. exports.debuglog = function(set) {
  5332. if (isUndefined(debugEnviron))
  5333. debugEnviron = process.env.NODE_DEBUG || '';
  5334. set = set.toUpperCase();
  5335. if (!debugs[set]) {
  5336. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  5337. var pid = process.pid;
  5338. debugs[set] = function() {
  5339. var msg = exports.format.apply(exports, arguments);
  5340. console.error('%s %d: %s', set, pid, msg);
  5341. };
  5342. } else {
  5343. debugs[set] = function() {};
  5344. }
  5345. }
  5346. return debugs[set];
  5347. };
  5348. /**
  5349. * Echos the value of a value. Trys to print the value out
  5350. * in the best way possible given the different types.
  5351. *
  5352. * @param {Object} obj The object to print out.
  5353. * @param {Object} opts Optional options object that alters the output.
  5354. */
  5355. /* legacy: obj, showHidden, depth, colors*/
  5356. function inspect(obj, opts) {
  5357. // default options
  5358. var ctx = {
  5359. seen: [],
  5360. stylize: stylizeNoColor
  5361. };
  5362. // legacy...
  5363. if (arguments.length >= 3) ctx.depth = arguments[2];
  5364. if (arguments.length >= 4) ctx.colors = arguments[3];
  5365. if (isBoolean(opts)) {
  5366. // legacy...
  5367. ctx.showHidden = opts;
  5368. } else if (opts) {
  5369. // got an "options" object
  5370. exports._extend(ctx, opts);
  5371. }
  5372. // set default options
  5373. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  5374. if (isUndefined(ctx.depth)) ctx.depth = 2;
  5375. if (isUndefined(ctx.colors)) ctx.colors = false;
  5376. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  5377. if (ctx.colors) ctx.stylize = stylizeWithColor;
  5378. return formatValue(ctx, obj, ctx.depth);
  5379. }
  5380. exports.inspect = inspect;
  5381. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  5382. inspect.colors = {
  5383. 'bold' : [1, 22],
  5384. 'italic' : [3, 23],
  5385. 'underline' : [4, 24],
  5386. 'inverse' : [7, 27],
  5387. 'white' : [37, 39],
  5388. 'grey' : [90, 39],
  5389. 'black' : [30, 39],
  5390. 'blue' : [34, 39],
  5391. 'cyan' : [36, 39],
  5392. 'green' : [32, 39],
  5393. 'magenta' : [35, 39],
  5394. 'red' : [31, 39],
  5395. 'yellow' : [33, 39]
  5396. };
  5397. // Don't use 'blue' not visible on cmd.exe
  5398. inspect.styles = {
  5399. 'special': 'cyan',
  5400. 'number': 'yellow',
  5401. 'boolean': 'yellow',
  5402. 'undefined': 'grey',
  5403. 'null': 'bold',
  5404. 'string': 'green',
  5405. 'date': 'magenta',
  5406. // "name": intentionally not styling
  5407. 'regexp': 'red'
  5408. };
  5409. function stylizeWithColor(str, styleType) {
  5410. var style = inspect.styles[styleType];
  5411. if (style) {
  5412. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  5413. '\u001b[' + inspect.colors[style][1] + 'm';
  5414. } else {
  5415. return str;
  5416. }
  5417. }
  5418. function stylizeNoColor(str, styleType) {
  5419. return str;
  5420. }
  5421. function arrayToHash(array) {
  5422. var hash = {};
  5423. array.forEach(function(val, idx) {
  5424. hash[val] = true;
  5425. });
  5426. return hash;
  5427. }
  5428. function formatValue(ctx, value, recurseTimes) {
  5429. // Provide a hook for user-specified inspect functions.
  5430. // Check that value is an object with an inspect function on it
  5431. if (ctx.customInspect &&
  5432. value &&
  5433. isFunction(value.inspect) &&
  5434. // Filter out the util module, it's inspect function is special
  5435. value.inspect !== exports.inspect &&
  5436. // Also filter out any prototype objects using the circular check.
  5437. !(value.constructor && value.constructor.prototype === value)) {
  5438. var ret = value.inspect(recurseTimes, ctx);
  5439. if (!isString(ret)) {
  5440. ret = formatValue(ctx, ret, recurseTimes);
  5441. }
  5442. return ret;
  5443. }
  5444. // Primitive types cannot have properties
  5445. var primitive = formatPrimitive(ctx, value);
  5446. if (primitive) {
  5447. return primitive;
  5448. }
  5449. // Look up the keys of the object.
  5450. var keys = Object.keys(value);
  5451. var visibleKeys = arrayToHash(keys);
  5452. if (ctx.showHidden) {
  5453. keys = Object.getOwnPropertyNames(value);
  5454. }
  5455. // IE doesn't make error fields non-enumerable
  5456. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  5457. if (isError(value)
  5458. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  5459. return formatError(value);
  5460. }
  5461. // Some type of object without properties can be shortcutted.
  5462. if (keys.length === 0) {
  5463. if (isFunction(value)) {
  5464. var name = value.name ? ': ' + value.name : '';
  5465. return ctx.stylize('[Function' + name + ']', 'special');
  5466. }
  5467. if (isRegExp(value)) {
  5468. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  5469. }
  5470. if (isDate(value)) {
  5471. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  5472. }
  5473. if (isError(value)) {
  5474. return formatError(value);
  5475. }
  5476. }
  5477. var base = '', array = false, braces = ['{', '}'];
  5478. // Make Array say that they are Array
  5479. if (isArray(value)) {
  5480. array = true;
  5481. braces = ['[', ']'];
  5482. }
  5483. // Make functions say that they are functions
  5484. if (isFunction(value)) {
  5485. var n = value.name ? ': ' + value.name : '';
  5486. base = ' [Function' + n + ']';
  5487. }
  5488. // Make RegExps say that they are RegExps
  5489. if (isRegExp(value)) {
  5490. base = ' ' + RegExp.prototype.toString.call(value);
  5491. }
  5492. // Make dates with properties first say the date
  5493. if (isDate(value)) {
  5494. base = ' ' + Date.prototype.toUTCString.call(value);
  5495. }
  5496. // Make error with message first say the error
  5497. if (isError(value)) {
  5498. base = ' ' + formatError(value);
  5499. }
  5500. if (keys.length === 0 && (!array || value.length == 0)) {
  5501. return braces[0] + base + braces[1];
  5502. }
  5503. if (recurseTimes < 0) {
  5504. if (isRegExp(value)) {
  5505. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  5506. } else {
  5507. return ctx.stylize('[Object]', 'special');
  5508. }
  5509. }
  5510. ctx.seen.push(value);
  5511. var output;
  5512. if (array) {
  5513. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  5514. } else {
  5515. output = keys.map(function(key) {
  5516. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  5517. });
  5518. }
  5519. ctx.seen.pop();
  5520. return reduceToSingleString(output, base, braces);
  5521. }
  5522. function formatPrimitive(ctx, value) {
  5523. if (isUndefined(value))
  5524. return ctx.stylize('undefined', 'undefined');
  5525. if (isString(value)) {
  5526. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  5527. .replace(/'/g, "\\'")
  5528. .replace(/\\"/g, '"') + '\'';
  5529. return ctx.stylize(simple, 'string');
  5530. }
  5531. if (isNumber(value))
  5532. return ctx.stylize('' + value, 'number');
  5533. if (isBoolean(value))
  5534. return ctx.stylize('' + value, 'boolean');
  5535. // For some reason typeof null is "object", so special case here.
  5536. if (isNull(value))
  5537. return ctx.stylize('null', 'null');
  5538. }
  5539. function formatError(value) {
  5540. return '[' + Error.prototype.toString.call(value) + ']';
  5541. }
  5542. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  5543. var output = [];
  5544. for (var i = 0, l = value.length; i < l; ++i) {
  5545. if (hasOwnProperty(value, String(i))) {
  5546. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  5547. String(i), true));
  5548. } else {
  5549. output.push('');
  5550. }
  5551. }
  5552. keys.forEach(function(key) {
  5553. if (!key.match(/^\d+$/)) {
  5554. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  5555. key, true));
  5556. }
  5557. });
  5558. return output;
  5559. }
  5560. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  5561. var name, str, desc;
  5562. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  5563. if (desc.get) {
  5564. if (desc.set) {
  5565. str = ctx.stylize('[Getter/Setter]', 'special');
  5566. } else {
  5567. str = ctx.stylize('[Getter]', 'special');
  5568. }
  5569. } else {
  5570. if (desc.set) {
  5571. str = ctx.stylize('[Setter]', 'special');
  5572. }
  5573. }
  5574. if (!hasOwnProperty(visibleKeys, key)) {
  5575. name = '[' + key + ']';
  5576. }
  5577. if (!str) {
  5578. if (ctx.seen.indexOf(desc.value) < 0) {
  5579. if (isNull(recurseTimes)) {
  5580. str = formatValue(ctx, desc.value, null);
  5581. } else {
  5582. str = formatValue(ctx, desc.value, recurseTimes - 1);
  5583. }
  5584. if (str.indexOf('\n') > -1) {
  5585. if (array) {
  5586. str = str.split('\n').map(function(line) {
  5587. return ' ' + line;
  5588. }).join('\n').substr(2);
  5589. } else {
  5590. str = '\n' + str.split('\n').map(function(line) {
  5591. return ' ' + line;
  5592. }).join('\n');
  5593. }
  5594. }
  5595. } else {
  5596. str = ctx.stylize('[Circular]', 'special');
  5597. }
  5598. }
  5599. if (isUndefined(name)) {
  5600. if (array && key.match(/^\d+$/)) {
  5601. return str;
  5602. }
  5603. name = JSON.stringify('' + key);
  5604. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  5605. name = name.substr(1, name.length - 2);
  5606. name = ctx.stylize(name, 'name');
  5607. } else {
  5608. name = name.replace(/'/g, "\\'")
  5609. .replace(/\\"/g, '"')
  5610. .replace(/(^"|"$)/g, "'");
  5611. name = ctx.stylize(name, 'string');
  5612. }
  5613. }
  5614. return name + ': ' + str;
  5615. }
  5616. function reduceToSingleString(output, base, braces) {
  5617. var numLinesEst = 0;
  5618. var length = output.reduce(function(prev, cur) {
  5619. numLinesEst++;
  5620. if (cur.indexOf('\n') >= 0) numLinesEst++;
  5621. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  5622. }, 0);
  5623. if (length > 60) {
  5624. return braces[0] +
  5625. (base === '' ? '' : base + '\n ') +
  5626. ' ' +
  5627. output.join(',\n ') +
  5628. ' ' +
  5629. braces[1];
  5630. }
  5631. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  5632. }
  5633. // NOTE: These type checking functions intentionally don't use `instanceof`
  5634. // because it is fragile and can be easily faked with `Object.create()`.
  5635. function isArray(ar) {
  5636. return Array.isArray(ar);
  5637. }
  5638. exports.isArray = isArray;
  5639. function isBoolean(arg) {
  5640. return typeof arg === 'boolean';
  5641. }
  5642. exports.isBoolean = isBoolean;
  5643. function isNull(arg) {
  5644. return arg === null;
  5645. }
  5646. exports.isNull = isNull;
  5647. function isNullOrUndefined(arg) {
  5648. return arg == null;
  5649. }
  5650. exports.isNullOrUndefined = isNullOrUndefined;
  5651. function isNumber(arg) {
  5652. return typeof arg === 'number';
  5653. }
  5654. exports.isNumber = isNumber;
  5655. function isString(arg) {
  5656. return typeof arg === 'string';
  5657. }
  5658. exports.isString = isString;
  5659. function isSymbol(arg) {
  5660. return typeof arg === 'symbol';
  5661. }
  5662. exports.isSymbol = isSymbol;
  5663. function isUndefined(arg) {
  5664. return arg === void 0;
  5665. }
  5666. exports.isUndefined = isUndefined;
  5667. function isRegExp(re) {
  5668. return isObject(re) && objectToString(re) === '[object RegExp]';
  5669. }
  5670. exports.isRegExp = isRegExp;
  5671. function isObject(arg) {
  5672. return typeof arg === 'object' && arg !== null;
  5673. }
  5674. exports.isObject = isObject;
  5675. function isDate(d) {
  5676. return isObject(d) && objectToString(d) === '[object Date]';
  5677. }
  5678. exports.isDate = isDate;
  5679. function isError(e) {
  5680. return isObject(e) &&
  5681. (objectToString(e) === '[object Error]' || e instanceof Error);
  5682. }
  5683. exports.isError = isError;
  5684. function isFunction(arg) {
  5685. return typeof arg === 'function';
  5686. }
  5687. exports.isFunction = isFunction;
  5688. function isPrimitive(arg) {
  5689. return arg === null ||
  5690. typeof arg === 'boolean' ||
  5691. typeof arg === 'number' ||
  5692. typeof arg === 'string' ||
  5693. typeof arg === 'symbol' || // ES6 symbol
  5694. typeof arg === 'undefined';
  5695. }
  5696. exports.isPrimitive = isPrimitive;
  5697. exports.isBuffer = require('./support/isBuffer');
  5698. function objectToString(o) {
  5699. return Object.prototype.toString.call(o);
  5700. }
  5701. function pad(n) {
  5702. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  5703. }
  5704. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  5705. 'Oct', 'Nov', 'Dec'];
  5706. // 26 Feb 16:19:34
  5707. function timestamp() {
  5708. var d = new Date();
  5709. var time = [pad(d.getHours()),
  5710. pad(d.getMinutes()),
  5711. pad(d.getSeconds())].join(':');
  5712. return [d.getDate(), months[d.getMonth()], time].join(' ');
  5713. }
  5714. // log is just a thin wrapper to console.log that prepends a timestamp
  5715. exports.log = function() {
  5716. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  5717. };
  5718. /**
  5719. * Inherit the prototype methods from one constructor into another.
  5720. *
  5721. * The Function.prototype.inherits from lang.js rewritten as a standalone
  5722. * function (not on Function.prototype). NOTE: If this file is to be loaded
  5723. * during bootstrapping this function needs to be rewritten using some native
  5724. * functions as prototype setup using normal JavaScript does not work as
  5725. * expected during bootstrapping (see mirror.js in r114903).
  5726. *
  5727. * @param {function} ctor Constructor function which needs to inherit the
  5728. * prototype.
  5729. * @param {function} superCtor Constructor function to inherit prototype from.
  5730. */
  5731. exports.inherits = require('inherits');
  5732. exports._extend = function(origin, add) {
  5733. // Don't do anything if add isn't an object
  5734. if (!add || !isObject(add)) return origin;
  5735. var keys = Object.keys(add);
  5736. var i = keys.length;
  5737. while (i--) {
  5738. origin[keys[i]] = add[keys[i]];
  5739. }
  5740. return origin;
  5741. };
  5742. function hasOwnProperty(obj, prop) {
  5743. return Object.prototype.hasOwnProperty.call(obj, prop);
  5744. }
  5745. }).call(this,require("g5I+bs"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  5746. },{"./support/isBuffer":28,"g5I+bs":13,"inherits":27}],30:[function(require,module,exports){
  5747. var http = require('http');
  5748. var Stream = require('stream');
  5749. var encode = typeof encodeURIComponent !== 'undefined'
  5750. ? encodeURIComponent : escape
  5751. ;
  5752. module.exports = function (opts) {
  5753. if (typeof opts === 'string') {
  5754. opts = { path : opts };
  5755. }
  5756. if (!opts) opts = {};
  5757. if (!opts.id) {
  5758. opts.id = Math.floor(Math.pow(16, 8) * Math.random()).toString(16);
  5759. }
  5760. var stream = new Stream;
  5761. stream.writable = true;
  5762. stream.order = 0;
  5763. stream.write = function (msg) {
  5764. if (stream.ended) return;
  5765. var data = 'order=' + stream.order
  5766. + '&data=' + encode(msg)
  5767. + '&id=' + encode(opts.id)
  5768. ;
  5769. stream.order ++;
  5770. send(data);
  5771. };
  5772. stream.destroy = function () {
  5773. stream.ended = true;
  5774. stream.emit('close');
  5775. };
  5776. stream.end = function (msg) {
  5777. if (stream.ended) return;
  5778. var data = 'order=' + stream.order
  5779. + '&id=' + encode(opts.id)
  5780. + '&end=true'
  5781. ;
  5782. if (msg !== undefined) data += '&data=' + encode(msg);
  5783. stream.order ++;
  5784. send(data);
  5785. stream.ended = true;
  5786. stream.emit('close');
  5787. };
  5788. function send (data) {
  5789. var params = {
  5790. method : 'POST',
  5791. host : opts.host || window.location.hostname,
  5792. port : opts.port || window.location.port,
  5793. path : opts.path || '/',
  5794. headers : {
  5795. 'content-type' : 'application/x-www-form-urlencoded'
  5796. }
  5797. };
  5798. var req = http.request(params);
  5799. req.end(data);
  5800. }
  5801. return stream
  5802. };
  5803. },{"http":6,"stream":19}]},{},[1])</script><script>(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  5804. 'use strict';
  5805. // modified from https://github.com/es-shims/es6-shim
  5806. var keys = require('object-keys');
  5807. var hasSymbols = require('has-symbols/shams')();
  5808. var callBound = require('call-bind/callBound');
  5809. var toObject = Object;
  5810. var $push = callBound('Array.prototype.push');
  5811. var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable');
  5812. var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
  5813. // eslint-disable-next-line no-unused-vars
  5814. module.exports = function assign(target, source1) {
  5815. if (target == null) { throw new TypeError('target must be an object'); }
  5816. var objTarget = toObject(target);
  5817. var s, source, i, props, syms, value, key;
  5818. for (s = 1; s < arguments.length; ++s) {
  5819. source = toObject(arguments[s]);
  5820. props = keys(source);
  5821. var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
  5822. if (getSymbols) {
  5823. syms = getSymbols(source);
  5824. for (i = 0; i < syms.length; ++i) {
  5825. key = syms[i];
  5826. if ($propIsEnumerable(source, key)) {
  5827. $push(props, key);
  5828. }
  5829. }
  5830. }
  5831. for (i = 0; i < props.length; ++i) {
  5832. key = props[i];
  5833. value = source[key];
  5834. if ($propIsEnumerable(source, key)) {
  5835. objTarget[key] = value;
  5836. }
  5837. }
  5838. }
  5839. return objTarget;
  5840. };
  5841. },{"call-bind/callBound":11,"has-symbols/shams":43,"object-keys":71}],2:[function(require,module,exports){
  5842. 'use strict';
  5843. var defineProperties = require('define-properties');
  5844. var callBind = require('call-bind');
  5845. var implementation = require('./implementation');
  5846. var getPolyfill = require('./polyfill');
  5847. var shim = require('./shim');
  5848. var polyfill = callBind.apply(getPolyfill());
  5849. // eslint-disable-next-line no-unused-vars
  5850. var bound = function assign(target, source1) {
  5851. return polyfill(Object, arguments);
  5852. };
  5853. defineProperties(bound, {
  5854. getPolyfill: getPolyfill,
  5855. implementation: implementation,
  5856. shim: shim
  5857. });
  5858. module.exports = bound;
  5859. },{"./implementation":1,"./polyfill":116,"./shim":117,"call-bind":12,"define-properties":16}],3:[function(require,module,exports){
  5860. 'use strict';
  5861. var IsCallable = require('es-abstract/2021/IsCallable');
  5862. var ToObject = require('es-abstract/2021/ToObject');
  5863. var ToUint32 = require('es-abstract/2021/ToUint32');
  5864. var callBound = require('call-bind/callBound');
  5865. var isString = require('is-string');
  5866. // Check failure of by-index access of string characters (IE < 9) and failure of `0 in boxedString` (Rhino)
  5867. var boxedString = Object('a');
  5868. var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
  5869. var $split = callBound('String.prototype.split');
  5870. module.exports = function every(callbackfn) {
  5871. var O = ToObject(this);
  5872. var self = splitString && isString(O) ? $split(O, '') : O;
  5873. var len = ToUint32(self.length);
  5874. var T;
  5875. if (arguments.length > 1) {
  5876. T = arguments[1];
  5877. }
  5878. // If no callback function or if callback is not a callable function
  5879. if (!IsCallable(callbackfn)) {
  5880. throw new TypeError('Array.prototype.every callback must be a function');
  5881. }
  5882. for (var i = 0; i < len; i++) {
  5883. if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, O) : callbackfn.call(T, self[i], i, O))) {
  5884. return false;
  5885. }
  5886. }
  5887. return true;
  5888. };
  5889. },{"call-bind/callBound":11,"es-abstract/2021/IsCallable":18,"es-abstract/2021/ToObject":21,"es-abstract/2021/ToUint32":24,"is-string":57}],4:[function(require,module,exports){
  5890. 'use strict';
  5891. var define = require('define-properties');
  5892. var RequireObjectCoercible = require('es-abstract/2021/RequireObjectCoercible');
  5893. var callBound = require('call-bind/callBound');
  5894. var implementation = require('./implementation');
  5895. var getPolyfill = require('./polyfill');
  5896. var polyfill = getPolyfill();
  5897. var shim = require('./shim');
  5898. var $slice = callBound('Array.prototype.slice');
  5899. // eslint-disable-next-line no-unused-vars
  5900. var boundEveryShim = function every(array, callbackfn) {
  5901. RequireObjectCoercible(array);
  5902. return polyfill.apply(array, $slice(arguments, 1));
  5903. };
  5904. define(boundEveryShim, {
  5905. getPolyfill: getPolyfill,
  5906. implementation: implementation,
  5907. shim: shim
  5908. });
  5909. module.exports = boundEveryShim;
  5910. },{"./implementation":3,"./polyfill":5,"./shim":6,"call-bind/callBound":11,"define-properties":16,"es-abstract/2021/RequireObjectCoercible":19}],5:[function(require,module,exports){
  5911. var implementation = require('./implementation');
  5912. module.exports = function getPolyfill() {
  5913. if (typeof Array.prototype.every === 'function') {
  5914. var hasPrimitiveContextInStrict = [1].every(function () {
  5915. 'use strict';
  5916. return typeof this === 'string' && this === 'x';
  5917. }, 'x');
  5918. if (hasPrimitiveContextInStrict) {
  5919. return Array.prototype.every;
  5920. }
  5921. }
  5922. return implementation;
  5923. };
  5924. },{"./implementation":3}],6:[function(require,module,exports){
  5925. 'use strict';
  5926. var define = require('define-properties');
  5927. var getPolyfill = require('./polyfill');
  5928. module.exports = function shimArrayPrototypeEvery() {
  5929. var polyfill = getPolyfill();
  5930. define(
  5931. Array.prototype,
  5932. { every: polyfill },
  5933. { every: function () { return Array.prototype.every !== polyfill; } }
  5934. );
  5935. return polyfill;
  5936. };
  5937. },{"./polyfill":5,"define-properties":16}],7:[function(require,module,exports){
  5938. (function (global){(function (){
  5939. 'use strict';
  5940. var possibleNames = [
  5941. 'BigInt64Array',
  5942. 'BigUint64Array',
  5943. 'Float32Array',
  5944. 'Float64Array',
  5945. 'Int16Array',
  5946. 'Int32Array',
  5947. 'Int8Array',
  5948. 'Uint16Array',
  5949. 'Uint32Array',
  5950. 'Uint8Array',
  5951. 'Uint8ClampedArray'
  5952. ];
  5953. var g = typeof globalThis === 'undefined' ? global : globalThis;
  5954. module.exports = function availableTypedArrays() {
  5955. var out = [];
  5956. for (var i = 0; i < possibleNames.length; i++) {
  5957. if (typeof g[possibleNames[i]] === 'function') {
  5958. out[out.length] = possibleNames[i];
  5959. }
  5960. }
  5961. return out;
  5962. };
  5963. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  5964. },{}],8:[function(require,module,exports){
  5965. 'use strict'
  5966. exports.byteLength = byteLength
  5967. exports.toByteArray = toByteArray
  5968. exports.fromByteArray = fromByteArray
  5969. var lookup = []
  5970. var revLookup = []
  5971. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  5972. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  5973. for (var i = 0, len = code.length; i < len; ++i) {
  5974. lookup[i] = code[i]
  5975. revLookup[code.charCodeAt(i)] = i
  5976. }
  5977. // Support decoding URL-safe base64 strings, as Node.js does.
  5978. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  5979. revLookup['-'.charCodeAt(0)] = 62
  5980. revLookup['_'.charCodeAt(0)] = 63
  5981. function getLens (b64) {
  5982. var len = b64.length
  5983. if (len % 4 > 0) {
  5984. throw new Error('Invalid string. Length must be a multiple of 4')
  5985. }
  5986. // Trim off extra bytes after placeholder bytes are found
  5987. // See: https://github.com/beatgammit/base64-js/issues/42
  5988. var validLen = b64.indexOf('=')
  5989. if (validLen === -1) validLen = len
  5990. var placeHoldersLen = validLen === len
  5991. ? 0
  5992. : 4 - (validLen % 4)
  5993. return [validLen, placeHoldersLen]
  5994. }
  5995. // base64 is 4/3 + up to two characters of the original data
  5996. function byteLength (b64) {
  5997. var lens = getLens(b64)
  5998. var validLen = lens[0]
  5999. var placeHoldersLen = lens[1]
  6000. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  6001. }
  6002. function _byteLength (b64, validLen, placeHoldersLen) {
  6003. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  6004. }
  6005. function toByteArray (b64) {
  6006. var tmp
  6007. var lens = getLens(b64)
  6008. var validLen = lens[0]
  6009. var placeHoldersLen = lens[1]
  6010. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  6011. var curByte = 0
  6012. // if there are placeholders, only get up to the last complete 4 chars
  6013. var len = placeHoldersLen > 0
  6014. ? validLen - 4
  6015. : validLen
  6016. var i
  6017. for (i = 0; i < len; i += 4) {
  6018. tmp =
  6019. (revLookup[b64.charCodeAt(i)] << 18) |
  6020. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  6021. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  6022. revLookup[b64.charCodeAt(i + 3)]
  6023. arr[curByte++] = (tmp >> 16) & 0xFF
  6024. arr[curByte++] = (tmp >> 8) & 0xFF
  6025. arr[curByte++] = tmp & 0xFF
  6026. }
  6027. if (placeHoldersLen === 2) {
  6028. tmp =
  6029. (revLookup[b64.charCodeAt(i)] << 2) |
  6030. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  6031. arr[curByte++] = tmp & 0xFF
  6032. }
  6033. if (placeHoldersLen === 1) {
  6034. tmp =
  6035. (revLookup[b64.charCodeAt(i)] << 10) |
  6036. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  6037. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  6038. arr[curByte++] = (tmp >> 8) & 0xFF
  6039. arr[curByte++] = tmp & 0xFF
  6040. }
  6041. return arr
  6042. }
  6043. function tripletToBase64 (num) {
  6044. return lookup[num >> 18 & 0x3F] +
  6045. lookup[num >> 12 & 0x3F] +
  6046. lookup[num >> 6 & 0x3F] +
  6047. lookup[num & 0x3F]
  6048. }
  6049. function encodeChunk (uint8, start, end) {
  6050. var tmp
  6051. var output = []
  6052. for (var i = start; i < end; i += 3) {
  6053. tmp =
  6054. ((uint8[i] << 16) & 0xFF0000) +
  6055. ((uint8[i + 1] << 8) & 0xFF00) +
  6056. (uint8[i + 2] & 0xFF)
  6057. output.push(tripletToBase64(tmp))
  6058. }
  6059. return output.join('')
  6060. }
  6061. function fromByteArray (uint8) {
  6062. var tmp
  6063. var len = uint8.length
  6064. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  6065. var parts = []
  6066. var maxChunkLength = 16383 // must be multiple of 3
  6067. // go through the array every three bytes, we'll deal with trailing stuff later
  6068. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  6069. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  6070. }
  6071. // pad the end with zeros, but make sure to not forget the extra bytes
  6072. if (extraBytes === 1) {
  6073. tmp = uint8[len - 1]
  6074. parts.push(
  6075. lookup[tmp >> 2] +
  6076. lookup[(tmp << 4) & 0x3F] +
  6077. '=='
  6078. )
  6079. } else if (extraBytes === 2) {
  6080. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  6081. parts.push(
  6082. lookup[tmp >> 10] +
  6083. lookup[(tmp >> 4) & 0x3F] +
  6084. lookup[(tmp << 2) & 0x3F] +
  6085. '='
  6086. )
  6087. }
  6088. return parts.join('')
  6089. }
  6090. },{}],9:[function(require,module,exports){
  6091. },{}],10:[function(require,module,exports){
  6092. (function (Buffer){(function (){
  6093. /*!
  6094. * The buffer module from node.js, for the browser.
  6095. *
  6096. * @author Feross Aboukhadijeh <https://feross.org>
  6097. * @license MIT
  6098. */
  6099. /* eslint-disable no-proto */
  6100. 'use strict'
  6101. var base64 = require('base64-js')
  6102. var ieee754 = require('ieee754')
  6103. exports.Buffer = Buffer
  6104. exports.SlowBuffer = SlowBuffer
  6105. exports.INSPECT_MAX_BYTES = 50
  6106. var K_MAX_LENGTH = 0x7fffffff
  6107. exports.kMaxLength = K_MAX_LENGTH
  6108. /**
  6109. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  6110. * === true Use Uint8Array implementation (fastest)
  6111. * === false Print warning and recommend using `buffer` v4.x which has an Object
  6112. * implementation (most compatible, even IE6)
  6113. *
  6114. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  6115. * Opera 11.6+, iOS 4.2+.
  6116. *
  6117. * We report that the browser does not support typed arrays if the are not subclassable
  6118. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  6119. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  6120. * for __proto__ and has a buggy typed array implementation.
  6121. */
  6122. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  6123. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  6124. typeof console.error === 'function') {
  6125. console.error(
  6126. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  6127. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  6128. )
  6129. }
  6130. function typedArraySupport () {
  6131. // Can typed array instances can be augmented?
  6132. try {
  6133. var arr = new Uint8Array(1)
  6134. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
  6135. return arr.foo() === 42
  6136. } catch (e) {
  6137. return false
  6138. }
  6139. }
  6140. Object.defineProperty(Buffer.prototype, 'parent', {
  6141. enumerable: true,
  6142. get: function () {
  6143. if (!Buffer.isBuffer(this)) return undefined
  6144. return this.buffer
  6145. }
  6146. })
  6147. Object.defineProperty(Buffer.prototype, 'offset', {
  6148. enumerable: true,
  6149. get: function () {
  6150. if (!Buffer.isBuffer(this)) return undefined
  6151. return this.byteOffset
  6152. }
  6153. })
  6154. function createBuffer (length) {
  6155. if (length > K_MAX_LENGTH) {
  6156. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  6157. }
  6158. // Return an augmented `Uint8Array` instance
  6159. var buf = new Uint8Array(length)
  6160. buf.__proto__ = Buffer.prototype
  6161. return buf
  6162. }
  6163. /**
  6164. * The Buffer constructor returns instances of `Uint8Array` that have their
  6165. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  6166. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  6167. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  6168. * returns a single octet.
  6169. *
  6170. * The `Uint8Array` prototype remains unmodified.
  6171. */
  6172. function Buffer (arg, encodingOrOffset, length) {
  6173. // Common case.
  6174. if (typeof arg === 'number') {
  6175. if (typeof encodingOrOffset === 'string') {
  6176. throw new TypeError(
  6177. 'The "string" argument must be of type string. Received type number'
  6178. )
  6179. }
  6180. return allocUnsafe(arg)
  6181. }
  6182. return from(arg, encodingOrOffset, length)
  6183. }
  6184. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  6185. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  6186. Buffer[Symbol.species] === Buffer) {
  6187. Object.defineProperty(Buffer, Symbol.species, {
  6188. value: null,
  6189. configurable: true,
  6190. enumerable: false,
  6191. writable: false
  6192. })
  6193. }
  6194. Buffer.poolSize = 8192 // not used by this implementation
  6195. function from (value, encodingOrOffset, length) {
  6196. if (typeof value === 'string') {
  6197. return fromString(value, encodingOrOffset)
  6198. }
  6199. if (ArrayBuffer.isView(value)) {
  6200. return fromArrayLike(value)
  6201. }
  6202. if (value == null) {
  6203. throw TypeError(
  6204. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  6205. 'or Array-like Object. Received type ' + (typeof value)
  6206. )
  6207. }
  6208. if (isInstance(value, ArrayBuffer) ||
  6209. (value && isInstance(value.buffer, ArrayBuffer))) {
  6210. return fromArrayBuffer(value, encodingOrOffset, length)
  6211. }
  6212. if (typeof value === 'number') {
  6213. throw new TypeError(
  6214. 'The "value" argument must not be of type number. Received type number'
  6215. )
  6216. }
  6217. var valueOf = value.valueOf && value.valueOf()
  6218. if (valueOf != null && valueOf !== value) {
  6219. return Buffer.from(valueOf, encodingOrOffset, length)
  6220. }
  6221. var b = fromObject(value)
  6222. if (b) return b
  6223. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  6224. typeof value[Symbol.toPrimitive] === 'function') {
  6225. return Buffer.from(
  6226. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  6227. )
  6228. }
  6229. throw new TypeError(
  6230. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  6231. 'or Array-like Object. Received type ' + (typeof value)
  6232. )
  6233. }
  6234. /**
  6235. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  6236. * if value is a number.
  6237. * Buffer.from(str[, encoding])
  6238. * Buffer.from(array)
  6239. * Buffer.from(buffer)
  6240. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  6241. **/
  6242. Buffer.from = function (value, encodingOrOffset, length) {
  6243. return from(value, encodingOrOffset, length)
  6244. }
  6245. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  6246. // https://github.com/feross/buffer/pull/148
  6247. Buffer.prototype.__proto__ = Uint8Array.prototype
  6248. Buffer.__proto__ = Uint8Array
  6249. function assertSize (size) {
  6250. if (typeof size !== 'number') {
  6251. throw new TypeError('"size" argument must be of type number')
  6252. } else if (size < 0) {
  6253. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  6254. }
  6255. }
  6256. function alloc (size, fill, encoding) {
  6257. assertSize(size)
  6258. if (size <= 0) {
  6259. return createBuffer(size)
  6260. }
  6261. if (fill !== undefined) {
  6262. // Only pay attention to encoding if it's a string. This
  6263. // prevents accidentally sending in a number that would
  6264. // be interpretted as a start offset.
  6265. return typeof encoding === 'string'
  6266. ? createBuffer(size).fill(fill, encoding)
  6267. : createBuffer(size).fill(fill)
  6268. }
  6269. return createBuffer(size)
  6270. }
  6271. /**
  6272. * Creates a new filled Buffer instance.
  6273. * alloc(size[, fill[, encoding]])
  6274. **/
  6275. Buffer.alloc = function (size, fill, encoding) {
  6276. return alloc(size, fill, encoding)
  6277. }
  6278. function allocUnsafe (size) {
  6279. assertSize(size)
  6280. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  6281. }
  6282. /**
  6283. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  6284. * */
  6285. Buffer.allocUnsafe = function (size) {
  6286. return allocUnsafe(size)
  6287. }
  6288. /**
  6289. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  6290. */
  6291. Buffer.allocUnsafeSlow = function (size) {
  6292. return allocUnsafe(size)
  6293. }
  6294. function fromString (string, encoding) {
  6295. if (typeof encoding !== 'string' || encoding === '') {
  6296. encoding = 'utf8'
  6297. }
  6298. if (!Buffer.isEncoding(encoding)) {
  6299. throw new TypeError('Unknown encoding: ' + encoding)
  6300. }
  6301. var length = byteLength(string, encoding) | 0
  6302. var buf = createBuffer(length)
  6303. var actual = buf.write(string, encoding)
  6304. if (actual !== length) {
  6305. // Writing a hex string, for example, that contains invalid characters will
  6306. // cause everything after the first invalid character to be ignored. (e.g.
  6307. // 'abxxcd' will be treated as 'ab')
  6308. buf = buf.slice(0, actual)
  6309. }
  6310. return buf
  6311. }
  6312. function fromArrayLike (array) {
  6313. var length = array.length < 0 ? 0 : checked(array.length) | 0
  6314. var buf = createBuffer(length)
  6315. for (var i = 0; i < length; i += 1) {
  6316. buf[i] = array[i] & 255
  6317. }
  6318. return buf
  6319. }
  6320. function fromArrayBuffer (array, byteOffset, length) {
  6321. if (byteOffset < 0 || array.byteLength < byteOffset) {
  6322. throw new RangeError('"offset" is outside of buffer bounds')
  6323. }
  6324. if (array.byteLength < byteOffset + (length || 0)) {
  6325. throw new RangeError('"length" is outside of buffer bounds')
  6326. }
  6327. var buf
  6328. if (byteOffset === undefined && length === undefined) {
  6329. buf = new Uint8Array(array)
  6330. } else if (length === undefined) {
  6331. buf = new Uint8Array(array, byteOffset)
  6332. } else {
  6333. buf = new Uint8Array(array, byteOffset, length)
  6334. }
  6335. // Return an augmented `Uint8Array` instance
  6336. buf.__proto__ = Buffer.prototype
  6337. return buf
  6338. }
  6339. function fromObject (obj) {
  6340. if (Buffer.isBuffer(obj)) {
  6341. var len = checked(obj.length) | 0
  6342. var buf = createBuffer(len)
  6343. if (buf.length === 0) {
  6344. return buf
  6345. }
  6346. obj.copy(buf, 0, 0, len)
  6347. return buf
  6348. }
  6349. if (obj.length !== undefined) {
  6350. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  6351. return createBuffer(0)
  6352. }
  6353. return fromArrayLike(obj)
  6354. }
  6355. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  6356. return fromArrayLike(obj.data)
  6357. }
  6358. }
  6359. function checked (length) {
  6360. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  6361. // length is NaN (which is otherwise coerced to zero.)
  6362. if (length >= K_MAX_LENGTH) {
  6363. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  6364. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  6365. }
  6366. return length | 0
  6367. }
  6368. function SlowBuffer (length) {
  6369. if (+length != length) { // eslint-disable-line eqeqeq
  6370. length = 0
  6371. }
  6372. return Buffer.alloc(+length)
  6373. }
  6374. Buffer.isBuffer = function isBuffer (b) {
  6375. return b != null && b._isBuffer === true &&
  6376. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  6377. }
  6378. Buffer.compare = function compare (a, b) {
  6379. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  6380. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  6381. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  6382. throw new TypeError(
  6383. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  6384. )
  6385. }
  6386. if (a === b) return 0
  6387. var x = a.length
  6388. var y = b.length
  6389. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  6390. if (a[i] !== b[i]) {
  6391. x = a[i]
  6392. y = b[i]
  6393. break
  6394. }
  6395. }
  6396. if (x < y) return -1
  6397. if (y < x) return 1
  6398. return 0
  6399. }
  6400. Buffer.isEncoding = function isEncoding (encoding) {
  6401. switch (String(encoding).toLowerCase()) {
  6402. case 'hex':
  6403. case 'utf8':
  6404. case 'utf-8':
  6405. case 'ascii':
  6406. case 'latin1':
  6407. case 'binary':
  6408. case 'base64':
  6409. case 'ucs2':
  6410. case 'ucs-2':
  6411. case 'utf16le':
  6412. case 'utf-16le':
  6413. return true
  6414. default:
  6415. return false
  6416. }
  6417. }
  6418. Buffer.concat = function concat (list, length) {
  6419. if (!Array.isArray(list)) {
  6420. throw new TypeError('"list" argument must be an Array of Buffers')
  6421. }
  6422. if (list.length === 0) {
  6423. return Buffer.alloc(0)
  6424. }
  6425. var i
  6426. if (length === undefined) {
  6427. length = 0
  6428. for (i = 0; i < list.length; ++i) {
  6429. length += list[i].length
  6430. }
  6431. }
  6432. var buffer = Buffer.allocUnsafe(length)
  6433. var pos = 0
  6434. for (i = 0; i < list.length; ++i) {
  6435. var buf = list[i]
  6436. if (isInstance(buf, Uint8Array)) {
  6437. buf = Buffer.from(buf)
  6438. }
  6439. if (!Buffer.isBuffer(buf)) {
  6440. throw new TypeError('"list" argument must be an Array of Buffers')
  6441. }
  6442. buf.copy(buffer, pos)
  6443. pos += buf.length
  6444. }
  6445. return buffer
  6446. }
  6447. function byteLength (string, encoding) {
  6448. if (Buffer.isBuffer(string)) {
  6449. return string.length
  6450. }
  6451. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  6452. return string.byteLength
  6453. }
  6454. if (typeof string !== 'string') {
  6455. throw new TypeError(
  6456. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  6457. 'Received type ' + typeof string
  6458. )
  6459. }
  6460. var len = string.length
  6461. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  6462. if (!mustMatch && len === 0) return 0
  6463. // Use a for loop to avoid recursion
  6464. var loweredCase = false
  6465. for (;;) {
  6466. switch (encoding) {
  6467. case 'ascii':
  6468. case 'latin1':
  6469. case 'binary':
  6470. return len
  6471. case 'utf8':
  6472. case 'utf-8':
  6473. return utf8ToBytes(string).length
  6474. case 'ucs2':
  6475. case 'ucs-2':
  6476. case 'utf16le':
  6477. case 'utf-16le':
  6478. return len * 2
  6479. case 'hex':
  6480. return len >>> 1
  6481. case 'base64':
  6482. return base64ToBytes(string).length
  6483. default:
  6484. if (loweredCase) {
  6485. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  6486. }
  6487. encoding = ('' + encoding).toLowerCase()
  6488. loweredCase = true
  6489. }
  6490. }
  6491. }
  6492. Buffer.byteLength = byteLength
  6493. function slowToString (encoding, start, end) {
  6494. var loweredCase = false
  6495. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  6496. // property of a typed array.
  6497. // This behaves neither like String nor Uint8Array in that we set start/end
  6498. // to their upper/lower bounds if the value passed is out of range.
  6499. // undefined is handled specially as per ECMA-262 6th Edition,
  6500. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  6501. if (start === undefined || start < 0) {
  6502. start = 0
  6503. }
  6504. // Return early if start > this.length. Done here to prevent potential uint32
  6505. // coercion fail below.
  6506. if (start > this.length) {
  6507. return ''
  6508. }
  6509. if (end === undefined || end > this.length) {
  6510. end = this.length
  6511. }
  6512. if (end <= 0) {
  6513. return ''
  6514. }
  6515. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  6516. end >>>= 0
  6517. start >>>= 0
  6518. if (end <= start) {
  6519. return ''
  6520. }
  6521. if (!encoding) encoding = 'utf8'
  6522. while (true) {
  6523. switch (encoding) {
  6524. case 'hex':
  6525. return hexSlice(this, start, end)
  6526. case 'utf8':
  6527. case 'utf-8':
  6528. return utf8Slice(this, start, end)
  6529. case 'ascii':
  6530. return asciiSlice(this, start, end)
  6531. case 'latin1':
  6532. case 'binary':
  6533. return latin1Slice(this, start, end)
  6534. case 'base64':
  6535. return base64Slice(this, start, end)
  6536. case 'ucs2':
  6537. case 'ucs-2':
  6538. case 'utf16le':
  6539. case 'utf-16le':
  6540. return utf16leSlice(this, start, end)
  6541. default:
  6542. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6543. encoding = (encoding + '').toLowerCase()
  6544. loweredCase = true
  6545. }
  6546. }
  6547. }
  6548. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  6549. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  6550. // reliably in a browserify context because there could be multiple different
  6551. // copies of the 'buffer' package in use. This method works even for Buffer
  6552. // instances that were created from another copy of the `buffer` package.
  6553. // See: https://github.com/feross/buffer/issues/154
  6554. Buffer.prototype._isBuffer = true
  6555. function swap (b, n, m) {
  6556. var i = b[n]
  6557. b[n] = b[m]
  6558. b[m] = i
  6559. }
  6560. Buffer.prototype.swap16 = function swap16 () {
  6561. var len = this.length
  6562. if (len % 2 !== 0) {
  6563. throw new RangeError('Buffer size must be a multiple of 16-bits')
  6564. }
  6565. for (var i = 0; i < len; i += 2) {
  6566. swap(this, i, i + 1)
  6567. }
  6568. return this
  6569. }
  6570. Buffer.prototype.swap32 = function swap32 () {
  6571. var len = this.length
  6572. if (len % 4 !== 0) {
  6573. throw new RangeError('Buffer size must be a multiple of 32-bits')
  6574. }
  6575. for (var i = 0; i < len; i += 4) {
  6576. swap(this, i, i + 3)
  6577. swap(this, i + 1, i + 2)
  6578. }
  6579. return this
  6580. }
  6581. Buffer.prototype.swap64 = function swap64 () {
  6582. var len = this.length
  6583. if (len % 8 !== 0) {
  6584. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6585. }
  6586. for (var i = 0; i < len; i += 8) {
  6587. swap(this, i, i + 7)
  6588. swap(this, i + 1, i + 6)
  6589. swap(this, i + 2, i + 5)
  6590. swap(this, i + 3, i + 4)
  6591. }
  6592. return this
  6593. }
  6594. Buffer.prototype.toString = function toString () {
  6595. var length = this.length
  6596. if (length === 0) return ''
  6597. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6598. return slowToString.apply(this, arguments)
  6599. }
  6600. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  6601. Buffer.prototype.equals = function equals (b) {
  6602. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6603. if (this === b) return true
  6604. return Buffer.compare(this, b) === 0
  6605. }
  6606. Buffer.prototype.inspect = function inspect () {
  6607. var str = ''
  6608. var max = exports.INSPECT_MAX_BYTES
  6609. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  6610. if (this.length > max) str += ' ... '
  6611. return '<Buffer ' + str + '>'
  6612. }
  6613. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6614. if (isInstance(target, Uint8Array)) {
  6615. target = Buffer.from(target, target.offset, target.byteLength)
  6616. }
  6617. if (!Buffer.isBuffer(target)) {
  6618. throw new TypeError(
  6619. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  6620. 'Received type ' + (typeof target)
  6621. )
  6622. }
  6623. if (start === undefined) {
  6624. start = 0
  6625. }
  6626. if (end === undefined) {
  6627. end = target ? target.length : 0
  6628. }
  6629. if (thisStart === undefined) {
  6630. thisStart = 0
  6631. }
  6632. if (thisEnd === undefined) {
  6633. thisEnd = this.length
  6634. }
  6635. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6636. throw new RangeError('out of range index')
  6637. }
  6638. if (thisStart >= thisEnd && start >= end) {
  6639. return 0
  6640. }
  6641. if (thisStart >= thisEnd) {
  6642. return -1
  6643. }
  6644. if (start >= end) {
  6645. return 1
  6646. }
  6647. start >>>= 0
  6648. end >>>= 0
  6649. thisStart >>>= 0
  6650. thisEnd >>>= 0
  6651. if (this === target) return 0
  6652. var x = thisEnd - thisStart
  6653. var y = end - start
  6654. var len = Math.min(x, y)
  6655. var thisCopy = this.slice(thisStart, thisEnd)
  6656. var targetCopy = target.slice(start, end)
  6657. for (var i = 0; i < len; ++i) {
  6658. if (thisCopy[i] !== targetCopy[i]) {
  6659. x = thisCopy[i]
  6660. y = targetCopy[i]
  6661. break
  6662. }
  6663. }
  6664. if (x < y) return -1
  6665. if (y < x) return 1
  6666. return 0
  6667. }
  6668. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6669. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6670. //
  6671. // Arguments:
  6672. // - buffer - a Buffer to search
  6673. // - val - a string, Buffer, or number
  6674. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6675. // - encoding - an optional encoding, relevant is val is a string
  6676. // - dir - true for indexOf, false for lastIndexOf
  6677. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6678. // Empty buffer means no match
  6679. if (buffer.length === 0) return -1
  6680. // Normalize byteOffset
  6681. if (typeof byteOffset === 'string') {
  6682. encoding = byteOffset
  6683. byteOffset = 0
  6684. } else if (byteOffset > 0x7fffffff) {
  6685. byteOffset = 0x7fffffff
  6686. } else if (byteOffset < -0x80000000) {
  6687. byteOffset = -0x80000000
  6688. }
  6689. byteOffset = +byteOffset // Coerce to Number.
  6690. if (numberIsNaN(byteOffset)) {
  6691. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6692. byteOffset = dir ? 0 : (buffer.length - 1)
  6693. }
  6694. // Normalize byteOffset: negative offsets start from the end of the buffer
  6695. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6696. if (byteOffset >= buffer.length) {
  6697. if (dir) return -1
  6698. else byteOffset = buffer.length - 1
  6699. } else if (byteOffset < 0) {
  6700. if (dir) byteOffset = 0
  6701. else return -1
  6702. }
  6703. // Normalize val
  6704. if (typeof val === 'string') {
  6705. val = Buffer.from(val, encoding)
  6706. }
  6707. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6708. if (Buffer.isBuffer(val)) {
  6709. // Special case: looking for empty string/buffer always fails
  6710. if (val.length === 0) {
  6711. return -1
  6712. }
  6713. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6714. } else if (typeof val === 'number') {
  6715. val = val & 0xFF // Search for a byte value [0-255]
  6716. if (typeof Uint8Array.prototype.indexOf === 'function') {
  6717. if (dir) {
  6718. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6719. } else {
  6720. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6721. }
  6722. }
  6723. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6724. }
  6725. throw new TypeError('val must be string, number or Buffer')
  6726. }
  6727. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6728. var indexSize = 1
  6729. var arrLength = arr.length
  6730. var valLength = val.length
  6731. if (encoding !== undefined) {
  6732. encoding = String(encoding).toLowerCase()
  6733. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6734. encoding === 'utf16le' || encoding === 'utf-16le') {
  6735. if (arr.length < 2 || val.length < 2) {
  6736. return -1
  6737. }
  6738. indexSize = 2
  6739. arrLength /= 2
  6740. valLength /= 2
  6741. byteOffset /= 2
  6742. }
  6743. }
  6744. function read (buf, i) {
  6745. if (indexSize === 1) {
  6746. return buf[i]
  6747. } else {
  6748. return buf.readUInt16BE(i * indexSize)
  6749. }
  6750. }
  6751. var i
  6752. if (dir) {
  6753. var foundIndex = -1
  6754. for (i = byteOffset; i < arrLength; i++) {
  6755. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6756. if (foundIndex === -1) foundIndex = i
  6757. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6758. } else {
  6759. if (foundIndex !== -1) i -= i - foundIndex
  6760. foundIndex = -1
  6761. }
  6762. }
  6763. } else {
  6764. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6765. for (i = byteOffset; i >= 0; i--) {
  6766. var found = true
  6767. for (var j = 0; j < valLength; j++) {
  6768. if (read(arr, i + j) !== read(val, j)) {
  6769. found = false
  6770. break
  6771. }
  6772. }
  6773. if (found) return i
  6774. }
  6775. }
  6776. return -1
  6777. }
  6778. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6779. return this.indexOf(val, byteOffset, encoding) !== -1
  6780. }
  6781. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6782. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6783. }
  6784. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6785. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6786. }
  6787. function hexWrite (buf, string, offset, length) {
  6788. offset = Number(offset) || 0
  6789. var remaining = buf.length - offset
  6790. if (!length) {
  6791. length = remaining
  6792. } else {
  6793. length = Number(length)
  6794. if (length > remaining) {
  6795. length = remaining
  6796. }
  6797. }
  6798. var strLen = string.length
  6799. if (length > strLen / 2) {
  6800. length = strLen / 2
  6801. }
  6802. for (var i = 0; i < length; ++i) {
  6803. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6804. if (numberIsNaN(parsed)) return i
  6805. buf[offset + i] = parsed
  6806. }
  6807. return i
  6808. }
  6809. function utf8Write (buf, string, offset, length) {
  6810. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6811. }
  6812. function asciiWrite (buf, string, offset, length) {
  6813. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6814. }
  6815. function latin1Write (buf, string, offset, length) {
  6816. return asciiWrite(buf, string, offset, length)
  6817. }
  6818. function base64Write (buf, string, offset, length) {
  6819. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6820. }
  6821. function ucs2Write (buf, string, offset, length) {
  6822. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6823. }
  6824. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6825. // Buffer#write(string)
  6826. if (offset === undefined) {
  6827. encoding = 'utf8'
  6828. length = this.length
  6829. offset = 0
  6830. // Buffer#write(string, encoding)
  6831. } else if (length === undefined && typeof offset === 'string') {
  6832. encoding = offset
  6833. length = this.length
  6834. offset = 0
  6835. // Buffer#write(string, offset[, length][, encoding])
  6836. } else if (isFinite(offset)) {
  6837. offset = offset >>> 0
  6838. if (isFinite(length)) {
  6839. length = length >>> 0
  6840. if (encoding === undefined) encoding = 'utf8'
  6841. } else {
  6842. encoding = length
  6843. length = undefined
  6844. }
  6845. } else {
  6846. throw new Error(
  6847. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6848. )
  6849. }
  6850. var remaining = this.length - offset
  6851. if (length === undefined || length > remaining) length = remaining
  6852. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6853. throw new RangeError('Attempt to write outside buffer bounds')
  6854. }
  6855. if (!encoding) encoding = 'utf8'
  6856. var loweredCase = false
  6857. for (;;) {
  6858. switch (encoding) {
  6859. case 'hex':
  6860. return hexWrite(this, string, offset, length)
  6861. case 'utf8':
  6862. case 'utf-8':
  6863. return utf8Write(this, string, offset, length)
  6864. case 'ascii':
  6865. return asciiWrite(this, string, offset, length)
  6866. case 'latin1':
  6867. case 'binary':
  6868. return latin1Write(this, string, offset, length)
  6869. case 'base64':
  6870. // Warning: maxLength not taken into account in base64Write
  6871. return base64Write(this, string, offset, length)
  6872. case 'ucs2':
  6873. case 'ucs-2':
  6874. case 'utf16le':
  6875. case 'utf-16le':
  6876. return ucs2Write(this, string, offset, length)
  6877. default:
  6878. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6879. encoding = ('' + encoding).toLowerCase()
  6880. loweredCase = true
  6881. }
  6882. }
  6883. }
  6884. Buffer.prototype.toJSON = function toJSON () {
  6885. return {
  6886. type: 'Buffer',
  6887. data: Array.prototype.slice.call(this._arr || this, 0)
  6888. }
  6889. }
  6890. function base64Slice (buf, start, end) {
  6891. if (start === 0 && end === buf.length) {
  6892. return base64.fromByteArray(buf)
  6893. } else {
  6894. return base64.fromByteArray(buf.slice(start, end))
  6895. }
  6896. }
  6897. function utf8Slice (buf, start, end) {
  6898. end = Math.min(buf.length, end)
  6899. var res = []
  6900. var i = start
  6901. while (i < end) {
  6902. var firstByte = buf[i]
  6903. var codePoint = null
  6904. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6905. : (firstByte > 0xDF) ? 3
  6906. : (firstByte > 0xBF) ? 2
  6907. : 1
  6908. if (i + bytesPerSequence <= end) {
  6909. var secondByte, thirdByte, fourthByte, tempCodePoint
  6910. switch (bytesPerSequence) {
  6911. case 1:
  6912. if (firstByte < 0x80) {
  6913. codePoint = firstByte
  6914. }
  6915. break
  6916. case 2:
  6917. secondByte = buf[i + 1]
  6918. if ((secondByte & 0xC0) === 0x80) {
  6919. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6920. if (tempCodePoint > 0x7F) {
  6921. codePoint = tempCodePoint
  6922. }
  6923. }
  6924. break
  6925. case 3:
  6926. secondByte = buf[i + 1]
  6927. thirdByte = buf[i + 2]
  6928. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6929. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6930. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6931. codePoint = tempCodePoint
  6932. }
  6933. }
  6934. break
  6935. case 4:
  6936. secondByte = buf[i + 1]
  6937. thirdByte = buf[i + 2]
  6938. fourthByte = buf[i + 3]
  6939. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6940. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6941. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6942. codePoint = tempCodePoint
  6943. }
  6944. }
  6945. }
  6946. }
  6947. if (codePoint === null) {
  6948. // we did not generate a valid codePoint so insert a
  6949. // replacement char (U+FFFD) and advance only 1 byte
  6950. codePoint = 0xFFFD
  6951. bytesPerSequence = 1
  6952. } else if (codePoint > 0xFFFF) {
  6953. // encode to utf16 (surrogate pair dance)
  6954. codePoint -= 0x10000
  6955. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6956. codePoint = 0xDC00 | codePoint & 0x3FF
  6957. }
  6958. res.push(codePoint)
  6959. i += bytesPerSequence
  6960. }
  6961. return decodeCodePointsArray(res)
  6962. }
  6963. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6964. // the lowest limit is Chrome, with 0x10000 args.
  6965. // We go 1 magnitude less, for safety
  6966. var MAX_ARGUMENTS_LENGTH = 0x1000
  6967. function decodeCodePointsArray (codePoints) {
  6968. var len = codePoints.length
  6969. if (len <= MAX_ARGUMENTS_LENGTH) {
  6970. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6971. }
  6972. // Decode in chunks to avoid "call stack size exceeded".
  6973. var res = ''
  6974. var i = 0
  6975. while (i < len) {
  6976. res += String.fromCharCode.apply(
  6977. String,
  6978. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6979. )
  6980. }
  6981. return res
  6982. }
  6983. function asciiSlice (buf, start, end) {
  6984. var ret = ''
  6985. end = Math.min(buf.length, end)
  6986. for (var i = start; i < end; ++i) {
  6987. ret += String.fromCharCode(buf[i] & 0x7F)
  6988. }
  6989. return ret
  6990. }
  6991. function latin1Slice (buf, start, end) {
  6992. var ret = ''
  6993. end = Math.min(buf.length, end)
  6994. for (var i = start; i < end; ++i) {
  6995. ret += String.fromCharCode(buf[i])
  6996. }
  6997. return ret
  6998. }
  6999. function hexSlice (buf, start, end) {
  7000. var len = buf.length
  7001. if (!start || start < 0) start = 0
  7002. if (!end || end < 0 || end > len) end = len
  7003. var out = ''
  7004. for (var i = start; i < end; ++i) {
  7005. out += toHex(buf[i])
  7006. }
  7007. return out
  7008. }
  7009. function utf16leSlice (buf, start, end) {
  7010. var bytes = buf.slice(start, end)
  7011. var res = ''
  7012. for (var i = 0; i < bytes.length; i += 2) {
  7013. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  7014. }
  7015. return res
  7016. }
  7017. Buffer.prototype.slice = function slice (start, end) {
  7018. var len = this.length
  7019. start = ~~start
  7020. end = end === undefined ? len : ~~end
  7021. if (start < 0) {
  7022. start += len
  7023. if (start < 0) start = 0
  7024. } else if (start > len) {
  7025. start = len
  7026. }
  7027. if (end < 0) {
  7028. end += len
  7029. if (end < 0) end = 0
  7030. } else if (end > len) {
  7031. end = len
  7032. }
  7033. if (end < start) end = start
  7034. var newBuf = this.subarray(start, end)
  7035. // Return an augmented `Uint8Array` instance
  7036. newBuf.__proto__ = Buffer.prototype
  7037. return newBuf
  7038. }
  7039. /*
  7040. * Need to make sure that buffer isn't trying to write out of bounds.
  7041. */
  7042. function checkOffset (offset, ext, length) {
  7043. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  7044. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  7045. }
  7046. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  7047. offset = offset >>> 0
  7048. byteLength = byteLength >>> 0
  7049. if (!noAssert) checkOffset(offset, byteLength, this.length)
  7050. var val = this[offset]
  7051. var mul = 1
  7052. var i = 0
  7053. while (++i < byteLength && (mul *= 0x100)) {
  7054. val += this[offset + i] * mul
  7055. }
  7056. return val
  7057. }
  7058. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  7059. offset = offset >>> 0
  7060. byteLength = byteLength >>> 0
  7061. if (!noAssert) {
  7062. checkOffset(offset, byteLength, this.length)
  7063. }
  7064. var val = this[offset + --byteLength]
  7065. var mul = 1
  7066. while (byteLength > 0 && (mul *= 0x100)) {
  7067. val += this[offset + --byteLength] * mul
  7068. }
  7069. return val
  7070. }
  7071. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  7072. offset = offset >>> 0
  7073. if (!noAssert) checkOffset(offset, 1, this.length)
  7074. return this[offset]
  7075. }
  7076. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  7077. offset = offset >>> 0
  7078. if (!noAssert) checkOffset(offset, 2, this.length)
  7079. return this[offset] | (this[offset + 1] << 8)
  7080. }
  7081. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  7082. offset = offset >>> 0
  7083. if (!noAssert) checkOffset(offset, 2, this.length)
  7084. return (this[offset] << 8) | this[offset + 1]
  7085. }
  7086. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  7087. offset = offset >>> 0
  7088. if (!noAssert) checkOffset(offset, 4, this.length)
  7089. return ((this[offset]) |
  7090. (this[offset + 1] << 8) |
  7091. (this[offset + 2] << 16)) +
  7092. (this[offset + 3] * 0x1000000)
  7093. }
  7094. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  7095. offset = offset >>> 0
  7096. if (!noAssert) checkOffset(offset, 4, this.length)
  7097. return (this[offset] * 0x1000000) +
  7098. ((this[offset + 1] << 16) |
  7099. (this[offset + 2] << 8) |
  7100. this[offset + 3])
  7101. }
  7102. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  7103. offset = offset >>> 0
  7104. byteLength = byteLength >>> 0
  7105. if (!noAssert) checkOffset(offset, byteLength, this.length)
  7106. var val = this[offset]
  7107. var mul = 1
  7108. var i = 0
  7109. while (++i < byteLength && (mul *= 0x100)) {
  7110. val += this[offset + i] * mul
  7111. }
  7112. mul *= 0x80
  7113. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  7114. return val
  7115. }
  7116. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  7117. offset = offset >>> 0
  7118. byteLength = byteLength >>> 0
  7119. if (!noAssert) checkOffset(offset, byteLength, this.length)
  7120. var i = byteLength
  7121. var mul = 1
  7122. var val = this[offset + --i]
  7123. while (i > 0 && (mul *= 0x100)) {
  7124. val += this[offset + --i] * mul
  7125. }
  7126. mul *= 0x80
  7127. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  7128. return val
  7129. }
  7130. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  7131. offset = offset >>> 0
  7132. if (!noAssert) checkOffset(offset, 1, this.length)
  7133. if (!(this[offset] & 0x80)) return (this[offset])
  7134. return ((0xff - this[offset] + 1) * -1)
  7135. }
  7136. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  7137. offset = offset >>> 0
  7138. if (!noAssert) checkOffset(offset, 2, this.length)
  7139. var val = this[offset] | (this[offset + 1] << 8)
  7140. return (val & 0x8000) ? val | 0xFFFF0000 : val
  7141. }
  7142. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  7143. offset = offset >>> 0
  7144. if (!noAssert) checkOffset(offset, 2, this.length)
  7145. var val = this[offset + 1] | (this[offset] << 8)
  7146. return (val & 0x8000) ? val | 0xFFFF0000 : val
  7147. }
  7148. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  7149. offset = offset >>> 0
  7150. if (!noAssert) checkOffset(offset, 4, this.length)
  7151. return (this[offset]) |
  7152. (this[offset + 1] << 8) |
  7153. (this[offset + 2] << 16) |
  7154. (this[offset + 3] << 24)
  7155. }
  7156. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  7157. offset = offset >>> 0
  7158. if (!noAssert) checkOffset(offset, 4, this.length)
  7159. return (this[offset] << 24) |
  7160. (this[offset + 1] << 16) |
  7161. (this[offset + 2] << 8) |
  7162. (this[offset + 3])
  7163. }
  7164. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  7165. offset = offset >>> 0
  7166. if (!noAssert) checkOffset(offset, 4, this.length)
  7167. return ieee754.read(this, offset, true, 23, 4)
  7168. }
  7169. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  7170. offset = offset >>> 0
  7171. if (!noAssert) checkOffset(offset, 4, this.length)
  7172. return ieee754.read(this, offset, false, 23, 4)
  7173. }
  7174. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  7175. offset = offset >>> 0
  7176. if (!noAssert) checkOffset(offset, 8, this.length)
  7177. return ieee754.read(this, offset, true, 52, 8)
  7178. }
  7179. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  7180. offset = offset >>> 0
  7181. if (!noAssert) checkOffset(offset, 8, this.length)
  7182. return ieee754.read(this, offset, false, 52, 8)
  7183. }
  7184. function checkInt (buf, value, offset, ext, max, min) {
  7185. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  7186. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  7187. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  7188. }
  7189. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  7190. value = +value
  7191. offset = offset >>> 0
  7192. byteLength = byteLength >>> 0
  7193. if (!noAssert) {
  7194. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  7195. checkInt(this, value, offset, byteLength, maxBytes, 0)
  7196. }
  7197. var mul = 1
  7198. var i = 0
  7199. this[offset] = value & 0xFF
  7200. while (++i < byteLength && (mul *= 0x100)) {
  7201. this[offset + i] = (value / mul) & 0xFF
  7202. }
  7203. return offset + byteLength
  7204. }
  7205. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  7206. value = +value
  7207. offset = offset >>> 0
  7208. byteLength = byteLength >>> 0
  7209. if (!noAssert) {
  7210. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  7211. checkInt(this, value, offset, byteLength, maxBytes, 0)
  7212. }
  7213. var i = byteLength - 1
  7214. var mul = 1
  7215. this[offset + i] = value & 0xFF
  7216. while (--i >= 0 && (mul *= 0x100)) {
  7217. this[offset + i] = (value / mul) & 0xFF
  7218. }
  7219. return offset + byteLength
  7220. }
  7221. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  7222. value = +value
  7223. offset = offset >>> 0
  7224. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  7225. this[offset] = (value & 0xff)
  7226. return offset + 1
  7227. }
  7228. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  7229. value = +value
  7230. offset = offset >>> 0
  7231. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  7232. this[offset] = (value & 0xff)
  7233. this[offset + 1] = (value >>> 8)
  7234. return offset + 2
  7235. }
  7236. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  7237. value = +value
  7238. offset = offset >>> 0
  7239. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  7240. this[offset] = (value >>> 8)
  7241. this[offset + 1] = (value & 0xff)
  7242. return offset + 2
  7243. }
  7244. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  7245. value = +value
  7246. offset = offset >>> 0
  7247. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  7248. this[offset + 3] = (value >>> 24)
  7249. this[offset + 2] = (value >>> 16)
  7250. this[offset + 1] = (value >>> 8)
  7251. this[offset] = (value & 0xff)
  7252. return offset + 4
  7253. }
  7254. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  7255. value = +value
  7256. offset = offset >>> 0
  7257. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  7258. this[offset] = (value >>> 24)
  7259. this[offset + 1] = (value >>> 16)
  7260. this[offset + 2] = (value >>> 8)
  7261. this[offset + 3] = (value & 0xff)
  7262. return offset + 4
  7263. }
  7264. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  7265. value = +value
  7266. offset = offset >>> 0
  7267. if (!noAssert) {
  7268. var limit = Math.pow(2, (8 * byteLength) - 1)
  7269. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  7270. }
  7271. var i = 0
  7272. var mul = 1
  7273. var sub = 0
  7274. this[offset] = value & 0xFF
  7275. while (++i < byteLength && (mul *= 0x100)) {
  7276. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  7277. sub = 1
  7278. }
  7279. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  7280. }
  7281. return offset + byteLength
  7282. }
  7283. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  7284. value = +value
  7285. offset = offset >>> 0
  7286. if (!noAssert) {
  7287. var limit = Math.pow(2, (8 * byteLength) - 1)
  7288. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  7289. }
  7290. var i = byteLength - 1
  7291. var mul = 1
  7292. var sub = 0
  7293. this[offset + i] = value & 0xFF
  7294. while (--i >= 0 && (mul *= 0x100)) {
  7295. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  7296. sub = 1
  7297. }
  7298. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  7299. }
  7300. return offset + byteLength
  7301. }
  7302. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  7303. value = +value
  7304. offset = offset >>> 0
  7305. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  7306. if (value < 0) value = 0xff + value + 1
  7307. this[offset] = (value & 0xff)
  7308. return offset + 1
  7309. }
  7310. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  7311. value = +value
  7312. offset = offset >>> 0
  7313. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  7314. this[offset] = (value & 0xff)
  7315. this[offset + 1] = (value >>> 8)
  7316. return offset + 2
  7317. }
  7318. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  7319. value = +value
  7320. offset = offset >>> 0
  7321. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  7322. this[offset] = (value >>> 8)
  7323. this[offset + 1] = (value & 0xff)
  7324. return offset + 2
  7325. }
  7326. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  7327. value = +value
  7328. offset = offset >>> 0
  7329. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  7330. this[offset] = (value & 0xff)
  7331. this[offset + 1] = (value >>> 8)
  7332. this[offset + 2] = (value >>> 16)
  7333. this[offset + 3] = (value >>> 24)
  7334. return offset + 4
  7335. }
  7336. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  7337. value = +value
  7338. offset = offset >>> 0
  7339. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  7340. if (value < 0) value = 0xffffffff + value + 1
  7341. this[offset] = (value >>> 24)
  7342. this[offset + 1] = (value >>> 16)
  7343. this[offset + 2] = (value >>> 8)
  7344. this[offset + 3] = (value & 0xff)
  7345. return offset + 4
  7346. }
  7347. function checkIEEE754 (buf, value, offset, ext, max, min) {
  7348. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  7349. if (offset < 0) throw new RangeError('Index out of range')
  7350. }
  7351. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  7352. value = +value
  7353. offset = offset >>> 0
  7354. if (!noAssert) {
  7355. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  7356. }
  7357. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  7358. return offset + 4
  7359. }
  7360. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  7361. return writeFloat(this, value, offset, true, noAssert)
  7362. }
  7363. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  7364. return writeFloat(this, value, offset, false, noAssert)
  7365. }
  7366. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  7367. value = +value
  7368. offset = offset >>> 0
  7369. if (!noAssert) {
  7370. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  7371. }
  7372. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  7373. return offset + 8
  7374. }
  7375. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  7376. return writeDouble(this, value, offset, true, noAssert)
  7377. }
  7378. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  7379. return writeDouble(this, value, offset, false, noAssert)
  7380. }
  7381. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  7382. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  7383. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  7384. if (!start) start = 0
  7385. if (!end && end !== 0) end = this.length
  7386. if (targetStart >= target.length) targetStart = target.length
  7387. if (!targetStart) targetStart = 0
  7388. if (end > 0 && end < start) end = start
  7389. // Copy 0 bytes; we're done
  7390. if (end === start) return 0
  7391. if (target.length === 0 || this.length === 0) return 0
  7392. // Fatal error conditions
  7393. if (targetStart < 0) {
  7394. throw new RangeError('targetStart out of bounds')
  7395. }
  7396. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  7397. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  7398. // Are we oob?
  7399. if (end > this.length) end = this.length
  7400. if (target.length - targetStart < end - start) {
  7401. end = target.length - targetStart + start
  7402. }
  7403. var len = end - start
  7404. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  7405. // Use built-in when available, missing from IE11
  7406. this.copyWithin(targetStart, start, end)
  7407. } else if (this === target && start < targetStart && targetStart < end) {
  7408. // descending copy from end
  7409. for (var i = len - 1; i >= 0; --i) {
  7410. target[i + targetStart] = this[i + start]
  7411. }
  7412. } else {
  7413. Uint8Array.prototype.set.call(
  7414. target,
  7415. this.subarray(start, end),
  7416. targetStart
  7417. )
  7418. }
  7419. return len
  7420. }
  7421. // Usage:
  7422. // buffer.fill(number[, offset[, end]])
  7423. // buffer.fill(buffer[, offset[, end]])
  7424. // buffer.fill(string[, offset[, end]][, encoding])
  7425. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  7426. // Handle string cases:
  7427. if (typeof val === 'string') {
  7428. if (typeof start === 'string') {
  7429. encoding = start
  7430. start = 0
  7431. end = this.length
  7432. } else if (typeof end === 'string') {
  7433. encoding = end
  7434. end = this.length
  7435. }
  7436. if (encoding !== undefined && typeof encoding !== 'string') {
  7437. throw new TypeError('encoding must be a string')
  7438. }
  7439. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  7440. throw new TypeError('Unknown encoding: ' + encoding)
  7441. }
  7442. if (val.length === 1) {
  7443. var code = val.charCodeAt(0)
  7444. if ((encoding === 'utf8' && code < 128) ||
  7445. encoding === 'latin1') {
  7446. // Fast path: If `val` fits into a single byte, use that numeric value.
  7447. val = code
  7448. }
  7449. }
  7450. } else if (typeof val === 'number') {
  7451. val = val & 255
  7452. }
  7453. // Invalid ranges are not set to a default, so can range check early.
  7454. if (start < 0 || this.length < start || this.length < end) {
  7455. throw new RangeError('Out of range index')
  7456. }
  7457. if (end <= start) {
  7458. return this
  7459. }
  7460. start = start >>> 0
  7461. end = end === undefined ? this.length : end >>> 0
  7462. if (!val) val = 0
  7463. var i
  7464. if (typeof val === 'number') {
  7465. for (i = start; i < end; ++i) {
  7466. this[i] = val
  7467. }
  7468. } else {
  7469. var bytes = Buffer.isBuffer(val)
  7470. ? val
  7471. : Buffer.from(val, encoding)
  7472. var len = bytes.length
  7473. if (len === 0) {
  7474. throw new TypeError('The value "' + val +
  7475. '" is invalid for argument "value"')
  7476. }
  7477. for (i = 0; i < end - start; ++i) {
  7478. this[i + start] = bytes[i % len]
  7479. }
  7480. }
  7481. return this
  7482. }
  7483. // HELPER FUNCTIONS
  7484. // ================
  7485. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  7486. function base64clean (str) {
  7487. // Node takes equal signs as end of the Base64 encoding
  7488. str = str.split('=')[0]
  7489. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  7490. str = str.trim().replace(INVALID_BASE64_RE, '')
  7491. // Node converts strings with length < 2 to ''
  7492. if (str.length < 2) return ''
  7493. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  7494. while (str.length % 4 !== 0) {
  7495. str = str + '='
  7496. }
  7497. return str
  7498. }
  7499. function toHex (n) {
  7500. if (n < 16) return '0' + n.toString(16)
  7501. return n.toString(16)
  7502. }
  7503. function utf8ToBytes (string, units) {
  7504. units = units || Infinity
  7505. var codePoint
  7506. var length = string.length
  7507. var leadSurrogate = null
  7508. var bytes = []
  7509. for (var i = 0; i < length; ++i) {
  7510. codePoint = string.charCodeAt(i)
  7511. // is surrogate component
  7512. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  7513. // last char was a lead
  7514. if (!leadSurrogate) {
  7515. // no lead yet
  7516. if (codePoint > 0xDBFF) {
  7517. // unexpected trail
  7518. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7519. continue
  7520. } else if (i + 1 === length) {
  7521. // unpaired lead
  7522. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7523. continue
  7524. }
  7525. // valid lead
  7526. leadSurrogate = codePoint
  7527. continue
  7528. }
  7529. // 2 leads in a row
  7530. if (codePoint < 0xDC00) {
  7531. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7532. leadSurrogate = codePoint
  7533. continue
  7534. }
  7535. // valid surrogate pair
  7536. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  7537. } else if (leadSurrogate) {
  7538. // valid bmp char, but last char was a lead
  7539. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7540. }
  7541. leadSurrogate = null
  7542. // encode utf8
  7543. if (codePoint < 0x80) {
  7544. if ((units -= 1) < 0) break
  7545. bytes.push(codePoint)
  7546. } else if (codePoint < 0x800) {
  7547. if ((units -= 2) < 0) break
  7548. bytes.push(
  7549. codePoint >> 0x6 | 0xC0,
  7550. codePoint & 0x3F | 0x80
  7551. )
  7552. } else if (codePoint < 0x10000) {
  7553. if ((units -= 3) < 0) break
  7554. bytes.push(
  7555. codePoint >> 0xC | 0xE0,
  7556. codePoint >> 0x6 & 0x3F | 0x80,
  7557. codePoint & 0x3F | 0x80
  7558. )
  7559. } else if (codePoint < 0x110000) {
  7560. if ((units -= 4) < 0) break
  7561. bytes.push(
  7562. codePoint >> 0x12 | 0xF0,
  7563. codePoint >> 0xC & 0x3F | 0x80,
  7564. codePoint >> 0x6 & 0x3F | 0x80,
  7565. codePoint & 0x3F | 0x80
  7566. )
  7567. } else {
  7568. throw new Error('Invalid code point')
  7569. }
  7570. }
  7571. return bytes
  7572. }
  7573. function asciiToBytes (str) {
  7574. var byteArray = []
  7575. for (var i = 0; i < str.length; ++i) {
  7576. // Node's code seems to be doing this and not & 0x7F..
  7577. byteArray.push(str.charCodeAt(i) & 0xFF)
  7578. }
  7579. return byteArray
  7580. }
  7581. function utf16leToBytes (str, units) {
  7582. var c, hi, lo
  7583. var byteArray = []
  7584. for (var i = 0; i < str.length; ++i) {
  7585. if ((units -= 2) < 0) break
  7586. c = str.charCodeAt(i)
  7587. hi = c >> 8
  7588. lo = c % 256
  7589. byteArray.push(lo)
  7590. byteArray.push(hi)
  7591. }
  7592. return byteArray
  7593. }
  7594. function base64ToBytes (str) {
  7595. return base64.toByteArray(base64clean(str))
  7596. }
  7597. function blitBuffer (src, dst, offset, length) {
  7598. for (var i = 0; i < length; ++i) {
  7599. if ((i + offset >= dst.length) || (i >= src.length)) break
  7600. dst[i + offset] = src[i]
  7601. }
  7602. return i
  7603. }
  7604. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  7605. // the `instanceof` check but they should be treated as of that type.
  7606. // See: https://github.com/feross/buffer/issues/166
  7607. function isInstance (obj, type) {
  7608. return obj instanceof type ||
  7609. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  7610. obj.constructor.name === type.name)
  7611. }
  7612. function numberIsNaN (obj) {
  7613. // For IE11 support
  7614. return obj !== obj // eslint-disable-line no-self-compare
  7615. }
  7616. }).call(this)}).call(this,require("buffer").Buffer)
  7617. },{"base64-js":8,"buffer":10,"ieee754":46}],11:[function(require,module,exports){
  7618. 'use strict';
  7619. var GetIntrinsic = require('get-intrinsic');
  7620. var callBind = require('./');
  7621. var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
  7622. module.exports = function callBoundIntrinsic(name, allowMissing) {
  7623. var intrinsic = GetIntrinsic(name, !!allowMissing);
  7624. if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
  7625. return callBind(intrinsic);
  7626. }
  7627. return intrinsic;
  7628. };
  7629. },{"./":12,"get-intrinsic":39}],12:[function(require,module,exports){
  7630. 'use strict';
  7631. var bind = require('function-bind');
  7632. var GetIntrinsic = require('get-intrinsic');
  7633. var $apply = GetIntrinsic('%Function.prototype.apply%');
  7634. var $call = GetIntrinsic('%Function.prototype.call%');
  7635. var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
  7636. var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
  7637. var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
  7638. var $max = GetIntrinsic('%Math.max%');
  7639. if ($defineProperty) {
  7640. try {
  7641. $defineProperty({}, 'a', { value: 1 });
  7642. } catch (e) {
  7643. // IE 8 has a broken defineProperty
  7644. $defineProperty = null;
  7645. }
  7646. }
  7647. module.exports = function callBind(originalFunction) {
  7648. var func = $reflectApply(bind, $call, arguments);
  7649. if ($gOPD && $defineProperty) {
  7650. var desc = $gOPD(func, 'length');
  7651. if (desc.configurable) {
  7652. // original length, plus the receiver, minus any additional arguments (after the receiver)
  7653. $defineProperty(
  7654. func,
  7655. 'length',
  7656. { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
  7657. );
  7658. }
  7659. }
  7660. return func;
  7661. };
  7662. var applyBind = function applyBind() {
  7663. return $reflectApply(bind, $apply, arguments);
  7664. };
  7665. if ($defineProperty) {
  7666. $defineProperty(module.exports, 'apply', { value: applyBind });
  7667. } else {
  7668. module.exports.apply = applyBind;
  7669. }
  7670. },{"function-bind":37,"get-intrinsic":39}],13:[function(require,module,exports){
  7671. // Copyright Joyent, Inc. and other Node contributors.
  7672. //
  7673. // Permission is hereby granted, free of charge, to any person obtaining a
  7674. // copy of this software and associated documentation files (the
  7675. // "Software"), to deal in the Software without restriction, including
  7676. // without limitation the rights to use, copy, modify, merge, publish,
  7677. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7678. // persons to whom the Software is furnished to do so, subject to the
  7679. // following conditions:
  7680. //
  7681. // The above copyright notice and this permission notice shall be included
  7682. // in all copies or substantial portions of the Software.
  7683. //
  7684. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7685. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7686. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7687. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7688. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7689. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7690. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7691. // NOTE: These type checking functions intentionally don't use `instanceof`
  7692. // because it is fragile and can be easily faked with `Object.create()`.
  7693. function isArray(arg) {
  7694. if (Array.isArray) {
  7695. return Array.isArray(arg);
  7696. }
  7697. return objectToString(arg) === '[object Array]';
  7698. }
  7699. exports.isArray = isArray;
  7700. function isBoolean(arg) {
  7701. return typeof arg === 'boolean';
  7702. }
  7703. exports.isBoolean = isBoolean;
  7704. function isNull(arg) {
  7705. return arg === null;
  7706. }
  7707. exports.isNull = isNull;
  7708. function isNullOrUndefined(arg) {
  7709. return arg == null;
  7710. }
  7711. exports.isNullOrUndefined = isNullOrUndefined;
  7712. function isNumber(arg) {
  7713. return typeof arg === 'number';
  7714. }
  7715. exports.isNumber = isNumber;
  7716. function isString(arg) {
  7717. return typeof arg === 'string';
  7718. }
  7719. exports.isString = isString;
  7720. function isSymbol(arg) {
  7721. return typeof arg === 'symbol';
  7722. }
  7723. exports.isSymbol = isSymbol;
  7724. function isUndefined(arg) {
  7725. return arg === void 0;
  7726. }
  7727. exports.isUndefined = isUndefined;
  7728. function isRegExp(re) {
  7729. return objectToString(re) === '[object RegExp]';
  7730. }
  7731. exports.isRegExp = isRegExp;
  7732. function isObject(arg) {
  7733. return typeof arg === 'object' && arg !== null;
  7734. }
  7735. exports.isObject = isObject;
  7736. function isDate(d) {
  7737. return objectToString(d) === '[object Date]';
  7738. }
  7739. exports.isDate = isDate;
  7740. function isError(e) {
  7741. return (objectToString(e) === '[object Error]' || e instanceof Error);
  7742. }
  7743. exports.isError = isError;
  7744. function isFunction(arg) {
  7745. return typeof arg === 'function';
  7746. }
  7747. exports.isFunction = isFunction;
  7748. function isPrimitive(arg) {
  7749. return arg === null ||
  7750. typeof arg === 'boolean' ||
  7751. typeof arg === 'number' ||
  7752. typeof arg === 'string' ||
  7753. typeof arg === 'symbol' || // ES6 symbol
  7754. typeof arg === 'undefined';
  7755. }
  7756. exports.isPrimitive = isPrimitive;
  7757. exports.isBuffer = require('buffer').Buffer.isBuffer;
  7758. function objectToString(o) {
  7759. return Object.prototype.toString.call(o);
  7760. }
  7761. },{"buffer":10}],14:[function(require,module,exports){
  7762. 'use strict';
  7763. var objectKeys = require('object-keys');
  7764. var isArguments = require('is-arguments');
  7765. var is = require('object-is');
  7766. var isRegex = require('is-regex');
  7767. var flags = require('regexp.prototype.flags');
  7768. var isArray = require('isarray');
  7769. var isDate = require('is-date-object');
  7770. var whichBoxedPrimitive = require('which-boxed-primitive');
  7771. var GetIntrinsic = require('get-intrinsic');
  7772. var callBound = require('call-bind/callBound');
  7773. var whichCollection = require('which-collection');
  7774. var getIterator = require('es-get-iterator');
  7775. var getSideChannel = require('side-channel');
  7776. var whichTypedArray = require('which-typed-array');
  7777. var assign = require('object.assign');
  7778. var $getTime = callBound('Date.prototype.getTime');
  7779. var gPO = Object.getPrototypeOf;
  7780. var $objToString = callBound('Object.prototype.toString');
  7781. var $Set = GetIntrinsic('%Set%', true);
  7782. var $mapHas = callBound('Map.prototype.has', true);
  7783. var $mapGet = callBound('Map.prototype.get', true);
  7784. var $mapSize = callBound('Map.prototype.size', true);
  7785. var $setAdd = callBound('Set.prototype.add', true);
  7786. var $setDelete = callBound('Set.prototype.delete', true);
  7787. var $setHas = callBound('Set.prototype.has', true);
  7788. var $setSize = callBound('Set.prototype.size', true);
  7789. // taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L401-L414
  7790. function setHasEqualElement(set, val1, opts, channel) {
  7791. var i = getIterator(set);
  7792. var result;
  7793. while ((result = i.next()) && !result.done) {
  7794. if (internalDeepEqual(val1, result.value, opts, channel)) { // eslint-disable-line no-use-before-define
  7795. // Remove the matching element to make sure we do not check that again.
  7796. $setDelete(set, result.value);
  7797. return true;
  7798. }
  7799. }
  7800. return false;
  7801. }
  7802. // taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L416-L439
  7803. function findLooseMatchingPrimitives(prim) {
  7804. if (typeof prim === 'undefined') {
  7805. return null;
  7806. }
  7807. if (typeof prim === 'object') { // Only pass in null as object!
  7808. return void 0;
  7809. }
  7810. if (typeof prim === 'symbol') {
  7811. return false;
  7812. }
  7813. if (typeof prim === 'string' || typeof prim === 'number') {
  7814. // Loose equal entries exist only if the string is possible to convert to a regular number and not NaN.
  7815. return +prim === +prim; // eslint-disable-line no-implicit-coercion
  7816. }
  7817. return true;
  7818. }
  7819. // taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L449-L460
  7820. function mapMightHaveLoosePrim(a, b, prim, item, opts, channel) {
  7821. var altValue = findLooseMatchingPrimitives(prim);
  7822. if (altValue != null) {
  7823. return altValue;
  7824. }
  7825. var curB = $mapGet(b, altValue);
  7826. var looseOpts = assign({}, opts, { strict: false });
  7827. if (
  7828. (typeof curB === 'undefined' && !$mapHas(b, altValue))
  7829. // eslint-disable-next-line no-use-before-define
  7830. || !internalDeepEqual(item, curB, looseOpts, channel)
  7831. ) {
  7832. return false;
  7833. }
  7834. // eslint-disable-next-line no-use-before-define
  7835. return !$mapHas(a, altValue) && internalDeepEqual(item, curB, looseOpts, channel);
  7836. }
  7837. // taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L441-L447
  7838. function setMightHaveLoosePrim(a, b, prim) {
  7839. var altValue = findLooseMatchingPrimitives(prim);
  7840. if (altValue != null) {
  7841. return altValue;
  7842. }
  7843. return $setHas(b, altValue) && !$setHas(a, altValue);
  7844. }
  7845. // taken from https://github.com/browserify/commonjs-assert/blob/bba838e9ba9e28edf3127ce6974624208502f6bc/internal/util/comparisons.js#L518-L533
  7846. function mapHasEqualEntry(set, map, key1, item1, opts, channel) {
  7847. var i = getIterator(set);
  7848. var result;
  7849. var key2;
  7850. while ((result = i.next()) && !result.done) {
  7851. key2 = result.value;
  7852. if (
  7853. // eslint-disable-next-line no-use-before-define
  7854. internalDeepEqual(key1, key2, opts, channel)
  7855. // eslint-disable-next-line no-use-before-define
  7856. && internalDeepEqual(item1, $mapGet(map, key2), opts, channel)
  7857. ) {
  7858. $setDelete(set, key2);
  7859. return true;
  7860. }
  7861. }
  7862. return false;
  7863. }
  7864. function internalDeepEqual(actual, expected, options, channel) {
  7865. var opts = options || {};
  7866. // 7.1. All identical values are equivalent, as determined by ===.
  7867. if (opts.strict ? is(actual, expected) : actual === expected) {
  7868. return true;
  7869. }
  7870. var actualBoxed = whichBoxedPrimitive(actual);
  7871. var expectedBoxed = whichBoxedPrimitive(expected);
  7872. if (actualBoxed !== expectedBoxed) {
  7873. return false;
  7874. }
  7875. // 7.3. Other pairs that do not both pass typeof value == 'object', equivalence is determined by ==.
  7876. if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) {
  7877. return opts.strict ? is(actual, expected) : actual == expected; // eslint-disable-line eqeqeq
  7878. }
  7879. /*
  7880. * 7.4. For all other Object pairs, including Array objects, equivalence is
  7881. * determined by having the same number of owned properties (as verified
  7882. * with Object.prototype.hasOwnProperty.call), the same set of keys
  7883. * (although not necessarily the same order), equivalent values for every
  7884. * corresponding key, and an identical 'prototype' property. Note: this
  7885. * accounts for both named and indexed properties on Arrays.
  7886. */
  7887. // see https://github.com/nodejs/node/commit/d3aafd02efd3a403d646a3044adcf14e63a88d32 for memos/channel inspiration
  7888. var hasActual = channel.has(actual);
  7889. var hasExpected = channel.has(expected);
  7890. var sentinel;
  7891. if (hasActual && hasExpected) {
  7892. if (channel.get(actual) === channel.get(expected)) {
  7893. return true;
  7894. }
  7895. } else {
  7896. sentinel = {};
  7897. }
  7898. if (!hasActual) { channel.set(actual, sentinel); }
  7899. if (!hasExpected) { channel.set(expected, sentinel); }
  7900. // eslint-disable-next-line no-use-before-define
  7901. return objEquiv(actual, expected, opts, channel);
  7902. }
  7903. function isBuffer(x) {
  7904. if (!x || typeof x !== 'object' || typeof x.length !== 'number') {
  7905. return false;
  7906. }
  7907. if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
  7908. return false;
  7909. }
  7910. if (x.length > 0 && typeof x[0] !== 'number') {
  7911. return false;
  7912. }
  7913. return !!(x.constructor && x.constructor.isBuffer && x.constructor.isBuffer(x));
  7914. }
  7915. function setEquiv(a, b, opts, channel) {
  7916. if ($setSize(a) !== $setSize(b)) {
  7917. return false;
  7918. }
  7919. var iA = getIterator(a);
  7920. var iB = getIterator(b);
  7921. var resultA;
  7922. var resultB;
  7923. var set;
  7924. while ((resultA = iA.next()) && !resultA.done) {
  7925. if (resultA.value && typeof resultA.value === 'object') {
  7926. if (!set) { set = new $Set(); }
  7927. $setAdd(set, resultA.value);
  7928. } else if (!$setHas(b, resultA.value)) {
  7929. if (opts.strict) { return false; }
  7930. if (!setMightHaveLoosePrim(a, b, resultA.value)) {
  7931. return false;
  7932. }
  7933. if (!set) { set = new $Set(); }
  7934. $setAdd(set, resultA.value);
  7935. }
  7936. }
  7937. if (set) {
  7938. while ((resultB = iB.next()) && !resultB.done) {
  7939. // We have to check if a primitive value is already matching and only if it's not, go hunting for it.
  7940. if (resultB.value && typeof resultB.value === 'object') {
  7941. if (!setHasEqualElement(set, resultB.value, opts.strict, channel)) {
  7942. return false;
  7943. }
  7944. } else if (
  7945. !opts.strict
  7946. && !$setHas(a, resultB.value)
  7947. && !setHasEqualElement(set, resultB.value, opts.strict, channel)
  7948. ) {
  7949. return false;
  7950. }
  7951. }
  7952. return $setSize(set) === 0;
  7953. }
  7954. return true;
  7955. }
  7956. function mapEquiv(a, b, opts, channel) {
  7957. if ($mapSize(a) !== $mapSize(b)) {
  7958. return false;
  7959. }
  7960. var iA = getIterator(a);
  7961. var iB = getIterator(b);
  7962. var resultA;
  7963. var resultB;
  7964. var set;
  7965. var key;
  7966. var item1;
  7967. var item2;
  7968. while ((resultA = iA.next()) && !resultA.done) {
  7969. key = resultA.value[0];
  7970. item1 = resultA.value[1];
  7971. if (key && typeof key === 'object') {
  7972. if (!set) { set = new $Set(); }
  7973. $setAdd(set, key);
  7974. } else {
  7975. item2 = $mapGet(b, key);
  7976. if ((typeof item2 === 'undefined' && !$mapHas(b, key)) || !internalDeepEqual(item1, item2, opts, channel)) {
  7977. if (opts.strict) {
  7978. return false;
  7979. }
  7980. if (!mapMightHaveLoosePrim(a, b, key, item1, opts, channel)) {
  7981. return false;
  7982. }
  7983. if (!set) { set = new $Set(); }
  7984. $setAdd(set, key);
  7985. }
  7986. }
  7987. }
  7988. if (set) {
  7989. while ((resultB = iB.next()) && !resultB.done) {
  7990. key = resultB.value[0];
  7991. item2 = resultB.value[1];
  7992. if (key && typeof key === 'object') {
  7993. if (!mapHasEqualEntry(set, a, key, item2, opts, channel)) {
  7994. return false;
  7995. }
  7996. } else if (
  7997. !opts.strict
  7998. && (!a.has(key) || !internalDeepEqual($mapGet(a, key), item2, opts, channel))
  7999. && !mapHasEqualEntry(set, a, key, item2, assign({}, opts, { strict: false }), channel)
  8000. ) {
  8001. return false;
  8002. }
  8003. }
  8004. return $setSize(set) === 0;
  8005. }
  8006. return true;
  8007. }
  8008. function objEquiv(a, b, opts, channel) {
  8009. /* eslint max-statements: [2, 100], max-lines-per-function: [2, 120], max-depth: [2, 5] */
  8010. var i, key;
  8011. if (typeof a !== typeof b) { return false; }
  8012. if (a == null || b == null) { return false; }
  8013. if ($objToString(a) !== $objToString(b)) { return false; }
  8014. if (isArguments(a) !== isArguments(b)) { return false; }
  8015. var aIsArray = isArray(a);
  8016. var bIsArray = isArray(b);
  8017. if (aIsArray !== bIsArray) { return false; }
  8018. // TODO: replace when a cross-realm brand check is available
  8019. var aIsError = a instanceof Error;
  8020. var bIsError = b instanceof Error;
  8021. if (aIsError !== bIsError) { return false; }
  8022. if (aIsError || bIsError) {
  8023. if (a.name !== b.name || a.message !== b.message) { return false; }
  8024. }
  8025. var aIsRegex = isRegex(a);
  8026. var bIsRegex = isRegex(b);
  8027. if (aIsRegex !== bIsRegex) { return false; }
  8028. if ((aIsRegex || bIsRegex) && (a.source !== b.source || flags(a) !== flags(b))) {
  8029. return false;
  8030. }
  8031. var aIsDate = isDate(a);
  8032. var bIsDate = isDate(b);
  8033. if (aIsDate !== bIsDate) { return false; }
  8034. if (aIsDate || bIsDate) { // && would work too, because both are true or both false here
  8035. if ($getTime(a) !== $getTime(b)) { return false; }
  8036. }
  8037. if (opts.strict && gPO && gPO(a) !== gPO(b)) { return false; }
  8038. if (whichTypedArray(a) !== whichTypedArray(b)) {
  8039. return false;
  8040. }
  8041. var aIsBuffer = isBuffer(a);
  8042. var bIsBuffer = isBuffer(b);
  8043. if (aIsBuffer !== bIsBuffer) { return false; }
  8044. if (aIsBuffer || bIsBuffer) { // && would work too, because both are true or both false here
  8045. if (a.length !== b.length) { return false; }
  8046. for (i = 0; i < a.length; i++) {
  8047. if (a[i] !== b[i]) { return false; }
  8048. }
  8049. return true;
  8050. }
  8051. if (typeof a !== typeof b) { return false; }
  8052. var ka = objectKeys(a);
  8053. var kb = objectKeys(b);
  8054. // having the same number of owned properties (keys incorporates hasOwnProperty)
  8055. if (ka.length !== kb.length) { return false; }
  8056. // the same set of keys (although not necessarily the same order),
  8057. ka.sort();
  8058. kb.sort();
  8059. // ~~~cheap key test
  8060. for (i = ka.length - 1; i >= 0; i--) {
  8061. if (ka[i] != kb[i]) { return false; } // eslint-disable-line eqeqeq
  8062. }
  8063. // equivalent values for every corresponding key, and ~~~possibly expensive deep test
  8064. for (i = ka.length - 1; i >= 0; i--) {
  8065. key = ka[i];
  8066. if (!internalDeepEqual(a[key], b[key], opts, channel)) { return false; }
  8067. }
  8068. var aCollection = whichCollection(a);
  8069. var bCollection = whichCollection(b);
  8070. if (aCollection !== bCollection) {
  8071. return false;
  8072. }
  8073. if (aCollection === 'Set' || bCollection === 'Set') { // aCollection === bCollection
  8074. return setEquiv(a, b, opts, channel);
  8075. }
  8076. if (aCollection === 'Map') { // aCollection === bCollection
  8077. return mapEquiv(a, b, opts, channel);
  8078. }
  8079. return true;
  8080. }
  8081. module.exports = function deepEqual(a, b, opts) {
  8082. return internalDeepEqual(a, b, opts, getSideChannel());
  8083. };
  8084. },{"call-bind/callBound":11,"es-get-iterator":29,"get-intrinsic":39,"is-arguments":48,"is-date-object":52,"is-regex":55,"isarray":15,"object-is":67,"object-keys":71,"object.assign":74,"regexp.prototype.flags":96,"side-channel":100,"which-boxed-primitive":113,"which-collection":114,"which-typed-array":115}],15:[function(require,module,exports){
  8085. var toString = {}.toString;
  8086. module.exports = Array.isArray || function (arr) {
  8087. return toString.call(arr) == '[object Array]';
  8088. };
  8089. },{}],16:[function(require,module,exports){
  8090. 'use strict';
  8091. var keys = require('object-keys');
  8092. var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
  8093. var toStr = Object.prototype.toString;
  8094. var concat = Array.prototype.concat;
  8095. var origDefineProperty = Object.defineProperty;
  8096. var isFunction = function (fn) {
  8097. return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
  8098. };
  8099. var hasPropertyDescriptors = require('has-property-descriptors')();
  8100. var supportsDescriptors = origDefineProperty && hasPropertyDescriptors;
  8101. var defineProperty = function (object, name, value, predicate) {
  8102. if (name in object && (!isFunction(predicate) || !predicate())) {
  8103. return;
  8104. }
  8105. if (supportsDescriptors) {
  8106. origDefineProperty(object, name, {
  8107. configurable: true,
  8108. enumerable: false,
  8109. value: value,
  8110. writable: true
  8111. });
  8112. } else {
  8113. object[name] = value; // eslint-disable-line no-param-reassign
  8114. }
  8115. };
  8116. var defineProperties = function (object, map) {
  8117. var predicates = arguments.length > 2 ? arguments[2] : {};
  8118. var props = keys(map);
  8119. if (hasSymbols) {
  8120. props = concat.call(props, Object.getOwnPropertySymbols(map));
  8121. }
  8122. for (var i = 0; i < props.length; i += 1) {
  8123. defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
  8124. }
  8125. };
  8126. defineProperties.supportsDescriptors = !!supportsDescriptors;
  8127. module.exports = defineProperties;
  8128. },{"has-property-descriptors":41,"object-keys":71}],17:[function(require,module,exports){
  8129. module.exports = function () {
  8130. for (var i = 0; i < arguments.length; i++) {
  8131. if (arguments[i] !== undefined) return arguments[i];
  8132. }
  8133. };
  8134. },{}],18:[function(require,module,exports){
  8135. 'use strict';
  8136. // http://262.ecma-international.org/5.1/#sec-9.11
  8137. module.exports = require('is-callable');
  8138. },{"is-callable":51}],19:[function(require,module,exports){
  8139. 'use strict';
  8140. module.exports = require('../5/CheckObjectCoercible');
  8141. },{"../5/CheckObjectCoercible":25}],20:[function(require,module,exports){
  8142. 'use strict';
  8143. var GetIntrinsic = require('get-intrinsic');
  8144. var $TypeError = GetIntrinsic('%TypeError%');
  8145. var $Number = GetIntrinsic('%Number%');
  8146. var $RegExp = GetIntrinsic('%RegExp%');
  8147. var $parseInteger = GetIntrinsic('%parseInt%');
  8148. var callBound = require('call-bind/callBound');
  8149. var regexTester = require('../helpers/regexTester');
  8150. var isPrimitive = require('../helpers/isPrimitive');
  8151. var $strSlice = callBound('String.prototype.slice');
  8152. var isBinary = regexTester(/^0b[01]+$/i);
  8153. var isOctal = regexTester(/^0o[0-7]+$/i);
  8154. var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i);
  8155. var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
  8156. var nonWSregex = new $RegExp('[' + nonWS + ']', 'g');
  8157. var hasNonWS = regexTester(nonWSregex);
  8158. // whitespace from: https://es5.github.io/#x15.5.4.20
  8159. // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
  8160. var ws = [
  8161. '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
  8162. '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
  8163. '\u2029\uFEFF'
  8164. ].join('');
  8165. var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
  8166. var $replace = callBound('String.prototype.replace');
  8167. var $trim = function (value) {
  8168. return $replace(value, trimRegex, '');
  8169. };
  8170. var ToPrimitive = require('./ToPrimitive');
  8171. // https://ecma-international.org/ecma-262/6.0/#sec-tonumber
  8172. module.exports = function ToNumber(argument) {
  8173. var value = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number);
  8174. if (typeof value === 'symbol') {
  8175. throw new $TypeError('Cannot convert a Symbol value to a number');
  8176. }
  8177. if (typeof value === 'bigint') {
  8178. throw new $TypeError('Conversion from \'BigInt\' to \'number\' is not allowed.');
  8179. }
  8180. if (typeof value === 'string') {
  8181. if (isBinary(value)) {
  8182. return ToNumber($parseInteger($strSlice(value, 2), 2));
  8183. } else if (isOctal(value)) {
  8184. return ToNumber($parseInteger($strSlice(value, 2), 8));
  8185. } else if (hasNonWS(value) || isInvalidHexLiteral(value)) {
  8186. return NaN;
  8187. }
  8188. var trimmed = $trim(value);
  8189. if (trimmed !== value) {
  8190. return ToNumber(trimmed);
  8191. }
  8192. }
  8193. return $Number(value);
  8194. };
  8195. },{"../helpers/isPrimitive":27,"../helpers/regexTester":28,"./ToPrimitive":22,"call-bind/callBound":11,"get-intrinsic":39}],21:[function(require,module,exports){
  8196. 'use strict';
  8197. var GetIntrinsic = require('get-intrinsic');
  8198. var $Object = GetIntrinsic('%Object%');
  8199. var RequireObjectCoercible = require('./RequireObjectCoercible');
  8200. // https://ecma-international.org/ecma-262/6.0/#sec-toobject
  8201. module.exports = function ToObject(value) {
  8202. RequireObjectCoercible(value);
  8203. return $Object(value);
  8204. };
  8205. },{"./RequireObjectCoercible":19,"get-intrinsic":39}],22:[function(require,module,exports){
  8206. 'use strict';
  8207. var toPrimitive = require('es-to-primitive/es2015');
  8208. // https://ecma-international.org/ecma-262/6.0/#sec-toprimitive
  8209. module.exports = function ToPrimitive(input) {
  8210. if (arguments.length > 1) {
  8211. return toPrimitive(input, arguments[1]);
  8212. }
  8213. return toPrimitive(input);
  8214. };
  8215. },{"es-to-primitive/es2015":31}],23:[function(require,module,exports){
  8216. 'use strict';
  8217. var GetIntrinsic = require('get-intrinsic');
  8218. var $String = GetIntrinsic('%String%');
  8219. var $TypeError = GetIntrinsic('%TypeError%');
  8220. // https://ecma-international.org/ecma-262/6.0/#sec-tostring
  8221. module.exports = function ToString(argument) {
  8222. if (typeof argument === 'symbol') {
  8223. throw new $TypeError('Cannot convert a Symbol value to a string');
  8224. }
  8225. return $String(argument);
  8226. };
  8227. },{"get-intrinsic":39}],24:[function(require,module,exports){
  8228. 'use strict';
  8229. var ToNumber = require('./ToNumber');
  8230. // http://262.ecma-international.org/5.1/#sec-9.6
  8231. module.exports = function ToUint32(x) {
  8232. return ToNumber(x) >>> 0;
  8233. };
  8234. },{"./ToNumber":20}],25:[function(require,module,exports){
  8235. 'use strict';
  8236. var GetIntrinsic = require('get-intrinsic');
  8237. var $TypeError = GetIntrinsic('%TypeError%');
  8238. // http://262.ecma-international.org/5.1/#sec-9.10
  8239. module.exports = function CheckObjectCoercible(value, optMessage) {
  8240. if (value == null) {
  8241. throw new $TypeError(optMessage || ('Cannot call method on ' + value));
  8242. }
  8243. return value;
  8244. };
  8245. },{"get-intrinsic":39}],26:[function(require,module,exports){
  8246. 'use strict';
  8247. var GetIntrinsic = require('get-intrinsic');
  8248. var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
  8249. if ($gOPD) {
  8250. try {
  8251. $gOPD([], 'length');
  8252. } catch (e) {
  8253. // IE 8 has a broken gOPD
  8254. $gOPD = null;
  8255. }
  8256. }
  8257. module.exports = $gOPD;
  8258. },{"get-intrinsic":39}],27:[function(require,module,exports){
  8259. 'use strict';
  8260. module.exports = function isPrimitive(value) {
  8261. return value === null || (typeof value !== 'function' && typeof value !== 'object');
  8262. };
  8263. },{}],28:[function(require,module,exports){
  8264. 'use strict';
  8265. var GetIntrinsic = require('get-intrinsic');
  8266. var $test = GetIntrinsic('RegExp.prototype.test');
  8267. var callBind = require('call-bind');
  8268. module.exports = function regexTester(regex) {
  8269. return callBind($test, regex);
  8270. };
  8271. },{"call-bind":12,"get-intrinsic":39}],29:[function(require,module,exports){
  8272. (function (process){(function (){
  8273. 'use strict';
  8274. /* eslint global-require: 0 */
  8275. // the code is structured this way so that bundlers can
  8276. // alias out `has-symbols` to `() => true` or `() => false` if your target
  8277. // environments' Symbol capabilities are known, and then use
  8278. // dead code elimination on the rest of this module.
  8279. //
  8280. // Similarly, `isarray` can be aliased to `Array.isArray` if
  8281. // available in all target environments.
  8282. var isArguments = require('is-arguments');
  8283. if (require('has-symbols')() || require('has-symbols/shams')()) {
  8284. var $iterator = Symbol.iterator;
  8285. // Symbol is available natively or shammed
  8286. // natively:
  8287. // - Chrome >= 38
  8288. // - Edge 12-14?, Edge >= 15 for sure
  8289. // - FF >= 36
  8290. // - Safari >= 9
  8291. // - node >= 0.12
  8292. module.exports = function getIterator(iterable) {
  8293. // alternatively, `iterable[$iterator]?.()`
  8294. if (iterable != null && typeof iterable[$iterator] !== 'undefined') {
  8295. return iterable[$iterator]();
  8296. }
  8297. if (isArguments(iterable)) {
  8298. // arguments objects lack Symbol.iterator
  8299. // - node 0.12
  8300. return Array.prototype[$iterator].call(iterable);
  8301. }
  8302. };
  8303. } else {
  8304. // Symbol is not available, native or shammed
  8305. var isArray = require('isarray');
  8306. var isString = require('is-string');
  8307. var GetIntrinsic = require('get-intrinsic');
  8308. var $Map = GetIntrinsic('%Map%', true);
  8309. var $Set = GetIntrinsic('%Set%', true);
  8310. var callBound = require('call-bind/callBound');
  8311. var $arrayPush = callBound('Array.prototype.push');
  8312. var $charCodeAt = callBound('String.prototype.charCodeAt');
  8313. var $stringSlice = callBound('String.prototype.slice');
  8314. var advanceStringIndex = function advanceStringIndex(S, index) {
  8315. var length = S.length;
  8316. if ((index + 1) >= length) {
  8317. return index + 1;
  8318. }
  8319. var first = $charCodeAt(S, index);
  8320. if (first < 0xD800 || first > 0xDBFF) {
  8321. return index + 1;
  8322. }
  8323. var second = $charCodeAt(S, index + 1);
  8324. if (second < 0xDC00 || second > 0xDFFF) {
  8325. return index + 1;
  8326. }
  8327. return index + 2;
  8328. };
  8329. var getArrayIterator = function getArrayIterator(arraylike) {
  8330. var i = 0;
  8331. return {
  8332. next: function next() {
  8333. var done = i >= arraylike.length;
  8334. var value;
  8335. if (!done) {
  8336. value = arraylike[i];
  8337. i += 1;
  8338. }
  8339. return {
  8340. done: done,
  8341. value: value
  8342. };
  8343. }
  8344. };
  8345. };
  8346. var getNonCollectionIterator = function getNonCollectionIterator(iterable, noPrimordialCollections) {
  8347. if (isArray(iterable) || isArguments(iterable)) {
  8348. return getArrayIterator(iterable);
  8349. }
  8350. if (isString(iterable)) {
  8351. var i = 0;
  8352. return {
  8353. next: function next() {
  8354. var nextIndex = advanceStringIndex(iterable, i);
  8355. var value = $stringSlice(iterable, i, nextIndex);
  8356. i = nextIndex;
  8357. return {
  8358. done: nextIndex > iterable.length,
  8359. value: value
  8360. };
  8361. }
  8362. };
  8363. }
  8364. // es6-shim and es-shims' es-map use a string "_es6-shim iterator_" property on different iterables, such as MapIterator.
  8365. if (noPrimordialCollections && typeof iterable['_es6-shim iterator_'] !== 'undefined') {
  8366. return iterable['_es6-shim iterator_']();
  8367. }
  8368. };
  8369. if (!$Map && !$Set) {
  8370. // the only language iterables are Array, String, arguments
  8371. // - Safari <= 6.0
  8372. // - Chrome < 38
  8373. // - node < 0.12
  8374. // - FF < 13
  8375. // - IE < 11
  8376. // - Edge < 11
  8377. module.exports = function getIterator(iterable) {
  8378. if (iterable != null) {
  8379. return getNonCollectionIterator(iterable, true);
  8380. }
  8381. };
  8382. } else {
  8383. // either Map or Set are available, but Symbol is not
  8384. // - es6-shim on an ES5 browser
  8385. // - Safari 6.2 (maybe 6.1?)
  8386. // - FF v[13, 36)
  8387. // - IE 11
  8388. // - Edge 11
  8389. // - Safari v[6, 9)
  8390. var isMap = require('is-map');
  8391. var isSet = require('is-set');
  8392. // Firefox >= 27, IE 11, Safari 6.2 - 9, Edge 11, es6-shim in older envs, all have forEach
  8393. var $mapForEach = callBound('Map.prototype.forEach', true);
  8394. var $setForEach = callBound('Set.prototype.forEach', true);
  8395. if (typeof process === 'undefined' || !process.versions || !process.versions.node) { // "if is not node"
  8396. // Firefox 17 - 26 has `.iterator()`, whose iterator `.next()` either
  8397. // returns a value, or throws a StopIteration object. These browsers
  8398. // do not have any other mechanism for iteration.
  8399. var $mapIterator = callBound('Map.prototype.iterator', true);
  8400. var $setIterator = callBound('Set.prototype.iterator', true);
  8401. var getStopIterationIterator = function (iterator) {
  8402. var done = false;
  8403. return {
  8404. next: function next() {
  8405. try {
  8406. return {
  8407. done: done,
  8408. value: done ? undefined : iterator.next()
  8409. };
  8410. } catch (e) {
  8411. done = true;
  8412. return {
  8413. done: true,
  8414. value: undefined
  8415. };
  8416. }
  8417. }
  8418. };
  8419. };
  8420. }
  8421. // Firefox 27-35, and some older es6-shim versions, use a string "@@iterator" property
  8422. // this returns a proper iterator object, so we should use it instead of forEach.
  8423. // newer es6-shim versions use a string "_es6-shim iterator_" property.
  8424. var $mapAtAtIterator = callBound('Map.prototype.@@iterator', true) || callBound('Map.prototype._es6-shim iterator_', true);
  8425. var $setAtAtIterator = callBound('Set.prototype.@@iterator', true) || callBound('Set.prototype._es6-shim iterator_', true);
  8426. var getCollectionIterator = function getCollectionIterator(iterable) {
  8427. if (isMap(iterable)) {
  8428. if ($mapIterator) {
  8429. return getStopIterationIterator($mapIterator(iterable));
  8430. }
  8431. if ($mapAtAtIterator) {
  8432. return $mapAtAtIterator(iterable);
  8433. }
  8434. if ($mapForEach) {
  8435. var entries = [];
  8436. $mapForEach(iterable, function (v, k) {
  8437. $arrayPush(entries, [k, v]);
  8438. });
  8439. return getArrayIterator(entries);
  8440. }
  8441. }
  8442. if (isSet(iterable)) {
  8443. if ($setIterator) {
  8444. return getStopIterationIterator($setIterator(iterable));
  8445. }
  8446. if ($setAtAtIterator) {
  8447. return $setAtAtIterator(iterable);
  8448. }
  8449. if ($setForEach) {
  8450. var values = [];
  8451. $setForEach(iterable, function (v) {
  8452. $arrayPush(values, v);
  8453. });
  8454. return getArrayIterator(values);
  8455. }
  8456. }
  8457. };
  8458. module.exports = function getIterator(iterable) {
  8459. return getCollectionIterator(iterable) || getNonCollectionIterator(iterable);
  8460. };
  8461. }
  8462. }
  8463. }).call(this)}).call(this,require('_process'))
  8464. },{"_process":79,"call-bind/callBound":11,"get-intrinsic":39,"has-symbols":42,"has-symbols/shams":43,"is-arguments":48,"is-map":53,"is-set":56,"is-string":57,"isarray":30}],30:[function(require,module,exports){
  8465. arguments[4][15][0].apply(exports,arguments)
  8466. },{"dup":15}],31:[function(require,module,exports){
  8467. 'use strict';
  8468. var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
  8469. var isPrimitive = require('./helpers/isPrimitive');
  8470. var isCallable = require('is-callable');
  8471. var isDate = require('is-date-object');
  8472. var isSymbol = require('is-symbol');
  8473. var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) {
  8474. if (typeof O === 'undefined' || O === null) {
  8475. throw new TypeError('Cannot call method on ' + O);
  8476. }
  8477. if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) {
  8478. throw new TypeError('hint must be "string" or "number"');
  8479. }
  8480. var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
  8481. var method, result, i;
  8482. for (i = 0; i < methodNames.length; ++i) {
  8483. method = O[methodNames[i]];
  8484. if (isCallable(method)) {
  8485. result = method.call(O);
  8486. if (isPrimitive(result)) {
  8487. return result;
  8488. }
  8489. }
  8490. }
  8491. throw new TypeError('No default value');
  8492. };
  8493. var GetMethod = function GetMethod(O, P) {
  8494. var func = O[P];
  8495. if (func !== null && typeof func !== 'undefined') {
  8496. if (!isCallable(func)) {
  8497. throw new TypeError(func + ' returned for property ' + P + ' of object ' + O + ' is not a function');
  8498. }
  8499. return func;
  8500. }
  8501. return void 0;
  8502. };
  8503. // http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
  8504. module.exports = function ToPrimitive(input) {
  8505. if (isPrimitive(input)) {
  8506. return input;
  8507. }
  8508. var hint = 'default';
  8509. if (arguments.length > 1) {
  8510. if (arguments[1] === String) {
  8511. hint = 'string';
  8512. } else if (arguments[1] === Number) {
  8513. hint = 'number';
  8514. }
  8515. }
  8516. var exoticToPrim;
  8517. if (hasSymbols) {
  8518. if (Symbol.toPrimitive) {
  8519. exoticToPrim = GetMethod(input, Symbol.toPrimitive);
  8520. } else if (isSymbol(input)) {
  8521. exoticToPrim = Symbol.prototype.valueOf;
  8522. }
  8523. }
  8524. if (typeof exoticToPrim !== 'undefined') {
  8525. var result = exoticToPrim.call(input, hint);
  8526. if (isPrimitive(result)) {
  8527. return result;
  8528. }
  8529. throw new TypeError('unable to convert exotic object to primitive');
  8530. }
  8531. if (hint === 'default' && (isDate(input) || isSymbol(input))) {
  8532. hint = 'string';
  8533. }
  8534. return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint);
  8535. };
  8536. },{"./helpers/isPrimitive":32,"is-callable":51,"is-date-object":52,"is-symbol":58}],32:[function(require,module,exports){
  8537. arguments[4][27][0].apply(exports,arguments)
  8538. },{"dup":27}],33:[function(require,module,exports){
  8539. // Copyright Joyent, Inc. and other Node contributors.
  8540. //
  8541. // Permission is hereby granted, free of charge, to any person obtaining a
  8542. // copy of this software and associated documentation files (the
  8543. // "Software"), to deal in the Software without restriction, including
  8544. // without limitation the rights to use, copy, modify, merge, publish,
  8545. // distribute, sublicense, and/or sell copies of the Software, and to permit
  8546. // persons to whom the Software is furnished to do so, subject to the
  8547. // following conditions:
  8548. //
  8549. // The above copyright notice and this permission notice shall be included
  8550. // in all copies or substantial portions of the Software.
  8551. //
  8552. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8553. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8554. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  8555. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8556. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  8557. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  8558. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  8559. var objectCreate = Object.create || objectCreatePolyfill
  8560. var objectKeys = Object.keys || objectKeysPolyfill
  8561. var bind = Function.prototype.bind || functionBindPolyfill
  8562. function EventEmitter() {
  8563. if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
  8564. this._events = objectCreate(null);
  8565. this._eventsCount = 0;
  8566. }
  8567. this._maxListeners = this._maxListeners || undefined;
  8568. }
  8569. module.exports = EventEmitter;
  8570. // Backwards-compat with node 0.10.x
  8571. EventEmitter.EventEmitter = EventEmitter;
  8572. EventEmitter.prototype._events = undefined;
  8573. EventEmitter.prototype._maxListeners = undefined;
  8574. // By default EventEmitters will print a warning if more than 10 listeners are
  8575. // added to it. This is a useful default which helps finding memory leaks.
  8576. var defaultMaxListeners = 10;
  8577. var hasDefineProperty;
  8578. try {
  8579. var o = {};
  8580. if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
  8581. hasDefineProperty = o.x === 0;
  8582. } catch (err) { hasDefineProperty = false }
  8583. if (hasDefineProperty) {
  8584. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  8585. enumerable: true,
  8586. get: function() {
  8587. return defaultMaxListeners;
  8588. },
  8589. set: function(arg) {
  8590. // check whether the input is a positive number (whose value is zero or
  8591. // greater and not a NaN).
  8592. if (typeof arg !== 'number' || arg < 0 || arg !== arg)
  8593. throw new TypeError('"defaultMaxListeners" must be a positive number');
  8594. defaultMaxListeners = arg;
  8595. }
  8596. });
  8597. } else {
  8598. EventEmitter.defaultMaxListeners = defaultMaxListeners;
  8599. }
  8600. // Obviously not all Emitters should be limited to 10. This function allows
  8601. // that to be increased. Set to zero for unlimited.
  8602. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  8603. if (typeof n !== 'number' || n < 0 || isNaN(n))
  8604. throw new TypeError('"n" argument must be a positive number');
  8605. this._maxListeners = n;
  8606. return this;
  8607. };
  8608. function $getMaxListeners(that) {
  8609. if (that._maxListeners === undefined)
  8610. return EventEmitter.defaultMaxListeners;
  8611. return that._maxListeners;
  8612. }
  8613. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  8614. return $getMaxListeners(this);
  8615. };
  8616. // These standalone emit* functions are used to optimize calling of event
  8617. // handlers for fast cases because emit() itself often has a variable number of
  8618. // arguments and can be deoptimized because of that. These functions always have
  8619. // the same number of arguments and thus do not get deoptimized, so the code
  8620. // inside them can execute faster.
  8621. function emitNone(handler, isFn, self) {
  8622. if (isFn)
  8623. handler.call(self);
  8624. else {
  8625. var len = handler.length;
  8626. var listeners = arrayClone(handler, len);
  8627. for (var i = 0; i < len; ++i)
  8628. listeners[i].call(self);
  8629. }
  8630. }
  8631. function emitOne(handler, isFn, self, arg1) {
  8632. if (isFn)
  8633. handler.call(self, arg1);
  8634. else {
  8635. var len = handler.length;
  8636. var listeners = arrayClone(handler, len);
  8637. for (var i = 0; i < len; ++i)
  8638. listeners[i].call(self, arg1);
  8639. }
  8640. }
  8641. function emitTwo(handler, isFn, self, arg1, arg2) {
  8642. if (isFn)
  8643. handler.call(self, arg1, arg2);
  8644. else {
  8645. var len = handler.length;
  8646. var listeners = arrayClone(handler, len);
  8647. for (var i = 0; i < len; ++i)
  8648. listeners[i].call(self, arg1, arg2);
  8649. }
  8650. }
  8651. function emitThree(handler, isFn, self, arg1, arg2, arg3) {
  8652. if (isFn)
  8653. handler.call(self, arg1, arg2, arg3);
  8654. else {
  8655. var len = handler.length;
  8656. var listeners = arrayClone(handler, len);
  8657. for (var i = 0; i < len; ++i)
  8658. listeners[i].call(self, arg1, arg2, arg3);
  8659. }
  8660. }
  8661. function emitMany(handler, isFn, self, args) {
  8662. if (isFn)
  8663. handler.apply(self, args);
  8664. else {
  8665. var len = handler.length;
  8666. var listeners = arrayClone(handler, len);
  8667. for (var i = 0; i < len; ++i)
  8668. listeners[i].apply(self, args);
  8669. }
  8670. }
  8671. EventEmitter.prototype.emit = function emit(type) {
  8672. var er, handler, len, args, i, events;
  8673. var doError = (type === 'error');
  8674. events = this._events;
  8675. if (events)
  8676. doError = (doError && events.error == null);
  8677. else if (!doError)
  8678. return false;
  8679. // If there is no 'error' event listener then throw.
  8680. if (doError) {
  8681. if (arguments.length > 1)
  8682. er = arguments[1];
  8683. if (er instanceof Error) {
  8684. throw er; // Unhandled 'error' event
  8685. } else {
  8686. // At least give some kind of context to the user
  8687. var err = new Error('Unhandled "error" event. (' + er + ')');
  8688. err.context = er;
  8689. throw err;
  8690. }
  8691. return false;
  8692. }
  8693. handler = events[type];
  8694. if (!handler)
  8695. return false;
  8696. var isFn = typeof handler === 'function';
  8697. len = arguments.length;
  8698. switch (len) {
  8699. // fast cases
  8700. case 1:
  8701. emitNone(handler, isFn, this);
  8702. break;
  8703. case 2:
  8704. emitOne(handler, isFn, this, arguments[1]);
  8705. break;
  8706. case 3:
  8707. emitTwo(handler, isFn, this, arguments[1], arguments[2]);
  8708. break;
  8709. case 4:
  8710. emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
  8711. break;
  8712. // slower
  8713. default:
  8714. args = new Array(len - 1);
  8715. for (i = 1; i < len; i++)
  8716. args[i - 1] = arguments[i];
  8717. emitMany(handler, isFn, this, args);
  8718. }
  8719. return true;
  8720. };
  8721. function _addListener(target, type, listener, prepend) {
  8722. var m;
  8723. var events;
  8724. var existing;
  8725. if (typeof listener !== 'function')
  8726. throw new TypeError('"listener" argument must be a function');
  8727. events = target._events;
  8728. if (!events) {
  8729. events = target._events = objectCreate(null);
  8730. target._eventsCount = 0;
  8731. } else {
  8732. // To avoid recursion in the case that type === "newListener"! Before
  8733. // adding it to the listeners, first emit "newListener".
  8734. if (events.newListener) {
  8735. target.emit('newListener', type,
  8736. listener.listener ? listener.listener : listener);
  8737. // Re-assign `events` because a newListener handler could have caused the
  8738. // this._events to be assigned to a new object
  8739. events = target._events;
  8740. }
  8741. existing = events[type];
  8742. }
  8743. if (!existing) {
  8744. // Optimize the case of one listener. Don't need the extra array object.
  8745. existing = events[type] = listener;
  8746. ++target._eventsCount;
  8747. } else {
  8748. if (typeof existing === 'function') {
  8749. // Adding the second element, need to change to array.
  8750. existing = events[type] =
  8751. prepend ? [listener, existing] : [existing, listener];
  8752. } else {
  8753. // If we've already got an array, just append.
  8754. if (prepend) {
  8755. existing.unshift(listener);
  8756. } else {
  8757. existing.push(listener);
  8758. }
  8759. }
  8760. // Check for listener leak
  8761. if (!existing.warned) {
  8762. m = $getMaxListeners(target);
  8763. if (m && m > 0 && existing.length > m) {
  8764. existing.warned = true;
  8765. var w = new Error('Possible EventEmitter memory leak detected. ' +
  8766. existing.length + ' "' + String(type) + '" listeners ' +
  8767. 'added. Use emitter.setMaxListeners() to ' +
  8768. 'increase limit.');
  8769. w.name = 'MaxListenersExceededWarning';
  8770. w.emitter = target;
  8771. w.type = type;
  8772. w.count = existing.length;
  8773. if (typeof console === 'object' && console.warn) {
  8774. console.warn('%s: %s', w.name, w.message);
  8775. }
  8776. }
  8777. }
  8778. }
  8779. return target;
  8780. }
  8781. EventEmitter.prototype.addListener = function addListener(type, listener) {
  8782. return _addListener(this, type, listener, false);
  8783. };
  8784. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  8785. EventEmitter.prototype.prependListener =
  8786. function prependListener(type, listener) {
  8787. return _addListener(this, type, listener, true);
  8788. };
  8789. function onceWrapper() {
  8790. if (!this.fired) {
  8791. this.target.removeListener(this.type, this.wrapFn);
  8792. this.fired = true;
  8793. switch (arguments.length) {
  8794. case 0:
  8795. return this.listener.call(this.target);
  8796. case 1:
  8797. return this.listener.call(this.target, arguments[0]);
  8798. case 2:
  8799. return this.listener.call(this.target, arguments[0], arguments[1]);
  8800. case 3:
  8801. return this.listener.call(this.target, arguments[0], arguments[1],
  8802. arguments[2]);
  8803. default:
  8804. var args = new Array(arguments.length);
  8805. for (var i = 0; i < args.length; ++i)
  8806. args[i] = arguments[i];
  8807. this.listener.apply(this.target, args);
  8808. }
  8809. }
  8810. }
  8811. function _onceWrap(target, type, listener) {
  8812. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  8813. var wrapped = bind.call(onceWrapper, state);
  8814. wrapped.listener = listener;
  8815. state.wrapFn = wrapped;
  8816. return wrapped;
  8817. }
  8818. EventEmitter.prototype.once = function once(type, listener) {
  8819. if (typeof listener !== 'function')
  8820. throw new TypeError('"listener" argument must be a function');
  8821. this.on(type, _onceWrap(this, type, listener));
  8822. return this;
  8823. };
  8824. EventEmitter.prototype.prependOnceListener =
  8825. function prependOnceListener(type, listener) {
  8826. if (typeof listener !== 'function')
  8827. throw new TypeError('"listener" argument must be a function');
  8828. this.prependListener(type, _onceWrap(this, type, listener));
  8829. return this;
  8830. };
  8831. // Emits a 'removeListener' event if and only if the listener was removed.
  8832. EventEmitter.prototype.removeListener =
  8833. function removeListener(type, listener) {
  8834. var list, events, position, i, originalListener;
  8835. if (typeof listener !== 'function')
  8836. throw new TypeError('"listener" argument must be a function');
  8837. events = this._events;
  8838. if (!events)
  8839. return this;
  8840. list = events[type];
  8841. if (!list)
  8842. return this;
  8843. if (list === listener || list.listener === listener) {
  8844. if (--this._eventsCount === 0)
  8845. this._events = objectCreate(null);
  8846. else {
  8847. delete events[type];
  8848. if (events.removeListener)
  8849. this.emit('removeListener', type, list.listener || listener);
  8850. }
  8851. } else if (typeof list !== 'function') {
  8852. position = -1;
  8853. for (i = list.length - 1; i >= 0; i--) {
  8854. if (list[i] === listener || list[i].listener === listener) {
  8855. originalListener = list[i].listener;
  8856. position = i;
  8857. break;
  8858. }
  8859. }
  8860. if (position < 0)
  8861. return this;
  8862. if (position === 0)
  8863. list.shift();
  8864. else
  8865. spliceOne(list, position);
  8866. if (list.length === 1)
  8867. events[type] = list[0];
  8868. if (events.removeListener)
  8869. this.emit('removeListener', type, originalListener || listener);
  8870. }
  8871. return this;
  8872. };
  8873. EventEmitter.prototype.removeAllListeners =
  8874. function removeAllListeners(type) {
  8875. var listeners, events, i;
  8876. events = this._events;
  8877. if (!events)
  8878. return this;
  8879. // not listening for removeListener, no need to emit
  8880. if (!events.removeListener) {
  8881. if (arguments.length === 0) {
  8882. this._events = objectCreate(null);
  8883. this._eventsCount = 0;
  8884. } else if (events[type]) {
  8885. if (--this._eventsCount === 0)
  8886. this._events = objectCreate(null);
  8887. else
  8888. delete events[type];
  8889. }
  8890. return this;
  8891. }
  8892. // emit removeListener for all listeners on all events
  8893. if (arguments.length === 0) {
  8894. var keys = objectKeys(events);
  8895. var key;
  8896. for (i = 0; i < keys.length; ++i) {
  8897. key = keys[i];
  8898. if (key === 'removeListener') continue;
  8899. this.removeAllListeners(key);
  8900. }
  8901. this.removeAllListeners('removeListener');
  8902. this._events = objectCreate(null);
  8903. this._eventsCount = 0;
  8904. return this;
  8905. }
  8906. listeners = events[type];
  8907. if (typeof listeners === 'function') {
  8908. this.removeListener(type, listeners);
  8909. } else if (listeners) {
  8910. // LIFO order
  8911. for (i = listeners.length - 1; i >= 0; i--) {
  8912. this.removeListener(type, listeners[i]);
  8913. }
  8914. }
  8915. return this;
  8916. };
  8917. function _listeners(target, type, unwrap) {
  8918. var events = target._events;
  8919. if (!events)
  8920. return [];
  8921. var evlistener = events[type];
  8922. if (!evlistener)
  8923. return [];
  8924. if (typeof evlistener === 'function')
  8925. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  8926. return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  8927. }
  8928. EventEmitter.prototype.listeners = function listeners(type) {
  8929. return _listeners(this, type, true);
  8930. };
  8931. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  8932. return _listeners(this, type, false);
  8933. };
  8934. EventEmitter.listenerCount = function(emitter, type) {
  8935. if (typeof emitter.listenerCount === 'function') {
  8936. return emitter.listenerCount(type);
  8937. } else {
  8938. return listenerCount.call(emitter, type);
  8939. }
  8940. };
  8941. EventEmitter.prototype.listenerCount = listenerCount;
  8942. function listenerCount(type) {
  8943. var events = this._events;
  8944. if (events) {
  8945. var evlistener = events[type];
  8946. if (typeof evlistener === 'function') {
  8947. return 1;
  8948. } else if (evlistener) {
  8949. return evlistener.length;
  8950. }
  8951. }
  8952. return 0;
  8953. }
  8954. EventEmitter.prototype.eventNames = function eventNames() {
  8955. return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
  8956. };
  8957. // About 1.5x faster than the two-arg version of Array#splice().
  8958. function spliceOne(list, index) {
  8959. for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
  8960. list[i] = list[k];
  8961. list.pop();
  8962. }
  8963. function arrayClone(arr, n) {
  8964. var copy = new Array(n);
  8965. for (var i = 0; i < n; ++i)
  8966. copy[i] = arr[i];
  8967. return copy;
  8968. }
  8969. function unwrapListeners(arr) {
  8970. var ret = new Array(arr.length);
  8971. for (var i = 0; i < ret.length; ++i) {
  8972. ret[i] = arr[i].listener || arr[i];
  8973. }
  8974. return ret;
  8975. }
  8976. function objectCreatePolyfill(proto) {
  8977. var F = function() {};
  8978. F.prototype = proto;
  8979. return new F;
  8980. }
  8981. function objectKeysPolyfill(obj) {
  8982. var keys = [];
  8983. for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
  8984. keys.push(k);
  8985. }
  8986. return k;
  8987. }
  8988. function functionBindPolyfill(context) {
  8989. var fn = this;
  8990. return function () {
  8991. return fn.apply(context, arguments);
  8992. };
  8993. }
  8994. },{}],34:[function(require,module,exports){
  8995. 'use strict';
  8996. var isCallable = require('is-callable');
  8997. var toStr = Object.prototype.toString;
  8998. var hasOwnProperty = Object.prototype.hasOwnProperty;
  8999. var forEachArray = function forEachArray(array, iterator, receiver) {
  9000. for (var i = 0, len = array.length; i < len; i++) {
  9001. if (hasOwnProperty.call(array, i)) {
  9002. if (receiver == null) {
  9003. iterator(array[i], i, array);
  9004. } else {
  9005. iterator.call(receiver, array[i], i, array);
  9006. }
  9007. }
  9008. }
  9009. };
  9010. var forEachString = function forEachString(string, iterator, receiver) {
  9011. for (var i = 0, len = string.length; i < len; i++) {
  9012. // no such thing as a sparse string.
  9013. if (receiver == null) {
  9014. iterator(string.charAt(i), i, string);
  9015. } else {
  9016. iterator.call(receiver, string.charAt(i), i, string);
  9017. }
  9018. }
  9019. };
  9020. var forEachObject = function forEachObject(object, iterator, receiver) {
  9021. for (var k in object) {
  9022. if (hasOwnProperty.call(object, k)) {
  9023. if (receiver == null) {
  9024. iterator(object[k], k, object);
  9025. } else {
  9026. iterator.call(receiver, object[k], k, object);
  9027. }
  9028. }
  9029. }
  9030. };
  9031. var forEach = function forEach(list, iterator, thisArg) {
  9032. if (!isCallable(iterator)) {
  9033. throw new TypeError('iterator must be a function');
  9034. }
  9035. var receiver;
  9036. if (arguments.length >= 3) {
  9037. receiver = thisArg;
  9038. }
  9039. if (toStr.call(list) === '[object Array]') {
  9040. forEachArray(list, iterator, receiver);
  9041. } else if (typeof list === 'string') {
  9042. forEachString(list, iterator, receiver);
  9043. } else {
  9044. forEachObject(list, iterator, receiver);
  9045. }
  9046. };
  9047. module.exports = forEach;
  9048. },{"is-callable":51}],35:[function(require,module,exports){
  9049. var hasOwn = Object.prototype.hasOwnProperty;
  9050. var toString = Object.prototype.toString;
  9051. module.exports = function forEach (obj, fn, ctx) {
  9052. if (toString.call(fn) !== '[object Function]') {
  9053. throw new TypeError('iterator must be a function');
  9054. }
  9055. var l = obj.length;
  9056. if (l === +l) {
  9057. for (var i = 0; i < l; i++) {
  9058. fn.call(ctx, obj[i], i, obj);
  9059. }
  9060. } else {
  9061. for (var k in obj) {
  9062. if (hasOwn.call(obj, k)) {
  9063. fn.call(ctx, obj[k], k, obj);
  9064. }
  9065. }
  9066. }
  9067. };
  9068. },{}],36:[function(require,module,exports){
  9069. 'use strict';
  9070. /* eslint no-invalid-this: 1 */
  9071. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  9072. var slice = Array.prototype.slice;
  9073. var toStr = Object.prototype.toString;
  9074. var funcType = '[object Function]';
  9075. module.exports = function bind(that) {
  9076. var target = this;
  9077. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  9078. throw new TypeError(ERROR_MESSAGE + target);
  9079. }
  9080. var args = slice.call(arguments, 1);
  9081. var bound;
  9082. var binder = function () {
  9083. if (this instanceof bound) {
  9084. var result = target.apply(
  9085. this,
  9086. args.concat(slice.call(arguments))
  9087. );
  9088. if (Object(result) === result) {
  9089. return result;
  9090. }
  9091. return this;
  9092. } else {
  9093. return target.apply(
  9094. that,
  9095. args.concat(slice.call(arguments))
  9096. );
  9097. }
  9098. };
  9099. var boundLength = Math.max(0, target.length - args.length);
  9100. var boundArgs = [];
  9101. for (var i = 0; i < boundLength; i++) {
  9102. boundArgs.push('$' + i);
  9103. }
  9104. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  9105. if (target.prototype) {
  9106. var Empty = function Empty() {};
  9107. Empty.prototype = target.prototype;
  9108. bound.prototype = new Empty();
  9109. Empty.prototype = null;
  9110. }
  9111. return bound;
  9112. };
  9113. },{}],37:[function(require,module,exports){
  9114. 'use strict';
  9115. var implementation = require('./implementation');
  9116. module.exports = Function.prototype.bind || implementation;
  9117. },{"./implementation":36}],38:[function(require,module,exports){
  9118. 'use strict';
  9119. var functionsHaveNames = function functionsHaveNames() {
  9120. return typeof function f() {}.name === 'string';
  9121. };
  9122. var gOPD = Object.getOwnPropertyDescriptor;
  9123. if (gOPD) {
  9124. try {
  9125. gOPD([], 'length');
  9126. } catch (e) {
  9127. // IE 8 has a broken gOPD
  9128. gOPD = null;
  9129. }
  9130. }
  9131. functionsHaveNames.functionsHaveConfigurableNames = function functionsHaveConfigurableNames() {
  9132. if (!functionsHaveNames() || !gOPD) {
  9133. return false;
  9134. }
  9135. var desc = gOPD(function () {}, 'name');
  9136. return !!desc && !!desc.configurable;
  9137. };
  9138. var $bind = Function.prototype.bind;
  9139. functionsHaveNames.boundFunctionsHaveNames = function boundFunctionsHaveNames() {
  9140. return functionsHaveNames() && typeof $bind === 'function' && function f() {}.bind().name !== '';
  9141. };
  9142. module.exports = functionsHaveNames;
  9143. },{}],39:[function(require,module,exports){
  9144. 'use strict';
  9145. var undefined;
  9146. var $SyntaxError = SyntaxError;
  9147. var $Function = Function;
  9148. var $TypeError = TypeError;
  9149. // eslint-disable-next-line consistent-return
  9150. var getEvalledConstructor = function (expressionSyntax) {
  9151. try {
  9152. return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
  9153. } catch (e) {}
  9154. };
  9155. var $gOPD = Object.getOwnPropertyDescriptor;
  9156. if ($gOPD) {
  9157. try {
  9158. $gOPD({}, '');
  9159. } catch (e) {
  9160. $gOPD = null; // this is IE 8, which has a broken gOPD
  9161. }
  9162. }
  9163. var throwTypeError = function () {
  9164. throw new $TypeError();
  9165. };
  9166. var ThrowTypeError = $gOPD
  9167. ? (function () {
  9168. try {
  9169. // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
  9170. arguments.callee; // IE 8 does not throw here
  9171. return throwTypeError;
  9172. } catch (calleeThrows) {
  9173. try {
  9174. // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
  9175. return $gOPD(arguments, 'callee').get;
  9176. } catch (gOPDthrows) {
  9177. return throwTypeError;
  9178. }
  9179. }
  9180. }())
  9181. : throwTypeError;
  9182. var hasSymbols = require('has-symbols')();
  9183. var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
  9184. var needsEval = {};
  9185. var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
  9186. var INTRINSICS = {
  9187. '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
  9188. '%Array%': Array,
  9189. '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
  9190. '%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
  9191. '%AsyncFromSyncIteratorPrototype%': undefined,
  9192. '%AsyncFunction%': needsEval,
  9193. '%AsyncGenerator%': needsEval,
  9194. '%AsyncGeneratorFunction%': needsEval,
  9195. '%AsyncIteratorPrototype%': needsEval,
  9196. '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
  9197. '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
  9198. '%Boolean%': Boolean,
  9199. '%DataView%': typeof DataView === 'undefined' ? undefined : DataView,
  9200. '%Date%': Date,
  9201. '%decodeURI%': decodeURI,
  9202. '%decodeURIComponent%': decodeURIComponent,
  9203. '%encodeURI%': encodeURI,
  9204. '%encodeURIComponent%': encodeURIComponent,
  9205. '%Error%': Error,
  9206. '%eval%': eval, // eslint-disable-line no-eval
  9207. '%EvalError%': EvalError,
  9208. '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
  9209. '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
  9210. '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
  9211. '%Function%': $Function,
  9212. '%GeneratorFunction%': needsEval,
  9213. '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
  9214. '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
  9215. '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
  9216. '%isFinite%': isFinite,
  9217. '%isNaN%': isNaN,
  9218. '%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
  9219. '%JSON%': typeof JSON === 'object' ? JSON : undefined,
  9220. '%Map%': typeof Map === 'undefined' ? undefined : Map,
  9221. '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
  9222. '%Math%': Math,
  9223. '%Number%': Number,
  9224. '%Object%': Object,
  9225. '%parseFloat%': parseFloat,
  9226. '%parseInt%': parseInt,
  9227. '%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
  9228. '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
  9229. '%RangeError%': RangeError,
  9230. '%ReferenceError%': ReferenceError,
  9231. '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
  9232. '%RegExp%': RegExp,
  9233. '%Set%': typeof Set === 'undefined' ? undefined : Set,
  9234. '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
  9235. '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
  9236. '%String%': String,
  9237. '%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
  9238. '%Symbol%': hasSymbols ? Symbol : undefined,
  9239. '%SyntaxError%': $SyntaxError,
  9240. '%ThrowTypeError%': ThrowTypeError,
  9241. '%TypedArray%': TypedArray,
  9242. '%TypeError%': $TypeError,
  9243. '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
  9244. '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
  9245. '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
  9246. '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
  9247. '%URIError%': URIError,
  9248. '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
  9249. '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
  9250. '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
  9251. };
  9252. var doEval = function doEval(name) {
  9253. var value;
  9254. if (name === '%AsyncFunction%') {
  9255. value = getEvalledConstructor('async function () {}');
  9256. } else if (name === '%GeneratorFunction%') {
  9257. value = getEvalledConstructor('function* () {}');
  9258. } else if (name === '%AsyncGeneratorFunction%') {
  9259. value = getEvalledConstructor('async function* () {}');
  9260. } else if (name === '%AsyncGenerator%') {
  9261. var fn = doEval('%AsyncGeneratorFunction%');
  9262. if (fn) {
  9263. value = fn.prototype;
  9264. }
  9265. } else if (name === '%AsyncIteratorPrototype%') {
  9266. var gen = doEval('%AsyncGenerator%');
  9267. if (gen) {
  9268. value = getProto(gen.prototype);
  9269. }
  9270. }
  9271. INTRINSICS[name] = value;
  9272. return value;
  9273. };
  9274. var LEGACY_ALIASES = {
  9275. '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
  9276. '%ArrayPrototype%': ['Array', 'prototype'],
  9277. '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
  9278. '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
  9279. '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
  9280. '%ArrayProto_values%': ['Array', 'prototype', 'values'],
  9281. '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
  9282. '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
  9283. '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
  9284. '%BooleanPrototype%': ['Boolean', 'prototype'],
  9285. '%DataViewPrototype%': ['DataView', 'prototype'],
  9286. '%DatePrototype%': ['Date', 'prototype'],
  9287. '%ErrorPrototype%': ['Error', 'prototype'],
  9288. '%EvalErrorPrototype%': ['EvalError', 'prototype'],
  9289. '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
  9290. '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
  9291. '%FunctionPrototype%': ['Function', 'prototype'],
  9292. '%Generator%': ['GeneratorFunction', 'prototype'],
  9293. '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
  9294. '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
  9295. '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
  9296. '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
  9297. '%JSONParse%': ['JSON', 'parse'],
  9298. '%JSONStringify%': ['JSON', 'stringify'],
  9299. '%MapPrototype%': ['Map', 'prototype'],
  9300. '%NumberPrototype%': ['Number', 'prototype'],
  9301. '%ObjectPrototype%': ['Object', 'prototype'],
  9302. '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
  9303. '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
  9304. '%PromisePrototype%': ['Promise', 'prototype'],
  9305. '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
  9306. '%Promise_all%': ['Promise', 'all'],
  9307. '%Promise_reject%': ['Promise', 'reject'],
  9308. '%Promise_resolve%': ['Promise', 'resolve'],
  9309. '%RangeErrorPrototype%': ['RangeError', 'prototype'],
  9310. '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
  9311. '%RegExpPrototype%': ['RegExp', 'prototype'],
  9312. '%SetPrototype%': ['Set', 'prototype'],
  9313. '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
  9314. '%StringPrototype%': ['String', 'prototype'],
  9315. '%SymbolPrototype%': ['Symbol', 'prototype'],
  9316. '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
  9317. '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
  9318. '%TypeErrorPrototype%': ['TypeError', 'prototype'],
  9319. '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
  9320. '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
  9321. '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
  9322. '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
  9323. '%URIErrorPrototype%': ['URIError', 'prototype'],
  9324. '%WeakMapPrototype%': ['WeakMap', 'prototype'],
  9325. '%WeakSetPrototype%': ['WeakSet', 'prototype']
  9326. };
  9327. var bind = require('function-bind');
  9328. var hasOwn = require('has');
  9329. var $concat = bind.call(Function.call, Array.prototype.concat);
  9330. var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
  9331. var $replace = bind.call(Function.call, String.prototype.replace);
  9332. var $strSlice = bind.call(Function.call, String.prototype.slice);
  9333. /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
  9334. var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
  9335. var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
  9336. var stringToPath = function stringToPath(string) {
  9337. var first = $strSlice(string, 0, 1);
  9338. var last = $strSlice(string, -1);
  9339. if (first === '%' && last !== '%') {
  9340. throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
  9341. } else if (last === '%' && first !== '%') {
  9342. throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
  9343. }
  9344. var result = [];
  9345. $replace(string, rePropName, function (match, number, quote, subString) {
  9346. result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
  9347. });
  9348. return result;
  9349. };
  9350. /* end adaptation */
  9351. var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
  9352. var intrinsicName = name;
  9353. var alias;
  9354. if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
  9355. alias = LEGACY_ALIASES[intrinsicName];
  9356. intrinsicName = '%' + alias[0] + '%';
  9357. }
  9358. if (hasOwn(INTRINSICS, intrinsicName)) {
  9359. var value = INTRINSICS[intrinsicName];
  9360. if (value === needsEval) {
  9361. value = doEval(intrinsicName);
  9362. }
  9363. if (typeof value === 'undefined' && !allowMissing) {
  9364. throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
  9365. }
  9366. return {
  9367. alias: alias,
  9368. name: intrinsicName,
  9369. value: value
  9370. };
  9371. }
  9372. throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
  9373. };
  9374. module.exports = function GetIntrinsic(name, allowMissing) {
  9375. if (typeof name !== 'string' || name.length === 0) {
  9376. throw new $TypeError('intrinsic name must be a non-empty string');
  9377. }
  9378. if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
  9379. throw new $TypeError('"allowMissing" argument must be a boolean');
  9380. }
  9381. var parts = stringToPath(name);
  9382. var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
  9383. var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
  9384. var intrinsicRealName = intrinsic.name;
  9385. var value = intrinsic.value;
  9386. var skipFurtherCaching = false;
  9387. var alias = intrinsic.alias;
  9388. if (alias) {
  9389. intrinsicBaseName = alias[0];
  9390. $spliceApply(parts, $concat([0, 1], alias));
  9391. }
  9392. for (var i = 1, isOwn = true; i < parts.length; i += 1) {
  9393. var part = parts[i];
  9394. var first = $strSlice(part, 0, 1);
  9395. var last = $strSlice(part, -1);
  9396. if (
  9397. (
  9398. (first === '"' || first === "'" || first === '`')
  9399. || (last === '"' || last === "'" || last === '`')
  9400. )
  9401. && first !== last
  9402. ) {
  9403. throw new $SyntaxError('property names with quotes must have matching quotes');
  9404. }
  9405. if (part === 'constructor' || !isOwn) {
  9406. skipFurtherCaching = true;
  9407. }
  9408. intrinsicBaseName += '.' + part;
  9409. intrinsicRealName = '%' + intrinsicBaseName + '%';
  9410. if (hasOwn(INTRINSICS, intrinsicRealName)) {
  9411. value = INTRINSICS[intrinsicRealName];
  9412. } else if (value != null) {
  9413. if (!(part in value)) {
  9414. if (!allowMissing) {
  9415. throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
  9416. }
  9417. return void undefined;
  9418. }
  9419. if ($gOPD && (i + 1) >= parts.length) {
  9420. var desc = $gOPD(value, part);
  9421. isOwn = !!desc;
  9422. // By convention, when a data property is converted to an accessor
  9423. // property to emulate a data property that does not suffer from
  9424. // the override mistake, that accessor's getter is marked with
  9425. // an `originalValue` property. Here, when we detect this, we
  9426. // uphold the illusion by pretending to see that original data
  9427. // property, i.e., returning the value rather than the getter
  9428. // itself.
  9429. if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
  9430. value = desc.get;
  9431. } else {
  9432. value = value[part];
  9433. }
  9434. } else {
  9435. isOwn = hasOwn(value, part);
  9436. value = value[part];
  9437. }
  9438. if (isOwn && !skipFurtherCaching) {
  9439. INTRINSICS[intrinsicRealName] = value;
  9440. }
  9441. }
  9442. }
  9443. return value;
  9444. };
  9445. },{"function-bind":37,"has":45,"has-symbols":42}],40:[function(require,module,exports){
  9446. (function (global){(function (){
  9447. 'use strict';
  9448. var $BigInt = global.BigInt;
  9449. module.exports = function hasNativeBigInts() {
  9450. return typeof $BigInt === 'function'
  9451. && typeof BigInt === 'function'
  9452. && typeof $BigInt(42) === 'bigint' // eslint-disable-line no-magic-numbers
  9453. && typeof BigInt(42) === 'bigint'; // eslint-disable-line no-magic-numbers
  9454. };
  9455. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  9456. },{}],41:[function(require,module,exports){
  9457. 'use strict';
  9458. var GetIntrinsic = require('get-intrinsic');
  9459. var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
  9460. var hasPropertyDescriptors = function hasPropertyDescriptors() {
  9461. if ($defineProperty) {
  9462. try {
  9463. $defineProperty({}, 'a', { value: 1 });
  9464. return true;
  9465. } catch (e) {
  9466. // IE 8 has a broken defineProperty
  9467. return false;
  9468. }
  9469. }
  9470. return false;
  9471. };
  9472. hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
  9473. // node v0.6 has a bug where array lengths can be Set but not Defined
  9474. if (!hasPropertyDescriptors()) {
  9475. return null;
  9476. }
  9477. try {
  9478. return $defineProperty([], 'length', { value: 1 }).length !== 1;
  9479. } catch (e) {
  9480. // In Firefox 4-22, defining length on an array throws an exception.
  9481. return true;
  9482. }
  9483. };
  9484. module.exports = hasPropertyDescriptors;
  9485. },{"get-intrinsic":39}],42:[function(require,module,exports){
  9486. 'use strict';
  9487. var origSymbol = typeof Symbol !== 'undefined' && Symbol;
  9488. var hasSymbolSham = require('./shams');
  9489. module.exports = function hasNativeSymbols() {
  9490. if (typeof origSymbol !== 'function') { return false; }
  9491. if (typeof Symbol !== 'function') { return false; }
  9492. if (typeof origSymbol('foo') !== 'symbol') { return false; }
  9493. if (typeof Symbol('bar') !== 'symbol') { return false; }
  9494. return hasSymbolSham();
  9495. };
  9496. },{"./shams":43}],43:[function(require,module,exports){
  9497. 'use strict';
  9498. /* eslint complexity: [2, 18], max-statements: [2, 33] */
  9499. module.exports = function hasSymbols() {
  9500. if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
  9501. if (typeof Symbol.iterator === 'symbol') { return true; }
  9502. var obj = {};
  9503. var sym = Symbol('test');
  9504. var symObj = Object(sym);
  9505. if (typeof sym === 'string') { return false; }
  9506. if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
  9507. if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
  9508. // temp disabled per https://github.com/ljharb/object.assign/issues/17
  9509. // if (sym instanceof Symbol) { return false; }
  9510. // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
  9511. // if (!(symObj instanceof Symbol)) { return false; }
  9512. // if (typeof Symbol.prototype.toString !== 'function') { return false; }
  9513. // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
  9514. var symVal = 42;
  9515. obj[sym] = symVal;
  9516. for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
  9517. if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
  9518. if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
  9519. var syms = Object.getOwnPropertySymbols(obj);
  9520. if (syms.length !== 1 || syms[0] !== sym) { return false; }
  9521. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
  9522. if (typeof Object.getOwnPropertyDescriptor === 'function') {
  9523. var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
  9524. if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
  9525. }
  9526. return true;
  9527. };
  9528. },{}],44:[function(require,module,exports){
  9529. 'use strict';
  9530. var hasSymbols = require('has-symbols/shams');
  9531. module.exports = function hasToStringTagShams() {
  9532. return hasSymbols() && !!Symbol.toStringTag;
  9533. };
  9534. },{"has-symbols/shams":43}],45:[function(require,module,exports){
  9535. 'use strict';
  9536. var bind = require('function-bind');
  9537. module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
  9538. },{"function-bind":37}],46:[function(require,module,exports){
  9539. /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
  9540. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  9541. var e, m
  9542. var eLen = (nBytes * 8) - mLen - 1
  9543. var eMax = (1 << eLen) - 1
  9544. var eBias = eMax >> 1
  9545. var nBits = -7
  9546. var i = isLE ? (nBytes - 1) : 0
  9547. var d = isLE ? -1 : 1
  9548. var s = buffer[offset + i]
  9549. i += d
  9550. e = s & ((1 << (-nBits)) - 1)
  9551. s >>= (-nBits)
  9552. nBits += eLen
  9553. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  9554. m = e & ((1 << (-nBits)) - 1)
  9555. e >>= (-nBits)
  9556. nBits += mLen
  9557. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  9558. if (e === 0) {
  9559. e = 1 - eBias
  9560. } else if (e === eMax) {
  9561. return m ? NaN : ((s ? -1 : 1) * Infinity)
  9562. } else {
  9563. m = m + Math.pow(2, mLen)
  9564. e = e - eBias
  9565. }
  9566. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  9567. }
  9568. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  9569. var e, m, c
  9570. var eLen = (nBytes * 8) - mLen - 1
  9571. var eMax = (1 << eLen) - 1
  9572. var eBias = eMax >> 1
  9573. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  9574. var i = isLE ? 0 : (nBytes - 1)
  9575. var d = isLE ? 1 : -1
  9576. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  9577. value = Math.abs(value)
  9578. if (isNaN(value) || value === Infinity) {
  9579. m = isNaN(value) ? 1 : 0
  9580. e = eMax
  9581. } else {
  9582. e = Math.floor(Math.log(value) / Math.LN2)
  9583. if (value * (c = Math.pow(2, -e)) < 1) {
  9584. e--
  9585. c *= 2
  9586. }
  9587. if (e + eBias >= 1) {
  9588. value += rt / c
  9589. } else {
  9590. value += rt * Math.pow(2, 1 - eBias)
  9591. }
  9592. if (value * c >= 2) {
  9593. e++
  9594. c /= 2
  9595. }
  9596. if (e + eBias >= eMax) {
  9597. m = 0
  9598. e = eMax
  9599. } else if (e + eBias >= 1) {
  9600. m = ((value * c) - 1) * Math.pow(2, mLen)
  9601. e = e + eBias
  9602. } else {
  9603. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  9604. e = 0
  9605. }
  9606. }
  9607. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  9608. e = (e << mLen) | m
  9609. eLen += mLen
  9610. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  9611. buffer[offset + i - d] |= s * 128
  9612. }
  9613. },{}],47:[function(require,module,exports){
  9614. if (typeof Object.create === 'function') {
  9615. // implementation from standard node.js 'util' module
  9616. module.exports = function inherits(ctor, superCtor) {
  9617. if (superCtor) {
  9618. ctor.super_ = superCtor
  9619. ctor.prototype = Object.create(superCtor.prototype, {
  9620. constructor: {
  9621. value: ctor,
  9622. enumerable: false,
  9623. writable: true,
  9624. configurable: true
  9625. }
  9626. })
  9627. }
  9628. };
  9629. } else {
  9630. // old school shim for old browsers
  9631. module.exports = function inherits(ctor, superCtor) {
  9632. if (superCtor) {
  9633. ctor.super_ = superCtor
  9634. var TempCtor = function () {}
  9635. TempCtor.prototype = superCtor.prototype
  9636. ctor.prototype = new TempCtor()
  9637. ctor.prototype.constructor = ctor
  9638. }
  9639. }
  9640. }
  9641. },{}],48:[function(require,module,exports){
  9642. 'use strict';
  9643. var hasToStringTag = require('has-tostringtag/shams')();
  9644. var callBound = require('call-bind/callBound');
  9645. var $toString = callBound('Object.prototype.toString');
  9646. var isStandardArguments = function isArguments(value) {
  9647. if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) {
  9648. return false;
  9649. }
  9650. return $toString(value) === '[object Arguments]';
  9651. };
  9652. var isLegacyArguments = function isArguments(value) {
  9653. if (isStandardArguments(value)) {
  9654. return true;
  9655. }
  9656. return value !== null &&
  9657. typeof value === 'object' &&
  9658. typeof value.length === 'number' &&
  9659. value.length >= 0 &&
  9660. $toString(value) !== '[object Array]' &&
  9661. $toString(value.callee) === '[object Function]';
  9662. };
  9663. var supportsStandardArguments = (function () {
  9664. return isStandardArguments(arguments);
  9665. }());
  9666. isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
  9667. module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
  9668. },{"call-bind/callBound":11,"has-tostringtag/shams":44}],49:[function(require,module,exports){
  9669. 'use strict';
  9670. var hasBigInts = require('has-bigints')();
  9671. if (hasBigInts) {
  9672. var bigIntValueOf = BigInt.prototype.valueOf;
  9673. var tryBigInt = function tryBigIntObject(value) {
  9674. try {
  9675. bigIntValueOf.call(value);
  9676. return true;
  9677. } catch (e) {
  9678. }
  9679. return false;
  9680. };
  9681. module.exports = function isBigInt(value) {
  9682. if (
  9683. value === null
  9684. || typeof value === 'undefined'
  9685. || typeof value === 'boolean'
  9686. || typeof value === 'string'
  9687. || typeof value === 'number'
  9688. || typeof value === 'symbol'
  9689. || typeof value === 'function'
  9690. ) {
  9691. return false;
  9692. }
  9693. if (typeof value === 'bigint') {
  9694. return true;
  9695. }
  9696. return tryBigInt(value);
  9697. };
  9698. } else {
  9699. module.exports = function isBigInt(value) {
  9700. return false && value;
  9701. };
  9702. }
  9703. },{"has-bigints":40}],50:[function(require,module,exports){
  9704. 'use strict';
  9705. var callBound = require('call-bind/callBound');
  9706. var $boolToStr = callBound('Boolean.prototype.toString');
  9707. var $toString = callBound('Object.prototype.toString');
  9708. var tryBooleanObject = function booleanBrandCheck(value) {
  9709. try {
  9710. $boolToStr(value);
  9711. return true;
  9712. } catch (e) {
  9713. return false;
  9714. }
  9715. };
  9716. var boolClass = '[object Boolean]';
  9717. var hasToStringTag = require('has-tostringtag/shams')();
  9718. module.exports = function isBoolean(value) {
  9719. if (typeof value === 'boolean') {
  9720. return true;
  9721. }
  9722. if (value === null || typeof value !== 'object') {
  9723. return false;
  9724. }
  9725. return hasToStringTag && Symbol.toStringTag in value ? tryBooleanObject(value) : $toString(value) === boolClass;
  9726. };
  9727. },{"call-bind/callBound":11,"has-tostringtag/shams":44}],51:[function(require,module,exports){
  9728. 'use strict';
  9729. var fnToStr = Function.prototype.toString;
  9730. var reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply;
  9731. var badArrayLike;
  9732. var isCallableMarker;
  9733. if (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') {
  9734. try {
  9735. badArrayLike = Object.defineProperty({}, 'length', {
  9736. get: function () {
  9737. throw isCallableMarker;
  9738. }
  9739. });
  9740. isCallableMarker = {};
  9741. // eslint-disable-next-line no-throw-literal
  9742. reflectApply(function () { throw 42; }, null, badArrayLike);
  9743. } catch (_) {
  9744. if (_ !== isCallableMarker) {
  9745. reflectApply = null;
  9746. }
  9747. }
  9748. } else {
  9749. reflectApply = null;
  9750. }
  9751. var constructorRegex = /^\s*class\b/;
  9752. var isES6ClassFn = function isES6ClassFunction(value) {
  9753. try {
  9754. var fnStr = fnToStr.call(value);
  9755. return constructorRegex.test(fnStr);
  9756. } catch (e) {
  9757. return false; // not a function
  9758. }
  9759. };
  9760. var tryFunctionObject = function tryFunctionToStr(value) {
  9761. try {
  9762. if (isES6ClassFn(value)) { return false; }
  9763. fnToStr.call(value);
  9764. return true;
  9765. } catch (e) {
  9766. return false;
  9767. }
  9768. };
  9769. var toStr = Object.prototype.toString;
  9770. var fnClass = '[object Function]';
  9771. var genClass = '[object GeneratorFunction]';
  9772. var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag`
  9773. /* globals document: false */
  9774. var documentDotAll = typeof document === 'object' && typeof document.all === 'undefined' && document.all !== undefined ? document.all : {};
  9775. module.exports = reflectApply
  9776. ? function isCallable(value) {
  9777. if (value === documentDotAll) { return true; }
  9778. if (!value) { return false; }
  9779. if (typeof value !== 'function' && typeof value !== 'object') { return false; }
  9780. if (typeof value === 'function' && !value.prototype) { return true; }
  9781. try {
  9782. reflectApply(value, null, badArrayLike);
  9783. } catch (e) {
  9784. if (e !== isCallableMarker) { return false; }
  9785. }
  9786. return !isES6ClassFn(value);
  9787. }
  9788. : function isCallable(value) {
  9789. if (value === documentDotAll) { return true; }
  9790. if (!value) { return false; }
  9791. if (typeof value !== 'function' && typeof value !== 'object') { return false; }
  9792. if (typeof value === 'function' && !value.prototype) { return true; }
  9793. if (hasToStringTag) { return tryFunctionObject(value); }
  9794. if (isES6ClassFn(value)) { return false; }
  9795. var strClass = toStr.call(value);
  9796. return strClass === fnClass || strClass === genClass;
  9797. };
  9798. },{}],52:[function(require,module,exports){
  9799. 'use strict';
  9800. var getDay = Date.prototype.getDay;
  9801. var tryDateObject = function tryDateGetDayCall(value) {
  9802. try {
  9803. getDay.call(value);
  9804. return true;
  9805. } catch (e) {
  9806. return false;
  9807. }
  9808. };
  9809. var toStr = Object.prototype.toString;
  9810. var dateClass = '[object Date]';
  9811. var hasToStringTag = require('has-tostringtag/shams')();
  9812. module.exports = function isDateObject(value) {
  9813. if (typeof value !== 'object' || value === null) {
  9814. return false;
  9815. }
  9816. return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
  9817. };
  9818. },{"has-tostringtag/shams":44}],53:[function(require,module,exports){
  9819. 'use strict';
  9820. var $Map = typeof Map === 'function' && Map.prototype ? Map : null;
  9821. var $Set = typeof Set === 'function' && Set.prototype ? Set : null;
  9822. var exported;
  9823. if (!$Map) {
  9824. // eslint-disable-next-line no-unused-vars
  9825. exported = function isMap(x) {
  9826. // `Map` is not present in this environment.
  9827. return false;
  9828. };
  9829. }
  9830. var $mapHas = $Map ? Map.prototype.has : null;
  9831. var $setHas = $Set ? Set.prototype.has : null;
  9832. if (!exported && !$mapHas) {
  9833. // eslint-disable-next-line no-unused-vars
  9834. exported = function isMap(x) {
  9835. // `Map` does not have a `has` method
  9836. return false;
  9837. };
  9838. }
  9839. module.exports = exported || function isMap(x) {
  9840. if (!x || typeof x !== 'object') {
  9841. return false;
  9842. }
  9843. try {
  9844. $mapHas.call(x);
  9845. if ($setHas) {
  9846. try {
  9847. $setHas.call(x);
  9848. } catch (e) {
  9849. return true;
  9850. }
  9851. }
  9852. return x instanceof $Map; // core-js workaround, pre-v2.5.0
  9853. } catch (e) {}
  9854. return false;
  9855. };
  9856. },{}],54:[function(require,module,exports){
  9857. 'use strict';
  9858. var numToStr = Number.prototype.toString;
  9859. var tryNumberObject = function tryNumberObject(value) {
  9860. try {
  9861. numToStr.call(value);
  9862. return true;
  9863. } catch (e) {
  9864. return false;
  9865. }
  9866. };
  9867. var toStr = Object.prototype.toString;
  9868. var numClass = '[object Number]';
  9869. var hasToStringTag = require('has-tostringtag/shams')();
  9870. module.exports = function isNumberObject(value) {
  9871. if (typeof value === 'number') {
  9872. return true;
  9873. }
  9874. if (typeof value !== 'object') {
  9875. return false;
  9876. }
  9877. return hasToStringTag ? tryNumberObject(value) : toStr.call(value) === numClass;
  9878. };
  9879. },{"has-tostringtag/shams":44}],55:[function(require,module,exports){
  9880. 'use strict';
  9881. var callBound = require('call-bind/callBound');
  9882. var hasToStringTag = require('has-tostringtag/shams')();
  9883. var has;
  9884. var $exec;
  9885. var isRegexMarker;
  9886. var badStringifier;
  9887. if (hasToStringTag) {
  9888. has = callBound('Object.prototype.hasOwnProperty');
  9889. $exec = callBound('RegExp.prototype.exec');
  9890. isRegexMarker = {};
  9891. var throwRegexMarker = function () {
  9892. throw isRegexMarker;
  9893. };
  9894. badStringifier = {
  9895. toString: throwRegexMarker,
  9896. valueOf: throwRegexMarker
  9897. };
  9898. if (typeof Symbol.toPrimitive === 'symbol') {
  9899. badStringifier[Symbol.toPrimitive] = throwRegexMarker;
  9900. }
  9901. }
  9902. var $toString = callBound('Object.prototype.toString');
  9903. var gOPD = Object.getOwnPropertyDescriptor;
  9904. var regexClass = '[object RegExp]';
  9905. module.exports = hasToStringTag
  9906. // eslint-disable-next-line consistent-return
  9907. ? function isRegex(value) {
  9908. if (!value || typeof value !== 'object') {
  9909. return false;
  9910. }
  9911. var descriptor = gOPD(value, 'lastIndex');
  9912. var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
  9913. if (!hasLastIndexDataProperty) {
  9914. return false;
  9915. }
  9916. try {
  9917. $exec(value, badStringifier);
  9918. } catch (e) {
  9919. return e === isRegexMarker;
  9920. }
  9921. }
  9922. : function isRegex(value) {
  9923. // In older browsers, typeof regex incorrectly returns 'function'
  9924. if (!value || (typeof value !== 'object' && typeof value !== 'function')) {
  9925. return false;
  9926. }
  9927. return $toString(value) === regexClass;
  9928. };
  9929. },{"call-bind/callBound":11,"has-tostringtag/shams":44}],56:[function(require,module,exports){
  9930. 'use strict';
  9931. var $Map = typeof Map === 'function' && Map.prototype ? Map : null;
  9932. var $Set = typeof Set === 'function' && Set.prototype ? Set : null;
  9933. var exported;
  9934. if (!$Set) {
  9935. // eslint-disable-next-line no-unused-vars
  9936. exported = function isSet(x) {
  9937. // `Set` is not present in this environment.
  9938. return false;
  9939. };
  9940. }
  9941. var $mapHas = $Map ? Map.prototype.has : null;
  9942. var $setHas = $Set ? Set.prototype.has : null;
  9943. if (!exported && !$setHas) {
  9944. // eslint-disable-next-line no-unused-vars
  9945. exported = function isSet(x) {
  9946. // `Set` does not have a `has` method
  9947. return false;
  9948. };
  9949. }
  9950. module.exports = exported || function isSet(x) {
  9951. if (!x || typeof x !== 'object') {
  9952. return false;
  9953. }
  9954. try {
  9955. $setHas.call(x);
  9956. if ($mapHas) {
  9957. try {
  9958. $mapHas.call(x);
  9959. } catch (e) {
  9960. return true;
  9961. }
  9962. }
  9963. return x instanceof $Set; // core-js workaround, pre-v2.5.0
  9964. } catch (e) {}
  9965. return false;
  9966. };
  9967. },{}],57:[function(require,module,exports){
  9968. 'use strict';
  9969. var strValue = String.prototype.valueOf;
  9970. var tryStringObject = function tryStringObject(value) {
  9971. try {
  9972. strValue.call(value);
  9973. return true;
  9974. } catch (e) {
  9975. return false;
  9976. }
  9977. };
  9978. var toStr = Object.prototype.toString;
  9979. var strClass = '[object String]';
  9980. var hasToStringTag = require('has-tostringtag/shams')();
  9981. module.exports = function isString(value) {
  9982. if (typeof value === 'string') {
  9983. return true;
  9984. }
  9985. if (typeof value !== 'object') {
  9986. return false;
  9987. }
  9988. return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass;
  9989. };
  9990. },{"has-tostringtag/shams":44}],58:[function(require,module,exports){
  9991. 'use strict';
  9992. var toStr = Object.prototype.toString;
  9993. var hasSymbols = require('has-symbols')();
  9994. if (hasSymbols) {
  9995. var symToStr = Symbol.prototype.toString;
  9996. var symStringRegex = /^Symbol\(.*\)$/;
  9997. var isSymbolObject = function isRealSymbolObject(value) {
  9998. if (typeof value.valueOf() !== 'symbol') {
  9999. return false;
  10000. }
  10001. return symStringRegex.test(symToStr.call(value));
  10002. };
  10003. module.exports = function isSymbol(value) {
  10004. if (typeof value === 'symbol') {
  10005. return true;
  10006. }
  10007. if (toStr.call(value) !== '[object Symbol]') {
  10008. return false;
  10009. }
  10010. try {
  10011. return isSymbolObject(value);
  10012. } catch (e) {
  10013. return false;
  10014. }
  10015. };
  10016. } else {
  10017. module.exports = function isSymbol(value) {
  10018. // this environment does not support Symbols.
  10019. return false && value;
  10020. };
  10021. }
  10022. },{"has-symbols":42}],59:[function(require,module,exports){
  10023. (function (global){(function (){
  10024. 'use strict';
  10025. var forEach = require('foreach');
  10026. var availableTypedArrays = require('available-typed-arrays');
  10027. var callBound = require('call-bind/callBound');
  10028. var $toString = callBound('Object.prototype.toString');
  10029. var hasToStringTag = require('has-tostringtag/shams')();
  10030. var g = typeof globalThis === 'undefined' ? global : globalThis;
  10031. var typedArrays = availableTypedArrays();
  10032. var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
  10033. for (var i = 0; i < array.length; i += 1) {
  10034. if (array[i] === value) {
  10035. return i;
  10036. }
  10037. }
  10038. return -1;
  10039. };
  10040. var $slice = callBound('String.prototype.slice');
  10041. var toStrTags = {};
  10042. var gOPD = require('es-abstract/helpers/getOwnPropertyDescriptor');
  10043. var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
  10044. if (hasToStringTag && gOPD && getPrototypeOf) {
  10045. forEach(typedArrays, function (typedArray) {
  10046. var arr = new g[typedArray]();
  10047. if (Symbol.toStringTag in arr) {
  10048. var proto = getPrototypeOf(arr);
  10049. var descriptor = gOPD(proto, Symbol.toStringTag);
  10050. if (!descriptor) {
  10051. var superProto = getPrototypeOf(proto);
  10052. descriptor = gOPD(superProto, Symbol.toStringTag);
  10053. }
  10054. toStrTags[typedArray] = descriptor.get;
  10055. }
  10056. });
  10057. }
  10058. var tryTypedArrays = function tryAllTypedArrays(value) {
  10059. var anyTrue = false;
  10060. forEach(toStrTags, function (getter, typedArray) {
  10061. if (!anyTrue) {
  10062. try {
  10063. anyTrue = getter.call(value) === typedArray;
  10064. } catch (e) { /**/ }
  10065. }
  10066. });
  10067. return anyTrue;
  10068. };
  10069. module.exports = function isTypedArray(value) {
  10070. if (!value || typeof value !== 'object') { return false; }
  10071. if (!hasToStringTag || !(Symbol.toStringTag in value)) {
  10072. var tag = $slice($toString(value), 8, -1);
  10073. return $indexOf(typedArrays, tag) > -1;
  10074. }
  10075. if (!gOPD) { return false; }
  10076. return tryTypedArrays(value);
  10077. };
  10078. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  10079. },{"available-typed-arrays":7,"call-bind/callBound":11,"es-abstract/helpers/getOwnPropertyDescriptor":26,"foreach":35,"has-tostringtag/shams":44}],60:[function(require,module,exports){
  10080. 'use strict';
  10081. var $WeakMap = typeof WeakMap === 'function' && WeakMap.prototype ? WeakMap : null;
  10082. var $WeakSet = typeof WeakSet === 'function' && WeakSet.prototype ? WeakSet : null;
  10083. var exported;
  10084. if (!$WeakMap) {
  10085. // eslint-disable-next-line no-unused-vars
  10086. exported = function isWeakMap(x) {
  10087. // `WeakMap` is not present in this environment.
  10088. return false;
  10089. };
  10090. }
  10091. var $mapHas = $WeakMap ? $WeakMap.prototype.has : null;
  10092. var $setHas = $WeakSet ? $WeakSet.prototype.has : null;
  10093. if (!exported && !$mapHas) {
  10094. // eslint-disable-next-line no-unused-vars
  10095. exported = function isWeakMap(x) {
  10096. // `WeakMap` does not have a `has` method
  10097. return false;
  10098. };
  10099. }
  10100. module.exports = exported || function isWeakMap(x) {
  10101. if (!x || typeof x !== 'object') {
  10102. return false;
  10103. }
  10104. try {
  10105. $mapHas.call(x, $mapHas);
  10106. if ($setHas) {
  10107. try {
  10108. $setHas.call(x, $setHas);
  10109. } catch (e) {
  10110. return true;
  10111. }
  10112. }
  10113. return x instanceof $WeakMap; // core-js workaround, pre-v3
  10114. } catch (e) {}
  10115. return false;
  10116. };
  10117. },{}],61:[function(require,module,exports){
  10118. 'use strict';
  10119. var GetIntrinsic = require('get-intrinsic');
  10120. var callBound = require('call-bind/callBound');
  10121. var $WeakSet = GetIntrinsic('%WeakSet%', true);
  10122. var $setHas = callBound('WeakSet.prototype.has', true);
  10123. if ($setHas) {
  10124. var $mapHas = callBound('WeakMap.prototype.has', true);
  10125. module.exports = function isWeakSet(x) {
  10126. if (!x || typeof x !== 'object') {
  10127. return false;
  10128. }
  10129. try {
  10130. $setHas(x, $setHas);
  10131. if ($mapHas) {
  10132. try {
  10133. $mapHas(x, $mapHas);
  10134. } catch (e) {
  10135. return true;
  10136. }
  10137. }
  10138. return x instanceof $WeakSet; // core-js workaround, pre-v3
  10139. } catch (e) {}
  10140. return false;
  10141. };
  10142. } else {
  10143. // eslint-disable-next-line no-unused-vars
  10144. module.exports = function isWeakSet(x) {
  10145. // `WeakSet` does not exist, or does not have a `has` method
  10146. return false;
  10147. };
  10148. }
  10149. },{"call-bind/callBound":11,"get-intrinsic":39}],62:[function(require,module,exports){
  10150. arguments[4][15][0].apply(exports,arguments)
  10151. },{"dup":15}],63:[function(require,module,exports){
  10152. 'use strict';
  10153. var has = require('has');
  10154. var hasPropertyDescriptors = require('has-property-descriptors');
  10155. var isArray = require('isarray');
  10156. var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();
  10157. var $defineProperty = hasPropertyDescriptors() && Object.defineProperty;
  10158. var hasArrayLengthDefineBug = hasPropertyDescriptors.hasArrayLengthDefineBug();
  10159. var gOPD = Object.getOwnPropertyDescriptor;
  10160. var $TypeError = TypeError;
  10161. var $SyntaxError = SyntaxError;
  10162. module.exports = function mockProperty(obj, prop, options) {
  10163. if (has(options, 'nonEnumerable') && typeof options.nonEnumerable !== 'boolean') {
  10164. throw new $TypeError('`nonEnumerable` option, when present, must be a boolean');
  10165. }
  10166. if (has(options, 'nonWritable') && typeof options.nonWritable !== 'boolean') {
  10167. throw new $TypeError('`nonEnumerable` option, when present, must be a boolean');
  10168. }
  10169. if (has(options, 'delete') && typeof options['delete'] !== 'boolean') {
  10170. throw new $TypeError('`delete` option, when present, must be a boolean');
  10171. }
  10172. var wantsData = has(options, 'value') || has(options, 'nonWritable');
  10173. var wantsAccessor = has(options, 'get') || has(options, 'set');
  10174. if (wantsAccessor) {
  10175. if (wantsData) {
  10176. throw new $TypeError('`value` and `nonWritable` options are mutually exclusive with `get`/`set` options');
  10177. }
  10178. if (
  10179. (has(options, 'get') && typeof options.get !== 'function' && typeof options.get !== 'undefined')
  10180. || (has(options, 'set') && typeof options.set !== 'function' && typeof options.set !== 'undefined')
  10181. ) {
  10182. throw new $TypeError('`get` and `set` options, when present, must be functions or `undefined`');
  10183. }
  10184. if (!gOPD || !$defineProperty) {
  10185. throw new $SyntaxError('the `get`/`set` options require native getter/setter support');
  10186. }
  10187. }
  10188. if (options['delete'] && (wantsData || wantsAccessor || has(options, 'nonEnumerable'))) {
  10189. throw new $TypeError('`delete` option must not be set to true when any of `value`, `get`, `set`, `nonWritable`, or `nonEnumerable` are provided');
  10190. }
  10191. var objIsArray = isArray(obj);
  10192. var origDescriptor = gOPD
  10193. ? gOPD(obj, prop)
  10194. : {
  10195. configurable: typeof obj === 'function' && prop === 'name' ? functionsHaveConfigurableNames : true,
  10196. enumerable: !(objIsArray && prop === 'length'),
  10197. value: obj[prop],
  10198. writable: true
  10199. };
  10200. var origConfigurable = origDescriptor ? origDescriptor.configurable : true;
  10201. var origEnumerable = origDescriptor ? origDescriptor.enumerable : true;
  10202. if (wantsAccessor) {
  10203. var hasGetter = origDescriptor && typeof origDescriptor.get === 'function';
  10204. var hasSetter = origDescriptor && typeof origDescriptor.set === 'function';
  10205. var hasFutureGetter = has(options, 'get') ? typeof options.get === 'function' : hasGetter;
  10206. var hasFutureSetter = has(options, 'set') ? typeof options.set === 'function' : hasSetter;
  10207. if (!hasFutureGetter && !hasFutureSetter) {
  10208. throw new $TypeError('when the `get` or `set` options are provided, the mocked object property must end up with at least one of a getter or a setter function');
  10209. }
  10210. }
  10211. var isChangingEnumerability = has(options, 'nonEnumerable') ? !options.nonEnumerable !== origEnumerable : false;
  10212. if (origDescriptor && !origDescriptor.configurable) {
  10213. if (isChangingEnumerability) {
  10214. throw new $TypeError('`' + prop + '` is nonconfigurable, and can not be changed');
  10215. }
  10216. if (wantsAccessor) {
  10217. if (has(origDescriptor, 'value')) {
  10218. throw new $TypeError('`' + prop + '` is a nonconfigurable data property, and can not be changed to an accessor');
  10219. }
  10220. var isChangingGetter = has(options, 'get') && has(origDescriptor, 'get') && options.get !== origDescriptor.get;
  10221. var isChangingSetter = has(options, 'set') && has(origDescriptor, 'set') && options.set !== origDescriptor.set;
  10222. if (isChangingGetter || isChangingSetter) {
  10223. throw new $TypeError('`' + prop + '` is nonconfigurable, and can not be changed');
  10224. }
  10225. return function restore() {};
  10226. }
  10227. if (has(origDescriptor, 'get') || has(origDescriptor, 'set')) {
  10228. throw new $TypeError('`' + prop + '` is a nonconfigurable accessor property, and can not be changed to a data property');
  10229. }
  10230. var isChangingValue = has(options, 'value') && has(origDescriptor, 'value') && options.value !== origDescriptor.value;
  10231. var isChangingWriteability = has(options, 'nonWritable') && !options.nonWritable !== origDescriptor.writable;
  10232. if ((!origDescriptor.writable && isChangingValue) || isChangingEnumerability || isChangingWriteability) {
  10233. throw new $TypeError('`' + prop + '` is nonconfigurable, and can not be changed');
  10234. }
  10235. if (!isChangingWriteability && !isChangingValue) {
  10236. return function restore() {};
  10237. }
  10238. }
  10239. if (options['delete']) {
  10240. delete obj[prop]; // eslint-disable-line no-param-reassign
  10241. } else if (
  10242. wantsData
  10243. && !isChangingEnumerability
  10244. && (!origDescriptor || origDescriptor.enumerable)
  10245. && (!has(options, 'nonWritable') || !options.nonWritable)
  10246. && (!origDescriptor || origDescriptor.writable)
  10247. && (!gOPD || !(prop in obj))
  10248. ) {
  10249. obj[prop] = options.value; // eslint-disable-line no-param-reassign
  10250. } else {
  10251. if (objIsArray && prop === 'length' && hasArrayLengthDefineBug) {
  10252. throw new $SyntaxError('this environment does not support Define on an array’s length');
  10253. }
  10254. var newEnumerable = has(options, 'nonEnumerable') ? !options.nonEnumerable : origEnumerable;
  10255. if (wantsData) {
  10256. $defineProperty(obj, prop, {
  10257. configurable: origConfigurable,
  10258. enumerable: newEnumerable,
  10259. value: has(options, 'value') ? options.value : origDescriptor.value,
  10260. writable: has(options, 'nonWritable') ? !options.nonWritable : has(origDescriptor, 'writable') ? origDescriptor.writable : true
  10261. });
  10262. } else if (wantsAccessor) {
  10263. var getter = has(options, 'get') ? options.get : origDescriptor && origDescriptor.get;
  10264. var setter = has(options, 'set') ? options.set : origDescriptor && origDescriptor.set;
  10265. $defineProperty(obj, prop, {
  10266. configurable: origConfigurable,
  10267. enumerable: newEnumerable,
  10268. get: getter,
  10269. set: setter
  10270. });
  10271. } else {
  10272. $defineProperty(obj, prop, {
  10273. configurable: origConfigurable,
  10274. enumerable: newEnumerable
  10275. });
  10276. }
  10277. }
  10278. return function restore() {
  10279. if (!origDescriptor) {
  10280. delete obj[prop]; // eslint-disable-line no-param-reassign
  10281. } else if ($defineProperty) {
  10282. if (has(origDescriptor, 'writable')) {
  10283. $defineProperty(obj, prop, {
  10284. configurable: origDescriptor.configurable,
  10285. enumerable: origDescriptor.enumerable,
  10286. value: origDescriptor.value,
  10287. writable: origDescriptor.writable
  10288. });
  10289. } else {
  10290. var oldGetter = origDescriptor && origDescriptor.get;
  10291. var oldSetter = origDescriptor && origDescriptor.set;
  10292. $defineProperty(obj, prop, {
  10293. configurable: origDescriptor.configurable,
  10294. enumerable: origDescriptor.enumerable,
  10295. get: oldGetter,
  10296. set: oldSetter
  10297. });
  10298. }
  10299. } else {
  10300. obj[prop] = origDescriptor.value; // eslint-disable-line no-param-reassign
  10301. }
  10302. };
  10303. };
  10304. },{"functions-have-names":38,"has":45,"has-property-descriptors":41,"isarray":64}],64:[function(require,module,exports){
  10305. arguments[4][15][0].apply(exports,arguments)
  10306. },{"dup":15}],65:[function(require,module,exports){
  10307. var hasMap = typeof Map === 'function' && Map.prototype;
  10308. var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
  10309. var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
  10310. var mapForEach = hasMap && Map.prototype.forEach;
  10311. var hasSet = typeof Set === 'function' && Set.prototype;
  10312. var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
  10313. var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
  10314. var setForEach = hasSet && Set.prototype.forEach;
  10315. var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
  10316. var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
  10317. var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
  10318. var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
  10319. var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
  10320. var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
  10321. var booleanValueOf = Boolean.prototype.valueOf;
  10322. var objectToString = Object.prototype.toString;
  10323. var functionToString = Function.prototype.toString;
  10324. var $match = String.prototype.match;
  10325. var $slice = String.prototype.slice;
  10326. var $replace = String.prototype.replace;
  10327. var $toUpperCase = String.prototype.toUpperCase;
  10328. var $toLowerCase = String.prototype.toLowerCase;
  10329. var $test = RegExp.prototype.test;
  10330. var $concat = Array.prototype.concat;
  10331. var $join = Array.prototype.join;
  10332. var $arrSlice = Array.prototype.slice;
  10333. var $floor = Math.floor;
  10334. var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
  10335. var gOPS = Object.getOwnPropertySymbols;
  10336. var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
  10337. var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
  10338. // ie, `has-tostringtag/shams
  10339. var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol')
  10340. ? Symbol.toStringTag
  10341. : null;
  10342. var isEnumerable = Object.prototype.propertyIsEnumerable;
  10343. var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || (
  10344. [].__proto__ === Array.prototype // eslint-disable-line no-proto
  10345. ? function (O) {
  10346. return O.__proto__; // eslint-disable-line no-proto
  10347. }
  10348. : null
  10349. );
  10350. function addNumericSeparator(num, str) {
  10351. if (
  10352. num === Infinity
  10353. || num === -Infinity
  10354. || num !== num
  10355. || (num && num > -1000 && num < 1000)
  10356. || $test.call(/e/, str)
  10357. ) {
  10358. return str;
  10359. }
  10360. var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
  10361. if (typeof num === 'number') {
  10362. var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num)
  10363. if (int !== num) {
  10364. var intStr = String(int);
  10365. var dec = $slice.call(str, intStr.length + 1);
  10366. return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
  10367. }
  10368. }
  10369. return $replace.call(str, sepRegex, '$&_');
  10370. }
  10371. var inspectCustom = require('./util.inspect').custom;
  10372. var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
  10373. module.exports = function inspect_(obj, options, depth, seen) {
  10374. var opts = options || {};
  10375. if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
  10376. throw new TypeError('option "quoteStyle" must be "single" or "double"');
  10377. }
  10378. if (
  10379. has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number'
  10380. ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
  10381. : opts.maxStringLength !== null
  10382. )
  10383. ) {
  10384. throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
  10385. }
  10386. var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
  10387. if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
  10388. throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
  10389. }
  10390. if (
  10391. has(opts, 'indent')
  10392. && opts.indent !== null
  10393. && opts.indent !== '\t'
  10394. && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
  10395. ) {
  10396. throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
  10397. }
  10398. if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
  10399. throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
  10400. }
  10401. var numericSeparator = opts.numericSeparator;
  10402. if (typeof obj === 'undefined') {
  10403. return 'undefined';
  10404. }
  10405. if (obj === null) {
  10406. return 'null';
  10407. }
  10408. if (typeof obj === 'boolean') {
  10409. return obj ? 'true' : 'false';
  10410. }
  10411. if (typeof obj === 'string') {
  10412. return inspectString(obj, opts);
  10413. }
  10414. if (typeof obj === 'number') {
  10415. if (obj === 0) {
  10416. return Infinity / obj > 0 ? '0' : '-0';
  10417. }
  10418. var str = String(obj);
  10419. return numericSeparator ? addNumericSeparator(obj, str) : str;
  10420. }
  10421. if (typeof obj === 'bigint') {
  10422. var bigIntStr = String(obj) + 'n';
  10423. return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
  10424. }
  10425. var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
  10426. if (typeof depth === 'undefined') { depth = 0; }
  10427. if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
  10428. return isArray(obj) ? '[Array]' : '[Object]';
  10429. }
  10430. var indent = getIndent(opts, depth);
  10431. if (typeof seen === 'undefined') {
  10432. seen = [];
  10433. } else if (indexOf(seen, obj) >= 0) {
  10434. return '[Circular]';
  10435. }
  10436. function inspect(value, from, noIndent) {
  10437. if (from) {
  10438. seen = $arrSlice.call(seen);
  10439. seen.push(from);
  10440. }
  10441. if (noIndent) {
  10442. var newOpts = {
  10443. depth: opts.depth
  10444. };
  10445. if (has(opts, 'quoteStyle')) {
  10446. newOpts.quoteStyle = opts.quoteStyle;
  10447. }
  10448. return inspect_(value, newOpts, depth + 1, seen);
  10449. }
  10450. return inspect_(value, opts, depth + 1, seen);
  10451. }
  10452. if (typeof obj === 'function') {
  10453. var name = nameOf(obj);
  10454. var keys = arrObjKeys(obj, inspect);
  10455. return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
  10456. }
  10457. if (isSymbol(obj)) {
  10458. var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
  10459. return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
  10460. }
  10461. if (isElement(obj)) {
  10462. var s = '<' + $toLowerCase.call(String(obj.nodeName));
  10463. var attrs = obj.attributes || [];
  10464. for (var i = 0; i < attrs.length; i++) {
  10465. s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
  10466. }
  10467. s += '>';
  10468. if (obj.childNodes && obj.childNodes.length) { s += '...'; }
  10469. s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
  10470. return s;
  10471. }
  10472. if (isArray(obj)) {
  10473. if (obj.length === 0) { return '[]'; }
  10474. var xs = arrObjKeys(obj, inspect);
  10475. if (indent && !singleLineValues(xs)) {
  10476. return '[' + indentedJoin(xs, indent) + ']';
  10477. }
  10478. return '[ ' + $join.call(xs, ', ') + ' ]';
  10479. }
  10480. if (isError(obj)) {
  10481. var parts = arrObjKeys(obj, inspect);
  10482. if ('cause' in obj && !isEnumerable.call(obj, 'cause')) {
  10483. return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
  10484. }
  10485. if (parts.length === 0) { return '[' + String(obj) + ']'; }
  10486. return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
  10487. }
  10488. if (typeof obj === 'object' && customInspect) {
  10489. if (inspectSymbol && typeof obj[inspectSymbol] === 'function') {
  10490. return obj[inspectSymbol]();
  10491. } else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
  10492. return obj.inspect();
  10493. }
  10494. }
  10495. if (isMap(obj)) {
  10496. var mapParts = [];
  10497. mapForEach.call(obj, function (value, key) {
  10498. mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
  10499. });
  10500. return collectionOf('Map', mapSize.call(obj), mapParts, indent);
  10501. }
  10502. if (isSet(obj)) {
  10503. var setParts = [];
  10504. setForEach.call(obj, function (value) {
  10505. setParts.push(inspect(value, obj));
  10506. });
  10507. return collectionOf('Set', setSize.call(obj), setParts, indent);
  10508. }
  10509. if (isWeakMap(obj)) {
  10510. return weakCollectionOf('WeakMap');
  10511. }
  10512. if (isWeakSet(obj)) {
  10513. return weakCollectionOf('WeakSet');
  10514. }
  10515. if (isWeakRef(obj)) {
  10516. return weakCollectionOf('WeakRef');
  10517. }
  10518. if (isNumber(obj)) {
  10519. return markBoxed(inspect(Number(obj)));
  10520. }
  10521. if (isBigInt(obj)) {
  10522. return markBoxed(inspect(bigIntValueOf.call(obj)));
  10523. }
  10524. if (isBoolean(obj)) {
  10525. return markBoxed(booleanValueOf.call(obj));
  10526. }
  10527. if (isString(obj)) {
  10528. return markBoxed(inspect(String(obj)));
  10529. }
  10530. if (!isDate(obj) && !isRegExp(obj)) {
  10531. var ys = arrObjKeys(obj, inspect);
  10532. var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
  10533. var protoTag = obj instanceof Object ? '' : 'null prototype';
  10534. var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
  10535. var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
  10536. var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
  10537. if (ys.length === 0) { return tag + '{}'; }
  10538. if (indent) {
  10539. return tag + '{' + indentedJoin(ys, indent) + '}';
  10540. }
  10541. return tag + '{ ' + $join.call(ys, ', ') + ' }';
  10542. }
  10543. return String(obj);
  10544. };
  10545. function wrapQuotes(s, defaultStyle, opts) {
  10546. var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
  10547. return quoteChar + s + quoteChar;
  10548. }
  10549. function quote(s) {
  10550. return $replace.call(String(s), /"/g, '&quot;');
  10551. }
  10552. function isArray(obj) { return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
  10553. function isDate(obj) { return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
  10554. function isRegExp(obj) { return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
  10555. function isError(obj) { return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
  10556. function isString(obj) { return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
  10557. function isNumber(obj) { return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
  10558. function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
  10559. // Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
  10560. function isSymbol(obj) {
  10561. if (hasShammedSymbols) {
  10562. return obj && typeof obj === 'object' && obj instanceof Symbol;
  10563. }
  10564. if (typeof obj === 'symbol') {
  10565. return true;
  10566. }
  10567. if (!obj || typeof obj !== 'object' || !symToString) {
  10568. return false;
  10569. }
  10570. try {
  10571. symToString.call(obj);
  10572. return true;
  10573. } catch (e) {}
  10574. return false;
  10575. }
  10576. function isBigInt(obj) {
  10577. if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
  10578. return false;
  10579. }
  10580. try {
  10581. bigIntValueOf.call(obj);
  10582. return true;
  10583. } catch (e) {}
  10584. return false;
  10585. }
  10586. var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
  10587. function has(obj, key) {
  10588. return hasOwn.call(obj, key);
  10589. }
  10590. function toStr(obj) {
  10591. return objectToString.call(obj);
  10592. }
  10593. function nameOf(f) {
  10594. if (f.name) { return f.name; }
  10595. var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
  10596. if (m) { return m[1]; }
  10597. return null;
  10598. }
  10599. function indexOf(xs, x) {
  10600. if (xs.indexOf) { return xs.indexOf(x); }
  10601. for (var i = 0, l = xs.length; i < l; i++) {
  10602. if (xs[i] === x) { return i; }
  10603. }
  10604. return -1;
  10605. }
  10606. function isMap(x) {
  10607. if (!mapSize || !x || typeof x !== 'object') {
  10608. return false;
  10609. }
  10610. try {
  10611. mapSize.call(x);
  10612. try {
  10613. setSize.call(x);
  10614. } catch (s) {
  10615. return true;
  10616. }
  10617. return x instanceof Map; // core-js workaround, pre-v2.5.0
  10618. } catch (e) {}
  10619. return false;
  10620. }
  10621. function isWeakMap(x) {
  10622. if (!weakMapHas || !x || typeof x !== 'object') {
  10623. return false;
  10624. }
  10625. try {
  10626. weakMapHas.call(x, weakMapHas);
  10627. try {
  10628. weakSetHas.call(x, weakSetHas);
  10629. } catch (s) {
  10630. return true;
  10631. }
  10632. return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
  10633. } catch (e) {}
  10634. return false;
  10635. }
  10636. function isWeakRef(x) {
  10637. if (!weakRefDeref || !x || typeof x !== 'object') {
  10638. return false;
  10639. }
  10640. try {
  10641. weakRefDeref.call(x);
  10642. return true;
  10643. } catch (e) {}
  10644. return false;
  10645. }
  10646. function isSet(x) {
  10647. if (!setSize || !x || typeof x !== 'object') {
  10648. return false;
  10649. }
  10650. try {
  10651. setSize.call(x);
  10652. try {
  10653. mapSize.call(x);
  10654. } catch (m) {
  10655. return true;
  10656. }
  10657. return x instanceof Set; // core-js workaround, pre-v2.5.0
  10658. } catch (e) {}
  10659. return false;
  10660. }
  10661. function isWeakSet(x) {
  10662. if (!weakSetHas || !x || typeof x !== 'object') {
  10663. return false;
  10664. }
  10665. try {
  10666. weakSetHas.call(x, weakSetHas);
  10667. try {
  10668. weakMapHas.call(x, weakMapHas);
  10669. } catch (s) {
  10670. return true;
  10671. }
  10672. return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
  10673. } catch (e) {}
  10674. return false;
  10675. }
  10676. function isElement(x) {
  10677. if (!x || typeof x !== 'object') { return false; }
  10678. if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
  10679. return true;
  10680. }
  10681. return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
  10682. }
  10683. function inspectString(str, opts) {
  10684. if (str.length > opts.maxStringLength) {
  10685. var remaining = str.length - opts.maxStringLength;
  10686. var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
  10687. return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
  10688. }
  10689. // eslint-disable-next-line no-control-regex
  10690. var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
  10691. return wrapQuotes(s, 'single', opts);
  10692. }
  10693. function lowbyte(c) {
  10694. var n = c.charCodeAt(0);
  10695. var x = {
  10696. 8: 'b',
  10697. 9: 't',
  10698. 10: 'n',
  10699. 12: 'f',
  10700. 13: 'r'
  10701. }[n];
  10702. if (x) { return '\\' + x; }
  10703. return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
  10704. }
  10705. function markBoxed(str) {
  10706. return 'Object(' + str + ')';
  10707. }
  10708. function weakCollectionOf(type) {
  10709. return type + ' { ? }';
  10710. }
  10711. function collectionOf(type, size, entries, indent) {
  10712. var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
  10713. return type + ' (' + size + ') {' + joinedEntries + '}';
  10714. }
  10715. function singleLineValues(xs) {
  10716. for (var i = 0; i < xs.length; i++) {
  10717. if (indexOf(xs[i], '\n') >= 0) {
  10718. return false;
  10719. }
  10720. }
  10721. return true;
  10722. }
  10723. function getIndent(opts, depth) {
  10724. var baseIndent;
  10725. if (opts.indent === '\t') {
  10726. baseIndent = '\t';
  10727. } else if (typeof opts.indent === 'number' && opts.indent > 0) {
  10728. baseIndent = $join.call(Array(opts.indent + 1), ' ');
  10729. } else {
  10730. return null;
  10731. }
  10732. return {
  10733. base: baseIndent,
  10734. prev: $join.call(Array(depth + 1), baseIndent)
  10735. };
  10736. }
  10737. function indentedJoin(xs, indent) {
  10738. if (xs.length === 0) { return ''; }
  10739. var lineJoiner = '\n' + indent.prev + indent.base;
  10740. return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
  10741. }
  10742. function arrObjKeys(obj, inspect) {
  10743. var isArr = isArray(obj);
  10744. var xs = [];
  10745. if (isArr) {
  10746. xs.length = obj.length;
  10747. for (var i = 0; i < obj.length; i++) {
  10748. xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
  10749. }
  10750. }
  10751. var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
  10752. var symMap;
  10753. if (hasShammedSymbols) {
  10754. symMap = {};
  10755. for (var k = 0; k < syms.length; k++) {
  10756. symMap['$' + syms[k]] = syms[k];
  10757. }
  10758. }
  10759. for (var key in obj) { // eslint-disable-line no-restricted-syntax
  10760. if (!has(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
  10761. if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
  10762. if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
  10763. // this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
  10764. continue; // eslint-disable-line no-restricted-syntax, no-continue
  10765. } else if ($test.call(/[^\w$]/, key)) {
  10766. xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
  10767. } else {
  10768. xs.push(key + ': ' + inspect(obj[key], obj));
  10769. }
  10770. }
  10771. if (typeof gOPS === 'function') {
  10772. for (var j = 0; j < syms.length; j++) {
  10773. if (isEnumerable.call(obj, syms[j])) {
  10774. xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
  10775. }
  10776. }
  10777. }
  10778. return xs;
  10779. }
  10780. },{"./util.inspect":9}],66:[function(require,module,exports){
  10781. 'use strict';
  10782. var numberIsNaN = function (value) {
  10783. return value !== value;
  10784. };
  10785. module.exports = function is(a, b) {
  10786. if (a === 0 && b === 0) {
  10787. return 1 / a === 1 / b;
  10788. }
  10789. if (a === b) {
  10790. return true;
  10791. }
  10792. if (numberIsNaN(a) && numberIsNaN(b)) {
  10793. return true;
  10794. }
  10795. return false;
  10796. };
  10797. },{}],67:[function(require,module,exports){
  10798. 'use strict';
  10799. var define = require('define-properties');
  10800. var callBind = require('call-bind');
  10801. var implementation = require('./implementation');
  10802. var getPolyfill = require('./polyfill');
  10803. var shim = require('./shim');
  10804. var polyfill = callBind(getPolyfill(), Object);
  10805. define(polyfill, {
  10806. getPolyfill: getPolyfill,
  10807. implementation: implementation,
  10808. shim: shim
  10809. });
  10810. module.exports = polyfill;
  10811. },{"./implementation":66,"./polyfill":68,"./shim":69,"call-bind":12,"define-properties":16}],68:[function(require,module,exports){
  10812. 'use strict';
  10813. var implementation = require('./implementation');
  10814. module.exports = function getPolyfill() {
  10815. return typeof Object.is === 'function' ? Object.is : implementation;
  10816. };
  10817. },{"./implementation":66}],69:[function(require,module,exports){
  10818. 'use strict';
  10819. var getPolyfill = require('./polyfill');
  10820. var define = require('define-properties');
  10821. module.exports = function shimObjectIs() {
  10822. var polyfill = getPolyfill();
  10823. define(Object, { is: polyfill }, {
  10824. is: function testObjectIs() {
  10825. return Object.is !== polyfill;
  10826. }
  10827. });
  10828. return polyfill;
  10829. };
  10830. },{"./polyfill":68,"define-properties":16}],70:[function(require,module,exports){
  10831. 'use strict';
  10832. var keysShim;
  10833. if (!Object.keys) {
  10834. // modified from https://github.com/es-shims/es5-shim
  10835. var has = Object.prototype.hasOwnProperty;
  10836. var toStr = Object.prototype.toString;
  10837. var isArgs = require('./isArguments'); // eslint-disable-line global-require
  10838. var isEnumerable = Object.prototype.propertyIsEnumerable;
  10839. var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
  10840. var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
  10841. var dontEnums = [
  10842. 'toString',
  10843. 'toLocaleString',
  10844. 'valueOf',
  10845. 'hasOwnProperty',
  10846. 'isPrototypeOf',
  10847. 'propertyIsEnumerable',
  10848. 'constructor'
  10849. ];
  10850. var equalsConstructorPrototype = function (o) {
  10851. var ctor = o.constructor;
  10852. return ctor && ctor.prototype === o;
  10853. };
  10854. var excludedKeys = {
  10855. $applicationCache: true,
  10856. $console: true,
  10857. $external: true,
  10858. $frame: true,
  10859. $frameElement: true,
  10860. $frames: true,
  10861. $innerHeight: true,
  10862. $innerWidth: true,
  10863. $onmozfullscreenchange: true,
  10864. $onmozfullscreenerror: true,
  10865. $outerHeight: true,
  10866. $outerWidth: true,
  10867. $pageXOffset: true,
  10868. $pageYOffset: true,
  10869. $parent: true,
  10870. $scrollLeft: true,
  10871. $scrollTop: true,
  10872. $scrollX: true,
  10873. $scrollY: true,
  10874. $self: true,
  10875. $webkitIndexedDB: true,
  10876. $webkitStorageInfo: true,
  10877. $window: true
  10878. };
  10879. var hasAutomationEqualityBug = (function () {
  10880. /* global window */
  10881. if (typeof window === 'undefined') { return false; }
  10882. for (var k in window) {
  10883. try {
  10884. if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  10885. try {
  10886. equalsConstructorPrototype(window[k]);
  10887. } catch (e) {
  10888. return true;
  10889. }
  10890. }
  10891. } catch (e) {
  10892. return true;
  10893. }
  10894. }
  10895. return false;
  10896. }());
  10897. var equalsConstructorPrototypeIfNotBuggy = function (o) {
  10898. /* global window */
  10899. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  10900. return equalsConstructorPrototype(o);
  10901. }
  10902. try {
  10903. return equalsConstructorPrototype(o);
  10904. } catch (e) {
  10905. return false;
  10906. }
  10907. };
  10908. keysShim = function keys(object) {
  10909. var isObject = object !== null && typeof object === 'object';
  10910. var isFunction = toStr.call(object) === '[object Function]';
  10911. var isArguments = isArgs(object);
  10912. var isString = isObject && toStr.call(object) === '[object String]';
  10913. var theKeys = [];
  10914. if (!isObject && !isFunction && !isArguments) {
  10915. throw new TypeError('Object.keys called on a non-object');
  10916. }
  10917. var skipProto = hasProtoEnumBug && isFunction;
  10918. if (isString && object.length > 0 && !has.call(object, 0)) {
  10919. for (var i = 0; i < object.length; ++i) {
  10920. theKeys.push(String(i));
  10921. }
  10922. }
  10923. if (isArguments && object.length > 0) {
  10924. for (var j = 0; j < object.length; ++j) {
  10925. theKeys.push(String(j));
  10926. }
  10927. } else {
  10928. for (var name in object) {
  10929. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  10930. theKeys.push(String(name));
  10931. }
  10932. }
  10933. }
  10934. if (hasDontEnumBug) {
  10935. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  10936. for (var k = 0; k < dontEnums.length; ++k) {
  10937. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  10938. theKeys.push(dontEnums[k]);
  10939. }
  10940. }
  10941. }
  10942. return theKeys;
  10943. };
  10944. }
  10945. module.exports = keysShim;
  10946. },{"./isArguments":72}],71:[function(require,module,exports){
  10947. 'use strict';
  10948. var slice = Array.prototype.slice;
  10949. var isArgs = require('./isArguments');
  10950. var origKeys = Object.keys;
  10951. var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation');
  10952. var originalKeys = Object.keys;
  10953. keysShim.shim = function shimObjectKeys() {
  10954. if (Object.keys) {
  10955. var keysWorksWithArguments = (function () {
  10956. // Safari 5.0 bug
  10957. var args = Object.keys(arguments);
  10958. return args && args.length === arguments.length;
  10959. }(1, 2));
  10960. if (!keysWorksWithArguments) {
  10961. Object.keys = function keys(object) { // eslint-disable-line func-name-matching
  10962. if (isArgs(object)) {
  10963. return originalKeys(slice.call(object));
  10964. }
  10965. return originalKeys(object);
  10966. };
  10967. }
  10968. } else {
  10969. Object.keys = keysShim;
  10970. }
  10971. return Object.keys || keysShim;
  10972. };
  10973. module.exports = keysShim;
  10974. },{"./implementation":70,"./isArguments":72}],72:[function(require,module,exports){
  10975. 'use strict';
  10976. var toStr = Object.prototype.toString;
  10977. module.exports = function isArguments(value) {
  10978. var str = toStr.call(value);
  10979. var isArgs = str === '[object Arguments]';
  10980. if (!isArgs) {
  10981. isArgs = str !== '[object Array]' &&
  10982. value !== null &&
  10983. typeof value === 'object' &&
  10984. typeof value.length === 'number' &&
  10985. value.length >= 0 &&
  10986. toStr.call(value.callee) === '[object Function]';
  10987. }
  10988. return isArgs;
  10989. };
  10990. },{}],73:[function(require,module,exports){
  10991. 'use strict';
  10992. // modified from https://github.com/es-shims/es6-shim
  10993. var keys = require('object-keys');
  10994. var canBeObject = function (obj) {
  10995. return typeof obj !== 'undefined' && obj !== null;
  10996. };
  10997. var hasSymbols = require('has-symbols/shams')();
  10998. var callBound = require('call-bind/callBound');
  10999. var toObject = Object;
  11000. var $push = callBound('Array.prototype.push');
  11001. var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable');
  11002. var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
  11003. // eslint-disable-next-line no-unused-vars
  11004. module.exports = function assign(target, source1) {
  11005. if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
  11006. var objTarget = toObject(target);
  11007. var s, source, i, props, syms, value, key;
  11008. for (s = 1; s < arguments.length; ++s) {
  11009. source = toObject(arguments[s]);
  11010. props = keys(source);
  11011. var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
  11012. if (getSymbols) {
  11013. syms = getSymbols(source);
  11014. for (i = 0; i < syms.length; ++i) {
  11015. key = syms[i];
  11016. if ($propIsEnumerable(source, key)) {
  11017. $push(props, key);
  11018. }
  11019. }
  11020. }
  11021. for (i = 0; i < props.length; ++i) {
  11022. key = props[i];
  11023. value = source[key];
  11024. if ($propIsEnumerable(source, key)) {
  11025. objTarget[key] = value;
  11026. }
  11027. }
  11028. }
  11029. return objTarget;
  11030. };
  11031. },{"call-bind/callBound":11,"has-symbols/shams":43,"object-keys":71}],74:[function(require,module,exports){
  11032. arguments[4][2][0].apply(exports,arguments)
  11033. },{"./implementation":73,"./polyfill":75,"./shim":76,"call-bind":12,"define-properties":16,"dup":2}],75:[function(require,module,exports){
  11034. 'use strict';
  11035. var implementation = require('./implementation');
  11036. var lacksProperEnumerationOrder = function () {
  11037. if (!Object.assign) {
  11038. return false;
  11039. }
  11040. /*
  11041. * v8, specifically in node 4.x, has a bug with incorrect property enumeration order
  11042. * note: this does not detect the bug unless there's 20 characters
  11043. */
  11044. var str = 'abcdefghijklmnopqrst';
  11045. var letters = str.split('');
  11046. var map = {};
  11047. for (var i = 0; i < letters.length; ++i) {
  11048. map[letters[i]] = letters[i];
  11049. }
  11050. var obj = Object.assign({}, map);
  11051. var actual = '';
  11052. for (var k in obj) {
  11053. actual += k;
  11054. }
  11055. return str !== actual;
  11056. };
  11057. var assignHasPendingExceptions = function () {
  11058. if (!Object.assign || !Object.preventExtensions) {
  11059. return false;
  11060. }
  11061. /*
  11062. * Firefox 37 still has "pending exception" logic in its Object.assign implementation,
  11063. * which is 72% slower than our shim, and Firefox 40's native implementation.
  11064. */
  11065. var thrower = Object.preventExtensions({ 1: 2 });
  11066. try {
  11067. Object.assign(thrower, 'xy');
  11068. } catch (e) {
  11069. return thrower[1] === 'y';
  11070. }
  11071. return false;
  11072. };
  11073. module.exports = function getPolyfill() {
  11074. if (!Object.assign) {
  11075. return implementation;
  11076. }
  11077. if (lacksProperEnumerationOrder()) {
  11078. return implementation;
  11079. }
  11080. if (assignHasPendingExceptions()) {
  11081. return implementation;
  11082. }
  11083. return Object.assign;
  11084. };
  11085. },{"./implementation":73}],76:[function(require,module,exports){
  11086. 'use strict';
  11087. var define = require('define-properties');
  11088. var getPolyfill = require('./polyfill');
  11089. module.exports = function shimAssign() {
  11090. var polyfill = getPolyfill();
  11091. define(
  11092. Object,
  11093. { assign: polyfill },
  11094. { assign: function () { return Object.assign !== polyfill; } }
  11095. );
  11096. return polyfill;
  11097. };
  11098. },{"./polyfill":75,"define-properties":16}],77:[function(require,module,exports){
  11099. (function (process){(function (){
  11100. // .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
  11101. // backported and transplited with Babel, with backwards-compat fixes
  11102. // Copyright Joyent, Inc. and other Node contributors.
  11103. //
  11104. // Permission is hereby granted, free of charge, to any person obtaining a
  11105. // copy of this software and associated documentation files (the
  11106. // "Software"), to deal in the Software without restriction, including
  11107. // without limitation the rights to use, copy, modify, merge, publish,
  11108. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11109. // persons to whom the Software is furnished to do so, subject to the
  11110. // following conditions:
  11111. //
  11112. // The above copyright notice and this permission notice shall be included
  11113. // in all copies or substantial portions of the Software.
  11114. //
  11115. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11116. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11117. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11118. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11119. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11120. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11121. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11122. // resolves . and .. elements in a path array with directory names there
  11123. // must be no slashes, empty elements, or device names (c:\) in the array
  11124. // (so also no leading and trailing slashes - it does not distinguish
  11125. // relative and absolute paths)
  11126. function normalizeArray(parts, allowAboveRoot) {
  11127. // if the path tries to go above the root, `up` ends up > 0
  11128. var up = 0;
  11129. for (var i = parts.length - 1; i >= 0; i--) {
  11130. var last = parts[i];
  11131. if (last === '.') {
  11132. parts.splice(i, 1);
  11133. } else if (last === '..') {
  11134. parts.splice(i, 1);
  11135. up++;
  11136. } else if (up) {
  11137. parts.splice(i, 1);
  11138. up--;
  11139. }
  11140. }
  11141. // if the path is allowed to go above the root, restore leading ..s
  11142. if (allowAboveRoot) {
  11143. for (; up--; up) {
  11144. parts.unshift('..');
  11145. }
  11146. }
  11147. return parts;
  11148. }
  11149. // path.resolve([from ...], to)
  11150. // posix version
  11151. exports.resolve = function() {
  11152. var resolvedPath = '',
  11153. resolvedAbsolute = false;
  11154. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  11155. var path = (i >= 0) ? arguments[i] : process.cwd();
  11156. // Skip empty and invalid entries
  11157. if (typeof path !== 'string') {
  11158. throw new TypeError('Arguments to path.resolve must be strings');
  11159. } else if (!path) {
  11160. continue;
  11161. }
  11162. resolvedPath = path + '/' + resolvedPath;
  11163. resolvedAbsolute = path.charAt(0) === '/';
  11164. }
  11165. // At this point the path should be resolved to a full absolute path, but
  11166. // handle relative paths to be safe (might happen when process.cwd() fails)
  11167. // Normalize the path
  11168. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  11169. return !!p;
  11170. }), !resolvedAbsolute).join('/');
  11171. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  11172. };
  11173. // path.normalize(path)
  11174. // posix version
  11175. exports.normalize = function(path) {
  11176. var isAbsolute = exports.isAbsolute(path),
  11177. trailingSlash = substr(path, -1) === '/';
  11178. // Normalize the path
  11179. path = normalizeArray(filter(path.split('/'), function(p) {
  11180. return !!p;
  11181. }), !isAbsolute).join('/');
  11182. if (!path && !isAbsolute) {
  11183. path = '.';
  11184. }
  11185. if (path && trailingSlash) {
  11186. path += '/';
  11187. }
  11188. return (isAbsolute ? '/' : '') + path;
  11189. };
  11190. // posix version
  11191. exports.isAbsolute = function(path) {
  11192. return path.charAt(0) === '/';
  11193. };
  11194. // posix version
  11195. exports.join = function() {
  11196. var paths = Array.prototype.slice.call(arguments, 0);
  11197. return exports.normalize(filter(paths, function(p, index) {
  11198. if (typeof p !== 'string') {
  11199. throw new TypeError('Arguments to path.join must be strings');
  11200. }
  11201. return p;
  11202. }).join('/'));
  11203. };
  11204. // path.relative(from, to)
  11205. // posix version
  11206. exports.relative = function(from, to) {
  11207. from = exports.resolve(from).substr(1);
  11208. to = exports.resolve(to).substr(1);
  11209. function trim(arr) {
  11210. var start = 0;
  11211. for (; start < arr.length; start++) {
  11212. if (arr[start] !== '') break;
  11213. }
  11214. var end = arr.length - 1;
  11215. for (; end >= 0; end--) {
  11216. if (arr[end] !== '') break;
  11217. }
  11218. if (start > end) return [];
  11219. return arr.slice(start, end - start + 1);
  11220. }
  11221. var fromParts = trim(from.split('/'));
  11222. var toParts = trim(to.split('/'));
  11223. var length = Math.min(fromParts.length, toParts.length);
  11224. var samePartsLength = length;
  11225. for (var i = 0; i < length; i++) {
  11226. if (fromParts[i] !== toParts[i]) {
  11227. samePartsLength = i;
  11228. break;
  11229. }
  11230. }
  11231. var outputParts = [];
  11232. for (var i = samePartsLength; i < fromParts.length; i++) {
  11233. outputParts.push('..');
  11234. }
  11235. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  11236. return outputParts.join('/');
  11237. };
  11238. exports.sep = '/';
  11239. exports.delimiter = ':';
  11240. exports.dirname = function (path) {
  11241. if (typeof path !== 'string') path = path + '';
  11242. if (path.length === 0) return '.';
  11243. var code = path.charCodeAt(0);
  11244. var hasRoot = code === 47 /*/*/;
  11245. var end = -1;
  11246. var matchedSlash = true;
  11247. for (var i = path.length - 1; i >= 1; --i) {
  11248. code = path.charCodeAt(i);
  11249. if (code === 47 /*/*/) {
  11250. if (!matchedSlash) {
  11251. end = i;
  11252. break;
  11253. }
  11254. } else {
  11255. // We saw the first non-path separator
  11256. matchedSlash = false;
  11257. }
  11258. }
  11259. if (end === -1) return hasRoot ? '/' : '.';
  11260. if (hasRoot && end === 1) {
  11261. // return '//';
  11262. // Backwards-compat fix:
  11263. return '/';
  11264. }
  11265. return path.slice(0, end);
  11266. };
  11267. function basename(path) {
  11268. if (typeof path !== 'string') path = path + '';
  11269. var start = 0;
  11270. var end = -1;
  11271. var matchedSlash = true;
  11272. var i;
  11273. for (i = path.length - 1; i >= 0; --i) {
  11274. if (path.charCodeAt(i) === 47 /*/*/) {
  11275. // If we reached a path separator that was not part of a set of path
  11276. // separators at the end of the string, stop now
  11277. if (!matchedSlash) {
  11278. start = i + 1;
  11279. break;
  11280. }
  11281. } else if (end === -1) {
  11282. // We saw the first non-path separator, mark this as the end of our
  11283. // path component
  11284. matchedSlash = false;
  11285. end = i + 1;
  11286. }
  11287. }
  11288. if (end === -1) return '';
  11289. return path.slice(start, end);
  11290. }
  11291. // Uses a mixed approach for backwards-compatibility, as ext behavior changed
  11292. // in new Node.js versions, so only basename() above is backported here
  11293. exports.basename = function (path, ext) {
  11294. var f = basename(path);
  11295. if (ext && f.substr(-1 * ext.length) === ext) {
  11296. f = f.substr(0, f.length - ext.length);
  11297. }
  11298. return f;
  11299. };
  11300. exports.extname = function (path) {
  11301. if (typeof path !== 'string') path = path + '';
  11302. var startDot = -1;
  11303. var startPart = 0;
  11304. var end = -1;
  11305. var matchedSlash = true;
  11306. // Track the state of characters (if any) we see before our first dot and
  11307. // after any path separator we find
  11308. var preDotState = 0;
  11309. for (var i = path.length - 1; i >= 0; --i) {
  11310. var code = path.charCodeAt(i);
  11311. if (code === 47 /*/*/) {
  11312. // If we reached a path separator that was not part of a set of path
  11313. // separators at the end of the string, stop now
  11314. if (!matchedSlash) {
  11315. startPart = i + 1;
  11316. break;
  11317. }
  11318. continue;
  11319. }
  11320. if (end === -1) {
  11321. // We saw the first non-path separator, mark this as the end of our
  11322. // extension
  11323. matchedSlash = false;
  11324. end = i + 1;
  11325. }
  11326. if (code === 46 /*.*/) {
  11327. // If this is our first dot, mark it as the start of our extension
  11328. if (startDot === -1)
  11329. startDot = i;
  11330. else if (preDotState !== 1)
  11331. preDotState = 1;
  11332. } else if (startDot !== -1) {
  11333. // We saw a non-dot and non-path separator before our dot, so we should
  11334. // have a good chance at having a non-empty extension
  11335. preDotState = -1;
  11336. }
  11337. }
  11338. if (startDot === -1 || end === -1 ||
  11339. // We saw a non-dot character immediately before the dot
  11340. preDotState === 0 ||
  11341. // The (right-most) trimmed path component is exactly '..'
  11342. preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
  11343. return '';
  11344. }
  11345. return path.slice(startDot, end);
  11346. };
  11347. function filter (xs, f) {
  11348. if (xs.filter) return xs.filter(f);
  11349. var res = [];
  11350. for (var i = 0; i < xs.length; i++) {
  11351. if (f(xs[i], i, xs)) res.push(xs[i]);
  11352. }
  11353. return res;
  11354. }
  11355. // String.prototype.substr - negative index don't work in IE8
  11356. var substr = 'ab'.substr(-1) === 'b'
  11357. ? function (str, start, len) { return str.substr(start, len) }
  11358. : function (str, start, len) {
  11359. if (start < 0) start = str.length + start;
  11360. return str.substr(start, len);
  11361. }
  11362. ;
  11363. }).call(this)}).call(this,require('_process'))
  11364. },{"_process":79}],78:[function(require,module,exports){
  11365. (function (process){(function (){
  11366. 'use strict';
  11367. if (typeof process === 'undefined' ||
  11368. !process.version ||
  11369. process.version.indexOf('v0.') === 0 ||
  11370. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  11371. module.exports = { nextTick: nextTick };
  11372. } else {
  11373. module.exports = process
  11374. }
  11375. function nextTick(fn, arg1, arg2, arg3) {
  11376. if (typeof fn !== 'function') {
  11377. throw new TypeError('"callback" argument must be a function');
  11378. }
  11379. var len = arguments.length;
  11380. var args, i;
  11381. switch (len) {
  11382. case 0:
  11383. case 1:
  11384. return process.nextTick(fn);
  11385. case 2:
  11386. return process.nextTick(function afterTickOne() {
  11387. fn.call(null, arg1);
  11388. });
  11389. case 3:
  11390. return process.nextTick(function afterTickTwo() {
  11391. fn.call(null, arg1, arg2);
  11392. });
  11393. case 4:
  11394. return process.nextTick(function afterTickThree() {
  11395. fn.call(null, arg1, arg2, arg3);
  11396. });
  11397. default:
  11398. args = new Array(len - 1);
  11399. i = 0;
  11400. while (i < args.length) {
  11401. args[i++] = arguments[i];
  11402. }
  11403. return process.nextTick(function afterTick() {
  11404. fn.apply(null, args);
  11405. });
  11406. }
  11407. }
  11408. }).call(this)}).call(this,require('_process'))
  11409. },{"_process":79}],79:[function(require,module,exports){
  11410. // shim for using process in browser
  11411. var process = module.exports = {};
  11412. // cached from whatever global is present so that test runners that stub it
  11413. // don't break things. But we need to wrap it in a try catch in case it is
  11414. // wrapped in strict mode code which doesn't define any globals. It's inside a
  11415. // function because try/catches deoptimize in certain engines.
  11416. var cachedSetTimeout;
  11417. var cachedClearTimeout;
  11418. function defaultSetTimout() {
  11419. throw new Error('setTimeout has not been defined');
  11420. }
  11421. function defaultClearTimeout () {
  11422. throw new Error('clearTimeout has not been defined');
  11423. }
  11424. (function () {
  11425. try {
  11426. if (typeof setTimeout === 'function') {
  11427. cachedSetTimeout = setTimeout;
  11428. } else {
  11429. cachedSetTimeout = defaultSetTimout;
  11430. }
  11431. } catch (e) {
  11432. cachedSetTimeout = defaultSetTimout;
  11433. }
  11434. try {
  11435. if (typeof clearTimeout === 'function') {
  11436. cachedClearTimeout = clearTimeout;
  11437. } else {
  11438. cachedClearTimeout = defaultClearTimeout;
  11439. }
  11440. } catch (e) {
  11441. cachedClearTimeout = defaultClearTimeout;
  11442. }
  11443. } ())
  11444. function runTimeout(fun) {
  11445. if (cachedSetTimeout === setTimeout) {
  11446. //normal enviroments in sane situations
  11447. return setTimeout(fun, 0);
  11448. }
  11449. // if setTimeout wasn't available but was latter defined
  11450. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  11451. cachedSetTimeout = setTimeout;
  11452. return setTimeout(fun, 0);
  11453. }
  11454. try {
  11455. // when when somebody has screwed with setTimeout but no I.E. maddness
  11456. return cachedSetTimeout(fun, 0);
  11457. } catch(e){
  11458. try {
  11459. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  11460. return cachedSetTimeout.call(null, fun, 0);
  11461. } catch(e){
  11462. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  11463. return cachedSetTimeout.call(this, fun, 0);
  11464. }
  11465. }
  11466. }
  11467. function runClearTimeout(marker) {
  11468. if (cachedClearTimeout === clearTimeout) {
  11469. //normal enviroments in sane situations
  11470. return clearTimeout(marker);
  11471. }
  11472. // if clearTimeout wasn't available but was latter defined
  11473. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  11474. cachedClearTimeout = clearTimeout;
  11475. return clearTimeout(marker);
  11476. }
  11477. try {
  11478. // when when somebody has screwed with setTimeout but no I.E. maddness
  11479. return cachedClearTimeout(marker);
  11480. } catch (e){
  11481. try {
  11482. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  11483. return cachedClearTimeout.call(null, marker);
  11484. } catch (e){
  11485. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  11486. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  11487. return cachedClearTimeout.call(this, marker);
  11488. }
  11489. }
  11490. }
  11491. var queue = [];
  11492. var draining = false;
  11493. var currentQueue;
  11494. var queueIndex = -1;
  11495. function cleanUpNextTick() {
  11496. if (!draining || !currentQueue) {
  11497. return;
  11498. }
  11499. draining = false;
  11500. if (currentQueue.length) {
  11501. queue = currentQueue.concat(queue);
  11502. } else {
  11503. queueIndex = -1;
  11504. }
  11505. if (queue.length) {
  11506. drainQueue();
  11507. }
  11508. }
  11509. function drainQueue() {
  11510. if (draining) {
  11511. return;
  11512. }
  11513. var timeout = runTimeout(cleanUpNextTick);
  11514. draining = true;
  11515. var len = queue.length;
  11516. while(len) {
  11517. currentQueue = queue;
  11518. queue = [];
  11519. while (++queueIndex < len) {
  11520. if (currentQueue) {
  11521. currentQueue[queueIndex].run();
  11522. }
  11523. }
  11524. queueIndex = -1;
  11525. len = queue.length;
  11526. }
  11527. currentQueue = null;
  11528. draining = false;
  11529. runClearTimeout(timeout);
  11530. }
  11531. process.nextTick = function (fun) {
  11532. var args = new Array(arguments.length - 1);
  11533. if (arguments.length > 1) {
  11534. for (var i = 1; i < arguments.length; i++) {
  11535. args[i - 1] = arguments[i];
  11536. }
  11537. }
  11538. queue.push(new Item(fun, args));
  11539. if (queue.length === 1 && !draining) {
  11540. runTimeout(drainQueue);
  11541. }
  11542. };
  11543. // v8 likes predictible objects
  11544. function Item(fun, array) {
  11545. this.fun = fun;
  11546. this.array = array;
  11547. }
  11548. Item.prototype.run = function () {
  11549. this.fun.apply(null, this.array);
  11550. };
  11551. process.title = 'browser';
  11552. process.browser = true;
  11553. process.env = {};
  11554. process.argv = [];
  11555. process.version = ''; // empty string to avoid regexp issues
  11556. process.versions = {};
  11557. function noop() {}
  11558. process.on = noop;
  11559. process.addListener = noop;
  11560. process.once = noop;
  11561. process.off = noop;
  11562. process.removeListener = noop;
  11563. process.removeAllListeners = noop;
  11564. process.emit = noop;
  11565. process.prependListener = noop;
  11566. process.prependOnceListener = noop;
  11567. process.listeners = function (name) { return [] }
  11568. process.binding = function (name) {
  11569. throw new Error('process.binding is not supported');
  11570. };
  11571. process.cwd = function () { return '/' };
  11572. process.chdir = function (dir) {
  11573. throw new Error('process.chdir is not supported');
  11574. };
  11575. process.umask = function() { return 0; };
  11576. },{}],80:[function(require,module,exports){
  11577. module.exports = require('./lib/_stream_duplex.js');
  11578. },{"./lib/_stream_duplex.js":81}],81:[function(require,module,exports){
  11579. // Copyright Joyent, Inc. and other Node contributors.
  11580. //
  11581. // Permission is hereby granted, free of charge, to any person obtaining a
  11582. // copy of this software and associated documentation files (the
  11583. // "Software"), to deal in the Software without restriction, including
  11584. // without limitation the rights to use, copy, modify, merge, publish,
  11585. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11586. // persons to whom the Software is furnished to do so, subject to the
  11587. // following conditions:
  11588. //
  11589. // The above copyright notice and this permission notice shall be included
  11590. // in all copies or substantial portions of the Software.
  11591. //
  11592. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11593. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11594. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11595. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11596. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11597. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11598. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11599. // a duplex stream is just a stream that is both readable and writable.
  11600. // Since JS doesn't have multiple prototypal inheritance, this class
  11601. // prototypally inherits from Readable, and then parasitically from
  11602. // Writable.
  11603. 'use strict';
  11604. /*<replacement>*/
  11605. var pna = require('process-nextick-args');
  11606. /*</replacement>*/
  11607. /*<replacement>*/
  11608. var objectKeys = Object.keys || function (obj) {
  11609. var keys = [];
  11610. for (var key in obj) {
  11611. keys.push(key);
  11612. }return keys;
  11613. };
  11614. /*</replacement>*/
  11615. module.exports = Duplex;
  11616. /*<replacement>*/
  11617. var util = Object.create(require('core-util-is'));
  11618. util.inherits = require('inherits');
  11619. /*</replacement>*/
  11620. var Readable = require('./_stream_readable');
  11621. var Writable = require('./_stream_writable');
  11622. util.inherits(Duplex, Readable);
  11623. {
  11624. // avoid scope creep, the keys array can then be collected
  11625. var keys = objectKeys(Writable.prototype);
  11626. for (var v = 0; v < keys.length; v++) {
  11627. var method = keys[v];
  11628. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  11629. }
  11630. }
  11631. function Duplex(options) {
  11632. if (!(this instanceof Duplex)) return new Duplex(options);
  11633. Readable.call(this, options);
  11634. Writable.call(this, options);
  11635. if (options && options.readable === false) this.readable = false;
  11636. if (options && options.writable === false) this.writable = false;
  11637. this.allowHalfOpen = true;
  11638. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  11639. this.once('end', onend);
  11640. }
  11641. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  11642. // making it explicit this property is not enumerable
  11643. // because otherwise some prototype manipulation in
  11644. // userland will fail
  11645. enumerable: false,
  11646. get: function () {
  11647. return this._writableState.highWaterMark;
  11648. }
  11649. });
  11650. // the no-half-open enforcer
  11651. function onend() {
  11652. // if we allow half-open state, or if the writable side ended,
  11653. // then we're ok.
  11654. if (this.allowHalfOpen || this._writableState.ended) return;
  11655. // no more data can be written.
  11656. // But allow more writes to happen in this tick.
  11657. pna.nextTick(onEndNT, this);
  11658. }
  11659. function onEndNT(self) {
  11660. self.end();
  11661. }
  11662. Object.defineProperty(Duplex.prototype, 'destroyed', {
  11663. get: function () {
  11664. if (this._readableState === undefined || this._writableState === undefined) {
  11665. return false;
  11666. }
  11667. return this._readableState.destroyed && this._writableState.destroyed;
  11668. },
  11669. set: function (value) {
  11670. // we ignore the value if the stream
  11671. // has not been initialized yet
  11672. if (this._readableState === undefined || this._writableState === undefined) {
  11673. return;
  11674. }
  11675. // backward compatibility, the user is explicitly
  11676. // managing destroyed
  11677. this._readableState.destroyed = value;
  11678. this._writableState.destroyed = value;
  11679. }
  11680. });
  11681. Duplex.prototype._destroy = function (err, cb) {
  11682. this.push(null);
  11683. this.end();
  11684. pna.nextTick(cb, err);
  11685. };
  11686. },{"./_stream_readable":83,"./_stream_writable":85,"core-util-is":13,"inherits":47,"process-nextick-args":78}],82:[function(require,module,exports){
  11687. // Copyright Joyent, Inc. and other Node contributors.
  11688. //
  11689. // Permission is hereby granted, free of charge, to any person obtaining a
  11690. // copy of this software and associated documentation files (the
  11691. // "Software"), to deal in the Software without restriction, including
  11692. // without limitation the rights to use, copy, modify, merge, publish,
  11693. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11694. // persons to whom the Software is furnished to do so, subject to the
  11695. // following conditions:
  11696. //
  11697. // The above copyright notice and this permission notice shall be included
  11698. // in all copies or substantial portions of the Software.
  11699. //
  11700. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11701. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11702. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11703. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11704. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11705. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11706. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11707. // a passthrough stream.
  11708. // basically just the most minimal sort of Transform stream.
  11709. // Every written chunk gets output as-is.
  11710. 'use strict';
  11711. module.exports = PassThrough;
  11712. var Transform = require('./_stream_transform');
  11713. /*<replacement>*/
  11714. var util = Object.create(require('core-util-is'));
  11715. util.inherits = require('inherits');
  11716. /*</replacement>*/
  11717. util.inherits(PassThrough, Transform);
  11718. function PassThrough(options) {
  11719. if (!(this instanceof PassThrough)) return new PassThrough(options);
  11720. Transform.call(this, options);
  11721. }
  11722. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  11723. cb(null, chunk);
  11724. };
  11725. },{"./_stream_transform":84,"core-util-is":13,"inherits":47}],83:[function(require,module,exports){
  11726. (function (process,global){(function (){
  11727. // Copyright Joyent, Inc. and other Node contributors.
  11728. //
  11729. // Permission is hereby granted, free of charge, to any person obtaining a
  11730. // copy of this software and associated documentation files (the
  11731. // "Software"), to deal in the Software without restriction, including
  11732. // without limitation the rights to use, copy, modify, merge, publish,
  11733. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11734. // persons to whom the Software is furnished to do so, subject to the
  11735. // following conditions:
  11736. //
  11737. // The above copyright notice and this permission notice shall be included
  11738. // in all copies or substantial portions of the Software.
  11739. //
  11740. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11741. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11742. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11743. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11744. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11745. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11746. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11747. 'use strict';
  11748. /*<replacement>*/
  11749. var pna = require('process-nextick-args');
  11750. /*</replacement>*/
  11751. module.exports = Readable;
  11752. /*<replacement>*/
  11753. var isArray = require('isarray');
  11754. /*</replacement>*/
  11755. /*<replacement>*/
  11756. var Duplex;
  11757. /*</replacement>*/
  11758. Readable.ReadableState = ReadableState;
  11759. /*<replacement>*/
  11760. var EE = require('events').EventEmitter;
  11761. var EElistenerCount = function (emitter, type) {
  11762. return emitter.listeners(type).length;
  11763. };
  11764. /*</replacement>*/
  11765. /*<replacement>*/
  11766. var Stream = require('./internal/streams/stream');
  11767. /*</replacement>*/
  11768. /*<replacement>*/
  11769. var Buffer = require('safe-buffer').Buffer;
  11770. var OurUint8Array = global.Uint8Array || function () {};
  11771. function _uint8ArrayToBuffer(chunk) {
  11772. return Buffer.from(chunk);
  11773. }
  11774. function _isUint8Array(obj) {
  11775. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  11776. }
  11777. /*</replacement>*/
  11778. /*<replacement>*/
  11779. var util = Object.create(require('core-util-is'));
  11780. util.inherits = require('inherits');
  11781. /*</replacement>*/
  11782. /*<replacement>*/
  11783. var debugUtil = require('util');
  11784. var debug = void 0;
  11785. if (debugUtil && debugUtil.debuglog) {
  11786. debug = debugUtil.debuglog('stream');
  11787. } else {
  11788. debug = function () {};
  11789. }
  11790. /*</replacement>*/
  11791. var BufferList = require('./internal/streams/BufferList');
  11792. var destroyImpl = require('./internal/streams/destroy');
  11793. var StringDecoder;
  11794. util.inherits(Readable, Stream);
  11795. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  11796. function prependListener(emitter, event, fn) {
  11797. // Sadly this is not cacheable as some libraries bundle their own
  11798. // event emitter implementation with them.
  11799. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
  11800. // This is a hack to make sure that our error handler is attached before any
  11801. // userland ones. NEVER DO THIS. This is here only because this code needs
  11802. // to continue to work with older versions of Node.js that do not include
  11803. // the prependListener() method. The goal is to eventually remove this hack.
  11804. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  11805. }
  11806. function ReadableState(options, stream) {
  11807. Duplex = Duplex || require('./_stream_duplex');
  11808. options = options || {};
  11809. // Duplex streams are both readable and writable, but share
  11810. // the same options object.
  11811. // However, some cases require setting options to different
  11812. // values for the readable and the writable sides of the duplex stream.
  11813. // These options can be provided separately as readableXXX and writableXXX.
  11814. var isDuplex = stream instanceof Duplex;
  11815. // object stream flag. Used to make read(n) ignore n and to
  11816. // make all the buffer merging and length checks go away
  11817. this.objectMode = !!options.objectMode;
  11818. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  11819. // the point at which it stops calling _read() to fill the buffer
  11820. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  11821. var hwm = options.highWaterMark;
  11822. var readableHwm = options.readableHighWaterMark;
  11823. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  11824. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
  11825. // cast to ints.
  11826. this.highWaterMark = Math.floor(this.highWaterMark);
  11827. // A linked list is used to store data chunks instead of an array because the
  11828. // linked list can remove elements from the beginning faster than
  11829. // array.shift()
  11830. this.buffer = new BufferList();
  11831. this.length = 0;
  11832. this.pipes = null;
  11833. this.pipesCount = 0;
  11834. this.flowing = null;
  11835. this.ended = false;
  11836. this.endEmitted = false;
  11837. this.reading = false;
  11838. // a flag to be able to tell if the event 'readable'/'data' is emitted
  11839. // immediately, or on a later tick. We set this to true at first, because
  11840. // any actions that shouldn't happen until "later" should generally also
  11841. // not happen before the first read call.
  11842. this.sync = true;
  11843. // whenever we return null, then we set a flag to say
  11844. // that we're awaiting a 'readable' event emission.
  11845. this.needReadable = false;
  11846. this.emittedReadable = false;
  11847. this.readableListening = false;
  11848. this.resumeScheduled = false;
  11849. // has it been destroyed
  11850. this.destroyed = false;
  11851. // Crypto is kind of old and crusty. Historically, its default string
  11852. // encoding is 'binary' so we have to make this configurable.
  11853. // Everything else in the universe uses 'utf8', though.
  11854. this.defaultEncoding = options.defaultEncoding || 'utf8';
  11855. // the number of writers that are awaiting a drain event in .pipe()s
  11856. this.awaitDrain = 0;
  11857. // if true, a maybeReadMore has been scheduled
  11858. this.readingMore = false;
  11859. this.decoder = null;
  11860. this.encoding = null;
  11861. if (options.encoding) {
  11862. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  11863. this.decoder = new StringDecoder(options.encoding);
  11864. this.encoding = options.encoding;
  11865. }
  11866. }
  11867. function Readable(options) {
  11868. Duplex = Duplex || require('./_stream_duplex');
  11869. if (!(this instanceof Readable)) return new Readable(options);
  11870. this._readableState = new ReadableState(options, this);
  11871. // legacy
  11872. this.readable = true;
  11873. if (options) {
  11874. if (typeof options.read === 'function') this._read = options.read;
  11875. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  11876. }
  11877. Stream.call(this);
  11878. }
  11879. Object.defineProperty(Readable.prototype, 'destroyed', {
  11880. get: function () {
  11881. if (this._readableState === undefined) {
  11882. return false;
  11883. }
  11884. return this._readableState.destroyed;
  11885. },
  11886. set: function (value) {
  11887. // we ignore the value if the stream
  11888. // has not been initialized yet
  11889. if (!this._readableState) {
  11890. return;
  11891. }
  11892. // backward compatibility, the user is explicitly
  11893. // managing destroyed
  11894. this._readableState.destroyed = value;
  11895. }
  11896. });
  11897. Readable.prototype.destroy = destroyImpl.destroy;
  11898. Readable.prototype._undestroy = destroyImpl.undestroy;
  11899. Readable.prototype._destroy = function (err, cb) {
  11900. this.push(null);
  11901. cb(err);
  11902. };
  11903. // Manually shove something into the read() buffer.
  11904. // This returns true if the highWaterMark has not been hit yet,
  11905. // similar to how Writable.write() returns true if you should
  11906. // write() some more.
  11907. Readable.prototype.push = function (chunk, encoding) {
  11908. var state = this._readableState;
  11909. var skipChunkCheck;
  11910. if (!state.objectMode) {
  11911. if (typeof chunk === 'string') {
  11912. encoding = encoding || state.defaultEncoding;
  11913. if (encoding !== state.encoding) {
  11914. chunk = Buffer.from(chunk, encoding);
  11915. encoding = '';
  11916. }
  11917. skipChunkCheck = true;
  11918. }
  11919. } else {
  11920. skipChunkCheck = true;
  11921. }
  11922. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  11923. };
  11924. // Unshift should *always* be something directly out of read()
  11925. Readable.prototype.unshift = function (chunk) {
  11926. return readableAddChunk(this, chunk, null, true, false);
  11927. };
  11928. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  11929. var state = stream._readableState;
  11930. if (chunk === null) {
  11931. state.reading = false;
  11932. onEofChunk(stream, state);
  11933. } else {
  11934. var er;
  11935. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  11936. if (er) {
  11937. stream.emit('error', er);
  11938. } else if (state.objectMode || chunk && chunk.length > 0) {
  11939. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  11940. chunk = _uint8ArrayToBuffer(chunk);
  11941. }
  11942. if (addToFront) {
  11943. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
  11944. } else if (state.ended) {
  11945. stream.emit('error', new Error('stream.push() after EOF'));
  11946. } else {
  11947. state.reading = false;
  11948. if (state.decoder && !encoding) {
  11949. chunk = state.decoder.write(chunk);
  11950. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  11951. } else {
  11952. addChunk(stream, state, chunk, false);
  11953. }
  11954. }
  11955. } else if (!addToFront) {
  11956. state.reading = false;
  11957. }
  11958. }
  11959. return needMoreData(state);
  11960. }
  11961. function addChunk(stream, state, chunk, addToFront) {
  11962. if (state.flowing && state.length === 0 && !state.sync) {
  11963. stream.emit('data', chunk);
  11964. stream.read(0);
  11965. } else {
  11966. // update the buffer info.
  11967. state.length += state.objectMode ? 1 : chunk.length;
  11968. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  11969. if (state.needReadable) emitReadable(stream);
  11970. }
  11971. maybeReadMore(stream, state);
  11972. }
  11973. function chunkInvalid(state, chunk) {
  11974. var er;
  11975. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  11976. er = new TypeError('Invalid non-string/buffer chunk');
  11977. }
  11978. return er;
  11979. }
  11980. // if it's past the high water mark, we can push in some more.
  11981. // Also, if we have no data yet, we can stand some
  11982. // more bytes. This is to work around cases where hwm=0,
  11983. // such as the repl. Also, if the push() triggered a
  11984. // readable event, and the user called read(largeNumber) such that
  11985. // needReadable was set, then we ought to push more, so that another
  11986. // 'readable' event will be triggered.
  11987. function needMoreData(state) {
  11988. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  11989. }
  11990. Readable.prototype.isPaused = function () {
  11991. return this._readableState.flowing === false;
  11992. };
  11993. // backwards compatibility.
  11994. Readable.prototype.setEncoding = function (enc) {
  11995. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  11996. this._readableState.decoder = new StringDecoder(enc);
  11997. this._readableState.encoding = enc;
  11998. return this;
  11999. };
  12000. // Don't raise the hwm > 8MB
  12001. var MAX_HWM = 0x800000;
  12002. function computeNewHighWaterMark(n) {
  12003. if (n >= MAX_HWM) {
  12004. n = MAX_HWM;
  12005. } else {
  12006. // Get the next highest power of 2 to prevent increasing hwm excessively in
  12007. // tiny amounts
  12008. n--;
  12009. n |= n >>> 1;
  12010. n |= n >>> 2;
  12011. n |= n >>> 4;
  12012. n |= n >>> 8;
  12013. n |= n >>> 16;
  12014. n++;
  12015. }
  12016. return n;
  12017. }
  12018. // This function is designed to be inlinable, so please take care when making
  12019. // changes to the function body.
  12020. function howMuchToRead(n, state) {
  12021. if (n <= 0 || state.length === 0 && state.ended) return 0;
  12022. if (state.objectMode) return 1;
  12023. if (n !== n) {
  12024. // Only flow one buffer at a time
  12025. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  12026. }
  12027. // If we're asking for more than the current hwm, then raise the hwm.
  12028. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  12029. if (n <= state.length) return n;
  12030. // Don't have enough
  12031. if (!state.ended) {
  12032. state.needReadable = true;
  12033. return 0;
  12034. }
  12035. return state.length;
  12036. }
  12037. // you can override either this method, or the async _read(n) below.
  12038. Readable.prototype.read = function (n) {
  12039. debug('read', n);
  12040. n = parseInt(n, 10);
  12041. var state = this._readableState;
  12042. var nOrig = n;
  12043. if (n !== 0) state.emittedReadable = false;
  12044. // if we're doing read(0) to trigger a readable event, but we
  12045. // already have a bunch of data in the buffer, then just trigger
  12046. // the 'readable' event and move on.
  12047. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  12048. debug('read: emitReadable', state.length, state.ended);
  12049. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  12050. return null;
  12051. }
  12052. n = howMuchToRead(n, state);
  12053. // if we've ended, and we're now clear, then finish it up.
  12054. if (n === 0 && state.ended) {
  12055. if (state.length === 0) endReadable(this);
  12056. return null;
  12057. }
  12058. // All the actual chunk generation logic needs to be
  12059. // *below* the call to _read. The reason is that in certain
  12060. // synthetic stream cases, such as passthrough streams, _read
  12061. // may be a completely synchronous operation which may change
  12062. // the state of the read buffer, providing enough data when
  12063. // before there was *not* enough.
  12064. //
  12065. // So, the steps are:
  12066. // 1. Figure out what the state of things will be after we do
  12067. // a read from the buffer.
  12068. //
  12069. // 2. If that resulting state will trigger a _read, then call _read.
  12070. // Note that this may be asynchronous, or synchronous. Yes, it is
  12071. // deeply ugly to write APIs this way, but that still doesn't mean
  12072. // that the Readable class should behave improperly, as streams are
  12073. // designed to be sync/async agnostic.
  12074. // Take note if the _read call is sync or async (ie, if the read call
  12075. // has returned yet), so that we know whether or not it's safe to emit
  12076. // 'readable' etc.
  12077. //
  12078. // 3. Actually pull the requested chunks out of the buffer and return.
  12079. // if we need a readable event, then we need to do some reading.
  12080. var doRead = state.needReadable;
  12081. debug('need readable', doRead);
  12082. // if we currently have less than the highWaterMark, then also read some
  12083. if (state.length === 0 || state.length - n < state.highWaterMark) {
  12084. doRead = true;
  12085. debug('length less than watermark', doRead);
  12086. }
  12087. // however, if we've ended, then there's no point, and if we're already
  12088. // reading, then it's unnecessary.
  12089. if (state.ended || state.reading) {
  12090. doRead = false;
  12091. debug('reading or ended', doRead);
  12092. } else if (doRead) {
  12093. debug('do read');
  12094. state.reading = true;
  12095. state.sync = true;
  12096. // if the length is currently zero, then we *need* a readable event.
  12097. if (state.length === 0) state.needReadable = true;
  12098. // call internal read method
  12099. this._read(state.highWaterMark);
  12100. state.sync = false;
  12101. // If _read pushed data synchronously, then `reading` will be false,
  12102. // and we need to re-evaluate how much data we can return to the user.
  12103. if (!state.reading) n = howMuchToRead(nOrig, state);
  12104. }
  12105. var ret;
  12106. if (n > 0) ret = fromList(n, state);else ret = null;
  12107. if (ret === null) {
  12108. state.needReadable = true;
  12109. n = 0;
  12110. } else {
  12111. state.length -= n;
  12112. }
  12113. if (state.length === 0) {
  12114. // If we have nothing in the buffer, then we want to know
  12115. // as soon as we *do* get something into the buffer.
  12116. if (!state.ended) state.needReadable = true;
  12117. // If we tried to read() past the EOF, then emit end on the next tick.
  12118. if (nOrig !== n && state.ended) endReadable(this);
  12119. }
  12120. if (ret !== null) this.emit('data', ret);
  12121. return ret;
  12122. };
  12123. function onEofChunk(stream, state) {
  12124. if (state.ended) return;
  12125. if (state.decoder) {
  12126. var chunk = state.decoder.end();
  12127. if (chunk && chunk.length) {
  12128. state.buffer.push(chunk);
  12129. state.length += state.objectMode ? 1 : chunk.length;
  12130. }
  12131. }
  12132. state.ended = true;
  12133. // emit 'readable' now to make sure it gets picked up.
  12134. emitReadable(stream);
  12135. }
  12136. // Don't emit readable right away in sync mode, because this can trigger
  12137. // another read() call => stack overflow. This way, it might trigger
  12138. // a nextTick recursion warning, but that's not so bad.
  12139. function emitReadable(stream) {
  12140. var state = stream._readableState;
  12141. state.needReadable = false;
  12142. if (!state.emittedReadable) {
  12143. debug('emitReadable', state.flowing);
  12144. state.emittedReadable = true;
  12145. if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
  12146. }
  12147. }
  12148. function emitReadable_(stream) {
  12149. debug('emit readable');
  12150. stream.emit('readable');
  12151. flow(stream);
  12152. }
  12153. // at this point, the user has presumably seen the 'readable' event,
  12154. // and called read() to consume some data. that may have triggered
  12155. // in turn another _read(n) call, in which case reading = true if
  12156. // it's in progress.
  12157. // However, if we're not ended, or reading, and the length < hwm,
  12158. // then go ahead and try to read some more preemptively.
  12159. function maybeReadMore(stream, state) {
  12160. if (!state.readingMore) {
  12161. state.readingMore = true;
  12162. pna.nextTick(maybeReadMore_, stream, state);
  12163. }
  12164. }
  12165. function maybeReadMore_(stream, state) {
  12166. var len = state.length;
  12167. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  12168. debug('maybeReadMore read 0');
  12169. stream.read(0);
  12170. if (len === state.length)
  12171. // didn't get any data, stop spinning.
  12172. break;else len = state.length;
  12173. }
  12174. state.readingMore = false;
  12175. }
  12176. // abstract method. to be overridden in specific implementation classes.
  12177. // call cb(er, data) where data is <= n in length.
  12178. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  12179. // arbitrary, and perhaps not very meaningful.
  12180. Readable.prototype._read = function (n) {
  12181. this.emit('error', new Error('_read() is not implemented'));
  12182. };
  12183. Readable.prototype.pipe = function (dest, pipeOpts) {
  12184. var src = this;
  12185. var state = this._readableState;
  12186. switch (state.pipesCount) {
  12187. case 0:
  12188. state.pipes = dest;
  12189. break;
  12190. case 1:
  12191. state.pipes = [state.pipes, dest];
  12192. break;
  12193. default:
  12194. state.pipes.push(dest);
  12195. break;
  12196. }
  12197. state.pipesCount += 1;
  12198. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  12199. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  12200. var endFn = doEnd ? onend : unpipe;
  12201. if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
  12202. dest.on('unpipe', onunpipe);
  12203. function onunpipe(readable, unpipeInfo) {
  12204. debug('onunpipe');
  12205. if (readable === src) {
  12206. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  12207. unpipeInfo.hasUnpiped = true;
  12208. cleanup();
  12209. }
  12210. }
  12211. }
  12212. function onend() {
  12213. debug('onend');
  12214. dest.end();
  12215. }
  12216. // when the dest drains, it reduces the awaitDrain counter
  12217. // on the source. This would be more elegant with a .once()
  12218. // handler in flow(), but adding and removing repeatedly is
  12219. // too slow.
  12220. var ondrain = pipeOnDrain(src);
  12221. dest.on('drain', ondrain);
  12222. var cleanedUp = false;
  12223. function cleanup() {
  12224. debug('cleanup');
  12225. // cleanup event handlers once the pipe is broken
  12226. dest.removeListener('close', onclose);
  12227. dest.removeListener('finish', onfinish);
  12228. dest.removeListener('drain', ondrain);
  12229. dest.removeListener('error', onerror);
  12230. dest.removeListener('unpipe', onunpipe);
  12231. src.removeListener('end', onend);
  12232. src.removeListener('end', unpipe);
  12233. src.removeListener('data', ondata);
  12234. cleanedUp = true;
  12235. // if the reader is waiting for a drain event from this
  12236. // specific writer, then it would cause it to never start
  12237. // flowing again.
  12238. // So, if this is awaiting a drain, then we just call it now.
  12239. // If we don't know, then assume that we are waiting for one.
  12240. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  12241. }
  12242. // If the user pushes more data while we're writing to dest then we'll end up
  12243. // in ondata again. However, we only want to increase awaitDrain once because
  12244. // dest will only emit one 'drain' event for the multiple writes.
  12245. // => Introduce a guard on increasing awaitDrain.
  12246. var increasedAwaitDrain = false;
  12247. src.on('data', ondata);
  12248. function ondata(chunk) {
  12249. debug('ondata');
  12250. increasedAwaitDrain = false;
  12251. var ret = dest.write(chunk);
  12252. if (false === ret && !increasedAwaitDrain) {
  12253. // If the user unpiped during `dest.write()`, it is possible
  12254. // to get stuck in a permanently paused state if that write
  12255. // also returned false.
  12256. // => Check whether `dest` is still a piping destination.
  12257. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  12258. debug('false write response, pause', src._readableState.awaitDrain);
  12259. src._readableState.awaitDrain++;
  12260. increasedAwaitDrain = true;
  12261. }
  12262. src.pause();
  12263. }
  12264. }
  12265. // if the dest has an error, then stop piping into it.
  12266. // however, don't suppress the throwing behavior for this.
  12267. function onerror(er) {
  12268. debug('onerror', er);
  12269. unpipe();
  12270. dest.removeListener('error', onerror);
  12271. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  12272. }
  12273. // Make sure our error handler is attached before userland ones.
  12274. prependListener(dest, 'error', onerror);
  12275. // Both close and finish should trigger unpipe, but only once.
  12276. function onclose() {
  12277. dest.removeListener('finish', onfinish);
  12278. unpipe();
  12279. }
  12280. dest.once('close', onclose);
  12281. function onfinish() {
  12282. debug('onfinish');
  12283. dest.removeListener('close', onclose);
  12284. unpipe();
  12285. }
  12286. dest.once('finish', onfinish);
  12287. function unpipe() {
  12288. debug('unpipe');
  12289. src.unpipe(dest);
  12290. }
  12291. // tell the dest that it's being piped to
  12292. dest.emit('pipe', src);
  12293. // start the flow if it hasn't been started already.
  12294. if (!state.flowing) {
  12295. debug('pipe resume');
  12296. src.resume();
  12297. }
  12298. return dest;
  12299. };
  12300. function pipeOnDrain(src) {
  12301. return function () {
  12302. var state = src._readableState;
  12303. debug('pipeOnDrain', state.awaitDrain);
  12304. if (state.awaitDrain) state.awaitDrain--;
  12305. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  12306. state.flowing = true;
  12307. flow(src);
  12308. }
  12309. };
  12310. }
  12311. Readable.prototype.unpipe = function (dest) {
  12312. var state = this._readableState;
  12313. var unpipeInfo = { hasUnpiped: false };
  12314. // if we're not piping anywhere, then do nothing.
  12315. if (state.pipesCount === 0) return this;
  12316. // just one destination. most common case.
  12317. if (state.pipesCount === 1) {
  12318. // passed in one, but it's not the right one.
  12319. if (dest && dest !== state.pipes) return this;
  12320. if (!dest) dest = state.pipes;
  12321. // got a match.
  12322. state.pipes = null;
  12323. state.pipesCount = 0;
  12324. state.flowing = false;
  12325. if (dest) dest.emit('unpipe', this, unpipeInfo);
  12326. return this;
  12327. }
  12328. // slow case. multiple pipe destinations.
  12329. if (!dest) {
  12330. // remove all.
  12331. var dests = state.pipes;
  12332. var len = state.pipesCount;
  12333. state.pipes = null;
  12334. state.pipesCount = 0;
  12335. state.flowing = false;
  12336. for (var i = 0; i < len; i++) {
  12337. dests[i].emit('unpipe', this, unpipeInfo);
  12338. }return this;
  12339. }
  12340. // try to find the right one.
  12341. var index = indexOf(state.pipes, dest);
  12342. if (index === -1) return this;
  12343. state.pipes.splice(index, 1);
  12344. state.pipesCount -= 1;
  12345. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  12346. dest.emit('unpipe', this, unpipeInfo);
  12347. return this;
  12348. };
  12349. // set up data events if they are asked for
  12350. // Ensure readable listeners eventually get something
  12351. Readable.prototype.on = function (ev, fn) {
  12352. var res = Stream.prototype.on.call(this, ev, fn);
  12353. if (ev === 'data') {
  12354. // Start flowing on next tick if stream isn't explicitly paused
  12355. if (this._readableState.flowing !== false) this.resume();
  12356. } else if (ev === 'readable') {
  12357. var state = this._readableState;
  12358. if (!state.endEmitted && !state.readableListening) {
  12359. state.readableListening = state.needReadable = true;
  12360. state.emittedReadable = false;
  12361. if (!state.reading) {
  12362. pna.nextTick(nReadingNextTick, this);
  12363. } else if (state.length) {
  12364. emitReadable(this);
  12365. }
  12366. }
  12367. }
  12368. return res;
  12369. };
  12370. Readable.prototype.addListener = Readable.prototype.on;
  12371. function nReadingNextTick(self) {
  12372. debug('readable nexttick read 0');
  12373. self.read(0);
  12374. }
  12375. // pause() and resume() are remnants of the legacy readable stream API
  12376. // If the user uses them, then switch into old mode.
  12377. Readable.prototype.resume = function () {
  12378. var state = this._readableState;
  12379. if (!state.flowing) {
  12380. debug('resume');
  12381. state.flowing = true;
  12382. resume(this, state);
  12383. }
  12384. return this;
  12385. };
  12386. function resume(stream, state) {
  12387. if (!state.resumeScheduled) {
  12388. state.resumeScheduled = true;
  12389. pna.nextTick(resume_, stream, state);
  12390. }
  12391. }
  12392. function resume_(stream, state) {
  12393. if (!state.reading) {
  12394. debug('resume read 0');
  12395. stream.read(0);
  12396. }
  12397. state.resumeScheduled = false;
  12398. state.awaitDrain = 0;
  12399. stream.emit('resume');
  12400. flow(stream);
  12401. if (state.flowing && !state.reading) stream.read(0);
  12402. }
  12403. Readable.prototype.pause = function () {
  12404. debug('call pause flowing=%j', this._readableState.flowing);
  12405. if (false !== this._readableState.flowing) {
  12406. debug('pause');
  12407. this._readableState.flowing = false;
  12408. this.emit('pause');
  12409. }
  12410. return this;
  12411. };
  12412. function flow(stream) {
  12413. var state = stream._readableState;
  12414. debug('flow', state.flowing);
  12415. while (state.flowing && stream.read() !== null) {}
  12416. }
  12417. // wrap an old-style stream as the async data source.
  12418. // This is *not* part of the readable stream interface.
  12419. // It is an ugly unfortunate mess of history.
  12420. Readable.prototype.wrap = function (stream) {
  12421. var _this = this;
  12422. var state = this._readableState;
  12423. var paused = false;
  12424. stream.on('end', function () {
  12425. debug('wrapped end');
  12426. if (state.decoder && !state.ended) {
  12427. var chunk = state.decoder.end();
  12428. if (chunk && chunk.length) _this.push(chunk);
  12429. }
  12430. _this.push(null);
  12431. });
  12432. stream.on('data', function (chunk) {
  12433. debug('wrapped data');
  12434. if (state.decoder) chunk = state.decoder.write(chunk);
  12435. // don't skip over falsy values in objectMode
  12436. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  12437. var ret = _this.push(chunk);
  12438. if (!ret) {
  12439. paused = true;
  12440. stream.pause();
  12441. }
  12442. });
  12443. // proxy all the other methods.
  12444. // important when wrapping filters and duplexes.
  12445. for (var i in stream) {
  12446. if (this[i] === undefined && typeof stream[i] === 'function') {
  12447. this[i] = function (method) {
  12448. return function () {
  12449. return stream[method].apply(stream, arguments);
  12450. };
  12451. }(i);
  12452. }
  12453. }
  12454. // proxy certain important events.
  12455. for (var n = 0; n < kProxyEvents.length; n++) {
  12456. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  12457. }
  12458. // when we try to consume some more bytes, simply unpause the
  12459. // underlying stream.
  12460. this._read = function (n) {
  12461. debug('wrapped _read', n);
  12462. if (paused) {
  12463. paused = false;
  12464. stream.resume();
  12465. }
  12466. };
  12467. return this;
  12468. };
  12469. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  12470. // making it explicit this property is not enumerable
  12471. // because otherwise some prototype manipulation in
  12472. // userland will fail
  12473. enumerable: false,
  12474. get: function () {
  12475. return this._readableState.highWaterMark;
  12476. }
  12477. });
  12478. // exposed for testing purposes only.
  12479. Readable._fromList = fromList;
  12480. // Pluck off n bytes from an array of buffers.
  12481. // Length is the combined lengths of all the buffers in the list.
  12482. // This function is designed to be inlinable, so please take care when making
  12483. // changes to the function body.
  12484. function fromList(n, state) {
  12485. // nothing buffered
  12486. if (state.length === 0) return null;
  12487. var ret;
  12488. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  12489. // read it all, truncate the list
  12490. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
  12491. state.buffer.clear();
  12492. } else {
  12493. // read part of list
  12494. ret = fromListPartial(n, state.buffer, state.decoder);
  12495. }
  12496. return ret;
  12497. }
  12498. // Extracts only enough buffered data to satisfy the amount requested.
  12499. // This function is designed to be inlinable, so please take care when making
  12500. // changes to the function body.
  12501. function fromListPartial(n, list, hasStrings) {
  12502. var ret;
  12503. if (n < list.head.data.length) {
  12504. // slice is the same for buffers and strings
  12505. ret = list.head.data.slice(0, n);
  12506. list.head.data = list.head.data.slice(n);
  12507. } else if (n === list.head.data.length) {
  12508. // first chunk is a perfect match
  12509. ret = list.shift();
  12510. } else {
  12511. // result spans more than one buffer
  12512. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  12513. }
  12514. return ret;
  12515. }
  12516. // Copies a specified amount of characters from the list of buffered data
  12517. // chunks.
  12518. // This function is designed to be inlinable, so please take care when making
  12519. // changes to the function body.
  12520. function copyFromBufferString(n, list) {
  12521. var p = list.head;
  12522. var c = 1;
  12523. var ret = p.data;
  12524. n -= ret.length;
  12525. while (p = p.next) {
  12526. var str = p.data;
  12527. var nb = n > str.length ? str.length : n;
  12528. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  12529. n -= nb;
  12530. if (n === 0) {
  12531. if (nb === str.length) {
  12532. ++c;
  12533. if (p.next) list.head = p.next;else list.head = list.tail = null;
  12534. } else {
  12535. list.head = p;
  12536. p.data = str.slice(nb);
  12537. }
  12538. break;
  12539. }
  12540. ++c;
  12541. }
  12542. list.length -= c;
  12543. return ret;
  12544. }
  12545. // Copies a specified amount of bytes from the list of buffered data chunks.
  12546. // This function is designed to be inlinable, so please take care when making
  12547. // changes to the function body.
  12548. function copyFromBuffer(n, list) {
  12549. var ret = Buffer.allocUnsafe(n);
  12550. var p = list.head;
  12551. var c = 1;
  12552. p.data.copy(ret);
  12553. n -= p.data.length;
  12554. while (p = p.next) {
  12555. var buf = p.data;
  12556. var nb = n > buf.length ? buf.length : n;
  12557. buf.copy(ret, ret.length - n, 0, nb);
  12558. n -= nb;
  12559. if (n === 0) {
  12560. if (nb === buf.length) {
  12561. ++c;
  12562. if (p.next) list.head = p.next;else list.head = list.tail = null;
  12563. } else {
  12564. list.head = p;
  12565. p.data = buf.slice(nb);
  12566. }
  12567. break;
  12568. }
  12569. ++c;
  12570. }
  12571. list.length -= c;
  12572. return ret;
  12573. }
  12574. function endReadable(stream) {
  12575. var state = stream._readableState;
  12576. // If we get here before consuming all the bytes, then that is a
  12577. // bug in node. Should never happen.
  12578. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  12579. if (!state.endEmitted) {
  12580. state.ended = true;
  12581. pna.nextTick(endReadableNT, state, stream);
  12582. }
  12583. }
  12584. function endReadableNT(state, stream) {
  12585. // Check that we didn't get one last unshift.
  12586. if (!state.endEmitted && state.length === 0) {
  12587. state.endEmitted = true;
  12588. stream.readable = false;
  12589. stream.emit('end');
  12590. }
  12591. }
  12592. function indexOf(xs, x) {
  12593. for (var i = 0, l = xs.length; i < l; i++) {
  12594. if (xs[i] === x) return i;
  12595. }
  12596. return -1;
  12597. }
  12598. }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  12599. },{"./_stream_duplex":81,"./internal/streams/BufferList":86,"./internal/streams/destroy":87,"./internal/streams/stream":88,"_process":79,"core-util-is":13,"events":33,"inherits":47,"isarray":62,"process-nextick-args":78,"safe-buffer":89,"string_decoder/":90,"util":9}],84:[function(require,module,exports){
  12600. // Copyright Joyent, Inc. and other Node contributors.
  12601. //
  12602. // Permission is hereby granted, free of charge, to any person obtaining a
  12603. // copy of this software and associated documentation files (the
  12604. // "Software"), to deal in the Software without restriction, including
  12605. // without limitation the rights to use, copy, modify, merge, publish,
  12606. // distribute, sublicense, and/or sell copies of the Software, and to permit
  12607. // persons to whom the Software is furnished to do so, subject to the
  12608. // following conditions:
  12609. //
  12610. // The above copyright notice and this permission notice shall be included
  12611. // in all copies or substantial portions of the Software.
  12612. //
  12613. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  12614. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  12615. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  12616. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  12617. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  12618. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  12619. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  12620. // a transform stream is a readable/writable stream where you do
  12621. // something with the data. Sometimes it's called a "filter",
  12622. // but that's not a great name for it, since that implies a thing where
  12623. // some bits pass through, and others are simply ignored. (That would
  12624. // be a valid example of a transform, of course.)
  12625. //
  12626. // While the output is causally related to the input, it's not a
  12627. // necessarily symmetric or synchronous transformation. For example,
  12628. // a zlib stream might take multiple plain-text writes(), and then
  12629. // emit a single compressed chunk some time in the future.
  12630. //
  12631. // Here's how this works:
  12632. //
  12633. // The Transform stream has all the aspects of the readable and writable
  12634. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  12635. // internally, and returns false if there's a lot of pending writes
  12636. // buffered up. When you call read(), that calls _read(n) until
  12637. // there's enough pending readable data buffered up.
  12638. //
  12639. // In a transform stream, the written data is placed in a buffer. When
  12640. // _read(n) is called, it transforms the queued up data, calling the
  12641. // buffered _write cb's as it consumes chunks. If consuming a single
  12642. // written chunk would result in multiple output chunks, then the first
  12643. // outputted bit calls the readcb, and subsequent chunks just go into
  12644. // the read buffer, and will cause it to emit 'readable' if necessary.
  12645. //
  12646. // This way, back-pressure is actually determined by the reading side,
  12647. // since _read has to be called to start processing a new chunk. However,
  12648. // a pathological inflate type of transform can cause excessive buffering
  12649. // here. For example, imagine a stream where every byte of input is
  12650. // interpreted as an integer from 0-255, and then results in that many
  12651. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  12652. // 1kb of data being output. In this case, you could write a very small
  12653. // amount of input, and end up with a very large amount of output. In
  12654. // such a pathological inflating mechanism, there'd be no way to tell
  12655. // the system to stop doing the transform. A single 4MB write could
  12656. // cause the system to run out of memory.
  12657. //
  12658. // However, even in such a pathological case, only a single written chunk
  12659. // would be consumed, and then the rest would wait (un-transformed) until
  12660. // the results of the previous transformed chunk were consumed.
  12661. 'use strict';
  12662. module.exports = Transform;
  12663. var Duplex = require('./_stream_duplex');
  12664. /*<replacement>*/
  12665. var util = Object.create(require('core-util-is'));
  12666. util.inherits = require('inherits');
  12667. /*</replacement>*/
  12668. util.inherits(Transform, Duplex);
  12669. function afterTransform(er, data) {
  12670. var ts = this._transformState;
  12671. ts.transforming = false;
  12672. var cb = ts.writecb;
  12673. if (!cb) {
  12674. return this.emit('error', new Error('write callback called multiple times'));
  12675. }
  12676. ts.writechunk = null;
  12677. ts.writecb = null;
  12678. if (data != null) // single equals check for both `null` and `undefined`
  12679. this.push(data);
  12680. cb(er);
  12681. var rs = this._readableState;
  12682. rs.reading = false;
  12683. if (rs.needReadable || rs.length < rs.highWaterMark) {
  12684. this._read(rs.highWaterMark);
  12685. }
  12686. }
  12687. function Transform(options) {
  12688. if (!(this instanceof Transform)) return new Transform(options);
  12689. Duplex.call(this, options);
  12690. this._transformState = {
  12691. afterTransform: afterTransform.bind(this),
  12692. needTransform: false,
  12693. transforming: false,
  12694. writecb: null,
  12695. writechunk: null,
  12696. writeencoding: null
  12697. };
  12698. // start out asking for a readable event once data is transformed.
  12699. this._readableState.needReadable = true;
  12700. // we have implemented the _read method, and done the other things
  12701. // that Readable wants before the first _read call, so unset the
  12702. // sync guard flag.
  12703. this._readableState.sync = false;
  12704. if (options) {
  12705. if (typeof options.transform === 'function') this._transform = options.transform;
  12706. if (typeof options.flush === 'function') this._flush = options.flush;
  12707. }
  12708. // When the writable side finishes, then flush out anything remaining.
  12709. this.on('prefinish', prefinish);
  12710. }
  12711. function prefinish() {
  12712. var _this = this;
  12713. if (typeof this._flush === 'function') {
  12714. this._flush(function (er, data) {
  12715. done(_this, er, data);
  12716. });
  12717. } else {
  12718. done(this, null, null);
  12719. }
  12720. }
  12721. Transform.prototype.push = function (chunk, encoding) {
  12722. this._transformState.needTransform = false;
  12723. return Duplex.prototype.push.call(this, chunk, encoding);
  12724. };
  12725. // This is the part where you do stuff!
  12726. // override this function in implementation classes.
  12727. // 'chunk' is an input chunk.
  12728. //
  12729. // Call `push(newChunk)` to pass along transformed output
  12730. // to the readable side. You may call 'push' zero or more times.
  12731. //
  12732. // Call `cb(err)` when you are done with this chunk. If you pass
  12733. // an error, then that'll put the hurt on the whole operation. If you
  12734. // never call cb(), then you'll never get another chunk.
  12735. Transform.prototype._transform = function (chunk, encoding, cb) {
  12736. throw new Error('_transform() is not implemented');
  12737. };
  12738. Transform.prototype._write = function (chunk, encoding, cb) {
  12739. var ts = this._transformState;
  12740. ts.writecb = cb;
  12741. ts.writechunk = chunk;
  12742. ts.writeencoding = encoding;
  12743. if (!ts.transforming) {
  12744. var rs = this._readableState;
  12745. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  12746. }
  12747. };
  12748. // Doesn't matter what the args are here.
  12749. // _transform does all the work.
  12750. // That we got here means that the readable side wants more data.
  12751. Transform.prototype._read = function (n) {
  12752. var ts = this._transformState;
  12753. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  12754. ts.transforming = true;
  12755. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  12756. } else {
  12757. // mark that we need a transform, so that any data that comes in
  12758. // will get processed, now that we've asked for it.
  12759. ts.needTransform = true;
  12760. }
  12761. };
  12762. Transform.prototype._destroy = function (err, cb) {
  12763. var _this2 = this;
  12764. Duplex.prototype._destroy.call(this, err, function (err2) {
  12765. cb(err2);
  12766. _this2.emit('close');
  12767. });
  12768. };
  12769. function done(stream, er, data) {
  12770. if (er) return stream.emit('error', er);
  12771. if (data != null) // single equals check for both `null` and `undefined`
  12772. stream.push(data);
  12773. // if there's nothing in the write buffer, then that means
  12774. // that nothing more will ever be provided
  12775. if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
  12776. if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
  12777. return stream.push(null);
  12778. }
  12779. },{"./_stream_duplex":81,"core-util-is":13,"inherits":47}],85:[function(require,module,exports){
  12780. (function (process,global,setImmediate){(function (){
  12781. // Copyright Joyent, Inc. and other Node contributors.
  12782. //
  12783. // Permission is hereby granted, free of charge, to any person obtaining a
  12784. // copy of this software and associated documentation files (the
  12785. // "Software"), to deal in the Software without restriction, including
  12786. // without limitation the rights to use, copy, modify, merge, publish,
  12787. // distribute, sublicense, and/or sell copies of the Software, and to permit
  12788. // persons to whom the Software is furnished to do so, subject to the
  12789. // following conditions:
  12790. //
  12791. // The above copyright notice and this permission notice shall be included
  12792. // in all copies or substantial portions of the Software.
  12793. //
  12794. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  12795. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  12796. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  12797. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  12798. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  12799. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  12800. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  12801. // A bit simpler than readable streams.
  12802. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  12803. // the drain event emission and buffering.
  12804. 'use strict';
  12805. /*<replacement>*/
  12806. var pna = require('process-nextick-args');
  12807. /*</replacement>*/
  12808. module.exports = Writable;
  12809. /* <replacement> */
  12810. function WriteReq(chunk, encoding, cb) {
  12811. this.chunk = chunk;
  12812. this.encoding = encoding;
  12813. this.callback = cb;
  12814. this.next = null;
  12815. }
  12816. // It seems a linked list but it is not
  12817. // there will be only 2 of these for each stream
  12818. function CorkedRequest(state) {
  12819. var _this = this;
  12820. this.next = null;
  12821. this.entry = null;
  12822. this.finish = function () {
  12823. onCorkedFinish(_this, state);
  12824. };
  12825. }
  12826. /* </replacement> */
  12827. /*<replacement>*/
  12828. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
  12829. /*</replacement>*/
  12830. /*<replacement>*/
  12831. var Duplex;
  12832. /*</replacement>*/
  12833. Writable.WritableState = WritableState;
  12834. /*<replacement>*/
  12835. var util = Object.create(require('core-util-is'));
  12836. util.inherits = require('inherits');
  12837. /*</replacement>*/
  12838. /*<replacement>*/
  12839. var internalUtil = {
  12840. deprecate: require('util-deprecate')
  12841. };
  12842. /*</replacement>*/
  12843. /*<replacement>*/
  12844. var Stream = require('./internal/streams/stream');
  12845. /*</replacement>*/
  12846. /*<replacement>*/
  12847. var Buffer = require('safe-buffer').Buffer;
  12848. var OurUint8Array = global.Uint8Array || function () {};
  12849. function _uint8ArrayToBuffer(chunk) {
  12850. return Buffer.from(chunk);
  12851. }
  12852. function _isUint8Array(obj) {
  12853. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  12854. }
  12855. /*</replacement>*/
  12856. var destroyImpl = require('./internal/streams/destroy');
  12857. util.inherits(Writable, Stream);
  12858. function nop() {}
  12859. function WritableState(options, stream) {
  12860. Duplex = Duplex || require('./_stream_duplex');
  12861. options = options || {};
  12862. // Duplex streams are both readable and writable, but share
  12863. // the same options object.
  12864. // However, some cases require setting options to different
  12865. // values for the readable and the writable sides of the duplex stream.
  12866. // These options can be provided separately as readableXXX and writableXXX.
  12867. var isDuplex = stream instanceof Duplex;
  12868. // object stream flag to indicate whether or not this stream
  12869. // contains buffers or objects.
  12870. this.objectMode = !!options.objectMode;
  12871. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  12872. // the point at which write() starts returning false
  12873. // Note: 0 is a valid value, means that we always return false if
  12874. // the entire buffer is not flushed immediately on write()
  12875. var hwm = options.highWaterMark;
  12876. var writableHwm = options.writableHighWaterMark;
  12877. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  12878. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
  12879. // cast to ints.
  12880. this.highWaterMark = Math.floor(this.highWaterMark);
  12881. // if _final has been called
  12882. this.finalCalled = false;
  12883. // drain event flag.
  12884. this.needDrain = false;
  12885. // at the start of calling end()
  12886. this.ending = false;
  12887. // when end() has been called, and returned
  12888. this.ended = false;
  12889. // when 'finish' is emitted
  12890. this.finished = false;
  12891. // has it been destroyed
  12892. this.destroyed = false;
  12893. // should we decode strings into buffers before passing to _write?
  12894. // this is here so that some node-core streams can optimize string
  12895. // handling at a lower level.
  12896. var noDecode = options.decodeStrings === false;
  12897. this.decodeStrings = !noDecode;
  12898. // Crypto is kind of old and crusty. Historically, its default string
  12899. // encoding is 'binary' so we have to make this configurable.
  12900. // Everything else in the universe uses 'utf8', though.
  12901. this.defaultEncoding = options.defaultEncoding || 'utf8';
  12902. // not an actual buffer we keep track of, but a measurement
  12903. // of how much we're waiting to get pushed to some underlying
  12904. // socket or file.
  12905. this.length = 0;
  12906. // a flag to see when we're in the middle of a write.
  12907. this.writing = false;
  12908. // when true all writes will be buffered until .uncork() call
  12909. this.corked = 0;
  12910. // a flag to be able to tell if the onwrite cb is called immediately,
  12911. // or on a later tick. We set this to true at first, because any
  12912. // actions that shouldn't happen until "later" should generally also
  12913. // not happen before the first write call.
  12914. this.sync = true;
  12915. // a flag to know if we're processing previously buffered items, which
  12916. // may call the _write() callback in the same tick, so that we don't
  12917. // end up in an overlapped onwrite situation.
  12918. this.bufferProcessing = false;
  12919. // the callback that's passed to _write(chunk,cb)
  12920. this.onwrite = function (er) {
  12921. onwrite(stream, er);
  12922. };
  12923. // the callback that the user supplies to write(chunk,encoding,cb)
  12924. this.writecb = null;
  12925. // the amount that is being written when _write is called.
  12926. this.writelen = 0;
  12927. this.bufferedRequest = null;
  12928. this.lastBufferedRequest = null;
  12929. // number of pending user-supplied write callbacks
  12930. // this must be 0 before 'finish' can be emitted
  12931. this.pendingcb = 0;
  12932. // emit prefinish if the only thing we're waiting for is _write cbs
  12933. // This is relevant for synchronous Transform streams
  12934. this.prefinished = false;
  12935. // True if the error was already emitted and should not be thrown again
  12936. this.errorEmitted = false;
  12937. // count buffered requests
  12938. this.bufferedRequestCount = 0;
  12939. // allocate the first CorkedRequest, there is always
  12940. // one allocated and free to use, and we maintain at most two
  12941. this.corkedRequestsFree = new CorkedRequest(this);
  12942. }
  12943. WritableState.prototype.getBuffer = function getBuffer() {
  12944. var current = this.bufferedRequest;
  12945. var out = [];
  12946. while (current) {
  12947. out.push(current);
  12948. current = current.next;
  12949. }
  12950. return out;
  12951. };
  12952. (function () {
  12953. try {
  12954. Object.defineProperty(WritableState.prototype, 'buffer', {
  12955. get: internalUtil.deprecate(function () {
  12956. return this.getBuffer();
  12957. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  12958. });
  12959. } catch (_) {}
  12960. })();
  12961. // Test _writableState for inheritance to account for Duplex streams,
  12962. // whose prototype chain only points to Readable.
  12963. var realHasInstance;
  12964. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  12965. realHasInstance = Function.prototype[Symbol.hasInstance];
  12966. Object.defineProperty(Writable, Symbol.hasInstance, {
  12967. value: function (object) {
  12968. if (realHasInstance.call(this, object)) return true;
  12969. if (this !== Writable) return false;
  12970. return object && object._writableState instanceof WritableState;
  12971. }
  12972. });
  12973. } else {
  12974. realHasInstance = function (object) {
  12975. return object instanceof this;
  12976. };
  12977. }
  12978. function Writable(options) {
  12979. Duplex = Duplex || require('./_stream_duplex');
  12980. // Writable ctor is applied to Duplexes, too.
  12981. // `realHasInstance` is necessary because using plain `instanceof`
  12982. // would return false, as no `_writableState` property is attached.
  12983. // Trying to use the custom `instanceof` for Writable here will also break the
  12984. // Node.js LazyTransform implementation, which has a non-trivial getter for
  12985. // `_writableState` that would lead to infinite recursion.
  12986. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  12987. return new Writable(options);
  12988. }
  12989. this._writableState = new WritableState(options, this);
  12990. // legacy.
  12991. this.writable = true;
  12992. if (options) {
  12993. if (typeof options.write === 'function') this._write = options.write;
  12994. if (typeof options.writev === 'function') this._writev = options.writev;
  12995. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  12996. if (typeof options.final === 'function') this._final = options.final;
  12997. }
  12998. Stream.call(this);
  12999. }
  13000. // Otherwise people can pipe Writable streams, which is just wrong.
  13001. Writable.prototype.pipe = function () {
  13002. this.emit('error', new Error('Cannot pipe, not readable'));
  13003. };
  13004. function writeAfterEnd(stream, cb) {
  13005. var er = new Error('write after end');
  13006. // TODO: defer error events consistently everywhere, not just the cb
  13007. stream.emit('error', er);
  13008. pna.nextTick(cb, er);
  13009. }
  13010. // Checks that a user-supplied chunk is valid, especially for the particular
  13011. // mode the stream is in. Currently this means that `null` is never accepted
  13012. // and undefined/non-string values are only allowed in object mode.
  13013. function validChunk(stream, state, chunk, cb) {
  13014. var valid = true;
  13015. var er = false;
  13016. if (chunk === null) {
  13017. er = new TypeError('May not write null values to stream');
  13018. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  13019. er = new TypeError('Invalid non-string/buffer chunk');
  13020. }
  13021. if (er) {
  13022. stream.emit('error', er);
  13023. pna.nextTick(cb, er);
  13024. valid = false;
  13025. }
  13026. return valid;
  13027. }
  13028. Writable.prototype.write = function (chunk, encoding, cb) {
  13029. var state = this._writableState;
  13030. var ret = false;
  13031. var isBuf = !state.objectMode && _isUint8Array(chunk);
  13032. if (isBuf && !Buffer.isBuffer(chunk)) {
  13033. chunk = _uint8ArrayToBuffer(chunk);
  13034. }
  13035. if (typeof encoding === 'function') {
  13036. cb = encoding;
  13037. encoding = null;
  13038. }
  13039. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  13040. if (typeof cb !== 'function') cb = nop;
  13041. if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  13042. state.pendingcb++;
  13043. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  13044. }
  13045. return ret;
  13046. };
  13047. Writable.prototype.cork = function () {
  13048. var state = this._writableState;
  13049. state.corked++;
  13050. };
  13051. Writable.prototype.uncork = function () {
  13052. var state = this._writableState;
  13053. if (state.corked) {
  13054. state.corked--;
  13055. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  13056. }
  13057. };
  13058. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  13059. // node::ParseEncoding() requires lower case.
  13060. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  13061. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
  13062. this._writableState.defaultEncoding = encoding;
  13063. return this;
  13064. };
  13065. function decodeChunk(state, chunk, encoding) {
  13066. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  13067. chunk = Buffer.from(chunk, encoding);
  13068. }
  13069. return chunk;
  13070. }
  13071. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  13072. // making it explicit this property is not enumerable
  13073. // because otherwise some prototype manipulation in
  13074. // userland will fail
  13075. enumerable: false,
  13076. get: function () {
  13077. return this._writableState.highWaterMark;
  13078. }
  13079. });
  13080. // if we're already writing something, then just put this
  13081. // in the queue, and wait our turn. Otherwise, call _write
  13082. // If we return false, then we need a drain event, so set that flag.
  13083. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  13084. if (!isBuf) {
  13085. var newChunk = decodeChunk(state, chunk, encoding);
  13086. if (chunk !== newChunk) {
  13087. isBuf = true;
  13088. encoding = 'buffer';
  13089. chunk = newChunk;
  13090. }
  13091. }
  13092. var len = state.objectMode ? 1 : chunk.length;
  13093. state.length += len;
  13094. var ret = state.length < state.highWaterMark;
  13095. // we must ensure that previous needDrain will not be reset to false.
  13096. if (!ret) state.needDrain = true;
  13097. if (state.writing || state.corked) {
  13098. var last = state.lastBufferedRequest;
  13099. state.lastBufferedRequest = {
  13100. chunk: chunk,
  13101. encoding: encoding,
  13102. isBuf: isBuf,
  13103. callback: cb,
  13104. next: null
  13105. };
  13106. if (last) {
  13107. last.next = state.lastBufferedRequest;
  13108. } else {
  13109. state.bufferedRequest = state.lastBufferedRequest;
  13110. }
  13111. state.bufferedRequestCount += 1;
  13112. } else {
  13113. doWrite(stream, state, false, len, chunk, encoding, cb);
  13114. }
  13115. return ret;
  13116. }
  13117. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  13118. state.writelen = len;
  13119. state.writecb = cb;
  13120. state.writing = true;
  13121. state.sync = true;
  13122. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  13123. state.sync = false;
  13124. }
  13125. function onwriteError(stream, state, sync, er, cb) {
  13126. --state.pendingcb;
  13127. if (sync) {
  13128. // defer the callback if we are being called synchronously
  13129. // to avoid piling up things on the stack
  13130. pna.nextTick(cb, er);
  13131. // this can emit finish, and it will always happen
  13132. // after error
  13133. pna.nextTick(finishMaybe, stream, state);
  13134. stream._writableState.errorEmitted = true;
  13135. stream.emit('error', er);
  13136. } else {
  13137. // the caller expect this to happen before if
  13138. // it is async
  13139. cb(er);
  13140. stream._writableState.errorEmitted = true;
  13141. stream.emit('error', er);
  13142. // this can emit finish, but finish must
  13143. // always follow error
  13144. finishMaybe(stream, state);
  13145. }
  13146. }
  13147. function onwriteStateUpdate(state) {
  13148. state.writing = false;
  13149. state.writecb = null;
  13150. state.length -= state.writelen;
  13151. state.writelen = 0;
  13152. }
  13153. function onwrite(stream, er) {
  13154. var state = stream._writableState;
  13155. var sync = state.sync;
  13156. var cb = state.writecb;
  13157. onwriteStateUpdate(state);
  13158. if (er) onwriteError(stream, state, sync, er, cb);else {
  13159. // Check if we're actually ready to finish, but don't emit yet
  13160. var finished = needFinish(state);
  13161. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  13162. clearBuffer(stream, state);
  13163. }
  13164. if (sync) {
  13165. /*<replacement>*/
  13166. asyncWrite(afterWrite, stream, state, finished, cb);
  13167. /*</replacement>*/
  13168. } else {
  13169. afterWrite(stream, state, finished, cb);
  13170. }
  13171. }
  13172. }
  13173. function afterWrite(stream, state, finished, cb) {
  13174. if (!finished) onwriteDrain(stream, state);
  13175. state.pendingcb--;
  13176. cb();
  13177. finishMaybe(stream, state);
  13178. }
  13179. // Must force callback to be called on nextTick, so that we don't
  13180. // emit 'drain' before the write() consumer gets the 'false' return
  13181. // value, and has a chance to attach a 'drain' listener.
  13182. function onwriteDrain(stream, state) {
  13183. if (state.length === 0 && state.needDrain) {
  13184. state.needDrain = false;
  13185. stream.emit('drain');
  13186. }
  13187. }
  13188. // if there's something in the buffer waiting, then process it
  13189. function clearBuffer(stream, state) {
  13190. state.bufferProcessing = true;
  13191. var entry = state.bufferedRequest;
  13192. if (stream._writev && entry && entry.next) {
  13193. // Fast case, write everything using _writev()
  13194. var l = state.bufferedRequestCount;
  13195. var buffer = new Array(l);
  13196. var holder = state.corkedRequestsFree;
  13197. holder.entry = entry;
  13198. var count = 0;
  13199. var allBuffers = true;
  13200. while (entry) {
  13201. buffer[count] = entry;
  13202. if (!entry.isBuf) allBuffers = false;
  13203. entry = entry.next;
  13204. count += 1;
  13205. }
  13206. buffer.allBuffers = allBuffers;
  13207. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  13208. // doWrite is almost always async, defer these to save a bit of time
  13209. // as the hot path ends with doWrite
  13210. state.pendingcb++;
  13211. state.lastBufferedRequest = null;
  13212. if (holder.next) {
  13213. state.corkedRequestsFree = holder.next;
  13214. holder.next = null;
  13215. } else {
  13216. state.corkedRequestsFree = new CorkedRequest(state);
  13217. }
  13218. state.bufferedRequestCount = 0;
  13219. } else {
  13220. // Slow case, write chunks one-by-one
  13221. while (entry) {
  13222. var chunk = entry.chunk;
  13223. var encoding = entry.encoding;
  13224. var cb = entry.callback;
  13225. var len = state.objectMode ? 1 : chunk.length;
  13226. doWrite(stream, state, false, len, chunk, encoding, cb);
  13227. entry = entry.next;
  13228. state.bufferedRequestCount--;
  13229. // if we didn't call the onwrite immediately, then
  13230. // it means that we need to wait until it does.
  13231. // also, that means that the chunk and cb are currently
  13232. // being processed, so move the buffer counter past them.
  13233. if (state.writing) {
  13234. break;
  13235. }
  13236. }
  13237. if (entry === null) state.lastBufferedRequest = null;
  13238. }
  13239. state.bufferedRequest = entry;
  13240. state.bufferProcessing = false;
  13241. }
  13242. Writable.prototype._write = function (chunk, encoding, cb) {
  13243. cb(new Error('_write() is not implemented'));
  13244. };
  13245. Writable.prototype._writev = null;
  13246. Writable.prototype.end = function (chunk, encoding, cb) {
  13247. var state = this._writableState;
  13248. if (typeof chunk === 'function') {
  13249. cb = chunk;
  13250. chunk = null;
  13251. encoding = null;
  13252. } else if (typeof encoding === 'function') {
  13253. cb = encoding;
  13254. encoding = null;
  13255. }
  13256. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  13257. // .end() fully uncorks
  13258. if (state.corked) {
  13259. state.corked = 1;
  13260. this.uncork();
  13261. }
  13262. // ignore unnecessary end() calls.
  13263. if (!state.ending && !state.finished) endWritable(this, state, cb);
  13264. };
  13265. function needFinish(state) {
  13266. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  13267. }
  13268. function callFinal(stream, state) {
  13269. stream._final(function (err) {
  13270. state.pendingcb--;
  13271. if (err) {
  13272. stream.emit('error', err);
  13273. }
  13274. state.prefinished = true;
  13275. stream.emit('prefinish');
  13276. finishMaybe(stream, state);
  13277. });
  13278. }
  13279. function prefinish(stream, state) {
  13280. if (!state.prefinished && !state.finalCalled) {
  13281. if (typeof stream._final === 'function') {
  13282. state.pendingcb++;
  13283. state.finalCalled = true;
  13284. pna.nextTick(callFinal, stream, state);
  13285. } else {
  13286. state.prefinished = true;
  13287. stream.emit('prefinish');
  13288. }
  13289. }
  13290. }
  13291. function finishMaybe(stream, state) {
  13292. var need = needFinish(state);
  13293. if (need) {
  13294. prefinish(stream, state);
  13295. if (state.pendingcb === 0) {
  13296. state.finished = true;
  13297. stream.emit('finish');
  13298. }
  13299. }
  13300. return need;
  13301. }
  13302. function endWritable(stream, state, cb) {
  13303. state.ending = true;
  13304. finishMaybe(stream, state);
  13305. if (cb) {
  13306. if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
  13307. }
  13308. state.ended = true;
  13309. stream.writable = false;
  13310. }
  13311. function onCorkedFinish(corkReq, state, err) {
  13312. var entry = corkReq.entry;
  13313. corkReq.entry = null;
  13314. while (entry) {
  13315. var cb = entry.callback;
  13316. state.pendingcb--;
  13317. cb(err);
  13318. entry = entry.next;
  13319. }
  13320. if (state.corkedRequestsFree) {
  13321. state.corkedRequestsFree.next = corkReq;
  13322. } else {
  13323. state.corkedRequestsFree = corkReq;
  13324. }
  13325. }
  13326. Object.defineProperty(Writable.prototype, 'destroyed', {
  13327. get: function () {
  13328. if (this._writableState === undefined) {
  13329. return false;
  13330. }
  13331. return this._writableState.destroyed;
  13332. },
  13333. set: function (value) {
  13334. // we ignore the value if the stream
  13335. // has not been initialized yet
  13336. if (!this._writableState) {
  13337. return;
  13338. }
  13339. // backward compatibility, the user is explicitly
  13340. // managing destroyed
  13341. this._writableState.destroyed = value;
  13342. }
  13343. });
  13344. Writable.prototype.destroy = destroyImpl.destroy;
  13345. Writable.prototype._undestroy = destroyImpl.undestroy;
  13346. Writable.prototype._destroy = function (err, cb) {
  13347. this.end();
  13348. cb(err);
  13349. };
  13350. }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
  13351. },{"./_stream_duplex":81,"./internal/streams/destroy":87,"./internal/streams/stream":88,"_process":79,"core-util-is":13,"inherits":47,"process-nextick-args":78,"safe-buffer":89,"timers":111,"util-deprecate":112}],86:[function(require,module,exports){
  13352. 'use strict';
  13353. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13354. var Buffer = require('safe-buffer').Buffer;
  13355. var util = require('util');
  13356. function copyBuffer(src, target, offset) {
  13357. src.copy(target, offset);
  13358. }
  13359. module.exports = function () {
  13360. function BufferList() {
  13361. _classCallCheck(this, BufferList);
  13362. this.head = null;
  13363. this.tail = null;
  13364. this.length = 0;
  13365. }
  13366. BufferList.prototype.push = function push(v) {
  13367. var entry = { data: v, next: null };
  13368. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  13369. this.tail = entry;
  13370. ++this.length;
  13371. };
  13372. BufferList.prototype.unshift = function unshift(v) {
  13373. var entry = { data: v, next: this.head };
  13374. if (this.length === 0) this.tail = entry;
  13375. this.head = entry;
  13376. ++this.length;
  13377. };
  13378. BufferList.prototype.shift = function shift() {
  13379. if (this.length === 0) return;
  13380. var ret = this.head.data;
  13381. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  13382. --this.length;
  13383. return ret;
  13384. };
  13385. BufferList.prototype.clear = function clear() {
  13386. this.head = this.tail = null;
  13387. this.length = 0;
  13388. };
  13389. BufferList.prototype.join = function join(s) {
  13390. if (this.length === 0) return '';
  13391. var p = this.head;
  13392. var ret = '' + p.data;
  13393. while (p = p.next) {
  13394. ret += s + p.data;
  13395. }return ret;
  13396. };
  13397. BufferList.prototype.concat = function concat(n) {
  13398. if (this.length === 0) return Buffer.alloc(0);
  13399. if (this.length === 1) return this.head.data;
  13400. var ret = Buffer.allocUnsafe(n >>> 0);
  13401. var p = this.head;
  13402. var i = 0;
  13403. while (p) {
  13404. copyBuffer(p.data, ret, i);
  13405. i += p.data.length;
  13406. p = p.next;
  13407. }
  13408. return ret;
  13409. };
  13410. return BufferList;
  13411. }();
  13412. if (util && util.inspect && util.inspect.custom) {
  13413. module.exports.prototype[util.inspect.custom] = function () {
  13414. var obj = util.inspect({ length: this.length });
  13415. return this.constructor.name + ' ' + obj;
  13416. };
  13417. }
  13418. },{"safe-buffer":89,"util":9}],87:[function(require,module,exports){
  13419. 'use strict';
  13420. /*<replacement>*/
  13421. var pna = require('process-nextick-args');
  13422. /*</replacement>*/
  13423. // undocumented cb() API, needed for core, not for public API
  13424. function destroy(err, cb) {
  13425. var _this = this;
  13426. var readableDestroyed = this._readableState && this._readableState.destroyed;
  13427. var writableDestroyed = this._writableState && this._writableState.destroyed;
  13428. if (readableDestroyed || writableDestroyed) {
  13429. if (cb) {
  13430. cb(err);
  13431. } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
  13432. pna.nextTick(emitErrorNT, this, err);
  13433. }
  13434. return this;
  13435. }
  13436. // we set destroyed to true before firing error callbacks in order
  13437. // to make it re-entrance safe in case destroy() is called within callbacks
  13438. if (this._readableState) {
  13439. this._readableState.destroyed = true;
  13440. }
  13441. // if this is a duplex stream mark the writable part as destroyed as well
  13442. if (this._writableState) {
  13443. this._writableState.destroyed = true;
  13444. }
  13445. this._destroy(err || null, function (err) {
  13446. if (!cb && err) {
  13447. pna.nextTick(emitErrorNT, _this, err);
  13448. if (_this._writableState) {
  13449. _this._writableState.errorEmitted = true;
  13450. }
  13451. } else if (cb) {
  13452. cb(err);
  13453. }
  13454. });
  13455. return this;
  13456. }
  13457. function undestroy() {
  13458. if (this._readableState) {
  13459. this._readableState.destroyed = false;
  13460. this._readableState.reading = false;
  13461. this._readableState.ended = false;
  13462. this._readableState.endEmitted = false;
  13463. }
  13464. if (this._writableState) {
  13465. this._writableState.destroyed = false;
  13466. this._writableState.ended = false;
  13467. this._writableState.ending = false;
  13468. this._writableState.finished = false;
  13469. this._writableState.errorEmitted = false;
  13470. }
  13471. }
  13472. function emitErrorNT(self, err) {
  13473. self.emit('error', err);
  13474. }
  13475. module.exports = {
  13476. destroy: destroy,
  13477. undestroy: undestroy
  13478. };
  13479. },{"process-nextick-args":78}],88:[function(require,module,exports){
  13480. module.exports = require('events').EventEmitter;
  13481. },{"events":33}],89:[function(require,module,exports){
  13482. /* eslint-disable node/no-deprecated-api */
  13483. var buffer = require('buffer')
  13484. var Buffer = buffer.Buffer
  13485. // alternative to using Object.keys for old browsers
  13486. function copyProps (src, dst) {
  13487. for (var key in src) {
  13488. dst[key] = src[key]
  13489. }
  13490. }
  13491. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  13492. module.exports = buffer
  13493. } else {
  13494. // Copy properties from require('buffer')
  13495. copyProps(buffer, exports)
  13496. exports.Buffer = SafeBuffer
  13497. }
  13498. function SafeBuffer (arg, encodingOrOffset, length) {
  13499. return Buffer(arg, encodingOrOffset, length)
  13500. }
  13501. // Copy static methods from Buffer
  13502. copyProps(Buffer, SafeBuffer)
  13503. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  13504. if (typeof arg === 'number') {
  13505. throw new TypeError('Argument must not be a number')
  13506. }
  13507. return Buffer(arg, encodingOrOffset, length)
  13508. }
  13509. SafeBuffer.alloc = function (size, fill, encoding) {
  13510. if (typeof size !== 'number') {
  13511. throw new TypeError('Argument must be a number')
  13512. }
  13513. var buf = Buffer(size)
  13514. if (fill !== undefined) {
  13515. if (typeof encoding === 'string') {
  13516. buf.fill(fill, encoding)
  13517. } else {
  13518. buf.fill(fill)
  13519. }
  13520. } else {
  13521. buf.fill(0)
  13522. }
  13523. return buf
  13524. }
  13525. SafeBuffer.allocUnsafe = function (size) {
  13526. if (typeof size !== 'number') {
  13527. throw new TypeError('Argument must be a number')
  13528. }
  13529. return Buffer(size)
  13530. }
  13531. SafeBuffer.allocUnsafeSlow = function (size) {
  13532. if (typeof size !== 'number') {
  13533. throw new TypeError('Argument must be a number')
  13534. }
  13535. return buffer.SlowBuffer(size)
  13536. }
  13537. },{"buffer":10}],90:[function(require,module,exports){
  13538. // Copyright Joyent, Inc. and other Node contributors.
  13539. //
  13540. // Permission is hereby granted, free of charge, to any person obtaining a
  13541. // copy of this software and associated documentation files (the
  13542. // "Software"), to deal in the Software without restriction, including
  13543. // without limitation the rights to use, copy, modify, merge, publish,
  13544. // distribute, sublicense, and/or sell copies of the Software, and to permit
  13545. // persons to whom the Software is furnished to do so, subject to the
  13546. // following conditions:
  13547. //
  13548. // The above copyright notice and this permission notice shall be included
  13549. // in all copies or substantial portions of the Software.
  13550. //
  13551. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13552. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13553. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  13554. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  13555. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  13556. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  13557. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  13558. 'use strict';
  13559. /*<replacement>*/
  13560. var Buffer = require('safe-buffer').Buffer;
  13561. /*</replacement>*/
  13562. var isEncoding = Buffer.isEncoding || function (encoding) {
  13563. encoding = '' + encoding;
  13564. switch (encoding && encoding.toLowerCase()) {
  13565. case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
  13566. return true;
  13567. default:
  13568. return false;
  13569. }
  13570. };
  13571. function _normalizeEncoding(enc) {
  13572. if (!enc) return 'utf8';
  13573. var retried;
  13574. while (true) {
  13575. switch (enc) {
  13576. case 'utf8':
  13577. case 'utf-8':
  13578. return 'utf8';
  13579. case 'ucs2':
  13580. case 'ucs-2':
  13581. case 'utf16le':
  13582. case 'utf-16le':
  13583. return 'utf16le';
  13584. case 'latin1':
  13585. case 'binary':
  13586. return 'latin1';
  13587. case 'base64':
  13588. case 'ascii':
  13589. case 'hex':
  13590. return enc;
  13591. default:
  13592. if (retried) return; // undefined
  13593. enc = ('' + enc).toLowerCase();
  13594. retried = true;
  13595. }
  13596. }
  13597. };
  13598. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  13599. // modules monkey-patch it to support additional encodings
  13600. function normalizeEncoding(enc) {
  13601. var nenc = _normalizeEncoding(enc);
  13602. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  13603. return nenc || enc;
  13604. }
  13605. // StringDecoder provides an interface for efficiently splitting a series of
  13606. // buffers into a series of JS strings without breaking apart multi-byte
  13607. // characters.
  13608. exports.StringDecoder = StringDecoder;
  13609. function StringDecoder(encoding) {
  13610. this.encoding = normalizeEncoding(encoding);
  13611. var nb;
  13612. switch (this.encoding) {
  13613. case 'utf16le':
  13614. this.text = utf16Text;
  13615. this.end = utf16End;
  13616. nb = 4;
  13617. break;
  13618. case 'utf8':
  13619. this.fillLast = utf8FillLast;
  13620. nb = 4;
  13621. break;
  13622. case 'base64':
  13623. this.text = base64Text;
  13624. this.end = base64End;
  13625. nb = 3;
  13626. break;
  13627. default:
  13628. this.write = simpleWrite;
  13629. this.end = simpleEnd;
  13630. return;
  13631. }
  13632. this.lastNeed = 0;
  13633. this.lastTotal = 0;
  13634. this.lastChar = Buffer.allocUnsafe(nb);
  13635. }
  13636. StringDecoder.prototype.write = function (buf) {
  13637. if (buf.length === 0) return '';
  13638. var r;
  13639. var i;
  13640. if (this.lastNeed) {
  13641. r = this.fillLast(buf);
  13642. if (r === undefined) return '';
  13643. i = this.lastNeed;
  13644. this.lastNeed = 0;
  13645. } else {
  13646. i = 0;
  13647. }
  13648. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  13649. return r || '';
  13650. };
  13651. StringDecoder.prototype.end = utf8End;
  13652. // Returns only complete characters in a Buffer
  13653. StringDecoder.prototype.text = utf8Text;
  13654. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  13655. StringDecoder.prototype.fillLast = function (buf) {
  13656. if (this.lastNeed <= buf.length) {
  13657. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  13658. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  13659. }
  13660. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  13661. this.lastNeed -= buf.length;
  13662. };
  13663. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  13664. // continuation byte. If an invalid byte is detected, -2 is returned.
  13665. function utf8CheckByte(byte) {
  13666. if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
  13667. return byte >> 6 === 0x02 ? -1 : -2;
  13668. }
  13669. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  13670. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  13671. // needed to complete the UTF-8 character (if applicable) are returned.
  13672. function utf8CheckIncomplete(self, buf, i) {
  13673. var j = buf.length - 1;
  13674. if (j < i) return 0;
  13675. var nb = utf8CheckByte(buf[j]);
  13676. if (nb >= 0) {
  13677. if (nb > 0) self.lastNeed = nb - 1;
  13678. return nb;
  13679. }
  13680. if (--j < i || nb === -2) return 0;
  13681. nb = utf8CheckByte(buf[j]);
  13682. if (nb >= 0) {
  13683. if (nb > 0) self.lastNeed = nb - 2;
  13684. return nb;
  13685. }
  13686. if (--j < i || nb === -2) return 0;
  13687. nb = utf8CheckByte(buf[j]);
  13688. if (nb >= 0) {
  13689. if (nb > 0) {
  13690. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  13691. }
  13692. return nb;
  13693. }
  13694. return 0;
  13695. }
  13696. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  13697. // needed or are available. If we see a non-continuation byte where we expect
  13698. // one, we "replace" the validated continuation bytes we've seen so far with
  13699. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  13700. // behavior. The continuation byte check is included three times in the case
  13701. // where all of the continuation bytes for a character exist in the same buffer.
  13702. // It is also done this way as a slight performance increase instead of using a
  13703. // loop.
  13704. function utf8CheckExtraBytes(self, buf, p) {
  13705. if ((buf[0] & 0xC0) !== 0x80) {
  13706. self.lastNeed = 0;
  13707. return '\ufffd';
  13708. }
  13709. if (self.lastNeed > 1 && buf.length > 1) {
  13710. if ((buf[1] & 0xC0) !== 0x80) {
  13711. self.lastNeed = 1;
  13712. return '\ufffd';
  13713. }
  13714. if (self.lastNeed > 2 && buf.length > 2) {
  13715. if ((buf[2] & 0xC0) !== 0x80) {
  13716. self.lastNeed = 2;
  13717. return '\ufffd';
  13718. }
  13719. }
  13720. }
  13721. }
  13722. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  13723. function utf8FillLast(buf) {
  13724. var p = this.lastTotal - this.lastNeed;
  13725. var r = utf8CheckExtraBytes(this, buf, p);
  13726. if (r !== undefined) return r;
  13727. if (this.lastNeed <= buf.length) {
  13728. buf.copy(this.lastChar, p, 0, this.lastNeed);
  13729. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  13730. }
  13731. buf.copy(this.lastChar, p, 0, buf.length);
  13732. this.lastNeed -= buf.length;
  13733. }
  13734. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  13735. // partial character, the character's bytes are buffered until the required
  13736. // number of bytes are available.
  13737. function utf8Text(buf, i) {
  13738. var total = utf8CheckIncomplete(this, buf, i);
  13739. if (!this.lastNeed) return buf.toString('utf8', i);
  13740. this.lastTotal = total;
  13741. var end = buf.length - (total - this.lastNeed);
  13742. buf.copy(this.lastChar, 0, end);
  13743. return buf.toString('utf8', i, end);
  13744. }
  13745. // For UTF-8, a replacement character is added when ending on a partial
  13746. // character.
  13747. function utf8End(buf) {
  13748. var r = buf && buf.length ? this.write(buf) : '';
  13749. if (this.lastNeed) return r + '\ufffd';
  13750. return r;
  13751. }
  13752. // UTF-16LE typically needs two bytes per character, but even if we have an even
  13753. // number of bytes available, we need to check if we end on a leading/high
  13754. // surrogate. In that case, we need to wait for the next two bytes in order to
  13755. // decode the last character properly.
  13756. function utf16Text(buf, i) {
  13757. if ((buf.length - i) % 2 === 0) {
  13758. var r = buf.toString('utf16le', i);
  13759. if (r) {
  13760. var c = r.charCodeAt(r.length - 1);
  13761. if (c >= 0xD800 && c <= 0xDBFF) {
  13762. this.lastNeed = 2;
  13763. this.lastTotal = 4;
  13764. this.lastChar[0] = buf[buf.length - 2];
  13765. this.lastChar[1] = buf[buf.length - 1];
  13766. return r.slice(0, -1);
  13767. }
  13768. }
  13769. return r;
  13770. }
  13771. this.lastNeed = 1;
  13772. this.lastTotal = 2;
  13773. this.lastChar[0] = buf[buf.length - 1];
  13774. return buf.toString('utf16le', i, buf.length - 1);
  13775. }
  13776. // For UTF-16LE we do not explicitly append special replacement characters if we
  13777. // end on a partial character, we simply let v8 handle that.
  13778. function utf16End(buf) {
  13779. var r = buf && buf.length ? this.write(buf) : '';
  13780. if (this.lastNeed) {
  13781. var end = this.lastTotal - this.lastNeed;
  13782. return r + this.lastChar.toString('utf16le', 0, end);
  13783. }
  13784. return r;
  13785. }
  13786. function base64Text(buf, i) {
  13787. var n = (buf.length - i) % 3;
  13788. if (n === 0) return buf.toString('base64', i);
  13789. this.lastNeed = 3 - n;
  13790. this.lastTotal = 3;
  13791. if (n === 1) {
  13792. this.lastChar[0] = buf[buf.length - 1];
  13793. } else {
  13794. this.lastChar[0] = buf[buf.length - 2];
  13795. this.lastChar[1] = buf[buf.length - 1];
  13796. }
  13797. return buf.toString('base64', i, buf.length - n);
  13798. }
  13799. function base64End(buf) {
  13800. var r = buf && buf.length ? this.write(buf) : '';
  13801. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  13802. return r;
  13803. }
  13804. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  13805. function simpleWrite(buf) {
  13806. return buf.toString(this.encoding);
  13807. }
  13808. function simpleEnd(buf) {
  13809. return buf && buf.length ? this.write(buf) : '';
  13810. }
  13811. },{"safe-buffer":89}],91:[function(require,module,exports){
  13812. module.exports = require('./readable').PassThrough
  13813. },{"./readable":92}],92:[function(require,module,exports){
  13814. exports = module.exports = require('./lib/_stream_readable.js');
  13815. exports.Stream = exports;
  13816. exports.Readable = exports;
  13817. exports.Writable = require('./lib/_stream_writable.js');
  13818. exports.Duplex = require('./lib/_stream_duplex.js');
  13819. exports.Transform = require('./lib/_stream_transform.js');
  13820. exports.PassThrough = require('./lib/_stream_passthrough.js');
  13821. },{"./lib/_stream_duplex.js":81,"./lib/_stream_passthrough.js":82,"./lib/_stream_readable.js":83,"./lib/_stream_transform.js":84,"./lib/_stream_writable.js":85}],93:[function(require,module,exports){
  13822. module.exports = require('./readable').Transform
  13823. },{"./readable":92}],94:[function(require,module,exports){
  13824. module.exports = require('./lib/_stream_writable.js');
  13825. },{"./lib/_stream_writable.js":85}],95:[function(require,module,exports){
  13826. 'use strict';
  13827. var $Object = Object;
  13828. var $TypeError = TypeError;
  13829. module.exports = function flags() {
  13830. if (this != null && this !== $Object(this)) {
  13831. throw new $TypeError('RegExp.prototype.flags getter called on non-object');
  13832. }
  13833. var result = '';
  13834. if (this.global) {
  13835. result += 'g';
  13836. }
  13837. if (this.ignoreCase) {
  13838. result += 'i';
  13839. }
  13840. if (this.multiline) {
  13841. result += 'm';
  13842. }
  13843. if (this.dotAll) {
  13844. result += 's';
  13845. }
  13846. if (this.unicode) {
  13847. result += 'u';
  13848. }
  13849. if (this.sticky) {
  13850. result += 'y';
  13851. }
  13852. return result;
  13853. };
  13854. },{}],96:[function(require,module,exports){
  13855. 'use strict';
  13856. var define = require('define-properties');
  13857. var callBind = require('call-bind');
  13858. var implementation = require('./implementation');
  13859. var getPolyfill = require('./polyfill');
  13860. var shim = require('./shim');
  13861. var flagsBound = callBind(implementation);
  13862. define(flagsBound, {
  13863. getPolyfill: getPolyfill,
  13864. implementation: implementation,
  13865. shim: shim
  13866. });
  13867. module.exports = flagsBound;
  13868. },{"./implementation":95,"./polyfill":97,"./shim":98,"call-bind":12,"define-properties":16}],97:[function(require,module,exports){
  13869. 'use strict';
  13870. var implementation = require('./implementation');
  13871. var supportsDescriptors = require('define-properties').supportsDescriptors;
  13872. var $gOPD = Object.getOwnPropertyDescriptor;
  13873. var $TypeError = TypeError;
  13874. module.exports = function getPolyfill() {
  13875. if (!supportsDescriptors) {
  13876. throw new $TypeError('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
  13877. }
  13878. if ((/a/mig).flags === 'gim') {
  13879. var descriptor = $gOPD(RegExp.prototype, 'flags');
  13880. if (descriptor && typeof descriptor.get === 'function' && typeof (/a/).dotAll === 'boolean') {
  13881. return descriptor.get;
  13882. }
  13883. }
  13884. return implementation;
  13885. };
  13886. },{"./implementation":95,"define-properties":16}],98:[function(require,module,exports){
  13887. 'use strict';
  13888. var supportsDescriptors = require('define-properties').supportsDescriptors;
  13889. var getPolyfill = require('./polyfill');
  13890. var gOPD = Object.getOwnPropertyDescriptor;
  13891. var defineProperty = Object.defineProperty;
  13892. var TypeErr = TypeError;
  13893. var getProto = Object.getPrototypeOf;
  13894. var regex = /a/;
  13895. module.exports = function shimFlags() {
  13896. if (!supportsDescriptors || !getProto) {
  13897. throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
  13898. }
  13899. var polyfill = getPolyfill();
  13900. var proto = getProto(regex);
  13901. var descriptor = gOPD(proto, 'flags');
  13902. if (!descriptor || descriptor.get !== polyfill) {
  13903. defineProperty(proto, 'flags', {
  13904. configurable: true,
  13905. enumerable: false,
  13906. get: polyfill
  13907. });
  13908. }
  13909. return polyfill;
  13910. };
  13911. },{"./polyfill":97,"define-properties":16}],99:[function(require,module,exports){
  13912. (function (process,setImmediate){(function (){
  13913. var through = require('through');
  13914. var nextTick = typeof setImmediate !== 'undefined'
  13915. ? setImmediate
  13916. : process.nextTick
  13917. ;
  13918. module.exports = function (write, end) {
  13919. var tr = through(write, end);
  13920. tr.pause();
  13921. var resume = tr.resume;
  13922. var pause = tr.pause;
  13923. var paused = false;
  13924. tr.pause = function () {
  13925. paused = true;
  13926. return pause.apply(this, arguments);
  13927. };
  13928. tr.resume = function () {
  13929. paused = false;
  13930. return resume.apply(this, arguments);
  13931. };
  13932. nextTick(function () {
  13933. if (!paused) tr.resume();
  13934. });
  13935. return tr;
  13936. };
  13937. }).call(this)}).call(this,require('_process'),require("timers").setImmediate)
  13938. },{"_process":79,"through":110,"timers":111}],100:[function(require,module,exports){
  13939. 'use strict';
  13940. var GetIntrinsic = require('get-intrinsic');
  13941. var callBound = require('call-bind/callBound');
  13942. var inspect = require('object-inspect');
  13943. var $TypeError = GetIntrinsic('%TypeError%');
  13944. var $WeakMap = GetIntrinsic('%WeakMap%', true);
  13945. var $Map = GetIntrinsic('%Map%', true);
  13946. var $weakMapGet = callBound('WeakMap.prototype.get', true);
  13947. var $weakMapSet = callBound('WeakMap.prototype.set', true);
  13948. var $weakMapHas = callBound('WeakMap.prototype.has', true);
  13949. var $mapGet = callBound('Map.prototype.get', true);
  13950. var $mapSet = callBound('Map.prototype.set', true);
  13951. var $mapHas = callBound('Map.prototype.has', true);
  13952. /*
  13953. * This function traverses the list returning the node corresponding to the
  13954. * given key.
  13955. *
  13956. * That node is also moved to the head of the list, so that if it's accessed
  13957. * again we don't need to traverse the whole list. By doing so, all the recently
  13958. * used nodes can be accessed relatively quickly.
  13959. */
  13960. var listGetNode = function (list, key) { // eslint-disable-line consistent-return
  13961. for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
  13962. if (curr.key === key) {
  13963. prev.next = curr.next;
  13964. curr.next = list.next;
  13965. list.next = curr; // eslint-disable-line no-param-reassign
  13966. return curr;
  13967. }
  13968. }
  13969. };
  13970. var listGet = function (objects, key) {
  13971. var node = listGetNode(objects, key);
  13972. return node && node.value;
  13973. };
  13974. var listSet = function (objects, key, value) {
  13975. var node = listGetNode(objects, key);
  13976. if (node) {
  13977. node.value = value;
  13978. } else {
  13979. // Prepend the new node to the beginning of the list
  13980. objects.next = { // eslint-disable-line no-param-reassign
  13981. key: key,
  13982. next: objects.next,
  13983. value: value
  13984. };
  13985. }
  13986. };
  13987. var listHas = function (objects, key) {
  13988. return !!listGetNode(objects, key);
  13989. };
  13990. module.exports = function getSideChannel() {
  13991. var $wm;
  13992. var $m;
  13993. var $o;
  13994. var channel = {
  13995. assert: function (key) {
  13996. if (!channel.has(key)) {
  13997. throw new $TypeError('Side channel does not contain ' + inspect(key));
  13998. }
  13999. },
  14000. get: function (key) { // eslint-disable-line consistent-return
  14001. if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
  14002. if ($wm) {
  14003. return $weakMapGet($wm, key);
  14004. }
  14005. } else if ($Map) {
  14006. if ($m) {
  14007. return $mapGet($m, key);
  14008. }
  14009. } else {
  14010. if ($o) { // eslint-disable-line no-lonely-if
  14011. return listGet($o, key);
  14012. }
  14013. }
  14014. },
  14015. has: function (key) {
  14016. if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
  14017. if ($wm) {
  14018. return $weakMapHas($wm, key);
  14019. }
  14020. } else if ($Map) {
  14021. if ($m) {
  14022. return $mapHas($m, key);
  14023. }
  14024. } else {
  14025. if ($o) { // eslint-disable-line no-lonely-if
  14026. return listHas($o, key);
  14027. }
  14028. }
  14029. return false;
  14030. },
  14031. set: function (key, value) {
  14032. if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
  14033. if (!$wm) {
  14034. $wm = new $WeakMap();
  14035. }
  14036. $weakMapSet($wm, key, value);
  14037. } else if ($Map) {
  14038. if (!$m) {
  14039. $m = new $Map();
  14040. }
  14041. $mapSet($m, key, value);
  14042. } else {
  14043. if (!$o) {
  14044. /*
  14045. * Initialize the linked list as an empty node, so that we don't have
  14046. * to special-case handling of the first node: we can always refer to
  14047. * it as (previous node).next, instead of something like (list).head
  14048. */
  14049. $o = { key: {}, next: null };
  14050. }
  14051. listSet($o, key, value);
  14052. }
  14053. }
  14054. };
  14055. return channel;
  14056. };
  14057. },{"call-bind/callBound":11,"get-intrinsic":39,"object-inspect":65}],101:[function(require,module,exports){
  14058. // Copyright Joyent, Inc. and other Node contributors.
  14059. //
  14060. // Permission is hereby granted, free of charge, to any person obtaining a
  14061. // copy of this software and associated documentation files (the
  14062. // "Software"), to deal in the Software without restriction, including
  14063. // without limitation the rights to use, copy, modify, merge, publish,
  14064. // distribute, sublicense, and/or sell copies of the Software, and to permit
  14065. // persons to whom the Software is furnished to do so, subject to the
  14066. // following conditions:
  14067. //
  14068. // The above copyright notice and this permission notice shall be included
  14069. // in all copies or substantial portions of the Software.
  14070. //
  14071. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14072. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14073. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  14074. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14075. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  14076. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  14077. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  14078. module.exports = Stream;
  14079. var EE = require('events').EventEmitter;
  14080. var inherits = require('inherits');
  14081. inherits(Stream, EE);
  14082. Stream.Readable = require('readable-stream/readable.js');
  14083. Stream.Writable = require('readable-stream/writable.js');
  14084. Stream.Duplex = require('readable-stream/duplex.js');
  14085. Stream.Transform = require('readable-stream/transform.js');
  14086. Stream.PassThrough = require('readable-stream/passthrough.js');
  14087. // Backwards-compat with node 0.4.x
  14088. Stream.Stream = Stream;
  14089. // old-style streams. Note that the pipe method (the only relevant
  14090. // part of this class) is overridden in the Readable class.
  14091. function Stream() {
  14092. EE.call(this);
  14093. }
  14094. Stream.prototype.pipe = function(dest, options) {
  14095. var source = this;
  14096. function ondata(chunk) {
  14097. if (dest.writable) {
  14098. if (false === dest.write(chunk) && source.pause) {
  14099. source.pause();
  14100. }
  14101. }
  14102. }
  14103. source.on('data', ondata);
  14104. function ondrain() {
  14105. if (source.readable && source.resume) {
  14106. source.resume();
  14107. }
  14108. }
  14109. dest.on('drain', ondrain);
  14110. // If the 'end' option is not supplied, dest.end() will be called when
  14111. // source gets the 'end' or 'close' events. Only dest.end() once.
  14112. if (!dest._isStdio && (!options || options.end !== false)) {
  14113. source.on('end', onend);
  14114. source.on('close', onclose);
  14115. }
  14116. var didOnEnd = false;
  14117. function onend() {
  14118. if (didOnEnd) return;
  14119. didOnEnd = true;
  14120. dest.end();
  14121. }
  14122. function onclose() {
  14123. if (didOnEnd) return;
  14124. didOnEnd = true;
  14125. if (typeof dest.destroy === 'function') dest.destroy();
  14126. }
  14127. // don't leave dangling pipes when there are errors.
  14128. function onerror(er) {
  14129. cleanup();
  14130. if (EE.listenerCount(this, 'error') === 0) {
  14131. throw er; // Unhandled stream error in pipe.
  14132. }
  14133. }
  14134. source.on('error', onerror);
  14135. dest.on('error', onerror);
  14136. // remove all the event listeners that were added.
  14137. function cleanup() {
  14138. source.removeListener('data', ondata);
  14139. dest.removeListener('drain', ondrain);
  14140. source.removeListener('end', onend);
  14141. source.removeListener('close', onclose);
  14142. source.removeListener('error', onerror);
  14143. dest.removeListener('error', onerror);
  14144. source.removeListener('end', cleanup);
  14145. source.removeListener('close', cleanup);
  14146. dest.removeListener('close', cleanup);
  14147. }
  14148. source.on('end', cleanup);
  14149. source.on('close', cleanup);
  14150. dest.on('close', cleanup);
  14151. dest.emit('pipe', source);
  14152. // Allow for unix-like usage: A.pipe(B).pipe(C)
  14153. return dest;
  14154. };
  14155. },{"events":33,"inherits":47,"readable-stream/duplex.js":80,"readable-stream/passthrough.js":91,"readable-stream/readable.js":92,"readable-stream/transform.js":93,"readable-stream/writable.js":94}],102:[function(require,module,exports){
  14156. 'use strict';
  14157. var RequireObjectCoercible = require('es-abstract/2021/RequireObjectCoercible');
  14158. var ToString = require('es-abstract/2021/ToString');
  14159. var callBound = require('call-bind/callBound');
  14160. var $replace = callBound('String.prototype.replace');
  14161. /* eslint-disable no-control-regex */
  14162. var leftWhitespace = /^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/;
  14163. var rightWhitespace = /[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/;
  14164. /* eslint-enable no-control-regex */
  14165. module.exports = function trim() {
  14166. var S = ToString(RequireObjectCoercible(this));
  14167. return $replace($replace(S, leftWhitespace, ''), rightWhitespace, '');
  14168. };
  14169. },{"call-bind/callBound":11,"es-abstract/2021/RequireObjectCoercible":19,"es-abstract/2021/ToString":23}],103:[function(require,module,exports){
  14170. 'use strict';
  14171. var callBind = require('call-bind');
  14172. var define = require('define-properties');
  14173. var implementation = require('./implementation');
  14174. var getPolyfill = require('./polyfill');
  14175. var shim = require('./shim');
  14176. var boundTrim = callBind(getPolyfill());
  14177. define(boundTrim, {
  14178. getPolyfill: getPolyfill,
  14179. implementation: implementation,
  14180. shim: shim
  14181. });
  14182. module.exports = boundTrim;
  14183. },{"./implementation":102,"./polyfill":104,"./shim":105,"call-bind":12,"define-properties":16}],104:[function(require,module,exports){
  14184. 'use strict';
  14185. var implementation = require('./implementation');
  14186. var zeroWidthSpace = '\u200b';
  14187. module.exports = function getPolyfill() {
  14188. if (String.prototype.trim && zeroWidthSpace.trim() === zeroWidthSpace) {
  14189. return String.prototype.trim;
  14190. }
  14191. return implementation;
  14192. };
  14193. },{"./implementation":102}],105:[function(require,module,exports){
  14194. 'use strict';
  14195. var define = require('define-properties');
  14196. var getPolyfill = require('./polyfill');
  14197. module.exports = function shimStringTrim() {
  14198. var polyfill = getPolyfill();
  14199. define(String.prototype, { trim: polyfill }, {
  14200. trim: function testTrim() {
  14201. return String.prototype.trim !== polyfill;
  14202. }
  14203. });
  14204. return polyfill;
  14205. };
  14206. },{"./polyfill":104,"define-properties":16}],106:[function(require,module,exports){
  14207. (function (process){(function (){
  14208. 'use strict';
  14209. var defined = require('defined');
  14210. var createDefaultStream = require('./lib/default_stream');
  14211. var Test = require('./lib/test');
  14212. var createResult = require('./lib/results');
  14213. var through = require('through');
  14214. var canEmitExit = typeof process !== 'undefined' && process
  14215. && typeof process.on === 'function' && process.browser !== true;
  14216. var canExit = typeof process !== 'undefined' && process
  14217. && typeof process.exit === 'function';
  14218. module.exports = (function () {
  14219. var wait = false;
  14220. var harness;
  14221. var lazyLoad = function () {
  14222. // eslint-disable-next-line no-invalid-this
  14223. return getHarness().apply(this, arguments);
  14224. };
  14225. lazyLoad.wait = function () {
  14226. wait = true;
  14227. };
  14228. lazyLoad.run = function () {
  14229. var run = getHarness().run;
  14230. if (run) { run(); }
  14231. };
  14232. lazyLoad.only = function () {
  14233. return getHarness().only.apply(this, arguments);
  14234. };
  14235. lazyLoad.createStream = function (opts) {
  14236. var options = opts || {};
  14237. if (!harness) {
  14238. var output = through();
  14239. getHarness({ stream: output, objectMode: options.objectMode });
  14240. return output;
  14241. }
  14242. return harness.createStream(options);
  14243. };
  14244. lazyLoad.onFinish = function () {
  14245. return getHarness().onFinish.apply(this, arguments);
  14246. };
  14247. lazyLoad.onFailure = function () {
  14248. return getHarness().onFailure.apply(this, arguments);
  14249. };
  14250. lazyLoad.getHarness = getHarness;
  14251. return lazyLoad;
  14252. function getHarness(opts) {
  14253. if (!opts) { opts = {}; }
  14254. opts.autoclose = !canEmitExit;
  14255. if (!harness) { harness = createExitHarness(opts, wait); }
  14256. return harness;
  14257. }
  14258. }());
  14259. function createExitHarness(conf, wait) {
  14260. var config = conf || {};
  14261. var harness = createHarness({
  14262. autoclose: defined(config.autoclose, false),
  14263. noOnly: defined(conf.noOnly, defined(process.env.NODE_TAPE_NO_ONLY_TEST, false))
  14264. });
  14265. var running = false;
  14266. var ended = false;
  14267. if (wait) {
  14268. harness.run = run;
  14269. } else {
  14270. run();
  14271. }
  14272. if (config.exit === false) { return harness; }
  14273. if (!canEmitExit || !canExit) { return harness; }
  14274. process.on('exit', function (code) {
  14275. // let the process exit cleanly.
  14276. if (typeof code === 'number' && code !== 0) {
  14277. return;
  14278. }
  14279. if (!ended) {
  14280. var only = harness._results._only;
  14281. for (var i = 0; i < harness._tests.length; i++) {
  14282. var t = harness._tests[i];
  14283. if (!only || t === only) {
  14284. t._exit();
  14285. }
  14286. }
  14287. }
  14288. harness.close();
  14289. process.removeAllListeners('exit'); // necessary for node v0.6
  14290. process.exit(code || harness._exitCode); // eslint-disable-line no-process-exit
  14291. });
  14292. return harness;
  14293. function run() {
  14294. if (running) { return; }
  14295. running = true;
  14296. var stream = harness.createStream({ objectMode: config.objectMode });
  14297. var es = stream.pipe(config.stream || createDefaultStream());
  14298. if (canEmitExit) {
  14299. // TODO: use `err` arg?
  14300. // eslint-disable-next-line no-unused-vars
  14301. es.on('error', function (err) { harness._exitCode = 1; });
  14302. }
  14303. stream.on('end', function () { ended = true; });
  14304. }
  14305. }
  14306. module.exports.createHarness = createHarness;
  14307. module.exports.Test = Test;
  14308. module.exports.test = module.exports; // tap compat
  14309. module.exports.test.skip = Test.skip;
  14310. function createHarness(conf_) {
  14311. var results = createResult();
  14312. if (!conf_ || conf_.autoclose !== false) {
  14313. results.once('done', function () { results.close(); });
  14314. }
  14315. var test = function (name, conf, cb) {
  14316. var t = new Test(name, conf, cb);
  14317. test._tests.push(t);
  14318. (function inspectCode(st) {
  14319. st.on('test', function sub(st_) {
  14320. inspectCode(st_);
  14321. });
  14322. st.on('result', function (r) {
  14323. if (!r.todo && !r.ok && typeof r !== 'string') { test._exitCode = 1; }
  14324. });
  14325. }(t));
  14326. results.push(t);
  14327. return t;
  14328. };
  14329. test._results = results;
  14330. test._tests = [];
  14331. test.createStream = function (opts) {
  14332. return results.createStream(opts);
  14333. };
  14334. test.onFinish = function (cb) {
  14335. results.on('done', cb);
  14336. };
  14337. test.onFailure = function (cb) {
  14338. results.on('fail', cb);
  14339. };
  14340. var only = false;
  14341. test.only = function () {
  14342. if (only) { throw new Error('there can only be one only test'); }
  14343. if (conf_.noOnly) { throw new Error('`only` tests are prohibited'); }
  14344. only = true;
  14345. var t = test.apply(null, arguments);
  14346. results.only(t);
  14347. return t;
  14348. };
  14349. test._exitCode = 0;
  14350. test.close = function () { results.close(); };
  14351. return test;
  14352. }
  14353. }).call(this)}).call(this,require('_process'))
  14354. },{"./lib/default_stream":107,"./lib/results":108,"./lib/test":109,"_process":79,"defined":17,"through":110}],107:[function(require,module,exports){
  14355. (function (process){(function (){
  14356. 'use strict';
  14357. var through = require('through');
  14358. var fs = require('fs');
  14359. module.exports = function () {
  14360. var line = '';
  14361. var stream = through(write, flush);
  14362. return stream;
  14363. function write(buf) {
  14364. for (var i = 0; i < buf.length; i++) {
  14365. var c = typeof buf === 'string'
  14366. ? buf.charAt(i)
  14367. : String.fromCharCode(buf[i]);
  14368. if (c === '\n') {
  14369. flush();
  14370. } else {
  14371. line += c;
  14372. }
  14373. }
  14374. }
  14375. function flush() {
  14376. if (fs.writeSync && (/^win/).test(process.platform)) {
  14377. try {
  14378. fs.writeSync(1, line + '\n');
  14379. } catch (e) {
  14380. stream.emit('error', e);
  14381. }
  14382. } else {
  14383. try {
  14384. console.log(line); // eslint-disable-line no-console
  14385. } catch (e) {
  14386. stream.emit('error', e);
  14387. }
  14388. }
  14389. line = '';
  14390. }
  14391. };
  14392. }).call(this)}).call(this,require('_process'))
  14393. },{"_process":79,"fs":9,"through":110}],108:[function(require,module,exports){
  14394. (function (process,setImmediate){(function (){
  14395. 'use strict';
  14396. var defined = require('defined');
  14397. var EventEmitter = require('events').EventEmitter;
  14398. var inherits = require('inherits');
  14399. var through = require('through');
  14400. var resumer = require('resumer');
  14401. var inspect = require('object-inspect');
  14402. var callBound = require('call-bind/callBound');
  14403. var has = require('has');
  14404. var regexpTest = callBound('RegExp.prototype.test');
  14405. var $split = callBound('String.prototype.split');
  14406. var $replace = callBound('String.prototype.replace');
  14407. var $shift = callBound('Array.prototype.shift');
  14408. var $push = callBound('Array.prototype.push');
  14409. var yamlIndicators = /:|-|\?/;
  14410. var nextTick = typeof setImmediate !== 'undefined'
  14411. ? setImmediate
  14412. : process.nextTick;
  14413. module.exports = Results;
  14414. inherits(Results, EventEmitter);
  14415. function coalesceWhiteSpaces(str) {
  14416. return $replace(String(str), /\s+/g, ' ');
  14417. }
  14418. function Results() {
  14419. if (!(this instanceof Results)) { return new Results(); }
  14420. this.count = 0;
  14421. this.fail = 0;
  14422. this.pass = 0;
  14423. this.todo = 0;
  14424. this._stream = through();
  14425. this.tests = [];
  14426. this._only = null;
  14427. this._isRunning = false;
  14428. }
  14429. Results.prototype.createStream = function (opts) {
  14430. if (!opts) { opts = {}; }
  14431. var self = this;
  14432. var output;
  14433. var testId = 0;
  14434. if (opts.objectMode) {
  14435. output = through();
  14436. self.on('_push', function ontest(t, extra) {
  14437. if (!extra) { extra = {}; }
  14438. var id = testId++;
  14439. t.once('prerun', function () {
  14440. var row = {
  14441. type: 'test',
  14442. name: t.name,
  14443. id: id,
  14444. skip: t._skip,
  14445. todo: t._todo
  14446. };
  14447. if (has(extra, 'parent')) {
  14448. row.parent = extra.parent;
  14449. }
  14450. output.queue(row);
  14451. });
  14452. t.on('test', function (st) {
  14453. ontest(st, { parent: id });
  14454. });
  14455. t.on('result', function (res) {
  14456. if (res && typeof res === 'object') {
  14457. res.test = id;
  14458. res.type = 'assert';
  14459. }
  14460. output.queue(res);
  14461. });
  14462. t.on('end', function () {
  14463. output.queue({ type: 'end', test: id });
  14464. });
  14465. });
  14466. self.on('done', function () { output.queue(null); });
  14467. } else {
  14468. output = resumer();
  14469. output.queue('TAP version 13\n');
  14470. self._stream.pipe(output);
  14471. }
  14472. if (!this._isRunning) {
  14473. this._isRunning = true;
  14474. nextTick(function next() {
  14475. var t;
  14476. while (t = getNextTest(self)) {
  14477. t.run();
  14478. if (!t.ended) {
  14479. t.once('end', function () { nextTick(next); });
  14480. return;
  14481. }
  14482. }
  14483. self.emit('done');
  14484. });
  14485. }
  14486. return output;
  14487. };
  14488. Results.prototype.push = function (t) {
  14489. var self = this;
  14490. $push(self.tests, t);
  14491. self._watch(t);
  14492. self.emit('_push', t);
  14493. };
  14494. Results.prototype.only = function (t) {
  14495. this._only = t;
  14496. };
  14497. Results.prototype._watch = function (t) {
  14498. var self = this;
  14499. var write = function (s) { self._stream.queue(s); };
  14500. t.once('prerun', function () {
  14501. var premsg = '';
  14502. if (t._skip) {
  14503. premsg = 'SKIP ';
  14504. } else if (t._todo) {
  14505. premsg = 'TODO ';
  14506. }
  14507. write('# ' + premsg + coalesceWhiteSpaces(t.name) + '\n');
  14508. });
  14509. t.on('result', function (res) {
  14510. if (typeof res === 'string') {
  14511. write('# ' + res + '\n');
  14512. return;
  14513. }
  14514. write(encodeResult(res, self.count + 1));
  14515. self.count++;
  14516. if (res.ok || res.todo) {
  14517. self.pass++;
  14518. } else {
  14519. self.fail++;
  14520. self.emit('fail');
  14521. }
  14522. });
  14523. t.on('test', function (st) { self._watch(st); });
  14524. };
  14525. Results.prototype.close = function () {
  14526. var self = this;
  14527. if (self.closed) { self._stream.emit('error', new Error('ALREADY CLOSED')); }
  14528. self.closed = true;
  14529. var write = function (s) { self._stream.queue(s); };
  14530. write('\n1..' + self.count + '\n');
  14531. write('# tests ' + self.count + '\n');
  14532. write('# pass ' + (self.pass + self.todo) + '\n');
  14533. if (self.todo) { write('# todo ' + self.todo + '\n'); }
  14534. if (self.fail) {
  14535. write('# fail ' + self.fail + '\n');
  14536. } else {
  14537. write('\n# ok\n');
  14538. }
  14539. self._stream.queue(null);
  14540. };
  14541. function encodeResult(res, count) {
  14542. var output = '';
  14543. output += (res.ok ? 'ok ' : 'not ok ') + count;
  14544. output += res.name ? ' ' + coalesceWhiteSpaces(res.name) : '';
  14545. if (res.skip) {
  14546. output += ' # SKIP' + (typeof res.skip === 'string' ? ' ' + coalesceWhiteSpaces(res.skip) : '');
  14547. } else if (res.todo) {
  14548. output += ' # TODO' + (typeof res.todo === 'string' ? ' ' + coalesceWhiteSpaces(res.todo) : '');
  14549. }
  14550. output += '\n';
  14551. if (res.ok) { return output; }
  14552. var outer = ' ';
  14553. var inner = outer + ' ';
  14554. output += outer + '---\n';
  14555. output += inner + 'operator: ' + res.operator + '\n';
  14556. if (has(res, 'expected') || has(res, 'actual')) {
  14557. var ex = inspect(res.expected, { depth: res.objectPrintDepth });
  14558. var ac = inspect(res.actual, { depth: res.objectPrintDepth });
  14559. if (Math.max(ex.length, ac.length) > 65 || invalidYaml(ex) || invalidYaml(ac)) {
  14560. output += inner + 'expected: |-\n' + inner + ' ' + ex + '\n';
  14561. output += inner + 'actual: |-\n' + inner + ' ' + ac + '\n';
  14562. } else {
  14563. output += inner + 'expected: ' + ex + '\n';
  14564. output += inner + 'actual: ' + ac + '\n';
  14565. }
  14566. }
  14567. if (res.at) {
  14568. output += inner + 'at: ' + res.at + '\n';
  14569. }
  14570. var actualStack = res.actual && (typeof res.actual === 'object' || typeof res.actual === 'function') ? res.actual.stack : undefined;
  14571. var errorStack = res.error && res.error.stack;
  14572. var stack = defined(actualStack, errorStack);
  14573. if (stack) {
  14574. var lines = $split(String(stack), '\n');
  14575. output += inner + 'stack: |-\n';
  14576. for (var i = 0; i < lines.length; i++) {
  14577. output += inner + ' ' + lines[i] + '\n';
  14578. }
  14579. }
  14580. output += outer + '...\n';
  14581. return output;
  14582. }
  14583. function getNextTest(results) {
  14584. if (!results._only) {
  14585. return $shift(results.tests);
  14586. }
  14587. do {
  14588. var t = $shift(results.tests);
  14589. if (t && results._only === t) {
  14590. return t;
  14591. }
  14592. } while (results.tests.length !== 0);
  14593. return void undefined;
  14594. }
  14595. function invalidYaml(str) {
  14596. return regexpTest(yamlIndicators, str);
  14597. }
  14598. }).call(this)}).call(this,require('_process'),require("timers").setImmediate)
  14599. },{"_process":79,"call-bind/callBound":11,"defined":17,"events":33,"has":45,"inherits":47,"object-inspect":65,"resumer":99,"through":110,"timers":111}],109:[function(require,module,exports){
  14600. (function (process,setImmediate,__dirname){(function (){
  14601. 'use strict';
  14602. var deepEqual = require('deep-equal');
  14603. var defined = require('defined');
  14604. var path = require('path');
  14605. var inherits = require('inherits');
  14606. var EventEmitter = require('events').EventEmitter;
  14607. var has = require('has');
  14608. var isRegExp = require('is-regex');
  14609. var trim = require('string.prototype.trim');
  14610. var callBound = require('call-bind/callBound');
  14611. var forEach = require('for-each');
  14612. var inspect = require('object-inspect');
  14613. var is = require('object-is');
  14614. var objectKeys = require('object-keys');
  14615. var every = require('array.prototype.every');
  14616. var isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
  14617. var toLowerCase = callBound('String.prototype.toLowerCase');
  14618. var isProto = callBound('Object.prototype.isPrototypeOf');
  14619. var $exec = callBound('RegExp.prototype.exec');
  14620. var objectToString = callBound('Object.prototype.toString');
  14621. var $split = callBound('String.prototype.split');
  14622. var $replace = callBound('String.prototype.replace');
  14623. var $strSlice = callBound('String.prototype.slice');
  14624. var $push = callBound('Array.prototype.push');
  14625. var $shift = callBound('Array.prototype.shift');
  14626. module.exports = Test;
  14627. var nextTick = typeof setImmediate !== 'undefined'
  14628. ? setImmediate
  14629. : process.nextTick;
  14630. var safeSetTimeout = setTimeout;
  14631. var safeClearTimeout = clearTimeout;
  14632. inherits(Test, EventEmitter);
  14633. // eslint-disable-next-line no-unused-vars
  14634. var getTestArgs = function (name_, opts_, cb_) {
  14635. var name = '(anonymous)';
  14636. var opts = {};
  14637. var cb;
  14638. for (var i = 0; i < arguments.length; i++) {
  14639. var arg = arguments[i];
  14640. var t = typeof arg;
  14641. if (t === 'string') {
  14642. name = arg;
  14643. } else if (t === 'object') {
  14644. opts = arg || opts;
  14645. } else if (t === 'function') {
  14646. cb = arg;
  14647. }
  14648. }
  14649. return {
  14650. name: name,
  14651. opts: opts,
  14652. cb: cb
  14653. };
  14654. };
  14655. function Test(name_, opts_, cb_) {
  14656. if (!(this instanceof Test)) {
  14657. return new Test(name_, opts_, cb_);
  14658. }
  14659. var args = getTestArgs(name_, opts_, cb_);
  14660. this.readable = true;
  14661. this.name = args.name || '(anonymous)';
  14662. this.assertCount = 0;
  14663. this.pendingCount = 0;
  14664. this._skip = args.opts.skip || false;
  14665. this._todo = args.opts.todo || false;
  14666. this._timeout = args.opts.timeout;
  14667. this._plan = undefined;
  14668. this._cb = args.cb;
  14669. this._progeny = [];
  14670. this._teardown = [];
  14671. this._ok = true;
  14672. var depthEnvVar = process.env.NODE_TAPE_OBJECT_PRINT_DEPTH;
  14673. if (args.opts.objectPrintDepth) {
  14674. this._objectPrintDepth = args.opts.objectPrintDepth;
  14675. } else if (depthEnvVar) {
  14676. if (toLowerCase(depthEnvVar) === 'infinity') {
  14677. this._objectPrintDepth = Infinity;
  14678. } else {
  14679. this._objectPrintDepth = depthEnvVar;
  14680. }
  14681. } else {
  14682. this._objectPrintDepth = 5;
  14683. }
  14684. for (var prop in this) {
  14685. this[prop] = (function bind(self, val) {
  14686. if (typeof val === 'function') {
  14687. return function bound() {
  14688. return val.apply(self, arguments);
  14689. };
  14690. }
  14691. return val;
  14692. }(this, this[prop]));
  14693. }
  14694. }
  14695. Test.prototype.run = function run() {
  14696. this.emit('prerun');
  14697. if (!this._cb || this._skip) {
  14698. this._end();
  14699. return;
  14700. }
  14701. if (this._timeout != null) {
  14702. this.timeoutAfter(this._timeout);
  14703. }
  14704. var callbackReturn = this._cb(this);
  14705. if (
  14706. typeof Promise === 'function'
  14707. && callbackReturn
  14708. && typeof callbackReturn.then === 'function'
  14709. ) {
  14710. var self = this;
  14711. Promise.resolve(callbackReturn).then(function onResolve() {
  14712. if (!self.calledEnd) {
  14713. self.end();
  14714. }
  14715. })['catch'](function onError(err) {
  14716. if (err instanceof Error || objectToString(err) === '[object Error]') {
  14717. self.ifError(err);
  14718. } else {
  14719. self.fail(err);
  14720. }
  14721. self.end();
  14722. });
  14723. return;
  14724. }
  14725. this.emit('run');
  14726. };
  14727. Test.prototype.test = function test(name, opts, cb) {
  14728. var self = this;
  14729. var t = new Test(name, opts, cb);
  14730. $push(this._progeny, t);
  14731. this.pendingCount++;
  14732. this.emit('test', t);
  14733. t.on('prerun', function () {
  14734. self.assertCount++;
  14735. });
  14736. if (!self._pendingAsserts()) {
  14737. nextTick(function () {
  14738. self._end();
  14739. });
  14740. }
  14741. nextTick(function () {
  14742. if (!self._plan && self.pendingCount == self._progeny.length) {
  14743. self._end();
  14744. }
  14745. });
  14746. };
  14747. Test.prototype.comment = function comment(msg) {
  14748. var that = this;
  14749. forEach($split(trim(msg), '\n'), function (aMsg) {
  14750. that.emit('result', $replace(trim(aMsg), /^#\s*/, ''));
  14751. });
  14752. };
  14753. Test.prototype.plan = function plan(n) {
  14754. this._plan = n;
  14755. this.emit('plan', n);
  14756. };
  14757. Test.prototype.timeoutAfter = function timeoutAfter(ms) {
  14758. if (!ms) { throw new Error('timeoutAfter requires a timespan'); }
  14759. var self = this;
  14760. var timeout = safeSetTimeout(function () {
  14761. self.fail(self.name + ' timed out after ' + ms + 'ms');
  14762. self.end();
  14763. }, ms);
  14764. this.once('end', function () {
  14765. safeClearTimeout(timeout);
  14766. });
  14767. };
  14768. Test.prototype.end = function end(err) {
  14769. if (arguments.length >= 1 && !!err) {
  14770. this.ifError(err);
  14771. }
  14772. if (this.calledEnd) {
  14773. this.fail('.end() already called');
  14774. }
  14775. this.calledEnd = true;
  14776. this._end();
  14777. };
  14778. Test.prototype.teardown = function teardown(fn) {
  14779. if (typeof fn !== 'function') {
  14780. this.fail('teardown: ' + inspect(fn) + ' is not a function');
  14781. } else {
  14782. this._teardown.push(fn);
  14783. }
  14784. };
  14785. Test.prototype._end = function _end(err) {
  14786. var self = this;
  14787. if (!this._cb && !this._todo && !this._skip) {
  14788. this.fail('# TODO ' + this.name);
  14789. }
  14790. if (this._progeny.length) {
  14791. var t = $shift(this._progeny);
  14792. t.on('end', function () { self._end(); });
  14793. t.run();
  14794. return;
  14795. }
  14796. function next() {
  14797. if (self._teardown.length === 0) {
  14798. completeEnd();
  14799. return;
  14800. }
  14801. var fn = self._teardown.shift();
  14802. var res;
  14803. try {
  14804. res = fn();
  14805. } catch (e) {
  14806. self.fail(e);
  14807. }
  14808. if (res && typeof res.then === 'function') {
  14809. res.then(next, function (_err) {
  14810. // TODO: wth?
  14811. err = err || _err;
  14812. });
  14813. } else {
  14814. next();
  14815. }
  14816. }
  14817. next();
  14818. function completeEnd() {
  14819. if (!self.ended) { self.emit('end'); }
  14820. var pendingAsserts = self._pendingAsserts();
  14821. if (!self._planError && self._plan !== undefined && pendingAsserts) {
  14822. self._planError = true;
  14823. self.fail('plan != count', {
  14824. expected: self._plan,
  14825. actual: self.assertCount
  14826. });
  14827. }
  14828. self.ended = true;
  14829. }
  14830. };
  14831. Test.prototype._exit = function _exit() {
  14832. if (this._plan !== undefined && !this._planError && this.assertCount !== this._plan) {
  14833. this._planError = true;
  14834. this.fail('plan != count', {
  14835. expected: this._plan,
  14836. actual: this.assertCount,
  14837. exiting: true
  14838. });
  14839. } else if (!this.ended) {
  14840. this.fail('test exited without ending: ' + this.name, {
  14841. exiting: true
  14842. });
  14843. }
  14844. };
  14845. Test.prototype._pendingAsserts = function _pendingAsserts() {
  14846. if (this._plan === undefined) {
  14847. return 1;
  14848. }
  14849. return this._plan - (this._progeny.length + this.assertCount);
  14850. };
  14851. Test.prototype._assert = function assert(ok, opts) {
  14852. var self = this;
  14853. var extra = opts.extra || {};
  14854. ok = !!ok || !!extra.skip;
  14855. var name = defined(extra.message, opts.message, '(unnamed assert)');
  14856. if (this.calledEnd && opts.operator !== 'fail') {
  14857. this.fail('.end() already called: ' + name);
  14858. return;
  14859. }
  14860. var res = {
  14861. id: self.assertCount++,
  14862. ok: ok,
  14863. skip: defined(extra.skip, opts.skip),
  14864. todo: defined(extra.todo, opts.todo, self._todo),
  14865. name: name,
  14866. operator: defined(extra.operator, opts.operator),
  14867. objectPrintDepth: self._objectPrintDepth
  14868. };
  14869. if (has(opts, 'actual') || has(extra, 'actual')) {
  14870. res.actual = defined(extra.actual, opts.actual);
  14871. }
  14872. if (has(opts, 'expected') || has(extra, 'expected')) {
  14873. res.expected = defined(extra.expected, opts.expected);
  14874. }
  14875. this._ok = !!(this._ok && ok);
  14876. if (!ok && !res.todo) {
  14877. res.error = defined(extra.error, opts.error, new Error(res.name));
  14878. }
  14879. if (!ok) {
  14880. var e = new Error('exception');
  14881. var err = $split(e.stack || '', '\n');
  14882. var dir = __dirname + path.sep;
  14883. for (var i = 0; i < err.length; i++) {
  14884. /*
  14885. Stack trace lines may resemble one of the following. We need
  14886. to correctly extract a function name (if any) and path / line
  14887. number for each line.
  14888. at myFunction (/path/to/file.js:123:45)
  14889. at myFunction (/path/to/file.other-ext:123:45)
  14890. at myFunction (/path to/file.js:123:45)
  14891. at myFunction (C:\path\to\file.js:123:45)
  14892. at myFunction (/path/to/file.js:123)
  14893. at Test.<anonymous> (/path/to/file.js:123:45)
  14894. at Test.bound [as run] (/path/to/file.js:123:45)
  14895. at /path/to/file.js:123:45
  14896. Regex has three parts. First is non-capturing group for 'at '
  14897. (plus anything preceding it).
  14898. /^(?:[^\s]*\s*\bat\s+)/
  14899. Second captures function call description (optional). This is
  14900. not necessarily a valid JS function name, but just what the
  14901. stack trace is using to represent a function call. It may look
  14902. like `<anonymous>` or 'Test.bound [as run]'.
  14903. For our purposes, we assume that, if there is a function
  14904. name, it's everything leading up to the first open
  14905. parentheses (trimmed) before our pathname.
  14906. /(?:(.*)\s+\()?/
  14907. Last part captures file path plus line no (and optional
  14908. column no).
  14909. /((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?/
  14910. */
  14911. var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:)]+:(\d+)(?::(\d+))?)\)?$/;
  14912. var lineWithTokens = $replace($replace(err[i], process.cwd(), '/$CWD'), __dirname, '/$TEST');
  14913. var m = re.exec(lineWithTokens);
  14914. if (!m) {
  14915. continue;
  14916. }
  14917. var callDescription = m[1] || '<anonymous>';
  14918. var filePath = $replace($replace(m[2], '/$CWD', process.cwd()), '/$TEST', __dirname);
  14919. if ($strSlice(filePath, 0, dir.length) === dir) {
  14920. continue;
  14921. }
  14922. // Function call description may not (just) be a function name.
  14923. // Try to extract function name by looking at first "word" only.
  14924. res.functionName = $split(callDescription, /\s+/)[0];
  14925. res.file = filePath;
  14926. res.line = Number(m[3]);
  14927. if (m[4]) { res.column = Number(m[4]); }
  14928. res.at = callDescription + ' (' + filePath + ')';
  14929. break;
  14930. }
  14931. }
  14932. self.emit('result', res);
  14933. var pendingAsserts = self._pendingAsserts();
  14934. if (!pendingAsserts) {
  14935. if (extra.exiting) {
  14936. self._end();
  14937. } else {
  14938. nextTick(function () {
  14939. self._end();
  14940. });
  14941. }
  14942. }
  14943. if (!self._planError && pendingAsserts < 0) {
  14944. self._planError = true;
  14945. self.fail('plan != count', {
  14946. expected: self._plan,
  14947. actual: self._plan - pendingAsserts
  14948. });
  14949. }
  14950. };
  14951. Test.prototype.fail = function fail(msg, extra) {
  14952. this._assert(false, {
  14953. message: msg,
  14954. operator: 'fail',
  14955. extra: extra
  14956. });
  14957. };
  14958. Test.prototype.pass = function pass(msg, extra) {
  14959. this._assert(true, {
  14960. message: msg,
  14961. operator: 'pass',
  14962. extra: extra
  14963. });
  14964. };
  14965. Test.prototype.skip = function skip(msg, extra) {
  14966. this._assert(true, {
  14967. message: msg,
  14968. operator: 'skip',
  14969. skip: true,
  14970. extra: extra
  14971. });
  14972. };
  14973. var testAssert = function assert(value, msg, extra) {
  14974. this._assert(value, {
  14975. message: defined(msg, 'should be truthy'),
  14976. operator: 'ok',
  14977. expected: true,
  14978. actual: value,
  14979. extra: extra
  14980. });
  14981. };
  14982. Test.prototype.ok
  14983. = Test.prototype['true']
  14984. = Test.prototype.assert
  14985. = testAssert;
  14986. function notOK(value, msg, extra) {
  14987. this._assert(!value, {
  14988. message: defined(msg, 'should be falsy'),
  14989. operator: 'notOk',
  14990. expected: false,
  14991. actual: value,
  14992. extra: extra
  14993. });
  14994. }
  14995. Test.prototype.notOk
  14996. = Test.prototype['false']
  14997. = Test.prototype.notok
  14998. = notOK;
  14999. function error(err, msg, extra) {
  15000. this._assert(!err, {
  15001. message: defined(msg, String(err)),
  15002. operator: 'error',
  15003. error: err,
  15004. extra: extra
  15005. });
  15006. }
  15007. Test.prototype.error
  15008. = Test.prototype.ifError
  15009. = Test.prototype.ifErr
  15010. = Test.prototype.iferror
  15011. = error;
  15012. function strictEqual(a, b, msg, extra) {
  15013. if (arguments.length < 2) {
  15014. throw new TypeError('two arguments must be provided to compare');
  15015. }
  15016. this._assert(is(a, b), {
  15017. message: defined(msg, 'should be strictly equal'),
  15018. operator: 'equal',
  15019. actual: a,
  15020. expected: b,
  15021. extra: extra
  15022. });
  15023. }
  15024. Test.prototype.equal
  15025. = Test.prototype.equals
  15026. = Test.prototype.isEqual
  15027. = Test.prototype.strictEqual
  15028. = Test.prototype.strictEquals
  15029. = Test.prototype.is
  15030. = strictEqual;
  15031. function notStrictEqual(a, b, msg, extra) {
  15032. if (arguments.length < 2) {
  15033. throw new TypeError('two arguments must be provided to compare');
  15034. }
  15035. this._assert(!is(a, b), {
  15036. message: defined(msg, 'should not be strictly equal'),
  15037. operator: 'notEqual',
  15038. actual: a,
  15039. expected: b,
  15040. extra: extra
  15041. });
  15042. }
  15043. Test.prototype.notEqual
  15044. = Test.prototype.notEquals
  15045. = Test.prototype.isNotEqual
  15046. = Test.prototype.doesNotEqual
  15047. = Test.prototype.isInequal
  15048. = Test.prototype.notStrictEqual
  15049. = Test.prototype.notStrictEquals
  15050. = Test.prototype.isNot
  15051. = Test.prototype.not
  15052. = notStrictEqual;
  15053. function looseEqual(a, b, msg, extra) {
  15054. if (arguments.length < 2) {
  15055. throw new TypeError('two arguments must be provided to compare');
  15056. }
  15057. this._assert(a == b, {
  15058. message: defined(msg, 'should be loosely equal'),
  15059. operator: 'looseEqual',
  15060. actual: a,
  15061. expected: b,
  15062. extra: extra
  15063. });
  15064. }
  15065. Test.prototype.looseEqual
  15066. = Test.prototype.looseEquals
  15067. = looseEqual;
  15068. function notLooseEqual(a, b, msg, extra) {
  15069. if (arguments.length < 2) {
  15070. throw new TypeError('two arguments must be provided to compare');
  15071. }
  15072. this._assert(a != b, {
  15073. message: defined(msg, 'should not be loosely equal'),
  15074. operator: 'notLooseEqual',
  15075. actual: a,
  15076. expected: b,
  15077. extra: extra
  15078. });
  15079. }
  15080. Test.prototype.notLooseEqual
  15081. = Test.prototype.notLooseEquals
  15082. = notLooseEqual;
  15083. function tapeDeepEqual(a, b, msg, extra) {
  15084. if (arguments.length < 2) {
  15085. throw new TypeError('two arguments must be provided to compare');
  15086. }
  15087. this._assert(deepEqual(a, b, { strict: true }), {
  15088. message: defined(msg, 'should be deeply equivalent'),
  15089. operator: 'deepEqual',
  15090. actual: a,
  15091. expected: b,
  15092. extra: extra
  15093. });
  15094. }
  15095. Test.prototype.deepEqual
  15096. = Test.prototype.deepEquals
  15097. = Test.prototype.isEquivalent
  15098. = Test.prototype.same
  15099. = tapeDeepEqual;
  15100. function notDeepEqual(a, b, msg, extra) {
  15101. if (arguments.length < 2) {
  15102. throw new TypeError('two arguments must be provided to compare');
  15103. }
  15104. this._assert(!deepEqual(a, b, { strict: true }), {
  15105. message: defined(msg, 'should not be deeply equivalent'),
  15106. operator: 'notDeepEqual',
  15107. actual: a,
  15108. expected: b,
  15109. extra: extra
  15110. });
  15111. }
  15112. Test.prototype.notDeepEqual
  15113. = Test.prototype.notDeepEquals
  15114. = Test.prototype.notEquivalent
  15115. = Test.prototype.notDeeply
  15116. = Test.prototype.notSame
  15117. = Test.prototype.isNotDeepEqual
  15118. = Test.prototype.isNotDeeply
  15119. = Test.prototype.isNotEquivalent
  15120. = Test.prototype.isInequivalent
  15121. = notDeepEqual;
  15122. function deepLooseEqual(a, b, msg, extra) {
  15123. if (arguments.length < 2) {
  15124. throw new TypeError('two arguments must be provided to compare');
  15125. }
  15126. this._assert(deepEqual(a, b), {
  15127. message: defined(msg, 'should be loosely deeply equivalent'),
  15128. operator: 'deepLooseEqual',
  15129. actual: a,
  15130. expected: b,
  15131. extra: extra
  15132. });
  15133. }
  15134. Test.prototype.deepLooseEqual
  15135. = deepLooseEqual;
  15136. function notDeepLooseEqual(a, b, msg, extra) {
  15137. if (arguments.length < 2) {
  15138. throw new TypeError('two arguments must be provided to compare');
  15139. }
  15140. this._assert(!deepEqual(a, b), {
  15141. message: defined(msg, 'should not be loosely deeply equivalent'),
  15142. operator: 'notDeepLooseEqual',
  15143. actual: a,
  15144. expected: b,
  15145. extra: extra
  15146. });
  15147. }
  15148. Test.prototype.notDeepLooseEqual
  15149. = notDeepLooseEqual;
  15150. Test.prototype['throws'] = function (fn, expected, msg, extra) {
  15151. if (typeof expected === 'string') {
  15152. msg = expected;
  15153. expected = undefined;
  15154. }
  15155. var caught;
  15156. try {
  15157. fn();
  15158. } catch (err) {
  15159. caught = { error: err };
  15160. if (Object(err) === err && (!isEnumerable(err, 'message') || !has(err, 'message'))) {
  15161. var message = err.message;
  15162. delete err.message;
  15163. err.message = message;
  15164. }
  15165. }
  15166. var passed = caught;
  15167. if (caught) {
  15168. if (typeof expected === 'string' && caught.error && caught.error.message === expected) {
  15169. throw new TypeError('The "error/message" argument is ambiguous. The error message ' + inspect(expected) + ' is identical to the message.');
  15170. }
  15171. if (typeof expected === 'function') {
  15172. if (typeof expected.prototype !== 'undefined' && caught.error instanceof expected) {
  15173. passed = true;
  15174. } else if (isProto(Error, expected)) {
  15175. passed = false;
  15176. } else {
  15177. passed = expected.call({}, caught.error) === true;
  15178. }
  15179. } else if (isRegExp(expected)) {
  15180. passed = $exec(expected, caught.error) !== null;
  15181. expected = inspect(expected);
  15182. } else if (expected && typeof expected === 'object') { // Handle validation objects.
  15183. var keys = objectKeys(expected);
  15184. // Special handle errors to make sure the name and the message are compared as well.
  15185. if (expected instanceof Error) {
  15186. $push(keys, 'name', 'message');
  15187. } else if (keys.length === 0) {
  15188. throw new TypeError('`throws` validation object must not be empty');
  15189. }
  15190. passed = every(keys, function (key) {
  15191. if (typeof caught.error[key] === 'string' && isRegExp(expected[key]) && $exec(expected[key], caught.error[key]) !== null) {
  15192. return true;
  15193. }
  15194. if (key in caught.error && deepEqual(caught.error[key], expected[key], { strict: true })) {
  15195. return true;
  15196. }
  15197. return false;
  15198. });
  15199. }
  15200. }
  15201. this._assert(!!passed, {
  15202. message: defined(msg, 'should throw'),
  15203. operator: 'throws',
  15204. actual: caught && caught.error,
  15205. expected: expected,
  15206. error: !passed && caught && caught.error,
  15207. extra: extra
  15208. });
  15209. };
  15210. Test.prototype.doesNotThrow = function doesNotThrow(fn, expected, msg, extra) {
  15211. if (typeof expected === 'string') {
  15212. msg = expected;
  15213. expected = undefined;
  15214. }
  15215. var caught;
  15216. try {
  15217. fn();
  15218. } catch (err) {
  15219. caught = { error: err };
  15220. }
  15221. this._assert(!caught, {
  15222. message: defined(msg, 'should not throw'),
  15223. operator: 'throws',
  15224. actual: caught && caught.error,
  15225. expected: expected,
  15226. error: caught && caught.error,
  15227. extra: extra
  15228. });
  15229. };
  15230. Test.prototype.match = function match(string, regexp, msg, extra) {
  15231. if (!isRegExp(regexp)) {
  15232. this._assert(false, {
  15233. message: defined(msg, 'The "regexp" argument must be an instance of RegExp. Received type ' + typeof regexp + ' (' + inspect(regexp) + ')'),
  15234. operator: 'match',
  15235. actual: objectToString(regexp),
  15236. expected: '[object RegExp]',
  15237. extra: extra
  15238. });
  15239. } else if (typeof string !== 'string') {
  15240. this._assert(false, {
  15241. message: defined(msg, 'The "string" argument must be of type string. Received type ' + typeof string + ' (' + inspect(string) + ')'),
  15242. operator: 'match',
  15243. actual: string === null ? null : typeof string,
  15244. expected: 'string',
  15245. extra: extra
  15246. });
  15247. } else {
  15248. var matches = $exec(regexp, string) !== null;
  15249. var message = defined(
  15250. msg,
  15251. 'The input ' + (matches ? 'matched' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string)
  15252. );
  15253. this._assert(matches, {
  15254. message: message,
  15255. operator: 'match',
  15256. actual: string,
  15257. expected: regexp,
  15258. extra: extra
  15259. });
  15260. }
  15261. };
  15262. Test.prototype.doesNotMatch = function doesNotMatch(string, regexp, msg, extra) {
  15263. if (!isRegExp(regexp)) {
  15264. this._assert(false, {
  15265. message: defined(msg, 'The "regexp" argument must be an instance of RegExp. Received type ' + typeof regexp + ' (' + inspect(regexp) + ')'),
  15266. operator: 'doesNotMatch',
  15267. actual: objectToString(regexp),
  15268. expected: '[object RegExp]',
  15269. extra: extra
  15270. });
  15271. } else if (typeof string !== 'string') {
  15272. this._assert(false, {
  15273. message: defined(msg, 'The "string" argument must be of type string. Received type ' + typeof string + ' (' + inspect(string) + ')'),
  15274. operator: 'doesNotMatch',
  15275. actual: string === null ? null : typeof string,
  15276. expected: 'string',
  15277. extra: extra
  15278. });
  15279. } else {
  15280. var matches = $exec(regexp, string) !== null;
  15281. var message = defined(
  15282. msg,
  15283. 'The input ' + (matches ? 'was expected to not match' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string)
  15284. );
  15285. this._assert(!matches, {
  15286. message: message,
  15287. operator: 'doesNotMatch',
  15288. actual: string,
  15289. expected: regexp,
  15290. extra: extra
  15291. });
  15292. }
  15293. };
  15294. // eslint-disable-next-line no-unused-vars
  15295. Test.skip = function skip(name_, _opts, _cb) {
  15296. var args = getTestArgs.apply(null, arguments);
  15297. args.opts.skip = true;
  15298. return new Test(args.name, args.opts, args.cb);
  15299. };
  15300. // vim: set softtabstop=4 shiftwidth=4:
  15301. }).call(this)}).call(this,require('_process'),require("timers").setImmediate,"/node_modules/tape/lib")
  15302. },{"_process":79,"array.prototype.every":4,"call-bind/callBound":11,"deep-equal":14,"defined":17,"events":33,"for-each":34,"has":45,"inherits":47,"is-regex":55,"object-inspect":65,"object-is":67,"object-keys":71,"path":77,"string.prototype.trim":103,"timers":111}],110:[function(require,module,exports){
  15303. (function (process){(function (){
  15304. var Stream = require('stream')
  15305. // through
  15306. //
  15307. // a stream that does nothing but re-emit the input.
  15308. // useful for aggregating a series of changing but not ending streams into one stream)
  15309. exports = module.exports = through
  15310. through.through = through
  15311. //create a readable writable stream.
  15312. function through (write, end, opts) {
  15313. write = write || function (data) { this.queue(data) }
  15314. end = end || function () { this.queue(null) }
  15315. var ended = false, destroyed = false, buffer = [], _ended = false
  15316. var stream = new Stream()
  15317. stream.readable = stream.writable = true
  15318. stream.paused = false
  15319. // stream.autoPause = !(opts && opts.autoPause === false)
  15320. stream.autoDestroy = !(opts && opts.autoDestroy === false)
  15321. stream.write = function (data) {
  15322. write.call(this, data)
  15323. return !stream.paused
  15324. }
  15325. function drain() {
  15326. while(buffer.length && !stream.paused) {
  15327. var data = buffer.shift()
  15328. if(null === data)
  15329. return stream.emit('end')
  15330. else
  15331. stream.emit('data', data)
  15332. }
  15333. }
  15334. stream.queue = stream.push = function (data) {
  15335. // console.error(ended)
  15336. if(_ended) return stream
  15337. if(data === null) _ended = true
  15338. buffer.push(data)
  15339. drain()
  15340. return stream
  15341. }
  15342. //this will be registered as the first 'end' listener
  15343. //must call destroy next tick, to make sure we're after any
  15344. //stream piped from here.
  15345. //this is only a problem if end is not emitted synchronously.
  15346. //a nicer way to do this is to make sure this is the last listener for 'end'
  15347. stream.on('end', function () {
  15348. stream.readable = false
  15349. if(!stream.writable && stream.autoDestroy)
  15350. process.nextTick(function () {
  15351. stream.destroy()
  15352. })
  15353. })
  15354. function _end () {
  15355. stream.writable = false
  15356. end.call(stream)
  15357. if(!stream.readable && stream.autoDestroy)
  15358. stream.destroy()
  15359. }
  15360. stream.end = function (data) {
  15361. if(ended) return
  15362. ended = true
  15363. if(arguments.length) stream.write(data)
  15364. _end() // will emit or queue
  15365. return stream
  15366. }
  15367. stream.destroy = function () {
  15368. if(destroyed) return
  15369. destroyed = true
  15370. ended = true
  15371. buffer.length = 0
  15372. stream.writable = stream.readable = false
  15373. stream.emit('close')
  15374. return stream
  15375. }
  15376. stream.pause = function () {
  15377. if(stream.paused) return
  15378. stream.paused = true
  15379. return stream
  15380. }
  15381. stream.resume = function () {
  15382. if(stream.paused) {
  15383. stream.paused = false
  15384. stream.emit('resume')
  15385. }
  15386. drain()
  15387. //may have become paused again,
  15388. //as drain emits 'data'.
  15389. if(!stream.paused)
  15390. stream.emit('drain')
  15391. return stream
  15392. }
  15393. return stream
  15394. }
  15395. }).call(this)}).call(this,require('_process'))
  15396. },{"_process":79,"stream":101}],111:[function(require,module,exports){
  15397. (function (setImmediate,clearImmediate){(function (){
  15398. var nextTick = require('process/browser.js').nextTick;
  15399. var apply = Function.prototype.apply;
  15400. var slice = Array.prototype.slice;
  15401. var immediateIds = {};
  15402. var nextImmediateId = 0;
  15403. // DOM APIs, for completeness
  15404. exports.setTimeout = function() {
  15405. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  15406. };
  15407. exports.setInterval = function() {
  15408. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  15409. };
  15410. exports.clearTimeout =
  15411. exports.clearInterval = function(timeout) { timeout.close(); };
  15412. function Timeout(id, clearFn) {
  15413. this._id = id;
  15414. this._clearFn = clearFn;
  15415. }
  15416. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  15417. Timeout.prototype.close = function() {
  15418. this._clearFn.call(window, this._id);
  15419. };
  15420. // Does not start the time, just sets up the members needed.
  15421. exports.enroll = function(item, msecs) {
  15422. clearTimeout(item._idleTimeoutId);
  15423. item._idleTimeout = msecs;
  15424. };
  15425. exports.unenroll = function(item) {
  15426. clearTimeout(item._idleTimeoutId);
  15427. item._idleTimeout = -1;
  15428. };
  15429. exports._unrefActive = exports.active = function(item) {
  15430. clearTimeout(item._idleTimeoutId);
  15431. var msecs = item._idleTimeout;
  15432. if (msecs >= 0) {
  15433. item._idleTimeoutId = setTimeout(function onTimeout() {
  15434. if (item._onTimeout)
  15435. item._onTimeout();
  15436. }, msecs);
  15437. }
  15438. };
  15439. // That's not how node.js implements it but the exposed api is the same.
  15440. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
  15441. var id = nextImmediateId++;
  15442. var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  15443. immediateIds[id] = true;
  15444. nextTick(function onNextTick() {
  15445. if (immediateIds[id]) {
  15446. // fn.call() is faster so we optimize for the common use-case
  15447. // @see http://jsperf.com/call-apply-segu
  15448. if (args) {
  15449. fn.apply(null, args);
  15450. } else {
  15451. fn.call(null);
  15452. }
  15453. // Prevent ids from leaking
  15454. exports.clearImmediate(id);
  15455. }
  15456. });
  15457. return id;
  15458. };
  15459. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
  15460. delete immediateIds[id];
  15461. };
  15462. }).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
  15463. },{"process/browser.js":79,"timers":111}],112:[function(require,module,exports){
  15464. (function (global){(function (){
  15465. /**
  15466. * Module exports.
  15467. */
  15468. module.exports = deprecate;
  15469. /**
  15470. * Mark that a method should not be used.
  15471. * Returns a modified function which warns once by default.
  15472. *
  15473. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  15474. *
  15475. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  15476. * will throw an Error when invoked.
  15477. *
  15478. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  15479. * will invoke `console.trace()` instead of `console.error()`.
  15480. *
  15481. * @param {Function} fn - the function to deprecate
  15482. * @param {String} msg - the string to print to the console when `fn` is invoked
  15483. * @returns {Function} a new "deprecated" version of `fn`
  15484. * @api public
  15485. */
  15486. function deprecate (fn, msg) {
  15487. if (config('noDeprecation')) {
  15488. return fn;
  15489. }
  15490. var warned = false;
  15491. function deprecated() {
  15492. if (!warned) {
  15493. if (config('throwDeprecation')) {
  15494. throw new Error(msg);
  15495. } else if (config('traceDeprecation')) {
  15496. console.trace(msg);
  15497. } else {
  15498. console.warn(msg);
  15499. }
  15500. warned = true;
  15501. }
  15502. return fn.apply(this, arguments);
  15503. }
  15504. return deprecated;
  15505. }
  15506. /**
  15507. * Checks `localStorage` for boolean values for the given `name`.
  15508. *
  15509. * @param {String} name
  15510. * @returns {Boolean}
  15511. * @api private
  15512. */
  15513. function config (name) {
  15514. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  15515. try {
  15516. if (!global.localStorage) return false;
  15517. } catch (_) {
  15518. return false;
  15519. }
  15520. var val = global.localStorage[name];
  15521. if (null == val) return false;
  15522. return String(val).toLowerCase() === 'true';
  15523. }
  15524. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  15525. },{}],113:[function(require,module,exports){
  15526. 'use strict';
  15527. var isString = require('is-string');
  15528. var isNumber = require('is-number-object');
  15529. var isBoolean = require('is-boolean-object');
  15530. var isSymbol = require('is-symbol');
  15531. var isBigInt = require('is-bigint');
  15532. // eslint-disable-next-line consistent-return
  15533. module.exports = function whichBoxedPrimitive(value) {
  15534. // eslint-disable-next-line eqeqeq
  15535. if (value == null || (typeof value !== 'object' && typeof value !== 'function')) {
  15536. return null;
  15537. }
  15538. if (isString(value)) {
  15539. return 'String';
  15540. }
  15541. if (isNumber(value)) {
  15542. return 'Number';
  15543. }
  15544. if (isBoolean(value)) {
  15545. return 'Boolean';
  15546. }
  15547. if (isSymbol(value)) {
  15548. return 'Symbol';
  15549. }
  15550. if (isBigInt(value)) {
  15551. return 'BigInt';
  15552. }
  15553. };
  15554. },{"is-bigint":49,"is-boolean-object":50,"is-number-object":54,"is-string":57,"is-symbol":58}],114:[function(require,module,exports){
  15555. 'use strict';
  15556. var isMap = require('is-map');
  15557. var isSet = require('is-set');
  15558. var isWeakMap = require('is-weakmap');
  15559. var isWeakSet = require('is-weakset');
  15560. module.exports = function whichCollection(value) {
  15561. if (value && typeof value === 'object') {
  15562. if (isMap(value)) {
  15563. return 'Map';
  15564. }
  15565. if (isSet(value)) {
  15566. return 'Set';
  15567. }
  15568. if (isWeakMap(value)) {
  15569. return 'WeakMap';
  15570. }
  15571. if (isWeakSet(value)) {
  15572. return 'WeakSet';
  15573. }
  15574. }
  15575. return false;
  15576. };
  15577. },{"is-map":53,"is-set":56,"is-weakmap":60,"is-weakset":61}],115:[function(require,module,exports){
  15578. (function (global){(function (){
  15579. 'use strict';
  15580. var forEach = require('foreach');
  15581. var availableTypedArrays = require('available-typed-arrays');
  15582. var callBound = require('call-bind/callBound');
  15583. var $toString = callBound('Object.prototype.toString');
  15584. var hasToStringTag = require('has-tostringtag/shams')();
  15585. var g = typeof globalThis === 'undefined' ? global : globalThis;
  15586. var typedArrays = availableTypedArrays();
  15587. var $slice = callBound('String.prototype.slice');
  15588. var toStrTags = {};
  15589. var gOPD = require('es-abstract/helpers/getOwnPropertyDescriptor');
  15590. var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
  15591. if (hasToStringTag && gOPD && getPrototypeOf) {
  15592. forEach(typedArrays, function (typedArray) {
  15593. if (typeof g[typedArray] === 'function') {
  15594. var arr = new g[typedArray]();
  15595. if (Symbol.toStringTag in arr) {
  15596. var proto = getPrototypeOf(arr);
  15597. var descriptor = gOPD(proto, Symbol.toStringTag);
  15598. if (!descriptor) {
  15599. var superProto = getPrototypeOf(proto);
  15600. descriptor = gOPD(superProto, Symbol.toStringTag);
  15601. }
  15602. toStrTags[typedArray] = descriptor.get;
  15603. }
  15604. }
  15605. });
  15606. }
  15607. var tryTypedArrays = function tryAllTypedArrays(value) {
  15608. var foundName = false;
  15609. forEach(toStrTags, function (getter, typedArray) {
  15610. if (!foundName) {
  15611. try {
  15612. var name = getter.call(value);
  15613. if (name === typedArray) {
  15614. foundName = name;
  15615. }
  15616. } catch (e) {}
  15617. }
  15618. });
  15619. return foundName;
  15620. };
  15621. var isTypedArray = require('is-typed-array');
  15622. module.exports = function whichTypedArray(value) {
  15623. if (!isTypedArray(value)) { return false; }
  15624. if (!hasToStringTag || !(Symbol.toStringTag in value)) { return $slice($toString(value), 8, -1); }
  15625. return tryTypedArrays(value);
  15626. };
  15627. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  15628. },{"available-typed-arrays":7,"call-bind/callBound":11,"es-abstract/helpers/getOwnPropertyDescriptor":26,"foreach":35,"has-tostringtag/shams":44,"is-typed-array":59}],116:[function(require,module,exports){
  15629. arguments[4][75][0].apply(exports,arguments)
  15630. },{"./implementation":1,"dup":75}],117:[function(require,module,exports){
  15631. arguments[4][76][0].apply(exports,arguments)
  15632. },{"./polyfill":116,"define-properties":16,"dup":76}],118:[function(require,module,exports){
  15633. 'use strict';
  15634. var assign = require('../');
  15635. var test = require('tape');
  15636. var runTests = require('./tests');
  15637. test('as a function', function (t) {
  15638. t.test('bad array/this value', function (st) {
  15639. st['throws'](function () { assign(undefined); }, TypeError, 'undefined is not an object');
  15640. st['throws'](function () { assign(null); }, TypeError, 'null is not an object');
  15641. st.end();
  15642. });
  15643. runTests(assign, t);
  15644. t.end();
  15645. });
  15646. },{"../":2,"./tests":119,"tape":106}],119:[function(require,module,exports){
  15647. 'use strict';
  15648. var hasSymbols = require('has-symbols/shams')();
  15649. var forEach = require('for-each');
  15650. var has = require('has');
  15651. var mockProperty = require('mock-property');
  15652. module.exports = function (assign, t) {
  15653. t.test('error cases', function (st) {
  15654. st['throws'](function () { assign(null); }, TypeError, 'target must be an object');
  15655. st['throws'](function () { assign(undefined); }, TypeError, 'target must be an object');
  15656. st['throws'](function () { assign(null, {}); }, TypeError, 'target must be an object');
  15657. st['throws'](function () { assign(undefined, {}); }, TypeError, 'target must be an object');
  15658. st.end();
  15659. });
  15660. t.test('non-object target, no sources', function (st) {
  15661. var bool = assign(true);
  15662. st.equal(typeof bool, 'object', 'bool is object');
  15663. st.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');
  15664. var number = assign(1);
  15665. st.equal(typeof number, 'object', 'number is object');
  15666. st.equal(Number.prototype.valueOf.call(number), 1, 'number coerces to `1`');
  15667. var string = assign('1');
  15668. st.equal(typeof string, 'object', 'number is object');
  15669. st.equal(String.prototype.valueOf.call(string), '1', 'number coerces to `"1"`');
  15670. st.end();
  15671. });
  15672. t.test('non-object target, with sources', function (st) {
  15673. var signal = {};
  15674. st.test('boolean', function (st2) {
  15675. var bool = assign(true, { a: signal });
  15676. st2.equal(typeof bool, 'object', 'bool is object');
  15677. st2.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');
  15678. st2.equal(bool.a, signal, 'source properties copied');
  15679. st2.end();
  15680. });
  15681. st.test('number', function (st2) {
  15682. var number = assign(1, { a: signal });
  15683. st2.equal(typeof number, 'object', 'number is object');
  15684. st2.equal(Number.prototype.valueOf.call(number), 1, 'number coerces to `1`');
  15685. st2.equal(number.a, signal, 'source properties copied');
  15686. st2.end();
  15687. });
  15688. st.test('string', function (st2) {
  15689. var string = assign('1', { a: signal });
  15690. st2.equal(typeof string, 'object', 'number is object');
  15691. st2.equal(String.prototype.valueOf.call(string), '1', 'number coerces to `"1"`');
  15692. st2.equal(string.a, signal, 'source properties copied');
  15693. st2.end();
  15694. });
  15695. st.end();
  15696. });
  15697. t.test('non-object sources', function (st) {
  15698. st.deepEqual(assign({ a: 1 }, null, { b: 2 }), { a: 1, b: 2 }, 'ignores null source');
  15699. st.deepEqual(assign({ a: 1 }, { b: 2 }, undefined), { a: 1, b: 2 }, 'ignores undefined source');
  15700. st.end();
  15701. });
  15702. t.test('returns the modified target object', function (st) {
  15703. var target = {};
  15704. var returned = assign(target, { a: 1 });
  15705. st.equal(returned, target, 'returned object is the same reference as the target object');
  15706. st.end();
  15707. });
  15708. t.test('has the right length', function (st) {
  15709. st.equal(assign.length, 2, 'length is 2 => 2 required arguments');
  15710. st.end();
  15711. });
  15712. t.test('merge two objects', function (st) {
  15713. var target = { a: 1 };
  15714. var returned = assign(target, { b: 2 });
  15715. st.deepEqual(returned, { a: 1, b: 2 }, 'returned object has properties from both');
  15716. st.end();
  15717. });
  15718. t.test('works with functions', function (st) {
  15719. var target = function () {};
  15720. target.a = 1;
  15721. var returned = assign(target, { b: 2 });
  15722. st.equal(target, returned, 'returned object is target');
  15723. st.equal(returned.a, 1);
  15724. st.equal(returned.b, 2);
  15725. st.end();
  15726. });
  15727. t.test('works with primitives', function (st) {
  15728. var target = 2;
  15729. var source = { b: 42 };
  15730. var returned = assign(target, source);
  15731. st.equal(Object.prototype.toString.call(returned), '[object Number]', 'returned is object form of number primitive');
  15732. st.equal(Number(returned), target, 'returned and target have same valueOf');
  15733. st.equal(returned.b, source.b);
  15734. st.end();
  15735. });
  15736. /* globals window */
  15737. t.test('works with window.location', { skip: typeof window === 'undefined' }, function (st) {
  15738. var target = {};
  15739. assign(target, window.location);
  15740. for (var prop in window.location) {
  15741. if (has(window.location, prop)) {
  15742. st.deepEqual(target[prop], window.location[prop], prop + ' is copied');
  15743. }
  15744. }
  15745. st.end();
  15746. });
  15747. t.test('merge N objects', function (st) {
  15748. var target = { a: 1 };
  15749. var source1 = { b: 2 };
  15750. var source2 = { c: 3 };
  15751. var returned = assign(target, source1, source2);
  15752. st.deepEqual(returned, { a: 1, b: 2, c: 3 }, 'returned object has properties from all sources');
  15753. st.end();
  15754. });
  15755. t.test('only iterates over own keys', function (st) {
  15756. var Foo = function () {};
  15757. Foo.prototype.bar = true;
  15758. var foo = new Foo();
  15759. foo.baz = true;
  15760. var target = { a: 1 };
  15761. var returned = assign(target, foo);
  15762. st.equal(returned, target, 'returned object is the same reference as the target object');
  15763. st.deepEqual(target, { a: 1, baz: true }, 'returned object has only own properties from both');
  15764. st.end();
  15765. });
  15766. t.test('includes enumerable symbols, after keys', { skip: !hasSymbols }, function (st) {
  15767. var visited = [];
  15768. var obj = {};
  15769. Object.defineProperty(obj, 'a', { enumerable: true, get: function () { visited.push('a'); return 42; } });
  15770. var symbol = Symbol('enumerable');
  15771. Object.defineProperty(obj, symbol, {
  15772. enumerable: true,
  15773. get: function () { visited.push(symbol); return Infinity; }
  15774. });
  15775. var nonEnumSymbol = Symbol('non-enumerable');
  15776. Object.defineProperty(obj, nonEnumSymbol, {
  15777. enumerable: false,
  15778. get: function () { visited.push(nonEnumSymbol); return -Infinity; }
  15779. });
  15780. var target = assign({}, obj);
  15781. st.deepEqual(visited, ['a', symbol], 'key is visited first, then symbol');
  15782. st.equal(target.a, 42, 'target.a is 42');
  15783. st.equal(target[symbol], Infinity, 'target[symbol] is Infinity');
  15784. st.notEqual(target[nonEnumSymbol], -Infinity, 'target[nonEnumSymbol] is not -Infinity');
  15785. st.end();
  15786. });
  15787. t.test('does not fail when symbols are not present', { skip: !Object.isFrozen || Object.isFrozen(Object) }, function (st) {
  15788. st.teardown(mockProperty(Object, 'getOwnPropertySymbols', { 'delete': true }));
  15789. var visited = [];
  15790. var obj = {};
  15791. Object.defineProperty(obj, 'a', { enumerable: true, get: function () { visited.push('a'); return 42; } });
  15792. var keys = ['a'];
  15793. if (hasSymbols) {
  15794. var symbol = Symbol('sym');
  15795. Object.defineProperty(obj, symbol, {
  15796. enumerable: true,
  15797. get: function () { visited.push(symbol); return Infinity; }
  15798. });
  15799. keys.push(symbol);
  15800. }
  15801. var target = assign({}, obj);
  15802. st.deepEqual(visited, keys, 'assign visits expected keys');
  15803. st.equal(target.a, 42, 'target.a is 42');
  15804. if (hasSymbols) {
  15805. st.equal(target[symbol], Infinity);
  15806. }
  15807. st.end();
  15808. });
  15809. t.test('preserves correct property enumeration order', function (st) {
  15810. var str = 'abcdefghijklmnopqrst';
  15811. var letters = {};
  15812. forEach(str.split(''), function (letter) {
  15813. letters[letter] = letter;
  15814. });
  15815. var n = 5;
  15816. st.comment('run the next test ' + n + ' times');
  15817. var object = assign({}, letters);
  15818. var actual = '';
  15819. for (var k in object) {
  15820. actual += k;
  15821. }
  15822. for (var i = 0; i < n; ++i) {
  15823. st.equal(actual, str, 'property enumeration order should be followed');
  15824. }
  15825. st.end();
  15826. });
  15827. t.test('checks enumerability and existence, in case of modification during [[Get]]', { skip: !Object.defineProperty }, function (st) {
  15828. var targetBvalue = {};
  15829. var targetCvalue = {};
  15830. var target = { b: targetBvalue, c: targetCvalue };
  15831. var source = {};
  15832. Object.defineProperty(source, 'a', {
  15833. enumerable: true,
  15834. get: function () {
  15835. delete this.b;
  15836. Object.defineProperty(this, 'c', { enumerable: false });
  15837. return 'a';
  15838. }
  15839. });
  15840. var sourceBvalue = {};
  15841. var sourceCvalue = {};
  15842. source.b = sourceBvalue;
  15843. source.c = sourceCvalue;
  15844. var result = assign(target, source);
  15845. st.equal(result, target, 'sanity check: result is === target');
  15846. st.equal(result.b, targetBvalue, 'target key not overwritten by deleted source key');
  15847. st.equal(result.c, targetCvalue, 'target key not overwritten by non-enumerable source key');
  15848. st.end();
  15849. });
  15850. };
  15851. },{"for-each":34,"has":45,"has-symbols/shams":43,"mock-property":63}]},{},[118])
  15852. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJpbXBsZW1lbnRhdGlvbi5qcyIsImluZGV4LmpzIiwibm9kZV9tb2R1bGVzL2FycmF5LnByb3RvdHlwZS5ldmVyeS9pbXBsZW1lbnRhdGlvbi5qcyIsIm5vZGVfbW9kdWxlcy9hcnJheS5wcm90b3R5cGUuZXZlcnkvaW5kZXguanMiLCJub2RlX21vZHVsZXMvYXJyYXkucHJvdG90eXBlLmV2ZXJ5L3BvbHlmaWxsLmpzIiwibm9kZV9tb2R1bGVzL2FycmF5LnByb3RvdHlwZS5ldmVyeS9zaGltLmpzIiwibm9kZV9tb2R1bGVzL2F2YWlsYWJsZS10eXBlZC1hcnJheXMvaW5kZXguanMiLCJub2RlX21vZHVsZXMvYmFzZTY0LWpzL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2Jyb3dzZXItcmVzb2x2ZS9lb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XG5cbiAgICAgIC8vIG5vdCBsaXN0ZW5pbmcgZm9yIHJlbW92ZUxpc3RlbmVyLCBubyBuZWVkIHRvIGVtaXRcbiAgICAgIGlmICghZXZlbnRzLnJlbW92ZUxpc3RlbmVyKSB7XG4gICAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgdGhpcy5fZXZlbnRzID0gb2JqZWN0Q3JlYXRlKG51bGwpO1xuICAgICAgICAgIHRoaXMuX2V2ZW50c0NvdW50ID0gMDtcbiAgICAgICAgfSBlbHNlIGlmIChldmVudHNbdHlwZV0pIHtcbiAgICAgICAgICBpZiAoLS10aGlzLl9ldmVudHNDb3VudCA9PT0gMClcbiAgICAgICAgICAgIHRoaXMuX2V2ZW50cyA9IG9iamVjdENyZWF0ZShudWxsKTtcbiAgICAgICAgICBlbHNlXG4gICAgICAgICAgICBkZWxldGUgZXZlbnRzW3R5cGVdO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgfVxuXG4gICAgICAvLyBlbWl0IHJlbW92ZUxpc3RlbmVyIGZvciBhbGwgbGlzdGVuZXJzIG9uIGFsbCBldmVudHNcbiAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID09PSAwKSB7XG4gICAgICAgIHZhciBrZXlzID0gb2JqZWN0S2V5cyhldmVudHMpO1xuICAgICAgICB2YXIga2V5O1xuICAgICAgICBmb3IgKGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7ICsraSkge1xuICAgICAgICAgIGtleSA9IGtleXNbaV07XG4gICAgICAgICAgaWYgKGtleSA9PT0gJ3JlbW92ZUxpc3RlbmVyJykgY29udGludWU7XG4gICAgICAgICAgdGhpcy5yZW1vdmVBbGxMaXN0ZW5lcnMoa2V5KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnJlbW92ZUFsbExpc3RlbmVycygncmVtb3ZlTGlzdGVuZXInKTtcbiAgICAgICAgdGhpcy5fZXZlbnRzID0gb2J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gICk7XG4gICAgICAgICAgICBpZiAoT2JqZWN0KHJlc3VsdCkgPT09IHJlc3VsdCkge1xuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0YXJnZXQuYXBwbHkoXG4gICAgICAgICAgICAgICAgdGhhdCxcbiAgICAgICAgICAgICAgICBhcmdzLmNvbmNhdChzbGljZS5jYWxsKGFyZ3VtZW50cykpXG4gICAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIHZhciBib3VuZExlbmd0aCA9IE1hdGgubWF4KDAsIHRhcmdldC5sZW5ndGggLSBhcmdzLmxlbmd0aCk7XG4gICAgdmFyIGJvdW5kQXJncyA9IFtdO1xuICAgIGZvciAodmFyIGkgPSAwOyBpIDwgYm91bmRMZW5ndGg7IGkrKykge1xuICAgICAgICBib3VuZEFyZ3MucHVzaCgnJCcgKyBpKTtcbiAgICB9XG5cbiAgICBib3VuZCA9IEZ1bmN0aW9uKCdiaW5kZXInLCAncmV0dXJuIGZ1bmN0aW9uICgnICsgYm91bmRBcmdzLmpvaW4oJywnKSArICcpeyByZXR1cm4gYmluZGVyLmFwcGx5KHRoaXMsYXJndW1lbnRzKTsgfScpKGJpbmRlcik7XG5cbiAgICBpZiAodGFyZ2V0LnByb3RvdHlwZSkge1xuICAgICAgICB2YXIgRW1wdHkgPSBmdW5jdGlvbiBFbXB0eSgpIHt9O1xuICAgICAgICBFbXB0eS5wcm90b3R5cGUgPSB0YXJnZXQucHJvdG90eXBlO1xuICAgICAgICBib3VuZC5wcm90b3R5cGUgPSBuZXcgRW1wdHkoKTtcbiAgICAgICAgRW1wdHkucHJvdG90eXBlID0gbnVsbDtcbiAgICB9XG5cbiAgICByZXR1cm4gYm91bmQ7XG59O1xuIiwiJ3VzZSBzdHJpY3QnO1xuXG52YXIgaW1wbGVtZW50Y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ICAgIHZhciBuZXdPcHRzID0ge1xuICAgICAgICAgICAgICAgIGRlcHRoOiBvcHRzLmRlcHRoXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKGhhcyhvcHRzLCAncXVvdGVTdHlsZScpKSB7XG4gICAgICAgICAgICAgICAgbmV3T3B0cy5xdW90ZVN0eWxlID0gb3B0cy5xdW90ZVN0eWxlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGluc3BlY3RfKHZhbHVlLCBuZXdPcHRzLCBkZXB0aCArIDEsIHNlZW4pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBpbnNwZWN0Xyh2YWx1ZSwgb3B0cywgZGVwdGggKyAxLCBzZWVuKTtcbiAgICB9XG5cbiAgICBpZiAodHlwZW9mIG9iaiA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICB2YXIgbmFtZSA9IG5hbWVPZihvYmopO1xuICAgICAgICB2YXIga2V5cyA9IGFyck9iaktleXMob2JqLCBpbnNwZWN0KTtcbiAgICAgICAgcmV0dXJuICdbRnVuY3Rpb24nICsgKG5hbWUgPyAnOiAnICsgbmFtZSA6ICcgKGFub255bW91cyknKSArICddJyArIChrZXlzLmxlbmd0aCA+IDAgPyAnIHsgJyArICRqb2luLmNhbGwoa2V5cywgJywgJykgKyAnIH0nIDogJycpO1xuICAgIH1cbiAgICBpZiAoaXNTeW1ib2wob2JqKSkge1xuICAgICAgICB2YXIgc3ltU3RyaW5nID0gaGFzU2hhbW1lZFN5bWJvbHMgPyAkcmVwbGFjZS5jYWxsKFN0cmluZyhvYmopLCAvXihTeW1ib2xcXCguKlxcKSlfW14pXSokLywgJyQxJykgOiBzeW1Ub1N0cmluZy5jYWxsKG9iaik7XG4gICAgICAgIHJldHVybiB0eXBlb2Ygb2JqID09PSAnb2JqZWN0JyAmJiAhaGFzU2hhbW1lZFN5bWJvbHMgPyBtYXJrQm94ZWQoc3ltU3RyaW5nKSA6IHN5bVN0cmluZztcbiAgICB9XG4gICAgaWYgKGlzRWxlbWVudChvYmopKSB7XG4gICAgICAgIHZhciBzID0gJzwnICsgJHRvTG93ZXJDYXNlLmNhbGwoU3RyaW5nKG9iai5ub2RlTmFtZSkpO1xuICAgICAgICB2YXIgYXR0cnMgPSBvYmouYXR0cmlidXRlcyB8fCBbXTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBhdHRycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgcyArPSAnICcgKyBhdHRyc1tpXS5uYW1lICsgJz0nICsgd3JhcFF1b3RlcyhxdW90ZShhdHRyc1tpXS52YWx1ZSksICdkb3VibGUnLCBvcHRzKTtcbiAgICAgICAgfVxuICAgICAgICBzICs9ICc+JztcbiAgICAgICAgaWYgKG9iai5jaGlsZE5vZGVzICYmIG9iai5jaGlsZE5vZGVzLmxlbmd0aCkgeyBzICs9ICcuLi4nOyB9XG4gICAgICAgIHMgKz0gJzwvJyArICR0b0xvd2VyQ2FzZS5jYWxsKFN0cmluZyhvYmoubm9kZU5hbWUpKSArICc+JztcbiAgICAgICAgcmV0dXJuIHM7XG4gICAgfVxuICAgIGlmIChpc0FycmF5KG9iaikpIHtcbiAgICAgICAgaWYgKG9iai5sZW5ndGggPT09IDApIHsgcmV0dXJuICdbXSc7IH1cbiAgICAgICAgdmFyIHhzID0gYXJyT2JqS2V5cyhvYmosIGluc3BlY3QpO1xuICAgICAgICBpZiAoaW5kZW50ICYmICFzaW5nbGVMaW5lVmFsdWVzKHhzKSkge1xuICAgICAgICAgICAgcmV0dXJuICdbJyArIGluZGVudGVkSm9pbih4cywgaW5kZW50KSArICddJztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gJ1sgJyArICRqb2luLmNhbGwoeHMsICcsICcpICsgJyBdJztcbiAgICB9XG4gICAgaWYgKGlzRXJyb3Iob2JqKSkge1xuICAgICAgICB2YXIgcGFydHMgPSBhcnJPYmpLZXlzKG9iaiwgaW5zcGVjdCk7XG4gICAgICAgIGlm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WQtc3ludGF4LCBuby1jb250aW51ZVxuICAgICAgICBpZiAoaXNBcnIgJiYgU3RyaW5nKE51bWJlcihrZXkpKSA9PT0ga2V5ICYmIGtleSA8IG9iai5sZW5ndGgpIHsgY29udGludWU7IH0gLy8gZXNsaW50LWRpc2FibGUtbGluZSBuby1yZXN0cmljdGVkLXN5bnRheCwgbm8tY29udGludWVcbiAgICAgICAgaWYgKGhhc1NoYW1tZWRTeW1ib2xzICYmIHN5bU1hcFsnJCcgKyBrZXldIGluc3RhbmNlb2YgU3ltYm9sKSB7XG4gICAgICAgICAgICAvLyB0aGlzIGlzIHRvIHByZXZlbnQgc2hhbW1lZCBTeW1ib2xzLCB3aGljaCBhcmUgc3RvcmVkIGFzIHN0cmluZ3MsIGZyb20gYmVpbmcgaW5jbHVkZWQgaW4gdGhlIHN0cmluZyBrZXkgc2VjdGlvblxuICAgICAgICAgICAgY29udGludWU7IC8vIGVzbGludC1kaXNhYmxlLWxpbmUgbm8tcmVzdHJpY3RlZC1zeW50YXgsIG5vLWNvbnRpbnVlXG4gICAgICAgIH0gZWxzZSBpZiAoJHRlc3QuY2FsbCgvW15cXHckXS8sIGtleSkpIHtcbiAgICAgICAgICAgIHhzLnB1c2goaW5zcGVjdChrZXksIG9iaikgKyAnOiAnICsgaW5zcGVjdChvYmpba2V5XSwgb2JqKSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB4cy5wdXNoKGtleSArICc6ICcgKyBpbnNwZWN0KG9ialtrZXldLCBvYmopKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBpZiAodHlwZW9mIGdPUFMgPT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgZm9yICh2YXIgaiA9IDA7IGogPCBzeW1zLmxlbmd0aDsgaisrKSB7XG4gICAgICAgICAgICBpZiAoaXNFbnVtZXJhYmxlLmNhbGwob2JqLCBzeW1zW2pdKSkge1xuICAgICAgICAgICAgICAgIHhzLnB1c2goJ1snICsgaW5zcGVjdChzeW1z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lc3RzW2ldO1xuICAgICAgICAgICAgICAgIGlmICghb25seSB8fCB0ID09PSBvbmx5KSB7XG4gICAgICAgICAgICAgICAgICAgIHQuX2V4aXQoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaGFybmVzcy5jbG9zZSgpO1xuXG4gICAgICAgIHByb2Nlc3MucmVtb3ZlQWxsTGlzdGVuZXJzKCdleGl0Jyk7IC8vIG5lY2Vzc2FyeSBmb3Igbm9kZSB2MC42XG4gICAgICAgIHByb2Nlc3MuZXhpdChjb2RlIHx8IGhhcm5lc3MuX2V4aXRDb2RlKTsgLy8gZXNsaW50LWRpc2FibGUtbGluZSBuby1wcm9jZXNzLWV4aXRcbiAgICB9KTtcblxuICAgIHJldHVybiBoYXJuZXNzO1xuXG4gICAgZnVuY3Rpb24gcnVuKCkge1xuICAgICAgICBpZiAocnVubmluZykgeyByZXR1cm47IH1cbiAgICAgICAgcnVubmluZyA9IHRydWU7XG4gICAgICAgIHZhciBzdHJlYW0gPSBoYXJuZXNzLmNyZWF0ZVN0cmVhbSh7IG9iamVjdE1vZGU6IGNvbmZpZy5vYmplY3RNb2RlIH0pO1xuICAgICAgICB2YXIgZXMgPSBzdHJlYW0ucGlwZShjb25maWcuc3RyZWFtIHx8IGNyZWF0ZURlZmF1bHRTdHJlYW0oKSk7XG4gICAgICAgIGlmIChjYW5FbWl0RXhpdCkge1xuICAgICAgICAgICAgLy8gVE9ETzogdXNlIGBlcnJgIGFyZz9cbiAgICAgICAgICAgIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBuby11bnVzZWQtdmFyc1xuICAgICAgICAgICAgZXMub24oJ2Vycm9yJywgZnVuY3Rpb24gKGVycikgeyBoYXJuZXNzLl9leGl0Q29kZSA9IDE7IH0pO1xuICAgICAgICB9XG4gICAgICAgIHN0cmVhbS5vbignZW5kJywgZnVuY3Rpb24gKCkgeyBlbmRlZCA9IHRydWU7IH0pO1xuIC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oJ3Rocm91Z2gnKTtcbnZhciBmcyA9IHJlcXVpcmUoJ2ZzJyk7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKCkge1xuICAgIHZhciBsaW5lID0gJyc7XG4gICAgdmFyIHN0cmVhbSA9IHRocm91Z2god3JpdGUsIGZsdXNoKTtcbiAgICByZXR1cm4gc3RyZWFtO1xuXG4gICAgZnVuY3Rpb24gd3JpdGUoYnVmKSB7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgYnVmLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB2YXIgYyA9IHR5cGVvZiBidWYgPT09ICdzdHJpbmcnXG4gICAgICAgICAgICAgICAgPyBidWYuY2hhckF0KGkpXG4gICAgICAgICAgICAgICAgOiBTdHJpbmcuZnJvbUNoYXJDb2RlKGJ1ZltpXSk7XG4gICAgICAgICAgICBpZiAoYyA9PT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICBmbHVzaCgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBsaW5lICs9IGM7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBmbHVzaCgpIHtcbiAgICAgICAgaWYgKGZzLndyaXRlU3luYyAmJiAoL153aW4vKS50ZXN0KHByb2Nlc3MucGxhdGZvcm0pKSB7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGZzLndyaXRlU3luYygxLCBsaW5lICsgJ1xcbicpO1xuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgIHN0cmVhbS5lbWl0KCdlcnJvcicsIGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhsaW5lKTsgLy8gZXNsaW50LWRpc2FibGUtbGluZSBuby1jb25zb2xlXG4gICAgICAgIC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AgICAgICAgICAgICB2YXIgcm93ID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiAndGVzdCcsXG4gICAgICAgICAgICAgICAgICAgIG5hbWU6IHQubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGlkLFxuICAgICAgICAgICAgICAgICAgICBza2lwOiB0Ll9za2lwLFxuICAgICAgICAgICAgICAgICAgICB0b2RvOiB0Ll90b2RvXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBpZiAoaGFzKGV4dHJhLCAncGFyZW50JykpIHtcbiAgICAgICAgICAgICAgICAgICAgcm93LnBhcmVudCA9IGV4dHJhLnBhcmVudDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgb3V0cHV0LnF1ZXVlKHJvdyk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHQub24oJ3Rlc3QnLCBmdW5jdGlvbiAoc3QpIHtcbiAgICAgICAgICAgICAgICBvbnRlc3Qoc3QsIHsgcGFyZW50OiBpZCB9KTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdC5vbigncmVzdWx0JywgZnVuY3Rpb24gKHJlcykge1xuICAgICAgICAgICAgICAgIGlmIChyZXMgJiYgdHlwZW9mIHJlcyA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzLnRlc3QgPSBpZDtcbiAgICAgICAgICAgICAgICAgICAgcmVzLnR5cGUgPSAnYXNzZXJ0JztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgb3V0cHV0LnF1ZXVlKHJlcyk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHQub24oJ2VuZCcsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBvdXRwdXQucXVldWUoeyB0eXBlOiAnZW5kJywgdGVzdDogaWQgfSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgICAgIHNlbGYub24oJ2R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2ZXJ5dGhpbmcgbGVhZGluZyB1cCB0byB0aGUgZmlyc3Qgb3BlblxuICAgICAgICAgICAgICAgIHBhcmVudGhlc2VzICh0cmltbWVkKSBiZWZvcmUgb3VyIHBhdGhuYW1lLlxuXG4gICAgICAgICAgICAgICAgICAgIC8oPzooLiopXFxzK1xcKCk/L1xuXG4gICAgICAgICAgICAgICAgTGFzdCBwYXJ0IGNhcHR1cmVzIGZpbGUgcGF0aCBwbHVzIGxpbmUgbm8gKGFuZCBvcHRpb25hbFxuICAgICAgICAgICAgICAgIGNvbHVtbiBubykuXG5cbiAgICAgICAgICAgICAgICAgICAgLygoPzpcXC98W2EtekEtWl06XFxcXClbXjpcXCldKzooXFxkKykoPzo6KFxcZCspKT8pXFwpPy9cbiAgICAgICAgICAgICovXG4gICAgICAgICAgICB2YXIgcmUgPSAvXig/OlteXFxzXSpcXHMqXFxiYXRcXHMrKSg/OiguKilcXHMrXFwoKT8oKD86XFwvfFthLXpBLVpdOlxcXFwpW146KV0rOihcXGQrKSg/OjooXFxkKykpPylcXCk/JC87XG4gICAgICAgICAgICB2YXIgbGluZVdpdGhUb2tlbnMgPSAkcmVwbGFjZSgkcmVwbGFjZShlcnJbaV0sIHByb2Nlc3MuY3dkKCksICcvJENXRCcpLCBfX2Rpcm5hbWUsICcvJFRFU1QnKTtcbiAgICAgICAgICAgIHZhciBtID0gcmUuZXhlYyhsaW5lV2l0aFRva2Vucyk7XG5cbiAgICAgICAgICAgIGlmICghbSkge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgY2FsbERlc2NyaXB0aW9uID0gbVsxXSB8fCAnPGFub255bW91cz4nO1xuICAgICAgICAgICAgdmFyIGZpbGVQYXRoID0gJHJlcGxhY2UoJHJlcGxhY2UobVsyXSwgJy8kQ1dEJywgcHJvY2Vzcy5jd2QoKSksICcvJFRFU1QnLCBfX2Rpcm5hbWUpO1xuXG4gICAgICAgICAgIC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kcHVzaChrZXlzLCAnbmFtZScsICdtZXNzYWdlJyk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGtleXMubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignYHRocm93c2AgdmFsaWRhdGlvbiBvYmplY3QgbXVzdCBub3QgYmUgZW1wdHknKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHBhc3NlZCA9IGV2ZXJ5KGtleXMsIGZ1bmN0aW9uIChrZXkpIHtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGNhdWdodC5lcnJvcltrZXldID09PSAnc3RyaW5nJyAmJiBpc1JlZ0V4cChleHBlY3RlZFtrZXldKSAmJiAkZXhlYyhleHBlY3RlZFtrZXldLCBjYXVnaHQuZXJyb3Jba2V5XSkgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChrZXkgaW4gY2F1Z2h0LmVycm9yICYmIGRlZXBFcXVhbChjYXVnaHQuZXJyb3Jba2V5XSwgZXhwZWN0ZWRba2V5XSwgeyBzdHJpY3Q6IHRydWUgfSkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgdGhpcy5fYXNzZXJ0KCEhcGFzc2VkLCB7XG4gICAgICAgIG1lc3NhZ2U6IGRlZmluZWQobXNnLCAnc2hvdWxkIHRocm93JyksXG4gICAgICAgIG9wZXJhdG9yOiAndGhyb3dzJyxcbiAgICAgICAgYWN0dWFsOiBjYXVnaHQgJiYgY2F1Z2h0LmVycm9yLFxuICAgICAgICBleHBlY3RlZDogZXhwZWN0ZWQsXG4gICAgICAgIGVycm9yOiAhcGF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RXhwLiBSZWNlaXZlZCB0eXBlICcgKyB0eXBlb2YgcmVnZXhwICsgJyAoJyArIGluc3BlY3QocmVnZXhwKSArICcpJyksXG4gICAgICAgICAgICBvcGVyYXRvcjogJ21hdGNoJyxcbiAgICAgICAgICAgIGFjdHVhbDogb2JqZWN0VG9TdHJpbmcocmVnZXhwKSxcbiAgICAgICAgICAgIGV4cGVjdGVkOiAnW29iamVjdCBSZWdFeHBdJyxcbiAgICAgICAgICAgIGV4dHJhOiBleHRyYVxuICAgICAgICB9KTtcbiAgICB9IGVsc2UgaWYgKHR5cGVvZiBzdHJpbmcgIT09ICdzdHJpbmcnKSB7XG4gICAgICAgIHRoaXMuX2Fzc2VydChmYWxzZSwge1xuICAgICAgICAgICAgbWVzc2FnZTogZGVmaW5lZChtc2csICdUaGUgXCJzdHJpbmdcIiBhcmd1bWVudCBtdXN0IGJlIG9mIHR5cGUgc3RyaW5nLiBSZWNlaXZlZCB0eXBlICcgKyB0eXBlb2Ygc3RyaW5nICsgJyAoJyArIGluc3BlY3Qoc3RyaW5nKSArICcpJyksXG4gICAgICAgICAgICBvcGVyYXRvcjogJ21hdGNoJyxcbiAgICAgICAgICAgIGFjdHVhbDogc3RyaW5nID09PSBudWxsID8gbnVsbCA6IHR5cGVvZiBzdHJpbmcsXG4gICAgICAgICAgICBleHBlY3RlZDogJ3N0cmluZycsXG4gICAgICAgICAgICBleHRyYTogZXh0cmFcbiAgICAgICAgfSk7XG4gICAgfSBlbHNlIHtcbiAgICAgICAgdmFyIG1hdGNoZXMgPSAkZXhlYyhyZWdleHAsIHN0cmluZykgIT09IG51bGw7XG4gICAgICAgIHZhciBtZXNzYWdlID0gZGVmaW5lZChcbiAgICAgICAgICAgIG1zZyxcbiAgICAgICAgICAgICdUaGUgaW5wdXQgJyArIChtYXRjaGVzID8gJ21hdGNoZWQnIDogJ2RpZCBub3QgbWF0Y2gnKSArICcgdGhlIHJlZ3VsYXIgZXhwcmVzc2lvbiAnICsgaW5zcGVjdChy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