Dieses Repository beinhaltet HTML- und Javascript Code zur einer NotizenWebApp auf Basis von Web Storage. Zudem sind Mocha/Chai Tests im Browser enthalten. https://meinenotizen.netlify.app/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mocha.js 592KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648
  1. (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){
  2. (function (process,global){
  3. 'use strict';
  4. /* eslint no-unused-vars: off */
  5. /* eslint-env commonjs */
  6. /**
  7. * Shim process.stdout.
  8. */
  9. process.stdout = require('browser-stdout')({label: false});
  10. var Mocha = require('./lib/mocha');
  11. /**
  12. * Create a Mocha instance.
  13. *
  14. * @return {undefined}
  15. */
  16. var mocha = new Mocha({reporter: 'html'});
  17. /**
  18. * Save timer references to avoid Sinon interfering (see GH-237).
  19. */
  20. var Date = global.Date;
  21. var setTimeout = global.setTimeout;
  22. var setInterval = global.setInterval;
  23. var clearTimeout = global.clearTimeout;
  24. var clearInterval = global.clearInterval;
  25. var uncaughtExceptionHandlers = [];
  26. var originalOnerrorHandler = global.onerror;
  27. /**
  28. * Remove uncaughtException listener.
  29. * Revert to original onerror handler if previously defined.
  30. */
  31. process.removeListener = function(e, fn) {
  32. if (e === 'uncaughtException') {
  33. if (originalOnerrorHandler) {
  34. global.onerror = originalOnerrorHandler;
  35. } else {
  36. global.onerror = function() {};
  37. }
  38. var i = uncaughtExceptionHandlers.indexOf(fn);
  39. if (i !== -1) {
  40. uncaughtExceptionHandlers.splice(i, 1);
  41. }
  42. }
  43. };
  44. /**
  45. * Implements listenerCount for 'uncaughtException'.
  46. */
  47. process.listenerCount = function(name) {
  48. if (name === 'uncaughtException') {
  49. return uncaughtExceptionHandlers.length;
  50. }
  51. return 0;
  52. };
  53. /**
  54. * Implements uncaughtException listener.
  55. */
  56. process.on = function(e, fn) {
  57. if (e === 'uncaughtException') {
  58. global.onerror = function(err, url, line) {
  59. fn(new Error(err + ' (' + url + ':' + line + ')'));
  60. return !mocha.options.allowUncaught;
  61. };
  62. uncaughtExceptionHandlers.push(fn);
  63. }
  64. };
  65. // The BDD UI is registered by default, but no UI will be functional in the
  66. // browser without an explicit call to the overridden `mocha.ui` (see below).
  67. // Ensure that this default UI does not expose its methods to the global scope.
  68. mocha.suite.removeAllListeners('pre-require');
  69. var immediateQueue = [];
  70. var immediateTimeout;
  71. function timeslice() {
  72. var immediateStart = new Date().getTime();
  73. while (immediateQueue.length && new Date().getTime() - immediateStart < 100) {
  74. immediateQueue.shift()();
  75. }
  76. if (immediateQueue.length) {
  77. immediateTimeout = setTimeout(timeslice, 0);
  78. } else {
  79. immediateTimeout = null;
  80. }
  81. }
  82. /**
  83. * High-performance override of Runner.immediately.
  84. */
  85. Mocha.Runner.immediately = function(callback) {
  86. immediateQueue.push(callback);
  87. if (!immediateTimeout) {
  88. immediateTimeout = setTimeout(timeslice, 0);
  89. }
  90. };
  91. /**
  92. * Function to allow assertion libraries to throw errors directly into mocha.
  93. * This is useful when running tests in a browser because window.onerror will
  94. * only receive the 'message' attribute of the Error.
  95. */
  96. mocha.throwError = function(err) {
  97. uncaughtExceptionHandlers.forEach(function(fn) {
  98. fn(err);
  99. });
  100. throw err;
  101. };
  102. /**
  103. * Override ui to ensure that the ui functions are initialized.
  104. * Normally this would happen in Mocha.prototype.loadFiles.
  105. */
  106. mocha.ui = function(ui) {
  107. Mocha.prototype.ui.call(this, ui);
  108. this.suite.emit('pre-require', global, null, this);
  109. return this;
  110. };
  111. /**
  112. * Setup mocha with the given setting options.
  113. */
  114. mocha.setup = function(opts) {
  115. if (typeof opts === 'string') {
  116. opts = {ui: opts};
  117. }
  118. for (var opt in opts) {
  119. if (Object.prototype.hasOwnProperty.call(opts, opt)) {
  120. this[opt](opts[opt]);
  121. }
  122. }
  123. return this;
  124. };
  125. /**
  126. * Run mocha, returning the Runner.
  127. */
  128. mocha.run = function(fn) {
  129. var options = mocha.options;
  130. mocha.globals('location');
  131. var query = Mocha.utils.parseQuery(global.location.search || '');
  132. if (query.grep) {
  133. mocha.grep(query.grep);
  134. }
  135. if (query.fgrep) {
  136. mocha.fgrep(query.fgrep);
  137. }
  138. if (query.invert) {
  139. mocha.invert();
  140. }
  141. return Mocha.prototype.run.call(mocha, function(err) {
  142. // The DOM Document is not available in Web Workers.
  143. var document = global.document;
  144. if (
  145. document &&
  146. document.getElementById('mocha') &&
  147. options.noHighlighting !== true
  148. ) {
  149. Mocha.utils.highlightTags('code');
  150. }
  151. if (fn) {
  152. fn(err);
  153. }
  154. });
  155. };
  156. /**
  157. * Expose the process shim.
  158. * https://github.com/mochajs/mocha/pull/916
  159. */
  160. Mocha.process = process;
  161. /**
  162. * Expose mocha.
  163. */
  164. global.Mocha = Mocha;
  165. global.mocha = mocha;
  166. // this allows test/acceptance/required-tokens.js to pass; thus,
  167. // you can now do `const describe = require('mocha').describe` in a
  168. // browser context (assuming browserification). should fix #880
  169. module.exports = global;
  170. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  171. },{"./lib/mocha":14,"_process":69,"browser-stdout":41}],2:[function(require,module,exports){
  172. (function (process,global){
  173. 'use strict';
  174. /**
  175. * Web Notifications module.
  176. * @module Growl
  177. */
  178. /**
  179. * Save timer references to avoid Sinon interfering (see GH-237).
  180. */
  181. var Date = global.Date;
  182. var setTimeout = global.setTimeout;
  183. var EVENT_RUN_END = require('../runner').constants.EVENT_RUN_END;
  184. /**
  185. * Checks if browser notification support exists.
  186. *
  187. * @public
  188. * @see {@link https://caniuse.com/#feat=notifications|Browser support (notifications)}
  189. * @see {@link https://caniuse.com/#feat=promises|Browser support (promises)}
  190. * @see {@link Mocha#growl}
  191. * @see {@link Mocha#isGrowlCapable}
  192. * @return {boolean} whether browser notification support exists
  193. */
  194. exports.isCapable = function() {
  195. var hasNotificationSupport = 'Notification' in window;
  196. var hasPromiseSupport = typeof Promise === 'function';
  197. return process.browser && hasNotificationSupport && hasPromiseSupport;
  198. };
  199. /**
  200. * Implements browser notifications as a pseudo-reporter.
  201. *
  202. * @public
  203. * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/notification|Notification API}
  204. * @see {@link https://developers.google.com/web/fundamentals/push-notifications/display-a-notification|Displaying a Notification}
  205. * @see {@link Growl#isPermitted}
  206. * @see {@link Mocha#_growl}
  207. * @param {Runner} runner - Runner instance.
  208. */
  209. exports.notify = function(runner) {
  210. var promise = isPermitted();
  211. /**
  212. * Attempt notification.
  213. */
  214. var sendNotification = function() {
  215. // If user hasn't responded yet... "No notification for you!" (Seinfeld)
  216. Promise.race([promise, Promise.resolve(undefined)])
  217. .then(canNotify)
  218. .then(function() {
  219. display(runner);
  220. })
  221. .catch(notPermitted);
  222. };
  223. runner.once(EVENT_RUN_END, sendNotification);
  224. };
  225. /**
  226. * Checks if browser notification is permitted by user.
  227. *
  228. * @private
  229. * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Notification/permission|Notification.permission}
  230. * @see {@link Mocha#growl}
  231. * @see {@link Mocha#isGrowlPermitted}
  232. * @returns {Promise<boolean>} promise determining if browser notification
  233. * permissible when fulfilled.
  234. */
  235. function isPermitted() {
  236. var permitted = {
  237. granted: function allow() {
  238. return Promise.resolve(true);
  239. },
  240. denied: function deny() {
  241. return Promise.resolve(false);
  242. },
  243. default: function ask() {
  244. return Notification.requestPermission().then(function(permission) {
  245. return permission === 'granted';
  246. });
  247. }
  248. };
  249. return permitted[Notification.permission]();
  250. }
  251. /**
  252. * @summary
  253. * Determines if notification should proceed.
  254. *
  255. * @description
  256. * Notification shall <strong>not</strong> proceed unless `value` is true.
  257. *
  258. * `value` will equal one of:
  259. * <ul>
  260. * <li><code>true</code> (from `isPermitted`)</li>
  261. * <li><code>false</code> (from `isPermitted`)</li>
  262. * <li><code>undefined</code> (from `Promise.race`)</li>
  263. * </ul>
  264. *
  265. * @private
  266. * @param {boolean|undefined} value - Determines if notification permissible.
  267. * @returns {Promise<undefined>} Notification can proceed
  268. */
  269. function canNotify(value) {
  270. if (!value) {
  271. var why = value === false ? 'blocked' : 'unacknowledged';
  272. var reason = 'not permitted by user (' + why + ')';
  273. return Promise.reject(new Error(reason));
  274. }
  275. return Promise.resolve();
  276. }
  277. /**
  278. * Displays the notification.
  279. *
  280. * @private
  281. * @param {Runner} runner - Runner instance.
  282. */
  283. function display(runner) {
  284. var stats = runner.stats;
  285. var symbol = {
  286. cross: '\u274C',
  287. tick: '\u2705'
  288. };
  289. var logo = require('../../package').notifyLogo;
  290. var _message;
  291. var message;
  292. var title;
  293. if (stats.failures) {
  294. _message = stats.failures + ' of ' + stats.tests + ' tests failed';
  295. message = symbol.cross + ' ' + _message;
  296. title = 'Failed';
  297. } else {
  298. _message = stats.passes + ' tests passed in ' + stats.duration + 'ms';
  299. message = symbol.tick + ' ' + _message;
  300. title = 'Passed';
  301. }
  302. // Send notification
  303. var options = {
  304. badge: logo,
  305. body: message,
  306. dir: 'ltr',
  307. icon: logo,
  308. lang: 'en-US',
  309. name: 'mocha',
  310. requireInteraction: false,
  311. timestamp: Date.now()
  312. };
  313. var notification = new Notification(title, options);
  314. // Autoclose after brief delay (makes various browsers act same)
  315. var FORCE_DURATION = 4000;
  316. setTimeout(notification.close.bind(notification), FORCE_DURATION);
  317. }
  318. /**
  319. * As notifications are tangential to our purpose, just log the error.
  320. *
  321. * @private
  322. * @param {Error} err - Why notification didn't happen.
  323. */
  324. function notPermitted(err) {
  325. console.error('notification error:', err.message);
  326. }
  327. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  328. },{"../../package":90,"../runner":34,"_process":69}],3:[function(require,module,exports){
  329. 'use strict';
  330. /**
  331. * Expose `Progress`.
  332. */
  333. module.exports = Progress;
  334. /**
  335. * Initialize a new `Progress` indicator.
  336. */
  337. function Progress() {
  338. this.percent = 0;
  339. this.size(0);
  340. this.fontSize(11);
  341. this.font('helvetica, arial, sans-serif');
  342. }
  343. /**
  344. * Set progress size to `size`.
  345. *
  346. * @public
  347. * @param {number} size
  348. * @return {Progress} Progress instance.
  349. */
  350. Progress.prototype.size = function(size) {
  351. this._size = size;
  352. return this;
  353. };
  354. /**
  355. * Set text to `text`.
  356. *
  357. * @public
  358. * @param {string} text
  359. * @return {Progress} Progress instance.
  360. */
  361. Progress.prototype.text = function(text) {
  362. this._text = text;
  363. return this;
  364. };
  365. /**
  366. * Set font size to `size`.
  367. *
  368. * @public
  369. * @param {number} size
  370. * @return {Progress} Progress instance.
  371. */
  372. Progress.prototype.fontSize = function(size) {
  373. this._fontSize = size;
  374. return this;
  375. };
  376. /**
  377. * Set font to `family`.
  378. *
  379. * @param {string} family
  380. * @return {Progress} Progress instance.
  381. */
  382. Progress.prototype.font = function(family) {
  383. this._font = family;
  384. return this;
  385. };
  386. /**
  387. * Update percentage to `n`.
  388. *
  389. * @param {number} n
  390. * @return {Progress} Progress instance.
  391. */
  392. Progress.prototype.update = function(n) {
  393. this.percent = n;
  394. return this;
  395. };
  396. /**
  397. * Draw on `ctx`.
  398. *
  399. * @param {CanvasRenderingContext2d} ctx
  400. * @return {Progress} Progress instance.
  401. */
  402. Progress.prototype.draw = function(ctx) {
  403. try {
  404. var percent = Math.min(this.percent, 100);
  405. var size = this._size;
  406. var half = size / 2;
  407. var x = half;
  408. var y = half;
  409. var rad = half - 1;
  410. var fontSize = this._fontSize;
  411. ctx.font = fontSize + 'px ' + this._font;
  412. var angle = Math.PI * 2 * (percent / 100);
  413. ctx.clearRect(0, 0, size, size);
  414. // outer circle
  415. ctx.strokeStyle = '#9f9f9f';
  416. ctx.beginPath();
  417. ctx.arc(x, y, rad, 0, angle, false);
  418. ctx.stroke();
  419. // inner circle
  420. ctx.strokeStyle = '#eee';
  421. ctx.beginPath();
  422. ctx.arc(x, y, rad - 1, 0, angle, true);
  423. ctx.stroke();
  424. // text
  425. var text = this._text || (percent | 0) + '%';
  426. var w = ctx.measureText(text).width;
  427. ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
  428. } catch (ignore) {
  429. // don't fail if we can't render progress
  430. }
  431. return this;
  432. };
  433. },{}],4:[function(require,module,exports){
  434. (function (global){
  435. 'use strict';
  436. exports.isatty = function isatty() {
  437. return true;
  438. };
  439. exports.getWindowSize = function getWindowSize() {
  440. if ('innerHeight' in global) {
  441. return [global.innerHeight, global.innerWidth];
  442. }
  443. // In a Web Worker, the DOM Window is not available.
  444. return [640, 480];
  445. };
  446. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  447. },{}],5:[function(require,module,exports){
  448. 'use strict';
  449. /**
  450. * @module Context
  451. */
  452. /**
  453. * Expose `Context`.
  454. */
  455. module.exports = Context;
  456. /**
  457. * Initialize a new `Context`.
  458. *
  459. * @private
  460. */
  461. function Context() {}
  462. /**
  463. * Set or get the context `Runnable` to `runnable`.
  464. *
  465. * @private
  466. * @param {Runnable} runnable
  467. * @return {Context} context
  468. */
  469. Context.prototype.runnable = function(runnable) {
  470. if (!arguments.length) {
  471. return this._runnable;
  472. }
  473. this.test = this._runnable = runnable;
  474. return this;
  475. };
  476. /**
  477. * Set or get test timeout `ms`.
  478. *
  479. * @private
  480. * @param {number} ms
  481. * @return {Context} self
  482. */
  483. Context.prototype.timeout = function(ms) {
  484. if (!arguments.length) {
  485. return this.runnable().timeout();
  486. }
  487. this.runnable().timeout(ms);
  488. return this;
  489. };
  490. /**
  491. * Set test timeout `enabled`.
  492. *
  493. * @private
  494. * @param {boolean} enabled
  495. * @return {Context} self
  496. */
  497. Context.prototype.enableTimeouts = function(enabled) {
  498. if (!arguments.length) {
  499. return this.runnable().enableTimeouts();
  500. }
  501. this.runnable().enableTimeouts(enabled);
  502. return this;
  503. };
  504. /**
  505. * Set or get test slowness threshold `ms`.
  506. *
  507. * @private
  508. * @param {number} ms
  509. * @return {Context} self
  510. */
  511. Context.prototype.slow = function(ms) {
  512. if (!arguments.length) {
  513. return this.runnable().slow();
  514. }
  515. this.runnable().slow(ms);
  516. return this;
  517. };
  518. /**
  519. * Mark a test as skipped.
  520. *
  521. * @private
  522. * @throws Pending
  523. */
  524. Context.prototype.skip = function() {
  525. this.runnable().skip();
  526. };
  527. /**
  528. * Set or get a number of allowed retries on failed tests
  529. *
  530. * @private
  531. * @param {number} n
  532. * @return {Context} self
  533. */
  534. Context.prototype.retries = function(n) {
  535. if (!arguments.length) {
  536. return this.runnable().retries();
  537. }
  538. this.runnable().retries(n);
  539. return this;
  540. };
  541. },{}],6:[function(require,module,exports){
  542. 'use strict';
  543. var format = require('util').format;
  544. /**
  545. * Factory functions to create throwable error objects
  546. * @module Errors
  547. */
  548. /**
  549. * When Mocha throw exceptions (or otherwise errors), it attempts to assign a
  550. * `code` property to the `Error` object, for easier handling. These are the
  551. * potential values of `code`.
  552. */
  553. var constants = {
  554. /**
  555. * An unrecoverable error.
  556. */
  557. FATAL: 'ERR_MOCHA_FATAL',
  558. /**
  559. * The type of an argument to a function call is invalid
  560. */
  561. INVALID_ARG_TYPE: 'ERR_MOCHA_INVALID_ARG_TYPE',
  562. /**
  563. * The value of an argument to a function call is invalid
  564. */
  565. INVALID_ARG_VALUE: 'ERR_MOCHA_INVALID_ARG_VALUE',
  566. /**
  567. * Something was thrown, but it wasn't an `Error`
  568. */
  569. INVALID_EXCEPTION: 'ERR_MOCHA_INVALID_EXCEPTION',
  570. /**
  571. * An interface (e.g., `Mocha.interfaces`) is unknown or invalid
  572. */
  573. INVALID_INTERFACE: 'ERR_MOCHA_INVALID_INTERFACE',
  574. /**
  575. * A reporter (.e.g, `Mocha.reporters`) is unknown or invalid
  576. */
  577. INVALID_REPORTER: 'ERR_MOCHA_INVALID_REPORTER',
  578. /**
  579. * `done()` was called twice in a `Test` or `Hook` callback
  580. */
  581. MULTIPLE_DONE: 'ERR_MOCHA_MULTIPLE_DONE',
  582. /**
  583. * No files matched the pattern provided by the user
  584. */
  585. NO_FILES_MATCH_PATTERN: 'ERR_MOCHA_NO_FILES_MATCH_PATTERN',
  586. /**
  587. * Known, but unsupported behavior of some kind
  588. */
  589. UNSUPPORTED: 'ERR_MOCHA_UNSUPPORTED',
  590. /**
  591. * Invalid state transition occuring in `Mocha` instance
  592. */
  593. INSTANCE_ALREADY_RUNNING: 'ERR_MOCHA_INSTANCE_ALREADY_RUNNING',
  594. /**
  595. * Invalid state transition occuring in `Mocha` instance
  596. */
  597. INSTANCE_ALREADY_DISPOSED: 'ERR_MOCHA_INSTANCE_ALREADY_DISPOSED'
  598. };
  599. /**
  600. * Creates an error object to be thrown when no files to be tested could be found using specified pattern.
  601. *
  602. * @public
  603. * @param {string} message - Error message to be displayed.
  604. * @param {string} pattern - User-specified argument value.
  605. * @returns {Error} instance detailing the error condition
  606. */
  607. function createNoFilesMatchPatternError(message, pattern) {
  608. var err = new Error(message);
  609. err.code = constants.NO_FILES_MATCH_PATTERN;
  610. err.pattern = pattern;
  611. return err;
  612. }
  613. /**
  614. * Creates an error object to be thrown when the reporter specified in the options was not found.
  615. *
  616. * @public
  617. * @param {string} message - Error message to be displayed.
  618. * @param {string} reporter - User-specified reporter value.
  619. * @returns {Error} instance detailing the error condition
  620. */
  621. function createInvalidReporterError(message, reporter) {
  622. var err = new TypeError(message);
  623. err.code = constants.INVALID_REPORTER;
  624. err.reporter = reporter;
  625. return err;
  626. }
  627. /**
  628. * Creates an error object to be thrown when the interface specified in the options was not found.
  629. *
  630. * @public
  631. * @param {string} message - Error message to be displayed.
  632. * @param {string} ui - User-specified interface value.
  633. * @returns {Error} instance detailing the error condition
  634. */
  635. function createInvalidInterfaceError(message, ui) {
  636. var err = new Error(message);
  637. err.code = constants.INVALID_INTERFACE;
  638. err.interface = ui;
  639. return err;
  640. }
  641. /**
  642. * Creates an error object to be thrown when a behavior, option, or parameter is unsupported.
  643. *
  644. * @public
  645. * @param {string} message - Error message to be displayed.
  646. * @returns {Error} instance detailing the error condition
  647. */
  648. function createUnsupportedError(message) {
  649. var err = new Error(message);
  650. err.code = constants.UNSUPPORTED;
  651. return err;
  652. }
  653. /**
  654. * Creates an error object to be thrown when an argument is missing.
  655. *
  656. * @public
  657. * @param {string} message - Error message to be displayed.
  658. * @param {string} argument - Argument name.
  659. * @param {string} expected - Expected argument datatype.
  660. * @returns {Error} instance detailing the error condition
  661. */
  662. function createMissingArgumentError(message, argument, expected) {
  663. return createInvalidArgumentTypeError(message, argument, expected);
  664. }
  665. /**
  666. * Creates an error object to be thrown when an argument did not use the supported type
  667. *
  668. * @public
  669. * @param {string} message - Error message to be displayed.
  670. * @param {string} argument - Argument name.
  671. * @param {string} expected - Expected argument datatype.
  672. * @returns {Error} instance detailing the error condition
  673. */
  674. function createInvalidArgumentTypeError(message, argument, expected) {
  675. var err = new TypeError(message);
  676. err.code = constants.INVALID_ARG_TYPE;
  677. err.argument = argument;
  678. err.expected = expected;
  679. err.actual = typeof argument;
  680. return err;
  681. }
  682. /**
  683. * Creates an error object to be thrown when an argument did not use the supported value
  684. *
  685. * @public
  686. * @param {string} message - Error message to be displayed.
  687. * @param {string} argument - Argument name.
  688. * @param {string} value - Argument value.
  689. * @param {string} [reason] - Why value is invalid.
  690. * @returns {Error} instance detailing the error condition
  691. */
  692. function createInvalidArgumentValueError(message, argument, value, reason) {
  693. var err = new TypeError(message);
  694. err.code = constants.INVALID_ARG_VALUE;
  695. err.argument = argument;
  696. err.value = value;
  697. err.reason = typeof reason !== 'undefined' ? reason : 'is invalid';
  698. return err;
  699. }
  700. /**
  701. * Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined.
  702. *
  703. * @public
  704. * @param {string} message - Error message to be displayed.
  705. * @returns {Error} instance detailing the error condition
  706. */
  707. function createInvalidExceptionError(message, value) {
  708. var err = new Error(message);
  709. err.code = constants.INVALID_EXCEPTION;
  710. err.valueType = typeof value;
  711. err.value = value;
  712. return err;
  713. }
  714. /**
  715. * Creates an error object to be thrown when an unrecoverable error occurs.
  716. *
  717. * @public
  718. * @param {string} message - Error message to be displayed.
  719. * @returns {Error} instance detailing the error condition
  720. */
  721. function createFatalError(message, value) {
  722. var err = new Error(message);
  723. err.code = constants.FATAL;
  724. err.valueType = typeof value;
  725. err.value = value;
  726. return err;
  727. }
  728. /**
  729. * Dynamically creates a plugin-type-specific error based on plugin type
  730. * @param {string} message - Error message
  731. * @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed
  732. * @param {string} [pluginId] - Name/path of plugin, if any
  733. * @throws When `pluginType` is not known
  734. * @public
  735. * @returns {Error}
  736. */
  737. function createInvalidPluginError(message, pluginType, pluginId) {
  738. switch (pluginType) {
  739. case 'reporter':
  740. return createInvalidReporterError(message, pluginId);
  741. case 'interface':
  742. return createInvalidInterfaceError(message, pluginId);
  743. default:
  744. throw new Error('unknown pluginType "' + pluginType + '"');
  745. }
  746. }
  747. /**
  748. * Creates an error object to be thrown when a mocha object's `run` method is executed while it is already disposed.
  749. * @param {string} message The error message to be displayed.
  750. * @param {boolean} cleanReferencesAfterRun the value of `cleanReferencesAfterRun`
  751. * @param {Mocha} instance the mocha instance that throw this error
  752. */
  753. function createMochaInstanceAlreadyDisposedError(
  754. message,
  755. cleanReferencesAfterRun,
  756. instance
  757. ) {
  758. var err = new Error(message);
  759. err.code = constants.INSTANCE_ALREADY_DISPOSED;
  760. err.cleanReferencesAfterRun = cleanReferencesAfterRun;
  761. err.instance = instance;
  762. return err;
  763. }
  764. /**
  765. * Creates an error object to be thrown when a mocha object's `run` method is called while a test run is in progress.
  766. * @param {string} message The error message to be displayed.
  767. */
  768. function createMochaInstanceAlreadyRunningError(message, instance) {
  769. var err = new Error(message);
  770. err.code = constants.INSTANCE_ALREADY_RUNNING;
  771. err.instance = instance;
  772. return err;
  773. }
  774. /*
  775. * Creates an error object to be thrown when done() is called multiple times in a test
  776. *
  777. * @public
  778. * @param {Runnable} runnable - Original runnable
  779. * @param {Error} [originalErr] - Original error, if any
  780. * @returns {Error} instance detailing the error condition
  781. */
  782. function createMultipleDoneError(runnable, originalErr) {
  783. var title;
  784. try {
  785. title = format('<%s>', runnable.fullTitle());
  786. if (runnable.parent.root) {
  787. title += ' (of root suite)';
  788. }
  789. } catch (ignored) {
  790. title = format('<%s> (of unknown suite)', runnable.title);
  791. }
  792. var message = format(
  793. 'done() called multiple times in %s %s',
  794. runnable.type ? runnable.type : 'unknown runnable',
  795. title
  796. );
  797. if (runnable.file) {
  798. message += format(' of file %s', runnable.file);
  799. }
  800. if (originalErr) {
  801. message += format('; in addition, done() received error: %s', originalErr);
  802. }
  803. var err = new Error(message);
  804. err.code = constants.MULTIPLE_DONE;
  805. err.valueType = typeof originalErr;
  806. err.value = originalErr;
  807. return err;
  808. }
  809. module.exports = {
  810. createInvalidArgumentTypeError: createInvalidArgumentTypeError,
  811. createInvalidArgumentValueError: createInvalidArgumentValueError,
  812. createInvalidExceptionError: createInvalidExceptionError,
  813. createInvalidInterfaceError: createInvalidInterfaceError,
  814. createInvalidReporterError: createInvalidReporterError,
  815. createMissingArgumentError: createMissingArgumentError,
  816. createNoFilesMatchPatternError: createNoFilesMatchPatternError,
  817. createUnsupportedError: createUnsupportedError,
  818. createInvalidPluginError: createInvalidPluginError,
  819. createMochaInstanceAlreadyDisposedError: createMochaInstanceAlreadyDisposedError,
  820. createMochaInstanceAlreadyRunningError: createMochaInstanceAlreadyRunningError,
  821. createFatalError: createFatalError,
  822. createMultipleDoneError: createMultipleDoneError,
  823. constants: constants
  824. };
  825. },{"util":89}],7:[function(require,module,exports){
  826. 'use strict';
  827. var Runnable = require('./runnable');
  828. var inherits = require('./utils').inherits;
  829. /**
  830. * Expose `Hook`.
  831. */
  832. module.exports = Hook;
  833. /**
  834. * Initialize a new `Hook` with the given `title` and callback `fn`
  835. *
  836. * @class
  837. * @extends Runnable
  838. * @param {String} title
  839. * @param {Function} fn
  840. */
  841. function Hook(title, fn) {
  842. Runnable.call(this, title, fn);
  843. this.type = 'hook';
  844. }
  845. /**
  846. * Inherit from `Runnable.prototype`.
  847. */
  848. inherits(Hook, Runnable);
  849. /**
  850. * Resets the state for a next run.
  851. */
  852. Hook.prototype.reset = function() {
  853. Runnable.prototype.reset.call(this);
  854. delete this._error;
  855. };
  856. /**
  857. * Get or set the test `err`.
  858. *
  859. * @memberof Hook
  860. * @public
  861. * @param {Error} err
  862. * @return {Error}
  863. */
  864. Hook.prototype.error = function(err) {
  865. if (!arguments.length) {
  866. err = this._error;
  867. this._error = null;
  868. return err;
  869. }
  870. this._error = err;
  871. };
  872. },{"./runnable":33,"./utils":38}],8:[function(require,module,exports){
  873. 'use strict';
  874. var Test = require('../test');
  875. var EVENT_FILE_PRE_REQUIRE = require('../suite').constants
  876. .EVENT_FILE_PRE_REQUIRE;
  877. /**
  878. * BDD-style interface:
  879. *
  880. * describe('Array', function() {
  881. * describe('#indexOf()', function() {
  882. * it('should return -1 when not present', function() {
  883. * // ...
  884. * });
  885. *
  886. * it('should return the index when present', function() {
  887. * // ...
  888. * });
  889. * });
  890. * });
  891. *
  892. * @param {Suite} suite Root suite.
  893. */
  894. module.exports = function bddInterface(suite) {
  895. var suites = [suite];
  896. suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) {
  897. var common = require('./common')(suites, context, mocha);
  898. context.before = common.before;
  899. context.after = common.after;
  900. context.beforeEach = common.beforeEach;
  901. context.afterEach = common.afterEach;
  902. context.run = mocha.options.delay && common.runWithSuite(suite);
  903. /**
  904. * Describe a "suite" with the given `title`
  905. * and callback `fn` containing nested suites
  906. * and/or tests.
  907. */
  908. context.describe = context.context = function(title, fn) {
  909. return common.suite.create({
  910. title: title,
  911. file: file,
  912. fn: fn
  913. });
  914. };
  915. /**
  916. * Pending describe.
  917. */
  918. context.xdescribe = context.xcontext = context.describe.skip = function(
  919. title,
  920. fn
  921. ) {
  922. return common.suite.skip({
  923. title: title,
  924. file: file,
  925. fn: fn
  926. });
  927. };
  928. /**
  929. * Exclusive suite.
  930. */
  931. context.describe.only = function(title, fn) {
  932. return common.suite.only({
  933. title: title,
  934. file: file,
  935. fn: fn
  936. });
  937. };
  938. /**
  939. * Describe a specification or test-case
  940. * with the given `title` and callback `fn`
  941. * acting as a thunk.
  942. */
  943. context.it = context.specify = function(title, fn) {
  944. var suite = suites[0];
  945. if (suite.isPending()) {
  946. fn = null;
  947. }
  948. var test = new Test(title, fn);
  949. test.file = file;
  950. suite.addTest(test);
  951. return test;
  952. };
  953. /**
  954. * Exclusive test-case.
  955. */
  956. context.it.only = function(title, fn) {
  957. return common.test.only(mocha, context.it(title, fn));
  958. };
  959. /**
  960. * Pending test case.
  961. */
  962. context.xit = context.xspecify = context.it.skip = function(title) {
  963. return context.it(title);
  964. };
  965. /**
  966. * Number of attempts to retry.
  967. */
  968. context.it.retries = function(n) {
  969. context.retries(n);
  970. };
  971. });
  972. };
  973. module.exports.description = 'BDD or RSpec style [default]';
  974. },{"../suite":36,"../test":37,"./common":9}],9:[function(require,module,exports){
  975. 'use strict';
  976. var Suite = require('../suite');
  977. var errors = require('../errors');
  978. var createMissingArgumentError = errors.createMissingArgumentError;
  979. var createUnsupportedError = errors.createUnsupportedError;
  980. /**
  981. * Functions common to more than one interface.
  982. *
  983. * @param {Suite[]} suites
  984. * @param {Context} context
  985. * @param {Mocha} mocha
  986. * @return {Object} An object containing common functions.
  987. */
  988. module.exports = function(suites, context, mocha) {
  989. /**
  990. * Check if the suite should be tested.
  991. *
  992. * @private
  993. * @param {Suite} suite - suite to check
  994. * @returns {boolean}
  995. */
  996. function shouldBeTested(suite) {
  997. return (
  998. !mocha.options.grep ||
  999. (mocha.options.grep &&
  1000. mocha.options.grep.test(suite.fullTitle()) &&
  1001. !mocha.options.invert)
  1002. );
  1003. }
  1004. return {
  1005. /**
  1006. * This is only present if flag --delay is passed into Mocha. It triggers
  1007. * root suite execution.
  1008. *
  1009. * @param {Suite} suite The root suite.
  1010. * @return {Function} A function which runs the root suite
  1011. */
  1012. runWithSuite: function runWithSuite(suite) {
  1013. return function run() {
  1014. suite.run();
  1015. };
  1016. },
  1017. /**
  1018. * Execute before running tests.
  1019. *
  1020. * @param {string} name
  1021. * @param {Function} fn
  1022. */
  1023. before: function(name, fn) {
  1024. suites[0].beforeAll(name, fn);
  1025. },
  1026. /**
  1027. * Execute after running tests.
  1028. *
  1029. * @param {string} name
  1030. * @param {Function} fn
  1031. */
  1032. after: function(name, fn) {
  1033. suites[0].afterAll(name, fn);
  1034. },
  1035. /**
  1036. * Execute before each test case.
  1037. *
  1038. * @param {string} name
  1039. * @param {Function} fn
  1040. */
  1041. beforeEach: function(name, fn) {
  1042. suites[0].beforeEach(name, fn);
  1043. },
  1044. /**
  1045. * Execute after each test case.
  1046. *
  1047. * @param {string} name
  1048. * @param {Function} fn
  1049. */
  1050. afterEach: function(name, fn) {
  1051. suites[0].afterEach(name, fn);
  1052. },
  1053. suite: {
  1054. /**
  1055. * Create an exclusive Suite; convenience function
  1056. * See docstring for create() below.
  1057. *
  1058. * @param {Object} opts
  1059. * @returns {Suite}
  1060. */
  1061. only: function only(opts) {
  1062. opts.isOnly = true;
  1063. return this.create(opts);
  1064. },
  1065. /**
  1066. * Create a Suite, but skip it; convenience function
  1067. * See docstring for create() below.
  1068. *
  1069. * @param {Object} opts
  1070. * @returns {Suite}
  1071. */
  1072. skip: function skip(opts) {
  1073. opts.pending = true;
  1074. return this.create(opts);
  1075. },
  1076. /**
  1077. * Creates a suite.
  1078. *
  1079. * @param {Object} opts Options
  1080. * @param {string} opts.title Title of Suite
  1081. * @param {Function} [opts.fn] Suite Function (not always applicable)
  1082. * @param {boolean} [opts.pending] Is Suite pending?
  1083. * @param {string} [opts.file] Filepath where this Suite resides
  1084. * @param {boolean} [opts.isOnly] Is Suite exclusive?
  1085. * @returns {Suite}
  1086. */
  1087. create: function create(opts) {
  1088. var suite = Suite.create(suites[0], opts.title);
  1089. suite.pending = Boolean(opts.pending);
  1090. suite.file = opts.file;
  1091. suites.unshift(suite);
  1092. if (opts.isOnly) {
  1093. if (mocha.options.forbidOnly && shouldBeTested(suite)) {
  1094. throw createUnsupportedError('`.only` forbidden');
  1095. }
  1096. suite.parent.appendOnlySuite(suite);
  1097. }
  1098. if (suite.pending) {
  1099. if (mocha.options.forbidPending && shouldBeTested(suite)) {
  1100. throw createUnsupportedError('Pending test forbidden');
  1101. }
  1102. }
  1103. if (typeof opts.fn === 'function') {
  1104. opts.fn.call(suite);
  1105. suites.shift();
  1106. } else if (typeof opts.fn === 'undefined' && !suite.pending) {
  1107. throw createMissingArgumentError(
  1108. 'Suite "' +
  1109. suite.fullTitle() +
  1110. '" was defined but no callback was supplied. ' +
  1111. 'Supply a callback or explicitly skip the suite.',
  1112. 'callback',
  1113. 'function'
  1114. );
  1115. } else if (!opts.fn && suite.pending) {
  1116. suites.shift();
  1117. }
  1118. return suite;
  1119. }
  1120. },
  1121. test: {
  1122. /**
  1123. * Exclusive test-case.
  1124. *
  1125. * @param {Object} mocha
  1126. * @param {Function} test
  1127. * @returns {*}
  1128. */
  1129. only: function(mocha, test) {
  1130. if (mocha.options.forbidOnly)
  1131. throw createUnsupportedError('`.only` forbidden');
  1132. test.markOnly();
  1133. return test;
  1134. },
  1135. /**
  1136. * Pending test case.
  1137. *
  1138. * @param {string} title
  1139. */
  1140. skip: function(title) {
  1141. context.test(title);
  1142. },
  1143. /**
  1144. * Number of retry attempts
  1145. *
  1146. * @param {number} n
  1147. */
  1148. retries: function(n) {
  1149. context.retries(n);
  1150. }
  1151. }
  1152. };
  1153. };
  1154. },{"../errors":6,"../suite":36}],10:[function(require,module,exports){
  1155. 'use strict';
  1156. var Suite = require('../suite');
  1157. var Test = require('../test');
  1158. /**
  1159. * Exports-style (as Node.js module) interface:
  1160. *
  1161. * exports.Array = {
  1162. * '#indexOf()': {
  1163. * 'should return -1 when the value is not present': function() {
  1164. *
  1165. * },
  1166. *
  1167. * 'should return the correct index when the value is present': function() {
  1168. *
  1169. * }
  1170. * }
  1171. * };
  1172. *
  1173. * @param {Suite} suite Root suite.
  1174. */
  1175. module.exports = function(suite) {
  1176. var suites = [suite];
  1177. suite.on(Suite.constants.EVENT_FILE_REQUIRE, visit);
  1178. function visit(obj, file) {
  1179. var suite;
  1180. for (var key in obj) {
  1181. if (typeof obj[key] === 'function') {
  1182. var fn = obj[key];
  1183. switch (key) {
  1184. case 'before':
  1185. suites[0].beforeAll(fn);
  1186. break;
  1187. case 'after':
  1188. suites[0].afterAll(fn);
  1189. break;
  1190. case 'beforeEach':
  1191. suites[0].beforeEach(fn);
  1192. break;
  1193. case 'afterEach':
  1194. suites[0].afterEach(fn);
  1195. break;
  1196. default:
  1197. var test = new Test(key, fn);
  1198. test.file = file;
  1199. suites[0].addTest(test);
  1200. }
  1201. } else {
  1202. suite = Suite.create(suites[0], key);
  1203. suites.unshift(suite);
  1204. visit(obj[key], file);
  1205. suites.shift();
  1206. }
  1207. }
  1208. }
  1209. };
  1210. module.exports.description = 'Node.js module ("exports") style';
  1211. },{"../suite":36,"../test":37}],11:[function(require,module,exports){
  1212. 'use strict';
  1213. exports.bdd = require('./bdd');
  1214. exports.tdd = require('./tdd');
  1215. exports.qunit = require('./qunit');
  1216. exports.exports = require('./exports');
  1217. },{"./bdd":8,"./exports":10,"./qunit":12,"./tdd":13}],12:[function(require,module,exports){
  1218. 'use strict';
  1219. var Test = require('../test');
  1220. var EVENT_FILE_PRE_REQUIRE = require('../suite').constants
  1221. .EVENT_FILE_PRE_REQUIRE;
  1222. /**
  1223. * QUnit-style interface:
  1224. *
  1225. * suite('Array');
  1226. *
  1227. * test('#length', function() {
  1228. * var arr = [1,2,3];
  1229. * ok(arr.length == 3);
  1230. * });
  1231. *
  1232. * test('#indexOf()', function() {
  1233. * var arr = [1,2,3];
  1234. * ok(arr.indexOf(1) == 0);
  1235. * ok(arr.indexOf(2) == 1);
  1236. * ok(arr.indexOf(3) == 2);
  1237. * });
  1238. *
  1239. * suite('String');
  1240. *
  1241. * test('#length', function() {
  1242. * ok('foo'.length == 3);
  1243. * });
  1244. *
  1245. * @param {Suite} suite Root suite.
  1246. */
  1247. module.exports = function qUnitInterface(suite) {
  1248. var suites = [suite];
  1249. suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) {
  1250. var common = require('./common')(suites, context, mocha);
  1251. context.before = common.before;
  1252. context.after = common.after;
  1253. context.beforeEach = common.beforeEach;
  1254. context.afterEach = common.afterEach;
  1255. context.run = mocha.options.delay && common.runWithSuite(suite);
  1256. /**
  1257. * Describe a "suite" with the given `title`.
  1258. */
  1259. context.suite = function(title) {
  1260. if (suites.length > 1) {
  1261. suites.shift();
  1262. }
  1263. return common.suite.create({
  1264. title: title,
  1265. file: file,
  1266. fn: false
  1267. });
  1268. };
  1269. /**
  1270. * Exclusive Suite.
  1271. */
  1272. context.suite.only = function(title) {
  1273. if (suites.length > 1) {
  1274. suites.shift();
  1275. }
  1276. return common.suite.only({
  1277. title: title,
  1278. file: file,
  1279. fn: false
  1280. });
  1281. };
  1282. /**
  1283. * Describe a specification or test-case
  1284. * with the given `title` and callback `fn`
  1285. * acting as a thunk.
  1286. */
  1287. context.test = function(title, fn) {
  1288. var test = new Test(title, fn);
  1289. test.file = file;
  1290. suites[0].addTest(test);
  1291. return test;
  1292. };
  1293. /**
  1294. * Exclusive test-case.
  1295. */
  1296. context.test.only = function(title, fn) {
  1297. return common.test.only(mocha, context.test(title, fn));
  1298. };
  1299. context.test.skip = common.test.skip;
  1300. context.test.retries = common.test.retries;
  1301. });
  1302. };
  1303. module.exports.description = 'QUnit style';
  1304. },{"../suite":36,"../test":37,"./common":9}],13:[function(require,module,exports){
  1305. 'use strict';
  1306. var Test = require('../test');
  1307. var EVENT_FILE_PRE_REQUIRE = require('../suite').constants
  1308. .EVENT_FILE_PRE_REQUIRE;
  1309. /**
  1310. * TDD-style interface:
  1311. *
  1312. * suite('Array', function() {
  1313. * suite('#indexOf()', function() {
  1314. * suiteSetup(function() {
  1315. *
  1316. * });
  1317. *
  1318. * test('should return -1 when not present', function() {
  1319. *
  1320. * });
  1321. *
  1322. * test('should return the index when present', function() {
  1323. *
  1324. * });
  1325. *
  1326. * suiteTeardown(function() {
  1327. *
  1328. * });
  1329. * });
  1330. * });
  1331. *
  1332. * @param {Suite} suite Root suite.
  1333. */
  1334. module.exports = function(suite) {
  1335. var suites = [suite];
  1336. suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) {
  1337. var common = require('./common')(suites, context, mocha);
  1338. context.setup = common.beforeEach;
  1339. context.teardown = common.afterEach;
  1340. context.suiteSetup = common.before;
  1341. context.suiteTeardown = common.after;
  1342. context.run = mocha.options.delay && common.runWithSuite(suite);
  1343. /**
  1344. * Describe a "suite" with the given `title` and callback `fn` containing
  1345. * nested suites and/or tests.
  1346. */
  1347. context.suite = function(title, fn) {
  1348. return common.suite.create({
  1349. title: title,
  1350. file: file,
  1351. fn: fn
  1352. });
  1353. };
  1354. /**
  1355. * Pending suite.
  1356. */
  1357. context.suite.skip = function(title, fn) {
  1358. return common.suite.skip({
  1359. title: title,
  1360. file: file,
  1361. fn: fn
  1362. });
  1363. };
  1364. /**
  1365. * Exclusive test-case.
  1366. */
  1367. context.suite.only = function(title, fn) {
  1368. return common.suite.only({
  1369. title: title,
  1370. file: file,
  1371. fn: fn
  1372. });
  1373. };
  1374. /**
  1375. * Describe a specification or test-case with the given `title` and
  1376. * callback `fn` acting as a thunk.
  1377. */
  1378. context.test = function(title, fn) {
  1379. var suite = suites[0];
  1380. if (suite.isPending()) {
  1381. fn = null;
  1382. }
  1383. var test = new Test(title, fn);
  1384. test.file = file;
  1385. suite.addTest(test);
  1386. return test;
  1387. };
  1388. /**
  1389. * Exclusive test-case.
  1390. */
  1391. context.test.only = function(title, fn) {
  1392. return common.test.only(mocha, context.test(title, fn));
  1393. };
  1394. context.test.skip = common.test.skip;
  1395. context.test.retries = common.test.retries;
  1396. });
  1397. };
  1398. module.exports.description =
  1399. 'traditional "suite"/"test" instead of BDD\'s "describe"/"it"';
  1400. },{"../suite":36,"../test":37,"./common":9}],14:[function(require,module,exports){
  1401. (function (process,global){
  1402. 'use strict';
  1403. /*!
  1404. * mocha
  1405. * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
  1406. * MIT Licensed
  1407. */
  1408. var escapeRe = require('escape-string-regexp');
  1409. var path = require('path');
  1410. var builtinReporters = require('./reporters');
  1411. var growl = require('./growl');
  1412. var utils = require('./utils');
  1413. var mocharc = require('./mocharc.json');
  1414. var errors = require('./errors');
  1415. var Suite = require('./suite');
  1416. var esmUtils = utils.supportsEsModules() ? require('./esm-utils') : undefined;
  1417. var createStatsCollector = require('./stats-collector');
  1418. var createInvalidReporterError = errors.createInvalidReporterError;
  1419. var createInvalidInterfaceError = errors.createInvalidInterfaceError;
  1420. var createMochaInstanceAlreadyDisposedError =
  1421. errors.createMochaInstanceAlreadyDisposedError;
  1422. var createMochaInstanceAlreadyRunningError =
  1423. errors.createMochaInstanceAlreadyRunningError;
  1424. var EVENT_FILE_PRE_REQUIRE = Suite.constants.EVENT_FILE_PRE_REQUIRE;
  1425. var EVENT_FILE_POST_REQUIRE = Suite.constants.EVENT_FILE_POST_REQUIRE;
  1426. var EVENT_FILE_REQUIRE = Suite.constants.EVENT_FILE_REQUIRE;
  1427. var sQuote = utils.sQuote;
  1428. exports = module.exports = Mocha;
  1429. /**
  1430. * A Mocha instance is a finite state machine.
  1431. * These are the states it can be in.
  1432. */
  1433. var mochaStates = utils.defineConstants({
  1434. /**
  1435. * Initial state of the mocha instance
  1436. */
  1437. INIT: 'init',
  1438. /**
  1439. * Mocha instance is running tests
  1440. */
  1441. RUNNING: 'running',
  1442. /**
  1443. * Mocha instance is done running tests and references to test functions and hooks are cleaned.
  1444. * You can reset this state by unloading the test files.
  1445. */
  1446. REFERENCES_CLEANED: 'referencesCleaned',
  1447. /**
  1448. * Mocha instance is disposed and can no longer be used.
  1449. */
  1450. DISPOSED: 'disposed'
  1451. });
  1452. /**
  1453. * To require local UIs and reporters when running in node.
  1454. */
  1455. if (!process.browser && typeof module.paths !== 'undefined') {
  1456. var cwd = utils.cwd();
  1457. module.paths.push(cwd, path.join(cwd, 'node_modules'));
  1458. }
  1459. /**
  1460. * Expose internals.
  1461. */
  1462. /**
  1463. * @public
  1464. * @class utils
  1465. * @memberof Mocha
  1466. */
  1467. exports.utils = utils;
  1468. exports.interfaces = require('./interfaces');
  1469. /**
  1470. * @public
  1471. * @memberof Mocha
  1472. */
  1473. exports.reporters = builtinReporters;
  1474. exports.Runnable = require('./runnable');
  1475. exports.Context = require('./context');
  1476. /**
  1477. *
  1478. * @memberof Mocha
  1479. */
  1480. exports.Runner = require('./runner');
  1481. exports.Suite = Suite;
  1482. exports.Hook = require('./hook');
  1483. exports.Test = require('./test');
  1484. /**
  1485. * Constructs a new Mocha instance with `options`.
  1486. *
  1487. * @public
  1488. * @class Mocha
  1489. * @param {Object} [options] - Settings object.
  1490. * @param {boolean} [options.allowUncaught] - Propagate uncaught errors?
  1491. * @param {boolean} [options.asyncOnly] - Force `done` callback or promise?
  1492. * @param {boolean} [options.bail] - Bail after first test failure?
  1493. * @param {boolean} [options.checkLeaks] - Check for global variable leaks?
  1494. * @param {boolean} [options.color] - Color TTY output from reporter?
  1495. * @param {boolean} [options.delay] - Delay root suite execution?
  1496. * @param {boolean} [options.diff] - Show diff on failure?
  1497. * @param {string} [options.fgrep] - Test filter given string.
  1498. * @param {boolean} [options.forbidOnly] - Tests marked `only` fail the suite?
  1499. * @param {boolean} [options.forbidPending] - Pending tests fail the suite?
  1500. * @param {boolean} [options.fullTrace] - Full stacktrace upon failure?
  1501. * @param {string[]} [options.global] - Variables expected in global scope.
  1502. * @param {RegExp|string} [options.grep] - Test filter given regular expression.
  1503. * @param {boolean} [options.growl] - Enable desktop notifications?
  1504. * @param {boolean} [options.inlineDiffs] - Display inline diffs?
  1505. * @param {boolean} [options.invert] - Invert test filter matches?
  1506. * @param {boolean} [options.noHighlighting] - Disable syntax highlighting?
  1507. * @param {string|constructor} [options.reporter] - Reporter name or constructor.
  1508. * @param {Object} [options.reporterOption] - Reporter settings object.
  1509. * @param {number} [options.retries] - Number of times to retry failed tests.
  1510. * @param {number} [options.slow] - Slow threshold value.
  1511. * @param {number|string} [options.timeout] - Timeout threshold value.
  1512. * @param {string} [options.ui] - Interface name.
  1513. * @param {MochaRootHookObject} [options.rootHooks] - Hooks to bootstrap the root
  1514. * suite with
  1515. */
  1516. function Mocha(options) {
  1517. options = utils.assign({}, mocharc, options || {});
  1518. this.files = [];
  1519. this.options = options;
  1520. // root suite
  1521. this.suite = new exports.Suite('', new exports.Context(), true);
  1522. this._cleanReferencesAfterRun = true;
  1523. this.grep(options.grep)
  1524. .fgrep(options.fgrep)
  1525. .ui(options.ui)
  1526. .reporter(
  1527. options.reporter,
  1528. options.reporterOption || options.reporterOptions // reporterOptions was previously the only way to specify options to reporter
  1529. )
  1530. .slow(options.slow)
  1531. .global(options.global);
  1532. // this guard exists because Suite#timeout does not consider `undefined` to be valid input
  1533. if (typeof options.timeout !== 'undefined') {
  1534. this.timeout(options.timeout === false ? 0 : options.timeout);
  1535. }
  1536. if ('retries' in options) {
  1537. this.retries(options.retries);
  1538. }
  1539. [
  1540. 'allowUncaught',
  1541. 'asyncOnly',
  1542. 'bail',
  1543. 'checkLeaks',
  1544. 'color',
  1545. 'delay',
  1546. 'diff',
  1547. 'forbidOnly',
  1548. 'forbidPending',
  1549. 'fullTrace',
  1550. 'growl',
  1551. 'inlineDiffs',
  1552. 'invert'
  1553. ].forEach(function(opt) {
  1554. if (options[opt]) {
  1555. this[opt]();
  1556. }
  1557. }, this);
  1558. if (options.rootHooks) {
  1559. this.rootHooks(options.rootHooks);
  1560. }
  1561. }
  1562. /**
  1563. * Enables or disables bailing on the first failure.
  1564. *
  1565. * @public
  1566. * @see [CLI option](../#-bail-b)
  1567. * @param {boolean} [bail=true] - Whether to bail on first error.
  1568. * @returns {Mocha} this
  1569. * @chainable
  1570. */
  1571. Mocha.prototype.bail = function(bail) {
  1572. this.suite.bail(bail !== false);
  1573. return this;
  1574. };
  1575. /**
  1576. * @summary
  1577. * Adds `file` to be loaded for execution.
  1578. *
  1579. * @description
  1580. * Useful for generic setup code that must be included within test suite.
  1581. *
  1582. * @public
  1583. * @see [CLI option](../#-file-filedirectoryglob)
  1584. * @param {string} file - Pathname of file to be loaded.
  1585. * @returns {Mocha} this
  1586. * @chainable
  1587. */
  1588. Mocha.prototype.addFile = function(file) {
  1589. this.files.push(file);
  1590. return this;
  1591. };
  1592. /**
  1593. * Sets reporter to `reporter`, defaults to "spec".
  1594. *
  1595. * @public
  1596. * @see [CLI option](../#-reporter-name-r-name)
  1597. * @see [Reporters](../#reporters)
  1598. * @param {String|Function} reporter - Reporter name or constructor.
  1599. * @param {Object} [reporterOptions] - Options used to configure the reporter.
  1600. * @returns {Mocha} this
  1601. * @chainable
  1602. * @throws {Error} if requested reporter cannot be loaded
  1603. * @example
  1604. *
  1605. * // Use XUnit reporter and direct its output to file
  1606. * mocha.reporter('xunit', { output: '/path/to/testspec.xunit.xml' });
  1607. */
  1608. Mocha.prototype.reporter = function(reporter, reporterOptions) {
  1609. if (typeof reporter === 'function') {
  1610. this._reporter = reporter;
  1611. } else {
  1612. reporter = reporter || 'spec';
  1613. var _reporter;
  1614. // Try to load a built-in reporter.
  1615. if (builtinReporters[reporter]) {
  1616. _reporter = builtinReporters[reporter];
  1617. }
  1618. // Try to load reporters from process.cwd() and node_modules
  1619. if (!_reporter) {
  1620. try {
  1621. _reporter = require(reporter);
  1622. } catch (err) {
  1623. if (
  1624. err.code === 'MODULE_NOT_FOUND' ||
  1625. err.message.indexOf('Cannot find module') >= 0
  1626. ) {
  1627. // Try to load reporters from a path (absolute or relative)
  1628. try {
  1629. _reporter = require(path.resolve(utils.cwd(), reporter));
  1630. } catch (_err) {
  1631. _err.code === 'MODULE_NOT_FOUND' ||
  1632. _err.message.indexOf('Cannot find module') >= 0
  1633. ? utils.warn(sQuote(reporter) + ' reporter not found')
  1634. : utils.warn(
  1635. sQuote(reporter) +
  1636. ' reporter blew up with error:\n' +
  1637. err.stack
  1638. );
  1639. }
  1640. } else {
  1641. utils.warn(
  1642. sQuote(reporter) + ' reporter blew up with error:\n' + err.stack
  1643. );
  1644. }
  1645. }
  1646. }
  1647. if (!_reporter) {
  1648. throw createInvalidReporterError(
  1649. 'invalid reporter ' + sQuote(reporter),
  1650. reporter
  1651. );
  1652. }
  1653. this._reporter = _reporter;
  1654. }
  1655. this.options.reporterOption = reporterOptions;
  1656. // alias option name is used in public reporters xunit/tap/progress
  1657. this.options.reporterOptions = reporterOptions;
  1658. return this;
  1659. };
  1660. /**
  1661. * Sets test UI `name`, defaults to "bdd".
  1662. *
  1663. * @public
  1664. * @see [CLI option](../#-ui-name-u-name)
  1665. * @see [Interface DSLs](../#interfaces)
  1666. * @param {string|Function} [ui=bdd] - Interface name or class.
  1667. * @returns {Mocha} this
  1668. * @chainable
  1669. * @throws {Error} if requested interface cannot be loaded
  1670. */
  1671. Mocha.prototype.ui = function(ui) {
  1672. var bindInterface;
  1673. if (typeof ui === 'function') {
  1674. bindInterface = ui;
  1675. } else {
  1676. ui = ui || 'bdd';
  1677. bindInterface = exports.interfaces[ui];
  1678. if (!bindInterface) {
  1679. try {
  1680. bindInterface = require(ui);
  1681. } catch (err) {
  1682. throw createInvalidInterfaceError(
  1683. 'invalid interface ' + sQuote(ui),
  1684. ui
  1685. );
  1686. }
  1687. }
  1688. }
  1689. bindInterface(this.suite);
  1690. this.suite.on(EVENT_FILE_PRE_REQUIRE, function(context) {
  1691. exports.afterEach = context.afterEach || context.teardown;
  1692. exports.after = context.after || context.suiteTeardown;
  1693. exports.beforeEach = context.beforeEach || context.setup;
  1694. exports.before = context.before || context.suiteSetup;
  1695. exports.describe = context.describe || context.suite;
  1696. exports.it = context.it || context.test;
  1697. exports.xit = context.xit || (context.test && context.test.skip);
  1698. exports.setup = context.setup || context.beforeEach;
  1699. exports.suiteSetup = context.suiteSetup || context.before;
  1700. exports.suiteTeardown = context.suiteTeardown || context.after;
  1701. exports.suite = context.suite || context.describe;
  1702. exports.teardown = context.teardown || context.afterEach;
  1703. exports.test = context.test || context.it;
  1704. exports.run = context.run;
  1705. });
  1706. return this;
  1707. };
  1708. /**
  1709. * Loads `files` prior to execution. Does not support ES Modules.
  1710. *
  1711. * @description
  1712. * The implementation relies on Node's `require` to execute
  1713. * the test interface functions and will be subject to its cache.
  1714. * Supports only CommonJS modules. To load ES modules, use Mocha#loadFilesAsync.
  1715. *
  1716. * @private
  1717. * @see {@link Mocha#addFile}
  1718. * @see {@link Mocha#run}
  1719. * @see {@link Mocha#unloadFiles}
  1720. * @see {@link Mocha#loadFilesAsync}
  1721. * @param {Function} [fn] - Callback invoked upon completion.
  1722. */
  1723. Mocha.prototype.loadFiles = function(fn) {
  1724. var self = this;
  1725. var suite = this.suite;
  1726. this.files.forEach(function(file) {
  1727. file = path.resolve(file);
  1728. suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self);
  1729. suite.emit(EVENT_FILE_REQUIRE, require(file), file, self);
  1730. suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self);
  1731. });
  1732. fn && fn();
  1733. };
  1734. /**
  1735. * Loads `files` prior to execution. Supports Node ES Modules.
  1736. *
  1737. * @description
  1738. * The implementation relies on Node's `require` and `import` to execute
  1739. * the test interface functions and will be subject to its cache.
  1740. * Supports both CJS and ESM modules.
  1741. *
  1742. * @public
  1743. * @see {@link Mocha#addFile}
  1744. * @see {@link Mocha#run}
  1745. * @see {@link Mocha#unloadFiles}
  1746. * @returns {Promise}
  1747. * @example
  1748. *
  1749. * // loads ESM (and CJS) test files asynchronously, then runs root suite
  1750. * mocha.loadFilesAsync()
  1751. * .then(() => mocha.run(failures => process.exitCode = failures ? 1 : 0))
  1752. * .catch(() => process.exitCode = 1);
  1753. */
  1754. Mocha.prototype.loadFilesAsync = function() {
  1755. var self = this;
  1756. var suite = this.suite;
  1757. this.loadAsync = true;
  1758. if (!esmUtils) {
  1759. return new Promise(function(resolve) {
  1760. self.loadFiles(resolve);
  1761. });
  1762. }
  1763. return esmUtils.loadFilesAsync(
  1764. this.files,
  1765. function(file) {
  1766. suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self);
  1767. },
  1768. function(file, resultModule) {
  1769. suite.emit(EVENT_FILE_REQUIRE, resultModule, file, self);
  1770. suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self);
  1771. }
  1772. );
  1773. };
  1774. /**
  1775. * Removes a previously loaded file from Node's `require` cache.
  1776. *
  1777. * @private
  1778. * @static
  1779. * @see {@link Mocha#unloadFiles}
  1780. * @param {string} file - Pathname of file to be unloaded.
  1781. */
  1782. Mocha.unloadFile = function(file) {
  1783. delete require.cache[require.resolve(file)];
  1784. };
  1785. /**
  1786. * Unloads `files` from Node's `require` cache.
  1787. *
  1788. * @description
  1789. * This allows required files to be "freshly" reloaded, providing the ability
  1790. * to reuse a Mocha instance programmatically.
  1791. * Note: does not clear ESM module files from the cache
  1792. *
  1793. * <strong>Intended for consumers &mdash; not used internally</strong>
  1794. *
  1795. * @public
  1796. * @see {@link Mocha#run}
  1797. * @returns {Mocha} this
  1798. * @chainable
  1799. */
  1800. Mocha.prototype.unloadFiles = function() {
  1801. if (this._state === mochaStates.DISPOSED) {
  1802. throw createMochaInstanceAlreadyDisposedError(
  1803. 'Mocha instance is already disposed, it cannot be used again.',
  1804. this._cleanReferencesAfterRun,
  1805. this
  1806. );
  1807. }
  1808. this.files.forEach(function(file) {
  1809. Mocha.unloadFile(file);
  1810. });
  1811. this._state = mochaStates.INIT;
  1812. return this;
  1813. };
  1814. /**
  1815. * Sets `grep` filter after escaping RegExp special characters.
  1816. *
  1817. * @public
  1818. * @see {@link Mocha#grep}
  1819. * @param {string} str - Value to be converted to a regexp.
  1820. * @returns {Mocha} this
  1821. * @chainable
  1822. * @example
  1823. *
  1824. * // Select tests whose full title begins with `"foo"` followed by a period
  1825. * mocha.fgrep('foo.');
  1826. */
  1827. Mocha.prototype.fgrep = function(str) {
  1828. if (!str) {
  1829. return this;
  1830. }
  1831. return this.grep(new RegExp(escapeRe(str)));
  1832. };
  1833. /**
  1834. * @summary
  1835. * Sets `grep` filter used to select specific tests for execution.
  1836. *
  1837. * @description
  1838. * If `re` is a regexp-like string, it will be converted to regexp.
  1839. * The regexp is tested against the full title of each test (i.e., the
  1840. * name of the test preceded by titles of each its ancestral suites).
  1841. * As such, using an <em>exact-match</em> fixed pattern against the
  1842. * test name itself will not yield any matches.
  1843. * <br>
  1844. * <strong>Previous filter value will be overwritten on each call!</strong>
  1845. *
  1846. * @public
  1847. * @see [CLI option](../#-grep-regexp-g-regexp)
  1848. * @see {@link Mocha#fgrep}
  1849. * @see {@link Mocha#invert}
  1850. * @param {RegExp|String} re - Regular expression used to select tests.
  1851. * @return {Mocha} this
  1852. * @chainable
  1853. * @example
  1854. *
  1855. * // Select tests whose full title contains `"match"`, ignoring case
  1856. * mocha.grep(/match/i);
  1857. * @example
  1858. *
  1859. * // Same as above but with regexp-like string argument
  1860. * mocha.grep('/match/i');
  1861. * @example
  1862. *
  1863. * // ## Anti-example
  1864. * // Given embedded test `it('only-this-test')`...
  1865. * mocha.grep('/^only-this-test$/'); // NO! Use `.only()` to do this!
  1866. */
  1867. Mocha.prototype.grep = function(re) {
  1868. if (utils.isString(re)) {
  1869. // extract args if it's regex-like, i.e: [string, pattern, flag]
  1870. var arg = re.match(/^\/(.*)\/(g|i|)$|.*/);
  1871. this.options.grep = new RegExp(arg[1] || arg[0], arg[2]);
  1872. } else {
  1873. this.options.grep = re;
  1874. }
  1875. return this;
  1876. };
  1877. /**
  1878. * Inverts `grep` matches.
  1879. *
  1880. * @public
  1881. * @see {@link Mocha#grep}
  1882. * @return {Mocha} this
  1883. * @chainable
  1884. * @example
  1885. *
  1886. * // Select tests whose full title does *not* contain `"match"`, ignoring case
  1887. * mocha.grep(/match/i).invert();
  1888. */
  1889. Mocha.prototype.invert = function() {
  1890. this.options.invert = true;
  1891. return this;
  1892. };
  1893. /**
  1894. * Enables or disables ignoring global leaks.
  1895. *
  1896. * @deprecated since v7.0.0
  1897. * @public
  1898. * @see {@link Mocha#checkLeaks}
  1899. * @param {boolean} [ignoreLeaks=false] - Whether to ignore global leaks.
  1900. * @return {Mocha} this
  1901. * @chainable
  1902. */
  1903. Mocha.prototype.ignoreLeaks = function(ignoreLeaks) {
  1904. utils.deprecate(
  1905. '"ignoreLeaks()" is DEPRECATED, please use "checkLeaks()" instead.'
  1906. );
  1907. this.options.checkLeaks = !ignoreLeaks;
  1908. return this;
  1909. };
  1910. /**
  1911. * Enables or disables checking for global variables leaked while running tests.
  1912. *
  1913. * @public
  1914. * @see [CLI option](../#-check-leaks)
  1915. * @param {boolean} [checkLeaks=true] - Whether to check for global variable leaks.
  1916. * @return {Mocha} this
  1917. * @chainable
  1918. */
  1919. Mocha.prototype.checkLeaks = function(checkLeaks) {
  1920. this.options.checkLeaks = checkLeaks !== false;
  1921. return this;
  1922. };
  1923. /**
  1924. * Enables or disables whether or not to dispose after each test run.
  1925. * Disable this to ensure you can run the test suite multiple times.
  1926. * If disabled, be sure to dispose mocha when you're done to prevent memory leaks.
  1927. * @public
  1928. * @see {@link Mocha#dispose}
  1929. * @param {boolean} cleanReferencesAfterRun
  1930. * @return {Mocha} this
  1931. * @chainable
  1932. */
  1933. Mocha.prototype.cleanReferencesAfterRun = function(cleanReferencesAfterRun) {
  1934. this._cleanReferencesAfterRun = cleanReferencesAfterRun !== false;
  1935. return this;
  1936. };
  1937. /**
  1938. * Manually dispose this mocha instance. Mark this instance as `disposed` and unable to run more tests.
  1939. * It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector.
  1940. * @public
  1941. */
  1942. Mocha.prototype.dispose = function() {
  1943. if (this._state === mochaStates.RUNNING) {
  1944. throw createMochaInstanceAlreadyRunningError(
  1945. 'Cannot dispose while the mocha instance is still running tests.'
  1946. );
  1947. }
  1948. this.unloadFiles();
  1949. this._previousRunner && this._previousRunner.dispose();
  1950. this.suite.dispose();
  1951. this._state = mochaStates.DISPOSED;
  1952. };
  1953. /**
  1954. * Displays full stack trace upon test failure.
  1955. *
  1956. * @public
  1957. * @see [CLI option](../#-full-trace)
  1958. * @param {boolean} [fullTrace=true] - Whether to print full stacktrace upon failure.
  1959. * @return {Mocha} this
  1960. * @chainable
  1961. */
  1962. Mocha.prototype.fullTrace = function(fullTrace) {
  1963. this.options.fullTrace = fullTrace !== false;
  1964. return this;
  1965. };
  1966. /**
  1967. * Enables desktop notification support if prerequisite software installed.
  1968. *
  1969. * @public
  1970. * @see [CLI option](../#-growl-g)
  1971. * @return {Mocha} this
  1972. * @chainable
  1973. */
  1974. Mocha.prototype.growl = function() {
  1975. this.options.growl = this.isGrowlCapable();
  1976. if (!this.options.growl) {
  1977. var detail = process.browser
  1978. ? 'notification support not available in this browser...'
  1979. : 'notification support prerequisites not installed...';
  1980. console.error(detail + ' cannot enable!');
  1981. }
  1982. return this;
  1983. };
  1984. /**
  1985. * @summary
  1986. * Determines if Growl support seems likely.
  1987. *
  1988. * @description
  1989. * <strong>Not available when run in browser.</strong>
  1990. *
  1991. * @private
  1992. * @see {@link Growl#isCapable}
  1993. * @see {@link Mocha#growl}
  1994. * @return {boolean} whether Growl support can be expected
  1995. */
  1996. Mocha.prototype.isGrowlCapable = growl.isCapable;
  1997. /**
  1998. * Implements desktop notifications using a pseudo-reporter.
  1999. *
  2000. * @private
  2001. * @see {@link Mocha#growl}
  2002. * @see {@link Growl#notify}
  2003. * @param {Runner} runner - Runner instance.
  2004. */
  2005. Mocha.prototype._growl = growl.notify;
  2006. /**
  2007. * Specifies whitelist of variable names to be expected in global scope.
  2008. *
  2009. * @public
  2010. * @see [CLI option](../#-global-variable-name)
  2011. * @see {@link Mocha#checkLeaks}
  2012. * @param {String[]|String} global - Accepted global variable name(s).
  2013. * @return {Mocha} this
  2014. * @chainable
  2015. * @example
  2016. *
  2017. * // Specify variables to be expected in global scope
  2018. * mocha.global(['jQuery', 'MyLib']);
  2019. */
  2020. Mocha.prototype.global = function(global) {
  2021. this.options.global = (this.options.global || [])
  2022. .concat(global)
  2023. .filter(Boolean)
  2024. .filter(function(elt, idx, arr) {
  2025. return arr.indexOf(elt) === idx;
  2026. });
  2027. return this;
  2028. };
  2029. // for backwards compability, 'globals' is an alias of 'global'
  2030. Mocha.prototype.globals = Mocha.prototype.global;
  2031. /**
  2032. * Enables or disables TTY color output by screen-oriented reporters.
  2033. *
  2034. * @deprecated since v7.0.0
  2035. * @public
  2036. * @see {@link Mocha#color}
  2037. * @param {boolean} colors - Whether to enable color output.
  2038. * @return {Mocha} this
  2039. * @chainable
  2040. */
  2041. Mocha.prototype.useColors = function(colors) {
  2042. utils.deprecate('"useColors()" is DEPRECATED, please use "color()" instead.');
  2043. if (colors !== undefined) {
  2044. this.options.color = colors;
  2045. }
  2046. return this;
  2047. };
  2048. /**
  2049. * Enables or disables TTY color output by screen-oriented reporters.
  2050. *
  2051. * @public
  2052. * @see [CLI option](../#-color-c-colors)
  2053. * @param {boolean} [color=true] - Whether to enable color output.
  2054. * @return {Mocha} this
  2055. * @chainable
  2056. */
  2057. Mocha.prototype.color = function(color) {
  2058. this.options.color = color !== false;
  2059. return this;
  2060. };
  2061. /**
  2062. * Determines if reporter should use inline diffs (rather than +/-)
  2063. * in test failure output.
  2064. *
  2065. * @deprecated since v7.0.0
  2066. * @public
  2067. * @see {@link Mocha#inlineDiffs}
  2068. * @param {boolean} [inlineDiffs=false] - Whether to use inline diffs.
  2069. * @return {Mocha} this
  2070. * @chainable
  2071. */
  2072. Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
  2073. utils.deprecate(
  2074. '"useInlineDiffs()" is DEPRECATED, please use "inlineDiffs()" instead.'
  2075. );
  2076. this.options.inlineDiffs = inlineDiffs !== undefined && inlineDiffs;
  2077. return this;
  2078. };
  2079. /**
  2080. * Enables or disables reporter to use inline diffs (rather than +/-)
  2081. * in test failure output.
  2082. *
  2083. * @public
  2084. * @see [CLI option](../#-inline-diffs)
  2085. * @param {boolean} [inlineDiffs=true] - Whether to use inline diffs.
  2086. * @return {Mocha} this
  2087. * @chainable
  2088. */
  2089. Mocha.prototype.inlineDiffs = function(inlineDiffs) {
  2090. this.options.inlineDiffs = inlineDiffs !== false;
  2091. return this;
  2092. };
  2093. /**
  2094. * Determines if reporter should include diffs in test failure output.
  2095. *
  2096. * @deprecated since v7.0.0
  2097. * @public
  2098. * @see {@link Mocha#diff}
  2099. * @param {boolean} [hideDiff=false] - Whether to hide diffs.
  2100. * @return {Mocha} this
  2101. * @chainable
  2102. */
  2103. Mocha.prototype.hideDiff = function(hideDiff) {
  2104. utils.deprecate('"hideDiff()" is DEPRECATED, please use "diff()" instead.');
  2105. this.options.diff = !(hideDiff === true);
  2106. return this;
  2107. };
  2108. /**
  2109. * Enables or disables reporter to include diff in test failure output.
  2110. *
  2111. * @public
  2112. * @see [CLI option](../#-diff)
  2113. * @param {boolean} [diff=true] - Whether to show diff on failure.
  2114. * @return {Mocha} this
  2115. * @chainable
  2116. */
  2117. Mocha.prototype.diff = function(diff) {
  2118. this.options.diff = diff !== false;
  2119. return this;
  2120. };
  2121. /**
  2122. * @summary
  2123. * Sets timeout threshold value.
  2124. *
  2125. * @description
  2126. * A string argument can use shorthand (such as "2s") and will be converted.
  2127. * If the value is `0`, timeouts will be disabled.
  2128. *
  2129. * @public
  2130. * @see [CLI option](../#-timeout-ms-t-ms)
  2131. * @see [Timeouts](../#timeouts)
  2132. * @see {@link Mocha#enableTimeouts}
  2133. * @param {number|string} msecs - Timeout threshold value.
  2134. * @return {Mocha} this
  2135. * @chainable
  2136. * @example
  2137. *
  2138. * // Sets timeout to one second
  2139. * mocha.timeout(1000);
  2140. * @example
  2141. *
  2142. * // Same as above but using string argument
  2143. * mocha.timeout('1s');
  2144. */
  2145. Mocha.prototype.timeout = function(msecs) {
  2146. this.suite.timeout(msecs);
  2147. return this;
  2148. };
  2149. /**
  2150. * Sets the number of times to retry failed tests.
  2151. *
  2152. * @public
  2153. * @see [CLI option](../#-retries-n)
  2154. * @see [Retry Tests](../#retry-tests)
  2155. * @param {number} retry - Number of times to retry failed tests.
  2156. * @return {Mocha} this
  2157. * @chainable
  2158. * @example
  2159. *
  2160. * // Allow any failed test to retry one more time
  2161. * mocha.retries(1);
  2162. */
  2163. Mocha.prototype.retries = function(n) {
  2164. this.suite.retries(n);
  2165. return this;
  2166. };
  2167. /**
  2168. * Sets slowness threshold value.
  2169. *
  2170. * @public
  2171. * @see [CLI option](../#-slow-ms-s-ms)
  2172. * @param {number} msecs - Slowness threshold value.
  2173. * @return {Mocha} this
  2174. * @chainable
  2175. * @example
  2176. *
  2177. * // Sets "slow" threshold to half a second
  2178. * mocha.slow(500);
  2179. * @example
  2180. *
  2181. * // Same as above but using string argument
  2182. * mocha.slow('0.5s');
  2183. */
  2184. Mocha.prototype.slow = function(msecs) {
  2185. this.suite.slow(msecs);
  2186. return this;
  2187. };
  2188. /**
  2189. * Enables or disables timeouts.
  2190. *
  2191. * @public
  2192. * @see [CLI option](../#-timeout-ms-t-ms)
  2193. * @param {boolean} enableTimeouts - Whether to enable timeouts.
  2194. * @return {Mocha} this
  2195. * @chainable
  2196. */
  2197. Mocha.prototype.enableTimeouts = function(enableTimeouts) {
  2198. this.suite.enableTimeouts(
  2199. arguments.length && enableTimeouts !== undefined ? enableTimeouts : true
  2200. );
  2201. return this;
  2202. };
  2203. /**
  2204. * Forces all tests to either accept a `done` callback or return a promise.
  2205. *
  2206. * @public
  2207. * @see [CLI option](../#-async-only-a)
  2208. * @param {boolean} [asyncOnly=true] - Wether to force `done` callback or promise.
  2209. * @return {Mocha} this
  2210. * @chainable
  2211. */
  2212. Mocha.prototype.asyncOnly = function(asyncOnly) {
  2213. this.options.asyncOnly = asyncOnly !== false;
  2214. return this;
  2215. };
  2216. /**
  2217. * Disables syntax highlighting (in browser).
  2218. *
  2219. * @public
  2220. * @return {Mocha} this
  2221. * @chainable
  2222. */
  2223. Mocha.prototype.noHighlighting = function() {
  2224. this.options.noHighlighting = true;
  2225. return this;
  2226. };
  2227. /**
  2228. * Enables or disables uncaught errors to propagate.
  2229. *
  2230. * @public
  2231. * @see [CLI option](../#-allow-uncaught)
  2232. * @param {boolean} [allowUncaught=true] - Whether to propagate uncaught errors.
  2233. * @return {Mocha} this
  2234. * @chainable
  2235. */
  2236. Mocha.prototype.allowUncaught = function(allowUncaught) {
  2237. this.options.allowUncaught = allowUncaught !== false;
  2238. return this;
  2239. };
  2240. /**
  2241. * @summary
  2242. * Delays root suite execution.
  2243. *
  2244. * @description
  2245. * Used to perform asynch operations before any suites are run.
  2246. *
  2247. * @public
  2248. * @see [delayed root suite](../#delayed-root-suite)
  2249. * @returns {Mocha} this
  2250. * @chainable
  2251. */
  2252. Mocha.prototype.delay = function delay() {
  2253. this.options.delay = true;
  2254. return this;
  2255. };
  2256. /**
  2257. * Causes tests marked `only` to fail the suite.
  2258. *
  2259. * @public
  2260. * @see [CLI option](../#-forbid-only)
  2261. * @param {boolean} [forbidOnly=true] - Whether tests marked `only` fail the suite.
  2262. * @returns {Mocha} this
  2263. * @chainable
  2264. */
  2265. Mocha.prototype.forbidOnly = function(forbidOnly) {
  2266. this.options.forbidOnly = forbidOnly !== false;
  2267. return this;
  2268. };
  2269. /**
  2270. * Causes pending tests and tests marked `skip` to fail the suite.
  2271. *
  2272. * @public
  2273. * @see [CLI option](../#-forbid-pending)
  2274. * @param {boolean} [forbidPending=true] - Whether pending tests fail the suite.
  2275. * @returns {Mocha} this
  2276. * @chainable
  2277. */
  2278. Mocha.prototype.forbidPending = function(forbidPending) {
  2279. this.options.forbidPending = forbidPending !== false;
  2280. return this;
  2281. };
  2282. /**
  2283. * Throws an error if mocha is in the wrong state to be able to transition to a "running" state.
  2284. */
  2285. Mocha.prototype._guardRunningStateTransition = function() {
  2286. if (this._state === mochaStates.RUNNING) {
  2287. throw createMochaInstanceAlreadyRunningError(
  2288. 'Mocha instance is currently running tests, cannot start a next test run until this one is done',
  2289. this
  2290. );
  2291. }
  2292. if (
  2293. this._state === mochaStates.DISPOSED ||
  2294. this._state === mochaStates.REFERENCES_CLEANED
  2295. ) {
  2296. throw createMochaInstanceAlreadyDisposedError(
  2297. 'Mocha instance is already disposed, cannot start a new test run. Please create a new mocha instance. Be sure to set disable `cleanReferencesAfterRun` when you want to reuse the same mocha instance for multiple test runs.',
  2298. this._cleanReferencesAfterRun,
  2299. this
  2300. );
  2301. }
  2302. };
  2303. /**
  2304. * Mocha version as specified by "package.json".
  2305. *
  2306. * @name Mocha#version
  2307. * @type string
  2308. * @readonly
  2309. */
  2310. Object.defineProperty(Mocha.prototype, 'version', {
  2311. value: require('../package.json').version,
  2312. configurable: false,
  2313. enumerable: true,
  2314. writable: false
  2315. });
  2316. /**
  2317. * Callback to be invoked when test execution is complete.
  2318. *
  2319. * @callback DoneCB
  2320. * @param {number} failures - Number of failures that occurred.
  2321. */
  2322. /**
  2323. * Runs root suite and invokes `fn()` when complete.
  2324. *
  2325. * @description
  2326. * To run tests multiple times (or to run tests in files that are
  2327. * already in the `require` cache), make sure to clear them from
  2328. * the cache first!
  2329. *
  2330. * @public
  2331. * @see {@link Mocha#unloadFiles}
  2332. * @see {@link Runner#run}
  2333. * @param {DoneCB} [fn] - Callback invoked when test execution completed.
  2334. * @returns {Runner} runner instance
  2335. * @example
  2336. *
  2337. * // exit with non-zero status if there were test failures
  2338. * mocha.run(failures => process.exitCode = failures ? 1 : 0);
  2339. */
  2340. Mocha.prototype.run = function(fn) {
  2341. this._guardRunningStateTransition();
  2342. this._state = mochaStates.RUNNING;
  2343. if (this._previousRunner) {
  2344. this._previousRunner.dispose();
  2345. this.suite.reset();
  2346. }
  2347. if (this.files.length && !this.loadAsync) {
  2348. this.loadFiles();
  2349. }
  2350. var self = this;
  2351. var suite = this.suite;
  2352. var options = this.options;
  2353. options.files = this.files;
  2354. var runner = new exports.Runner(suite, {
  2355. delay: options.delay,
  2356. cleanReferencesAfterRun: this._cleanReferencesAfterRun
  2357. });
  2358. createStatsCollector(runner);
  2359. var reporter = new this._reporter(runner, options);
  2360. runner.checkLeaks = options.checkLeaks === true;
  2361. runner.fullStackTrace = options.fullTrace;
  2362. runner.asyncOnly = options.asyncOnly;
  2363. runner.allowUncaught = options.allowUncaught;
  2364. runner.forbidOnly = options.forbidOnly;
  2365. runner.forbidPending = options.forbidPending;
  2366. if (options.grep) {
  2367. runner.grep(options.grep, options.invert);
  2368. }
  2369. if (options.global) {
  2370. runner.globals(options.global);
  2371. }
  2372. if (options.growl) {
  2373. this._growl(runner);
  2374. }
  2375. if (options.color !== undefined) {
  2376. exports.reporters.Base.useColors = options.color;
  2377. }
  2378. exports.reporters.Base.inlineDiffs = options.inlineDiffs;
  2379. exports.reporters.Base.hideDiff = !options.diff;
  2380. function done(failures) {
  2381. self._previousRunner = runner;
  2382. if (self._cleanReferencesAfterRun) {
  2383. self._state = mochaStates.REFERENCES_CLEANED;
  2384. } else {
  2385. self._state = mochaStates.INIT;
  2386. }
  2387. fn = fn || utils.noop;
  2388. if (reporter.done) {
  2389. reporter.done(failures, fn);
  2390. } else {
  2391. fn(failures);
  2392. }
  2393. }
  2394. return runner.run(done);
  2395. };
  2396. /**
  2397. * Assigns hooks to the root suite
  2398. * @param {MochaRootHookObject} [hooks] - Hooks to assign to root suite
  2399. * @chainable
  2400. */
  2401. Mocha.prototype.rootHooks = function rootHooks(hooks) {
  2402. if (utils.type(hooks) === 'object') {
  2403. var beforeAll = [].concat(hooks.beforeAll || []);
  2404. var beforeEach = [].concat(hooks.beforeEach || []);
  2405. var afterAll = [].concat(hooks.afterAll || []);
  2406. var afterEach = [].concat(hooks.afterEach || []);
  2407. var rootSuite = this.suite;
  2408. beforeAll.forEach(function(hook) {
  2409. rootSuite.beforeAll(hook);
  2410. });
  2411. beforeEach.forEach(function(hook) {
  2412. rootSuite.beforeEach(hook);
  2413. });
  2414. afterAll.forEach(function(hook) {
  2415. rootSuite.afterAll(hook);
  2416. });
  2417. afterEach.forEach(function(hook) {
  2418. rootSuite.afterEach(hook);
  2419. });
  2420. }
  2421. return this;
  2422. };
  2423. /**
  2424. * An alternative way to define root hooks that works with parallel runs.
  2425. * @typedef {Object} MochaRootHookObject
  2426. * @property {Function|Function[]} [beforeAll] - "Before all" hook(s)
  2427. * @property {Function|Function[]} [beforeEach] - "Before each" hook(s)
  2428. * @property {Function|Function[]} [afterAll] - "After all" hook(s)
  2429. * @property {Function|Function[]} [afterEach] - "After each" hook(s)
  2430. */
  2431. /**
  2432. * An function that returns a {@link MochaRootHookObject}, either sync or async.
  2433. * @callback MochaRootHookFunction
  2434. * @returns {MochaRootHookObject|Promise<MochaRootHookObject>}
  2435. */
  2436. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2437. },{"../package.json":90,"./context":5,"./errors":6,"./esm-utils":42,"./growl":2,"./hook":7,"./interfaces":11,"./mocharc.json":15,"./reporters":21,"./runnable":33,"./runner":34,"./stats-collector":35,"./suite":36,"./test":37,"./utils":38,"_process":69,"escape-string-regexp":49,"path":42}],15:[function(require,module,exports){
  2438. module.exports={
  2439. "diff": true,
  2440. "extension": ["js", "cjs", "mjs"],
  2441. "opts": "./test/mocha.opts",
  2442. "package": "./package.json",
  2443. "reporter": "spec",
  2444. "slow": 75,
  2445. "timeout": 2000,
  2446. "ui": "bdd",
  2447. "watch-ignore": ["node_modules", ".git"]
  2448. }
  2449. },{}],16:[function(require,module,exports){
  2450. 'use strict';
  2451. module.exports = Pending;
  2452. /**
  2453. * Initialize a new `Pending` error with the given message.
  2454. *
  2455. * @param {string} message
  2456. */
  2457. function Pending(message) {
  2458. this.message = message;
  2459. }
  2460. },{}],17:[function(require,module,exports){
  2461. (function (process){
  2462. 'use strict';
  2463. /**
  2464. * @module Base
  2465. */
  2466. /**
  2467. * Module dependencies.
  2468. */
  2469. var tty = require('tty');
  2470. var diff = require('diff');
  2471. var milliseconds = require('ms');
  2472. var utils = require('../utils');
  2473. var supportsColor = process.browser ? null : require('supports-color');
  2474. var constants = require('../runner').constants;
  2475. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  2476. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  2477. /**
  2478. * Expose `Base`.
  2479. */
  2480. exports = module.exports = Base;
  2481. /**
  2482. * Check if both stdio streams are associated with a tty.
  2483. */
  2484. var isatty = process.stdout.isTTY && process.stderr.isTTY;
  2485. /**
  2486. * Save log references to avoid tests interfering (see GH-3604).
  2487. */
  2488. var consoleLog = console.log;
  2489. /**
  2490. * Enable coloring by default, except in the browser interface.
  2491. */
  2492. exports.useColors =
  2493. !process.browser &&
  2494. (supportsColor.stdout || process.env.MOCHA_COLORS !== undefined);
  2495. /**
  2496. * Inline diffs instead of +/-
  2497. */
  2498. exports.inlineDiffs = false;
  2499. /**
  2500. * Default color map.
  2501. */
  2502. exports.colors = {
  2503. pass: 90,
  2504. fail: 31,
  2505. 'bright pass': 92,
  2506. 'bright fail': 91,
  2507. 'bright yellow': 93,
  2508. pending: 36,
  2509. suite: 0,
  2510. 'error title': 0,
  2511. 'error message': 31,
  2512. 'error stack': 90,
  2513. checkmark: 32,
  2514. fast: 90,
  2515. medium: 33,
  2516. slow: 31,
  2517. green: 32,
  2518. light: 90,
  2519. 'diff gutter': 90,
  2520. 'diff added': 32,
  2521. 'diff removed': 31
  2522. };
  2523. /**
  2524. * Default symbol map.
  2525. */
  2526. exports.symbols = {
  2527. ok: '✓',
  2528. err: '✖',
  2529. dot: '․',
  2530. comma: ',',
  2531. bang: '!'
  2532. };
  2533. // With node.js on Windows: use symbols available in terminal default fonts
  2534. if (process.platform === 'win32') {
  2535. exports.symbols.ok = '\u221A';
  2536. exports.symbols.err = '\u00D7';
  2537. exports.symbols.dot = '.';
  2538. }
  2539. /**
  2540. * Color `str` with the given `type`,
  2541. * allowing colors to be disabled,
  2542. * as well as user-defined color
  2543. * schemes.
  2544. *
  2545. * @private
  2546. * @param {string} type
  2547. * @param {string} str
  2548. * @return {string}
  2549. */
  2550. var color = (exports.color = function(type, str) {
  2551. if (!exports.useColors) {
  2552. return String(str);
  2553. }
  2554. return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
  2555. });
  2556. /**
  2557. * Expose term window size, with some defaults for when stderr is not a tty.
  2558. */
  2559. exports.window = {
  2560. width: 75
  2561. };
  2562. if (isatty) {
  2563. exports.window.width = process.stdout.getWindowSize
  2564. ? process.stdout.getWindowSize(1)[0]
  2565. : tty.getWindowSize()[1];
  2566. }
  2567. /**
  2568. * Expose some basic cursor interactions that are common among reporters.
  2569. */
  2570. exports.cursor = {
  2571. hide: function() {
  2572. isatty && process.stdout.write('\u001b[?25l');
  2573. },
  2574. show: function() {
  2575. isatty && process.stdout.write('\u001b[?25h');
  2576. },
  2577. deleteLine: function() {
  2578. isatty && process.stdout.write('\u001b[2K');
  2579. },
  2580. beginningOfLine: function() {
  2581. isatty && process.stdout.write('\u001b[0G');
  2582. },
  2583. CR: function() {
  2584. if (isatty) {
  2585. exports.cursor.deleteLine();
  2586. exports.cursor.beginningOfLine();
  2587. } else {
  2588. process.stdout.write('\r');
  2589. }
  2590. }
  2591. };
  2592. var showDiff = (exports.showDiff = function(err) {
  2593. return (
  2594. err &&
  2595. err.showDiff !== false &&
  2596. sameType(err.actual, err.expected) &&
  2597. err.expected !== undefined
  2598. );
  2599. });
  2600. function stringifyDiffObjs(err) {
  2601. if (!utils.isString(err.actual) || !utils.isString(err.expected)) {
  2602. err.actual = utils.stringify(err.actual);
  2603. err.expected = utils.stringify(err.expected);
  2604. }
  2605. }
  2606. /**
  2607. * Returns a diff between 2 strings with coloured ANSI output.
  2608. *
  2609. * @description
  2610. * The diff will be either inline or unified dependent on the value
  2611. * of `Base.inlineDiff`.
  2612. *
  2613. * @param {string} actual
  2614. * @param {string} expected
  2615. * @return {string} Diff
  2616. */
  2617. var generateDiff = (exports.generateDiff = function(actual, expected) {
  2618. try {
  2619. return exports.inlineDiffs
  2620. ? inlineDiff(actual, expected)
  2621. : unifiedDiff(actual, expected);
  2622. } catch (err) {
  2623. var msg =
  2624. '\n ' +
  2625. color('diff added', '+ expected') +
  2626. ' ' +
  2627. color('diff removed', '- actual: failed to generate Mocha diff') +
  2628. '\n';
  2629. return msg;
  2630. }
  2631. });
  2632. /**
  2633. * Outputs the given `failures` as a list.
  2634. *
  2635. * @public
  2636. * @memberof Mocha.reporters.Base
  2637. * @variation 1
  2638. * @param {Object[]} failures - Each is Test instance with corresponding
  2639. * Error property
  2640. */
  2641. exports.list = function(failures) {
  2642. var multipleErr, multipleTest;
  2643. Base.consoleLog();
  2644. failures.forEach(function(test, i) {
  2645. // format
  2646. var fmt =
  2647. color('error title', ' %s) %s:\n') +
  2648. color('error message', ' %s') +
  2649. color('error stack', '\n%s\n');
  2650. // msg
  2651. var msg;
  2652. var err;
  2653. if (test.err && test.err.multiple) {
  2654. if (multipleTest !== test) {
  2655. multipleTest = test;
  2656. multipleErr = [test.err].concat(test.err.multiple);
  2657. }
  2658. err = multipleErr.shift();
  2659. } else {
  2660. err = test.err;
  2661. }
  2662. var message;
  2663. if (err.message && typeof err.message.toString === 'function') {
  2664. message = err.message + '';
  2665. } else if (typeof err.inspect === 'function') {
  2666. message = err.inspect() + '';
  2667. } else {
  2668. message = '';
  2669. }
  2670. var stack = err.stack || message;
  2671. var index = message ? stack.indexOf(message) : -1;
  2672. if (index === -1) {
  2673. msg = message;
  2674. } else {
  2675. index += message.length;
  2676. msg = stack.slice(0, index);
  2677. // remove msg from stack
  2678. stack = stack.slice(index + 1);
  2679. }
  2680. // uncaught
  2681. if (err.uncaught) {
  2682. msg = 'Uncaught ' + msg;
  2683. }
  2684. // explicitly show diff
  2685. if (!exports.hideDiff && showDiff(err)) {
  2686. stringifyDiffObjs(err);
  2687. fmt =
  2688. color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
  2689. var match = message.match(/^([^:]+): expected/);
  2690. msg = '\n ' + color('error message', match ? match[1] : msg);
  2691. msg += generateDiff(err.actual, err.expected);
  2692. }
  2693. // indent stack trace
  2694. stack = stack.replace(/^/gm, ' ');
  2695. // indented test title
  2696. var testTitle = '';
  2697. test.titlePath().forEach(function(str, index) {
  2698. if (index !== 0) {
  2699. testTitle += '\n ';
  2700. }
  2701. for (var i = 0; i < index; i++) {
  2702. testTitle += ' ';
  2703. }
  2704. testTitle += str;
  2705. });
  2706. Base.consoleLog(fmt, i + 1, testTitle, msg, stack);
  2707. });
  2708. };
  2709. /**
  2710. * Constructs a new `Base` reporter instance.
  2711. *
  2712. * @description
  2713. * All other reporters generally inherit from this reporter.
  2714. *
  2715. * @public
  2716. * @class
  2717. * @memberof Mocha.reporters
  2718. * @param {Runner} runner - Instance triggers reporter actions.
  2719. * @param {Object} [options] - runner options
  2720. */
  2721. function Base(runner, options) {
  2722. var failures = (this.failures = []);
  2723. if (!runner) {
  2724. throw new TypeError('Missing runner argument');
  2725. }
  2726. this.options = options || {};
  2727. this.runner = runner;
  2728. this.stats = runner.stats; // assigned so Reporters keep a closer reference
  2729. runner.on(EVENT_TEST_PASS, function(test) {
  2730. if (test.duration > test.slow()) {
  2731. test.speed = 'slow';
  2732. } else if (test.duration > test.slow() / 2) {
  2733. test.speed = 'medium';
  2734. } else {
  2735. test.speed = 'fast';
  2736. }
  2737. });
  2738. runner.on(EVENT_TEST_FAIL, function(test, err) {
  2739. if (showDiff(err)) {
  2740. stringifyDiffObjs(err);
  2741. }
  2742. // more than one error per test
  2743. if (test.err && err instanceof Error) {
  2744. test.err.multiple = (test.err.multiple || []).concat(err);
  2745. } else {
  2746. test.err = err;
  2747. }
  2748. failures.push(test);
  2749. });
  2750. }
  2751. /**
  2752. * Outputs common epilogue used by many of the bundled reporters.
  2753. *
  2754. * @public
  2755. * @memberof Mocha.reporters
  2756. */
  2757. Base.prototype.epilogue = function() {
  2758. var stats = this.stats;
  2759. var fmt;
  2760. Base.consoleLog();
  2761. // passes
  2762. fmt =
  2763. color('bright pass', ' ') +
  2764. color('green', ' %d passing') +
  2765. color('light', ' (%s)');
  2766. Base.consoleLog(fmt, stats.passes || 0, milliseconds(stats.duration));
  2767. // pending
  2768. if (stats.pending) {
  2769. fmt = color('pending', ' ') + color('pending', ' %d pending');
  2770. Base.consoleLog(fmt, stats.pending);
  2771. }
  2772. // failures
  2773. if (stats.failures) {
  2774. fmt = color('fail', ' %d failing');
  2775. Base.consoleLog(fmt, stats.failures);
  2776. Base.list(this.failures);
  2777. Base.consoleLog();
  2778. }
  2779. Base.consoleLog();
  2780. };
  2781. /**
  2782. * Pads the given `str` to `len`.
  2783. *
  2784. * @private
  2785. * @param {string} str
  2786. * @param {string} len
  2787. * @return {string}
  2788. */
  2789. function pad(str, len) {
  2790. str = String(str);
  2791. return Array(len - str.length + 1).join(' ') + str;
  2792. }
  2793. /**
  2794. * Returns inline diff between 2 strings with coloured ANSI output.
  2795. *
  2796. * @private
  2797. * @param {String} actual
  2798. * @param {String} expected
  2799. * @return {string} Diff
  2800. */
  2801. function inlineDiff(actual, expected) {
  2802. var msg = errorDiff(actual, expected);
  2803. // linenos
  2804. var lines = msg.split('\n');
  2805. if (lines.length > 4) {
  2806. var width = String(lines.length).length;
  2807. msg = lines
  2808. .map(function(str, i) {
  2809. return pad(++i, width) + ' |' + ' ' + str;
  2810. })
  2811. .join('\n');
  2812. }
  2813. // legend
  2814. msg =
  2815. '\n' +
  2816. color('diff removed', 'actual') +
  2817. ' ' +
  2818. color('diff added', 'expected') +
  2819. '\n\n' +
  2820. msg +
  2821. '\n';
  2822. // indent
  2823. msg = msg.replace(/^/gm, ' ');
  2824. return msg;
  2825. }
  2826. /**
  2827. * Returns unified diff between two strings with coloured ANSI output.
  2828. *
  2829. * @private
  2830. * @param {String} actual
  2831. * @param {String} expected
  2832. * @return {string} The diff.
  2833. */
  2834. function unifiedDiff(actual, expected) {
  2835. var indent = ' ';
  2836. function cleanUp(line) {
  2837. if (line[0] === '+') {
  2838. return indent + colorLines('diff added', line);
  2839. }
  2840. if (line[0] === '-') {
  2841. return indent + colorLines('diff removed', line);
  2842. }
  2843. if (line.match(/@@/)) {
  2844. return '--';
  2845. }
  2846. if (line.match(/\\ No newline/)) {
  2847. return null;
  2848. }
  2849. return indent + line;
  2850. }
  2851. function notBlank(line) {
  2852. return typeof line !== 'undefined' && line !== null;
  2853. }
  2854. var msg = diff.createPatch('string', actual, expected);
  2855. var lines = msg.split('\n').splice(5);
  2856. return (
  2857. '\n ' +
  2858. colorLines('diff added', '+ expected') +
  2859. ' ' +
  2860. colorLines('diff removed', '- actual') +
  2861. '\n\n' +
  2862. lines
  2863. .map(cleanUp)
  2864. .filter(notBlank)
  2865. .join('\n')
  2866. );
  2867. }
  2868. /**
  2869. * Returns character diff for `err`.
  2870. *
  2871. * @private
  2872. * @param {String} actual
  2873. * @param {String} expected
  2874. * @return {string} the diff
  2875. */
  2876. function errorDiff(actual, expected) {
  2877. return diff
  2878. .diffWordsWithSpace(actual, expected)
  2879. .map(function(str) {
  2880. if (str.added) {
  2881. return colorLines('diff added', str.value);
  2882. }
  2883. if (str.removed) {
  2884. return colorLines('diff removed', str.value);
  2885. }
  2886. return str.value;
  2887. })
  2888. .join('');
  2889. }
  2890. /**
  2891. * Colors lines for `str`, using the color `name`.
  2892. *
  2893. * @private
  2894. * @param {string} name
  2895. * @param {string} str
  2896. * @return {string}
  2897. */
  2898. function colorLines(name, str) {
  2899. return str
  2900. .split('\n')
  2901. .map(function(str) {
  2902. return color(name, str);
  2903. })
  2904. .join('\n');
  2905. }
  2906. /**
  2907. * Object#toString reference.
  2908. */
  2909. var objToString = Object.prototype.toString;
  2910. /**
  2911. * Checks that a / b have the same type.
  2912. *
  2913. * @private
  2914. * @param {Object} a
  2915. * @param {Object} b
  2916. * @return {boolean}
  2917. */
  2918. function sameType(a, b) {
  2919. return objToString.call(a) === objToString.call(b);
  2920. }
  2921. Base.consoleLog = consoleLog;
  2922. Base.abstract = true;
  2923. }).call(this,require('_process'))
  2924. },{"../runner":34,"../utils":38,"_process":69,"diff":48,"ms":60,"supports-color":42,"tty":4}],18:[function(require,module,exports){
  2925. 'use strict';
  2926. /**
  2927. * @module Doc
  2928. */
  2929. /**
  2930. * Module dependencies.
  2931. */
  2932. var Base = require('./base');
  2933. var utils = require('../utils');
  2934. var constants = require('../runner').constants;
  2935. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  2936. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  2937. var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
  2938. var EVENT_SUITE_END = constants.EVENT_SUITE_END;
  2939. /**
  2940. * Expose `Doc`.
  2941. */
  2942. exports = module.exports = Doc;
  2943. /**
  2944. * Constructs a new `Doc` reporter instance.
  2945. *
  2946. * @public
  2947. * @class
  2948. * @memberof Mocha.reporters
  2949. * @extends Mocha.reporters.Base
  2950. * @param {Runner} runner - Instance triggers reporter actions.
  2951. * @param {Object} [options] - runner options
  2952. */
  2953. function Doc(runner, options) {
  2954. Base.call(this, runner, options);
  2955. var indents = 2;
  2956. function indent() {
  2957. return Array(indents).join(' ');
  2958. }
  2959. runner.on(EVENT_SUITE_BEGIN, function(suite) {
  2960. if (suite.root) {
  2961. return;
  2962. }
  2963. ++indents;
  2964. Base.consoleLog('%s<section class="suite">', indent());
  2965. ++indents;
  2966. Base.consoleLog('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
  2967. Base.consoleLog('%s<dl>', indent());
  2968. });
  2969. runner.on(EVENT_SUITE_END, function(suite) {
  2970. if (suite.root) {
  2971. return;
  2972. }
  2973. Base.consoleLog('%s</dl>', indent());
  2974. --indents;
  2975. Base.consoleLog('%s</section>', indent());
  2976. --indents;
  2977. });
  2978. runner.on(EVENT_TEST_PASS, function(test) {
  2979. Base.consoleLog('%s <dt>%s</dt>', indent(), utils.escape(test.title));
  2980. Base.consoleLog('%s <dt>%s</dt>', indent(), utils.escape(test.file));
  2981. var code = utils.escape(utils.clean(test.body));
  2982. Base.consoleLog('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
  2983. });
  2984. runner.on(EVENT_TEST_FAIL, function(test, err) {
  2985. Base.consoleLog(
  2986. '%s <dt class="error">%s</dt>',
  2987. indent(),
  2988. utils.escape(test.title)
  2989. );
  2990. Base.consoleLog(
  2991. '%s <dt class="error">%s</dt>',
  2992. indent(),
  2993. utils.escape(test.file)
  2994. );
  2995. var code = utils.escape(utils.clean(test.body));
  2996. Base.consoleLog(
  2997. '%s <dd class="error"><pre><code>%s</code></pre></dd>',
  2998. indent(),
  2999. code
  3000. );
  3001. Base.consoleLog(
  3002. '%s <dd class="error">%s</dd>',
  3003. indent(),
  3004. utils.escape(err)
  3005. );
  3006. });
  3007. }
  3008. Doc.description = 'HTML documentation';
  3009. },{"../runner":34,"../utils":38,"./base":17}],19:[function(require,module,exports){
  3010. (function (process){
  3011. 'use strict';
  3012. /**
  3013. * @module Dot
  3014. */
  3015. /**
  3016. * Module dependencies.
  3017. */
  3018. var Base = require('./base');
  3019. var inherits = require('../utils').inherits;
  3020. var constants = require('../runner').constants;
  3021. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  3022. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  3023. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  3024. var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
  3025. var EVENT_RUN_END = constants.EVENT_RUN_END;
  3026. /**
  3027. * Expose `Dot`.
  3028. */
  3029. exports = module.exports = Dot;
  3030. /**
  3031. * Constructs a new `Dot` reporter instance.
  3032. *
  3033. * @public
  3034. * @class
  3035. * @memberof Mocha.reporters
  3036. * @extends Mocha.reporters.Base
  3037. * @param {Runner} runner - Instance triggers reporter actions.
  3038. * @param {Object} [options] - runner options
  3039. */
  3040. function Dot(runner, options) {
  3041. Base.call(this, runner, options);
  3042. var self = this;
  3043. var width = (Base.window.width * 0.75) | 0;
  3044. var n = -1;
  3045. runner.on(EVENT_RUN_BEGIN, function() {
  3046. process.stdout.write('\n');
  3047. });
  3048. runner.on(EVENT_TEST_PENDING, function() {
  3049. if (++n % width === 0) {
  3050. process.stdout.write('\n ');
  3051. }
  3052. process.stdout.write(Base.color('pending', Base.symbols.comma));
  3053. });
  3054. runner.on(EVENT_TEST_PASS, function(test) {
  3055. if (++n % width === 0) {
  3056. process.stdout.write('\n ');
  3057. }
  3058. if (test.speed === 'slow') {
  3059. process.stdout.write(Base.color('bright yellow', Base.symbols.dot));
  3060. } else {
  3061. process.stdout.write(Base.color(test.speed, Base.symbols.dot));
  3062. }
  3063. });
  3064. runner.on(EVENT_TEST_FAIL, function() {
  3065. if (++n % width === 0) {
  3066. process.stdout.write('\n ');
  3067. }
  3068. process.stdout.write(Base.color('fail', Base.symbols.bang));
  3069. });
  3070. runner.once(EVENT_RUN_END, function() {
  3071. process.stdout.write('\n');
  3072. self.epilogue();
  3073. });
  3074. }
  3075. /**
  3076. * Inherit from `Base.prototype`.
  3077. */
  3078. inherits(Dot, Base);
  3079. Dot.description = 'dot matrix representation';
  3080. }).call(this,require('_process'))
  3081. },{"../runner":34,"../utils":38,"./base":17,"_process":69}],20:[function(require,module,exports){
  3082. (function (global){
  3083. 'use strict';
  3084. /* eslint-env browser */
  3085. /**
  3086. * @module HTML
  3087. */
  3088. /**
  3089. * Module dependencies.
  3090. */
  3091. var Base = require('./base');
  3092. var utils = require('../utils');
  3093. var Progress = require('../browser/progress');
  3094. var escapeRe = require('escape-string-regexp');
  3095. var constants = require('../runner').constants;
  3096. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  3097. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  3098. var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
  3099. var EVENT_SUITE_END = constants.EVENT_SUITE_END;
  3100. var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
  3101. var escape = utils.escape;
  3102. /**
  3103. * Save timer references to avoid Sinon interfering (see GH-237).
  3104. */
  3105. var Date = global.Date;
  3106. /**
  3107. * Expose `HTML`.
  3108. */
  3109. exports = module.exports = HTML;
  3110. /**
  3111. * Stats template.
  3112. */
  3113. var statsTemplate =
  3114. '<ul id="mocha-stats">' +
  3115. '<li class="progress"><canvas width="40" height="40"></canvas></li>' +
  3116. '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
  3117. '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
  3118. '<li class="duration">duration: <em>0</em>s</li>' +
  3119. '</ul>';
  3120. var playIcon = '&#x2023;';
  3121. /**
  3122. * Constructs a new `HTML` reporter instance.
  3123. *
  3124. * @public
  3125. * @class
  3126. * @memberof Mocha.reporters
  3127. * @extends Mocha.reporters.Base
  3128. * @param {Runner} runner - Instance triggers reporter actions.
  3129. * @param {Object} [options] - runner options
  3130. */
  3131. function HTML(runner, options) {
  3132. Base.call(this, runner, options);
  3133. var self = this;
  3134. var stats = this.stats;
  3135. var stat = fragment(statsTemplate);
  3136. var items = stat.getElementsByTagName('li');
  3137. var passes = items[1].getElementsByTagName('em')[0];
  3138. var passesLink = items[1].getElementsByTagName('a')[0];
  3139. var failures = items[2].getElementsByTagName('em')[0];
  3140. var failuresLink = items[2].getElementsByTagName('a')[0];
  3141. var duration = items[3].getElementsByTagName('em')[0];
  3142. var canvas = stat.getElementsByTagName('canvas')[0];
  3143. var report = fragment('<ul id="mocha-report"></ul>');
  3144. var stack = [report];
  3145. var progress;
  3146. var ctx;
  3147. var root = document.getElementById('mocha');
  3148. if (canvas.getContext) {
  3149. var ratio = window.devicePixelRatio || 1;
  3150. canvas.style.width = canvas.width;
  3151. canvas.style.height = canvas.height;
  3152. canvas.width *= ratio;
  3153. canvas.height *= ratio;
  3154. ctx = canvas.getContext('2d');
  3155. ctx.scale(ratio, ratio);
  3156. progress = new Progress();
  3157. }
  3158. if (!root) {
  3159. return error('#mocha div missing, add it to your document');
  3160. }
  3161. // pass toggle
  3162. on(passesLink, 'click', function(evt) {
  3163. evt.preventDefault();
  3164. unhide();
  3165. var name = /pass/.test(report.className) ? '' : ' pass';
  3166. report.className = report.className.replace(/fail|pass/g, '') + name;
  3167. if (report.className.trim()) {
  3168. hideSuitesWithout('test pass');
  3169. }
  3170. });
  3171. // failure toggle
  3172. on(failuresLink, 'click', function(evt) {
  3173. evt.preventDefault();
  3174. unhide();
  3175. var name = /fail/.test(report.className) ? '' : ' fail';
  3176. report.className = report.className.replace(/fail|pass/g, '') + name;
  3177. if (report.className.trim()) {
  3178. hideSuitesWithout('test fail');
  3179. }
  3180. });
  3181. root.appendChild(stat);
  3182. root.appendChild(report);
  3183. if (progress) {
  3184. progress.size(40);
  3185. }
  3186. runner.on(EVENT_SUITE_BEGIN, function(suite) {
  3187. if (suite.root) {
  3188. return;
  3189. }
  3190. // suite
  3191. var url = self.suiteURL(suite);
  3192. var el = fragment(
  3193. '<li class="suite"><h1><a href="%s">%s</a></h1></li>',
  3194. url,
  3195. escape(suite.title)
  3196. );
  3197. // container
  3198. stack[0].appendChild(el);
  3199. stack.unshift(document.createElement('ul'));
  3200. el.appendChild(stack[0]);
  3201. });
  3202. runner.on(EVENT_SUITE_END, function(suite) {
  3203. if (suite.root) {
  3204. updateStats();
  3205. return;
  3206. }
  3207. stack.shift();
  3208. });
  3209. runner.on(EVENT_TEST_PASS, function(test) {
  3210. var url = self.testURL(test);
  3211. var markup =
  3212. '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
  3213. '<a href="%s" class="replay">' +
  3214. playIcon +
  3215. '</a></h2></li>';
  3216. var el = fragment(markup, test.speed, test.title, test.duration, url);
  3217. self.addCodeToggle(el, test.body);
  3218. appendToStack(el);
  3219. updateStats();
  3220. });
  3221. runner.on(EVENT_TEST_FAIL, function(test) {
  3222. var el = fragment(
  3223. '<li class="test fail"><h2>%e <a href="%e" class="replay">' +
  3224. playIcon +
  3225. '</a></h2></li>',
  3226. test.title,
  3227. self.testURL(test)
  3228. );
  3229. var stackString; // Note: Includes leading newline
  3230. var message = test.err.toString();
  3231. // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
  3232. // check for the result of the stringifying.
  3233. if (message === '[object Error]') {
  3234. message = test.err.message;
  3235. }
  3236. if (test.err.stack) {
  3237. var indexOfMessage = test.err.stack.indexOf(test.err.message);
  3238. if (indexOfMessage === -1) {
  3239. stackString = test.err.stack;
  3240. } else {
  3241. stackString = test.err.stack.substr(
  3242. test.err.message.length + indexOfMessage
  3243. );
  3244. }
  3245. } else if (test.err.sourceURL && test.err.line !== undefined) {
  3246. // Safari doesn't give you a stack. Let's at least provide a source line.
  3247. stackString = '\n(' + test.err.sourceURL + ':' + test.err.line + ')';
  3248. }
  3249. stackString = stackString || '';
  3250. if (test.err.htmlMessage && stackString) {
  3251. el.appendChild(
  3252. fragment(
  3253. '<div class="html-error">%s\n<pre class="error">%e</pre></div>',
  3254. test.err.htmlMessage,
  3255. stackString
  3256. )
  3257. );
  3258. } else if (test.err.htmlMessage) {
  3259. el.appendChild(
  3260. fragment('<div class="html-error">%s</div>', test.err.htmlMessage)
  3261. );
  3262. } else {
  3263. el.appendChild(
  3264. fragment('<pre class="error">%e%e</pre>', message, stackString)
  3265. );
  3266. }
  3267. self.addCodeToggle(el, test.body);
  3268. appendToStack(el);
  3269. updateStats();
  3270. });
  3271. runner.on(EVENT_TEST_PENDING, function(test) {
  3272. var el = fragment(
  3273. '<li class="test pass pending"><h2>%e</h2></li>',
  3274. test.title
  3275. );
  3276. appendToStack(el);
  3277. updateStats();
  3278. });
  3279. function appendToStack(el) {
  3280. // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
  3281. if (stack[0]) {
  3282. stack[0].appendChild(el);
  3283. }
  3284. }
  3285. function updateStats() {
  3286. // TODO: add to stats
  3287. var percent = ((stats.tests / runner.total) * 100) | 0;
  3288. if (progress) {
  3289. progress.update(percent).draw(ctx);
  3290. }
  3291. // update stats
  3292. var ms = new Date() - stats.start;
  3293. text(passes, stats.passes);
  3294. text(failures, stats.failures);
  3295. text(duration, (ms / 1000).toFixed(2));
  3296. }
  3297. }
  3298. /**
  3299. * Makes a URL, preserving querystring ("search") parameters.
  3300. *
  3301. * @param {string} s
  3302. * @return {string} A new URL.
  3303. */
  3304. function makeUrl(s) {
  3305. var search = window.location.search;
  3306. // Remove previous grep query parameter if present
  3307. if (search) {
  3308. search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
  3309. }
  3310. return (
  3311. window.location.pathname +
  3312. (search ? search + '&' : '?') +
  3313. 'grep=' +
  3314. encodeURIComponent(escapeRe(s))
  3315. );
  3316. }
  3317. /**
  3318. * Provide suite URL.
  3319. *
  3320. * @param {Object} [suite]
  3321. */
  3322. HTML.prototype.suiteURL = function(suite) {
  3323. return makeUrl(suite.fullTitle());
  3324. };
  3325. /**
  3326. * Provide test URL.
  3327. *
  3328. * @param {Object} [test]
  3329. */
  3330. HTML.prototype.testURL = function(test) {
  3331. return makeUrl(test.fullTitle());
  3332. };
  3333. /**
  3334. * Adds code toggle functionality for the provided test's list element.
  3335. *
  3336. * @param {HTMLLIElement} el
  3337. * @param {string} contents
  3338. */
  3339. HTML.prototype.addCodeToggle = function(el, contents) {
  3340. var h2 = el.getElementsByTagName('h2')[0];
  3341. on(h2, 'click', function() {
  3342. pre.style.display = pre.style.display === 'none' ? 'block' : 'none';
  3343. });
  3344. var pre = fragment('<pre><code>%e</code></pre>', utils.clean(contents));
  3345. el.appendChild(pre);
  3346. pre.style.display = 'none';
  3347. };
  3348. /**
  3349. * Display error `msg`.
  3350. *
  3351. * @param {string} msg
  3352. */
  3353. function error(msg) {
  3354. document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));
  3355. }
  3356. /**
  3357. * Return a DOM fragment from `html`.
  3358. *
  3359. * @param {string} html
  3360. */
  3361. function fragment(html) {
  3362. var args = arguments;
  3363. var div = document.createElement('div');
  3364. var i = 1;
  3365. div.innerHTML = html.replace(/%([se])/g, function(_, type) {
  3366. switch (type) {
  3367. case 's':
  3368. return String(args[i++]);
  3369. case 'e':
  3370. return escape(args[i++]);
  3371. // no default
  3372. }
  3373. });
  3374. return div.firstChild;
  3375. }
  3376. /**
  3377. * Check for suites that do not have elements
  3378. * with `classname`, and hide them.
  3379. *
  3380. * @param {text} classname
  3381. */
  3382. function hideSuitesWithout(classname) {
  3383. var suites = document.getElementsByClassName('suite');
  3384. for (var i = 0; i < suites.length; i++) {
  3385. var els = suites[i].getElementsByClassName(classname);
  3386. if (!els.length) {
  3387. suites[i].className += ' hidden';
  3388. }
  3389. }
  3390. }
  3391. /**
  3392. * Unhide .hidden suites.
  3393. */
  3394. function unhide() {
  3395. var els = document.getElementsByClassName('suite hidden');
  3396. while (els.length > 0) {
  3397. els[0].className = els[0].className.replace('suite hidden', 'suite');
  3398. }
  3399. }
  3400. /**
  3401. * Set an element's text contents.
  3402. *
  3403. * @param {HTMLElement} el
  3404. * @param {string} contents
  3405. */
  3406. function text(el, contents) {
  3407. if (el.textContent) {
  3408. el.textContent = contents;
  3409. } else {
  3410. el.innerText = contents;
  3411. }
  3412. }
  3413. /**
  3414. * Listen on `event` with callback `fn`.
  3415. */
  3416. function on(el, event, fn) {
  3417. if (el.addEventListener) {
  3418. el.addEventListener(event, fn, false);
  3419. } else {
  3420. el.attachEvent('on' + event, fn);
  3421. }
  3422. }
  3423. HTML.browserOnly = true;
  3424. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  3425. },{"../browser/progress":3,"../runner":34,"../utils":38,"./base":17,"escape-string-regexp":49}],21:[function(require,module,exports){
  3426. 'use strict';
  3427. // Alias exports to a their normalized format Mocha#reporter to prevent a need
  3428. // for dynamic (try/catch) requires, which Browserify doesn't handle.
  3429. exports.Base = exports.base = require('./base');
  3430. exports.Dot = exports.dot = require('./dot');
  3431. exports.Doc = exports.doc = require('./doc');
  3432. exports.TAP = exports.tap = require('./tap');
  3433. exports.JSON = exports.json = require('./json');
  3434. exports.HTML = exports.html = require('./html');
  3435. exports.List = exports.list = require('./list');
  3436. exports.Min = exports.min = require('./min');
  3437. exports.Spec = exports.spec = require('./spec');
  3438. exports.Nyan = exports.nyan = require('./nyan');
  3439. exports.XUnit = exports.xunit = require('./xunit');
  3440. exports.Markdown = exports.markdown = require('./markdown');
  3441. exports.Progress = exports.progress = require('./progress');
  3442. exports.Landing = exports.landing = require('./landing');
  3443. exports.JSONStream = exports['json-stream'] = require('./json-stream');
  3444. },{"./base":17,"./doc":18,"./dot":19,"./html":20,"./json":23,"./json-stream":22,"./landing":24,"./list":25,"./markdown":26,"./min":27,"./nyan":28,"./progress":29,"./spec":30,"./tap":31,"./xunit":32}],22:[function(require,module,exports){
  3445. (function (process){
  3446. 'use strict';
  3447. /**
  3448. * @module JSONStream
  3449. */
  3450. /**
  3451. * Module dependencies.
  3452. */
  3453. var Base = require('./base');
  3454. var constants = require('../runner').constants;
  3455. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  3456. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  3457. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  3458. var EVENT_RUN_END = constants.EVENT_RUN_END;
  3459. /**
  3460. * Expose `JSONStream`.
  3461. */
  3462. exports = module.exports = JSONStream;
  3463. /**
  3464. * Constructs a new `JSONStream` reporter instance.
  3465. *
  3466. * @public
  3467. * @class
  3468. * @memberof Mocha.reporters
  3469. * @extends Mocha.reporters.Base
  3470. * @param {Runner} runner - Instance triggers reporter actions.
  3471. * @param {Object} [options] - runner options
  3472. */
  3473. function JSONStream(runner, options) {
  3474. Base.call(this, runner, options);
  3475. var self = this;
  3476. var total = runner.total;
  3477. runner.once(EVENT_RUN_BEGIN, function() {
  3478. writeEvent(['start', {total: total}]);
  3479. });
  3480. runner.on(EVENT_TEST_PASS, function(test) {
  3481. writeEvent(['pass', clean(test)]);
  3482. });
  3483. runner.on(EVENT_TEST_FAIL, function(test, err) {
  3484. test = clean(test);
  3485. test.err = err.message;
  3486. test.stack = err.stack || null;
  3487. writeEvent(['fail', test]);
  3488. });
  3489. runner.once(EVENT_RUN_END, function() {
  3490. writeEvent(['end', self.stats]);
  3491. });
  3492. }
  3493. /**
  3494. * Mocha event to be written to the output stream.
  3495. * @typedef {Array} JSONStream~MochaEvent
  3496. */
  3497. /**
  3498. * Writes Mocha event to reporter output stream.
  3499. *
  3500. * @private
  3501. * @param {JSONStream~MochaEvent} event - Mocha event to be output.
  3502. */
  3503. function writeEvent(event) {
  3504. process.stdout.write(JSON.stringify(event) + '\n');
  3505. }
  3506. /**
  3507. * Returns an object literal representation of `test`
  3508. * free of cyclic properties, etc.
  3509. *
  3510. * @private
  3511. * @param {Test} test - Instance used as data source.
  3512. * @return {Object} object containing pared-down test instance data
  3513. */
  3514. function clean(test) {
  3515. return {
  3516. title: test.title,
  3517. fullTitle: test.fullTitle(),
  3518. file: test.file,
  3519. duration: test.duration,
  3520. currentRetry: test.currentRetry()
  3521. };
  3522. }
  3523. JSONStream.description = 'newline delimited JSON events';
  3524. }).call(this,require('_process'))
  3525. },{"../runner":34,"./base":17,"_process":69}],23:[function(require,module,exports){
  3526. (function (process){
  3527. 'use strict';
  3528. /**
  3529. * @module JSON
  3530. */
  3531. /**
  3532. * Module dependencies.
  3533. */
  3534. var Base = require('./base');
  3535. var constants = require('../runner').constants;
  3536. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  3537. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  3538. var EVENT_TEST_END = constants.EVENT_TEST_END;
  3539. var EVENT_RUN_END = constants.EVENT_RUN_END;
  3540. var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
  3541. /**
  3542. * Expose `JSON`.
  3543. */
  3544. exports = module.exports = JSONReporter;
  3545. /**
  3546. * Constructs a new `JSON` reporter instance.
  3547. *
  3548. * @public
  3549. * @class JSON
  3550. * @memberof Mocha.reporters
  3551. * @extends Mocha.reporters.Base
  3552. * @param {Runner} runner - Instance triggers reporter actions.
  3553. * @param {Object} [options] - runner options
  3554. */
  3555. function JSONReporter(runner, options) {
  3556. Base.call(this, runner, options);
  3557. var self = this;
  3558. var tests = [];
  3559. var pending = [];
  3560. var failures = [];
  3561. var passes = [];
  3562. runner.on(EVENT_TEST_END, function(test) {
  3563. tests.push(test);
  3564. });
  3565. runner.on(EVENT_TEST_PASS, function(test) {
  3566. passes.push(test);
  3567. });
  3568. runner.on(EVENT_TEST_FAIL, function(test) {
  3569. failures.push(test);
  3570. });
  3571. runner.on(EVENT_TEST_PENDING, function(test) {
  3572. pending.push(test);
  3573. });
  3574. runner.once(EVENT_RUN_END, function() {
  3575. var obj = {
  3576. stats: self.stats,
  3577. tests: tests.map(clean),
  3578. pending: pending.map(clean),
  3579. failures: failures.map(clean),
  3580. passes: passes.map(clean)
  3581. };
  3582. runner.testResults = obj;
  3583. process.stdout.write(JSON.stringify(obj, null, 2));
  3584. });
  3585. }
  3586. /**
  3587. * Return a plain-object representation of `test`
  3588. * free of cyclic properties etc.
  3589. *
  3590. * @private
  3591. * @param {Object} test
  3592. * @return {Object}
  3593. */
  3594. function clean(test) {
  3595. var err = test.err || {};
  3596. if (err instanceof Error) {
  3597. err = errorJSON(err);
  3598. }
  3599. return {
  3600. title: test.title,
  3601. fullTitle: test.fullTitle(),
  3602. file: test.file,
  3603. duration: test.duration,
  3604. currentRetry: test.currentRetry(),
  3605. err: cleanCycles(err)
  3606. };
  3607. }
  3608. /**
  3609. * Replaces any circular references inside `obj` with '[object Object]'
  3610. *
  3611. * @private
  3612. * @param {Object} obj
  3613. * @return {Object}
  3614. */
  3615. function cleanCycles(obj) {
  3616. var cache = [];
  3617. return JSON.parse(
  3618. JSON.stringify(obj, function(key, value) {
  3619. if (typeof value === 'object' && value !== null) {
  3620. if (cache.indexOf(value) !== -1) {
  3621. // Instead of going in a circle, we'll print [object Object]
  3622. return '' + value;
  3623. }
  3624. cache.push(value);
  3625. }
  3626. return value;
  3627. })
  3628. );
  3629. }
  3630. /**
  3631. * Transform an Error object into a JSON object.
  3632. *
  3633. * @private
  3634. * @param {Error} err
  3635. * @return {Object}
  3636. */
  3637. function errorJSON(err) {
  3638. var res = {};
  3639. Object.getOwnPropertyNames(err).forEach(function(key) {
  3640. res[key] = err[key];
  3641. }, err);
  3642. return res;
  3643. }
  3644. JSONReporter.description = 'single JSON object';
  3645. }).call(this,require('_process'))
  3646. },{"../runner":34,"./base":17,"_process":69}],24:[function(require,module,exports){
  3647. (function (process){
  3648. 'use strict';
  3649. /**
  3650. * @module Landing
  3651. */
  3652. /**
  3653. * Module dependencies.
  3654. */
  3655. var Base = require('./base');
  3656. var inherits = require('../utils').inherits;
  3657. var constants = require('../runner').constants;
  3658. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  3659. var EVENT_RUN_END = constants.EVENT_RUN_END;
  3660. var EVENT_TEST_END = constants.EVENT_TEST_END;
  3661. var STATE_FAILED = require('../runnable').constants.STATE_FAILED;
  3662. var cursor = Base.cursor;
  3663. var color = Base.color;
  3664. /**
  3665. * Expose `Landing`.
  3666. */
  3667. exports = module.exports = Landing;
  3668. /**
  3669. * Airplane color.
  3670. */
  3671. Base.colors.plane = 0;
  3672. /**
  3673. * Airplane crash color.
  3674. */
  3675. Base.colors['plane crash'] = 31;
  3676. /**
  3677. * Runway color.
  3678. */
  3679. Base.colors.runway = 90;
  3680. /**
  3681. * Constructs a new `Landing` reporter instance.
  3682. *
  3683. * @public
  3684. * @class
  3685. * @memberof Mocha.reporters
  3686. * @extends Mocha.reporters.Base
  3687. * @param {Runner} runner - Instance triggers reporter actions.
  3688. * @param {Object} [options] - runner options
  3689. */
  3690. function Landing(runner, options) {
  3691. Base.call(this, runner, options);
  3692. var self = this;
  3693. var width = (Base.window.width * 0.75) | 0;
  3694. var total = runner.total;
  3695. var stream = process.stdout;
  3696. var plane = color('plane', '✈');
  3697. var crashed = -1;
  3698. var n = 0;
  3699. function runway() {
  3700. var buf = Array(width).join('-');
  3701. return ' ' + color('runway', buf);
  3702. }
  3703. runner.on(EVENT_RUN_BEGIN, function() {
  3704. stream.write('\n\n\n ');
  3705. cursor.hide();
  3706. });
  3707. runner.on(EVENT_TEST_END, function(test) {
  3708. // check if the plane crashed
  3709. var col = crashed === -1 ? ((width * ++n) / total) | 0 : crashed;
  3710. // show the crash
  3711. if (test.state === STATE_FAILED) {
  3712. plane = color('plane crash', '✈');
  3713. crashed = col;
  3714. }
  3715. // render landing strip
  3716. stream.write('\u001b[' + (width + 1) + 'D\u001b[2A');
  3717. stream.write(runway());
  3718. stream.write('\n ');
  3719. stream.write(color('runway', Array(col).join('⋅')));
  3720. stream.write(plane);
  3721. stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
  3722. stream.write(runway());
  3723. stream.write('\u001b[0m');
  3724. });
  3725. runner.once(EVENT_RUN_END, function() {
  3726. cursor.show();
  3727. process.stdout.write('\n');
  3728. self.epilogue();
  3729. });
  3730. // if cursor is hidden when we ctrl-C, then it will remain hidden unless...
  3731. process.once('SIGINT', function() {
  3732. cursor.show();
  3733. process.nextTick(function() {
  3734. process.kill(process.pid, 'SIGINT');
  3735. });
  3736. });
  3737. }
  3738. /**
  3739. * Inherit from `Base.prototype`.
  3740. */
  3741. inherits(Landing, Base);
  3742. Landing.description = 'Unicode landing strip';
  3743. }).call(this,require('_process'))
  3744. },{"../runnable":33,"../runner":34,"../utils":38,"./base":17,"_process":69}],25:[function(require,module,exports){
  3745. (function (process){
  3746. 'use strict';
  3747. /**
  3748. * @module List
  3749. */
  3750. /**
  3751. * Module dependencies.
  3752. */
  3753. var Base = require('./base');
  3754. var inherits = require('../utils').inherits;
  3755. var constants = require('../runner').constants;
  3756. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  3757. var EVENT_RUN_END = constants.EVENT_RUN_END;
  3758. var EVENT_TEST_BEGIN = constants.EVENT_TEST_BEGIN;
  3759. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  3760. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  3761. var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
  3762. var color = Base.color;
  3763. var cursor = Base.cursor;
  3764. /**
  3765. * Expose `List`.
  3766. */
  3767. exports = module.exports = List;
  3768. /**
  3769. * Constructs a new `List` reporter instance.
  3770. *
  3771. * @public
  3772. * @class
  3773. * @memberof Mocha.reporters
  3774. * @extends Mocha.reporters.Base
  3775. * @param {Runner} runner - Instance triggers reporter actions.
  3776. * @param {Object} [options] - runner options
  3777. */
  3778. function List(runner, options) {
  3779. Base.call(this, runner, options);
  3780. var self = this;
  3781. var n = 0;
  3782. runner.on(EVENT_RUN_BEGIN, function() {
  3783. Base.consoleLog();
  3784. });
  3785. runner.on(EVENT_TEST_BEGIN, function(test) {
  3786. process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
  3787. });
  3788. runner.on(EVENT_TEST_PENDING, function(test) {
  3789. var fmt = color('checkmark', ' -') + color('pending', ' %s');
  3790. Base.consoleLog(fmt, test.fullTitle());
  3791. });
  3792. runner.on(EVENT_TEST_PASS, function(test) {
  3793. var fmt =
  3794. color('checkmark', ' ' + Base.symbols.ok) +
  3795. color('pass', ' %s: ') +
  3796. color(test.speed, '%dms');
  3797. cursor.CR();
  3798. Base.consoleLog(fmt, test.fullTitle(), test.duration);
  3799. });
  3800. runner.on(EVENT_TEST_FAIL, function(test) {
  3801. cursor.CR();
  3802. Base.consoleLog(color('fail', ' %d) %s'), ++n, test.fullTitle());
  3803. });
  3804. runner.once(EVENT_RUN_END, self.epilogue.bind(self));
  3805. }
  3806. /**
  3807. * Inherit from `Base.prototype`.
  3808. */
  3809. inherits(List, Base);
  3810. List.description = 'like "spec" reporter but flat';
  3811. }).call(this,require('_process'))
  3812. },{"../runner":34,"../utils":38,"./base":17,"_process":69}],26:[function(require,module,exports){
  3813. (function (process){
  3814. 'use strict';
  3815. /**
  3816. * @module Markdown
  3817. */
  3818. /**
  3819. * Module dependencies.
  3820. */
  3821. var Base = require('./base');
  3822. var utils = require('../utils');
  3823. var constants = require('../runner').constants;
  3824. var EVENT_RUN_END = constants.EVENT_RUN_END;
  3825. var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
  3826. var EVENT_SUITE_END = constants.EVENT_SUITE_END;
  3827. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  3828. /**
  3829. * Constants
  3830. */
  3831. var SUITE_PREFIX = '$';
  3832. /**
  3833. * Expose `Markdown`.
  3834. */
  3835. exports = module.exports = Markdown;
  3836. /**
  3837. * Constructs a new `Markdown` reporter instance.
  3838. *
  3839. * @public
  3840. * @class
  3841. * @memberof Mocha.reporters
  3842. * @extends Mocha.reporters.Base
  3843. * @param {Runner} runner - Instance triggers reporter actions.
  3844. * @param {Object} [options] - runner options
  3845. */
  3846. function Markdown(runner, options) {
  3847. Base.call(this, runner, options);
  3848. var level = 0;
  3849. var buf = '';
  3850. function title(str) {
  3851. return Array(level).join('#') + ' ' + str;
  3852. }
  3853. function mapTOC(suite, obj) {
  3854. var ret = obj;
  3855. var key = SUITE_PREFIX + suite.title;
  3856. obj = obj[key] = obj[key] || {suite: suite};
  3857. suite.suites.forEach(function(suite) {
  3858. mapTOC(suite, obj);
  3859. });
  3860. return ret;
  3861. }
  3862. function stringifyTOC(obj, level) {
  3863. ++level;
  3864. var buf = '';
  3865. var link;
  3866. for (var key in obj) {
  3867. if (key === 'suite') {
  3868. continue;
  3869. }
  3870. if (key !== SUITE_PREFIX) {
  3871. link = ' - [' + key.substring(1) + ']';
  3872. link += '(#' + utils.slug(obj[key].suite.fullTitle()) + ')\n';
  3873. buf += Array(level).join(' ') + link;
  3874. }
  3875. buf += stringifyTOC(obj[key], level);
  3876. }
  3877. return buf;
  3878. }
  3879. function generateTOC(suite) {
  3880. var obj = mapTOC(suite, {});
  3881. return stringifyTOC(obj, 0);
  3882. }
  3883. generateTOC(runner.suite);
  3884. runner.on(EVENT_SUITE_BEGIN, function(suite) {
  3885. ++level;
  3886. var slug = utils.slug(suite.fullTitle());
  3887. buf += '<a name="' + slug + '"></a>' + '\n';
  3888. buf += title(suite.title) + '\n';
  3889. });
  3890. runner.on(EVENT_SUITE_END, function() {
  3891. --level;
  3892. });
  3893. runner.on(EVENT_TEST_PASS, function(test) {
  3894. var code = utils.clean(test.body);
  3895. buf += test.title + '.\n';
  3896. buf += '\n```js\n';
  3897. buf += code + '\n';
  3898. buf += '```\n\n';
  3899. });
  3900. runner.once(EVENT_RUN_END, function() {
  3901. process.stdout.write('# TOC\n');
  3902. process.stdout.write(generateTOC(runner.suite));
  3903. process.stdout.write(buf);
  3904. });
  3905. }
  3906. Markdown.description = 'GitHub Flavored Markdown';
  3907. }).call(this,require('_process'))
  3908. },{"../runner":34,"../utils":38,"./base":17,"_process":69}],27:[function(require,module,exports){
  3909. (function (process){
  3910. 'use strict';
  3911. /**
  3912. * @module Min
  3913. */
  3914. /**
  3915. * Module dependencies.
  3916. */
  3917. var Base = require('./base');
  3918. var inherits = require('../utils').inherits;
  3919. var constants = require('../runner').constants;
  3920. var EVENT_RUN_END = constants.EVENT_RUN_END;
  3921. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  3922. /**
  3923. * Expose `Min`.
  3924. */
  3925. exports = module.exports = Min;
  3926. /**
  3927. * Constructs a new `Min` reporter instance.
  3928. *
  3929. * @description
  3930. * This minimal test reporter is best used with '--watch'.
  3931. *
  3932. * @public
  3933. * @class
  3934. * @memberof Mocha.reporters
  3935. * @extends Mocha.reporters.Base
  3936. * @param {Runner} runner - Instance triggers reporter actions.
  3937. * @param {Object} [options] - runner options
  3938. */
  3939. function Min(runner, options) {
  3940. Base.call(this, runner, options);
  3941. runner.on(EVENT_RUN_BEGIN, function() {
  3942. // clear screen
  3943. process.stdout.write('\u001b[2J');
  3944. // set cursor position
  3945. process.stdout.write('\u001b[1;3H');
  3946. });
  3947. runner.once(EVENT_RUN_END, this.epilogue.bind(this));
  3948. }
  3949. /**
  3950. * Inherit from `Base.prototype`.
  3951. */
  3952. inherits(Min, Base);
  3953. Min.description = 'essentially just a summary';
  3954. }).call(this,require('_process'))
  3955. },{"../runner":34,"../utils":38,"./base":17,"_process":69}],28:[function(require,module,exports){
  3956. (function (process){
  3957. 'use strict';
  3958. /**
  3959. * @module Nyan
  3960. */
  3961. /**
  3962. * Module dependencies.
  3963. */
  3964. var Base = require('./base');
  3965. var constants = require('../runner').constants;
  3966. var inherits = require('../utils').inherits;
  3967. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  3968. var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
  3969. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  3970. var EVENT_RUN_END = constants.EVENT_RUN_END;
  3971. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  3972. /**
  3973. * Expose `Dot`.
  3974. */
  3975. exports = module.exports = NyanCat;
  3976. /**
  3977. * Constructs a new `Nyan` reporter instance.
  3978. *
  3979. * @public
  3980. * @class Nyan
  3981. * @memberof Mocha.reporters
  3982. * @extends Mocha.reporters.Base
  3983. * @param {Runner} runner - Instance triggers reporter actions.
  3984. * @param {Object} [options] - runner options
  3985. */
  3986. function NyanCat(runner, options) {
  3987. Base.call(this, runner, options);
  3988. var self = this;
  3989. var width = (Base.window.width * 0.75) | 0;
  3990. var nyanCatWidth = (this.nyanCatWidth = 11);
  3991. this.colorIndex = 0;
  3992. this.numberOfLines = 4;
  3993. this.rainbowColors = self.generateColors();
  3994. this.scoreboardWidth = 5;
  3995. this.tick = 0;
  3996. this.trajectories = [[], [], [], []];
  3997. this.trajectoryWidthMax = width - nyanCatWidth;
  3998. runner.on(EVENT_RUN_BEGIN, function() {
  3999. Base.cursor.hide();
  4000. self.draw();
  4001. });
  4002. runner.on(EVENT_TEST_PENDING, function() {
  4003. self.draw();
  4004. });
  4005. runner.on(EVENT_TEST_PASS, function() {
  4006. self.draw();
  4007. });
  4008. runner.on(EVENT_TEST_FAIL, function() {
  4009. self.draw();
  4010. });
  4011. runner.once(EVENT_RUN_END, function() {
  4012. Base.cursor.show();
  4013. for (var i = 0; i < self.numberOfLines; i++) {
  4014. write('\n');
  4015. }
  4016. self.epilogue();
  4017. });
  4018. }
  4019. /**
  4020. * Inherit from `Base.prototype`.
  4021. */
  4022. inherits(NyanCat, Base);
  4023. /**
  4024. * Draw the nyan cat
  4025. *
  4026. * @private
  4027. */
  4028. NyanCat.prototype.draw = function() {
  4029. this.appendRainbow();
  4030. this.drawScoreboard();
  4031. this.drawRainbow();
  4032. this.drawNyanCat();
  4033. this.tick = !this.tick;
  4034. };
  4035. /**
  4036. * Draw the "scoreboard" showing the number
  4037. * of passes, failures and pending tests.
  4038. *
  4039. * @private
  4040. */
  4041. NyanCat.prototype.drawScoreboard = function() {
  4042. var stats = this.stats;
  4043. function draw(type, n) {
  4044. write(' ');
  4045. write(Base.color(type, n));
  4046. write('\n');
  4047. }
  4048. draw('green', stats.passes);
  4049. draw('fail', stats.failures);
  4050. draw('pending', stats.pending);
  4051. write('\n');
  4052. this.cursorUp(this.numberOfLines);
  4053. };
  4054. /**
  4055. * Append the rainbow.
  4056. *
  4057. * @private
  4058. */
  4059. NyanCat.prototype.appendRainbow = function() {
  4060. var segment = this.tick ? '_' : '-';
  4061. var rainbowified = this.rainbowify(segment);
  4062. for (var index = 0; index < this.numberOfLines; index++) {
  4063. var trajectory = this.trajectories[index];
  4064. if (trajectory.length >= this.trajectoryWidthMax) {
  4065. trajectory.shift();
  4066. }
  4067. trajectory.push(rainbowified);
  4068. }
  4069. };
  4070. /**
  4071. * Draw the rainbow.
  4072. *
  4073. * @private
  4074. */
  4075. NyanCat.prototype.drawRainbow = function() {
  4076. var self = this;
  4077. this.trajectories.forEach(function(line) {
  4078. write('\u001b[' + self.scoreboardWidth + 'C');
  4079. write(line.join(''));
  4080. write('\n');
  4081. });
  4082. this.cursorUp(this.numberOfLines);
  4083. };
  4084. /**
  4085. * Draw the nyan cat
  4086. *
  4087. * @private
  4088. */
  4089. NyanCat.prototype.drawNyanCat = function() {
  4090. var self = this;
  4091. var startWidth = this.scoreboardWidth + this.trajectories[0].length;
  4092. var dist = '\u001b[' + startWidth + 'C';
  4093. var padding = '';
  4094. write(dist);
  4095. write('_,------,');
  4096. write('\n');
  4097. write(dist);
  4098. padding = self.tick ? ' ' : ' ';
  4099. write('_|' + padding + '/\\_/\\ ');
  4100. write('\n');
  4101. write(dist);
  4102. padding = self.tick ? '_' : '__';
  4103. var tail = self.tick ? '~' : '^';
  4104. write(tail + '|' + padding + this.face() + ' ');
  4105. write('\n');
  4106. write(dist);
  4107. padding = self.tick ? ' ' : ' ';
  4108. write(padding + '"" "" ');
  4109. write('\n');
  4110. this.cursorUp(this.numberOfLines);
  4111. };
  4112. /**
  4113. * Draw nyan cat face.
  4114. *
  4115. * @private
  4116. * @return {string}
  4117. */
  4118. NyanCat.prototype.face = function() {
  4119. var stats = this.stats;
  4120. if (stats.failures) {
  4121. return '( x .x)';
  4122. } else if (stats.pending) {
  4123. return '( o .o)';
  4124. } else if (stats.passes) {
  4125. return '( ^ .^)';
  4126. }
  4127. return '( - .-)';
  4128. };
  4129. /**
  4130. * Move cursor up `n`.
  4131. *
  4132. * @private
  4133. * @param {number} n
  4134. */
  4135. NyanCat.prototype.cursorUp = function(n) {
  4136. write('\u001b[' + n + 'A');
  4137. };
  4138. /**
  4139. * Move cursor down `n`.
  4140. *
  4141. * @private
  4142. * @param {number} n
  4143. */
  4144. NyanCat.prototype.cursorDown = function(n) {
  4145. write('\u001b[' + n + 'B');
  4146. };
  4147. /**
  4148. * Generate rainbow colors.
  4149. *
  4150. * @private
  4151. * @return {Array}
  4152. */
  4153. NyanCat.prototype.generateColors = function() {
  4154. var colors = [];
  4155. for (var i = 0; i < 6 * 7; i++) {
  4156. var pi3 = Math.floor(Math.PI / 3);
  4157. var n = i * (1.0 / 6);
  4158. var r = Math.floor(3 * Math.sin(n) + 3);
  4159. var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
  4160. var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
  4161. colors.push(36 * r + 6 * g + b + 16);
  4162. }
  4163. return colors;
  4164. };
  4165. /**
  4166. * Apply rainbow to the given `str`.
  4167. *
  4168. * @private
  4169. * @param {string} str
  4170. * @return {string}
  4171. */
  4172. NyanCat.prototype.rainbowify = function(str) {
  4173. if (!Base.useColors) {
  4174. return str;
  4175. }
  4176. var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
  4177. this.colorIndex += 1;
  4178. return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
  4179. };
  4180. /**
  4181. * Stdout helper.
  4182. *
  4183. * @param {string} string A message to write to stdout.
  4184. */
  4185. function write(string) {
  4186. process.stdout.write(string);
  4187. }
  4188. NyanCat.description = '"nyan cat"';
  4189. }).call(this,require('_process'))
  4190. },{"../runner":34,"../utils":38,"./base":17,"_process":69}],29:[function(require,module,exports){
  4191. (function (process){
  4192. 'use strict';
  4193. /**
  4194. * @module Progress
  4195. */
  4196. /**
  4197. * Module dependencies.
  4198. */
  4199. var Base = require('./base');
  4200. var constants = require('../runner').constants;
  4201. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  4202. var EVENT_TEST_END = constants.EVENT_TEST_END;
  4203. var EVENT_RUN_END = constants.EVENT_RUN_END;
  4204. var inherits = require('../utils').inherits;
  4205. var color = Base.color;
  4206. var cursor = Base.cursor;
  4207. /**
  4208. * Expose `Progress`.
  4209. */
  4210. exports = module.exports = Progress;
  4211. /**
  4212. * General progress bar color.
  4213. */
  4214. Base.colors.progress = 90;
  4215. /**
  4216. * Constructs a new `Progress` reporter instance.
  4217. *
  4218. * @public
  4219. * @class
  4220. * @memberof Mocha.reporters
  4221. * @extends Mocha.reporters.Base
  4222. * @param {Runner} runner - Instance triggers reporter actions.
  4223. * @param {Object} [options] - runner options
  4224. */
  4225. function Progress(runner, options) {
  4226. Base.call(this, runner, options);
  4227. var self = this;
  4228. var width = (Base.window.width * 0.5) | 0;
  4229. var total = runner.total;
  4230. var complete = 0;
  4231. var lastN = -1;
  4232. // default chars
  4233. options = options || {};
  4234. var reporterOptions = options.reporterOptions || {};
  4235. options.open = reporterOptions.open || '[';
  4236. options.complete = reporterOptions.complete || '▬';
  4237. options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
  4238. options.close = reporterOptions.close || ']';
  4239. options.verbose = reporterOptions.verbose || false;
  4240. // tests started
  4241. runner.on(EVENT_RUN_BEGIN, function() {
  4242. process.stdout.write('\n');
  4243. cursor.hide();
  4244. });
  4245. // tests complete
  4246. runner.on(EVENT_TEST_END, function() {
  4247. complete++;
  4248. var percent = complete / total;
  4249. var n = (width * percent) | 0;
  4250. var i = width - n;
  4251. if (n === lastN && !options.verbose) {
  4252. // Don't re-render the line if it hasn't changed
  4253. return;
  4254. }
  4255. lastN = n;
  4256. cursor.CR();
  4257. process.stdout.write('\u001b[J');
  4258. process.stdout.write(color('progress', ' ' + options.open));
  4259. process.stdout.write(Array(n).join(options.complete));
  4260. process.stdout.write(Array(i).join(options.incomplete));
  4261. process.stdout.write(color('progress', options.close));
  4262. if (options.verbose) {
  4263. process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
  4264. }
  4265. });
  4266. // tests are complete, output some stats
  4267. // and the failures if any
  4268. runner.once(EVENT_RUN_END, function() {
  4269. cursor.show();
  4270. process.stdout.write('\n');
  4271. self.epilogue();
  4272. });
  4273. }
  4274. /**
  4275. * Inherit from `Base.prototype`.
  4276. */
  4277. inherits(Progress, Base);
  4278. Progress.description = 'a progress bar';
  4279. }).call(this,require('_process'))
  4280. },{"../runner":34,"../utils":38,"./base":17,"_process":69}],30:[function(require,module,exports){
  4281. 'use strict';
  4282. /**
  4283. * @module Spec
  4284. */
  4285. /**
  4286. * Module dependencies.
  4287. */
  4288. var Base = require('./base');
  4289. var constants = require('../runner').constants;
  4290. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  4291. var EVENT_RUN_END = constants.EVENT_RUN_END;
  4292. var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
  4293. var EVENT_SUITE_END = constants.EVENT_SUITE_END;
  4294. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  4295. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  4296. var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
  4297. var inherits = require('../utils').inherits;
  4298. var color = Base.color;
  4299. /**
  4300. * Expose `Spec`.
  4301. */
  4302. exports = module.exports = Spec;
  4303. /**
  4304. * Constructs a new `Spec` reporter instance.
  4305. *
  4306. * @public
  4307. * @class
  4308. * @memberof Mocha.reporters
  4309. * @extends Mocha.reporters.Base
  4310. * @param {Runner} runner - Instance triggers reporter actions.
  4311. * @param {Object} [options] - runner options
  4312. */
  4313. function Spec(runner, options) {
  4314. Base.call(this, runner, options);
  4315. var self = this;
  4316. var indents = 0;
  4317. var n = 0;
  4318. function indent() {
  4319. return Array(indents).join(' ');
  4320. }
  4321. runner.on(EVENT_RUN_BEGIN, function() {
  4322. Base.consoleLog();
  4323. });
  4324. runner.on(EVENT_SUITE_BEGIN, function(suite) {
  4325. ++indents;
  4326. Base.consoleLog(color('suite', '%s%s'), indent(), suite.title);
  4327. });
  4328. runner.on(EVENT_SUITE_END, function() {
  4329. --indents;
  4330. if (indents === 1) {
  4331. Base.consoleLog();
  4332. }
  4333. });
  4334. runner.on(EVENT_TEST_PENDING, function(test) {
  4335. var fmt = indent() + color('pending', ' - %s');
  4336. Base.consoleLog(fmt, test.title);
  4337. });
  4338. runner.on(EVENT_TEST_PASS, function(test) {
  4339. var fmt;
  4340. if (test.speed === 'fast') {
  4341. fmt =
  4342. indent() +
  4343. color('checkmark', ' ' + Base.symbols.ok) +
  4344. color('pass', ' %s');
  4345. Base.consoleLog(fmt, test.title);
  4346. } else {
  4347. fmt =
  4348. indent() +
  4349. color('checkmark', ' ' + Base.symbols.ok) +
  4350. color('pass', ' %s') +
  4351. color(test.speed, ' (%dms)');
  4352. Base.consoleLog(fmt, test.title, test.duration);
  4353. }
  4354. });
  4355. runner.on(EVENT_TEST_FAIL, function(test) {
  4356. Base.consoleLog(indent() + color('fail', ' %d) %s'), ++n, test.title);
  4357. });
  4358. runner.once(EVENT_RUN_END, self.epilogue.bind(self));
  4359. }
  4360. /**
  4361. * Inherit from `Base.prototype`.
  4362. */
  4363. inherits(Spec, Base);
  4364. Spec.description = 'hierarchical & verbose [default]';
  4365. },{"../runner":34,"../utils":38,"./base":17}],31:[function(require,module,exports){
  4366. (function (process){
  4367. 'use strict';
  4368. /**
  4369. * @module TAP
  4370. */
  4371. /**
  4372. * Module dependencies.
  4373. */
  4374. var util = require('util');
  4375. var Base = require('./base');
  4376. var constants = require('../runner').constants;
  4377. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  4378. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  4379. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  4380. var EVENT_RUN_END = constants.EVENT_RUN_END;
  4381. var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
  4382. var EVENT_TEST_END = constants.EVENT_TEST_END;
  4383. var inherits = require('../utils').inherits;
  4384. var sprintf = util.format;
  4385. /**
  4386. * Expose `TAP`.
  4387. */
  4388. exports = module.exports = TAP;
  4389. /**
  4390. * Constructs a new `TAP` reporter instance.
  4391. *
  4392. * @public
  4393. * @class
  4394. * @memberof Mocha.reporters
  4395. * @extends Mocha.reporters.Base
  4396. * @param {Runner} runner - Instance triggers reporter actions.
  4397. * @param {Object} [options] - runner options
  4398. */
  4399. function TAP(runner, options) {
  4400. Base.call(this, runner, options);
  4401. var self = this;
  4402. var n = 1;
  4403. var tapVersion = '12';
  4404. if (options && options.reporterOptions) {
  4405. if (options.reporterOptions.tapVersion) {
  4406. tapVersion = options.reporterOptions.tapVersion.toString();
  4407. }
  4408. }
  4409. this._producer = createProducer(tapVersion);
  4410. runner.once(EVENT_RUN_BEGIN, function() {
  4411. var ntests = runner.grepTotal(runner.suite);
  4412. self._producer.writeVersion();
  4413. self._producer.writePlan(ntests);
  4414. });
  4415. runner.on(EVENT_TEST_END, function() {
  4416. ++n;
  4417. });
  4418. runner.on(EVENT_TEST_PENDING, function(test) {
  4419. self._producer.writePending(n, test);
  4420. });
  4421. runner.on(EVENT_TEST_PASS, function(test) {
  4422. self._producer.writePass(n, test);
  4423. });
  4424. runner.on(EVENT_TEST_FAIL, function(test, err) {
  4425. self._producer.writeFail(n, test, err);
  4426. });
  4427. runner.once(EVENT_RUN_END, function() {
  4428. self._producer.writeEpilogue(runner.stats);
  4429. });
  4430. }
  4431. /**
  4432. * Inherit from `Base.prototype`.
  4433. */
  4434. inherits(TAP, Base);
  4435. /**
  4436. * Returns a TAP-safe title of `test`.
  4437. *
  4438. * @private
  4439. * @param {Test} test - Test instance.
  4440. * @return {String} title with any hash character removed
  4441. */
  4442. function title(test) {
  4443. return test.fullTitle().replace(/#/g, '');
  4444. }
  4445. /**
  4446. * Writes newline-terminated formatted string to reporter output stream.
  4447. *
  4448. * @private
  4449. * @param {string} format - `printf`-like format string
  4450. * @param {...*} [varArgs] - Format string arguments
  4451. */
  4452. function println(format, varArgs) {
  4453. var vargs = Array.from(arguments);
  4454. vargs[0] += '\n';
  4455. process.stdout.write(sprintf.apply(null, vargs));
  4456. }
  4457. /**
  4458. * Returns a `tapVersion`-appropriate TAP producer instance, if possible.
  4459. *
  4460. * @private
  4461. * @param {string} tapVersion - Version of TAP specification to produce.
  4462. * @returns {TAPProducer} specification-appropriate instance
  4463. * @throws {Error} if specification version has no associated producer.
  4464. */
  4465. function createProducer(tapVersion) {
  4466. var producers = {
  4467. '12': new TAP12Producer(),
  4468. '13': new TAP13Producer()
  4469. };
  4470. var producer = producers[tapVersion];
  4471. if (!producer) {
  4472. throw new Error(
  4473. 'invalid or unsupported TAP version: ' + JSON.stringify(tapVersion)
  4474. );
  4475. }
  4476. return producer;
  4477. }
  4478. /**
  4479. * @summary
  4480. * Constructs a new TAPProducer.
  4481. *
  4482. * @description
  4483. * <em>Only</em> to be used as an abstract base class.
  4484. *
  4485. * @private
  4486. * @constructor
  4487. */
  4488. function TAPProducer() {}
  4489. /**
  4490. * Writes the TAP version to reporter output stream.
  4491. *
  4492. * @abstract
  4493. */
  4494. TAPProducer.prototype.writeVersion = function() {};
  4495. /**
  4496. * Writes the plan to reporter output stream.
  4497. *
  4498. * @abstract
  4499. * @param {number} ntests - Number of tests that are planned to run.
  4500. */
  4501. TAPProducer.prototype.writePlan = function(ntests) {
  4502. println('%d..%d', 1, ntests);
  4503. };
  4504. /**
  4505. * Writes that test passed to reporter output stream.
  4506. *
  4507. * @abstract
  4508. * @param {number} n - Index of test that passed.
  4509. * @param {Test} test - Instance containing test information.
  4510. */
  4511. TAPProducer.prototype.writePass = function(n, test) {
  4512. println('ok %d %s', n, title(test));
  4513. };
  4514. /**
  4515. * Writes that test was skipped to reporter output stream.
  4516. *
  4517. * @abstract
  4518. * @param {number} n - Index of test that was skipped.
  4519. * @param {Test} test - Instance containing test information.
  4520. */
  4521. TAPProducer.prototype.writePending = function(n, test) {
  4522. println('ok %d %s # SKIP -', n, title(test));
  4523. };
  4524. /**
  4525. * Writes that test failed to reporter output stream.
  4526. *
  4527. * @abstract
  4528. * @param {number} n - Index of test that failed.
  4529. * @param {Test} test - Instance containing test information.
  4530. * @param {Error} err - Reason the test failed.
  4531. */
  4532. TAPProducer.prototype.writeFail = function(n, test, err) {
  4533. println('not ok %d %s', n, title(test));
  4534. };
  4535. /**
  4536. * Writes the summary epilogue to reporter output stream.
  4537. *
  4538. * @abstract
  4539. * @param {Object} stats - Object containing run statistics.
  4540. */
  4541. TAPProducer.prototype.writeEpilogue = function(stats) {
  4542. // :TBD: Why is this not counting pending tests?
  4543. println('# tests ' + (stats.passes + stats.failures));
  4544. println('# pass ' + stats.passes);
  4545. // :TBD: Why are we not showing pending results?
  4546. println('# fail ' + stats.failures);
  4547. };
  4548. /**
  4549. * @summary
  4550. * Constructs a new TAP12Producer.
  4551. *
  4552. * @description
  4553. * Produces output conforming to the TAP12 specification.
  4554. *
  4555. * @private
  4556. * @constructor
  4557. * @extends TAPProducer
  4558. * @see {@link https://testanything.org/tap-specification.html|Specification}
  4559. */
  4560. function TAP12Producer() {
  4561. /**
  4562. * Writes that test failed to reporter output stream, with error formatting.
  4563. * @override
  4564. */
  4565. this.writeFail = function(n, test, err) {
  4566. TAPProducer.prototype.writeFail.call(this, n, test, err);
  4567. if (err.message) {
  4568. println(err.message.replace(/^/gm, ' '));
  4569. }
  4570. if (err.stack) {
  4571. println(err.stack.replace(/^/gm, ' '));
  4572. }
  4573. };
  4574. }
  4575. /**
  4576. * Inherit from `TAPProducer.prototype`.
  4577. */
  4578. inherits(TAP12Producer, TAPProducer);
  4579. /**
  4580. * @summary
  4581. * Constructs a new TAP13Producer.
  4582. *
  4583. * @description
  4584. * Produces output conforming to the TAP13 specification.
  4585. *
  4586. * @private
  4587. * @constructor
  4588. * @extends TAPProducer
  4589. * @see {@link https://testanything.org/tap-version-13-specification.html|Specification}
  4590. */
  4591. function TAP13Producer() {
  4592. /**
  4593. * Writes the TAP version to reporter output stream.
  4594. * @override
  4595. */
  4596. this.writeVersion = function() {
  4597. println('TAP version 13');
  4598. };
  4599. /**
  4600. * Writes that test failed to reporter output stream, with error formatting.
  4601. * @override
  4602. */
  4603. this.writeFail = function(n, test, err) {
  4604. TAPProducer.prototype.writeFail.call(this, n, test, err);
  4605. var emitYamlBlock = err.message != null || err.stack != null;
  4606. if (emitYamlBlock) {
  4607. println(indent(1) + '---');
  4608. if (err.message) {
  4609. println(indent(2) + 'message: |-');
  4610. println(err.message.replace(/^/gm, indent(3)));
  4611. }
  4612. if (err.stack) {
  4613. println(indent(2) + 'stack: |-');
  4614. println(err.stack.replace(/^/gm, indent(3)));
  4615. }
  4616. println(indent(1) + '...');
  4617. }
  4618. };
  4619. function indent(level) {
  4620. return Array(level + 1).join(' ');
  4621. }
  4622. }
  4623. /**
  4624. * Inherit from `TAPProducer.prototype`.
  4625. */
  4626. inherits(TAP13Producer, TAPProducer);
  4627. TAP.description = 'TAP-compatible output';
  4628. }).call(this,require('_process'))
  4629. },{"../runner":34,"../utils":38,"./base":17,"_process":69,"util":89}],32:[function(require,module,exports){
  4630. (function (process,global){
  4631. 'use strict';
  4632. /**
  4633. * @module XUnit
  4634. */
  4635. /**
  4636. * Module dependencies.
  4637. */
  4638. var Base = require('./base');
  4639. var utils = require('../utils');
  4640. var fs = require('fs');
  4641. var mkdirp = require('mkdirp');
  4642. var path = require('path');
  4643. var errors = require('../errors');
  4644. var createUnsupportedError = errors.createUnsupportedError;
  4645. var constants = require('../runner').constants;
  4646. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  4647. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  4648. var EVENT_RUN_END = constants.EVENT_RUN_END;
  4649. var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
  4650. var STATE_FAILED = require('../runnable').constants.STATE_FAILED;
  4651. var inherits = utils.inherits;
  4652. var escape = utils.escape;
  4653. /**
  4654. * Save timer references to avoid Sinon interfering (see GH-237).
  4655. */
  4656. var Date = global.Date;
  4657. /**
  4658. * Expose `XUnit`.
  4659. */
  4660. exports = module.exports = XUnit;
  4661. /**
  4662. * Constructs a new `XUnit` reporter instance.
  4663. *
  4664. * @public
  4665. * @class
  4666. * @memberof Mocha.reporters
  4667. * @extends Mocha.reporters.Base
  4668. * @param {Runner} runner - Instance triggers reporter actions.
  4669. * @param {Object} [options] - runner options
  4670. */
  4671. function XUnit(runner, options) {
  4672. Base.call(this, runner, options);
  4673. var stats = this.stats;
  4674. var tests = [];
  4675. var self = this;
  4676. // the name of the test suite, as it will appear in the resulting XML file
  4677. var suiteName;
  4678. // the default name of the test suite if none is provided
  4679. var DEFAULT_SUITE_NAME = 'Mocha Tests';
  4680. if (options && options.reporterOptions) {
  4681. if (options.reporterOptions.output) {
  4682. if (!fs.createWriteStream) {
  4683. throw createUnsupportedError('file output not supported in browser');
  4684. }
  4685. mkdirp.sync(path.dirname(options.reporterOptions.output));
  4686. self.fileStream = fs.createWriteStream(options.reporterOptions.output);
  4687. }
  4688. // get the suite name from the reporter options (if provided)
  4689. suiteName = options.reporterOptions.suiteName;
  4690. }
  4691. // fall back to the default suite name
  4692. suiteName = suiteName || DEFAULT_SUITE_NAME;
  4693. runner.on(EVENT_TEST_PENDING, function(test) {
  4694. tests.push(test);
  4695. });
  4696. runner.on(EVENT_TEST_PASS, function(test) {
  4697. tests.push(test);
  4698. });
  4699. runner.on(EVENT_TEST_FAIL, function(test) {
  4700. tests.push(test);
  4701. });
  4702. runner.once(EVENT_RUN_END, function() {
  4703. self.write(
  4704. tag(
  4705. 'testsuite',
  4706. {
  4707. name: suiteName,
  4708. tests: stats.tests,
  4709. failures: 0,
  4710. errors: stats.failures,
  4711. skipped: stats.tests - stats.failures - stats.passes,
  4712. timestamp: new Date().toUTCString(),
  4713. time: stats.duration / 1000 || 0
  4714. },
  4715. false
  4716. )
  4717. );
  4718. tests.forEach(function(t) {
  4719. self.test(t);
  4720. });
  4721. self.write('</testsuite>');
  4722. });
  4723. }
  4724. /**
  4725. * Inherit from `Base.prototype`.
  4726. */
  4727. inherits(XUnit, Base);
  4728. /**
  4729. * Override done to close the stream (if it's a file).
  4730. *
  4731. * @param failures
  4732. * @param {Function} fn
  4733. */
  4734. XUnit.prototype.done = function(failures, fn) {
  4735. if (this.fileStream) {
  4736. this.fileStream.end(function() {
  4737. fn(failures);
  4738. });
  4739. } else {
  4740. fn(failures);
  4741. }
  4742. };
  4743. /**
  4744. * Write out the given line.
  4745. *
  4746. * @param {string} line
  4747. */
  4748. XUnit.prototype.write = function(line) {
  4749. if (this.fileStream) {
  4750. this.fileStream.write(line + '\n');
  4751. } else if (typeof process === 'object' && process.stdout) {
  4752. process.stdout.write(line + '\n');
  4753. } else {
  4754. Base.consoleLog(line);
  4755. }
  4756. };
  4757. /**
  4758. * Output tag for the given `test.`
  4759. *
  4760. * @param {Test} test
  4761. */
  4762. XUnit.prototype.test = function(test) {
  4763. Base.useColors = false;
  4764. var attrs = {
  4765. classname: test.parent.fullTitle(),
  4766. name: test.title,
  4767. time: test.duration / 1000 || 0
  4768. };
  4769. if (test.state === STATE_FAILED) {
  4770. var err = test.err;
  4771. var diff =
  4772. !Base.hideDiff && Base.showDiff(err)
  4773. ? '\n' + Base.generateDiff(err.actual, err.expected)
  4774. : '';
  4775. this.write(
  4776. tag(
  4777. 'testcase',
  4778. attrs,
  4779. false,
  4780. tag(
  4781. 'failure',
  4782. {},
  4783. false,
  4784. escape(err.message) + escape(diff) + '\n' + escape(err.stack)
  4785. )
  4786. )
  4787. );
  4788. } else if (test.isPending()) {
  4789. this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));
  4790. } else {
  4791. this.write(tag('testcase', attrs, true));
  4792. }
  4793. };
  4794. /**
  4795. * HTML tag helper.
  4796. *
  4797. * @param name
  4798. * @param attrs
  4799. * @param close
  4800. * @param content
  4801. * @return {string}
  4802. */
  4803. function tag(name, attrs, close, content) {
  4804. var end = close ? '/>' : '>';
  4805. var pairs = [];
  4806. var tag;
  4807. for (var key in attrs) {
  4808. if (Object.prototype.hasOwnProperty.call(attrs, key)) {
  4809. pairs.push(key + '="' + escape(attrs[key]) + '"');
  4810. }
  4811. }
  4812. tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
  4813. if (content) {
  4814. tag += content + '</' + name + end;
  4815. }
  4816. return tag;
  4817. }
  4818. XUnit.description = 'XUnit-compatible XML output';
  4819. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  4820. },{"../errors":6,"../runnable":33,"../runner":34,"../utils":38,"./base":17,"_process":69,"fs":42,"mkdirp":59,"path":42}],33:[function(require,module,exports){
  4821. (function (global){
  4822. 'use strict';
  4823. var EventEmitter = require('events').EventEmitter;
  4824. var Pending = require('./pending');
  4825. var debug = require('debug')('mocha:runnable');
  4826. var milliseconds = require('ms');
  4827. var utils = require('./utils');
  4828. var errors = require('./errors');
  4829. var createInvalidExceptionError = errors.createInvalidExceptionError;
  4830. var createMultipleDoneError = errors.createMultipleDoneError;
  4831. /**
  4832. * Save timer references to avoid Sinon interfering (see GH-237).
  4833. */
  4834. var Date = global.Date;
  4835. var setTimeout = global.setTimeout;
  4836. var clearTimeout = global.clearTimeout;
  4837. var toString = Object.prototype.toString;
  4838. module.exports = Runnable;
  4839. /**
  4840. * Initialize a new `Runnable` with the given `title` and callback `fn`.
  4841. *
  4842. * @class
  4843. * @extends external:EventEmitter
  4844. * @public
  4845. * @param {String} title
  4846. * @param {Function} fn
  4847. */
  4848. function Runnable(title, fn) {
  4849. this.title = title;
  4850. this.fn = fn;
  4851. this.body = (fn || '').toString();
  4852. this.async = fn && fn.length;
  4853. this.sync = !this.async;
  4854. this._timeout = 2000;
  4855. this._slow = 75;
  4856. this._enableTimeouts = true;
  4857. this._retries = -1;
  4858. this.reset();
  4859. }
  4860. /**
  4861. * Inherit from `EventEmitter.prototype`.
  4862. */
  4863. utils.inherits(Runnable, EventEmitter);
  4864. /**
  4865. * Resets the state initially or for a next run.
  4866. */
  4867. Runnable.prototype.reset = function() {
  4868. this.timedOut = false;
  4869. this._currentRetry = 0;
  4870. this.pending = false;
  4871. delete this.state;
  4872. delete this.err;
  4873. };
  4874. /**
  4875. * Get current timeout value in msecs.
  4876. *
  4877. * @private
  4878. * @returns {number} current timeout threshold value
  4879. */
  4880. /**
  4881. * @summary
  4882. * Set timeout threshold value (msecs).
  4883. *
  4884. * @description
  4885. * A string argument can use shorthand (e.g., "2s") and will be converted.
  4886. * The value will be clamped to range [<code>0</code>, <code>2^<sup>31</sup>-1</code>].
  4887. * If clamped value matches either range endpoint, timeouts will be disabled.
  4888. *
  4889. * @private
  4890. * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value}
  4891. * @param {number|string} ms - Timeout threshold value.
  4892. * @returns {Runnable} this
  4893. * @chainable
  4894. */
  4895. Runnable.prototype.timeout = function(ms) {
  4896. if (!arguments.length) {
  4897. return this._timeout;
  4898. }
  4899. if (typeof ms === 'string') {
  4900. ms = milliseconds(ms);
  4901. }
  4902. // Clamp to range
  4903. var INT_MAX = Math.pow(2, 31) - 1;
  4904. var range = [0, INT_MAX];
  4905. ms = utils.clamp(ms, range);
  4906. // see #1652 for reasoning
  4907. if (ms === range[0] || ms === range[1]) {
  4908. this._enableTimeouts = false;
  4909. }
  4910. debug('timeout %d', ms);
  4911. this._timeout = ms;
  4912. if (this.timer) {
  4913. this.resetTimeout();
  4914. }
  4915. return this;
  4916. };
  4917. /**
  4918. * Set or get slow `ms`.
  4919. *
  4920. * @private
  4921. * @param {number|string} ms
  4922. * @return {Runnable|number} ms or Runnable instance.
  4923. */
  4924. Runnable.prototype.slow = function(ms) {
  4925. if (!arguments.length || typeof ms === 'undefined') {
  4926. return this._slow;
  4927. }
  4928. if (typeof ms === 'string') {
  4929. ms = milliseconds(ms);
  4930. }
  4931. debug('slow %d', ms);
  4932. this._slow = ms;
  4933. return this;
  4934. };
  4935. /**
  4936. * Set and get whether timeout is `enabled`.
  4937. *
  4938. * @private
  4939. * @param {boolean} enabled
  4940. * @return {Runnable|boolean} enabled or Runnable instance.
  4941. */
  4942. Runnable.prototype.enableTimeouts = function(enabled) {
  4943. if (!arguments.length) {
  4944. return this._enableTimeouts;
  4945. }
  4946. debug('enableTimeouts %s', enabled);
  4947. this._enableTimeouts = enabled;
  4948. return this;
  4949. };
  4950. /**
  4951. * Halt and mark as pending.
  4952. *
  4953. * @memberof Mocha.Runnable
  4954. * @public
  4955. */
  4956. Runnable.prototype.skip = function() {
  4957. this.pending = true;
  4958. throw new Pending('sync skip; aborting execution');
  4959. };
  4960. /**
  4961. * Check if this runnable or its parent suite is marked as pending.
  4962. *
  4963. * @private
  4964. */
  4965. Runnable.prototype.isPending = function() {
  4966. return this.pending || (this.parent && this.parent.isPending());
  4967. };
  4968. /**
  4969. * Return `true` if this Runnable has failed.
  4970. * @return {boolean}
  4971. * @private
  4972. */
  4973. Runnable.prototype.isFailed = function() {
  4974. return !this.isPending() && this.state === constants.STATE_FAILED;
  4975. };
  4976. /**
  4977. * Return `true` if this Runnable has passed.
  4978. * @return {boolean}
  4979. * @private
  4980. */
  4981. Runnable.prototype.isPassed = function() {
  4982. return !this.isPending() && this.state === constants.STATE_PASSED;
  4983. };
  4984. /**
  4985. * Set or get number of retries.
  4986. *
  4987. * @private
  4988. */
  4989. Runnable.prototype.retries = function(n) {
  4990. if (!arguments.length) {
  4991. return this._retries;
  4992. }
  4993. this._retries = n;
  4994. };
  4995. /**
  4996. * Set or get current retry
  4997. *
  4998. * @private
  4999. */
  5000. Runnable.prototype.currentRetry = function(n) {
  5001. if (!arguments.length) {
  5002. return this._currentRetry;
  5003. }
  5004. this._currentRetry = n;
  5005. };
  5006. /**
  5007. * Return the full title generated by recursively concatenating the parent's
  5008. * full title.
  5009. *
  5010. * @memberof Mocha.Runnable
  5011. * @public
  5012. * @return {string}
  5013. */
  5014. Runnable.prototype.fullTitle = function() {
  5015. return this.titlePath().join(' ');
  5016. };
  5017. /**
  5018. * Return the title path generated by concatenating the parent's title path with the title.
  5019. *
  5020. * @memberof Mocha.Runnable
  5021. * @public
  5022. * @return {string}
  5023. */
  5024. Runnable.prototype.titlePath = function() {
  5025. return this.parent.titlePath().concat([this.title]);
  5026. };
  5027. /**
  5028. * Clear the timeout.
  5029. *
  5030. * @private
  5031. */
  5032. Runnable.prototype.clearTimeout = function() {
  5033. clearTimeout(this.timer);
  5034. };
  5035. /**
  5036. * Reset the timeout.
  5037. *
  5038. * @private
  5039. */
  5040. Runnable.prototype.resetTimeout = function() {
  5041. var self = this;
  5042. var ms = this.timeout() || 1e9;
  5043. if (!this._enableTimeouts) {
  5044. return;
  5045. }
  5046. this.clearTimeout();
  5047. this.timer = setTimeout(function() {
  5048. if (!self._enableTimeouts) {
  5049. return;
  5050. }
  5051. self.callback(self._timeoutError(ms));
  5052. self.timedOut = true;
  5053. }, ms);
  5054. };
  5055. /**
  5056. * Set or get a list of whitelisted globals for this test run.
  5057. *
  5058. * @private
  5059. * @param {string[]} globals
  5060. */
  5061. Runnable.prototype.globals = function(globals) {
  5062. if (!arguments.length) {
  5063. return this._allowedGlobals;
  5064. }
  5065. this._allowedGlobals = globals;
  5066. };
  5067. /**
  5068. * Run the test and invoke `fn(err)`.
  5069. *
  5070. * @param {Function} fn
  5071. * @private
  5072. */
  5073. Runnable.prototype.run = function(fn) {
  5074. var self = this;
  5075. var start = new Date();
  5076. var ctx = this.ctx;
  5077. var finished;
  5078. var errorWasHandled = false;
  5079. // Sometimes the ctx exists, but it is not runnable
  5080. if (ctx && ctx.runnable) {
  5081. ctx.runnable(this);
  5082. }
  5083. // called multiple times
  5084. function multiple(err) {
  5085. if (errorWasHandled) {
  5086. return;
  5087. }
  5088. errorWasHandled = true;
  5089. self.emit('error', createMultipleDoneError(self, err));
  5090. }
  5091. // finished
  5092. function done(err) {
  5093. var ms = self.timeout();
  5094. if (self.timedOut) {
  5095. return;
  5096. }
  5097. if (finished) {
  5098. return multiple(err);
  5099. }
  5100. self.clearTimeout();
  5101. self.duration = new Date() - start;
  5102. finished = true;
  5103. if (!err && self.duration > ms && self._enableTimeouts) {
  5104. err = self._timeoutError(ms);
  5105. }
  5106. fn(err);
  5107. }
  5108. // for .resetTimeout() and Runner#uncaught()
  5109. this.callback = done;
  5110. if (this.fn && typeof this.fn.call !== 'function') {
  5111. done(
  5112. new TypeError(
  5113. 'A runnable must be passed a function as its second argument.'
  5114. )
  5115. );
  5116. return;
  5117. }
  5118. // explicit async with `done` argument
  5119. if (this.async) {
  5120. this.resetTimeout();
  5121. // allows skip() to be used in an explicit async context
  5122. this.skip = function asyncSkip() {
  5123. this.pending = true;
  5124. done();
  5125. // halt execution, the uncaught handler will ignore the failure.
  5126. throw new Pending('async skip; aborting execution');
  5127. };
  5128. try {
  5129. callFnAsync(this.fn);
  5130. } catch (err) {
  5131. // handles async runnables which actually run synchronously
  5132. errorWasHandled = true;
  5133. if (err instanceof Pending) {
  5134. return; // done() is already called in this.skip()
  5135. } else if (this.allowUncaught) {
  5136. throw err;
  5137. }
  5138. done(Runnable.toValueOrError(err));
  5139. }
  5140. return;
  5141. }
  5142. // sync or promise-returning
  5143. try {
  5144. if (this.isPending()) {
  5145. done();
  5146. } else {
  5147. callFn(this.fn);
  5148. }
  5149. } catch (err) {
  5150. errorWasHandled = true;
  5151. if (err instanceof Pending) {
  5152. return done();
  5153. } else if (this.allowUncaught) {
  5154. throw err;
  5155. }
  5156. done(Runnable.toValueOrError(err));
  5157. }
  5158. function callFn(fn) {
  5159. var result = fn.call(ctx);
  5160. if (result && typeof result.then === 'function') {
  5161. self.resetTimeout();
  5162. result.then(
  5163. function() {
  5164. done();
  5165. // Return null so libraries like bluebird do not warn about
  5166. // subsequently constructed Promises.
  5167. return null;
  5168. },
  5169. function(reason) {
  5170. done(reason || new Error('Promise rejected with no or falsy reason'));
  5171. }
  5172. );
  5173. } else {
  5174. if (self.asyncOnly) {
  5175. return done(
  5176. new Error(
  5177. '--async-only option in use without declaring `done()` or returning a promise'
  5178. )
  5179. );
  5180. }
  5181. done();
  5182. }
  5183. }
  5184. function callFnAsync(fn) {
  5185. var result = fn.call(ctx, function(err) {
  5186. if (err instanceof Error || toString.call(err) === '[object Error]') {
  5187. return done(err);
  5188. }
  5189. if (err) {
  5190. if (Object.prototype.toString.call(err) === '[object Object]') {
  5191. return done(
  5192. new Error('done() invoked with non-Error: ' + JSON.stringify(err))
  5193. );
  5194. }
  5195. return done(new Error('done() invoked with non-Error: ' + err));
  5196. }
  5197. if (result && utils.isPromise(result)) {
  5198. return done(
  5199. new Error(
  5200. 'Resolution method is overspecified. Specify a callback *or* return a Promise; not both.'
  5201. )
  5202. );
  5203. }
  5204. done();
  5205. });
  5206. }
  5207. };
  5208. /**
  5209. * Instantiates a "timeout" error
  5210. *
  5211. * @param {number} ms - Timeout (in milliseconds)
  5212. * @returns {Error} a "timeout" error
  5213. * @private
  5214. */
  5215. Runnable.prototype._timeoutError = function(ms) {
  5216. var msg =
  5217. 'Timeout of ' +
  5218. ms +
  5219. 'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
  5220. if (this.file) {
  5221. msg += ' (' + this.file + ')';
  5222. }
  5223. return new Error(msg);
  5224. };
  5225. var constants = utils.defineConstants(
  5226. /**
  5227. * {@link Runnable}-related constants.
  5228. * @public
  5229. * @memberof Runnable
  5230. * @readonly
  5231. * @static
  5232. * @alias constants
  5233. * @enum {string}
  5234. */
  5235. {
  5236. /**
  5237. * Value of `state` prop when a `Runnable` has failed
  5238. */
  5239. STATE_FAILED: 'failed',
  5240. /**
  5241. * Value of `state` prop when a `Runnable` has passed
  5242. */
  5243. STATE_PASSED: 'passed'
  5244. }
  5245. );
  5246. /**
  5247. * Given `value`, return identity if truthy, otherwise create an "invalid exception" error and return that.
  5248. * @param {*} [value] - Value to return, if present
  5249. * @returns {*|Error} `value`, otherwise an `Error`
  5250. * @private
  5251. */
  5252. Runnable.toValueOrError = function(value) {
  5253. return (
  5254. value ||
  5255. createInvalidExceptionError(
  5256. 'Runnable failed with falsy or undefined exception. Please throw an Error instead.',
  5257. value
  5258. )
  5259. );
  5260. };
  5261. Runnable.constants = constants;
  5262. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  5263. },{"./errors":6,"./pending":16,"./utils":38,"debug":45,"events":50,"ms":60}],34:[function(require,module,exports){
  5264. (function (process,global){
  5265. 'use strict';
  5266. /**
  5267. * Module dependencies.
  5268. */
  5269. var util = require('util');
  5270. var EventEmitter = require('events').EventEmitter;
  5271. var Pending = require('./pending');
  5272. var utils = require('./utils');
  5273. var inherits = utils.inherits;
  5274. var debug = require('debug')('mocha:runner');
  5275. var Runnable = require('./runnable');
  5276. var Suite = require('./suite');
  5277. var HOOK_TYPE_BEFORE_EACH = Suite.constants.HOOK_TYPE_BEFORE_EACH;
  5278. var HOOK_TYPE_AFTER_EACH = Suite.constants.HOOK_TYPE_AFTER_EACH;
  5279. var HOOK_TYPE_AFTER_ALL = Suite.constants.HOOK_TYPE_AFTER_ALL;
  5280. var HOOK_TYPE_BEFORE_ALL = Suite.constants.HOOK_TYPE_BEFORE_ALL;
  5281. var EVENT_ROOT_SUITE_RUN = Suite.constants.EVENT_ROOT_SUITE_RUN;
  5282. var STATE_FAILED = Runnable.constants.STATE_FAILED;
  5283. var STATE_PASSED = Runnable.constants.STATE_PASSED;
  5284. var dQuote = utils.dQuote;
  5285. var sQuote = utils.sQuote;
  5286. var stackFilter = utils.stackTraceFilter();
  5287. var stringify = utils.stringify;
  5288. var type = utils.type;
  5289. var errors = require('./errors');
  5290. var createInvalidExceptionError = errors.createInvalidExceptionError;
  5291. var createUnsupportedError = errors.createUnsupportedError;
  5292. var createFatalError = errors.createFatalError;
  5293. /**
  5294. * Non-enumerable globals.
  5295. * @readonly
  5296. */
  5297. var globals = [
  5298. 'setTimeout',
  5299. 'clearTimeout',
  5300. 'setInterval',
  5301. 'clearInterval',
  5302. 'XMLHttpRequest',
  5303. 'Date',
  5304. 'setImmediate',
  5305. 'clearImmediate'
  5306. ];
  5307. var constants = utils.defineConstants(
  5308. /**
  5309. * {@link Runner}-related constants.
  5310. * @public
  5311. * @memberof Runner
  5312. * @readonly
  5313. * @alias constants
  5314. * @static
  5315. * @enum {string}
  5316. */
  5317. {
  5318. /**
  5319. * Emitted when {@link Hook} execution begins
  5320. */
  5321. EVENT_HOOK_BEGIN: 'hook',
  5322. /**
  5323. * Emitted when {@link Hook} execution ends
  5324. */
  5325. EVENT_HOOK_END: 'hook end',
  5326. /**
  5327. * Emitted when Root {@link Suite} execution begins (all files have been parsed and hooks/tests are ready for execution)
  5328. */
  5329. EVENT_RUN_BEGIN: 'start',
  5330. /**
  5331. * Emitted when Root {@link Suite} execution has been delayed via `delay` option
  5332. */
  5333. EVENT_DELAY_BEGIN: 'waiting',
  5334. /**
  5335. * Emitted when delayed Root {@link Suite} execution is triggered by user via `global.run()`
  5336. */
  5337. EVENT_DELAY_END: 'ready',
  5338. /**
  5339. * Emitted when Root {@link Suite} execution ends
  5340. */
  5341. EVENT_RUN_END: 'end',
  5342. /**
  5343. * Emitted when {@link Suite} execution begins
  5344. */
  5345. EVENT_SUITE_BEGIN: 'suite',
  5346. /**
  5347. * Emitted when {@link Suite} execution ends
  5348. */
  5349. EVENT_SUITE_END: 'suite end',
  5350. /**
  5351. * Emitted when {@link Test} execution begins
  5352. */
  5353. EVENT_TEST_BEGIN: 'test',
  5354. /**
  5355. * Emitted when {@link Test} execution ends
  5356. */
  5357. EVENT_TEST_END: 'test end',
  5358. /**
  5359. * Emitted when {@link Test} execution fails
  5360. */
  5361. EVENT_TEST_FAIL: 'fail',
  5362. /**
  5363. * Emitted when {@link Test} execution succeeds
  5364. */
  5365. EVENT_TEST_PASS: 'pass',
  5366. /**
  5367. * Emitted when {@link Test} becomes pending
  5368. */
  5369. EVENT_TEST_PENDING: 'pending',
  5370. /**
  5371. * Emitted when {@link Test} execution has failed, but will retry
  5372. */
  5373. EVENT_TEST_RETRY: 'retry',
  5374. /**
  5375. * Initial state of Runner
  5376. */
  5377. STATE_IDLE: 'idle',
  5378. /**
  5379. * State set to this value when the Runner has started running
  5380. */
  5381. STATE_RUNNING: 'running',
  5382. /**
  5383. * State set to this value when the Runner has stopped
  5384. */
  5385. STATE_STOPPED: 'stopped'
  5386. }
  5387. );
  5388. module.exports = Runner;
  5389. /**
  5390. * Initialize a `Runner` at the Root {@link Suite}, which represents a hierarchy of {@link Suite|Suites} and {@link Test|Tests}.
  5391. *
  5392. * @extends external:EventEmitter
  5393. * @public
  5394. * @class
  5395. * @param {Suite} suite - Root suite
  5396. * @param {Object|boolean} [opts] - Options. If `boolean`, whether or not to delay execution of root suite until ready (for backwards compatibility).
  5397. * @param {boolean} [opts.delay] - Whether to delay execution of root suite until ready.
  5398. * @param {boolean} [opts.cleanReferencesAfterRun] - Whether to clean references to test fns and hooks when a suite is done.
  5399. */
  5400. function Runner(suite, opts) {
  5401. if (opts === undefined) {
  5402. opts = {};
  5403. }
  5404. if (typeof opts === 'boolean') {
  5405. this._delay = opts;
  5406. opts = {};
  5407. } else {
  5408. this._delay = opts.delay;
  5409. }
  5410. var self = this;
  5411. this._globals = [];
  5412. this._abort = false;
  5413. this.suite = suite;
  5414. this._opts = opts;
  5415. this.state = constants.STATE_IDLE;
  5416. this.total = suite.total();
  5417. this.failures = 0;
  5418. this._eventListeners = [];
  5419. this.on(constants.EVENT_TEST_END, function(test) {
  5420. if (test.type === 'test' && test.retriedTest() && test.parent) {
  5421. var idx =
  5422. test.parent.tests && test.parent.tests.indexOf(test.retriedTest());
  5423. if (idx > -1) test.parent.tests[idx] = test;
  5424. }
  5425. self.checkGlobals(test);
  5426. });
  5427. this.on(constants.EVENT_HOOK_END, function(hook) {
  5428. self.checkGlobals(hook);
  5429. });
  5430. this._defaultGrep = /.*/;
  5431. this.grep(this._defaultGrep);
  5432. this.globals(this.globalProps());
  5433. this.uncaught = this._uncaught.bind(this);
  5434. }
  5435. /**
  5436. * Wrapper for setImmediate, process.nextTick, or browser polyfill.
  5437. *
  5438. * @param {Function} fn
  5439. * @private
  5440. */
  5441. Runner.immediately = global.setImmediate || process.nextTick;
  5442. /**
  5443. * Inherit from `EventEmitter.prototype`.
  5444. */
  5445. inherits(Runner, EventEmitter);
  5446. /**
  5447. * Replacement for `target.on(eventName, listener)` that does bookkeeping to remove them when this runner instance is disposed.
  5448. * @param {EventEmitter} target - The `EventEmitter`
  5449. * @param {string} eventName - The event name
  5450. * @param {string} fn - Listener function
  5451. */
  5452. Runner.prototype._addEventListener = function(target, eventName, listener) {
  5453. target.on(eventName, listener);
  5454. this._eventListeners.push([target, eventName, listener]);
  5455. };
  5456. /**
  5457. * Replacement for `target.removeListener(eventName, listener)` that also updates the bookkeeping.
  5458. * @param {EventEmitter} target - The `EventEmitter`
  5459. * @param {string} eventName - The event anme
  5460. * @param {function} listener - Listener function
  5461. */
  5462. Runner.prototype._removeEventListener = function(target, eventName, listener) {
  5463. var eventListenerIndex = -1;
  5464. for (var i = 0; i < this._eventListeners.length; i++) {
  5465. var eventListenerDescriptor = this._eventListeners[i];
  5466. if (
  5467. eventListenerDescriptor[0] === target &&
  5468. eventListenerDescriptor[1] === eventName &&
  5469. eventListenerDescriptor[2] === listener
  5470. ) {
  5471. eventListenerIndex = i;
  5472. break;
  5473. }
  5474. }
  5475. if (eventListenerIndex !== -1) {
  5476. var removedListener = this._eventListeners.splice(eventListenerIndex, 1)[0];
  5477. removedListener[0].removeListener(removedListener[1], removedListener[2]);
  5478. }
  5479. };
  5480. /**
  5481. * Removes all event handlers set during a run on this instance.
  5482. * Remark: this does _not_ clean/dispose the tests or suites themselves.
  5483. */
  5484. Runner.prototype.dispose = function() {
  5485. this.removeAllListeners();
  5486. this._eventListeners.forEach(function(eventListenerDescriptor) {
  5487. eventListenerDescriptor[0].removeListener(
  5488. eventListenerDescriptor[1],
  5489. eventListenerDescriptor[2]
  5490. );
  5491. });
  5492. };
  5493. /**
  5494. * Run tests with full titles matching `re`. Updates runner.total
  5495. * with number of tests matched.
  5496. *
  5497. * @public
  5498. * @memberof Runner
  5499. * @param {RegExp} re
  5500. * @param {boolean} invert
  5501. * @return {Runner} Runner instance.
  5502. */
  5503. Runner.prototype.grep = function(re, invert) {
  5504. debug('grep(): setting to %s', re);
  5505. this._grep = re;
  5506. this._invert = invert;
  5507. this.total = this.grepTotal(this.suite);
  5508. return this;
  5509. };
  5510. /**
  5511. * Returns the number of tests matching the grep search for the
  5512. * given suite.
  5513. *
  5514. * @memberof Runner
  5515. * @public
  5516. * @param {Suite} suite
  5517. * @return {number}
  5518. */
  5519. Runner.prototype.grepTotal = function(suite) {
  5520. var self = this;
  5521. var total = 0;
  5522. suite.eachTest(function(test) {
  5523. var match = self._grep.test(test.fullTitle());
  5524. if (self._invert) {
  5525. match = !match;
  5526. }
  5527. if (match) {
  5528. total++;
  5529. }
  5530. });
  5531. return total;
  5532. };
  5533. /**
  5534. * Return a list of global properties.
  5535. *
  5536. * @return {Array}
  5537. * @private
  5538. */
  5539. Runner.prototype.globalProps = function() {
  5540. var props = Object.keys(global);
  5541. // non-enumerables
  5542. for (var i = 0; i < globals.length; ++i) {
  5543. if (~props.indexOf(globals[i])) {
  5544. continue;
  5545. }
  5546. props.push(globals[i]);
  5547. }
  5548. return props;
  5549. };
  5550. /**
  5551. * Allow the given `arr` of globals.
  5552. *
  5553. * @public
  5554. * @memberof Runner
  5555. * @param {Array} arr
  5556. * @return {Runner} Runner instance.
  5557. */
  5558. Runner.prototype.globals = function(arr) {
  5559. if (!arguments.length) {
  5560. return this._globals;
  5561. }
  5562. debug('globals(): setting to %O', arr);
  5563. this._globals = this._globals.concat(arr);
  5564. return this;
  5565. };
  5566. /**
  5567. * Check for global variable leaks.
  5568. *
  5569. * @private
  5570. */
  5571. Runner.prototype.checkGlobals = function(test) {
  5572. if (!this.checkLeaks) {
  5573. return;
  5574. }
  5575. var ok = this._globals;
  5576. var globals = this.globalProps();
  5577. var leaks;
  5578. if (test) {
  5579. ok = ok.concat(test._allowedGlobals || []);
  5580. }
  5581. if (this.prevGlobalsLength === globals.length) {
  5582. return;
  5583. }
  5584. this.prevGlobalsLength = globals.length;
  5585. leaks = filterLeaks(ok, globals);
  5586. this._globals = this._globals.concat(leaks);
  5587. if (leaks.length) {
  5588. var msg = 'global leak(s) detected: %s';
  5589. var error = new Error(util.format(msg, leaks.map(sQuote).join(', ')));
  5590. this.fail(test, error);
  5591. }
  5592. };
  5593. /**
  5594. * Fail the given `test`.
  5595. *
  5596. * @private
  5597. * @param {Test} test
  5598. * @param {Error} err
  5599. */
  5600. Runner.prototype.fail = function(test, err) {
  5601. if (test.isPending()) {
  5602. return;
  5603. }
  5604. if (this.state === constants.STATE_STOPPED) {
  5605. if (err.code === errors.constants.MULTIPLE_DONE) {
  5606. throw err;
  5607. }
  5608. throw createFatalError(
  5609. 'Test failed after root suite execution completed!',
  5610. err
  5611. );
  5612. }
  5613. ++this.failures;
  5614. debug('total number of failures: %d', this.failures);
  5615. test.state = STATE_FAILED;
  5616. if (!isError(err)) {
  5617. err = thrown2Error(err);
  5618. }
  5619. try {
  5620. err.stack =
  5621. this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack);
  5622. } catch (ignore) {
  5623. // some environments do not take kindly to monkeying with the stack
  5624. }
  5625. this.emit(constants.EVENT_TEST_FAIL, test, err);
  5626. };
  5627. /**
  5628. * Fail the given `hook` with `err`.
  5629. *
  5630. * Hook failures work in the following pattern:
  5631. * - If bail, run corresponding `after each` and `after` hooks,
  5632. * then exit
  5633. * - Failed `before` hook skips all tests in a suite and subsuites,
  5634. * but jumps to corresponding `after` hook
  5635. * - Failed `before each` hook skips remaining tests in a
  5636. * suite and jumps to corresponding `after each` hook,
  5637. * which is run only once
  5638. * - Failed `after` hook does not alter execution order
  5639. * - Failed `after each` hook skips remaining tests in a
  5640. * suite and subsuites, but executes other `after each`
  5641. * hooks
  5642. *
  5643. * @private
  5644. * @param {Hook} hook
  5645. * @param {Error} err
  5646. */
  5647. Runner.prototype.failHook = function(hook, err) {
  5648. hook.originalTitle = hook.originalTitle || hook.title;
  5649. if (hook.ctx && hook.ctx.currentTest) {
  5650. hook.title =
  5651. hook.originalTitle + ' for ' + dQuote(hook.ctx.currentTest.title);
  5652. } else {
  5653. var parentTitle;
  5654. if (hook.parent.title) {
  5655. parentTitle = hook.parent.title;
  5656. } else {
  5657. parentTitle = hook.parent.root ? '{root}' : '';
  5658. }
  5659. hook.title = hook.originalTitle + ' in ' + dQuote(parentTitle);
  5660. }
  5661. this.fail(hook, err);
  5662. };
  5663. /**
  5664. * Run hook `name` callbacks and then invoke `fn()`.
  5665. *
  5666. * @private
  5667. * @param {string} name
  5668. * @param {Function} fn
  5669. */
  5670. Runner.prototype.hook = function(name, fn) {
  5671. var suite = this.suite;
  5672. var hooks = suite.getHooks(name);
  5673. var self = this;
  5674. function next(i) {
  5675. var hook = hooks[i];
  5676. if (!hook) {
  5677. return fn();
  5678. }
  5679. self.currentRunnable = hook;
  5680. if (name === HOOK_TYPE_BEFORE_ALL) {
  5681. hook.ctx.currentTest = hook.parent.tests[0];
  5682. } else if (name === HOOK_TYPE_AFTER_ALL) {
  5683. hook.ctx.currentTest = hook.parent.tests[hook.parent.tests.length - 1];
  5684. } else {
  5685. hook.ctx.currentTest = self.test;
  5686. }
  5687. hook.allowUncaught = self.allowUncaught;
  5688. self.emit(constants.EVENT_HOOK_BEGIN, hook);
  5689. if (!hook.listeners('error').length) {
  5690. self._addEventListener(hook, 'error', function(err) {
  5691. self.failHook(hook, err);
  5692. });
  5693. }
  5694. hook.run(function(err) {
  5695. var testError = hook.error();
  5696. if (testError) {
  5697. self.fail(self.test, testError);
  5698. }
  5699. // conditional skip
  5700. if (hook.pending) {
  5701. if (name === HOOK_TYPE_AFTER_EACH) {
  5702. // TODO define and implement use case
  5703. if (self.test) {
  5704. self.test.pending = true;
  5705. }
  5706. } else if (name === HOOK_TYPE_BEFORE_EACH) {
  5707. if (self.test) {
  5708. self.test.pending = true;
  5709. }
  5710. self.emit(constants.EVENT_HOOK_END, hook);
  5711. hook.pending = false; // activates hook for next test
  5712. return fn(new Error('abort hookDown'));
  5713. } else if (name === HOOK_TYPE_BEFORE_ALL) {
  5714. suite.tests.forEach(function(test) {
  5715. test.pending = true;
  5716. });
  5717. suite.suites.forEach(function(suite) {
  5718. suite.pending = true;
  5719. });
  5720. } else {
  5721. hook.pending = false;
  5722. var errForbid = createUnsupportedError('`this.skip` forbidden');
  5723. self.failHook(hook, errForbid);
  5724. return fn(errForbid);
  5725. }
  5726. } else if (err) {
  5727. self.failHook(hook, err);
  5728. // stop executing hooks, notify callee of hook err
  5729. return fn(err);
  5730. }
  5731. self.emit(constants.EVENT_HOOK_END, hook);
  5732. delete hook.ctx.currentTest;
  5733. next(++i);
  5734. });
  5735. }
  5736. Runner.immediately(function() {
  5737. next(0);
  5738. });
  5739. };
  5740. /**
  5741. * Run hook `name` for the given array of `suites`
  5742. * in order, and callback `fn(err, errSuite)`.
  5743. *
  5744. * @private
  5745. * @param {string} name
  5746. * @param {Array} suites
  5747. * @param {Function} fn
  5748. */
  5749. Runner.prototype.hooks = function(name, suites, fn) {
  5750. var self = this;
  5751. var orig = this.suite;
  5752. function next(suite) {
  5753. self.suite = suite;
  5754. if (!suite) {
  5755. self.suite = orig;
  5756. return fn();
  5757. }
  5758. self.hook(name, function(err) {
  5759. if (err) {
  5760. var errSuite = self.suite;
  5761. self.suite = orig;
  5762. return fn(err, errSuite);
  5763. }
  5764. next(suites.pop());
  5765. });
  5766. }
  5767. next(suites.pop());
  5768. };
  5769. /**
  5770. * Run hooks from the top level down.
  5771. *
  5772. * @param {String} name
  5773. * @param {Function} fn
  5774. * @private
  5775. */
  5776. Runner.prototype.hookUp = function(name, fn) {
  5777. var suites = [this.suite].concat(this.parents()).reverse();
  5778. this.hooks(name, suites, fn);
  5779. };
  5780. /**
  5781. * Run hooks from the bottom up.
  5782. *
  5783. * @param {String} name
  5784. * @param {Function} fn
  5785. * @private
  5786. */
  5787. Runner.prototype.hookDown = function(name, fn) {
  5788. var suites = [this.suite].concat(this.parents());
  5789. this.hooks(name, suites, fn);
  5790. };
  5791. /**
  5792. * Return an array of parent Suites from
  5793. * closest to furthest.
  5794. *
  5795. * @return {Array}
  5796. * @private
  5797. */
  5798. Runner.prototype.parents = function() {
  5799. var suite = this.suite;
  5800. var suites = [];
  5801. while (suite.parent) {
  5802. suite = suite.parent;
  5803. suites.push(suite);
  5804. }
  5805. return suites;
  5806. };
  5807. /**
  5808. * Run the current test and callback `fn(err)`.
  5809. *
  5810. * @param {Function} fn
  5811. * @private
  5812. */
  5813. Runner.prototype.runTest = function(fn) {
  5814. var self = this;
  5815. var test = this.test;
  5816. if (!test) {
  5817. return;
  5818. }
  5819. if (this.asyncOnly) {
  5820. test.asyncOnly = true;
  5821. }
  5822. this._addEventListener(test, 'error', function(err) {
  5823. self.fail(test, err);
  5824. });
  5825. if (this.allowUncaught) {
  5826. test.allowUncaught = true;
  5827. return test.run(fn);
  5828. }
  5829. try {
  5830. test.run(fn);
  5831. } catch (err) {
  5832. fn(err);
  5833. }
  5834. };
  5835. /**
  5836. * Run tests in the given `suite` and invoke the callback `fn()` when complete.
  5837. *
  5838. * @private
  5839. * @param {Suite} suite
  5840. * @param {Function} fn
  5841. */
  5842. Runner.prototype.runTests = function(suite, fn) {
  5843. var self = this;
  5844. var tests = suite.tests.slice();
  5845. var test;
  5846. function hookErr(_, errSuite, after) {
  5847. // before/after Each hook for errSuite failed:
  5848. var orig = self.suite;
  5849. // for failed 'after each' hook start from errSuite parent,
  5850. // otherwise start from errSuite itself
  5851. self.suite = after ? errSuite.parent : errSuite;
  5852. if (self.suite) {
  5853. // call hookUp afterEach
  5854. self.hookUp(HOOK_TYPE_AFTER_EACH, function(err2, errSuite2) {
  5855. self.suite = orig;
  5856. // some hooks may fail even now
  5857. if (err2) {
  5858. return hookErr(err2, errSuite2, true);
  5859. }
  5860. // report error suite
  5861. fn(errSuite);
  5862. });
  5863. } else {
  5864. // there is no need calling other 'after each' hooks
  5865. self.suite = orig;
  5866. fn(errSuite);
  5867. }
  5868. }
  5869. function next(err, errSuite) {
  5870. // if we bail after first err
  5871. if (self.failures && suite._bail) {
  5872. tests = [];
  5873. }
  5874. if (self._abort) {
  5875. return fn();
  5876. }
  5877. if (err) {
  5878. return hookErr(err, errSuite, true);
  5879. }
  5880. // next test
  5881. test = tests.shift();
  5882. // all done
  5883. if (!test) {
  5884. return fn();
  5885. }
  5886. // grep
  5887. var match = self._grep.test(test.fullTitle());
  5888. if (self._invert) {
  5889. match = !match;
  5890. }
  5891. if (!match) {
  5892. // Run immediately only if we have defined a grep. When we
  5893. // define a grep — It can cause maximum callstack error if
  5894. // the grep is doing a large recursive loop by neglecting
  5895. // all tests. The run immediately function also comes with
  5896. // a performance cost. So we don't want to run immediately
  5897. // if we run the whole test suite, because running the whole
  5898. // test suite don't do any immediate recursive loops. Thus,
  5899. // allowing a JS runtime to breathe.
  5900. if (self._grep !== self._defaultGrep) {
  5901. Runner.immediately(next);
  5902. } else {
  5903. next();
  5904. }
  5905. return;
  5906. }
  5907. // static skip, no hooks are executed
  5908. if (test.isPending()) {
  5909. if (self.forbidPending) {
  5910. test.isPending = alwaysFalse;
  5911. self.fail(test, new Error('Pending test forbidden'));
  5912. delete test.isPending;
  5913. } else {
  5914. self.emit(constants.EVENT_TEST_PENDING, test);
  5915. }
  5916. self.emit(constants.EVENT_TEST_END, test);
  5917. return next();
  5918. }
  5919. // execute test and hook(s)
  5920. self.emit(constants.EVENT_TEST_BEGIN, (self.test = test));
  5921. self.hookDown(HOOK_TYPE_BEFORE_EACH, function(err, errSuite) {
  5922. // conditional skip within beforeEach
  5923. if (test.isPending()) {
  5924. if (self.forbidPending) {
  5925. test.isPending = alwaysFalse;
  5926. self.fail(test, new Error('Pending test forbidden'));
  5927. delete test.isPending;
  5928. } else {
  5929. self.emit(constants.EVENT_TEST_PENDING, test);
  5930. }
  5931. self.emit(constants.EVENT_TEST_END, test);
  5932. // skip inner afterEach hooks below errSuite level
  5933. var origSuite = self.suite;
  5934. self.suite = errSuite || self.suite;
  5935. return self.hookUp(HOOK_TYPE_AFTER_EACH, function(e, eSuite) {
  5936. self.suite = origSuite;
  5937. next(e, eSuite);
  5938. });
  5939. }
  5940. if (err) {
  5941. return hookErr(err, errSuite, false);
  5942. }
  5943. self.currentRunnable = self.test;
  5944. self.runTest(function(err) {
  5945. test = self.test;
  5946. // conditional skip within it
  5947. if (test.pending) {
  5948. if (self.forbidPending) {
  5949. test.isPending = alwaysFalse;
  5950. self.fail(test, new Error('Pending test forbidden'));
  5951. delete test.isPending;
  5952. } else {
  5953. self.emit(constants.EVENT_TEST_PENDING, test);
  5954. }
  5955. self.emit(constants.EVENT_TEST_END, test);
  5956. return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
  5957. } else if (err) {
  5958. var retry = test.currentRetry();
  5959. if (retry < test.retries()) {
  5960. var clonedTest = test.clone();
  5961. clonedTest.currentRetry(retry + 1);
  5962. tests.unshift(clonedTest);
  5963. self.emit(constants.EVENT_TEST_RETRY, test, err);
  5964. // Early return + hook trigger so that it doesn't
  5965. // increment the count wrong
  5966. return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
  5967. } else {
  5968. self.fail(test, err);
  5969. }
  5970. self.emit(constants.EVENT_TEST_END, test);
  5971. return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
  5972. }
  5973. test.state = STATE_PASSED;
  5974. self.emit(constants.EVENT_TEST_PASS, test);
  5975. self.emit(constants.EVENT_TEST_END, test);
  5976. self.hookUp(HOOK_TYPE_AFTER_EACH, next);
  5977. });
  5978. });
  5979. }
  5980. this.next = next;
  5981. this.hookErr = hookErr;
  5982. next();
  5983. };
  5984. function alwaysFalse() {
  5985. return false;
  5986. }
  5987. /**
  5988. * Run the given `suite` and invoke the callback `fn()` when complete.
  5989. *
  5990. * @private
  5991. * @param {Suite} suite
  5992. * @param {Function} fn
  5993. */
  5994. Runner.prototype.runSuite = function(suite, fn) {
  5995. var i = 0;
  5996. var self = this;
  5997. var total = this.grepTotal(suite);
  5998. debug('runSuite(): running %s', suite.fullTitle());
  5999. if (!total || (self.failures && suite._bail)) {
  6000. debug('runSuite(): bailing');
  6001. return fn();
  6002. }
  6003. this.emit(constants.EVENT_SUITE_BEGIN, (this.suite = suite));
  6004. function next(errSuite) {
  6005. if (errSuite) {
  6006. // current suite failed on a hook from errSuite
  6007. if (errSuite === suite) {
  6008. // if errSuite is current suite
  6009. // continue to the next sibling suite
  6010. return done();
  6011. }
  6012. // errSuite is among the parents of current suite
  6013. // stop execution of errSuite and all sub-suites
  6014. return done(errSuite);
  6015. }
  6016. if (self._abort) {
  6017. return done();
  6018. }
  6019. var curr = suite.suites[i++];
  6020. if (!curr) {
  6021. return done();
  6022. }
  6023. // Avoid grep neglecting large number of tests causing a
  6024. // huge recursive loop and thus a maximum call stack error.
  6025. // See comment in `this.runTests()` for more information.
  6026. if (self._grep !== self._defaultGrep) {
  6027. Runner.immediately(function() {
  6028. self.runSuite(curr, next);
  6029. });
  6030. } else {
  6031. self.runSuite(curr, next);
  6032. }
  6033. }
  6034. function done(errSuite) {
  6035. self.suite = suite;
  6036. self.nextSuite = next;
  6037. // remove reference to test
  6038. delete self.test;
  6039. self.hook(HOOK_TYPE_AFTER_ALL, function() {
  6040. self.emit(constants.EVENT_SUITE_END, suite);
  6041. fn(errSuite);
  6042. });
  6043. }
  6044. this.nextSuite = next;
  6045. this.hook(HOOK_TYPE_BEFORE_ALL, function(err) {
  6046. if (err) {
  6047. return done();
  6048. }
  6049. self.runTests(suite, next);
  6050. });
  6051. };
  6052. /**
  6053. * Handle uncaught exceptions within runner.
  6054. *
  6055. * This function is bound to the instance as `Runner#uncaught` at instantiation
  6056. * time. It's intended to be listening on the `Process.uncaughtException` event.
  6057. * In order to not leak EE listeners, we need to ensure no more than a single
  6058. * `uncaughtException` listener exists per `Runner`. The only way to do
  6059. * this--because this function needs the context (and we don't have lambdas)--is
  6060. * to use `Function.prototype.bind`. We need strict equality to unregister and
  6061. * _only_ unregister the _one_ listener we set from the
  6062. * `Process.uncaughtException` event; would be poor form to just remove
  6063. * everything. See {@link Runner#run} for where the event listener is registered
  6064. * and unregistered.
  6065. * @param {Error} err - Some uncaught error
  6066. * @private
  6067. */
  6068. Runner.prototype._uncaught = function(err) {
  6069. // this is defensive to prevent future developers from mis-calling this function.
  6070. // it's more likely that it'd be called with the incorrect context--say, the global
  6071. // `process` object--than it would to be called with a context that is not a "subclass"
  6072. // of `Runner`.
  6073. if (!(this instanceof Runner)) {
  6074. throw createFatalError(
  6075. 'Runner#uncaught() called with invalid context',
  6076. this
  6077. );
  6078. }
  6079. if (err instanceof Pending) {
  6080. debug('uncaught(): caught a Pending');
  6081. return;
  6082. }
  6083. // browser does not exit script when throwing in global.onerror()
  6084. if (this.allowUncaught && !process.browser) {
  6085. debug('uncaught(): bubbling exception due to --allow-uncaught');
  6086. throw err;
  6087. }
  6088. if (this.state === constants.STATE_STOPPED) {
  6089. debug('uncaught(): throwing after run has completed!');
  6090. throw err;
  6091. }
  6092. if (err) {
  6093. debug('uncaught(): got truthy exception %O', err);
  6094. } else {
  6095. debug('uncaught(): undefined/falsy exception');
  6096. err = createInvalidExceptionError(
  6097. 'Caught falsy/undefined exception which would otherwise be uncaught. No stack trace found; try a debugger',
  6098. err
  6099. );
  6100. }
  6101. if (!isError(err)) {
  6102. err = thrown2Error(err);
  6103. debug('uncaught(): converted "error" %o to Error', err);
  6104. }
  6105. err.uncaught = true;
  6106. var runnable = this.currentRunnable;
  6107. if (!runnable) {
  6108. runnable = new Runnable('Uncaught error outside test suite');
  6109. debug('uncaught(): no current Runnable; created a phony one');
  6110. runnable.parent = this.suite;
  6111. if (this.state === constants.STATE_RUNNING) {
  6112. debug('uncaught(): failing gracefully');
  6113. this.fail(runnable, err);
  6114. } else {
  6115. // Can't recover from this failure
  6116. debug('uncaught(): test run has not yet started; unrecoverable');
  6117. this.emit(constants.EVENT_RUN_BEGIN);
  6118. this.fail(runnable, err);
  6119. this.emit(constants.EVENT_RUN_END);
  6120. }
  6121. return;
  6122. }
  6123. runnable.clearTimeout();
  6124. if (runnable.isFailed()) {
  6125. debug('uncaught(): Runnable has already failed');
  6126. // Ignore error if already failed
  6127. return;
  6128. } else if (runnable.isPending()) {
  6129. debug('uncaught(): pending Runnable wound up failing!');
  6130. // report 'pending test' retrospectively as failed
  6131. runnable.isPending = alwaysFalse;
  6132. this.fail(runnable, err);
  6133. delete runnable.isPending;
  6134. return;
  6135. }
  6136. // we cannot recover gracefully if a Runnable has already passed
  6137. // then fails asynchronously
  6138. if (runnable.isPassed()) {
  6139. debug('uncaught(): Runnable has already passed; bailing gracefully');
  6140. this.fail(runnable, err);
  6141. this.abort();
  6142. } else {
  6143. debug('uncaught(): forcing Runnable to complete with Error');
  6144. return runnable.callback(err);
  6145. }
  6146. };
  6147. /**
  6148. * Run the root suite and invoke `fn(failures)`
  6149. * on completion.
  6150. *
  6151. * @public
  6152. * @memberof Runner
  6153. * @param {Function} fn
  6154. * @return {Runner} Runner instance.
  6155. */
  6156. Runner.prototype.run = function(fn) {
  6157. var self = this;
  6158. var rootSuite = this.suite;
  6159. fn = fn || function() {};
  6160. function start() {
  6161. debug('run(): starting');
  6162. // If there is an `only` filter
  6163. if (rootSuite.hasOnly()) {
  6164. rootSuite.filterOnly();
  6165. debug('run(): filtered exclusive Runnables');
  6166. }
  6167. self.state = constants.STATE_RUNNING;
  6168. if (self._delay) {
  6169. self.emit(constants.EVENT_DELAY_END);
  6170. debug('run(): "delay" ended');
  6171. }
  6172. debug('run(): emitting %s', constants.EVENT_RUN_BEGIN);
  6173. self.emit(constants.EVENT_RUN_BEGIN);
  6174. debug('run(): emitted %s', constants.EVENT_RUN_BEGIN);
  6175. self.runSuite(rootSuite, function() {
  6176. debug(
  6177. 'run(): root suite completed; emitting %s',
  6178. constants.EVENT_RUN_END
  6179. );
  6180. self.emit(constants.EVENT_RUN_END);
  6181. debug('run(): emitted %s', constants.EVENT_RUN_END);
  6182. });
  6183. }
  6184. // references cleanup to avoid memory leaks
  6185. if (this._opts.cleanReferencesAfterRun) {
  6186. this.on(constants.EVENT_SUITE_END, function(suite) {
  6187. suite.cleanReferences();
  6188. });
  6189. }
  6190. // callback
  6191. this.on(constants.EVENT_RUN_END, function() {
  6192. self.state = constants.STATE_STOPPED;
  6193. debug(constants.EVENT_RUN_END);
  6194. debug('run(): emitted %s', constants.EVENT_RUN_END);
  6195. fn(self.failures);
  6196. });
  6197. self._removeEventListener(process, 'uncaughtException', self.uncaught);
  6198. self._addEventListener(process, 'uncaughtException', self.uncaught);
  6199. if (this._delay) {
  6200. // for reporters, I guess.
  6201. // might be nice to debounce some dots while we wait.
  6202. this.emit(constants.EVENT_DELAY_BEGIN, rootSuite);
  6203. rootSuite.once(EVENT_ROOT_SUITE_RUN, start);
  6204. debug('run(): waiting for green light due to --delay');
  6205. } else {
  6206. Runner.immediately(function() {
  6207. start();
  6208. });
  6209. }
  6210. return this;
  6211. };
  6212. /**
  6213. * Cleanly abort execution.
  6214. *
  6215. * @memberof Runner
  6216. * @public
  6217. * @return {Runner} Runner instance.
  6218. */
  6219. Runner.prototype.abort = function() {
  6220. debug('abort(): aborting');
  6221. this._abort = true;
  6222. return this;
  6223. };
  6224. /**
  6225. * Filter leaks with the given globals flagged as `ok`.
  6226. *
  6227. * @private
  6228. * @param {Array} ok
  6229. * @param {Array} globals
  6230. * @return {Array}
  6231. */
  6232. function filterLeaks(ok, globals) {
  6233. return globals.filter(function(key) {
  6234. // Firefox and Chrome exposes iframes as index inside the window object
  6235. if (/^\d+/.test(key)) {
  6236. return false;
  6237. }
  6238. // in firefox
  6239. // if runner runs in an iframe, this iframe's window.getInterface method
  6240. // not init at first it is assigned in some seconds
  6241. if (global.navigator && /^getInterface/.test(key)) {
  6242. return false;
  6243. }
  6244. // an iframe could be approached by window[iframeIndex]
  6245. // in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak
  6246. if (global.navigator && /^\d+/.test(key)) {
  6247. return false;
  6248. }
  6249. // Opera and IE expose global variables for HTML element IDs (issue #243)
  6250. if (/^mocha-/.test(key)) {
  6251. return false;
  6252. }
  6253. var matched = ok.filter(function(ok) {
  6254. if (~ok.indexOf('*')) {
  6255. return key.indexOf(ok.split('*')[0]) === 0;
  6256. }
  6257. return key === ok;
  6258. });
  6259. return !matched.length && (!global.navigator || key !== 'onerror');
  6260. });
  6261. }
  6262. /**
  6263. * Check if argument is an instance of Error object or a duck-typed equivalent.
  6264. *
  6265. * @private
  6266. * @param {Object} err - object to check
  6267. * @param {string} err.message - error message
  6268. * @returns {boolean}
  6269. */
  6270. function isError(err) {
  6271. return err instanceof Error || (err && typeof err.message === 'string');
  6272. }
  6273. /**
  6274. *
  6275. * Converts thrown non-extensible type into proper Error.
  6276. *
  6277. * @private
  6278. * @param {*} thrown - Non-extensible type thrown by code
  6279. * @return {Error}
  6280. */
  6281. function thrown2Error(err) {
  6282. return new Error(
  6283. 'the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)'
  6284. );
  6285. }
  6286. Runner.constants = constants;
  6287. /**
  6288. * Node.js' `EventEmitter`
  6289. * @external EventEmitter
  6290. * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter}
  6291. */
  6292. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  6293. },{"./errors":6,"./pending":16,"./runnable":33,"./suite":36,"./utils":38,"_process":69,"debug":45,"events":50,"util":89}],35:[function(require,module,exports){
  6294. (function (global){
  6295. 'use strict';
  6296. /**
  6297. * Provides a factory function for a {@link StatsCollector} object.
  6298. * @module
  6299. */
  6300. var constants = require('./runner').constants;
  6301. var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
  6302. var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
  6303. var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
  6304. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  6305. var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
  6306. var EVENT_RUN_END = constants.EVENT_RUN_END;
  6307. var EVENT_TEST_END = constants.EVENT_TEST_END;
  6308. /**
  6309. * Test statistics collector.
  6310. *
  6311. * @public
  6312. * @typedef {Object} StatsCollector
  6313. * @property {number} suites - integer count of suites run.
  6314. * @property {number} tests - integer count of tests run.
  6315. * @property {number} passes - integer count of passing tests.
  6316. * @property {number} pending - integer count of pending tests.
  6317. * @property {number} failures - integer count of failed tests.
  6318. * @property {Date} start - time when testing began.
  6319. * @property {Date} end - time when testing concluded.
  6320. * @property {number} duration - number of msecs that testing took.
  6321. */
  6322. var Date = global.Date;
  6323. /**
  6324. * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`.
  6325. *
  6326. * @private
  6327. * @param {Runner} runner - Runner instance
  6328. * @throws {TypeError} If falsy `runner`
  6329. */
  6330. function createStatsCollector(runner) {
  6331. /**
  6332. * @type StatsCollector
  6333. */
  6334. var stats = {
  6335. suites: 0,
  6336. tests: 0,
  6337. passes: 0,
  6338. pending: 0,
  6339. failures: 0
  6340. };
  6341. if (!runner) {
  6342. throw new TypeError('Missing runner argument');
  6343. }
  6344. runner.stats = stats;
  6345. runner.once(EVENT_RUN_BEGIN, function() {
  6346. stats.start = new Date();
  6347. });
  6348. runner.on(EVENT_SUITE_BEGIN, function(suite) {
  6349. suite.root || stats.suites++;
  6350. });
  6351. runner.on(EVENT_TEST_PASS, function() {
  6352. stats.passes++;
  6353. });
  6354. runner.on(EVENT_TEST_FAIL, function() {
  6355. stats.failures++;
  6356. });
  6357. runner.on(EVENT_TEST_PENDING, function() {
  6358. stats.pending++;
  6359. });
  6360. runner.on(EVENT_TEST_END, function() {
  6361. stats.tests++;
  6362. });
  6363. runner.once(EVENT_RUN_END, function() {
  6364. stats.end = new Date();
  6365. stats.duration = stats.end - stats.start;
  6366. });
  6367. }
  6368. module.exports = createStatsCollector;
  6369. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  6370. },{"./runner":34}],36:[function(require,module,exports){
  6371. 'use strict';
  6372. /**
  6373. * Module dependencies.
  6374. */
  6375. var EventEmitter = require('events').EventEmitter;
  6376. var Hook = require('./hook');
  6377. var utils = require('./utils');
  6378. var inherits = utils.inherits;
  6379. var debug = require('debug')('mocha:suite');
  6380. var milliseconds = require('ms');
  6381. var errors = require('./errors');
  6382. var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError;
  6383. /**
  6384. * Expose `Suite`.
  6385. */
  6386. exports = module.exports = Suite;
  6387. /**
  6388. * Create a new `Suite` with the given `title` and parent `Suite`.
  6389. *
  6390. * @public
  6391. * @param {Suite} parent - Parent suite (required!)
  6392. * @param {string} title - Title
  6393. * @return {Suite}
  6394. */
  6395. Suite.create = function(parent, title) {
  6396. var suite = new Suite(title, parent.ctx);
  6397. suite.parent = parent;
  6398. title = suite.fullTitle();
  6399. parent.addSuite(suite);
  6400. return suite;
  6401. };
  6402. /**
  6403. * Constructs a new `Suite` instance with the given `title`, `ctx`, and `isRoot`.
  6404. *
  6405. * @public
  6406. * @class
  6407. * @extends EventEmitter
  6408. * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter|EventEmitter}
  6409. * @param {string} title - Suite title.
  6410. * @param {Context} parentContext - Parent context instance.
  6411. * @param {boolean} [isRoot=false] - Whether this is the root suite.
  6412. */
  6413. function Suite(title, parentContext, isRoot) {
  6414. if (!utils.isString(title)) {
  6415. throw createInvalidArgumentTypeError(
  6416. 'Suite argument "title" must be a string. Received type "' +
  6417. typeof title +
  6418. '"',
  6419. 'title',
  6420. 'string'
  6421. );
  6422. }
  6423. this.title = title;
  6424. function Context() {}
  6425. Context.prototype = parentContext;
  6426. this.ctx = new Context();
  6427. this.suites = [];
  6428. this.tests = [];
  6429. this.root = isRoot === true;
  6430. this.pending = false;
  6431. this._retries = -1;
  6432. this._beforeEach = [];
  6433. this._beforeAll = [];
  6434. this._afterEach = [];
  6435. this._afterAll = [];
  6436. this._timeout = 2000;
  6437. this._enableTimeouts = true;
  6438. this._slow = 75;
  6439. this._bail = false;
  6440. this._onlyTests = [];
  6441. this._onlySuites = [];
  6442. this.reset();
  6443. this.on('newListener', function(event) {
  6444. if (deprecatedEvents[event]) {
  6445. utils.deprecate(
  6446. 'Event "' +
  6447. event +
  6448. '" is deprecated. Please let the Mocha team know about your use case: https://git.io/v6Lwm'
  6449. );
  6450. }
  6451. });
  6452. }
  6453. /**
  6454. * Inherit from `EventEmitter.prototype`.
  6455. */
  6456. inherits(Suite, EventEmitter);
  6457. /**
  6458. * Resets the state initially or for a next run.
  6459. */
  6460. Suite.prototype.reset = function() {
  6461. this.delayed = false;
  6462. function doReset(thingToReset) {
  6463. thingToReset.reset();
  6464. }
  6465. this.suites.forEach(doReset);
  6466. this.tests.forEach(doReset);
  6467. this._beforeEach.forEach(doReset);
  6468. this._afterEach.forEach(doReset);
  6469. this._beforeAll.forEach(doReset);
  6470. this._afterAll.forEach(doReset);
  6471. };
  6472. /**
  6473. * Return a clone of this `Suite`.
  6474. *
  6475. * @private
  6476. * @return {Suite}
  6477. */
  6478. Suite.prototype.clone = function() {
  6479. var suite = new Suite(this.title);
  6480. debug('clone');
  6481. suite.ctx = this.ctx;
  6482. suite.root = this.root;
  6483. suite.timeout(this.timeout());
  6484. suite.retries(this.retries());
  6485. suite.enableTimeouts(this.enableTimeouts());
  6486. suite.slow(this.slow());
  6487. suite.bail(this.bail());
  6488. return suite;
  6489. };
  6490. /**
  6491. * Set or get timeout `ms` or short-hand such as "2s".
  6492. *
  6493. * @private
  6494. * @todo Do not attempt to set value if `ms` is undefined
  6495. * @param {number|string} ms
  6496. * @return {Suite|number} for chaining
  6497. */
  6498. Suite.prototype.timeout = function(ms) {
  6499. if (!arguments.length) {
  6500. return this._timeout;
  6501. }
  6502. if (ms.toString() === '0') {
  6503. this._enableTimeouts = false;
  6504. }
  6505. if (typeof ms === 'string') {
  6506. ms = milliseconds(ms);
  6507. }
  6508. debug('timeout %d', ms);
  6509. this._timeout = parseInt(ms, 10);
  6510. return this;
  6511. };
  6512. /**
  6513. * Set or get number of times to retry a failed test.
  6514. *
  6515. * @private
  6516. * @param {number|string} n
  6517. * @return {Suite|number} for chaining
  6518. */
  6519. Suite.prototype.retries = function(n) {
  6520. if (!arguments.length) {
  6521. return this._retries;
  6522. }
  6523. debug('retries %d', n);
  6524. this._retries = parseInt(n, 10) || 0;
  6525. return this;
  6526. };
  6527. /**
  6528. * Set or get timeout to `enabled`.
  6529. *
  6530. * @private
  6531. * @param {boolean} enabled
  6532. * @return {Suite|boolean} self or enabled
  6533. */
  6534. Suite.prototype.enableTimeouts = function(enabled) {
  6535. if (!arguments.length) {
  6536. return this._enableTimeouts;
  6537. }
  6538. debug('enableTimeouts %s', enabled);
  6539. this._enableTimeouts = enabled;
  6540. return this;
  6541. };
  6542. /**
  6543. * Set or get slow `ms` or short-hand such as "2s".
  6544. *
  6545. * @private
  6546. * @param {number|string} ms
  6547. * @return {Suite|number} for chaining
  6548. */
  6549. Suite.prototype.slow = function(ms) {
  6550. if (!arguments.length) {
  6551. return this._slow;
  6552. }
  6553. if (typeof ms === 'string') {
  6554. ms = milliseconds(ms);
  6555. }
  6556. debug('slow %d', ms);
  6557. this._slow = ms;
  6558. return this;
  6559. };
  6560. /**
  6561. * Set or get whether to bail after first error.
  6562. *
  6563. * @private
  6564. * @param {boolean} bail
  6565. * @return {Suite|number} for chaining
  6566. */
  6567. Suite.prototype.bail = function(bail) {
  6568. if (!arguments.length) {
  6569. return this._bail;
  6570. }
  6571. debug('bail %s', bail);
  6572. this._bail = bail;
  6573. return this;
  6574. };
  6575. /**
  6576. * Check if this suite or its parent suite is marked as pending.
  6577. *
  6578. * @private
  6579. */
  6580. Suite.prototype.isPending = function() {
  6581. return this.pending || (this.parent && this.parent.isPending());
  6582. };
  6583. /**
  6584. * Generic hook-creator.
  6585. * @private
  6586. * @param {string} title - Title of hook
  6587. * @param {Function} fn - Hook callback
  6588. * @returns {Hook} A new hook
  6589. */
  6590. Suite.prototype._createHook = function(title, fn) {
  6591. var hook = new Hook(title, fn);
  6592. hook.parent = this;
  6593. hook.timeout(this.timeout());
  6594. hook.retries(this.retries());
  6595. hook.enableTimeouts(this.enableTimeouts());
  6596. hook.slow(this.slow());
  6597. hook.ctx = this.ctx;
  6598. hook.file = this.file;
  6599. return hook;
  6600. };
  6601. /**
  6602. * Run `fn(test[, done])` before running tests.
  6603. *
  6604. * @private
  6605. * @param {string} title
  6606. * @param {Function} fn
  6607. * @return {Suite} for chaining
  6608. */
  6609. Suite.prototype.beforeAll = function(title, fn) {
  6610. if (this.isPending()) {
  6611. return this;
  6612. }
  6613. if (typeof title === 'function') {
  6614. fn = title;
  6615. title = fn.name;
  6616. }
  6617. title = '"before all" hook' + (title ? ': ' + title : '');
  6618. var hook = this._createHook(title, fn);
  6619. this._beforeAll.push(hook);
  6620. this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_ALL, hook);
  6621. return this;
  6622. };
  6623. /**
  6624. * Run `fn(test[, done])` after running tests.
  6625. *
  6626. * @private
  6627. * @param {string} title
  6628. * @param {Function} fn
  6629. * @return {Suite} for chaining
  6630. */
  6631. Suite.prototype.afterAll = function(title, fn) {
  6632. if (this.isPending()) {
  6633. return this;
  6634. }
  6635. if (typeof title === 'function') {
  6636. fn = title;
  6637. title = fn.name;
  6638. }
  6639. title = '"after all" hook' + (title ? ': ' + title : '');
  6640. var hook = this._createHook(title, fn);
  6641. this._afterAll.push(hook);
  6642. this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_ALL, hook);
  6643. return this;
  6644. };
  6645. /**
  6646. * Run `fn(test[, done])` before each test case.
  6647. *
  6648. * @private
  6649. * @param {string} title
  6650. * @param {Function} fn
  6651. * @return {Suite} for chaining
  6652. */
  6653. Suite.prototype.beforeEach = function(title, fn) {
  6654. if (this.isPending()) {
  6655. return this;
  6656. }
  6657. if (typeof title === 'function') {
  6658. fn = title;
  6659. title = fn.name;
  6660. }
  6661. title = '"before each" hook' + (title ? ': ' + title : '');
  6662. var hook = this._createHook(title, fn);
  6663. this._beforeEach.push(hook);
  6664. this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_EACH, hook);
  6665. return this;
  6666. };
  6667. /**
  6668. * Run `fn(test[, done])` after each test case.
  6669. *
  6670. * @private
  6671. * @param {string} title
  6672. * @param {Function} fn
  6673. * @return {Suite} for chaining
  6674. */
  6675. Suite.prototype.afterEach = function(title, fn) {
  6676. if (this.isPending()) {
  6677. return this;
  6678. }
  6679. if (typeof title === 'function') {
  6680. fn = title;
  6681. title = fn.name;
  6682. }
  6683. title = '"after each" hook' + (title ? ': ' + title : '');
  6684. var hook = this._createHook(title, fn);
  6685. this._afterEach.push(hook);
  6686. this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_EACH, hook);
  6687. return this;
  6688. };
  6689. /**
  6690. * Add a test `suite`.
  6691. *
  6692. * @private
  6693. * @param {Suite} suite
  6694. * @return {Suite} for chaining
  6695. */
  6696. Suite.prototype.addSuite = function(suite) {
  6697. suite.parent = this;
  6698. suite.root = false;
  6699. suite.timeout(this.timeout());
  6700. suite.retries(this.retries());
  6701. suite.enableTimeouts(this.enableTimeouts());
  6702. suite.slow(this.slow());
  6703. suite.bail(this.bail());
  6704. this.suites.push(suite);
  6705. this.emit(constants.EVENT_SUITE_ADD_SUITE, suite);
  6706. return this;
  6707. };
  6708. /**
  6709. * Add a `test` to this suite.
  6710. *
  6711. * @private
  6712. * @param {Test} test
  6713. * @return {Suite} for chaining
  6714. */
  6715. Suite.prototype.addTest = function(test) {
  6716. test.parent = this;
  6717. test.timeout(this.timeout());
  6718. test.retries(this.retries());
  6719. test.enableTimeouts(this.enableTimeouts());
  6720. test.slow(this.slow());
  6721. test.ctx = this.ctx;
  6722. this.tests.push(test);
  6723. this.emit(constants.EVENT_SUITE_ADD_TEST, test);
  6724. return this;
  6725. };
  6726. /**
  6727. * Return the full title generated by recursively concatenating the parent's
  6728. * full title.
  6729. *
  6730. * @memberof Suite
  6731. * @public
  6732. * @return {string}
  6733. */
  6734. Suite.prototype.fullTitle = function() {
  6735. return this.titlePath().join(' ');
  6736. };
  6737. /**
  6738. * Return the title path generated by recursively concatenating the parent's
  6739. * title path.
  6740. *
  6741. * @memberof Suite
  6742. * @public
  6743. * @return {string}
  6744. */
  6745. Suite.prototype.titlePath = function() {
  6746. var result = [];
  6747. if (this.parent) {
  6748. result = result.concat(this.parent.titlePath());
  6749. }
  6750. if (!this.root) {
  6751. result.push(this.title);
  6752. }
  6753. return result;
  6754. };
  6755. /**
  6756. * Return the total number of tests.
  6757. *
  6758. * @memberof Suite
  6759. * @public
  6760. * @return {number}
  6761. */
  6762. Suite.prototype.total = function() {
  6763. return (
  6764. this.suites.reduce(function(sum, suite) {
  6765. return sum + suite.total();
  6766. }, 0) + this.tests.length
  6767. );
  6768. };
  6769. /**
  6770. * Iterates through each suite recursively to find all tests. Applies a
  6771. * function in the format `fn(test)`.
  6772. *
  6773. * @private
  6774. * @param {Function} fn
  6775. * @return {Suite}
  6776. */
  6777. Suite.prototype.eachTest = function(fn) {
  6778. this.tests.forEach(fn);
  6779. this.suites.forEach(function(suite) {
  6780. suite.eachTest(fn);
  6781. });
  6782. return this;
  6783. };
  6784. /**
  6785. * This will run the root suite if we happen to be running in delayed mode.
  6786. * @private
  6787. */
  6788. Suite.prototype.run = function run() {
  6789. if (this.root) {
  6790. this.emit(constants.EVENT_ROOT_SUITE_RUN);
  6791. }
  6792. };
  6793. /**
  6794. * Determines whether a suite has an `only` test or suite as a descendant.
  6795. *
  6796. * @private
  6797. * @returns {Boolean}
  6798. */
  6799. Suite.prototype.hasOnly = function hasOnly() {
  6800. return (
  6801. this._onlyTests.length > 0 ||
  6802. this._onlySuites.length > 0 ||
  6803. this.suites.some(function(suite) {
  6804. return suite.hasOnly();
  6805. })
  6806. );
  6807. };
  6808. /**
  6809. * Filter suites based on `isOnly` logic.
  6810. *
  6811. * @private
  6812. * @returns {Boolean}
  6813. */
  6814. Suite.prototype.filterOnly = function filterOnly() {
  6815. if (this._onlyTests.length) {
  6816. // If the suite contains `only` tests, run those and ignore any nested suites.
  6817. this.tests = this._onlyTests;
  6818. this.suites = [];
  6819. } else {
  6820. // Otherwise, do not run any of the tests in this suite.
  6821. this.tests = [];
  6822. this._onlySuites.forEach(function(onlySuite) {
  6823. // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.
  6824. // Otherwise, all of the tests on this `only` suite should be run, so don't filter it.
  6825. if (onlySuite.hasOnly()) {
  6826. onlySuite.filterOnly();
  6827. }
  6828. });
  6829. // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.
  6830. var onlySuites = this._onlySuites;
  6831. this.suites = this.suites.filter(function(childSuite) {
  6832. return onlySuites.indexOf(childSuite) !== -1 || childSuite.filterOnly();
  6833. });
  6834. }
  6835. // Keep the suite only if there is something to run
  6836. return this.tests.length > 0 || this.suites.length > 0;
  6837. };
  6838. /**
  6839. * Adds a suite to the list of subsuites marked `only`.
  6840. *
  6841. * @private
  6842. * @param {Suite} suite
  6843. */
  6844. Suite.prototype.appendOnlySuite = function(suite) {
  6845. this._onlySuites.push(suite);
  6846. };
  6847. /**
  6848. * Adds a test to the list of tests marked `only`.
  6849. *
  6850. * @private
  6851. * @param {Test} test
  6852. */
  6853. Suite.prototype.appendOnlyTest = function(test) {
  6854. this._onlyTests.push(test);
  6855. };
  6856. /**
  6857. * Returns the array of hooks by hook name; see `HOOK_TYPE_*` constants.
  6858. * @private
  6859. */
  6860. Suite.prototype.getHooks = function getHooks(name) {
  6861. return this['_' + name];
  6862. };
  6863. /**
  6864. * cleans all references from this suite and all child suites.
  6865. */
  6866. Suite.prototype.dispose = function() {
  6867. this.suites.forEach(function(suite) {
  6868. suite.dispose();
  6869. });
  6870. this.cleanReferences();
  6871. };
  6872. /**
  6873. * Cleans up the references to all the deferred functions
  6874. * (before/after/beforeEach/afterEach) and tests of a Suite.
  6875. * These must be deleted otherwise a memory leak can happen,
  6876. * as those functions may reference variables from closures,
  6877. * thus those variables can never be garbage collected as long
  6878. * as the deferred functions exist.
  6879. *
  6880. * @private
  6881. */
  6882. Suite.prototype.cleanReferences = function cleanReferences() {
  6883. function cleanArrReferences(arr) {
  6884. for (var i = 0; i < arr.length; i++) {
  6885. delete arr[i].fn;
  6886. }
  6887. }
  6888. if (Array.isArray(this._beforeAll)) {
  6889. cleanArrReferences(this._beforeAll);
  6890. }
  6891. if (Array.isArray(this._beforeEach)) {
  6892. cleanArrReferences(this._beforeEach);
  6893. }
  6894. if (Array.isArray(this._afterAll)) {
  6895. cleanArrReferences(this._afterAll);
  6896. }
  6897. if (Array.isArray(this._afterEach)) {
  6898. cleanArrReferences(this._afterEach);
  6899. }
  6900. for (var i = 0; i < this.tests.length; i++) {
  6901. delete this.tests[i].fn;
  6902. }
  6903. };
  6904. var constants = utils.defineConstants(
  6905. /**
  6906. * {@link Suite}-related constants.
  6907. * @public
  6908. * @memberof Suite
  6909. * @alias constants
  6910. * @readonly
  6911. * @static
  6912. * @enum {string}
  6913. */
  6914. {
  6915. /**
  6916. * Event emitted after a test file has been loaded Not emitted in browser.
  6917. */
  6918. EVENT_FILE_POST_REQUIRE: 'post-require',
  6919. /**
  6920. * Event emitted before a test file has been loaded. In browser, this is emitted once an interface has been selected.
  6921. */
  6922. EVENT_FILE_PRE_REQUIRE: 'pre-require',
  6923. /**
  6924. * Event emitted immediately after a test file has been loaded. Not emitted in browser.
  6925. */
  6926. EVENT_FILE_REQUIRE: 'require',
  6927. /**
  6928. * Event emitted when `global.run()` is called (use with `delay` option)
  6929. */
  6930. EVENT_ROOT_SUITE_RUN: 'run',
  6931. /**
  6932. * Namespace for collection of a `Suite`'s "after all" hooks
  6933. */
  6934. HOOK_TYPE_AFTER_ALL: 'afterAll',
  6935. /**
  6936. * Namespace for collection of a `Suite`'s "after each" hooks
  6937. */
  6938. HOOK_TYPE_AFTER_EACH: 'afterEach',
  6939. /**
  6940. * Namespace for collection of a `Suite`'s "before all" hooks
  6941. */
  6942. HOOK_TYPE_BEFORE_ALL: 'beforeAll',
  6943. /**
  6944. * Namespace for collection of a `Suite`'s "before all" hooks
  6945. */
  6946. HOOK_TYPE_BEFORE_EACH: 'beforeEach',
  6947. // the following events are all deprecated
  6948. /**
  6949. * Emitted after an "after all" `Hook` has been added to a `Suite`. Deprecated
  6950. */
  6951. EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll',
  6952. /**
  6953. * Emitted after an "after each" `Hook` has been added to a `Suite` Deprecated
  6954. */
  6955. EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach',
  6956. /**
  6957. * Emitted after an "before all" `Hook` has been added to a `Suite` Deprecated
  6958. */
  6959. EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll',
  6960. /**
  6961. * Emitted after an "before each" `Hook` has been added to a `Suite` Deprecated
  6962. */
  6963. EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach',
  6964. /**
  6965. * Emitted after a child `Suite` has been added to a `Suite`. Deprecated
  6966. */
  6967. EVENT_SUITE_ADD_SUITE: 'suite',
  6968. /**
  6969. * Emitted after a `Test` has been added to a `Suite`. Deprecated
  6970. */
  6971. EVENT_SUITE_ADD_TEST: 'test'
  6972. }
  6973. );
  6974. /**
  6975. * @summary There are no known use cases for these events.
  6976. * @desc This is a `Set`-like object having all keys being the constant's string value and the value being `true`.
  6977. * @todo Remove eventually
  6978. * @type {Object<string,boolean>}
  6979. * @ignore
  6980. */
  6981. var deprecatedEvents = Object.keys(constants)
  6982. .filter(function(constant) {
  6983. return constant.substring(0, 15) === 'EVENT_SUITE_ADD';
  6984. })
  6985. .reduce(function(acc, constant) {
  6986. acc[constants[constant]] = true;
  6987. return acc;
  6988. }, utils.createMap());
  6989. Suite.constants = constants;
  6990. },{"./errors":6,"./hook":7,"./utils":38,"debug":45,"events":50,"ms":60}],37:[function(require,module,exports){
  6991. 'use strict';
  6992. var Runnable = require('./runnable');
  6993. var utils = require('./utils');
  6994. var errors = require('./errors');
  6995. var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError;
  6996. var isString = utils.isString;
  6997. module.exports = Test;
  6998. /**
  6999. * Initialize a new `Test` with the given `title` and callback `fn`.
  7000. *
  7001. * @public
  7002. * @class
  7003. * @extends Runnable
  7004. * @param {String} title - Test title (required)
  7005. * @param {Function} [fn] - Test callback. If omitted, the Test is considered "pending"
  7006. */
  7007. function Test(title, fn) {
  7008. if (!isString(title)) {
  7009. throw createInvalidArgumentTypeError(
  7010. 'Test argument "title" should be a string. Received type "' +
  7011. typeof title +
  7012. '"',
  7013. 'title',
  7014. 'string'
  7015. );
  7016. }
  7017. this.type = 'test';
  7018. Runnable.call(this, title, fn);
  7019. this.reset();
  7020. }
  7021. /**
  7022. * Inherit from `Runnable.prototype`.
  7023. */
  7024. utils.inherits(Test, Runnable);
  7025. /**
  7026. * Resets the state initially or for a next run.
  7027. */
  7028. Test.prototype.reset = function() {
  7029. Runnable.prototype.reset.call(this);
  7030. this.pending = !this.fn;
  7031. delete this.state;
  7032. };
  7033. /**
  7034. * Set or get retried test
  7035. *
  7036. * @private
  7037. */
  7038. Test.prototype.retriedTest = function(n) {
  7039. if (!arguments.length) {
  7040. return this._retriedTest;
  7041. }
  7042. this._retriedTest = n;
  7043. };
  7044. /**
  7045. * Add test to the list of tests marked `only`.
  7046. *
  7047. * @private
  7048. */
  7049. Test.prototype.markOnly = function() {
  7050. this.parent.appendOnlyTest(this);
  7051. };
  7052. Test.prototype.clone = function() {
  7053. var test = new Test(this.title, this.fn);
  7054. test.timeout(this.timeout());
  7055. test.slow(this.slow());
  7056. test.enableTimeouts(this.enableTimeouts());
  7057. test.retries(this.retries());
  7058. test.currentRetry(this.currentRetry());
  7059. test.retriedTest(this.retriedTest() || this);
  7060. test.globals(this.globals());
  7061. test.parent = this.parent;
  7062. test.file = this.file;
  7063. test.ctx = this.ctx;
  7064. return test;
  7065. };
  7066. },{"./errors":6,"./runnable":33,"./utils":38}],38:[function(require,module,exports){
  7067. (function (process,Buffer){
  7068. 'use strict';
  7069. /**
  7070. * Various utility functions used throughout Mocha's codebase.
  7071. * @module utils
  7072. */
  7073. /**
  7074. * Module dependencies.
  7075. */
  7076. var fs = require('fs');
  7077. var path = require('path');
  7078. var util = require('util');
  7079. var glob = require('glob');
  7080. var he = require('he');
  7081. var errors = require('./errors');
  7082. var createNoFilesMatchPatternError = errors.createNoFilesMatchPatternError;
  7083. var createMissingArgumentError = errors.createMissingArgumentError;
  7084. var assign = (exports.assign = require('object.assign').getPolyfill());
  7085. /**
  7086. * Inherit the prototype methods from one constructor into another.
  7087. *
  7088. * @param {function} ctor - Constructor function which needs to inherit the
  7089. * prototype.
  7090. * @param {function} superCtor - Constructor function to inherit prototype from.
  7091. * @throws {TypeError} if either constructor is null, or if super constructor
  7092. * lacks a prototype.
  7093. */
  7094. exports.inherits = util.inherits;
  7095. /**
  7096. * Escape special characters in the given string of html.
  7097. *
  7098. * @private
  7099. * @param {string} html
  7100. * @return {string}
  7101. */
  7102. exports.escape = function(html) {
  7103. return he.encode(String(html), {useNamedReferences: false});
  7104. };
  7105. /**
  7106. * Test if the given obj is type of string.
  7107. *
  7108. * @private
  7109. * @param {Object} obj
  7110. * @return {boolean}
  7111. */
  7112. exports.isString = function(obj) {
  7113. return typeof obj === 'string';
  7114. };
  7115. /**
  7116. * Compute a slug from the given `str`.
  7117. *
  7118. * @private
  7119. * @param {string} str
  7120. * @return {string}
  7121. */
  7122. exports.slug = function(str) {
  7123. return str
  7124. .toLowerCase()
  7125. .replace(/\s+/g, '-')
  7126. .replace(/[^-\w]/g, '')
  7127. .replace(/-{2,}/g, '-');
  7128. };
  7129. /**
  7130. * Strip the function definition from `str`, and re-indent for pre whitespace.
  7131. *
  7132. * @param {string} str
  7133. * @return {string}
  7134. */
  7135. exports.clean = function(str) {
  7136. str = str
  7137. .replace(/\r\n?|[\n\u2028\u2029]/g, '\n')
  7138. .replace(/^\uFEFF/, '')
  7139. // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content
  7140. .replace(
  7141. /^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/,
  7142. '$1$2$3'
  7143. );
  7144. var spaces = str.match(/^\n?( *)/)[1].length;
  7145. var tabs = str.match(/^\n?(\t*)/)[1].length;
  7146. var re = new RegExp(
  7147. '^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}',
  7148. 'gm'
  7149. );
  7150. str = str.replace(re, '');
  7151. return str.trim();
  7152. };
  7153. /**
  7154. * Parse the given `qs`.
  7155. *
  7156. * @private
  7157. * @param {string} qs
  7158. * @return {Object}
  7159. */
  7160. exports.parseQuery = function(qs) {
  7161. return qs
  7162. .replace('?', '')
  7163. .split('&')
  7164. .reduce(function(obj, pair) {
  7165. var i = pair.indexOf('=');
  7166. var key = pair.slice(0, i);
  7167. var val = pair.slice(++i);
  7168. // Due to how the URLSearchParams API treats spaces
  7169. obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
  7170. return obj;
  7171. }, {});
  7172. };
  7173. /**
  7174. * Highlight the given string of `js`.
  7175. *
  7176. * @private
  7177. * @param {string} js
  7178. * @return {string}
  7179. */
  7180. function highlight(js) {
  7181. return js
  7182. .replace(/</g, '&lt;')
  7183. .replace(/>/g, '&gt;')
  7184. .replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
  7185. .replace(/('.*?')/gm, '<span class="string">$1</span>')
  7186. .replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
  7187. .replace(/(\d+)/gm, '<span class="number">$1</span>')
  7188. .replace(
  7189. /\bnew[ \t]+(\w+)/gm,
  7190. '<span class="keyword">new</span> <span class="init">$1</span>'
  7191. )
  7192. .replace(
  7193. /\b(function|new|throw|return|var|if|else)\b/gm,
  7194. '<span class="keyword">$1</span>'
  7195. );
  7196. }
  7197. /**
  7198. * Highlight the contents of tag `name`.
  7199. *
  7200. * @private
  7201. * @param {string} name
  7202. */
  7203. exports.highlightTags = function(name) {
  7204. var code = document.getElementById('mocha').getElementsByTagName(name);
  7205. for (var i = 0, len = code.length; i < len; ++i) {
  7206. code[i].innerHTML = highlight(code[i].innerHTML);
  7207. }
  7208. };
  7209. /**
  7210. * If a value could have properties, and has none, this function is called,
  7211. * which returns a string representation of the empty value.
  7212. *
  7213. * Functions w/ no properties return `'[Function]'`
  7214. * Arrays w/ length === 0 return `'[]'`
  7215. * Objects w/ no properties return `'{}'`
  7216. * All else: return result of `value.toString()`
  7217. *
  7218. * @private
  7219. * @param {*} value The value to inspect.
  7220. * @param {string} typeHint The type of the value
  7221. * @returns {string}
  7222. */
  7223. function emptyRepresentation(value, typeHint) {
  7224. switch (typeHint) {
  7225. case 'function':
  7226. return '[Function]';
  7227. case 'object':
  7228. return '{}';
  7229. case 'array':
  7230. return '[]';
  7231. default:
  7232. return value.toString();
  7233. }
  7234. }
  7235. /**
  7236. * Takes some variable and asks `Object.prototype.toString()` what it thinks it
  7237. * is.
  7238. *
  7239. * @private
  7240. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
  7241. * @param {*} value The value to test.
  7242. * @returns {string} Computed type
  7243. * @example
  7244. * type({}) // 'object'
  7245. * type([]) // 'array'
  7246. * type(1) // 'number'
  7247. * type(false) // 'boolean'
  7248. * type(Infinity) // 'number'
  7249. * type(null) // 'null'
  7250. * type(new Date()) // 'date'
  7251. * type(/foo/) // 'regexp'
  7252. * type('type') // 'string'
  7253. * type(global) // 'global'
  7254. * type(new String('foo') // 'object'
  7255. */
  7256. var type = (exports.type = function type(value) {
  7257. if (value === undefined) {
  7258. return 'undefined';
  7259. } else if (value === null) {
  7260. return 'null';
  7261. } else if (Buffer.isBuffer(value)) {
  7262. return 'buffer';
  7263. }
  7264. return Object.prototype.toString
  7265. .call(value)
  7266. .replace(/^\[.+\s(.+?)]$/, '$1')
  7267. .toLowerCase();
  7268. });
  7269. /**
  7270. * Stringify `value`. Different behavior depending on type of value:
  7271. *
  7272. * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
  7273. * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
  7274. * - If `value` is an *empty* object, function, or array, return result of function
  7275. * {@link emptyRepresentation}.
  7276. * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of
  7277. * JSON.stringify().
  7278. *
  7279. * @private
  7280. * @see exports.type
  7281. * @param {*} value
  7282. * @return {string}
  7283. */
  7284. exports.stringify = function(value) {
  7285. var typeHint = type(value);
  7286. if (!~['object', 'array', 'function'].indexOf(typeHint)) {
  7287. if (typeHint === 'buffer') {
  7288. var json = Buffer.prototype.toJSON.call(value);
  7289. // Based on the toJSON result
  7290. return jsonStringify(
  7291. json.data && json.type ? json.data : json,
  7292. 2
  7293. ).replace(/,(\n|$)/g, '$1');
  7294. }
  7295. // IE7/IE8 has a bizarre String constructor; needs to be coerced
  7296. // into an array and back to obj.
  7297. if (typeHint === 'string' && typeof value === 'object') {
  7298. value = value.split('').reduce(function(acc, char, idx) {
  7299. acc[idx] = char;
  7300. return acc;
  7301. }, {});
  7302. typeHint = 'object';
  7303. } else {
  7304. return jsonStringify(value);
  7305. }
  7306. }
  7307. for (var prop in value) {
  7308. if (Object.prototype.hasOwnProperty.call(value, prop)) {
  7309. return jsonStringify(
  7310. exports.canonicalize(value, null, typeHint),
  7311. 2
  7312. ).replace(/,(\n|$)/g, '$1');
  7313. }
  7314. }
  7315. return emptyRepresentation(value, typeHint);
  7316. };
  7317. /**
  7318. * like JSON.stringify but more sense.
  7319. *
  7320. * @private
  7321. * @param {Object} object
  7322. * @param {number=} spaces
  7323. * @param {number=} depth
  7324. * @returns {*}
  7325. */
  7326. function jsonStringify(object, spaces, depth) {
  7327. if (typeof spaces === 'undefined') {
  7328. // primitive types
  7329. return _stringify(object);
  7330. }
  7331. depth = depth || 1;
  7332. var space = spaces * depth;
  7333. var str = Array.isArray(object) ? '[' : '{';
  7334. var end = Array.isArray(object) ? ']' : '}';
  7335. var length =
  7336. typeof object.length === 'number'
  7337. ? object.length
  7338. : Object.keys(object).length;
  7339. // `.repeat()` polyfill
  7340. function repeat(s, n) {
  7341. return new Array(n).join(s);
  7342. }
  7343. function _stringify(val) {
  7344. switch (type(val)) {
  7345. case 'null':
  7346. case 'undefined':
  7347. val = '[' + val + ']';
  7348. break;
  7349. case 'array':
  7350. case 'object':
  7351. val = jsonStringify(val, spaces, depth + 1);
  7352. break;
  7353. case 'boolean':
  7354. case 'regexp':
  7355. case 'symbol':
  7356. case 'number':
  7357. val =
  7358. val === 0 && 1 / val === -Infinity // `-0`
  7359. ? '-0'
  7360. : val.toString();
  7361. break;
  7362. case 'date':
  7363. var sDate = isNaN(val.getTime()) ? val.toString() : val.toISOString();
  7364. val = '[Date: ' + sDate + ']';
  7365. break;
  7366. case 'buffer':
  7367. var json = val.toJSON();
  7368. // Based on the toJSON result
  7369. json = json.data && json.type ? json.data : json;
  7370. val = '[Buffer: ' + jsonStringify(json, 2, depth + 1) + ']';
  7371. break;
  7372. default:
  7373. val =
  7374. val === '[Function]' || val === '[Circular]'
  7375. ? val
  7376. : JSON.stringify(val); // string
  7377. }
  7378. return val;
  7379. }
  7380. for (var i in object) {
  7381. if (!Object.prototype.hasOwnProperty.call(object, i)) {
  7382. continue; // not my business
  7383. }
  7384. --length;
  7385. str +=
  7386. '\n ' +
  7387. repeat(' ', space) +
  7388. (Array.isArray(object) ? '' : '"' + i + '": ') + // key
  7389. _stringify(object[i]) + // value
  7390. (length ? ',' : ''); // comma
  7391. }
  7392. return (
  7393. str +
  7394. // [], {}
  7395. (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end)
  7396. );
  7397. }
  7398. /**
  7399. * Return a new Thing that has the keys in sorted order. Recursive.
  7400. *
  7401. * If the Thing...
  7402. * - has already been seen, return string `'[Circular]'`
  7403. * - is `undefined`, return string `'[undefined]'`
  7404. * - is `null`, return value `null`
  7405. * - is some other primitive, return the value
  7406. * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method
  7407. * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again.
  7408. * - is an empty `Array`, `Object`, or `Function`, return the result of calling `emptyRepresentation()`
  7409. *
  7410. * @private
  7411. * @see {@link exports.stringify}
  7412. * @param {*} value Thing to inspect. May or may not have properties.
  7413. * @param {Array} [stack=[]] Stack of seen values
  7414. * @param {string} [typeHint] Type hint
  7415. * @return {(Object|Array|Function|string|undefined)}
  7416. */
  7417. exports.canonicalize = function canonicalize(value, stack, typeHint) {
  7418. var canonicalizedObj;
  7419. /* eslint-disable no-unused-vars */
  7420. var prop;
  7421. /* eslint-enable no-unused-vars */
  7422. typeHint = typeHint || type(value);
  7423. function withStack(value, fn) {
  7424. stack.push(value);
  7425. fn();
  7426. stack.pop();
  7427. }
  7428. stack = stack || [];
  7429. if (stack.indexOf(value) !== -1) {
  7430. return '[Circular]';
  7431. }
  7432. switch (typeHint) {
  7433. case 'undefined':
  7434. case 'buffer':
  7435. case 'null':
  7436. canonicalizedObj = value;
  7437. break;
  7438. case 'array':
  7439. withStack(value, function() {
  7440. canonicalizedObj = value.map(function(item) {
  7441. return exports.canonicalize(item, stack);
  7442. });
  7443. });
  7444. break;
  7445. case 'function':
  7446. /* eslint-disable guard-for-in */
  7447. for (prop in value) {
  7448. canonicalizedObj = {};
  7449. break;
  7450. }
  7451. /* eslint-enable guard-for-in */
  7452. if (!canonicalizedObj) {
  7453. canonicalizedObj = emptyRepresentation(value, typeHint);
  7454. break;
  7455. }
  7456. /* falls through */
  7457. case 'object':
  7458. canonicalizedObj = canonicalizedObj || {};
  7459. withStack(value, function() {
  7460. Object.keys(value)
  7461. .sort()
  7462. .forEach(function(key) {
  7463. canonicalizedObj[key] = exports.canonicalize(value[key], stack);
  7464. });
  7465. });
  7466. break;
  7467. case 'date':
  7468. case 'number':
  7469. case 'regexp':
  7470. case 'boolean':
  7471. case 'symbol':
  7472. canonicalizedObj = value;
  7473. break;
  7474. default:
  7475. canonicalizedObj = value + '';
  7476. }
  7477. return canonicalizedObj;
  7478. };
  7479. /**
  7480. * Determines if pathname has a matching file extension.
  7481. *
  7482. * @private
  7483. * @param {string} pathname - Pathname to check for match.
  7484. * @param {string[]} exts - List of file extensions (sans period).
  7485. * @return {boolean} whether file extension matches.
  7486. * @example
  7487. * hasMatchingExtname('foo.html', ['js', 'css']); // => false
  7488. */
  7489. function hasMatchingExtname(pathname, exts) {
  7490. var suffix = path.extname(pathname).slice(1);
  7491. return exts.some(function(element) {
  7492. return suffix === element;
  7493. });
  7494. }
  7495. /**
  7496. * Determines if pathname would be a "hidden" file (or directory) on UN*X.
  7497. *
  7498. * @description
  7499. * On UN*X, pathnames beginning with a full stop (aka dot) are hidden during
  7500. * typical usage. Dotfiles, plain-text configuration files, are prime examples.
  7501. *
  7502. * @see {@link http://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_filename.html|Origin of Dot File Names}
  7503. *
  7504. * @private
  7505. * @param {string} pathname - Pathname to check for match.
  7506. * @return {boolean} whether pathname would be considered a hidden file.
  7507. * @example
  7508. * isHiddenOnUnix('.profile'); // => true
  7509. */
  7510. function isHiddenOnUnix(pathname) {
  7511. return path.basename(pathname)[0] === '.';
  7512. }
  7513. /**
  7514. * Lookup file names at the given `path`.
  7515. *
  7516. * @description
  7517. * Filenames are returned in _traversal_ order by the OS/filesystem.
  7518. * **Make no assumption that the names will be sorted in any fashion.**
  7519. *
  7520. * @public
  7521. * @memberof Mocha.utils
  7522. * @param {string} filepath - Base path to start searching from.
  7523. * @param {string[]} [extensions=[]] - File extensions to look for.
  7524. * @param {boolean} [recursive=false] - Whether to recurse into subdirectories.
  7525. * @return {string[]} An array of paths.
  7526. * @throws {Error} if no files match pattern.
  7527. * @throws {TypeError} if `filepath` is directory and `extensions` not provided.
  7528. */
  7529. exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {
  7530. extensions = extensions || [];
  7531. recursive = recursive || false;
  7532. var files = [];
  7533. var stat;
  7534. if (!fs.existsSync(filepath)) {
  7535. var pattern;
  7536. if (glob.hasMagic(filepath)) {
  7537. // Handle glob as is without extensions
  7538. pattern = filepath;
  7539. } else {
  7540. // glob pattern e.g. 'filepath+(.js|.ts)'
  7541. var strExtensions = extensions
  7542. .map(function(v) {
  7543. return '.' + v;
  7544. })
  7545. .join('|');
  7546. pattern = filepath + '+(' + strExtensions + ')';
  7547. }
  7548. files = glob.sync(pattern, {nodir: true});
  7549. if (!files.length) {
  7550. throw createNoFilesMatchPatternError(
  7551. 'Cannot find any files matching pattern ' + exports.dQuote(filepath),
  7552. filepath
  7553. );
  7554. }
  7555. return files;
  7556. }
  7557. // Handle file
  7558. try {
  7559. stat = fs.statSync(filepath);
  7560. if (stat.isFile()) {
  7561. return filepath;
  7562. }
  7563. } catch (err) {
  7564. // ignore error
  7565. return;
  7566. }
  7567. // Handle directory
  7568. fs.readdirSync(filepath).forEach(function(dirent) {
  7569. var pathname = path.join(filepath, dirent);
  7570. var stat;
  7571. try {
  7572. stat = fs.statSync(pathname);
  7573. if (stat.isDirectory()) {
  7574. if (recursive) {
  7575. files = files.concat(lookupFiles(pathname, extensions, recursive));
  7576. }
  7577. return;
  7578. }
  7579. } catch (err) {
  7580. // ignore error
  7581. return;
  7582. }
  7583. if (!extensions.length) {
  7584. throw createMissingArgumentError(
  7585. util.format(
  7586. 'Argument %s required when argument %s is a directory',
  7587. exports.sQuote('extensions'),
  7588. exports.sQuote('filepath')
  7589. ),
  7590. 'extensions',
  7591. 'array'
  7592. );
  7593. }
  7594. if (
  7595. !stat.isFile() ||
  7596. !hasMatchingExtname(pathname, extensions) ||
  7597. isHiddenOnUnix(pathname)
  7598. ) {
  7599. return;
  7600. }
  7601. files.push(pathname);
  7602. });
  7603. return files;
  7604. };
  7605. /**
  7606. * process.emitWarning or a polyfill
  7607. * @see https://nodejs.org/api/process.html#process_process_emitwarning_warning_options
  7608. * @ignore
  7609. */
  7610. function emitWarning(msg, type) {
  7611. if (process.emitWarning) {
  7612. process.emitWarning(msg, type);
  7613. } else {
  7614. process.nextTick(function() {
  7615. console.warn(type + ': ' + msg);
  7616. });
  7617. }
  7618. }
  7619. /**
  7620. * Show a deprecation warning. Each distinct message is only displayed once.
  7621. * Ignores empty messages.
  7622. *
  7623. * @param {string} [msg] - Warning to print
  7624. * @private
  7625. */
  7626. exports.deprecate = function deprecate(msg) {
  7627. msg = String(msg);
  7628. if (msg && !deprecate.cache[msg]) {
  7629. deprecate.cache[msg] = true;
  7630. emitWarning(msg, 'DeprecationWarning');
  7631. }
  7632. };
  7633. exports.deprecate.cache = {};
  7634. /**
  7635. * Show a generic warning.
  7636. * Ignores empty messages.
  7637. *
  7638. * @param {string} [msg] - Warning to print
  7639. * @private
  7640. */
  7641. exports.warn = function warn(msg) {
  7642. if (msg) {
  7643. emitWarning(msg);
  7644. }
  7645. };
  7646. /**
  7647. * @summary
  7648. * This Filter based on `mocha-clean` module.(see: `github.com/rstacruz/mocha-clean`)
  7649. * @description
  7650. * When invoking this function you get a filter function that get the Error.stack as an input,
  7651. * and return a prettify output.
  7652. * (i.e: strip Mocha and internal node functions from stack trace).
  7653. * @returns {Function}
  7654. */
  7655. exports.stackTraceFilter = function() {
  7656. // TODO: Replace with `process.browser`
  7657. var is = typeof document === 'undefined' ? {node: true} : {browser: true};
  7658. var slash = path.sep;
  7659. var cwd;
  7660. if (is.node) {
  7661. cwd = exports.cwd() + slash;
  7662. } else {
  7663. cwd = (typeof location === 'undefined'
  7664. ? window.location
  7665. : location
  7666. ).href.replace(/\/[^/]*$/, '/');
  7667. slash = '/';
  7668. }
  7669. function isMochaInternal(line) {
  7670. return (
  7671. ~line.indexOf('node_modules' + slash + 'mocha' + slash) ||
  7672. ~line.indexOf(slash + 'mocha.js') ||
  7673. ~line.indexOf(slash + 'mocha.min.js')
  7674. );
  7675. }
  7676. function isNodeInternal(line) {
  7677. return (
  7678. ~line.indexOf('(timers.js:') ||
  7679. ~line.indexOf('(events.js:') ||
  7680. ~line.indexOf('(node.js:') ||
  7681. ~line.indexOf('(module.js:') ||
  7682. ~line.indexOf('GeneratorFunctionPrototype.next (native)') ||
  7683. false
  7684. );
  7685. }
  7686. return function(stack) {
  7687. stack = stack.split('\n');
  7688. stack = stack.reduce(function(list, line) {
  7689. if (isMochaInternal(line)) {
  7690. return list;
  7691. }
  7692. if (is.node && isNodeInternal(line)) {
  7693. return list;
  7694. }
  7695. // Clean up cwd(absolute)
  7696. if (/:\d+:\d+\)?$/.test(line)) {
  7697. line = line.replace('(' + cwd, '(');
  7698. }
  7699. list.push(line);
  7700. return list;
  7701. }, []);
  7702. return stack.join('\n');
  7703. };
  7704. };
  7705. /**
  7706. * Crude, but effective.
  7707. * @public
  7708. * @param {*} value
  7709. * @returns {boolean} Whether or not `value` is a Promise
  7710. */
  7711. exports.isPromise = function isPromise(value) {
  7712. return (
  7713. typeof value === 'object' &&
  7714. value !== null &&
  7715. typeof value.then === 'function'
  7716. );
  7717. };
  7718. /**
  7719. * Clamps a numeric value to an inclusive range.
  7720. *
  7721. * @param {number} value - Value to be clamped.
  7722. * @param {numer[]} range - Two element array specifying [min, max] range.
  7723. * @returns {number} clamped value
  7724. */
  7725. exports.clamp = function clamp(value, range) {
  7726. return Math.min(Math.max(value, range[0]), range[1]);
  7727. };
  7728. /**
  7729. * Single quote text by combining with undirectional ASCII quotation marks.
  7730. *
  7731. * @description
  7732. * Provides a simple means of markup for quoting text to be used in output.
  7733. * Use this to quote names of variables, methods, and packages.
  7734. *
  7735. * <samp>package 'foo' cannot be found</samp>
  7736. *
  7737. * @private
  7738. * @param {string} str - Value to be quoted.
  7739. * @returns {string} quoted value
  7740. * @example
  7741. * sQuote('n') // => 'n'
  7742. */
  7743. exports.sQuote = function(str) {
  7744. return "'" + str + "'";
  7745. };
  7746. /**
  7747. * Double quote text by combining with undirectional ASCII quotation marks.
  7748. *
  7749. * @description
  7750. * Provides a simple means of markup for quoting text to be used in output.
  7751. * Use this to quote names of datatypes, classes, pathnames, and strings.
  7752. *
  7753. * <samp>argument 'value' must be "string" or "number"</samp>
  7754. *
  7755. * @private
  7756. * @param {string} str - Value to be quoted.
  7757. * @returns {string} quoted value
  7758. * @example
  7759. * dQuote('number') // => "number"
  7760. */
  7761. exports.dQuote = function(str) {
  7762. return '"' + str + '"';
  7763. };
  7764. /**
  7765. * It's a noop.
  7766. * @public
  7767. */
  7768. exports.noop = function() {};
  7769. /**
  7770. * Creates a map-like object.
  7771. *
  7772. * @description
  7773. * A "map" is an object with no prototype, for our purposes. In some cases
  7774. * this would be more appropriate than a `Map`, especially if your environment
  7775. * doesn't support it. Recommended for use in Mocha's public APIs.
  7776. *
  7777. * @public
  7778. * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|MDN:Map}
  7779. * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#Custom_and_Null_objects|MDN:Object.create - Custom objects}
  7780. * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign|MDN:Object.assign}
  7781. * @param {...*} [obj] - Arguments to `Object.assign()`.
  7782. * @returns {Object} An object with no prototype, having `...obj` properties
  7783. */
  7784. exports.createMap = function(obj) {
  7785. return assign.apply(
  7786. null,
  7787. [Object.create(null)].concat(Array.prototype.slice.call(arguments))
  7788. );
  7789. };
  7790. /**
  7791. * Creates a read-only map-like object.
  7792. *
  7793. * @description
  7794. * This differs from {@link module:utils.createMap createMap} only in that
  7795. * the argument must be non-empty, because the result is frozen.
  7796. *
  7797. * @see {@link module:utils.createMap createMap}
  7798. * @param {...*} [obj] - Arguments to `Object.assign()`.
  7799. * @returns {Object} A frozen object with no prototype, having `...obj` properties
  7800. * @throws {TypeError} if argument is not a non-empty object.
  7801. */
  7802. exports.defineConstants = function(obj) {
  7803. if (type(obj) !== 'object' || !Object.keys(obj).length) {
  7804. throw new TypeError('Invalid argument; expected a non-empty object');
  7805. }
  7806. return Object.freeze(exports.createMap(obj));
  7807. };
  7808. /**
  7809. * Whether current version of Node support ES modules
  7810. *
  7811. * @description
  7812. * Versions prior to 10 did not support ES Modules, and version 10 has an old incompatibile version of ESM.
  7813. * This function returns whether Node.JS has ES Module supports that is compatible with Mocha's needs,
  7814. * which is version >=12.11.
  7815. *
  7816. * @returns {Boolean} whether the current version of Node.JS supports ES Modules in a way that is compatible with Mocha
  7817. */
  7818. exports.supportsEsModules = function() {
  7819. if (!process.browser && process.versions && process.versions.node) {
  7820. var versionFields = process.versions.node.split('.');
  7821. var major = +versionFields[0];
  7822. var minor = +versionFields[1];
  7823. if (major >= 13 || (major === 12 && minor >= 11)) {
  7824. return true;
  7825. }
  7826. }
  7827. };
  7828. /**
  7829. * Returns current working directory
  7830. *
  7831. * Wrapper around `process.cwd()` for isolation
  7832. * @private
  7833. */
  7834. exports.cwd = function cwd() {
  7835. return process.cwd();
  7836. };
  7837. }).call(this,require('_process'),require("buffer").Buffer)
  7838. },{"./errors":6,"_process":69,"buffer":43,"fs":42,"glob":42,"he":54,"object.assign":65,"path":42,"util":89}],39:[function(require,module,exports){
  7839. 'use strict'
  7840. exports.byteLength = byteLength
  7841. exports.toByteArray = toByteArray
  7842. exports.fromByteArray = fromByteArray
  7843. var lookup = []
  7844. var revLookup = []
  7845. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  7846. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  7847. for (var i = 0, len = code.length; i < len; ++i) {
  7848. lookup[i] = code[i]
  7849. revLookup[code.charCodeAt(i)] = i
  7850. }
  7851. // Support decoding URL-safe base64 strings, as Node.js does.
  7852. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  7853. revLookup['-'.charCodeAt(0)] = 62
  7854. revLookup['_'.charCodeAt(0)] = 63
  7855. function getLens (b64) {
  7856. var len = b64.length
  7857. if (len % 4 > 0) {
  7858. throw new Error('Invalid string. Length must be a multiple of 4')
  7859. }
  7860. // Trim off extra bytes after placeholder bytes are found
  7861. // See: https://github.com/beatgammit/base64-js/issues/42
  7862. var validLen = b64.indexOf('=')
  7863. if (validLen === -1) validLen = len
  7864. var placeHoldersLen = validLen === len
  7865. ? 0
  7866. : 4 - (validLen % 4)
  7867. return [validLen, placeHoldersLen]
  7868. }
  7869. // base64 is 4/3 + up to two characters of the original data
  7870. function byteLength (b64) {
  7871. var lens = getLens(b64)
  7872. var validLen = lens[0]
  7873. var placeHoldersLen = lens[1]
  7874. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  7875. }
  7876. function _byteLength (b64, validLen, placeHoldersLen) {
  7877. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  7878. }
  7879. function toByteArray (b64) {
  7880. var tmp
  7881. var lens = getLens(b64)
  7882. var validLen = lens[0]
  7883. var placeHoldersLen = lens[1]
  7884. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  7885. var curByte = 0
  7886. // if there are placeholders, only get up to the last complete 4 chars
  7887. var len = placeHoldersLen > 0
  7888. ? validLen - 4
  7889. : validLen
  7890. for (var i = 0; i < len; i += 4) {
  7891. tmp =
  7892. (revLookup[b64.charCodeAt(i)] << 18) |
  7893. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  7894. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  7895. revLookup[b64.charCodeAt(i + 3)]
  7896. arr[curByte++] = (tmp >> 16) & 0xFF
  7897. arr[curByte++] = (tmp >> 8) & 0xFF
  7898. arr[curByte++] = tmp & 0xFF
  7899. }
  7900. if (placeHoldersLen === 2) {
  7901. tmp =
  7902. (revLookup[b64.charCodeAt(i)] << 2) |
  7903. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  7904. arr[curByte++] = tmp & 0xFF
  7905. }
  7906. if (placeHoldersLen === 1) {
  7907. tmp =
  7908. (revLookup[b64.charCodeAt(i)] << 10) |
  7909. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  7910. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  7911. arr[curByte++] = (tmp >> 8) & 0xFF
  7912. arr[curByte++] = tmp & 0xFF
  7913. }
  7914. return arr
  7915. }
  7916. function tripletToBase64 (num) {
  7917. return lookup[num >> 18 & 0x3F] +
  7918. lookup[num >> 12 & 0x3F] +
  7919. lookup[num >> 6 & 0x3F] +
  7920. lookup[num & 0x3F]
  7921. }
  7922. function encodeChunk (uint8, start, end) {
  7923. var tmp
  7924. var output = []
  7925. for (var i = start; i < end; i += 3) {
  7926. tmp =
  7927. ((uint8[i] << 16) & 0xFF0000) +
  7928. ((uint8[i + 1] << 8) & 0xFF00) +
  7929. (uint8[i + 2] & 0xFF)
  7930. output.push(tripletToBase64(tmp))
  7931. }
  7932. return output.join('')
  7933. }
  7934. function fromByteArray (uint8) {
  7935. var tmp
  7936. var len = uint8.length
  7937. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  7938. var parts = []
  7939. var maxChunkLength = 16383 // must be multiple of 3
  7940. // go through the array every three bytes, we'll deal with trailing stuff later
  7941. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  7942. parts.push(encodeChunk(
  7943. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  7944. ))
  7945. }
  7946. // pad the end with zeros, but make sure to not forget the extra bytes
  7947. if (extraBytes === 1) {
  7948. tmp = uint8[len - 1]
  7949. parts.push(
  7950. lookup[tmp >> 2] +
  7951. lookup[(tmp << 4) & 0x3F] +
  7952. '=='
  7953. )
  7954. } else if (extraBytes === 2) {
  7955. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  7956. parts.push(
  7957. lookup[tmp >> 10] +
  7958. lookup[(tmp >> 4) & 0x3F] +
  7959. lookup[(tmp << 2) & 0x3F] +
  7960. '='
  7961. )
  7962. }
  7963. return parts.join('')
  7964. }
  7965. },{}],40:[function(require,module,exports){
  7966. },{}],41:[function(require,module,exports){
  7967. (function (process){
  7968. var WritableStream = require('stream').Writable
  7969. var inherits = require('util').inherits
  7970. module.exports = BrowserStdout
  7971. inherits(BrowserStdout, WritableStream)
  7972. function BrowserStdout(opts) {
  7973. if (!(this instanceof BrowserStdout)) return new BrowserStdout(opts)
  7974. opts = opts || {}
  7975. WritableStream.call(this, opts)
  7976. this.label = (opts.label !== undefined) ? opts.label : 'stdout'
  7977. }
  7978. BrowserStdout.prototype._write = function(chunks, encoding, cb) {
  7979. var output = chunks.toString ? chunks.toString() : chunks
  7980. if (this.label === false) {
  7981. console.log(output)
  7982. } else {
  7983. console.log(this.label+':', output)
  7984. }
  7985. process.nextTick(cb)
  7986. }
  7987. }).call(this,require('_process'))
  7988. },{"_process":69,"stream":84,"util":89}],42:[function(require,module,exports){
  7989. arguments[4][40][0].apply(exports,arguments)
  7990. },{"dup":40}],43:[function(require,module,exports){
  7991. (function (Buffer){
  7992. /*!
  7993. * The buffer module from node.js, for the browser.
  7994. *
  7995. * @author Feross Aboukhadijeh <https://feross.org>
  7996. * @license MIT
  7997. */
  7998. /* eslint-disable no-proto */
  7999. 'use strict'
  8000. var base64 = require('base64-js')
  8001. var ieee754 = require('ieee754')
  8002. exports.Buffer = Buffer
  8003. exports.SlowBuffer = SlowBuffer
  8004. exports.INSPECT_MAX_BYTES = 50
  8005. var K_MAX_LENGTH = 0x7fffffff
  8006. exports.kMaxLength = K_MAX_LENGTH
  8007. /**
  8008. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  8009. * === true Use Uint8Array implementation (fastest)
  8010. * === false Print warning and recommend using `buffer` v4.x which has an Object
  8011. * implementation (most compatible, even IE6)
  8012. *
  8013. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  8014. * Opera 11.6+, iOS 4.2+.
  8015. *
  8016. * We report that the browser does not support typed arrays if the are not subclassable
  8017. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  8018. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  8019. * for __proto__ and has a buggy typed array implementation.
  8020. */
  8021. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  8022. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  8023. typeof console.error === 'function') {
  8024. console.error(
  8025. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  8026. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  8027. )
  8028. }
  8029. function typedArraySupport () {
  8030. // Can typed array instances can be augmented?
  8031. try {
  8032. var arr = new Uint8Array(1)
  8033. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
  8034. return arr.foo() === 42
  8035. } catch (e) {
  8036. return false
  8037. }
  8038. }
  8039. Object.defineProperty(Buffer.prototype, 'parent', {
  8040. enumerable: true,
  8041. get: function () {
  8042. if (!Buffer.isBuffer(this)) return undefined
  8043. return this.buffer
  8044. }
  8045. })
  8046. Object.defineProperty(Buffer.prototype, 'offset', {
  8047. enumerable: true,
  8048. get: function () {
  8049. if (!Buffer.isBuffer(this)) return undefined
  8050. return this.byteOffset
  8051. }
  8052. })
  8053. function createBuffer (length) {
  8054. if (length > K_MAX_LENGTH) {
  8055. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  8056. }
  8057. // Return an augmented `Uint8Array` instance
  8058. var buf = new Uint8Array(length)
  8059. buf.__proto__ = Buffer.prototype
  8060. return buf
  8061. }
  8062. /**
  8063. * The Buffer constructor returns instances of `Uint8Array` that have their
  8064. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  8065. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  8066. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  8067. * returns a single octet.
  8068. *
  8069. * The `Uint8Array` prototype remains unmodified.
  8070. */
  8071. function Buffer (arg, encodingOrOffset, length) {
  8072. // Common case.
  8073. if (typeof arg === 'number') {
  8074. if (typeof encodingOrOffset === 'string') {
  8075. throw new TypeError(
  8076. 'The "string" argument must be of type string. Received type number'
  8077. )
  8078. }
  8079. return allocUnsafe(arg)
  8080. }
  8081. return from(arg, encodingOrOffset, length)
  8082. }
  8083. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  8084. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  8085. Buffer[Symbol.species] === Buffer) {
  8086. Object.defineProperty(Buffer, Symbol.species, {
  8087. value: null,
  8088. configurable: true,
  8089. enumerable: false,
  8090. writable: false
  8091. })
  8092. }
  8093. Buffer.poolSize = 8192 // not used by this implementation
  8094. function from (value, encodingOrOffset, length) {
  8095. if (typeof value === 'string') {
  8096. return fromString(value, encodingOrOffset)
  8097. }
  8098. if (ArrayBuffer.isView(value)) {
  8099. return fromArrayLike(value)
  8100. }
  8101. if (value == null) {
  8102. throw TypeError(
  8103. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  8104. 'or Array-like Object. Received type ' + (typeof value)
  8105. )
  8106. }
  8107. if (isInstance(value, ArrayBuffer) ||
  8108. (value && isInstance(value.buffer, ArrayBuffer))) {
  8109. return fromArrayBuffer(value, encodingOrOffset, length)
  8110. }
  8111. if (typeof value === 'number') {
  8112. throw new TypeError(
  8113. 'The "value" argument must not be of type number. Received type number'
  8114. )
  8115. }
  8116. var valueOf = value.valueOf && value.valueOf()
  8117. if (valueOf != null && valueOf !== value) {
  8118. return Buffer.from(valueOf, encodingOrOffset, length)
  8119. }
  8120. var b = fromObject(value)
  8121. if (b) return b
  8122. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  8123. typeof value[Symbol.toPrimitive] === 'function') {
  8124. return Buffer.from(
  8125. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  8126. )
  8127. }
  8128. throw new TypeError(
  8129. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  8130. 'or Array-like Object. Received type ' + (typeof value)
  8131. )
  8132. }
  8133. /**
  8134. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  8135. * if value is a number.
  8136. * Buffer.from(str[, encoding])
  8137. * Buffer.from(array)
  8138. * Buffer.from(buffer)
  8139. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  8140. **/
  8141. Buffer.from = function (value, encodingOrOffset, length) {
  8142. return from(value, encodingOrOffset, length)
  8143. }
  8144. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  8145. // https://github.com/feross/buffer/pull/148
  8146. Buffer.prototype.__proto__ = Uint8Array.prototype
  8147. Buffer.__proto__ = Uint8Array
  8148. function assertSize (size) {
  8149. if (typeof size !== 'number') {
  8150. throw new TypeError('"size" argument must be of type number')
  8151. } else if (size < 0) {
  8152. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  8153. }
  8154. }
  8155. function alloc (size, fill, encoding) {
  8156. assertSize(size)
  8157. if (size <= 0) {
  8158. return createBuffer(size)
  8159. }
  8160. if (fill !== undefined) {
  8161. // Only pay attention to encoding if it's a string. This
  8162. // prevents accidentally sending in a number that would
  8163. // be interpretted as a start offset.
  8164. return typeof encoding === 'string'
  8165. ? createBuffer(size).fill(fill, encoding)
  8166. : createBuffer(size).fill(fill)
  8167. }
  8168. return createBuffer(size)
  8169. }
  8170. /**
  8171. * Creates a new filled Buffer instance.
  8172. * alloc(size[, fill[, encoding]])
  8173. **/
  8174. Buffer.alloc = function (size, fill, encoding) {
  8175. return alloc(size, fill, encoding)
  8176. }
  8177. function allocUnsafe (size) {
  8178. assertSize(size)
  8179. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  8180. }
  8181. /**
  8182. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  8183. * */
  8184. Buffer.allocUnsafe = function (size) {
  8185. return allocUnsafe(size)
  8186. }
  8187. /**
  8188. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  8189. */
  8190. Buffer.allocUnsafeSlow = function (size) {
  8191. return allocUnsafe(size)
  8192. }
  8193. function fromString (string, encoding) {
  8194. if (typeof encoding !== 'string' || encoding === '') {
  8195. encoding = 'utf8'
  8196. }
  8197. if (!Buffer.isEncoding(encoding)) {
  8198. throw new TypeError('Unknown encoding: ' + encoding)
  8199. }
  8200. var length = byteLength(string, encoding) | 0
  8201. var buf = createBuffer(length)
  8202. var actual = buf.write(string, encoding)
  8203. if (actual !== length) {
  8204. // Writing a hex string, for example, that contains invalid characters will
  8205. // cause everything after the first invalid character to be ignored. (e.g.
  8206. // 'abxxcd' will be treated as 'ab')
  8207. buf = buf.slice(0, actual)
  8208. }
  8209. return buf
  8210. }
  8211. function fromArrayLike (array) {
  8212. var length = array.length < 0 ? 0 : checked(array.length) | 0
  8213. var buf = createBuffer(length)
  8214. for (var i = 0; i < length; i += 1) {
  8215. buf[i] = array[i] & 255
  8216. }
  8217. return buf
  8218. }
  8219. function fromArrayBuffer (array, byteOffset, length) {
  8220. if (byteOffset < 0 || array.byteLength < byteOffset) {
  8221. throw new RangeError('"offset" is outside of buffer bounds')
  8222. }
  8223. if (array.byteLength < byteOffset + (length || 0)) {
  8224. throw new RangeError('"length" is outside of buffer bounds')
  8225. }
  8226. var buf
  8227. if (byteOffset === undefined && length === undefined) {
  8228. buf = new Uint8Array(array)
  8229. } else if (length === undefined) {
  8230. buf = new Uint8Array(array, byteOffset)
  8231. } else {
  8232. buf = new Uint8Array(array, byteOffset, length)
  8233. }
  8234. // Return an augmented `Uint8Array` instance
  8235. buf.__proto__ = Buffer.prototype
  8236. return buf
  8237. }
  8238. function fromObject (obj) {
  8239. if (Buffer.isBuffer(obj)) {
  8240. var len = checked(obj.length) | 0
  8241. var buf = createBuffer(len)
  8242. if (buf.length === 0) {
  8243. return buf
  8244. }
  8245. obj.copy(buf, 0, 0, len)
  8246. return buf
  8247. }
  8248. if (obj.length !== undefined) {
  8249. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  8250. return createBuffer(0)
  8251. }
  8252. return fromArrayLike(obj)
  8253. }
  8254. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  8255. return fromArrayLike(obj.data)
  8256. }
  8257. }
  8258. function checked (length) {
  8259. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  8260. // length is NaN (which is otherwise coerced to zero.)
  8261. if (length >= K_MAX_LENGTH) {
  8262. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  8263. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  8264. }
  8265. return length | 0
  8266. }
  8267. function SlowBuffer (length) {
  8268. if (+length != length) { // eslint-disable-line eqeqeq
  8269. length = 0
  8270. }
  8271. return Buffer.alloc(+length)
  8272. }
  8273. Buffer.isBuffer = function isBuffer (b) {
  8274. return b != null && b._isBuffer === true &&
  8275. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  8276. }
  8277. Buffer.compare = function compare (a, b) {
  8278. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  8279. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  8280. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  8281. throw new TypeError(
  8282. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  8283. )
  8284. }
  8285. if (a === b) return 0
  8286. var x = a.length
  8287. var y = b.length
  8288. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  8289. if (a[i] !== b[i]) {
  8290. x = a[i]
  8291. y = b[i]
  8292. break
  8293. }
  8294. }
  8295. if (x < y) return -1
  8296. if (y < x) return 1
  8297. return 0
  8298. }
  8299. Buffer.isEncoding = function isEncoding (encoding) {
  8300. switch (String(encoding).toLowerCase()) {
  8301. case 'hex':
  8302. case 'utf8':
  8303. case 'utf-8':
  8304. case 'ascii':
  8305. case 'latin1':
  8306. case 'binary':
  8307. case 'base64':
  8308. case 'ucs2':
  8309. case 'ucs-2':
  8310. case 'utf16le':
  8311. case 'utf-16le':
  8312. return true
  8313. default:
  8314. return false
  8315. }
  8316. }
  8317. Buffer.concat = function concat (list, length) {
  8318. if (!Array.isArray(list)) {
  8319. throw new TypeError('"list" argument must be an Array of Buffers')
  8320. }
  8321. if (list.length === 0) {
  8322. return Buffer.alloc(0)
  8323. }
  8324. var i
  8325. if (length === undefined) {
  8326. length = 0
  8327. for (i = 0; i < list.length; ++i) {
  8328. length += list[i].length
  8329. }
  8330. }
  8331. var buffer = Buffer.allocUnsafe(length)
  8332. var pos = 0
  8333. for (i = 0; i < list.length; ++i) {
  8334. var buf = list[i]
  8335. if (isInstance(buf, Uint8Array)) {
  8336. buf = Buffer.from(buf)
  8337. }
  8338. if (!Buffer.isBuffer(buf)) {
  8339. throw new TypeError('"list" argument must be an Array of Buffers')
  8340. }
  8341. buf.copy(buffer, pos)
  8342. pos += buf.length
  8343. }
  8344. return buffer
  8345. }
  8346. function byteLength (string, encoding) {
  8347. if (Buffer.isBuffer(string)) {
  8348. return string.length
  8349. }
  8350. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  8351. return string.byteLength
  8352. }
  8353. if (typeof string !== 'string') {
  8354. throw new TypeError(
  8355. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  8356. 'Received type ' + typeof string
  8357. )
  8358. }
  8359. var len = string.length
  8360. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  8361. if (!mustMatch && len === 0) return 0
  8362. // Use a for loop to avoid recursion
  8363. var loweredCase = false
  8364. for (;;) {
  8365. switch (encoding) {
  8366. case 'ascii':
  8367. case 'latin1':
  8368. case 'binary':
  8369. return len
  8370. case 'utf8':
  8371. case 'utf-8':
  8372. return utf8ToBytes(string).length
  8373. case 'ucs2':
  8374. case 'ucs-2':
  8375. case 'utf16le':
  8376. case 'utf-16le':
  8377. return len * 2
  8378. case 'hex':
  8379. return len >>> 1
  8380. case 'base64':
  8381. return base64ToBytes(string).length
  8382. default:
  8383. if (loweredCase) {
  8384. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  8385. }
  8386. encoding = ('' + encoding).toLowerCase()
  8387. loweredCase = true
  8388. }
  8389. }
  8390. }
  8391. Buffer.byteLength = byteLength
  8392. function slowToString (encoding, start, end) {
  8393. var loweredCase = false
  8394. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  8395. // property of a typed array.
  8396. // This behaves neither like String nor Uint8Array in that we set start/end
  8397. // to their upper/lower bounds if the value passed is out of range.
  8398. // undefined is handled specially as per ECMA-262 6th Edition,
  8399. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  8400. if (start === undefined || start < 0) {
  8401. start = 0
  8402. }
  8403. // Return early if start > this.length. Done here to prevent potential uint32
  8404. // coercion fail below.
  8405. if (start > this.length) {
  8406. return ''
  8407. }
  8408. if (end === undefined || end > this.length) {
  8409. end = this.length
  8410. }
  8411. if (end <= 0) {
  8412. return ''
  8413. }
  8414. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  8415. end >>>= 0
  8416. start >>>= 0
  8417. if (end <= start) {
  8418. return ''
  8419. }
  8420. if (!encoding) encoding = 'utf8'
  8421. while (true) {
  8422. switch (encoding) {
  8423. case 'hex':
  8424. return hexSlice(this, start, end)
  8425. case 'utf8':
  8426. case 'utf-8':
  8427. return utf8Slice(this, start, end)
  8428. case 'ascii':
  8429. return asciiSlice(this, start, end)
  8430. case 'latin1':
  8431. case 'binary':
  8432. return latin1Slice(this, start, end)
  8433. case 'base64':
  8434. return base64Slice(this, start, end)
  8435. case 'ucs2':
  8436. case 'ucs-2':
  8437. case 'utf16le':
  8438. case 'utf-16le':
  8439. return utf16leSlice(this, start, end)
  8440. default:
  8441. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  8442. encoding = (encoding + '').toLowerCase()
  8443. loweredCase = true
  8444. }
  8445. }
  8446. }
  8447. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  8448. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  8449. // reliably in a browserify context because there could be multiple different
  8450. // copies of the 'buffer' package in use. This method works even for Buffer
  8451. // instances that were created from another copy of the `buffer` package.
  8452. // See: https://github.com/feross/buffer/issues/154
  8453. Buffer.prototype._isBuffer = true
  8454. function swap (b, n, m) {
  8455. var i = b[n]
  8456. b[n] = b[m]
  8457. b[m] = i
  8458. }
  8459. Buffer.prototype.swap16 = function swap16 () {
  8460. var len = this.length
  8461. if (len % 2 !== 0) {
  8462. throw new RangeError('Buffer size must be a multiple of 16-bits')
  8463. }
  8464. for (var i = 0; i < len; i += 2) {
  8465. swap(this, i, i + 1)
  8466. }
  8467. return this
  8468. }
  8469. Buffer.prototype.swap32 = function swap32 () {
  8470. var len = this.length
  8471. if (len % 4 !== 0) {
  8472. throw new RangeError('Buffer size must be a multiple of 32-bits')
  8473. }
  8474. for (var i = 0; i < len; i += 4) {
  8475. swap(this, i, i + 3)
  8476. swap(this, i + 1, i + 2)
  8477. }
  8478. return this
  8479. }
  8480. Buffer.prototype.swap64 = function swap64 () {
  8481. var len = this.length
  8482. if (len % 8 !== 0) {
  8483. throw new RangeError('Buffer size must be a multiple of 64-bits')
  8484. }
  8485. for (var i = 0; i < len; i += 8) {
  8486. swap(this, i, i + 7)
  8487. swap(this, i + 1, i + 6)
  8488. swap(this, i + 2, i + 5)
  8489. swap(this, i + 3, i + 4)
  8490. }
  8491. return this
  8492. }
  8493. Buffer.prototype.toString = function toString () {
  8494. var length = this.length
  8495. if (length === 0) return ''
  8496. if (arguments.length === 0) return utf8Slice(this, 0, length)
  8497. return slowToString.apply(this, arguments)
  8498. }
  8499. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  8500. Buffer.prototype.equals = function equals (b) {
  8501. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  8502. if (this === b) return true
  8503. return Buffer.compare(this, b) === 0
  8504. }
  8505. Buffer.prototype.inspect = function inspect () {
  8506. var str = ''
  8507. var max = exports.INSPECT_MAX_BYTES
  8508. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  8509. if (this.length > max) str += ' ... '
  8510. return '<Buffer ' + str + '>'
  8511. }
  8512. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  8513. if (isInstance(target, Uint8Array)) {
  8514. target = Buffer.from(target, target.offset, target.byteLength)
  8515. }
  8516. if (!Buffer.isBuffer(target)) {
  8517. throw new TypeError(
  8518. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  8519. 'Received type ' + (typeof target)
  8520. )
  8521. }
  8522. if (start === undefined) {
  8523. start = 0
  8524. }
  8525. if (end === undefined) {
  8526. end = target ? target.length : 0
  8527. }
  8528. if (thisStart === undefined) {
  8529. thisStart = 0
  8530. }
  8531. if (thisEnd === undefined) {
  8532. thisEnd = this.length
  8533. }
  8534. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  8535. throw new RangeError('out of range index')
  8536. }
  8537. if (thisStart >= thisEnd && start >= end) {
  8538. return 0
  8539. }
  8540. if (thisStart >= thisEnd) {
  8541. return -1
  8542. }
  8543. if (start >= end) {
  8544. return 1
  8545. }
  8546. start >>>= 0
  8547. end >>>= 0
  8548. thisStart >>>= 0
  8549. thisEnd >>>= 0
  8550. if (this === target) return 0
  8551. var x = thisEnd - thisStart
  8552. var y = end - start
  8553. var len = Math.min(x, y)
  8554. var thisCopy = this.slice(thisStart, thisEnd)
  8555. var targetCopy = target.slice(start, end)
  8556. for (var i = 0; i < len; ++i) {
  8557. if (thisCopy[i] !== targetCopy[i]) {
  8558. x = thisCopy[i]
  8559. y = targetCopy[i]
  8560. break
  8561. }
  8562. }
  8563. if (x < y) return -1
  8564. if (y < x) return 1
  8565. return 0
  8566. }
  8567. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  8568. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  8569. //
  8570. // Arguments:
  8571. // - buffer - a Buffer to search
  8572. // - val - a string, Buffer, or number
  8573. // - byteOffset - an index into `buffer`; will be clamped to an int32
  8574. // - encoding - an optional encoding, relevant is val is a string
  8575. // - dir - true for indexOf, false for lastIndexOf
  8576. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  8577. // Empty buffer means no match
  8578. if (buffer.length === 0) return -1
  8579. // Normalize byteOffset
  8580. if (typeof byteOffset === 'string') {
  8581. encoding = byteOffset
  8582. byteOffset = 0
  8583. } else if (byteOffset > 0x7fffffff) {
  8584. byteOffset = 0x7fffffff
  8585. } else if (byteOffset < -0x80000000) {
  8586. byteOffset = -0x80000000
  8587. }
  8588. byteOffset = +byteOffset // Coerce to Number.
  8589. if (numberIsNaN(byteOffset)) {
  8590. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  8591. byteOffset = dir ? 0 : (buffer.length - 1)
  8592. }
  8593. // Normalize byteOffset: negative offsets start from the end of the buffer
  8594. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  8595. if (byteOffset >= buffer.length) {
  8596. if (dir) return -1
  8597. else byteOffset = buffer.length - 1
  8598. } else if (byteOffset < 0) {
  8599. if (dir) byteOffset = 0
  8600. else return -1
  8601. }
  8602. // Normalize val
  8603. if (typeof val === 'string') {
  8604. val = Buffer.from(val, encoding)
  8605. }
  8606. // Finally, search either indexOf (if dir is true) or lastIndexOf
  8607. if (Buffer.isBuffer(val)) {
  8608. // Special case: looking for empty string/buffer always fails
  8609. if (val.length === 0) {
  8610. return -1
  8611. }
  8612. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  8613. } else if (typeof val === 'number') {
  8614. val = val & 0xFF // Search for a byte value [0-255]
  8615. if (typeof Uint8Array.prototype.indexOf === 'function') {
  8616. if (dir) {
  8617. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  8618. } else {
  8619. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  8620. }
  8621. }
  8622. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  8623. }
  8624. throw new TypeError('val must be string, number or Buffer')
  8625. }
  8626. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  8627. var indexSize = 1
  8628. var arrLength = arr.length
  8629. var valLength = val.length
  8630. if (encoding !== undefined) {
  8631. encoding = String(encoding).toLowerCase()
  8632. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  8633. encoding === 'utf16le' || encoding === 'utf-16le') {
  8634. if (arr.length < 2 || val.length < 2) {
  8635. return -1
  8636. }
  8637. indexSize = 2
  8638. arrLength /= 2
  8639. valLength /= 2
  8640. byteOffset /= 2
  8641. }
  8642. }
  8643. function read (buf, i) {
  8644. if (indexSize === 1) {
  8645. return buf[i]
  8646. } else {
  8647. return buf.readUInt16BE(i * indexSize)
  8648. }
  8649. }
  8650. var i
  8651. if (dir) {
  8652. var foundIndex = -1
  8653. for (i = byteOffset; i < arrLength; i++) {
  8654. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  8655. if (foundIndex === -1) foundIndex = i
  8656. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  8657. } else {
  8658. if (foundIndex !== -1) i -= i - foundIndex
  8659. foundIndex = -1
  8660. }
  8661. }
  8662. } else {
  8663. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  8664. for (i = byteOffset; i >= 0; i--) {
  8665. var found = true
  8666. for (var j = 0; j < valLength; j++) {
  8667. if (read(arr, i + j) !== read(val, j)) {
  8668. found = false
  8669. break
  8670. }
  8671. }
  8672. if (found) return i
  8673. }
  8674. }
  8675. return -1
  8676. }
  8677. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  8678. return this.indexOf(val, byteOffset, encoding) !== -1
  8679. }
  8680. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  8681. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  8682. }
  8683. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  8684. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  8685. }
  8686. function hexWrite (buf, string, offset, length) {
  8687. offset = Number(offset) || 0
  8688. var remaining = buf.length - offset
  8689. if (!length) {
  8690. length = remaining
  8691. } else {
  8692. length = Number(length)
  8693. if (length > remaining) {
  8694. length = remaining
  8695. }
  8696. }
  8697. var strLen = string.length
  8698. if (length > strLen / 2) {
  8699. length = strLen / 2
  8700. }
  8701. for (var i = 0; i < length; ++i) {
  8702. var parsed = parseInt(string.substr(i * 2, 2), 16)
  8703. if (numberIsNaN(parsed)) return i
  8704. buf[offset + i] = parsed
  8705. }
  8706. return i
  8707. }
  8708. function utf8Write (buf, string, offset, length) {
  8709. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  8710. }
  8711. function asciiWrite (buf, string, offset, length) {
  8712. return blitBuffer(asciiToBytes(string), buf, offset, length)
  8713. }
  8714. function latin1Write (buf, string, offset, length) {
  8715. return asciiWrite(buf, string, offset, length)
  8716. }
  8717. function base64Write (buf, string, offset, length) {
  8718. return blitBuffer(base64ToBytes(string), buf, offset, length)
  8719. }
  8720. function ucs2Write (buf, string, offset, length) {
  8721. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  8722. }
  8723. Buffer.prototype.write = function write (string, offset, length, encoding) {
  8724. // Buffer#write(string)
  8725. if (offset === undefined) {
  8726. encoding = 'utf8'
  8727. length = this.length
  8728. offset = 0
  8729. // Buffer#write(string, encoding)
  8730. } else if (length === undefined && typeof offset === 'string') {
  8731. encoding = offset
  8732. length = this.length
  8733. offset = 0
  8734. // Buffer#write(string, offset[, length][, encoding])
  8735. } else if (isFinite(offset)) {
  8736. offset = offset >>> 0
  8737. if (isFinite(length)) {
  8738. length = length >>> 0
  8739. if (encoding === undefined) encoding = 'utf8'
  8740. } else {
  8741. encoding = length
  8742. length = undefined
  8743. }
  8744. } else {
  8745. throw new Error(
  8746. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  8747. )
  8748. }
  8749. var remaining = this.length - offset
  8750. if (length === undefined || length > remaining) length = remaining
  8751. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  8752. throw new RangeError('Attempt to write outside buffer bounds')
  8753. }
  8754. if (!encoding) encoding = 'utf8'
  8755. var loweredCase = false
  8756. for (;;) {
  8757. switch (encoding) {
  8758. case 'hex':
  8759. return hexWrite(this, string, offset, length)
  8760. case 'utf8':
  8761. case 'utf-8':
  8762. return utf8Write(this, string, offset, length)
  8763. case 'ascii':
  8764. return asciiWrite(this, string, offset, length)
  8765. case 'latin1':
  8766. case 'binary':
  8767. return latin1Write(this, string, offset, length)
  8768. case 'base64':
  8769. // Warning: maxLength not taken into account in base64Write
  8770. return base64Write(this, string, offset, length)
  8771. case 'ucs2':
  8772. case 'ucs-2':
  8773. case 'utf16le':
  8774. case 'utf-16le':
  8775. return ucs2Write(this, string, offset, length)
  8776. default:
  8777. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  8778. encoding = ('' + encoding).toLowerCase()
  8779. loweredCase = true
  8780. }
  8781. }
  8782. }
  8783. Buffer.prototype.toJSON = function toJSON () {
  8784. return {
  8785. type: 'Buffer',
  8786. data: Array.prototype.slice.call(this._arr || this, 0)
  8787. }
  8788. }
  8789. function base64Slice (buf, start, end) {
  8790. if (start === 0 && end === buf.length) {
  8791. return base64.fromByteArray(buf)
  8792. } else {
  8793. return base64.fromByteArray(buf.slice(start, end))
  8794. }
  8795. }
  8796. function utf8Slice (buf, start, end) {
  8797. end = Math.min(buf.length, end)
  8798. var res = []
  8799. var i = start
  8800. while (i < end) {
  8801. var firstByte = buf[i]
  8802. var codePoint = null
  8803. var bytesPerSequence = (firstByte > 0xEF) ? 4
  8804. : (firstByte > 0xDF) ? 3
  8805. : (firstByte > 0xBF) ? 2
  8806. : 1
  8807. if (i + bytesPerSequence <= end) {
  8808. var secondByte, thirdByte, fourthByte, tempCodePoint
  8809. switch (bytesPerSequence) {
  8810. case 1:
  8811. if (firstByte < 0x80) {
  8812. codePoint = firstByte
  8813. }
  8814. break
  8815. case 2:
  8816. secondByte = buf[i + 1]
  8817. if ((secondByte & 0xC0) === 0x80) {
  8818. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  8819. if (tempCodePoint > 0x7F) {
  8820. codePoint = tempCodePoint
  8821. }
  8822. }
  8823. break
  8824. case 3:
  8825. secondByte = buf[i + 1]
  8826. thirdByte = buf[i + 2]
  8827. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  8828. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  8829. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  8830. codePoint = tempCodePoint
  8831. }
  8832. }
  8833. break
  8834. case 4:
  8835. secondByte = buf[i + 1]
  8836. thirdByte = buf[i + 2]
  8837. fourthByte = buf[i + 3]
  8838. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  8839. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  8840. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  8841. codePoint = tempCodePoint
  8842. }
  8843. }
  8844. }
  8845. }
  8846. if (codePoint === null) {
  8847. // we did not generate a valid codePoint so insert a
  8848. // replacement char (U+FFFD) and advance only 1 byte
  8849. codePoint = 0xFFFD
  8850. bytesPerSequence = 1
  8851. } else if (codePoint > 0xFFFF) {
  8852. // encode to utf16 (surrogate pair dance)
  8853. codePoint -= 0x10000
  8854. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  8855. codePoint = 0xDC00 | codePoint & 0x3FF
  8856. }
  8857. res.push(codePoint)
  8858. i += bytesPerSequence
  8859. }
  8860. return decodeCodePointsArray(res)
  8861. }
  8862. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  8863. // the lowest limit is Chrome, with 0x10000 args.
  8864. // We go 1 magnitude less, for safety
  8865. var MAX_ARGUMENTS_LENGTH = 0x1000
  8866. function decodeCodePointsArray (codePoints) {
  8867. var len = codePoints.length
  8868. if (len <= MAX_ARGUMENTS_LENGTH) {
  8869. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  8870. }
  8871. // Decode in chunks to avoid "call stack size exceeded".
  8872. var res = ''
  8873. var i = 0
  8874. while (i < len) {
  8875. res += String.fromCharCode.apply(
  8876. String,
  8877. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  8878. )
  8879. }
  8880. return res
  8881. }
  8882. function asciiSlice (buf, start, end) {
  8883. var ret = ''
  8884. end = Math.min(buf.length, end)
  8885. for (var i = start; i < end; ++i) {
  8886. ret += String.fromCharCode(buf[i] & 0x7F)
  8887. }
  8888. return ret
  8889. }
  8890. function latin1Slice (buf, start, end) {
  8891. var ret = ''
  8892. end = Math.min(buf.length, end)
  8893. for (var i = start; i < end; ++i) {
  8894. ret += String.fromCharCode(buf[i])
  8895. }
  8896. return ret
  8897. }
  8898. function hexSlice (buf, start, end) {
  8899. var len = buf.length
  8900. if (!start || start < 0) start = 0
  8901. if (!end || end < 0 || end > len) end = len
  8902. var out = ''
  8903. for (var i = start; i < end; ++i) {
  8904. out += toHex(buf[i])
  8905. }
  8906. return out
  8907. }
  8908. function utf16leSlice (buf, start, end) {
  8909. var bytes = buf.slice(start, end)
  8910. var res = ''
  8911. for (var i = 0; i < bytes.length; i += 2) {
  8912. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  8913. }
  8914. return res
  8915. }
  8916. Buffer.prototype.slice = function slice (start, end) {
  8917. var len = this.length
  8918. start = ~~start
  8919. end = end === undefined ? len : ~~end
  8920. if (start < 0) {
  8921. start += len
  8922. if (start < 0) start = 0
  8923. } else if (start > len) {
  8924. start = len
  8925. }
  8926. if (end < 0) {
  8927. end += len
  8928. if (end < 0) end = 0
  8929. } else if (end > len) {
  8930. end = len
  8931. }
  8932. if (end < start) end = start
  8933. var newBuf = this.subarray(start, end)
  8934. // Return an augmented `Uint8Array` instance
  8935. newBuf.__proto__ = Buffer.prototype
  8936. return newBuf
  8937. }
  8938. /*
  8939. * Need to make sure that buffer isn't trying to write out of bounds.
  8940. */
  8941. function checkOffset (offset, ext, length) {
  8942. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  8943. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  8944. }
  8945. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  8946. offset = offset >>> 0
  8947. byteLength = byteLength >>> 0
  8948. if (!noAssert) checkOffset(offset, byteLength, this.length)
  8949. var val = this[offset]
  8950. var mul = 1
  8951. var i = 0
  8952. while (++i < byteLength && (mul *= 0x100)) {
  8953. val += this[offset + i] * mul
  8954. }
  8955. return val
  8956. }
  8957. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  8958. offset = offset >>> 0
  8959. byteLength = byteLength >>> 0
  8960. if (!noAssert) {
  8961. checkOffset(offset, byteLength, this.length)
  8962. }
  8963. var val = this[offset + --byteLength]
  8964. var mul = 1
  8965. while (byteLength > 0 && (mul *= 0x100)) {
  8966. val += this[offset + --byteLength] * mul
  8967. }
  8968. return val
  8969. }
  8970. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  8971. offset = offset >>> 0
  8972. if (!noAssert) checkOffset(offset, 1, this.length)
  8973. return this[offset]
  8974. }
  8975. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  8976. offset = offset >>> 0
  8977. if (!noAssert) checkOffset(offset, 2, this.length)
  8978. return this[offset] | (this[offset + 1] << 8)
  8979. }
  8980. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  8981. offset = offset >>> 0
  8982. if (!noAssert) checkOffset(offset, 2, this.length)
  8983. return (this[offset] << 8) | this[offset + 1]
  8984. }
  8985. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  8986. offset = offset >>> 0
  8987. if (!noAssert) checkOffset(offset, 4, this.length)
  8988. return ((this[offset]) |
  8989. (this[offset + 1] << 8) |
  8990. (this[offset + 2] << 16)) +
  8991. (this[offset + 3] * 0x1000000)
  8992. }
  8993. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  8994. offset = offset >>> 0
  8995. if (!noAssert) checkOffset(offset, 4, this.length)
  8996. return (this[offset] * 0x1000000) +
  8997. ((this[offset + 1] << 16) |
  8998. (this[offset + 2] << 8) |
  8999. this[offset + 3])
  9000. }
  9001. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  9002. offset = offset >>> 0
  9003. byteLength = byteLength >>> 0
  9004. if (!noAssert) checkOffset(offset, byteLength, this.length)
  9005. var val = this[offset]
  9006. var mul = 1
  9007. var i = 0
  9008. while (++i < byteLength && (mul *= 0x100)) {
  9009. val += this[offset + i] * mul
  9010. }
  9011. mul *= 0x80
  9012. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  9013. return val
  9014. }
  9015. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  9016. offset = offset >>> 0
  9017. byteLength = byteLength >>> 0
  9018. if (!noAssert) checkOffset(offset, byteLength, this.length)
  9019. var i = byteLength
  9020. var mul = 1
  9021. var val = this[offset + --i]
  9022. while (i > 0 && (mul *= 0x100)) {
  9023. val += this[offset + --i] * mul
  9024. }
  9025. mul *= 0x80
  9026. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  9027. return val
  9028. }
  9029. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  9030. offset = offset >>> 0
  9031. if (!noAssert) checkOffset(offset, 1, this.length)
  9032. if (!(this[offset] & 0x80)) return (this[offset])
  9033. return ((0xff - this[offset] + 1) * -1)
  9034. }
  9035. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  9036. offset = offset >>> 0
  9037. if (!noAssert) checkOffset(offset, 2, this.length)
  9038. var val = this[offset] | (this[offset + 1] << 8)
  9039. return (val & 0x8000) ? val | 0xFFFF0000 : val
  9040. }
  9041. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  9042. offset = offset >>> 0
  9043. if (!noAssert) checkOffset(offset, 2, this.length)
  9044. var val = this[offset + 1] | (this[offset] << 8)
  9045. return (val & 0x8000) ? val | 0xFFFF0000 : val
  9046. }
  9047. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  9048. offset = offset >>> 0
  9049. if (!noAssert) checkOffset(offset, 4, this.length)
  9050. return (this[offset]) |
  9051. (this[offset + 1] << 8) |
  9052. (this[offset + 2] << 16) |
  9053. (this[offset + 3] << 24)
  9054. }
  9055. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  9056. offset = offset >>> 0
  9057. if (!noAssert) checkOffset(offset, 4, this.length)
  9058. return (this[offset] << 24) |
  9059. (this[offset + 1] << 16) |
  9060. (this[offset + 2] << 8) |
  9061. (this[offset + 3])
  9062. }
  9063. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  9064. offset = offset >>> 0
  9065. if (!noAssert) checkOffset(offset, 4, this.length)
  9066. return ieee754.read(this, offset, true, 23, 4)
  9067. }
  9068. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  9069. offset = offset >>> 0
  9070. if (!noAssert) checkOffset(offset, 4, this.length)
  9071. return ieee754.read(this, offset, false, 23, 4)
  9072. }
  9073. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  9074. offset = offset >>> 0
  9075. if (!noAssert) checkOffset(offset, 8, this.length)
  9076. return ieee754.read(this, offset, true, 52, 8)
  9077. }
  9078. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  9079. offset = offset >>> 0
  9080. if (!noAssert) checkOffset(offset, 8, this.length)
  9081. return ieee754.read(this, offset, false, 52, 8)
  9082. }
  9083. function checkInt (buf, value, offset, ext, max, min) {
  9084. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  9085. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  9086. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  9087. }
  9088. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  9089. value = +value
  9090. offset = offset >>> 0
  9091. byteLength = byteLength >>> 0
  9092. if (!noAssert) {
  9093. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  9094. checkInt(this, value, offset, byteLength, maxBytes, 0)
  9095. }
  9096. var mul = 1
  9097. var i = 0
  9098. this[offset] = value & 0xFF
  9099. while (++i < byteLength && (mul *= 0x100)) {
  9100. this[offset + i] = (value / mul) & 0xFF
  9101. }
  9102. return offset + byteLength
  9103. }
  9104. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  9105. value = +value
  9106. offset = offset >>> 0
  9107. byteLength = byteLength >>> 0
  9108. if (!noAssert) {
  9109. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  9110. checkInt(this, value, offset, byteLength, maxBytes, 0)
  9111. }
  9112. var i = byteLength - 1
  9113. var mul = 1
  9114. this[offset + i] = value & 0xFF
  9115. while (--i >= 0 && (mul *= 0x100)) {
  9116. this[offset + i] = (value / mul) & 0xFF
  9117. }
  9118. return offset + byteLength
  9119. }
  9120. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  9121. value = +value
  9122. offset = offset >>> 0
  9123. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  9124. this[offset] = (value & 0xff)
  9125. return offset + 1
  9126. }
  9127. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  9128. value = +value
  9129. offset = offset >>> 0
  9130. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  9131. this[offset] = (value & 0xff)
  9132. this[offset + 1] = (value >>> 8)
  9133. return offset + 2
  9134. }
  9135. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  9136. value = +value
  9137. offset = offset >>> 0
  9138. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  9139. this[offset] = (value >>> 8)
  9140. this[offset + 1] = (value & 0xff)
  9141. return offset + 2
  9142. }
  9143. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  9144. value = +value
  9145. offset = offset >>> 0
  9146. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  9147. this[offset + 3] = (value >>> 24)
  9148. this[offset + 2] = (value >>> 16)
  9149. this[offset + 1] = (value >>> 8)
  9150. this[offset] = (value & 0xff)
  9151. return offset + 4
  9152. }
  9153. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  9154. value = +value
  9155. offset = offset >>> 0
  9156. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  9157. this[offset] = (value >>> 24)
  9158. this[offset + 1] = (value >>> 16)
  9159. this[offset + 2] = (value >>> 8)
  9160. this[offset + 3] = (value & 0xff)
  9161. return offset + 4
  9162. }
  9163. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  9164. value = +value
  9165. offset = offset >>> 0
  9166. if (!noAssert) {
  9167. var limit = Math.pow(2, (8 * byteLength) - 1)
  9168. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  9169. }
  9170. var i = 0
  9171. var mul = 1
  9172. var sub = 0
  9173. this[offset] = value & 0xFF
  9174. while (++i < byteLength && (mul *= 0x100)) {
  9175. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  9176. sub = 1
  9177. }
  9178. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  9179. }
  9180. return offset + byteLength
  9181. }
  9182. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  9183. value = +value
  9184. offset = offset >>> 0
  9185. if (!noAssert) {
  9186. var limit = Math.pow(2, (8 * byteLength) - 1)
  9187. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  9188. }
  9189. var i = byteLength - 1
  9190. var mul = 1
  9191. var sub = 0
  9192. this[offset + i] = value & 0xFF
  9193. while (--i >= 0 && (mul *= 0x100)) {
  9194. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  9195. sub = 1
  9196. }
  9197. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  9198. }
  9199. return offset + byteLength
  9200. }
  9201. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  9202. value = +value
  9203. offset = offset >>> 0
  9204. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  9205. if (value < 0) value = 0xff + value + 1
  9206. this[offset] = (value & 0xff)
  9207. return offset + 1
  9208. }
  9209. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  9210. value = +value
  9211. offset = offset >>> 0
  9212. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  9213. this[offset] = (value & 0xff)
  9214. this[offset + 1] = (value >>> 8)
  9215. return offset + 2
  9216. }
  9217. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  9218. value = +value
  9219. offset = offset >>> 0
  9220. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  9221. this[offset] = (value >>> 8)
  9222. this[offset + 1] = (value & 0xff)
  9223. return offset + 2
  9224. }
  9225. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  9226. value = +value
  9227. offset = offset >>> 0
  9228. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  9229. this[offset] = (value & 0xff)
  9230. this[offset + 1] = (value >>> 8)
  9231. this[offset + 2] = (value >>> 16)
  9232. this[offset + 3] = (value >>> 24)
  9233. return offset + 4
  9234. }
  9235. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  9236. value = +value
  9237. offset = offset >>> 0
  9238. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  9239. if (value < 0) value = 0xffffffff + value + 1
  9240. this[offset] = (value >>> 24)
  9241. this[offset + 1] = (value >>> 16)
  9242. this[offset + 2] = (value >>> 8)
  9243. this[offset + 3] = (value & 0xff)
  9244. return offset + 4
  9245. }
  9246. function checkIEEE754 (buf, value, offset, ext, max, min) {
  9247. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  9248. if (offset < 0) throw new RangeError('Index out of range')
  9249. }
  9250. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  9251. value = +value
  9252. offset = offset >>> 0
  9253. if (!noAssert) {
  9254. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  9255. }
  9256. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  9257. return offset + 4
  9258. }
  9259. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  9260. return writeFloat(this, value, offset, true, noAssert)
  9261. }
  9262. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  9263. return writeFloat(this, value, offset, false, noAssert)
  9264. }
  9265. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  9266. value = +value
  9267. offset = offset >>> 0
  9268. if (!noAssert) {
  9269. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  9270. }
  9271. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  9272. return offset + 8
  9273. }
  9274. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  9275. return writeDouble(this, value, offset, true, noAssert)
  9276. }
  9277. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  9278. return writeDouble(this, value, offset, false, noAssert)
  9279. }
  9280. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  9281. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  9282. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  9283. if (!start) start = 0
  9284. if (!end && end !== 0) end = this.length
  9285. if (targetStart >= target.length) targetStart = target.length
  9286. if (!targetStart) targetStart = 0
  9287. if (end > 0 && end < start) end = start
  9288. // Copy 0 bytes; we're done
  9289. if (end === start) return 0
  9290. if (target.length === 0 || this.length === 0) return 0
  9291. // Fatal error conditions
  9292. if (targetStart < 0) {
  9293. throw new RangeError('targetStart out of bounds')
  9294. }
  9295. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  9296. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  9297. // Are we oob?
  9298. if (end > this.length) end = this.length
  9299. if (target.length - targetStart < end - start) {
  9300. end = target.length - targetStart + start
  9301. }
  9302. var len = end - start
  9303. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  9304. // Use built-in when available, missing from IE11
  9305. this.copyWithin(targetStart, start, end)
  9306. } else if (this === target && start < targetStart && targetStart < end) {
  9307. // descending copy from end
  9308. for (var i = len - 1; i >= 0; --i) {
  9309. target[i + targetStart] = this[i + start]
  9310. }
  9311. } else {
  9312. Uint8Array.prototype.set.call(
  9313. target,
  9314. this.subarray(start, end),
  9315. targetStart
  9316. )
  9317. }
  9318. return len
  9319. }
  9320. // Usage:
  9321. // buffer.fill(number[, offset[, end]])
  9322. // buffer.fill(buffer[, offset[, end]])
  9323. // buffer.fill(string[, offset[, end]][, encoding])
  9324. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  9325. // Handle string cases:
  9326. if (typeof val === 'string') {
  9327. if (typeof start === 'string') {
  9328. encoding = start
  9329. start = 0
  9330. end = this.length
  9331. } else if (typeof end === 'string') {
  9332. encoding = end
  9333. end = this.length
  9334. }
  9335. if (encoding !== undefined && typeof encoding !== 'string') {
  9336. throw new TypeError('encoding must be a string')
  9337. }
  9338. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  9339. throw new TypeError('Unknown encoding: ' + encoding)
  9340. }
  9341. if (val.length === 1) {
  9342. var code = val.charCodeAt(0)
  9343. if ((encoding === 'utf8' && code < 128) ||
  9344. encoding === 'latin1') {
  9345. // Fast path: If `val` fits into a single byte, use that numeric value.
  9346. val = code
  9347. }
  9348. }
  9349. } else if (typeof val === 'number') {
  9350. val = val & 255
  9351. }
  9352. // Invalid ranges are not set to a default, so can range check early.
  9353. if (start < 0 || this.length < start || this.length < end) {
  9354. throw new RangeError('Out of range index')
  9355. }
  9356. if (end <= start) {
  9357. return this
  9358. }
  9359. start = start >>> 0
  9360. end = end === undefined ? this.length : end >>> 0
  9361. if (!val) val = 0
  9362. var i
  9363. if (typeof val === 'number') {
  9364. for (i = start; i < end; ++i) {
  9365. this[i] = val
  9366. }
  9367. } else {
  9368. var bytes = Buffer.isBuffer(val)
  9369. ? val
  9370. : Buffer.from(val, encoding)
  9371. var len = bytes.length
  9372. if (len === 0) {
  9373. throw new TypeError('The value "' + val +
  9374. '" is invalid for argument "value"')
  9375. }
  9376. for (i = 0; i < end - start; ++i) {
  9377. this[i + start] = bytes[i % len]
  9378. }
  9379. }
  9380. return this
  9381. }
  9382. // HELPER FUNCTIONS
  9383. // ================
  9384. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  9385. function base64clean (str) {
  9386. // Node takes equal signs as end of the Base64 encoding
  9387. str = str.split('=')[0]
  9388. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  9389. str = str.trim().replace(INVALID_BASE64_RE, '')
  9390. // Node converts strings with length < 2 to ''
  9391. if (str.length < 2) return ''
  9392. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  9393. while (str.length % 4 !== 0) {
  9394. str = str + '='
  9395. }
  9396. return str
  9397. }
  9398. function toHex (n) {
  9399. if (n < 16) return '0' + n.toString(16)
  9400. return n.toString(16)
  9401. }
  9402. function utf8ToBytes (string, units) {
  9403. units = units || Infinity
  9404. var codePoint
  9405. var length = string.length
  9406. var leadSurrogate = null
  9407. var bytes = []
  9408. for (var i = 0; i < length; ++i) {
  9409. codePoint = string.charCodeAt(i)
  9410. // is surrogate component
  9411. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  9412. // last char was a lead
  9413. if (!leadSurrogate) {
  9414. // no lead yet
  9415. if (codePoint > 0xDBFF) {
  9416. // unexpected trail
  9417. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  9418. continue
  9419. } else if (i + 1 === length) {
  9420. // unpaired lead
  9421. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  9422. continue
  9423. }
  9424. // valid lead
  9425. leadSurrogate = codePoint
  9426. continue
  9427. }
  9428. // 2 leads in a row
  9429. if (codePoint < 0xDC00) {
  9430. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  9431. leadSurrogate = codePoint
  9432. continue
  9433. }
  9434. // valid surrogate pair
  9435. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  9436. } else if (leadSurrogate) {
  9437. // valid bmp char, but last char was a lead
  9438. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  9439. }
  9440. leadSurrogate = null
  9441. // encode utf8
  9442. if (codePoint < 0x80) {
  9443. if ((units -= 1) < 0) break
  9444. bytes.push(codePoint)
  9445. } else if (codePoint < 0x800) {
  9446. if ((units -= 2) < 0) break
  9447. bytes.push(
  9448. codePoint >> 0x6 | 0xC0,
  9449. codePoint & 0x3F | 0x80
  9450. )
  9451. } else if (codePoint < 0x10000) {
  9452. if ((units -= 3) < 0) break
  9453. bytes.push(
  9454. codePoint >> 0xC | 0xE0,
  9455. codePoint >> 0x6 & 0x3F | 0x80,
  9456. codePoint & 0x3F | 0x80
  9457. )
  9458. } else if (codePoint < 0x110000) {
  9459. if ((units -= 4) < 0) break
  9460. bytes.push(
  9461. codePoint >> 0x12 | 0xF0,
  9462. codePoint >> 0xC & 0x3F | 0x80,
  9463. codePoint >> 0x6 & 0x3F | 0x80,
  9464. codePoint & 0x3F | 0x80
  9465. )
  9466. } else {
  9467. throw new Error('Invalid code point')
  9468. }
  9469. }
  9470. return bytes
  9471. }
  9472. function asciiToBytes (str) {
  9473. var byteArray = []
  9474. for (var i = 0; i < str.length; ++i) {
  9475. // Node's code seems to be doing this and not & 0x7F..
  9476. byteArray.push(str.charCodeAt(i) & 0xFF)
  9477. }
  9478. return byteArray
  9479. }
  9480. function utf16leToBytes (str, units) {
  9481. var c, hi, lo
  9482. var byteArray = []
  9483. for (var i = 0; i < str.length; ++i) {
  9484. if ((units -= 2) < 0) break
  9485. c = str.charCodeAt(i)
  9486. hi = c >> 8
  9487. lo = c % 256
  9488. byteArray.push(lo)
  9489. byteArray.push(hi)
  9490. }
  9491. return byteArray
  9492. }
  9493. function base64ToBytes (str) {
  9494. return base64.toByteArray(base64clean(str))
  9495. }
  9496. function blitBuffer (src, dst, offset, length) {
  9497. for (var i = 0; i < length; ++i) {
  9498. if ((i + offset >= dst.length) || (i >= src.length)) break
  9499. dst[i + offset] = src[i]
  9500. }
  9501. return i
  9502. }
  9503. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  9504. // the `instanceof` check but they should be treated as of that type.
  9505. // See: https://github.com/feross/buffer/issues/166
  9506. function isInstance (obj, type) {
  9507. return obj instanceof type ||
  9508. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  9509. obj.constructor.name === type.name)
  9510. }
  9511. function numberIsNaN (obj) {
  9512. // For IE11 support
  9513. return obj !== obj // eslint-disable-line no-self-compare
  9514. }
  9515. }).call(this,require("buffer").Buffer)
  9516. },{"base64-js":39,"buffer":43,"ieee754":55}],44:[function(require,module,exports){
  9517. (function (Buffer){
  9518. // Copyright Joyent, Inc. and other Node contributors.
  9519. //
  9520. // Permission is hereby granted, free of charge, to any person obtaining a
  9521. // copy of this software and associated documentation files (the
  9522. // "Software"), to deal in the Software without restriction, including
  9523. // without limitation the rights to use, copy, modify, merge, publish,
  9524. // distribute, sublicense, and/or sell copies of the Software, and to permit
  9525. // persons to whom the Software is furnished to do so, subject to the
  9526. // following conditions:
  9527. //
  9528. // The above copyright notice and this permission notice shall be included
  9529. // in all copies or substantial portions of the Software.
  9530. //
  9531. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  9532. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  9533. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  9534. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  9535. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  9536. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  9537. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  9538. // NOTE: These type checking functions intentionally don't use `instanceof`
  9539. // because it is fragile and can be easily faked with `Object.create()`.
  9540. function isArray(arg) {
  9541. if (Array.isArray) {
  9542. return Array.isArray(arg);
  9543. }
  9544. return objectToString(arg) === '[object Array]';
  9545. }
  9546. exports.isArray = isArray;
  9547. function isBoolean(arg) {
  9548. return typeof arg === 'boolean';
  9549. }
  9550. exports.isBoolean = isBoolean;
  9551. function isNull(arg) {
  9552. return arg === null;
  9553. }
  9554. exports.isNull = isNull;
  9555. function isNullOrUndefined(arg) {
  9556. return arg == null;
  9557. }
  9558. exports.isNullOrUndefined = isNullOrUndefined;
  9559. function isNumber(arg) {
  9560. return typeof arg === 'number';
  9561. }
  9562. exports.isNumber = isNumber;
  9563. function isString(arg) {
  9564. return typeof arg === 'string';
  9565. }
  9566. exports.isString = isString;
  9567. function isSymbol(arg) {
  9568. return typeof arg === 'symbol';
  9569. }
  9570. exports.isSymbol = isSymbol;
  9571. function isUndefined(arg) {
  9572. return arg === void 0;
  9573. }
  9574. exports.isUndefined = isUndefined;
  9575. function isRegExp(re) {
  9576. return objectToString(re) === '[object RegExp]';
  9577. }
  9578. exports.isRegExp = isRegExp;
  9579. function isObject(arg) {
  9580. return typeof arg === 'object' && arg !== null;
  9581. }
  9582. exports.isObject = isObject;
  9583. function isDate(d) {
  9584. return objectToString(d) === '[object Date]';
  9585. }
  9586. exports.isDate = isDate;
  9587. function isError(e) {
  9588. return (objectToString(e) === '[object Error]' || e instanceof Error);
  9589. }
  9590. exports.isError = isError;
  9591. function isFunction(arg) {
  9592. return typeof arg === 'function';
  9593. }
  9594. exports.isFunction = isFunction;
  9595. function isPrimitive(arg) {
  9596. return arg === null ||
  9597. typeof arg === 'boolean' ||
  9598. typeof arg === 'number' ||
  9599. typeof arg === 'string' ||
  9600. typeof arg === 'symbol' || // ES6 symbol
  9601. typeof arg === 'undefined';
  9602. }
  9603. exports.isPrimitive = isPrimitive;
  9604. exports.isBuffer = Buffer.isBuffer;
  9605. function objectToString(o) {
  9606. return Object.prototype.toString.call(o);
  9607. }
  9608. }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
  9609. },{"../../is-buffer/index.js":57}],45:[function(require,module,exports){
  9610. (function (process){
  9611. "use strict";
  9612. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9613. /* eslint-env browser */
  9614. /**
  9615. * This is the web browser implementation of `debug()`.
  9616. */
  9617. exports.log = log;
  9618. exports.formatArgs = formatArgs;
  9619. exports.save = save;
  9620. exports.load = load;
  9621. exports.useColors = useColors;
  9622. exports.storage = localstorage();
  9623. /**
  9624. * Colors.
  9625. */
  9626. exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
  9627. /**
  9628. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  9629. * and the Firebug extension (any Firefox version) are known
  9630. * to support "%c" CSS customizations.
  9631. *
  9632. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  9633. */
  9634. // eslint-disable-next-line complexity
  9635. function useColors() {
  9636. // NB: In an Electron preload script, document will be defined but not fully
  9637. // initialized. Since we know we're in Chrome, we'll just detect this case
  9638. // explicitly
  9639. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  9640. return true;
  9641. } // Internet Explorer and Edge do not support colors.
  9642. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  9643. return false;
  9644. } // Is webkit? http://stackoverflow.com/a/16459606/376773
  9645. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  9646. return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
  9647. typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
  9648. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  9649. typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
  9650. typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
  9651. }
  9652. /**
  9653. * Colorize log arguments if enabled.
  9654. *
  9655. * @api public
  9656. */
  9657. function formatArgs(args) {
  9658. args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
  9659. if (!this.useColors) {
  9660. return;
  9661. }
  9662. var c = 'color: ' + this.color;
  9663. args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
  9664. // arguments passed either before or after the %c, so we need to
  9665. // figure out the correct index to insert the CSS into
  9666. var index = 0;
  9667. var lastC = 0;
  9668. args[0].replace(/%[a-zA-Z%]/g, function (match) {
  9669. if (match === '%%') {
  9670. return;
  9671. }
  9672. index++;
  9673. if (match === '%c') {
  9674. // We only are interested in the *last* %c
  9675. // (the user may have provided their own)
  9676. lastC = index;
  9677. }
  9678. });
  9679. args.splice(lastC, 0, c);
  9680. }
  9681. /**
  9682. * Invokes `console.log()` when available.
  9683. * No-op when `console.log` is not a "function".
  9684. *
  9685. * @api public
  9686. */
  9687. function log() {
  9688. var _console;
  9689. // This hackery is required for IE8/9, where
  9690. // the `console.log` function doesn't have 'apply'
  9691. return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
  9692. }
  9693. /**
  9694. * Save `namespaces`.
  9695. *
  9696. * @param {String} namespaces
  9697. * @api private
  9698. */
  9699. function save(namespaces) {
  9700. try {
  9701. if (namespaces) {
  9702. exports.storage.setItem('debug', namespaces);
  9703. } else {
  9704. exports.storage.removeItem('debug');
  9705. }
  9706. } catch (error) {// Swallow
  9707. // XXX (@Qix-) should we be logging these?
  9708. }
  9709. }
  9710. /**
  9711. * Load `namespaces`.
  9712. *
  9713. * @return {String} returns the previously persisted debug modes
  9714. * @api private
  9715. */
  9716. function load() {
  9717. var r;
  9718. try {
  9719. r = exports.storage.getItem('debug');
  9720. } catch (error) {} // Swallow
  9721. // XXX (@Qix-) should we be logging these?
  9722. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  9723. if (!r && typeof process !== 'undefined' && 'env' in process) {
  9724. r = process.env.DEBUG;
  9725. }
  9726. return r;
  9727. }
  9728. /**
  9729. * Localstorage attempts to return the localstorage.
  9730. *
  9731. * This is necessary because safari throws
  9732. * when a user disables cookies/localstorage
  9733. * and you attempt to access it.
  9734. *
  9735. * @return {LocalStorage}
  9736. * @api private
  9737. */
  9738. function localstorage() {
  9739. try {
  9740. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  9741. // The Browser also has localStorage in the global context.
  9742. return localStorage;
  9743. } catch (error) {// Swallow
  9744. // XXX (@Qix-) should we be logging these?
  9745. }
  9746. }
  9747. module.exports = require('./common')(exports);
  9748. var formatters = module.exports.formatters;
  9749. /**
  9750. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  9751. */
  9752. formatters.j = function (v) {
  9753. try {
  9754. return JSON.stringify(v);
  9755. } catch (error) {
  9756. return '[UnexpectedJSONParseError]: ' + error.message;
  9757. }
  9758. };
  9759. }).call(this,require('_process'))
  9760. },{"./common":46,"_process":69}],46:[function(require,module,exports){
  9761. "use strict";
  9762. /**
  9763. * This is the common logic for both the Node.js and web browser
  9764. * implementations of `debug()`.
  9765. */
  9766. function setup(env) {
  9767. createDebug.debug = createDebug;
  9768. createDebug.default = createDebug;
  9769. createDebug.coerce = coerce;
  9770. createDebug.disable = disable;
  9771. createDebug.enable = enable;
  9772. createDebug.enabled = enabled;
  9773. createDebug.humanize = require('ms');
  9774. Object.keys(env).forEach(function (key) {
  9775. createDebug[key] = env[key];
  9776. });
  9777. /**
  9778. * Active `debug` instances.
  9779. */
  9780. createDebug.instances = [];
  9781. /**
  9782. * The currently active debug mode names, and names to skip.
  9783. */
  9784. createDebug.names = [];
  9785. createDebug.skips = [];
  9786. /**
  9787. * Map of special "%n" handling functions, for the debug "format" argument.
  9788. *
  9789. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  9790. */
  9791. createDebug.formatters = {};
  9792. /**
  9793. * Selects a color for a debug namespace
  9794. * @param {String} namespace The namespace string for the for the debug instance to be colored
  9795. * @return {Number|String} An ANSI color code for the given namespace
  9796. * @api private
  9797. */
  9798. function selectColor(namespace) {
  9799. var hash = 0;
  9800. for (var i = 0; i < namespace.length; i++) {
  9801. hash = (hash << 5) - hash + namespace.charCodeAt(i);
  9802. hash |= 0; // Convert to 32bit integer
  9803. }
  9804. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  9805. }
  9806. createDebug.selectColor = selectColor;
  9807. /**
  9808. * Create a debugger with the given `namespace`.
  9809. *
  9810. * @param {String} namespace
  9811. * @return {Function}
  9812. * @api public
  9813. */
  9814. function createDebug(namespace) {
  9815. var prevTime;
  9816. function debug() {
  9817. // Disabled?
  9818. if (!debug.enabled) {
  9819. return;
  9820. }
  9821. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  9822. args[_key] = arguments[_key];
  9823. }
  9824. var self = debug; // Set `diff` timestamp
  9825. var curr = Number(new Date());
  9826. var ms = curr - (prevTime || curr);
  9827. self.diff = ms;
  9828. self.prev = prevTime;
  9829. self.curr = curr;
  9830. prevTime = curr;
  9831. args[0] = createDebug.coerce(args[0]);
  9832. if (typeof args[0] !== 'string') {
  9833. // Anything else let's inspect with %O
  9834. args.unshift('%O');
  9835. } // Apply any `formatters` transformations
  9836. var index = 0;
  9837. args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
  9838. // If we encounter an escaped % then don't increase the array index
  9839. if (match === '%%') {
  9840. return match;
  9841. }
  9842. index++;
  9843. var formatter = createDebug.formatters[format];
  9844. if (typeof formatter === 'function') {
  9845. var val = args[index];
  9846. match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
  9847. args.splice(index, 1);
  9848. index--;
  9849. }
  9850. return match;
  9851. }); // Apply env-specific formatting (colors, etc.)
  9852. createDebug.formatArgs.call(self, args);
  9853. var logFn = self.log || createDebug.log;
  9854. logFn.apply(self, args);
  9855. }
  9856. debug.namespace = namespace;
  9857. debug.enabled = createDebug.enabled(namespace);
  9858. debug.useColors = createDebug.useColors();
  9859. debug.color = selectColor(namespace);
  9860. debug.destroy = destroy;
  9861. debug.extend = extend; // Debug.formatArgs = formatArgs;
  9862. // debug.rawLog = rawLog;
  9863. // env-specific initialization logic for debug instances
  9864. if (typeof createDebug.init === 'function') {
  9865. createDebug.init(debug);
  9866. }
  9867. createDebug.instances.push(debug);
  9868. return debug;
  9869. }
  9870. function destroy() {
  9871. var index = createDebug.instances.indexOf(this);
  9872. if (index !== -1) {
  9873. createDebug.instances.splice(index, 1);
  9874. return true;
  9875. }
  9876. return false;
  9877. }
  9878. function extend(namespace, delimiter) {
  9879. return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  9880. }
  9881. /**
  9882. * Enables a debug mode by namespaces. This can include modes
  9883. * separated by a colon and wildcards.
  9884. *
  9885. * @param {String} namespaces
  9886. * @api public
  9887. */
  9888. function enable(namespaces) {
  9889. createDebug.save(namespaces);
  9890. createDebug.names = [];
  9891. createDebug.skips = [];
  9892. var i;
  9893. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  9894. var len = split.length;
  9895. for (i = 0; i < len; i++) {
  9896. if (!split[i]) {
  9897. // ignore empty strings
  9898. continue;
  9899. }
  9900. namespaces = split[i].replace(/\*/g, '.*?');
  9901. if (namespaces[0] === '-') {
  9902. createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  9903. } else {
  9904. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  9905. }
  9906. }
  9907. for (i = 0; i < createDebug.instances.length; i++) {
  9908. var instance = createDebug.instances[i];
  9909. instance.enabled = createDebug.enabled(instance.namespace);
  9910. }
  9911. }
  9912. /**
  9913. * Disable debug output.
  9914. *
  9915. * @api public
  9916. */
  9917. function disable() {
  9918. createDebug.enable('');
  9919. }
  9920. /**
  9921. * Returns true if the given mode name is enabled, false otherwise.
  9922. *
  9923. * @param {String} name
  9924. * @return {Boolean}
  9925. * @api public
  9926. */
  9927. function enabled(name) {
  9928. if (name[name.length - 1] === '*') {
  9929. return true;
  9930. }
  9931. var i;
  9932. var len;
  9933. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  9934. if (createDebug.skips[i].test(name)) {
  9935. return false;
  9936. }
  9937. }
  9938. for (i = 0, len = createDebug.names.length; i < len; i++) {
  9939. if (createDebug.names[i].test(name)) {
  9940. return true;
  9941. }
  9942. }
  9943. return false;
  9944. }
  9945. /**
  9946. * Coerce `val`.
  9947. *
  9948. * @param {Mixed} val
  9949. * @return {Mixed}
  9950. * @api private
  9951. */
  9952. function coerce(val) {
  9953. if (val instanceof Error) {
  9954. return val.stack || val.message;
  9955. }
  9956. return val;
  9957. }
  9958. createDebug.enable(createDebug.load());
  9959. return createDebug;
  9960. }
  9961. module.exports = setup;
  9962. },{"ms":60}],47:[function(require,module,exports){
  9963. 'use strict';
  9964. var keys = require('object-keys');
  9965. var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
  9966. var toStr = Object.prototype.toString;
  9967. var concat = Array.prototype.concat;
  9968. var origDefineProperty = Object.defineProperty;
  9969. var isFunction = function (fn) {
  9970. return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
  9971. };
  9972. var arePropertyDescriptorsSupported = function () {
  9973. var obj = {};
  9974. try {
  9975. origDefineProperty(obj, 'x', { enumerable: false, value: obj });
  9976. // eslint-disable-next-line no-unused-vars, no-restricted-syntax
  9977. for (var _ in obj) { // jscs:ignore disallowUnusedVariables
  9978. return false;
  9979. }
  9980. return obj.x === obj;
  9981. } catch (e) { /* this is IE 8. */
  9982. return false;
  9983. }
  9984. };
  9985. var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
  9986. var defineProperty = function (object, name, value, predicate) {
  9987. if (name in object && (!isFunction(predicate) || !predicate())) {
  9988. return;
  9989. }
  9990. if (supportsDescriptors) {
  9991. origDefineProperty(object, name, {
  9992. configurable: true,
  9993. enumerable: false,
  9994. value: value,
  9995. writable: true
  9996. });
  9997. } else {
  9998. object[name] = value;
  9999. }
  10000. };
  10001. var defineProperties = function (object, map) {
  10002. var predicates = arguments.length > 2 ? arguments[2] : {};
  10003. var props = keys(map);
  10004. if (hasSymbols) {
  10005. props = concat.call(props, Object.getOwnPropertySymbols(map));
  10006. }
  10007. for (var i = 0; i < props.length; i += 1) {
  10008. defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
  10009. }
  10010. };
  10011. defineProperties.supportsDescriptors = !!supportsDescriptors;
  10012. module.exports = defineProperties;
  10013. },{"object-keys":62}],48:[function(require,module,exports){
  10014. /*!
  10015. diff v3.5.0
  10016. Software License Agreement (BSD License)
  10017. Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
  10018. All rights reserved.
  10019. Redistribution and use of this software in source and binary forms, with or without modification,
  10020. are permitted provided that the following conditions are met:
  10021. * Redistributions of source code must retain the above
  10022. copyright notice, this list of conditions and the
  10023. following disclaimer.
  10024. * Redistributions in binary form must reproduce the above
  10025. copyright notice, this list of conditions and the
  10026. following disclaimer in the documentation and/or other
  10027. materials provided with the distribution.
  10028. * Neither the name of Kevin Decker nor the names of its
  10029. contributors may be used to endorse or promote products
  10030. derived from this software without specific prior
  10031. written permission.
  10032. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  10033. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  10034. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  10035. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  10036. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10037. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  10038. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  10039. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10040. @license
  10041. */
  10042. (function webpackUniversalModuleDefinition(root, factory) {
  10043. if(typeof exports === 'object' && typeof module === 'object')
  10044. module.exports = factory();
  10045. else if(false)
  10046. define([], factory);
  10047. else if(typeof exports === 'object')
  10048. exports["JsDiff"] = factory();
  10049. else
  10050. root["JsDiff"] = factory();
  10051. })(this, function() {
  10052. return /******/ (function(modules) { // webpackBootstrap
  10053. /******/ // The module cache
  10054. /******/ var installedModules = {};
  10055. /******/ // The require function
  10056. /******/ function __webpack_require__(moduleId) {
  10057. /******/ // Check if module is in cache
  10058. /******/ if(installedModules[moduleId])
  10059. /******/ return installedModules[moduleId].exports;
  10060. /******/ // Create a new module (and put it into the cache)
  10061. /******/ var module = installedModules[moduleId] = {
  10062. /******/ exports: {},
  10063. /******/ id: moduleId,
  10064. /******/ loaded: false
  10065. /******/ };
  10066. /******/ // Execute the module function
  10067. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  10068. /******/ // Flag the module as loaded
  10069. /******/ module.loaded = true;
  10070. /******/ // Return the exports of the module
  10071. /******/ return module.exports;
  10072. /******/ }
  10073. /******/ // expose the modules object (__webpack_modules__)
  10074. /******/ __webpack_require__.m = modules;
  10075. /******/ // expose the module cache
  10076. /******/ __webpack_require__.c = installedModules;
  10077. /******/ // __webpack_public_path__
  10078. /******/ __webpack_require__.p = "";
  10079. /******/ // Load entry module and return exports
  10080. /******/ return __webpack_require__(0);
  10081. /******/ })
  10082. /************************************************************************/
  10083. /******/ ([
  10084. /* 0 */
  10085. /***/ (function(module, exports, __webpack_require__) {
  10086. /*istanbul ignore start*/'use strict';
  10087. exports.__esModule = true;
  10088. exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = exports.merge = exports.parsePatch = exports.applyPatches = exports.applyPatch = exports.createPatch = exports.createTwoFilesPatch = exports.structuredPatch = exports.diffArrays = exports.diffJson = exports.diffCss = exports.diffSentences = exports.diffTrimmedLines = exports.diffLines = exports.diffWordsWithSpace = exports.diffWords = exports.diffChars = exports.Diff = undefined;
  10089. /*istanbul ignore end*/var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  10090. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  10091. /*istanbul ignore end*/var /*istanbul ignore start*/_character = __webpack_require__(2) /*istanbul ignore end*/;
  10092. var /*istanbul ignore start*/_word = __webpack_require__(3) /*istanbul ignore end*/;
  10093. var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
  10094. var /*istanbul ignore start*/_sentence = __webpack_require__(6) /*istanbul ignore end*/;
  10095. var /*istanbul ignore start*/_css = __webpack_require__(7) /*istanbul ignore end*/;
  10096. var /*istanbul ignore start*/_json = __webpack_require__(8) /*istanbul ignore end*/;
  10097. var /*istanbul ignore start*/_array = __webpack_require__(9) /*istanbul ignore end*/;
  10098. var /*istanbul ignore start*/_apply = __webpack_require__(10) /*istanbul ignore end*/;
  10099. var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
  10100. var /*istanbul ignore start*/_merge = __webpack_require__(13) /*istanbul ignore end*/;
  10101. var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
  10102. var /*istanbul ignore start*/_dmp = __webpack_require__(16) /*istanbul ignore end*/;
  10103. var /*istanbul ignore start*/_xml = __webpack_require__(17) /*istanbul ignore end*/;
  10104. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10105. /* See LICENSE file for terms of use */
  10106. /*
  10107. * Text diff implementation.
  10108. *
  10109. * This library supports the following APIS:
  10110. * JsDiff.diffChars: Character by character diff
  10111. * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
  10112. * JsDiff.diffLines: Line based diff
  10113. *
  10114. * JsDiff.diffCss: Diff targeted at CSS content
  10115. *
  10116. * These methods are based on the implementation proposed in
  10117. * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
  10118. * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
  10119. */
  10120. exports. /*istanbul ignore end*/Diff = _base2['default'];
  10121. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars;
  10122. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords;
  10123. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace;
  10124. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines;
  10125. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines;
  10126. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences;
  10127. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss;
  10128. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson;
  10129. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays;
  10130. /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch;
  10131. /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch;
  10132. /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch;
  10133. /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch;
  10134. /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches;
  10135. /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch;
  10136. /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = _merge.merge;
  10137. /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP;
  10138. /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML;
  10139. /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize;
  10140. /***/ }),
  10141. /* 1 */
  10142. /***/ (function(module, exports) {
  10143. /*istanbul ignore start*/'use strict';
  10144. exports.__esModule = true;
  10145. exports['default'] = /*istanbul ignore end*/Diff;
  10146. function Diff() {}
  10147. Diff.prototype = {
  10148. /*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) {
  10149. /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  10150. var callback = options.callback;
  10151. if (typeof options === 'function') {
  10152. callback = options;
  10153. options = {};
  10154. }
  10155. this.options = options;
  10156. var self = this;
  10157. function done(value) {
  10158. if (callback) {
  10159. setTimeout(function () {
  10160. callback(undefined, value);
  10161. }, 0);
  10162. return true;
  10163. } else {
  10164. return value;
  10165. }
  10166. }
  10167. // Allow subclasses to massage the input prior to running
  10168. oldString = this.castInput(oldString);
  10169. newString = this.castInput(newString);
  10170. oldString = this.removeEmpty(this.tokenize(oldString));
  10171. newString = this.removeEmpty(this.tokenize(newString));
  10172. var newLen = newString.length,
  10173. oldLen = oldString.length;
  10174. var editLength = 1;
  10175. var maxEditLength = newLen + oldLen;
  10176. var bestPath = [{ newPos: -1, components: [] }];
  10177. // Seed editLength = 0, i.e. the content starts with the same values
  10178. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  10179. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  10180. // Identity per the equality and tokenizer
  10181. return done([{ value: this.join(newString), count: newString.length }]);
  10182. }
  10183. // Main worker method. checks all permutations of a given edit length for acceptance.
  10184. function execEditLength() {
  10185. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  10186. var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  10187. var addPath = bestPath[diagonalPath - 1],
  10188. removePath = bestPath[diagonalPath + 1],
  10189. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  10190. if (addPath) {
  10191. // No one else is going to attempt to use this value, clear it
  10192. bestPath[diagonalPath - 1] = undefined;
  10193. }
  10194. var canAdd = addPath && addPath.newPos + 1 < newLen,
  10195. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  10196. if (!canAdd && !canRemove) {
  10197. // If this path is a terminal then prune
  10198. bestPath[diagonalPath] = undefined;
  10199. continue;
  10200. }
  10201. // Select the diagonal that we want to branch from. We select the prior
  10202. // path whose position in the new string is the farthest from the origin
  10203. // and does not pass the bounds of the diff graph
  10204. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  10205. basePath = clonePath(removePath);
  10206. self.pushComponent(basePath.components, undefined, true);
  10207. } else {
  10208. basePath = addPath; // No need to clone, we've pulled it from the list
  10209. basePath.newPos++;
  10210. self.pushComponent(basePath.components, true, undefined);
  10211. }
  10212. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
  10213. // If we have hit the end of both strings, then we are done
  10214. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  10215. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  10216. } else {
  10217. // Otherwise track this path as a potential candidate and continue.
  10218. bestPath[diagonalPath] = basePath;
  10219. }
  10220. }
  10221. editLength++;
  10222. }
  10223. // Performs the length of edit iteration. Is a bit fugly as this has to support the
  10224. // sync and async mode which is never fun. Loops over execEditLength until a value
  10225. // is produced.
  10226. if (callback) {
  10227. (function exec() {
  10228. setTimeout(function () {
  10229. // This should not happen, but we want to be safe.
  10230. /* istanbul ignore next */
  10231. if (editLength > maxEditLength) {
  10232. return callback();
  10233. }
  10234. if (!execEditLength()) {
  10235. exec();
  10236. }
  10237. }, 0);
  10238. })();
  10239. } else {
  10240. while (editLength <= maxEditLength) {
  10241. var ret = execEditLength();
  10242. if (ret) {
  10243. return ret;
  10244. }
  10245. }
  10246. }
  10247. },
  10248. /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) {
  10249. var last = components[components.length - 1];
  10250. if (last && last.added === added && last.removed === removed) {
  10251. // We need to clone here as the component clone operation is just
  10252. // as shallow array clone
  10253. components[components.length - 1] = { count: last.count + 1, added: added, removed: removed };
  10254. } else {
  10255. components.push({ count: 1, added: added, removed: removed });
  10256. }
  10257. },
  10258. /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  10259. var newLen = newString.length,
  10260. oldLen = oldString.length,
  10261. newPos = basePath.newPos,
  10262. oldPos = newPos - diagonalPath,
  10263. commonCount = 0;
  10264. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  10265. newPos++;
  10266. oldPos++;
  10267. commonCount++;
  10268. }
  10269. if (commonCount) {
  10270. basePath.components.push({ count: commonCount });
  10271. }
  10272. basePath.newPos = newPos;
  10273. return oldPos;
  10274. },
  10275. /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
  10276. if (this.options.comparator) {
  10277. return this.options.comparator(left, right);
  10278. } else {
  10279. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  10280. }
  10281. },
  10282. /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
  10283. var ret = [];
  10284. for (var i = 0; i < array.length; i++) {
  10285. if (array[i]) {
  10286. ret.push(array[i]);
  10287. }
  10288. }
  10289. return ret;
  10290. },
  10291. /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) {
  10292. return value;
  10293. },
  10294. /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) {
  10295. return value.split('');
  10296. },
  10297. /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) {
  10298. return chars.join('');
  10299. }
  10300. };
  10301. function buildValues(diff, components, newString, oldString, useLongestToken) {
  10302. var componentPos = 0,
  10303. componentLen = components.length,
  10304. newPos = 0,
  10305. oldPos = 0;
  10306. for (; componentPos < componentLen; componentPos++) {
  10307. var component = components[componentPos];
  10308. if (!component.removed) {
  10309. if (!component.added && useLongestToken) {
  10310. var value = newString.slice(newPos, newPos + component.count);
  10311. value = value.map(function (value, i) {
  10312. var oldValue = oldString[oldPos + i];
  10313. return oldValue.length > value.length ? oldValue : value;
  10314. });
  10315. component.value = diff.join(value);
  10316. } else {
  10317. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  10318. }
  10319. newPos += component.count;
  10320. // Common case
  10321. if (!component.added) {
  10322. oldPos += component.count;
  10323. }
  10324. } else {
  10325. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  10326. oldPos += component.count;
  10327. // Reverse add and remove so removes are output first to match common convention
  10328. // The diffing algorithm is tied to add then remove output and this is the simplest
  10329. // route to get the desired output with minimal overhead.
  10330. if (componentPos && components[componentPos - 1].added) {
  10331. var tmp = components[componentPos - 1];
  10332. components[componentPos - 1] = components[componentPos];
  10333. components[componentPos] = tmp;
  10334. }
  10335. }
  10336. }
  10337. // Special case handle for when one terminal is ignored (i.e. whitespace).
  10338. // For this case we merge the terminal into the prior string and drop the change.
  10339. // This is only available for string mode.
  10340. var lastComponent = components[componentLen - 1];
  10341. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  10342. components[componentLen - 2].value += lastComponent.value;
  10343. components.pop();
  10344. }
  10345. return components;
  10346. }
  10347. function clonePath(path) {
  10348. return { newPos: path.newPos, components: path.components.slice(0) };
  10349. }
  10350. /***/ }),
  10351. /* 2 */
  10352. /***/ (function(module, exports, __webpack_require__) {
  10353. /*istanbul ignore start*/'use strict';
  10354. exports.__esModule = true;
  10355. exports.characterDiff = undefined;
  10356. exports. /*istanbul ignore end*/diffChars = diffChars;
  10357. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  10358. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  10359. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10360. /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  10361. function diffChars(oldStr, newStr, options) {
  10362. return characterDiff.diff(oldStr, newStr, options);
  10363. }
  10364. /***/ }),
  10365. /* 3 */
  10366. /***/ (function(module, exports, __webpack_require__) {
  10367. /*istanbul ignore start*/'use strict';
  10368. exports.__esModule = true;
  10369. exports.wordDiff = undefined;
  10370. exports. /*istanbul ignore end*/diffWords = diffWords;
  10371. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace;
  10372. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  10373. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  10374. /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
  10375. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10376. /*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  10377. //
  10378. // Ranges and exceptions:
  10379. // Latin-1 Supplement, 0080–00FF
  10380. // - U+00D7 × Multiplication sign
  10381. // - U+00F7 ÷ Division sign
  10382. // Latin Extended-A, 0100–017F
  10383. // Latin Extended-B, 0180–024F
  10384. // IPA Extensions, 0250–02AF
  10385. // Spacing Modifier Letters, 02B0–02FF
  10386. // - U+02C7 ˇ &#711; Caron
  10387. // - U+02D8 ˘ &#728; Breve
  10388. // - U+02D9 ˙ &#729; Dot Above
  10389. // - U+02DA ˚ &#730; Ring Above
  10390. // - U+02DB ˛ &#731; Ogonek
  10391. // - U+02DC ˜ &#732; Small Tilde
  10392. // - U+02DD ˝ &#733; Double Acute Accent
  10393. // Latin Extended Additional, 1E00–1EFF
  10394. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  10395. var reWhitespace = /\S/;
  10396. var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  10397. wordDiff.equals = function (left, right) {
  10398. if (this.options.ignoreCase) {
  10399. left = left.toLowerCase();
  10400. right = right.toLowerCase();
  10401. }
  10402. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  10403. };
  10404. wordDiff.tokenize = function (value) {
  10405. var tokens = value.split(/(\s+|\b)/);
  10406. // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  10407. for (var i = 0; i < tokens.length - 1; i++) {
  10408. // If we have an empty string in the next field and we have only word chars before and after, merge
  10409. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  10410. tokens[i] += tokens[i + 2];
  10411. tokens.splice(i + 1, 2);
  10412. i--;
  10413. }
  10414. }
  10415. return tokens;
  10416. };
  10417. function diffWords(oldStr, newStr, options) {
  10418. options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(options, { ignoreWhitespace: true });
  10419. return wordDiff.diff(oldStr, newStr, options);
  10420. }
  10421. function diffWordsWithSpace(oldStr, newStr, options) {
  10422. return wordDiff.diff(oldStr, newStr, options);
  10423. }
  10424. /***/ }),
  10425. /* 4 */
  10426. /***/ (function(module, exports) {
  10427. /*istanbul ignore start*/'use strict';
  10428. exports.__esModule = true;
  10429. exports. /*istanbul ignore end*/generateOptions = generateOptions;
  10430. function generateOptions(options, defaults) {
  10431. if (typeof options === 'function') {
  10432. defaults.callback = options;
  10433. } else if (options) {
  10434. for (var name in options) {
  10435. /* istanbul ignore else */
  10436. if (options.hasOwnProperty(name)) {
  10437. defaults[name] = options[name];
  10438. }
  10439. }
  10440. }
  10441. return defaults;
  10442. }
  10443. /***/ }),
  10444. /* 5 */
  10445. /***/ (function(module, exports, __webpack_require__) {
  10446. /*istanbul ignore start*/'use strict';
  10447. exports.__esModule = true;
  10448. exports.lineDiff = undefined;
  10449. exports. /*istanbul ignore end*/diffLines = diffLines;
  10450. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines;
  10451. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  10452. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  10453. /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
  10454. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10455. /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  10456. lineDiff.tokenize = function (value) {
  10457. var retLines = [],
  10458. linesAndNewlines = value.split(/(\n|\r\n)/);
  10459. // Ignore the final empty token that occurs if the string ends with a new line
  10460. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  10461. linesAndNewlines.pop();
  10462. }
  10463. // Merge the content and line separators into single tokens
  10464. for (var i = 0; i < linesAndNewlines.length; i++) {
  10465. var line = linesAndNewlines[i];
  10466. if (i % 2 && !this.options.newlineIsToken) {
  10467. retLines[retLines.length - 1] += line;
  10468. } else {
  10469. if (this.options.ignoreWhitespace) {
  10470. line = line.trim();
  10471. }
  10472. retLines.push(line);
  10473. }
  10474. }
  10475. return retLines;
  10476. };
  10477. function diffLines(oldStr, newStr, callback) {
  10478. return lineDiff.diff(oldStr, newStr, callback);
  10479. }
  10480. function diffTrimmedLines(oldStr, newStr, callback) {
  10481. var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
  10482. return lineDiff.diff(oldStr, newStr, options);
  10483. }
  10484. /***/ }),
  10485. /* 6 */
  10486. /***/ (function(module, exports, __webpack_require__) {
  10487. /*istanbul ignore start*/'use strict';
  10488. exports.__esModule = true;
  10489. exports.sentenceDiff = undefined;
  10490. exports. /*istanbul ignore end*/diffSentences = diffSentences;
  10491. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  10492. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  10493. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10494. /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  10495. sentenceDiff.tokenize = function (value) {
  10496. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  10497. };
  10498. function diffSentences(oldStr, newStr, callback) {
  10499. return sentenceDiff.diff(oldStr, newStr, callback);
  10500. }
  10501. /***/ }),
  10502. /* 7 */
  10503. /***/ (function(module, exports, __webpack_require__) {
  10504. /*istanbul ignore start*/'use strict';
  10505. exports.__esModule = true;
  10506. exports.cssDiff = undefined;
  10507. exports. /*istanbul ignore end*/diffCss = diffCss;
  10508. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  10509. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  10510. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10511. /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  10512. cssDiff.tokenize = function (value) {
  10513. return value.split(/([{}:;,]|\s+)/);
  10514. };
  10515. function diffCss(oldStr, newStr, callback) {
  10516. return cssDiff.diff(oldStr, newStr, callback);
  10517. }
  10518. /***/ }),
  10519. /* 8 */
  10520. /***/ (function(module, exports, __webpack_require__) {
  10521. /*istanbul ignore start*/'use strict';
  10522. exports.__esModule = true;
  10523. exports.jsonDiff = undefined;
  10524. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  10525. exports. /*istanbul ignore end*/diffJson = diffJson;
  10526. /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize;
  10527. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  10528. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  10529. /*istanbul ignore end*/var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
  10530. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10531. /*istanbul ignore end*/var objectPrototypeToString = Object.prototype.toString;
  10532. var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  10533. // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  10534. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  10535. jsonDiff.useLongestToken = true;
  10536. jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff /*istanbul ignore end*/.tokenize;
  10537. jsonDiff.castInput = function (value) {
  10538. /*istanbul ignore start*/var _options = /*istanbul ignore end*/this.options,
  10539. undefinedReplacement = _options.undefinedReplacement,
  10540. _options$stringifyRep = _options.stringifyReplacer,
  10541. stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) /*istanbul ignore start*/{
  10542. return (/*istanbul ignore end*/typeof v === 'undefined' ? undefinedReplacement : v
  10543. );
  10544. } : _options$stringifyRep;
  10545. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
  10546. };
  10547. jsonDiff.equals = function (left, right) {
  10548. return (/*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  10549. );
  10550. };
  10551. function diffJson(oldObj, newObj, options) {
  10552. return jsonDiff.diff(oldObj, newObj, options);
  10553. }
  10554. // This function handles the presence of circular references by bailing out when encountering an
  10555. // object that is already on the "stack" of items being processed. Accepts an optional replacer
  10556. function canonicalize(obj, stack, replacementStack, replacer, key) {
  10557. stack = stack || [];
  10558. replacementStack = replacementStack || [];
  10559. if (replacer) {
  10560. obj = replacer(key, obj);
  10561. }
  10562. var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  10563. for (i = 0; i < stack.length; i += 1) {
  10564. if (stack[i] === obj) {
  10565. return replacementStack[i];
  10566. }
  10567. }
  10568. var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  10569. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  10570. stack.push(obj);
  10571. canonicalizedObj = new Array(obj.length);
  10572. replacementStack.push(canonicalizedObj);
  10573. for (i = 0; i < obj.length; i += 1) {
  10574. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
  10575. }
  10576. stack.pop();
  10577. replacementStack.pop();
  10578. return canonicalizedObj;
  10579. }
  10580. if (obj && obj.toJSON) {
  10581. obj = obj.toJSON();
  10582. }
  10583. if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
  10584. stack.push(obj);
  10585. canonicalizedObj = {};
  10586. replacementStack.push(canonicalizedObj);
  10587. var sortedKeys = [],
  10588. _key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  10589. for (_key in obj) {
  10590. /* istanbul ignore else */
  10591. if (obj.hasOwnProperty(_key)) {
  10592. sortedKeys.push(_key);
  10593. }
  10594. }
  10595. sortedKeys.sort();
  10596. for (i = 0; i < sortedKeys.length; i += 1) {
  10597. _key = sortedKeys[i];
  10598. canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
  10599. }
  10600. stack.pop();
  10601. replacementStack.pop();
  10602. } else {
  10603. canonicalizedObj = obj;
  10604. }
  10605. return canonicalizedObj;
  10606. }
  10607. /***/ }),
  10608. /* 9 */
  10609. /***/ (function(module, exports, __webpack_require__) {
  10610. /*istanbul ignore start*/'use strict';
  10611. exports.__esModule = true;
  10612. exports.arrayDiff = undefined;
  10613. exports. /*istanbul ignore end*/diffArrays = diffArrays;
  10614. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  10615. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  10616. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10617. /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  10618. arrayDiff.tokenize = function (value) {
  10619. return value.slice();
  10620. };
  10621. arrayDiff.join = arrayDiff.removeEmpty = function (value) {
  10622. return value;
  10623. };
  10624. function diffArrays(oldArr, newArr, callback) {
  10625. return arrayDiff.diff(oldArr, newArr, callback);
  10626. }
  10627. /***/ }),
  10628. /* 10 */
  10629. /***/ (function(module, exports, __webpack_require__) {
  10630. /*istanbul ignore start*/'use strict';
  10631. exports.__esModule = true;
  10632. exports. /*istanbul ignore end*/applyPatch = applyPatch;
  10633. /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches;
  10634. var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
  10635. var /*istanbul ignore start*/_distanceIterator = __webpack_require__(12) /*istanbul ignore end*/;
  10636. /*istanbul ignore start*/var _distanceIterator2 = _interopRequireDefault(_distanceIterator);
  10637. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10638. /*istanbul ignore end*/function applyPatch(source, uniDiff) {
  10639. /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  10640. if (typeof uniDiff === 'string') {
  10641. uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
  10642. }
  10643. if (Array.isArray(uniDiff)) {
  10644. if (uniDiff.length > 1) {
  10645. throw new Error('applyPatch only works with a single input.');
  10646. }
  10647. uniDiff = uniDiff[0];
  10648. }
  10649. // Apply the diff to the input
  10650. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  10651. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  10652. hunks = uniDiff.hunks,
  10653. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{
  10654. return (/*istanbul ignore end*/line === patchContent
  10655. );
  10656. },
  10657. errorCount = 0,
  10658. fuzzFactor = options.fuzzFactor || 0,
  10659. minLine = 0,
  10660. offset = 0,
  10661. removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
  10662. addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  10663. /**
  10664. * Checks if the hunk exactly fits on the provided location
  10665. */
  10666. function hunkFits(hunk, toPos) {
  10667. for (var j = 0; j < hunk.lines.length; j++) {
  10668. var line = hunk.lines[j],
  10669. operation = line.length > 0 ? line[0] : ' ',
  10670. content = line.length > 0 ? line.substr(1) : line;
  10671. if (operation === ' ' || operation === '-') {
  10672. // Context sanity check
  10673. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  10674. errorCount++;
  10675. if (errorCount > fuzzFactor) {
  10676. return false;
  10677. }
  10678. }
  10679. toPos++;
  10680. }
  10681. }
  10682. return true;
  10683. }
  10684. // Search best fit offsets for each hunk based on the previous ones
  10685. for (var i = 0; i < hunks.length; i++) {
  10686. var hunk = hunks[i],
  10687. maxLine = lines.length - hunk.oldLines,
  10688. localOffset = 0,
  10689. toPos = offset + hunk.oldStart - 1;
  10690. var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine);
  10691. for (; localOffset !== undefined; localOffset = iterator()) {
  10692. if (hunkFits(hunk, toPos + localOffset)) {
  10693. hunk.offset = offset += localOffset;
  10694. break;
  10695. }
  10696. }
  10697. if (localOffset === undefined) {
  10698. return false;
  10699. }
  10700. // Set lower text limit to end of the current hunk, so next ones don't try
  10701. // to fit over already patched text
  10702. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  10703. }
  10704. // Apply patch hunks
  10705. var diffOffset = 0;
  10706. for (var _i = 0; _i < hunks.length; _i++) {
  10707. var _hunk = hunks[_i],
  10708. _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
  10709. diffOffset += _hunk.newLines - _hunk.oldLines;
  10710. if (_toPos < 0) {
  10711. // Creating a new file
  10712. _toPos = 0;
  10713. }
  10714. for (var j = 0; j < _hunk.lines.length; j++) {
  10715. var line = _hunk.lines[j],
  10716. operation = line.length > 0 ? line[0] : ' ',
  10717. content = line.length > 0 ? line.substr(1) : line,
  10718. delimiter = _hunk.linedelimiters[j];
  10719. if (operation === ' ') {
  10720. _toPos++;
  10721. } else if (operation === '-') {
  10722. lines.splice(_toPos, 1);
  10723. delimiters.splice(_toPos, 1);
  10724. /* istanbul ignore else */
  10725. } else if (operation === '+') {
  10726. lines.splice(_toPos, 0, content);
  10727. delimiters.splice(_toPos, 0, delimiter);
  10728. _toPos++;
  10729. } else if (operation === '\\') {
  10730. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  10731. if (previousOperation === '+') {
  10732. removeEOFNL = true;
  10733. } else if (previousOperation === '-') {
  10734. addEOFNL = true;
  10735. }
  10736. }
  10737. }
  10738. }
  10739. // Handle EOFNL insertion/removal
  10740. if (removeEOFNL) {
  10741. while (!lines[lines.length - 1]) {
  10742. lines.pop();
  10743. delimiters.pop();
  10744. }
  10745. } else if (addEOFNL) {
  10746. lines.push('');
  10747. delimiters.push('\n');
  10748. }
  10749. for (var _k = 0; _k < lines.length - 1; _k++) {
  10750. lines[_k] = lines[_k] + delimiters[_k];
  10751. }
  10752. return lines.join('');
  10753. }
  10754. // Wrapper that supports multiple file patches via callbacks.
  10755. function applyPatches(uniDiff, options) {
  10756. if (typeof uniDiff === 'string') {
  10757. uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
  10758. }
  10759. var currentIndex = 0;
  10760. function processIndex() {
  10761. var index = uniDiff[currentIndex++];
  10762. if (!index) {
  10763. return options.complete();
  10764. }
  10765. options.loadFile(index, function (err, data) {
  10766. if (err) {
  10767. return options.complete(err);
  10768. }
  10769. var updatedContent = applyPatch(data, index, options);
  10770. options.patched(index, updatedContent, function (err) {
  10771. if (err) {
  10772. return options.complete(err);
  10773. }
  10774. processIndex();
  10775. });
  10776. });
  10777. }
  10778. processIndex();
  10779. }
  10780. /***/ }),
  10781. /* 11 */
  10782. /***/ (function(module, exports) {
  10783. /*istanbul ignore start*/'use strict';
  10784. exports.__esModule = true;
  10785. exports. /*istanbul ignore end*/parsePatch = parsePatch;
  10786. function parsePatch(uniDiff) {
  10787. /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  10788. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  10789. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  10790. list = [],
  10791. i = 0;
  10792. function parseIndex() {
  10793. var index = {};
  10794. list.push(index);
  10795. // Parse diff metadata
  10796. while (i < diffstr.length) {
  10797. var line = diffstr[i];
  10798. // File header found, end parsing diff metadata
  10799. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  10800. break;
  10801. }
  10802. // Diff index
  10803. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  10804. if (header) {
  10805. index.index = header[1];
  10806. }
  10807. i++;
  10808. }
  10809. // Parse file headers if they are defined. Unified diff requires them, but
  10810. // there's no technical issues to have an isolated hunk without file header
  10811. parseFileHeader(index);
  10812. parseFileHeader(index);
  10813. // Parse hunks
  10814. index.hunks = [];
  10815. while (i < diffstr.length) {
  10816. var _line = diffstr[i];
  10817. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  10818. break;
  10819. } else if (/^@@/.test(_line)) {
  10820. index.hunks.push(parseHunk());
  10821. } else if (_line && options.strict) {
  10822. // Ignore unexpected content unless in strict mode
  10823. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  10824. } else {
  10825. i++;
  10826. }
  10827. }
  10828. }
  10829. // Parses the --- and +++ headers, if none are found, no lines
  10830. // are consumed.
  10831. function parseFileHeader(index) {
  10832. var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
  10833. if (fileHeader) {
  10834. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  10835. var data = fileHeader[2].split('\t', 2);
  10836. var fileName = data[0].replace(/\\\\/g, '\\');
  10837. if (/^".*"$/.test(fileName)) {
  10838. fileName = fileName.substr(1, fileName.length - 2);
  10839. }
  10840. index[keyPrefix + 'FileName'] = fileName;
  10841. index[keyPrefix + 'Header'] = (data[1] || '').trim();
  10842. i++;
  10843. }
  10844. }
  10845. // Parses a hunk
  10846. // This assumes that we are at the start of a hunk.
  10847. function parseHunk() {
  10848. var chunkHeaderIndex = i,
  10849. chunkHeaderLine = diffstr[i++],
  10850. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  10851. var hunk = {
  10852. oldStart: +chunkHeader[1],
  10853. oldLines: +chunkHeader[2] || 1,
  10854. newStart: +chunkHeader[3],
  10855. newLines: +chunkHeader[4] || 1,
  10856. lines: [],
  10857. linedelimiters: []
  10858. };
  10859. var addCount = 0,
  10860. removeCount = 0;
  10861. for (; i < diffstr.length; i++) {
  10862. // Lines starting with '---' could be mistaken for the "remove line" operation
  10863. // But they could be the header for the next file. Therefore prune such cases out.
  10864. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  10865. break;
  10866. }
  10867. var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
  10868. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  10869. hunk.lines.push(diffstr[i]);
  10870. hunk.linedelimiters.push(delimiters[i] || '\n');
  10871. if (operation === '+') {
  10872. addCount++;
  10873. } else if (operation === '-') {
  10874. removeCount++;
  10875. } else if (operation === ' ') {
  10876. addCount++;
  10877. removeCount++;
  10878. }
  10879. } else {
  10880. break;
  10881. }
  10882. }
  10883. // Handle the empty block count case
  10884. if (!addCount && hunk.newLines === 1) {
  10885. hunk.newLines = 0;
  10886. }
  10887. if (!removeCount && hunk.oldLines === 1) {
  10888. hunk.oldLines = 0;
  10889. }
  10890. // Perform optional sanity checking
  10891. if (options.strict) {
  10892. if (addCount !== hunk.newLines) {
  10893. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  10894. }
  10895. if (removeCount !== hunk.oldLines) {
  10896. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  10897. }
  10898. }
  10899. return hunk;
  10900. }
  10901. while (i < diffstr.length) {
  10902. parseIndex();
  10903. }
  10904. return list;
  10905. }
  10906. /***/ }),
  10907. /* 12 */
  10908. /***/ (function(module, exports) {
  10909. /*istanbul ignore start*/"use strict";
  10910. exports.__esModule = true;
  10911. exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) {
  10912. var wantForward = true,
  10913. backwardExhausted = false,
  10914. forwardExhausted = false,
  10915. localOffset = 1;
  10916. return function iterator() {
  10917. if (wantForward && !forwardExhausted) {
  10918. if (backwardExhausted) {
  10919. localOffset++;
  10920. } else {
  10921. wantForward = false;
  10922. }
  10923. // Check if trying to fit beyond text length, and if not, check it fits
  10924. // after offset location (or desired location on first iteration)
  10925. if (start + localOffset <= maxLine) {
  10926. return localOffset;
  10927. }
  10928. forwardExhausted = true;
  10929. }
  10930. if (!backwardExhausted) {
  10931. if (!forwardExhausted) {
  10932. wantForward = true;
  10933. }
  10934. // Check if trying to fit before text beginning, and if not, check it fits
  10935. // before offset location
  10936. if (minLine <= start - localOffset) {
  10937. return -localOffset++;
  10938. }
  10939. backwardExhausted = true;
  10940. return iterator();
  10941. }
  10942. // We tried to fit hunk before text beginning and beyond text length, then
  10943. // hunk can't fit on the text. Return undefined
  10944. };
  10945. };
  10946. /***/ }),
  10947. /* 13 */
  10948. /***/ (function(module, exports, __webpack_require__) {
  10949. /*istanbul ignore start*/'use strict';
  10950. exports.__esModule = true;
  10951. exports. /*istanbul ignore end*/calcLineCount = calcLineCount;
  10952. /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge;
  10953. var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
  10954. var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
  10955. var /*istanbul ignore start*/_array = __webpack_require__(15) /*istanbul ignore end*/;
  10956. /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  10957. /*istanbul ignore end*/function calcLineCount(hunk) {
  10958. /*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines),
  10959. oldLines = _calcOldNewLineCount.oldLines,
  10960. newLines = _calcOldNewLineCount.newLines;
  10961. if (oldLines !== undefined) {
  10962. hunk.oldLines = oldLines;
  10963. } else {
  10964. delete hunk.oldLines;
  10965. }
  10966. if (newLines !== undefined) {
  10967. hunk.newLines = newLines;
  10968. } else {
  10969. delete hunk.newLines;
  10970. }
  10971. }
  10972. function merge(mine, theirs, base) {
  10973. mine = loadPatch(mine, base);
  10974. theirs = loadPatch(theirs, base);
  10975. var ret = {};
  10976. // For index we just let it pass through as it doesn't have any necessary meaning.
  10977. // Leaving sanity checks on this to the API consumer that may know more about the
  10978. // meaning in their own context.
  10979. if (mine.index || theirs.index) {
  10980. ret.index = mine.index || theirs.index;
  10981. }
  10982. if (mine.newFileName || theirs.newFileName) {
  10983. if (!fileNameChanged(mine)) {
  10984. // No header or no change in ours, use theirs (and ours if theirs does not exist)
  10985. ret.oldFileName = theirs.oldFileName || mine.oldFileName;
  10986. ret.newFileName = theirs.newFileName || mine.newFileName;
  10987. ret.oldHeader = theirs.oldHeader || mine.oldHeader;
  10988. ret.newHeader = theirs.newHeader || mine.newHeader;
  10989. } else if (!fileNameChanged(theirs)) {
  10990. // No header or no change in theirs, use ours
  10991. ret.oldFileName = mine.oldFileName;
  10992. ret.newFileName = mine.newFileName;
  10993. ret.oldHeader = mine.oldHeader;
  10994. ret.newHeader = mine.newHeader;
  10995. } else {
  10996. // Both changed... figure it out
  10997. ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
  10998. ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
  10999. ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
  11000. ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
  11001. }
  11002. }
  11003. ret.hunks = [];
  11004. var mineIndex = 0,
  11005. theirsIndex = 0,
  11006. mineOffset = 0,
  11007. theirsOffset = 0;
  11008. while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
  11009. var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity },
  11010. theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity };
  11011. if (hunkBefore(mineCurrent, theirsCurrent)) {
  11012. // This patch does not overlap with any of the others, yay.
  11013. ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
  11014. mineIndex++;
  11015. theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
  11016. } else if (hunkBefore(theirsCurrent, mineCurrent)) {
  11017. // This patch does not overlap with any of the others, yay.
  11018. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
  11019. theirsIndex++;
  11020. mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
  11021. } else {
  11022. // Overlap, merge as best we can
  11023. var mergedHunk = {
  11024. oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
  11025. oldLines: 0,
  11026. newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
  11027. newLines: 0,
  11028. lines: []
  11029. };
  11030. mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
  11031. theirsIndex++;
  11032. mineIndex++;
  11033. ret.hunks.push(mergedHunk);
  11034. }
  11035. }
  11036. return ret;
  11037. }
  11038. function loadPatch(param, base) {
  11039. if (typeof param === 'string') {
  11040. if (/^@@/m.test(param) || /^Index:/m.test(param)) {
  11041. return (/*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(param)[0]
  11042. );
  11043. }
  11044. if (!base) {
  11045. throw new Error('Must provide a base reference or pass in a patch');
  11046. }
  11047. return (/*istanbul ignore start*/(0, _create.structuredPatch) /*istanbul ignore end*/(undefined, undefined, base, param)
  11048. );
  11049. }
  11050. return param;
  11051. }
  11052. function fileNameChanged(patch) {
  11053. return patch.newFileName && patch.newFileName !== patch.oldFileName;
  11054. }
  11055. function selectField(index, mine, theirs) {
  11056. if (mine === theirs) {
  11057. return mine;
  11058. } else {
  11059. index.conflict = true;
  11060. return { mine: mine, theirs: theirs };
  11061. }
  11062. }
  11063. function hunkBefore(test, check) {
  11064. return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
  11065. }
  11066. function cloneHunk(hunk, offset) {
  11067. return {
  11068. oldStart: hunk.oldStart, oldLines: hunk.oldLines,
  11069. newStart: hunk.newStart + offset, newLines: hunk.newLines,
  11070. lines: hunk.lines
  11071. };
  11072. }
  11073. function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
  11074. // This will generally result in a conflicted hunk, but there are cases where the context
  11075. // is the only overlap where we can successfully merge the content here.
  11076. var mine = { offset: mineOffset, lines: mineLines, index: 0 },
  11077. their = { offset: theirOffset, lines: theirLines, index: 0 };
  11078. // Handle any leading content
  11079. insertLeading(hunk, mine, their);
  11080. insertLeading(hunk, their, mine);
  11081. // Now in the overlap content. Scan through and select the best changes from each.
  11082. while (mine.index < mine.lines.length && their.index < their.lines.length) {
  11083. var mineCurrent = mine.lines[mine.index],
  11084. theirCurrent = their.lines[their.index];
  11085. if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
  11086. // Both modified ...
  11087. mutualChange(hunk, mine, their);
  11088. } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
  11089. /*istanbul ignore start*/var _hunk$lines;
  11090. /*istanbul ignore end*/ // Mine inserted
  11091. /*istanbul ignore start*/(_hunk$lines = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(mine)));
  11092. } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
  11093. /*istanbul ignore start*/var _hunk$lines2;
  11094. /*istanbul ignore end*/ // Theirs inserted
  11095. /*istanbul ignore start*/(_hunk$lines2 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(their)));
  11096. } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
  11097. // Mine removed or edited
  11098. removal(hunk, mine, their);
  11099. } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
  11100. // Their removed or edited
  11101. removal(hunk, their, mine, true);
  11102. } else if (mineCurrent === theirCurrent) {
  11103. // Context identity
  11104. hunk.lines.push(mineCurrent);
  11105. mine.index++;
  11106. their.index++;
  11107. } else {
  11108. // Context mismatch
  11109. conflict(hunk, collectChange(mine), collectChange(their));
  11110. }
  11111. }
  11112. // Now push anything that may be remaining
  11113. insertTrailing(hunk, mine);
  11114. insertTrailing(hunk, their);
  11115. calcLineCount(hunk);
  11116. }
  11117. function mutualChange(hunk, mine, their) {
  11118. var myChanges = collectChange(mine),
  11119. theirChanges = collectChange(their);
  11120. if (allRemoves(myChanges) && allRemoves(theirChanges)) {
  11121. // Special case for remove changes that are supersets of one another
  11122. if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
  11123. /*istanbul ignore start*/var _hunk$lines3;
  11124. /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines3 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges));
  11125. return;
  11126. } else if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
  11127. /*istanbul ignore start*/var _hunk$lines4;
  11128. /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines4 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines4 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges));
  11129. return;
  11130. }
  11131. } else if ( /*istanbul ignore start*/(0, _array.arrayEqual) /*istanbul ignore end*/(myChanges, theirChanges)) {
  11132. /*istanbul ignore start*/var _hunk$lines5;
  11133. /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines5 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines5 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges));
  11134. return;
  11135. }
  11136. conflict(hunk, myChanges, theirChanges);
  11137. }
  11138. function removal(hunk, mine, their, swap) {
  11139. var myChanges = collectChange(mine),
  11140. theirChanges = collectContext(their, myChanges);
  11141. if (theirChanges.merged) {
  11142. /*istanbul ignore start*/var _hunk$lines6;
  11143. /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines6 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines6 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges.merged));
  11144. } else {
  11145. conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
  11146. }
  11147. }
  11148. function conflict(hunk, mine, their) {
  11149. hunk.conflict = true;
  11150. hunk.lines.push({
  11151. conflict: true,
  11152. mine: mine,
  11153. theirs: their
  11154. });
  11155. }
  11156. function insertLeading(hunk, insert, their) {
  11157. while (insert.offset < their.offset && insert.index < insert.lines.length) {
  11158. var line = insert.lines[insert.index++];
  11159. hunk.lines.push(line);
  11160. insert.offset++;
  11161. }
  11162. }
  11163. function insertTrailing(hunk, insert) {
  11164. while (insert.index < insert.lines.length) {
  11165. var line = insert.lines[insert.index++];
  11166. hunk.lines.push(line);
  11167. }
  11168. }
  11169. function collectChange(state) {
  11170. var ret = [],
  11171. operation = state.lines[state.index][0];
  11172. while (state.index < state.lines.length) {
  11173. var line = state.lines[state.index];
  11174. // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
  11175. if (operation === '-' && line[0] === '+') {
  11176. operation = '+';
  11177. }
  11178. if (operation === line[0]) {
  11179. ret.push(line);
  11180. state.index++;
  11181. } else {
  11182. break;
  11183. }
  11184. }
  11185. return ret;
  11186. }
  11187. function collectContext(state, matchChanges) {
  11188. var changes = [],
  11189. merged = [],
  11190. matchIndex = 0,
  11191. contextChanges = false,
  11192. conflicted = false;
  11193. while (matchIndex < matchChanges.length && state.index < state.lines.length) {
  11194. var change = state.lines[state.index],
  11195. match = matchChanges[matchIndex];
  11196. // Once we've hit our add, then we are done
  11197. if (match[0] === '+') {
  11198. break;
  11199. }
  11200. contextChanges = contextChanges || change[0] !== ' ';
  11201. merged.push(match);
  11202. matchIndex++;
  11203. // Consume any additions in the other block as a conflict to attempt
  11204. // to pull in the remaining context after this
  11205. if (change[0] === '+') {
  11206. conflicted = true;
  11207. while (change[0] === '+') {
  11208. changes.push(change);
  11209. change = state.lines[++state.index];
  11210. }
  11211. }
  11212. if (match.substr(1) === change.substr(1)) {
  11213. changes.push(change);
  11214. state.index++;
  11215. } else {
  11216. conflicted = true;
  11217. }
  11218. }
  11219. if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
  11220. conflicted = true;
  11221. }
  11222. if (conflicted) {
  11223. return changes;
  11224. }
  11225. while (matchIndex < matchChanges.length) {
  11226. merged.push(matchChanges[matchIndex++]);
  11227. }
  11228. return {
  11229. merged: merged,
  11230. changes: changes
  11231. };
  11232. }
  11233. function allRemoves(changes) {
  11234. return changes.reduce(function (prev, change) {
  11235. return prev && change[0] === '-';
  11236. }, true);
  11237. }
  11238. function skipRemoveSuperset(state, removeChanges, delta) {
  11239. for (var i = 0; i < delta; i++) {
  11240. var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
  11241. if (state.lines[state.index + i] !== ' ' + changeContent) {
  11242. return false;
  11243. }
  11244. }
  11245. state.index += delta;
  11246. return true;
  11247. }
  11248. function calcOldNewLineCount(lines) {
  11249. var oldLines = 0;
  11250. var newLines = 0;
  11251. lines.forEach(function (line) {
  11252. if (typeof line !== 'string') {
  11253. var myCount = calcOldNewLineCount(line.mine);
  11254. var theirCount = calcOldNewLineCount(line.theirs);
  11255. if (oldLines !== undefined) {
  11256. if (myCount.oldLines === theirCount.oldLines) {
  11257. oldLines += myCount.oldLines;
  11258. } else {
  11259. oldLines = undefined;
  11260. }
  11261. }
  11262. if (newLines !== undefined) {
  11263. if (myCount.newLines === theirCount.newLines) {
  11264. newLines += myCount.newLines;
  11265. } else {
  11266. newLines = undefined;
  11267. }
  11268. }
  11269. } else {
  11270. if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
  11271. newLines++;
  11272. }
  11273. if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
  11274. oldLines++;
  11275. }
  11276. }
  11277. });
  11278. return { oldLines: oldLines, newLines: newLines };
  11279. }
  11280. /***/ }),
  11281. /* 14 */
  11282. /***/ (function(module, exports, __webpack_require__) {
  11283. /*istanbul ignore start*/'use strict';
  11284. exports.__esModule = true;
  11285. exports. /*istanbul ignore end*/structuredPatch = structuredPatch;
  11286. /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch;
  11287. /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch;
  11288. var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
  11289. /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  11290. /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  11291. if (!options) {
  11292. options = {};
  11293. }
  11294. if (typeof options.context === 'undefined') {
  11295. options.context = 4;
  11296. }
  11297. var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options);
  11298. diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
  11299. function contextLines(lines) {
  11300. return lines.map(function (entry) {
  11301. return ' ' + entry;
  11302. });
  11303. }
  11304. var hunks = [];
  11305. var oldRangeStart = 0,
  11306. newRangeStart = 0,
  11307. curRange = [],
  11308. oldLine = 1,
  11309. newLine = 1;
  11310. /*istanbul ignore start*/var _loop = function _loop( /*istanbul ignore end*/i) {
  11311. var current = diff[i],
  11312. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  11313. current.lines = lines;
  11314. if (current.added || current.removed) {
  11315. /*istanbul ignore start*/var _curRange;
  11316. /*istanbul ignore end*/ // If we have previous context, start with that
  11317. if (!oldRangeStart) {
  11318. var prev = diff[i - 1];
  11319. oldRangeStart = oldLine;
  11320. newRangeStart = newLine;
  11321. if (prev) {
  11322. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  11323. oldRangeStart -= curRange.length;
  11324. newRangeStart -= curRange.length;
  11325. }
  11326. }
  11327. // Output our changes
  11328. /*istanbul ignore start*/(_curRange = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/lines.map(function (entry) {
  11329. return (current.added ? '+' : '-') + entry;
  11330. })));
  11331. // Track the updated file position
  11332. if (current.added) {
  11333. newLine += lines.length;
  11334. } else {
  11335. oldLine += lines.length;
  11336. }
  11337. } else {
  11338. // Identical context lines. Track line changes
  11339. if (oldRangeStart) {
  11340. // Close out any changes that have been output (or join overlapping)
  11341. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  11342. /*istanbul ignore start*/var _curRange2;
  11343. /*istanbul ignore end*/ // Overlapping
  11344. /*istanbul ignore start*/(_curRange2 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines)));
  11345. } else {
  11346. /*istanbul ignore start*/var _curRange3;
  11347. /*istanbul ignore end*/ // end the range and output
  11348. var contextSize = Math.min(lines.length, options.context);
  11349. /*istanbul ignore start*/(_curRange3 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines.slice(0, contextSize))));
  11350. var hunk = {
  11351. oldStart: oldRangeStart,
  11352. oldLines: oldLine - oldRangeStart + contextSize,
  11353. newStart: newRangeStart,
  11354. newLines: newLine - newRangeStart + contextSize,
  11355. lines: curRange
  11356. };
  11357. if (i >= diff.length - 2 && lines.length <= options.context) {
  11358. // EOF is inside this hunk
  11359. var oldEOFNewline = /\n$/.test(oldStr);
  11360. var newEOFNewline = /\n$/.test(newStr);
  11361. if (lines.length == 0 && !oldEOFNewline) {
  11362. // special case: old has no eol and no trailing context; no-nl can end up before adds
  11363. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  11364. } else if (!oldEOFNewline || !newEOFNewline) {
  11365. curRange.push('\\ No newline at end of file');
  11366. }
  11367. }
  11368. hunks.push(hunk);
  11369. oldRangeStart = 0;
  11370. newRangeStart = 0;
  11371. curRange = [];
  11372. }
  11373. }
  11374. oldLine += lines.length;
  11375. newLine += lines.length;
  11376. }
  11377. };
  11378. for (var i = 0; i < diff.length; i++) {
  11379. /*istanbul ignore start*/_loop( /*istanbul ignore end*/i);
  11380. }
  11381. return {
  11382. oldFileName: oldFileName, newFileName: newFileName,
  11383. oldHeader: oldHeader, newHeader: newHeader,
  11384. hunks: hunks
  11385. };
  11386. }
  11387. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  11388. var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
  11389. var ret = [];
  11390. if (oldFileName == newFileName) {
  11391. ret.push('Index: ' + oldFileName);
  11392. }
  11393. ret.push('===================================================================');
  11394. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  11395. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  11396. for (var i = 0; i < diff.hunks.length; i++) {
  11397. var hunk = diff.hunks[i];
  11398. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  11399. ret.push.apply(ret, hunk.lines);
  11400. }
  11401. return ret.join('\n') + '\n';
  11402. }
  11403. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  11404. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  11405. }
  11406. /***/ }),
  11407. /* 15 */
  11408. /***/ (function(module, exports) {
  11409. /*istanbul ignore start*/"use strict";
  11410. exports.__esModule = true;
  11411. exports. /*istanbul ignore end*/arrayEqual = arrayEqual;
  11412. /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayStartsWith = arrayStartsWith;
  11413. function arrayEqual(a, b) {
  11414. if (a.length !== b.length) {
  11415. return false;
  11416. }
  11417. return arrayStartsWith(a, b);
  11418. }
  11419. function arrayStartsWith(array, start) {
  11420. if (start.length > array.length) {
  11421. return false;
  11422. }
  11423. for (var i = 0; i < start.length; i++) {
  11424. if (start[i] !== array[i]) {
  11425. return false;
  11426. }
  11427. }
  11428. return true;
  11429. }
  11430. /***/ }),
  11431. /* 16 */
  11432. /***/ (function(module, exports) {
  11433. /*istanbul ignore start*/"use strict";
  11434. exports.__esModule = true;
  11435. exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP;
  11436. // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  11437. function convertChangesToDMP(changes) {
  11438. var ret = [],
  11439. change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
  11440. operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  11441. for (var i = 0; i < changes.length; i++) {
  11442. change = changes[i];
  11443. if (change.added) {
  11444. operation = 1;
  11445. } else if (change.removed) {
  11446. operation = -1;
  11447. } else {
  11448. operation = 0;
  11449. }
  11450. ret.push([operation, change.value]);
  11451. }
  11452. return ret;
  11453. }
  11454. /***/ }),
  11455. /* 17 */
  11456. /***/ (function(module, exports) {
  11457. /*istanbul ignore start*/'use strict';
  11458. exports.__esModule = true;
  11459. exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML;
  11460. function convertChangesToXML(changes) {
  11461. var ret = [];
  11462. for (var i = 0; i < changes.length; i++) {
  11463. var change = changes[i];
  11464. if (change.added) {
  11465. ret.push('<ins>');
  11466. } else if (change.removed) {
  11467. ret.push('<del>');
  11468. }
  11469. ret.push(escapeHTML(change.value));
  11470. if (change.added) {
  11471. ret.push('</ins>');
  11472. } else if (change.removed) {
  11473. ret.push('</del>');
  11474. }
  11475. }
  11476. return ret.join('');
  11477. }
  11478. function escapeHTML(s) {
  11479. var n = s;
  11480. n = n.replace(/&/g, '&amp;');
  11481. n = n.replace(/</g, '&lt;');
  11482. n = n.replace(/>/g, '&gt;');
  11483. n = n.replace(/"/g, '&quot;');
  11484. return n;
  11485. }
  11486. /***/ })
  11487. /******/ ])
  11488. });
  11489. ;
  11490. },{}],49:[function(require,module,exports){
  11491. 'use strict';
  11492. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  11493. module.exports = function (str) {
  11494. if (typeof str !== 'string') {
  11495. throw new TypeError('Expected a string');
  11496. }
  11497. return str.replace(matchOperatorsRe, '\\$&');
  11498. };
  11499. },{}],50:[function(require,module,exports){
  11500. // Copyright Joyent, Inc. and other Node contributors.
  11501. //
  11502. // Permission is hereby granted, free of charge, to any person obtaining a
  11503. // copy of this software and associated documentation files (the
  11504. // "Software"), to deal in the Software without restriction, including
  11505. // without limitation the rights to use, copy, modify, merge, publish,
  11506. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11507. // persons to whom the Software is furnished to do so, subject to the
  11508. // following conditions:
  11509. //
  11510. // The above copyright notice and this permission notice shall be included
  11511. // in all copies or substantial portions of the Software.
  11512. //
  11513. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11514. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11515. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11516. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11517. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11518. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11519. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11520. var objectCreate = Object.create || objectCreatePolyfill
  11521. var objectKeys = Object.keys || objectKeysPolyfill
  11522. var bind = Function.prototype.bind || functionBindPolyfill
  11523. function EventEmitter() {
  11524. if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
  11525. this._events = objectCreate(null);
  11526. this._eventsCount = 0;
  11527. }
  11528. this._maxListeners = this._maxListeners || undefined;
  11529. }
  11530. module.exports = EventEmitter;
  11531. // Backwards-compat with node 0.10.x
  11532. EventEmitter.EventEmitter = EventEmitter;
  11533. EventEmitter.prototype._events = undefined;
  11534. EventEmitter.prototype._maxListeners = undefined;
  11535. // By default EventEmitters will print a warning if more than 10 listeners are
  11536. // added to it. This is a useful default which helps finding memory leaks.
  11537. var defaultMaxListeners = 10;
  11538. var hasDefineProperty;
  11539. try {
  11540. var o = {};
  11541. if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
  11542. hasDefineProperty = o.x === 0;
  11543. } catch (err) { hasDefineProperty = false }
  11544. if (hasDefineProperty) {
  11545. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  11546. enumerable: true,
  11547. get: function() {
  11548. return defaultMaxListeners;
  11549. },
  11550. set: function(arg) {
  11551. // check whether the input is a positive number (whose value is zero or
  11552. // greater and not a NaN).
  11553. if (typeof arg !== 'number' || arg < 0 || arg !== arg)
  11554. throw new TypeError('"defaultMaxListeners" must be a positive number');
  11555. defaultMaxListeners = arg;
  11556. }
  11557. });
  11558. } else {
  11559. EventEmitter.defaultMaxListeners = defaultMaxListeners;
  11560. }
  11561. // Obviously not all Emitters should be limited to 10. This function allows
  11562. // that to be increased. Set to zero for unlimited.
  11563. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  11564. if (typeof n !== 'number' || n < 0 || isNaN(n))
  11565. throw new TypeError('"n" argument must be a positive number');
  11566. this._maxListeners = n;
  11567. return this;
  11568. };
  11569. function $getMaxListeners(that) {
  11570. if (that._maxListeners === undefined)
  11571. return EventEmitter.defaultMaxListeners;
  11572. return that._maxListeners;
  11573. }
  11574. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  11575. return $getMaxListeners(this);
  11576. };
  11577. // These standalone emit* functions are used to optimize calling of event
  11578. // handlers for fast cases because emit() itself often has a variable number of
  11579. // arguments and can be deoptimized because of that. These functions always have
  11580. // the same number of arguments and thus do not get deoptimized, so the code
  11581. // inside them can execute faster.
  11582. function emitNone(handler, isFn, self) {
  11583. if (isFn)
  11584. handler.call(self);
  11585. else {
  11586. var len = handler.length;
  11587. var listeners = arrayClone(handler, len);
  11588. for (var i = 0; i < len; ++i)
  11589. listeners[i].call(self);
  11590. }
  11591. }
  11592. function emitOne(handler, isFn, self, arg1) {
  11593. if (isFn)
  11594. handler.call(self, arg1);
  11595. else {
  11596. var len = handler.length;
  11597. var listeners = arrayClone(handler, len);
  11598. for (var i = 0; i < len; ++i)
  11599. listeners[i].call(self, arg1);
  11600. }
  11601. }
  11602. function emitTwo(handler, isFn, self, arg1, arg2) {
  11603. if (isFn)
  11604. handler.call(self, arg1, arg2);
  11605. else {
  11606. var len = handler.length;
  11607. var listeners = arrayClone(handler, len);
  11608. for (var i = 0; i < len; ++i)
  11609. listeners[i].call(self, arg1, arg2);
  11610. }
  11611. }
  11612. function emitThree(handler, isFn, self, arg1, arg2, arg3) {
  11613. if (isFn)
  11614. handler.call(self, arg1, arg2, arg3);
  11615. else {
  11616. var len = handler.length;
  11617. var listeners = arrayClone(handler, len);
  11618. for (var i = 0; i < len; ++i)
  11619. listeners[i].call(self, arg1, arg2, arg3);
  11620. }
  11621. }
  11622. function emitMany(handler, isFn, self, args) {
  11623. if (isFn)
  11624. handler.apply(self, args);
  11625. else {
  11626. var len = handler.length;
  11627. var listeners = arrayClone(handler, len);
  11628. for (var i = 0; i < len; ++i)
  11629. listeners[i].apply(self, args);
  11630. }
  11631. }
  11632. EventEmitter.prototype.emit = function emit(type) {
  11633. var er, handler, len, args, i, events;
  11634. var doError = (type === 'error');
  11635. events = this._events;
  11636. if (events)
  11637. doError = (doError && events.error == null);
  11638. else if (!doError)
  11639. return false;
  11640. // If there is no 'error' event listener then throw.
  11641. if (doError) {
  11642. if (arguments.length > 1)
  11643. er = arguments[1];
  11644. if (er instanceof Error) {
  11645. throw er; // Unhandled 'error' event
  11646. } else {
  11647. // At least give some kind of context to the user
  11648. var err = new Error('Unhandled "error" event. (' + er + ')');
  11649. err.context = er;
  11650. throw err;
  11651. }
  11652. return false;
  11653. }
  11654. handler = events[type];
  11655. if (!handler)
  11656. return false;
  11657. var isFn = typeof handler === 'function';
  11658. len = arguments.length;
  11659. switch (len) {
  11660. // fast cases
  11661. case 1:
  11662. emitNone(handler, isFn, this);
  11663. break;
  11664. case 2:
  11665. emitOne(handler, isFn, this, arguments[1]);
  11666. break;
  11667. case 3:
  11668. emitTwo(handler, isFn, this, arguments[1], arguments[2]);
  11669. break;
  11670. case 4:
  11671. emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
  11672. break;
  11673. // slower
  11674. default:
  11675. args = new Array(len - 1);
  11676. for (i = 1; i < len; i++)
  11677. args[i - 1] = arguments[i];
  11678. emitMany(handler, isFn, this, args);
  11679. }
  11680. return true;
  11681. };
  11682. function _addListener(target, type, listener, prepend) {
  11683. var m;
  11684. var events;
  11685. var existing;
  11686. if (typeof listener !== 'function')
  11687. throw new TypeError('"listener" argument must be a function');
  11688. events = target._events;
  11689. if (!events) {
  11690. events = target._events = objectCreate(null);
  11691. target._eventsCount = 0;
  11692. } else {
  11693. // To avoid recursion in the case that type === "newListener"! Before
  11694. // adding it to the listeners, first emit "newListener".
  11695. if (events.newListener) {
  11696. target.emit('newListener', type,
  11697. listener.listener ? listener.listener : listener);
  11698. // Re-assign `events` because a newListener handler could have caused the
  11699. // this._events to be assigned to a new object
  11700. events = target._events;
  11701. }
  11702. existing = events[type];
  11703. }
  11704. if (!existing) {
  11705. // Optimize the case of one listener. Don't need the extra array object.
  11706. existing = events[type] = listener;
  11707. ++target._eventsCount;
  11708. } else {
  11709. if (typeof existing === 'function') {
  11710. // Adding the second element, need to change to array.
  11711. existing = events[type] =
  11712. prepend ? [listener, existing] : [existing, listener];
  11713. } else {
  11714. // If we've already got an array, just append.
  11715. if (prepend) {
  11716. existing.unshift(listener);
  11717. } else {
  11718. existing.push(listener);
  11719. }
  11720. }
  11721. // Check for listener leak
  11722. if (!existing.warned) {
  11723. m = $getMaxListeners(target);
  11724. if (m && m > 0 && existing.length > m) {
  11725. existing.warned = true;
  11726. var w = new Error('Possible EventEmitter memory leak detected. ' +
  11727. existing.length + ' "' + String(type) + '" listeners ' +
  11728. 'added. Use emitter.setMaxListeners() to ' +
  11729. 'increase limit.');
  11730. w.name = 'MaxListenersExceededWarning';
  11731. w.emitter = target;
  11732. w.type = type;
  11733. w.count = existing.length;
  11734. if (typeof console === 'object' && console.warn) {
  11735. console.warn('%s: %s', w.name, w.message);
  11736. }
  11737. }
  11738. }
  11739. }
  11740. return target;
  11741. }
  11742. EventEmitter.prototype.addListener = function addListener(type, listener) {
  11743. return _addListener(this, type, listener, false);
  11744. };
  11745. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  11746. EventEmitter.prototype.prependListener =
  11747. function prependListener(type, listener) {
  11748. return _addListener(this, type, listener, true);
  11749. };
  11750. function onceWrapper() {
  11751. if (!this.fired) {
  11752. this.target.removeListener(this.type, this.wrapFn);
  11753. this.fired = true;
  11754. switch (arguments.length) {
  11755. case 0:
  11756. return this.listener.call(this.target);
  11757. case 1:
  11758. return this.listener.call(this.target, arguments[0]);
  11759. case 2:
  11760. return this.listener.call(this.target, arguments[0], arguments[1]);
  11761. case 3:
  11762. return this.listener.call(this.target, arguments[0], arguments[1],
  11763. arguments[2]);
  11764. default:
  11765. var args = new Array(arguments.length);
  11766. for (var i = 0; i < args.length; ++i)
  11767. args[i] = arguments[i];
  11768. this.listener.apply(this.target, args);
  11769. }
  11770. }
  11771. }
  11772. function _onceWrap(target, type, listener) {
  11773. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  11774. var wrapped = bind.call(onceWrapper, state);
  11775. wrapped.listener = listener;
  11776. state.wrapFn = wrapped;
  11777. return wrapped;
  11778. }
  11779. EventEmitter.prototype.once = function once(type, listener) {
  11780. if (typeof listener !== 'function')
  11781. throw new TypeError('"listener" argument must be a function');
  11782. this.on(type, _onceWrap(this, type, listener));
  11783. return this;
  11784. };
  11785. EventEmitter.prototype.prependOnceListener =
  11786. function prependOnceListener(type, listener) {
  11787. if (typeof listener !== 'function')
  11788. throw new TypeError('"listener" argument must be a function');
  11789. this.prependListener(type, _onceWrap(this, type, listener));
  11790. return this;
  11791. };
  11792. // Emits a 'removeListener' event if and only if the listener was removed.
  11793. EventEmitter.prototype.removeListener =
  11794. function removeListener(type, listener) {
  11795. var list, events, position, i, originalListener;
  11796. if (typeof listener !== 'function')
  11797. throw new TypeError('"listener" argument must be a function');
  11798. events = this._events;
  11799. if (!events)
  11800. return this;
  11801. list = events[type];
  11802. if (!list)
  11803. return this;
  11804. if (list === listener || list.listener === listener) {
  11805. if (--this._eventsCount === 0)
  11806. this._events = objectCreate(null);
  11807. else {
  11808. delete events[type];
  11809. if (events.removeListener)
  11810. this.emit('removeListener', type, list.listener || listener);
  11811. }
  11812. } else if (typeof list !== 'function') {
  11813. position = -1;
  11814. for (i = list.length - 1; i >= 0; i--) {
  11815. if (list[i] === listener || list[i].listener === listener) {
  11816. originalListener = list[i].listener;
  11817. position = i;
  11818. break;
  11819. }
  11820. }
  11821. if (position < 0)
  11822. return this;
  11823. if (position === 0)
  11824. list.shift();
  11825. else
  11826. spliceOne(list, position);
  11827. if (list.length === 1)
  11828. events[type] = list[0];
  11829. if (events.removeListener)
  11830. this.emit('removeListener', type, originalListener || listener);
  11831. }
  11832. return this;
  11833. };
  11834. EventEmitter.prototype.removeAllListeners =
  11835. function removeAllListeners(type) {
  11836. var listeners, events, i;
  11837. events = this._events;
  11838. if (!events)
  11839. return this;
  11840. // not listening for removeListener, no need to emit
  11841. if (!events.removeListener) {
  11842. if (arguments.length === 0) {
  11843. this._events = objectCreate(null);
  11844. this._eventsCount = 0;
  11845. } else if (events[type]) {
  11846. if (--this._eventsCount === 0)
  11847. this._events = objectCreate(null);
  11848. else
  11849. delete events[type];
  11850. }
  11851. return this;
  11852. }
  11853. // emit removeListener for all listeners on all events
  11854. if (arguments.length === 0) {
  11855. var keys = objectKeys(events);
  11856. var key;
  11857. for (i = 0; i < keys.length; ++i) {
  11858. key = keys[i];
  11859. if (key === 'removeListener') continue;
  11860. this.removeAllListeners(key);
  11861. }
  11862. this.removeAllListeners('removeListener');
  11863. this._events = objectCreate(null);
  11864. this._eventsCount = 0;
  11865. return this;
  11866. }
  11867. listeners = events[type];
  11868. if (typeof listeners === 'function') {
  11869. this.removeListener(type, listeners);
  11870. } else if (listeners) {
  11871. // LIFO order
  11872. for (i = listeners.length - 1; i >= 0; i--) {
  11873. this.removeListener(type, listeners[i]);
  11874. }
  11875. }
  11876. return this;
  11877. };
  11878. function _listeners(target, type, unwrap) {
  11879. var events = target._events;
  11880. if (!events)
  11881. return [];
  11882. var evlistener = events[type];
  11883. if (!evlistener)
  11884. return [];
  11885. if (typeof evlistener === 'function')
  11886. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  11887. return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  11888. }
  11889. EventEmitter.prototype.listeners = function listeners(type) {
  11890. return _listeners(this, type, true);
  11891. };
  11892. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  11893. return _listeners(this, type, false);
  11894. };
  11895. EventEmitter.listenerCount = function(emitter, type) {
  11896. if (typeof emitter.listenerCount === 'function') {
  11897. return emitter.listenerCount(type);
  11898. } else {
  11899. return listenerCount.call(emitter, type);
  11900. }
  11901. };
  11902. EventEmitter.prototype.listenerCount = listenerCount;
  11903. function listenerCount(type) {
  11904. var events = this._events;
  11905. if (events) {
  11906. var evlistener = events[type];
  11907. if (typeof evlistener === 'function') {
  11908. return 1;
  11909. } else if (evlistener) {
  11910. return evlistener.length;
  11911. }
  11912. }
  11913. return 0;
  11914. }
  11915. EventEmitter.prototype.eventNames = function eventNames() {
  11916. return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
  11917. };
  11918. // About 1.5x faster than the two-arg version of Array#splice().
  11919. function spliceOne(list, index) {
  11920. for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
  11921. list[i] = list[k];
  11922. list.pop();
  11923. }
  11924. function arrayClone(arr, n) {
  11925. var copy = new Array(n);
  11926. for (var i = 0; i < n; ++i)
  11927. copy[i] = arr[i];
  11928. return copy;
  11929. }
  11930. function unwrapListeners(arr) {
  11931. var ret = new Array(arr.length);
  11932. for (var i = 0; i < ret.length; ++i) {
  11933. ret[i] = arr[i].listener || arr[i];
  11934. }
  11935. return ret;
  11936. }
  11937. function objectCreatePolyfill(proto) {
  11938. var F = function() {};
  11939. F.prototype = proto;
  11940. return new F;
  11941. }
  11942. function objectKeysPolyfill(obj) {
  11943. var keys = [];
  11944. for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
  11945. keys.push(k);
  11946. }
  11947. return k;
  11948. }
  11949. function functionBindPolyfill(context) {
  11950. var fn = this;
  11951. return function () {
  11952. return fn.apply(context, arguments);
  11953. };
  11954. }
  11955. },{}],51:[function(require,module,exports){
  11956. 'use strict';
  11957. /* eslint no-invalid-this: 1 */
  11958. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  11959. var slice = Array.prototype.slice;
  11960. var toStr = Object.prototype.toString;
  11961. var funcType = '[object Function]';
  11962. module.exports = function bind(that) {
  11963. var target = this;
  11964. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  11965. throw new TypeError(ERROR_MESSAGE + target);
  11966. }
  11967. var args = slice.call(arguments, 1);
  11968. var bound;
  11969. var binder = function () {
  11970. if (this instanceof bound) {
  11971. var result = target.apply(
  11972. this,
  11973. args.concat(slice.call(arguments))
  11974. );
  11975. if (Object(result) === result) {
  11976. return result;
  11977. }
  11978. return this;
  11979. } else {
  11980. return target.apply(
  11981. that,
  11982. args.concat(slice.call(arguments))
  11983. );
  11984. }
  11985. };
  11986. var boundLength = Math.max(0, target.length - args.length);
  11987. var boundArgs = [];
  11988. for (var i = 0; i < boundLength; i++) {
  11989. boundArgs.push('$' + i);
  11990. }
  11991. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  11992. if (target.prototype) {
  11993. var Empty = function Empty() {};
  11994. Empty.prototype = target.prototype;
  11995. bound.prototype = new Empty();
  11996. Empty.prototype = null;
  11997. }
  11998. return bound;
  11999. };
  12000. },{}],52:[function(require,module,exports){
  12001. 'use strict';
  12002. var implementation = require('./implementation');
  12003. module.exports = Function.prototype.bind || implementation;
  12004. },{"./implementation":51}],53:[function(require,module,exports){
  12005. 'use strict';
  12006. /* eslint complexity: [2, 17], max-statements: [2, 33] */
  12007. module.exports = function hasSymbols() {
  12008. if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
  12009. if (typeof Symbol.iterator === 'symbol') { return true; }
  12010. var obj = {};
  12011. var sym = Symbol('test');
  12012. var symObj = Object(sym);
  12013. if (typeof sym === 'string') { return false; }
  12014. if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
  12015. if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
  12016. // temp disabled per https://github.com/ljharb/object.assign/issues/17
  12017. // if (sym instanceof Symbol) { return false; }
  12018. // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
  12019. // if (!(symObj instanceof Symbol)) { return false; }
  12020. // if (typeof Symbol.prototype.toString !== 'function') { return false; }
  12021. // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
  12022. var symVal = 42;
  12023. obj[sym] = symVal;
  12024. for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
  12025. if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
  12026. if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
  12027. var syms = Object.getOwnPropertySymbols(obj);
  12028. if (syms.length !== 1 || syms[0] !== sym) { return false; }
  12029. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
  12030. if (typeof Object.getOwnPropertyDescriptor === 'function') {
  12031. var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
  12032. if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
  12033. }
  12034. return true;
  12035. };
  12036. },{}],54:[function(require,module,exports){
  12037. (function (global){
  12038. /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
  12039. ;(function(root) {
  12040. // Detect free variables `exports`.
  12041. var freeExports = typeof exports == 'object' && exports;
  12042. // Detect free variable `module`.
  12043. var freeModule = typeof module == 'object' && module &&
  12044. module.exports == freeExports && module;
  12045. // Detect free variable `global`, from Node.js or Browserified code,
  12046. // and use it as `root`.
  12047. var freeGlobal = typeof global == 'object' && global;
  12048. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
  12049. root = freeGlobal;
  12050. }
  12051. /*--------------------------------------------------------------------------*/
  12052. // All astral symbols.
  12053. var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
  12054. // All ASCII symbols (not just printable ASCII) except those listed in the
  12055. // first column of the overrides table.
  12056. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides
  12057. var regexAsciiWhitelist = /[\x01-\x7F]/g;
  12058. // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
  12059. // code points listed in the first column of the overrides table on
  12060. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides.
  12061. var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
  12062. var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g;
  12063. var encodeMap = {'\xAD':'shy','\u200C':'zwnj','\u200D':'zwj','\u200E':'lrm','\u2063':'ic','\u2062':'it','\u2061':'af','\u200F':'rlm','\u200B':'ZeroWidthSpace','\u2060':'NoBreak','\u0311':'DownBreve','\u20DB':'tdot','\u20DC':'DotDot','\t':'Tab','\n':'NewLine','\u2008':'puncsp','\u205F':'MediumSpace','\u2009':'thinsp','\u200A':'hairsp','\u2004':'emsp13','\u2002':'ensp','\u2005':'emsp14','\u2003':'emsp','\u2007':'numsp','\xA0':'nbsp','\u205F\u200A':'ThickSpace','\u203E':'oline','_':'lowbar','\u2010':'dash','\u2013':'ndash','\u2014':'mdash','\u2015':'horbar',',':'comma',';':'semi','\u204F':'bsemi',':':'colon','\u2A74':'Colone','!':'excl','\xA1':'iexcl','?':'quest','\xBF':'iquest','.':'period','\u2025':'nldr','\u2026':'mldr','\xB7':'middot','\'':'apos','\u2018':'lsquo','\u2019':'rsquo','\u201A':'sbquo','\u2039':'lsaquo','\u203A':'rsaquo','"':'quot','\u201C':'ldquo','\u201D':'rdquo','\u201E':'bdquo','\xAB':'laquo','\xBB':'raquo','(':'lpar',')':'rpar','[':'lsqb',']':'rsqb','{':'lcub','}':'rcub','\u2308':'lceil','\u2309':'rceil','\u230A':'lfloor','\u230B':'rfloor','\u2985':'lopar','\u2986':'ropar','\u298B':'lbrke','\u298C':'rbrke','\u298D':'lbrkslu','\u298E':'rbrksld','\u298F':'lbrksld','\u2990':'rbrkslu','\u2991':'langd','\u2992':'rangd','\u2993':'lparlt','\u2994':'rpargt','\u2995':'gtlPar','\u2996':'ltrPar','\u27E6':'lobrk','\u27E7':'robrk','\u27E8':'lang','\u27E9':'rang','\u27EA':'Lang','\u27EB':'Rang','\u27EC':'loang','\u27ED':'roang','\u2772':'lbbrk','\u2773':'rbbrk','\u2016':'Vert','\xA7':'sect','\xB6':'para','@':'commat','*':'ast','/':'sol','undefined':null,'&':'amp','#':'num','%':'percnt','\u2030':'permil','\u2031':'pertenk','\u2020':'dagger','\u2021':'Dagger','\u2022':'bull','\u2043':'hybull','\u2032':'prime','\u2033':'Prime','\u2034':'tprime','\u2057':'qprime','\u2035':'bprime','\u2041':'caret','`':'grave','\xB4':'acute','\u02DC':'tilde','^':'Hat','\xAF':'macr','\u02D8':'breve','\u02D9':'dot','\xA8':'die','\u02DA':'ring','\u02DD':'dblac','\xB8':'cedil','\u02DB':'ogon','\u02C6':'circ','\u02C7':'caron','\xB0':'deg','\xA9':'copy','\xAE':'reg','\u2117':'copysr','\u2118':'wp','\u211E':'rx','\u2127':'mho','\u2129':'iiota','\u2190':'larr','\u219A':'nlarr','\u2192':'rarr','\u219B':'nrarr','\u2191':'uarr','\u2193':'darr','\u2194':'harr','\u21AE':'nharr','\u2195':'varr','\u2196':'nwarr','\u2197':'nearr','\u2198':'searr','\u2199':'swarr','\u219D':'rarrw','\u219D\u0338':'nrarrw','\u219E':'Larr','\u219F':'Uarr','\u21A0':'Rarr','\u21A1':'Darr','\u21A2':'larrtl','\u21A3':'rarrtl','\u21A4':'mapstoleft','\u21A5':'mapstoup','\u21A6':'map','\u21A7':'mapstodown','\u21A9':'larrhk','\u21AA':'rarrhk','\u21AB':'larrlp','\u21AC':'rarrlp','\u21AD':'harrw','\u21B0':'lsh','\u21B1':'rsh','\u21B2':'ldsh','\u21B3':'rdsh','\u21B5':'crarr','\u21B6':'cularr','\u21B7':'curarr','\u21BA':'olarr','\u21BB':'orarr','\u21BC':'lharu','\u21BD':'lhard','\u21BE':'uharr','\u21BF':'uharl','\u21C0':'rharu','\u21C1':'rhard','\u21C2':'dharr','\u21C3':'dharl','\u21C4':'rlarr','\u21C5':'udarr','\u21C6':'lrarr','\u21C7':'llarr','\u21C8':'uuarr','\u21C9':'rrarr','\u21CA':'ddarr','\u21CB':'lrhar','\u21CC':'rlhar','\u21D0':'lArr','\u21CD':'nlArr','\u21D1':'uArr','\u21D2':'rArr','\u21CF':'nrArr','\u21D3':'dArr','\u21D4':'iff','\u21CE':'nhArr','\u21D5':'vArr','\u21D6':'nwArr','\u21D7':'neArr','\u21D8':'seArr','\u21D9':'swArr','\u21DA':'lAarr','\u21DB':'rAarr','\u21DD':'zigrarr','\u21E4':'larrb','\u21E5':'rarrb','\u21F5':'duarr','\u21FD':'loarr','\u21FE':'roarr','\u21FF':'hoarr','\u2200':'forall','\u2201':'comp','\u2202':'part','\u2202\u0338':'npart','\u2203':'exist','\u2204':'nexist','\u2205':'empty','\u2207':'Del','\u2208':'in','\u2209':'notin','\u220B':'ni','\u220C':'notni','\u03F6':'bepsi','\u220F':'prod','\u2210':'coprod','\u2211':'sum','+':'plus','\xB1':'pm','\xF7':'div','\xD7':'times','<':'lt','\u226E':'nlt','<\u20D2':'nvlt','=':'equals','\u2260':'ne','=\u20E5':'bne','\u2A75':'Equal','>':'gt','\u226F':'ngt','>\u20D2':'nvgt','\xAC':'not','|':'vert','\xA6':'brvbar','\u2212':'minus','\u2213':'mp','\u2214':'plusdo','\u2044':'frasl','\u2216':'setmn','\u2217':'lowast','\u2218':'compfn','\u221A':'Sqrt','\u221D':'prop','\u221E':'infin','\u221F':'angrt','\u2220':'ang','\u2220\u20D2':'nang','\u2221':'angmsd','\u2222':'angsph','\u2223':'mid','\u2224':'nmid','\u2225':'par','\u2226':'npar','\u2227':'and','\u2228':'or','\u2229':'cap','\u2229\uFE00':'caps','\u222A':'cup','\u222A\uFE00':'cups','\u222B':'int','\u222C':'Int','\u222D':'tint','\u2A0C':'qint','\u222E':'oint','\u222F':'Conint','\u2230':'Cconint','\u2231':'cwint','\u2232':'cwconint','\u2233':'awconint','\u2234':'there4','\u2235':'becaus','\u2236':'ratio','\u2237':'Colon','\u2238':'minusd','\u223A':'mDDot','\u223B':'homtht','\u223C':'sim','\u2241':'nsim','\u223C\u20D2':'nvsim','\u223D':'bsim','\u223D\u0331':'race','\u223E':'ac','\u223E\u0333':'acE','\u223F':'acd','\u2240':'wr','\u2242':'esim','\u2242\u0338':'nesim','\u2243':'sime','\u2244':'nsime','\u2245':'cong','\u2247':'ncong','\u2246':'simne','\u2248':'ap','\u2249':'nap','\u224A':'ape','\u224B':'apid','\u224B\u0338':'napid','\u224C':'bcong','\u224D':'CupCap','\u226D':'NotCupCap','\u224D\u20D2':'nvap','\u224E':'bump','\u224E\u0338':'nbump','\u224F':'bumpe','\u224F\u0338':'nbumpe','\u2250':'doteq','\u2250\u0338':'nedot','\u2251':'eDot','\u2252':'efDot','\u2253':'erDot','\u2254':'colone','\u2255':'ecolon','\u2256':'ecir','\u2257':'cire','\u2259':'wedgeq','\u225A':'veeeq','\u225C':'trie','\u225F':'equest','\u2261':'equiv','\u2262':'nequiv','\u2261\u20E5':'bnequiv','\u2264':'le','\u2270':'nle','\u2264\u20D2':'nvle','\u2265':'ge','\u2271':'nge','\u2265\u20D2':'nvge','\u2266':'lE','\u2266\u0338':'nlE','\u2267':'gE','\u2267\u0338':'ngE','\u2268\uFE00':'lvnE','\u2268':'lnE','\u2269':'gnE','\u2269\uFE00':'gvnE','\u226A':'ll','\u226A\u0338':'nLtv','\u226A\u20D2':'nLt','\u226B':'gg','\u226B\u0338':'nGtv','\u226B\u20D2':'nGt','\u226C':'twixt','\u2272':'lsim','\u2274':'nlsim','\u2273':'gsim','\u2275':'ngsim','\u2276':'lg','\u2278':'ntlg','\u2277':'gl','\u2279':'ntgl','\u227A':'pr','\u2280':'npr','\u227B':'sc','\u2281':'nsc','\u227C':'prcue','\u22E0':'nprcue','\u227D':'sccue','\u22E1':'nsccue','\u227E':'prsim','\u227F':'scsim','\u227F\u0338':'NotSucceedsTilde','\u2282':'sub','\u2284':'nsub','\u2282\u20D2':'vnsub','\u2283':'sup','\u2285':'nsup','\u2283\u20D2':'vnsup','\u2286':'sube','\u2288':'nsube','\u2287':'supe','\u2289':'nsupe','\u228A\uFE00':'vsubne','\u228A':'subne','\u228B\uFE00':'vsupne','\u228B':'supne','\u228D':'cupdot','\u228E':'uplus','\u228F':'sqsub','\u228F\u0338':'NotSquareSubset','\u2290':'sqsup','\u2290\u0338':'NotSquareSuperset','\u2291':'sqsube','\u22E2':'nsqsube','\u2292':'sqsupe','\u22E3':'nsqsupe','\u2293':'sqcap','\u2293\uFE00':'sqcaps','\u2294':'sqcup','\u2294\uFE00':'sqcups','\u2295':'oplus','\u2296':'ominus','\u2297':'otimes','\u2298':'osol','\u2299':'odot','\u229A':'ocir','\u229B':'oast','\u229D':'odash','\u229E':'plusb','\u229F':'minusb','\u22A0':'timesb','\u22A1':'sdotb','\u22A2':'vdash','\u22AC':'nvdash','\u22A3':'dashv','\u22A4':'top','\u22A5':'bot','\u22A7':'models','\u22A8':'vDash','\u22AD':'nvDash','\u22A9':'Vdash','\u22AE':'nVdash','\u22AA':'Vvdash','\u22AB':'VDash','\u22AF':'nVDash','\u22B0':'prurel','\u22B2':'vltri','\u22EA':'nltri','\u22B3':'vrtri','\u22EB':'nrtri','\u22B4':'ltrie','\u22EC':'nltrie','\u22B4\u20D2':'nvltrie','\u22B5':'rtrie','\u22ED':'nrtrie','\u22B5\u20D2':'nvrtrie','\u22B6':'origof','\u22B7':'imof','\u22B8':'mumap','\u22B9':'hercon','\u22BA':'intcal','\u22BB':'veebar','\u22BD':'barvee','\u22BE':'angrtvb','\u22BF':'lrtri','\u22C0':'Wedge','\u22C1':'Vee','\u22C2':'xcap','\u22C3':'xcup','\u22C4':'diam','\u22C5':'sdot','\u22C6':'Star','\u22C7':'divonx','\u22C8':'bowtie','\u22C9':'ltimes','\u22CA':'rtimes','\u22CB':'lthree','\u22CC':'rthree','\u22CD':'bsime','\u22CE':'cuvee','\u22CF':'cuwed','\u22D0':'Sub','\u22D1':'Sup','\u22D2':'Cap','\u22D3':'Cup','\u22D4':'fork','\u22D5':'epar','\u22D6':'ltdot','\u22D7':'gtdot','\u22D8':'Ll','\u22D8\u0338':'nLl','\u22D9':'Gg','\u22D9\u0338':'nGg','\u22DA\uFE00':'lesg','\u22DA':'leg','\u22DB':'gel','\u22DB\uFE00':'gesl','\u22DE':'cuepr','\u22DF':'cuesc','\u22E6':'lnsim','\u22E7':'gnsim','\u22E8':'prnsim','\u22E9':'scnsim','\u22EE':'vellip','\u22EF':'ctdot','\u22F0':'utdot','\u22F1':'dtdot','\u22F2':'disin','\u22F3':'isinsv','\u22F4':'isins','\u22F5':'isindot','\u22F5\u0338':'notindot','\u22F6':'notinvc','\u22F7':'notinvb','\u22F9':'isinE','\u22F9\u0338':'notinE','\u22FA':'nisd','\u22FB':'xnis','\u22FC':'nis','\u22FD':'notnivc','\u22FE':'notnivb','\u2305':'barwed','\u2306':'Barwed','\u230C':'drcrop','\u230D':'dlcrop','\u230E':'urcrop','\u230F':'ulcrop','\u2310':'bnot','\u2312':'profline','\u2313':'profsurf','\u2315':'telrec','\u2316':'target','\u231C':'ulcorn','\u231D':'urcorn','\u231E':'dlcorn','\u231F':'drcorn','\u2322':'frown','\u2323':'smile','\u232D':'cylcty','\u232E':'profalar','\u2336':'topbot','\u233D':'ovbar','\u233F':'solbar','\u237C':'angzarr','\u23B0':'lmoust','\u23B1':'rmoust','\u23B4':'tbrk','\u23B5':'bbrk','\u23B6':'bbrktbrk','\u23DC':'OverParenthesis','\u23DD':'UnderParenthesis','\u23DE':'OverBrace','\u23DF':'UnderBrace','\u23E2':'trpezium','\u23E7':'elinters','\u2423':'blank','\u2500':'boxh','\u2502':'boxv','\u250C':'boxdr','\u2510':'boxdl','\u2514':'boxur','\u2518':'boxul','\u251C':'boxvr','\u2524':'boxvl','\u252C':'boxhd','\u2534':'boxhu','\u253C':'boxvh','\u2550':'boxH','\u2551':'boxV','\u2552':'boxdR','\u2553':'boxDr','\u2554':'boxDR','\u2555':'boxdL','\u2556':'boxDl','\u2557':'boxDL','\u2558':'boxuR','\u2559':'boxUr','\u255A':'boxUR','\u255B':'boxuL','\u255C':'boxUl','\u255D':'boxUL','\u255E':'boxvR','\u255F':'boxVr','\u2560':'boxVR','\u2561':'boxvL','\u2562':'boxVl','\u2563':'boxVL','\u2564':'boxHd','\u2565':'boxhD','\u2566':'boxHD','\u2567':'boxHu','\u2568':'boxhU','\u2569':'boxHU','\u256A':'boxvH','\u256B':'boxVh','\u256C':'boxVH','\u2580':'uhblk','\u2584':'lhblk','\u2588':'block','\u2591':'blk14','\u2592':'blk12','\u2593':'blk34','\u25A1':'squ','\u25AA':'squf','\u25AB':'EmptyVerySmallSquare','\u25AD':'rect','\u25AE':'marker','\u25B1':'fltns','\u25B3':'xutri','\u25B4':'utrif','\u25B5':'utri','\u25B8':'rtrif','\u25B9':'rtri','\u25BD':'xdtri','\u25BE':'dtrif','\u25BF':'dtri','\u25C2':'ltrif','\u25C3':'ltri','\u25CA':'loz','\u25CB':'cir','\u25EC':'tridot','\u25EF':'xcirc','\u25F8':'ultri','\u25F9':'urtri','\u25FA':'lltri','\u25FB':'EmptySmallSquare','\u25FC':'FilledSmallSquare','\u2605':'starf','\u2606':'star','\u260E':'phone','\u2640':'female','\u2642':'male','\u2660':'spades','\u2663':'clubs','\u2665':'hearts','\u2666':'diams','\u266A':'sung','\u2713':'check','\u2717':'cross','\u2720':'malt','\u2736':'sext','\u2758':'VerticalSeparator','\u27C8':'bsolhsub','\u27C9':'suphsol','\u27F5':'xlarr','\u27F6':'xrarr','\u27F7':'xharr','\u27F8':'xlArr','\u27F9':'xrArr','\u27FA':'xhArr','\u27FC':'xmap','\u27FF':'dzigrarr','\u2902':'nvlArr','\u2903':'nvrArr','\u2904':'nvHarr','\u2905':'Map','\u290C':'lbarr','\u290D':'rbarr','\u290E':'lBarr','\u290F':'rBarr','\u2910':'RBarr','\u2911':'DDotrahd','\u2912':'UpArrowBar','\u2913':'DownArrowBar','\u2916':'Rarrtl','\u2919':'latail','\u291A':'ratail','\u291B':'lAtail','\u291C':'rAtail','\u291D':'larrfs','\u291E':'rarrfs','\u291F':'larrbfs','\u2920':'rarrbfs','\u2923':'nwarhk','\u2924':'nearhk','\u2925':'searhk','\u2926':'swarhk','\u2927':'nwnear','\u2928':'toea','\u2929':'tosa','\u292A':'swnwar','\u2933':'rarrc','\u2933\u0338':'nrarrc','\u2935':'cudarrr','\u2936':'ldca','\u2937':'rdca','\u2938':'cudarrl','\u2939':'larrpl','\u293C':'curarrm','\u293D':'cularrp','\u2945':'rarrpl','\u2948':'harrcir','\u2949':'Uarrocir','\u294A':'lurdshar','\u294B':'ldrushar','\u294E':'LeftRightVector','\u294F':'RightUpDownVector','\u2950':'DownLeftRightVector','\u2951':'LeftUpDownVector','\u2952':'LeftVectorBar','\u2953':'RightVectorBar','\u2954':'RightUpVectorBar','\u2955':'RightDownVectorBar','\u2956':'DownLeftVectorBar','\u2957':'DownRightVectorBar','\u2958':'LeftUpVectorBar','\u2959':'LeftDownVectorBar','\u295A':'LeftTeeVector','\u295B':'RightTeeVector','\u295C':'RightUpTeeVector','\u295D':'RightDownTeeVector','\u295E':'DownLeftTeeVector','\u295F':'DownRightTeeVector','\u2960':'LeftUpTeeVector','\u2961':'LeftDownTeeVector','\u2962':'lHar','\u2963':'uHar','\u2964':'rHar','\u2965':'dHar','\u2966':'luruhar','\u2967':'ldrdhar','\u2968':'ruluhar','\u2969':'rdldhar','\u296A':'lharul','\u296B':'llhard','\u296C':'rharul','\u296D':'lrhard','\u296E':'udhar','\u296F':'duhar','\u2970':'RoundImplies','\u2971':'erarr','\u2972':'simrarr','\u2973':'larrsim','\u2974':'rarrsim','\u2975':'rarrap','\u2976':'ltlarr','\u2978':'gtrarr','\u2979':'subrarr','\u297B':'suplarr','\u297C':'lfisht','\u297D':'rfisht','\u297E':'ufisht','\u297F':'dfisht','\u299A':'vzigzag','\u299C':'vangrt','\u299D':'angrtvbd','\u29A4':'ange','\u29A5':'range','\u29A6':'dwangle','\u29A7':'uwangle','\u29A8':'angmsdaa','\u29A9':'angmsdab','\u29AA':'angmsdac','\u29AB':'angmsdad','\u29AC':'angmsdae','\u29AD':'angmsdaf','\u29AE':'angmsdag','\u29AF':'angmsdah','\u29B0':'bemptyv','\u29B1':'demptyv','\u29B2':'cemptyv','\u29B3':'raemptyv','\u29B4':'laemptyv','\u29B5':'ohbar','\u29B6':'omid','\u29B7':'opar','\u29B9':'operp','\u29BB':'olcross','\u29BC':'odsold','\u29BE':'olcir','\u29BF':'ofcir','\u29C0':'olt','\u29C1':'ogt','\u29C2':'cirscir','\u29C3':'cirE','\u29C4':'solb','\u29C5':'bsolb','\u29C9':'boxbox','\u29CD':'trisb','\u29CE':'rtriltri','\u29CF':'LeftTriangleBar','\u29CF\u0338':'NotLeftTriangleBar','\u29D0':'RightTriangleBar','\u29D0\u0338':'NotRightTriangleBar','\u29DC':'iinfin','\u29DD':'infintie','\u29DE':'nvinfin','\u29E3':'eparsl','\u29E4':'smeparsl','\u29E5':'eqvparsl','\u29EB':'lozf','\u29F4':'RuleDelayed','\u29F6':'dsol','\u2A00':'xodot','\u2A01':'xoplus','\u2A02':'xotime','\u2A04':'xuplus','\u2A06':'xsqcup','\u2A0D':'fpartint','\u2A10':'cirfnint','\u2A11':'awint','\u2A12':'rppolint','\u2A13':'scpolint','\u2A14':'npolint','\u2A15':'pointint','\u2A16':'quatint','\u2A17':'intlarhk','\u2A22':'pluscir','\u2A23':'plusacir','\u2A24':'simplus','\u2A25':'plusdu','\u2A26':'plussim','\u2A27':'plustwo','\u2A29':'mcomma','\u2A2A':'minusdu','\u2A2D':'loplus','\u2A2E':'roplus','\u2A2F':'Cross','\u2A30':'timesd','\u2A31':'timesbar','\u2A33':'smashp','\u2A34':'lotimes','\u2A35':'rotimes','\u2A36':'otimesas','\u2A37':'Otimes','\u2A38':'odiv','\u2A39':'triplus','\u2A3A':'triminus','\u2A3B':'tritime','\u2A3C':'iprod','\u2A3F':'amalg','\u2A40':'capdot','\u2A42':'ncup','\u2A43':'ncap','\u2A44':'capand','\u2A45':'cupor','\u2A46':'cupcap','\u2A47':'capcup','\u2A48':'cupbrcap','\u2A49':'capbrcup','\u2A4A':'cupcup','\u2A4B':'capcap','\u2A4C':'ccups','\u2A4D':'ccaps','\u2A50':'ccupssm','\u2A53':'And','\u2A54':'Or','\u2A55':'andand','\u2A56':'oror','\u2A57':'orslope','\u2A58':'andslope','\u2A5A':'andv','\u2A5B':'orv','\u2A5C':'andd','\u2A5D':'ord','\u2A5F':'wedbar','\u2A66':'sdote','\u2A6A':'simdot','\u2A6D':'congdot','\u2A6D\u0338':'ncongdot','\u2A6E':'easter','\u2A6F':'apacir','\u2A70':'apE','\u2A70\u0338':'napE','\u2A71':'eplus','\u2A72':'pluse','\u2A73':'Esim','\u2A77':'eDDot','\u2A78':'equivDD','\u2A79':'ltcir','\u2A7A':'gtcir','\u2A7B':'ltquest','\u2A7C':'gtquest','\u2A7D':'les','\u2A7D\u0338':'nles','\u2A7E':'ges','\u2A7E\u0338':'nges','\u2A7F':'lesdot','\u2A80':'gesdot','\u2A81':'lesdoto','\u2A82':'gesdoto','\u2A83':'lesdotor','\u2A84':'gesdotol','\u2A85':'lap','\u2A86':'gap','\u2A87':'lne','\u2A88':'gne','\u2A89':'lnap','\u2A8A':'gnap','\u2A8B':'lEg','\u2A8C':'gEl','\u2A8D':'lsime','\u2A8E':'gsime','\u2A8F':'lsimg','\u2A90':'gsiml','\u2A91':'lgE','\u2A92':'glE','\u2A93':'lesges','\u2A94':'gesles','\u2A95':'els','\u2A96':'egs','\u2A97':'elsdot','\u2A98':'egsdot','\u2A99':'el','\u2A9A':'eg','\u2A9D':'siml','\u2A9E':'simg','\u2A9F':'simlE','\u2AA0':'simgE','\u2AA1':'LessLess','\u2AA1\u0338':'NotNestedLessLess','\u2AA2':'GreaterGreater','\u2AA2\u0338':'NotNestedGreaterGreater','\u2AA4':'glj','\u2AA5':'gla','\u2AA6':'ltcc','\u2AA7':'gtcc','\u2AA8':'lescc','\u2AA9':'gescc','\u2AAA':'smt','\u2AAB':'lat','\u2AAC':'smte','\u2AAC\uFE00':'smtes','\u2AAD':'late','\u2AAD\uFE00':'lates','\u2AAE':'bumpE','\u2AAF':'pre','\u2AAF\u0338':'npre','\u2AB0':'sce','\u2AB0\u0338':'nsce','\u2AB3':'prE','\u2AB4':'scE','\u2AB5':'prnE','\u2AB6':'scnE','\u2AB7':'prap','\u2AB8':'scap','\u2AB9':'prnap','\u2ABA':'scnap','\u2ABB':'Pr','\u2ABC':'Sc','\u2ABD':'subdot','\u2ABE':'supdot','\u2ABF':'subplus','\u2AC0':'supplus','\u2AC1':'submult','\u2AC2':'supmult','\u2AC3':'subedot','\u2AC4':'supedot','\u2AC5':'subE','\u2AC5\u0338':'nsubE','\u2AC6':'supE','\u2AC6\u0338':'nsupE','\u2AC7':'subsim','\u2AC8':'supsim','\u2ACB\uFE00':'vsubnE','\u2ACB':'subnE','\u2ACC\uFE00':'vsupnE','\u2ACC':'supnE','\u2ACF':'csub','\u2AD0':'csup','\u2AD1':'csube','\u2AD2':'csupe','\u2AD3':'subsup','\u2AD4':'supsub','\u2AD5':'subsub','\u2AD6':'supsup','\u2AD7':'suphsub','\u2AD8':'supdsub','\u2AD9':'forkv','\u2ADA':'topfork','\u2ADB':'mlcp','\u2AE4':'Dashv','\u2AE6':'Vdashl','\u2AE7':'Barv','\u2AE8':'vBar','\u2AE9':'vBarv','\u2AEB':'Vbar','\u2AEC':'Not','\u2AED':'bNot','\u2AEE':'rnmid','\u2AEF':'cirmid','\u2AF0':'midcir','\u2AF1':'topcir','\u2AF2':'nhpar','\u2AF3':'parsim','\u2AFD':'parsl','\u2AFD\u20E5':'nparsl','\u266D':'flat','\u266E':'natur','\u266F':'sharp','\xA4':'curren','\xA2':'cent','$':'dollar','\xA3':'pound','\xA5':'yen','\u20AC':'euro','\xB9':'sup1','\xBD':'half','\u2153':'frac13','\xBC':'frac14','\u2155':'frac15','\u2159':'frac16','\u215B':'frac18','\xB2':'sup2','\u2154':'frac23','\u2156':'frac25','\xB3':'sup3','\xBE':'frac34','\u2157':'frac35','\u215C':'frac38','\u2158':'frac45','\u215A':'frac56','\u215D':'frac58','\u215E':'frac78','\uD835\uDCB6':'ascr','\uD835\uDD52':'aopf','\uD835\uDD1E':'afr','\uD835\uDD38':'Aopf','\uD835\uDD04':'Afr','\uD835\uDC9C':'Ascr','\xAA':'ordf','\xE1':'aacute','\xC1':'Aacute','\xE0':'agrave','\xC0':'Agrave','\u0103':'abreve','\u0102':'Abreve','\xE2':'acirc','\xC2':'Acirc','\xE5':'aring','\xC5':'angst','\xE4':'auml','\xC4':'Auml','\xE3':'atilde','\xC3':'Atilde','\u0105':'aogon','\u0104':'Aogon','\u0101':'amacr','\u0100':'Amacr','\xE6':'aelig','\xC6':'AElig','\uD835\uDCB7':'bscr','\uD835\uDD53':'bopf','\uD835\uDD1F':'bfr','\uD835\uDD39':'Bopf','\u212C':'Bscr','\uD835\uDD05':'Bfr','\uD835\uDD20':'cfr','\uD835\uDCB8':'cscr','\uD835\uDD54':'copf','\u212D':'Cfr','\uD835\uDC9E':'Cscr','\u2102':'Copf','\u0107':'cacute','\u0106':'Cacute','\u0109':'ccirc','\u0108':'Ccirc','\u010D':'ccaron','\u010C':'Ccaron','\u010B':'cdot','\u010A':'Cdot','\xE7':'ccedil','\xC7':'Ccedil','\u2105':'incare','\uD835\uDD21':'dfr','\u2146':'dd','\uD835\uDD55':'dopf','\uD835\uDCB9':'dscr','\uD835\uDC9F':'Dscr','\uD835\uDD07':'Dfr','\u2145':'DD','\uD835\uDD3B':'Dopf','\u010F':'dcaron','\u010E':'Dcaron','\u0111':'dstrok','\u0110':'Dstrok','\xF0':'eth','\xD0':'ETH','\u2147':'ee','\u212F':'escr','\uD835\uDD22':'efr','\uD835\uDD56':'eopf','\u2130':'Escr','\uD835\uDD08':'Efr','\uD835\uDD3C':'Eopf','\xE9':'eacute','\xC9':'Eacute','\xE8':'egrave','\xC8':'Egrave','\xEA':'ecirc','\xCA':'Ecirc','\u011B':'ecaron','\u011A':'Ecaron','\xEB':'euml','\xCB':'Euml','\u0117':'edot','\u0116':'Edot','\u0119':'eogon','\u0118':'Eogon','\u0113':'emacr','\u0112':'Emacr','\uD835\uDD23':'ffr','\uD835\uDD57':'fopf','\uD835\uDCBB':'fscr','\uD835\uDD09':'Ffr','\uD835\uDD3D':'Fopf','\u2131':'Fscr','\uFB00':'fflig','\uFB03':'ffilig','\uFB04':'ffllig','\uFB01':'filig','fj':'fjlig','\uFB02':'fllig','\u0192':'fnof','\u210A':'gscr','\uD835\uDD58':'gopf','\uD835\uDD24':'gfr','\uD835\uDCA2':'Gscr','\uD835\uDD3E':'Gopf','\uD835\uDD0A':'Gfr','\u01F5':'gacute','\u011F':'gbreve','\u011E':'Gbreve','\u011D':'gcirc','\u011C':'Gcirc','\u0121':'gdot','\u0120':'Gdot','\u0122':'Gcedil','\uD835\uDD25':'hfr','\u210E':'planckh','\uD835\uDCBD':'hscr','\uD835\uDD59':'hopf','\u210B':'Hscr','\u210C':'Hfr','\u210D':'Hopf','\u0125':'hcirc','\u0124':'Hcirc','\u210F':'hbar','\u0127':'hstrok','\u0126':'Hstrok','\uD835\uDD5A':'iopf','\uD835\uDD26':'ifr','\uD835\uDCBE':'iscr','\u2148':'ii','\uD835\uDD40':'Iopf','\u2110':'Iscr','\u2111':'Im','\xED':'iacute','\xCD':'Iacute','\xEC':'igrave','\xCC':'Igrave','\xEE':'icirc','\xCE':'Icirc','\xEF':'iuml','\xCF':'Iuml','\u0129':'itilde','\u0128':'Itilde','\u0130':'Idot','\u012F':'iogon','\u012E':'Iogon','\u012B':'imacr','\u012A':'Imacr','\u0133':'ijlig','\u0132':'IJlig','\u0131':'imath','\uD835\uDCBF':'jscr','\uD835\uDD5B':'jopf','\uD835\uDD27':'jfr','\uD835\uDCA5':'Jscr','\uD835\uDD0D':'Jfr','\uD835\uDD41':'Jopf','\u0135':'jcirc','\u0134':'Jcirc','\u0237':'jmath','\uD835\uDD5C':'kopf','\uD835\uDCC0':'kscr','\uD835\uDD28':'kfr','\uD835\uDCA6':'Kscr','\uD835\uDD42':'Kopf','\uD835\uDD0E':'Kfr','\u0137':'kcedil','\u0136':'Kcedil','\uD835\uDD29':'lfr','\uD835\uDCC1':'lscr','\u2113':'ell','\uD835\uDD5D':'lopf','\u2112':'Lscr','\uD835\uDD0F':'Lfr','\uD835\uDD43':'Lopf','\u013A':'lacute','\u0139':'Lacute','\u013E':'lcaron','\u013D':'Lcaron','\u013C':'lcedil','\u013B':'Lcedil','\u0142':'lstrok','\u0141':'Lstrok','\u0140':'lmidot','\u013F':'Lmidot','\uD835\uDD2A':'mfr','\uD835\uDD5E':'mopf','\uD835\uDCC2':'mscr','\uD835\uDD10':'Mfr','\uD835\uDD44':'Mopf','\u2133':'Mscr','\uD835\uDD2B':'nfr','\uD835\uDD5F':'nopf','\uD835\uDCC3':'nscr','\u2115':'Nopf','\uD835\uDCA9':'Nscr','\uD835\uDD11':'Nfr','\u0144':'nacute','\u0143':'Nacute','\u0148':'ncaron','\u0147':'Ncaron','\xF1':'ntilde','\xD1':'Ntilde','\u0146':'ncedil','\u0145':'Ncedil','\u2116':'numero','\u014B':'eng','\u014A':'ENG','\uD835\uDD60':'oopf','\uD835\uDD2C':'ofr','\u2134':'oscr','\uD835\uDCAA':'Oscr','\uD835\uDD12':'Ofr','\uD835\uDD46':'Oopf','\xBA':'ordm','\xF3':'oacute','\xD3':'Oacute','\xF2':'ograve','\xD2':'Ograve','\xF4':'ocirc','\xD4':'Ocirc','\xF6':'ouml','\xD6':'Ouml','\u0151':'odblac','\u0150':'Odblac','\xF5':'otilde','\xD5':'Otilde','\xF8':'oslash','\xD8':'Oslash','\u014D':'omacr','\u014C':'Omacr','\u0153':'oelig','\u0152':'OElig','\uD835\uDD2D':'pfr','\uD835\uDCC5':'pscr','\uD835\uDD61':'popf','\u2119':'Popf','\uD835\uDD13':'Pfr','\uD835\uDCAB':'Pscr','\uD835\uDD62':'qopf','\uD835\uDD2E':'qfr','\uD835\uDCC6':'qscr','\uD835\uDCAC':'Qscr','\uD835\uDD14':'Qfr','\u211A':'Qopf','\u0138':'kgreen','\uD835\uDD2F':'rfr','\uD835\uDD63':'ropf','\uD835\uDCC7':'rscr','\u211B':'Rscr','\u211C':'Re','\u211D':'Ropf','\u0155':'racute','\u0154':'Racute','\u0159':'rcaron','\u0158':'Rcaron','\u0157':'rcedil','\u0156':'Rcedil','\uD835\uDD64':'sopf','\uD835\uDCC8':'sscr','\uD835\uDD30':'sfr','\uD835\uDD4A':'Sopf','\uD835\uDD16':'Sfr','\uD835\uDCAE':'Sscr','\u24C8':'oS','\u015B':'sacute','\u015A':'Sacute','\u015D':'scirc','\u015C':'Scirc','\u0161':'scaron','\u0160':'Scaron','\u015F':'scedil','\u015E':'Scedil','\xDF':'szlig','\uD835\uDD31':'tfr','\uD835\uDCC9':'tscr','\uD835\uDD65':'topf','\uD835\uDCAF':'Tscr','\uD835\uDD17':'Tfr','\uD835\uDD4B':'Topf','\u0165':'tcaron','\u0164':'Tcaron','\u0163':'tcedil','\u0162':'Tcedil','\u2122':'trade','\u0167':'tstrok','\u0166':'Tstrok','\uD835\uDCCA':'uscr','\uD835\uDD66':'uopf','\uD835\uDD32':'ufr','\uD835\uDD4C':'Uopf','\uD835\uDD18':'Ufr','\uD835\uDCB0':'Uscr','\xFA':'uacute','\xDA':'Uacute','\xF9':'ugrave','\xD9':'Ugrave','\u016D':'ubreve','\u016C':'Ubreve','\xFB':'ucirc','\xDB':'Ucirc','\u016F':'uring','\u016E':'Uring','\xFC':'uuml','\xDC':'Uuml','\u0171':'udblac','\u0170':'Udblac','\u0169':'utilde','\u0168':'Utilde','\u0173':'uogon','\u0172':'Uogon','\u016B':'umacr','\u016A':'Umacr','\uD835\uDD33':'vfr','\uD835\uDD67':'vopf','\uD835\uDCCB':'vscr','\uD835\uDD19':'Vfr','\uD835\uDD4D':'Vopf','\uD835\uDCB1':'Vscr','\uD835\uDD68':'wopf','\uD835\uDCCC':'wscr','\uD835\uDD34':'wfr','\uD835\uDCB2':'Wscr','\uD835\uDD4E':'Wopf','\uD835\uDD1A':'Wfr','\u0175':'wcirc','\u0174':'Wcirc','\uD835\uDD35':'xfr','\uD835\uDCCD':'xscr','\uD835\uDD69':'xopf','\uD835\uDD4F':'Xopf','\uD835\uDD1B':'Xfr','\uD835\uDCB3':'Xscr','\uD835\uDD36':'yfr','\uD835\uDCCE':'yscr','\uD835\uDD6A':'yopf','\uD835\uDCB4':'Yscr','\uD835\uDD1C':'Yfr','\uD835\uDD50':'Yopf','\xFD':'yacute','\xDD':'Yacute','\u0177':'ycirc','\u0176':'Ycirc','\xFF':'yuml','\u0178':'Yuml','\uD835\uDCCF':'zscr','\uD835\uDD37':'zfr','\uD835\uDD6B':'zopf','\u2128':'Zfr','\u2124':'Zopf','\uD835\uDCB5':'Zscr','\u017A':'zacute','\u0179':'Zacute','\u017E':'zcaron','\u017D':'Zcaron','\u017C':'zdot','\u017B':'Zdot','\u01B5':'imped','\xFE':'thorn','\xDE':'THORN','\u0149':'napos','\u03B1':'alpha','\u0391':'Alpha','\u03B2':'beta','\u0392':'Beta','\u03B3':'gamma','\u0393':'Gamma','\u03B4':'delta','\u0394':'Delta','\u03B5':'epsi','\u03F5':'epsiv','\u0395':'Epsilon','\u03DD':'gammad','\u03DC':'Gammad','\u03B6':'zeta','\u0396':'Zeta','\u03B7':'eta','\u0397':'Eta','\u03B8':'theta','\u03D1':'thetav','\u0398':'Theta','\u03B9':'iota','\u0399':'Iota','\u03BA':'kappa','\u03F0':'kappav','\u039A':'Kappa','\u03BB':'lambda','\u039B':'Lambda','\u03BC':'mu','\xB5':'micro','\u039C':'Mu','\u03BD':'nu','\u039D':'Nu','\u03BE':'xi','\u039E':'Xi','\u03BF':'omicron','\u039F':'Omicron','\u03C0':'pi','\u03D6':'piv','\u03A0':'Pi','\u03C1':'rho','\u03F1':'rhov','\u03A1':'Rho','\u03C3':'sigma','\u03A3':'Sigma','\u03C2':'sigmaf','\u03C4':'tau','\u03A4':'Tau','\u03C5':'upsi','\u03A5':'Upsilon','\u03D2':'Upsi','\u03C6':'phi','\u03D5':'phiv','\u03A6':'Phi','\u03C7':'chi','\u03A7':'Chi','\u03C8':'psi','\u03A8':'Psi','\u03C9':'omega','\u03A9':'ohm','\u0430':'acy','\u0410':'Acy','\u0431':'bcy','\u0411':'Bcy','\u0432':'vcy','\u0412':'Vcy','\u0433':'gcy','\u0413':'Gcy','\u0453':'gjcy','\u0403':'GJcy','\u0434':'dcy','\u0414':'Dcy','\u0452':'djcy','\u0402':'DJcy','\u0435':'iecy','\u0415':'IEcy','\u0451':'iocy','\u0401':'IOcy','\u0454':'jukcy','\u0404':'Jukcy','\u0436':'zhcy','\u0416':'ZHcy','\u0437':'zcy','\u0417':'Zcy','\u0455':'dscy','\u0405':'DScy','\u0438':'icy','\u0418':'Icy','\u0456':'iukcy','\u0406':'Iukcy','\u0457':'yicy','\u0407':'YIcy','\u0439':'jcy','\u0419':'Jcy','\u0458':'jsercy','\u0408':'Jsercy','\u043A':'kcy','\u041A':'Kcy','\u045C':'kjcy','\u040C':'KJcy','\u043B':'lcy','\u041B':'Lcy','\u0459':'ljcy','\u0409':'LJcy','\u043C':'mcy','\u041C':'Mcy','\u043D':'ncy','\u041D':'Ncy','\u045A':'njcy','\u040A':'NJcy','\u043E':'ocy','\u041E':'Ocy','\u043F':'pcy','\u041F':'Pcy','\u0440':'rcy','\u0420':'Rcy','\u0441':'scy','\u0421':'Scy','\u0442':'tcy','\u0422':'Tcy','\u045B':'tshcy','\u040B':'TSHcy','\u0443':'ucy','\u0423':'Ucy','\u045E':'ubrcy','\u040E':'Ubrcy','\u0444':'fcy','\u0424':'Fcy','\u0445':'khcy','\u0425':'KHcy','\u0446':'tscy','\u0426':'TScy','\u0447':'chcy','\u0427':'CHcy','\u045F':'dzcy','\u040F':'DZcy','\u0448':'shcy','\u0428':'SHcy','\u0449':'shchcy','\u0429':'SHCHcy','\u044A':'hardcy','\u042A':'HARDcy','\u044B':'ycy','\u042B':'Ycy','\u044C':'softcy','\u042C':'SOFTcy','\u044D':'ecy','\u042D':'Ecy','\u044E':'yucy','\u042E':'YUcy','\u044F':'yacy','\u042F':'YAcy','\u2135':'aleph','\u2136':'beth','\u2137':'gimel','\u2138':'daleth'};
  12064. var regexEscape = /["&'<>`]/g;
  12065. var escapeMap = {
  12066. '"': '&quot;',
  12067. '&': '&amp;',
  12068. '\'': '&#x27;',
  12069. '<': '&lt;',
  12070. // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
  12071. // following is not strictly necessary unless it’s part of a tag or an
  12072. // unquoted attribute value. We’re only escaping it to support those
  12073. // situations, and for XML support.
  12074. '>': '&gt;',
  12075. // In Internet Explorer ≤ 8, the backtick character can be used
  12076. // to break out of (un)quoted attribute values or HTML comments.
  12077. // See http://html5sec.org/#102, http://html5sec.org/#108, and
  12078. // http://html5sec.org/#133.
  12079. '`': '&#x60;'
  12080. };
  12081. var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
  12082. var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  12083. var regexDecode = /&(CounterClockwiseContourIntegral|DoubleLongLeftRightArrow|ClockwiseContourIntegral|NotNestedGreaterGreater|NotSquareSupersetEqual|DiacriticalDoubleAcute|NotRightTriangleEqual|NotSucceedsSlantEqual|NotPrecedesSlantEqual|CloseCurlyDoubleQuote|NegativeVeryThinSpace|DoubleContourIntegral|FilledVerySmallSquare|CapitalDifferentialD|OpenCurlyDoubleQuote|EmptyVerySmallSquare|NestedGreaterGreater|DoubleLongRightArrow|NotLeftTriangleEqual|NotGreaterSlantEqual|ReverseUpEquilibrium|DoubleLeftRightArrow|NotSquareSubsetEqual|NotDoubleVerticalBar|RightArrowLeftArrow|NotGreaterFullEqual|NotRightTriangleBar|SquareSupersetEqual|DownLeftRightVector|DoubleLongLeftArrow|leftrightsquigarrow|LeftArrowRightArrow|NegativeMediumSpace|blacktriangleright|RightDownVectorBar|PrecedesSlantEqual|RightDoubleBracket|SucceedsSlantEqual|NotLeftTriangleBar|RightTriangleEqual|SquareIntersection|RightDownTeeVector|ReverseEquilibrium|NegativeThickSpace|longleftrightarrow|Longleftrightarrow|LongLeftRightArrow|DownRightTeeVector|DownRightVectorBar|GreaterSlantEqual|SquareSubsetEqual|LeftDownVectorBar|LeftDoubleBracket|VerticalSeparator|rightleftharpoons|NotGreaterGreater|NotSquareSuperset|blacktriangleleft|blacktriangledown|NegativeThinSpace|LeftDownTeeVector|NotLessSlantEqual|leftrightharpoons|DoubleUpDownArrow|DoubleVerticalBar|LeftTriangleEqual|FilledSmallSquare|twoheadrightarrow|NotNestedLessLess|DownLeftTeeVector|DownLeftVectorBar|RightAngleBracket|NotTildeFullEqual|NotReverseElement|RightUpDownVector|DiacriticalTilde|NotSucceedsTilde|circlearrowright|NotPrecedesEqual|rightharpoondown|DoubleRightArrow|NotSucceedsEqual|NonBreakingSpace|NotRightTriangle|LessEqualGreater|RightUpTeeVector|LeftAngleBracket|GreaterFullEqual|DownArrowUpArrow|RightUpVectorBar|twoheadleftarrow|GreaterEqualLess|downharpoonright|RightTriangleBar|ntrianglerighteq|NotSupersetEqual|LeftUpDownVector|DiacriticalAcute|rightrightarrows|vartriangleright|UpArrowDownArrow|DiacriticalGrave|UnderParenthesis|EmptySmallSquare|LeftUpVectorBar|leftrightarrows|DownRightVector|downharpoonleft|trianglerighteq|ShortRightArrow|OverParenthesis|DoubleLeftArrow|DoubleDownArrow|NotSquareSubset|bigtriangledown|ntrianglelefteq|UpperRightArrow|curvearrowright|vartriangleleft|NotLeftTriangle|nleftrightarrow|LowerRightArrow|NotHumpDownHump|NotGreaterTilde|rightthreetimes|LeftUpTeeVector|NotGreaterEqual|straightepsilon|LeftTriangleBar|rightsquigarrow|ContourIntegral|rightleftarrows|CloseCurlyQuote|RightDownVector|LeftRightVector|nLeftrightarrow|leftharpoondown|circlearrowleft|SquareSuperset|OpenCurlyQuote|hookrightarrow|HorizontalLine|DiacriticalDot|NotLessGreater|ntriangleright|DoubleRightTee|InvisibleComma|InvisibleTimes|LowerLeftArrow|DownLeftVector|NotSubsetEqual|curvearrowleft|trianglelefteq|NotVerticalBar|TildeFullEqual|downdownarrows|NotGreaterLess|RightTeeVector|ZeroWidthSpace|looparrowright|LongRightArrow|doublebarwedge|ShortLeftArrow|ShortDownArrow|RightVectorBar|GreaterGreater|ReverseElement|rightharpoonup|LessSlantEqual|leftthreetimes|upharpoonright|rightarrowtail|LeftDownVector|Longrightarrow|NestedLessLess|UpperLeftArrow|nshortparallel|leftleftarrows|leftrightarrow|Leftrightarrow|LeftRightArrow|longrightarrow|upharpoonleft|RightArrowBar|ApplyFunction|LeftTeeVector|leftarrowtail|NotEqualTilde|varsubsetneqq|varsupsetneqq|RightTeeArrow|SucceedsEqual|SucceedsTilde|LeftVectorBar|SupersetEqual|hookleftarrow|DifferentialD|VerticalTilde|VeryThinSpace|blacktriangle|bigtriangleup|LessFullEqual|divideontimes|leftharpoonup|UpEquilibrium|ntriangleleft|RightTriangle|measuredangle|shortparallel|longleftarrow|Longleftarrow|LongLeftArrow|DoubleLeftTee|Poincareplane|PrecedesEqual|triangleright|DoubleUpArrow|RightUpVector|fallingdotseq|looparrowleft|PrecedesTilde|NotTildeEqual|NotTildeTilde|smallsetminus|Proportional|triangleleft|triangledown|UnderBracket|NotHumpEqual|exponentiale|ExponentialE|NotLessTilde|HilbertSpace|RightCeiling|blacklozenge|varsupsetneq|HumpDownHump|GreaterEqual|VerticalLine|LeftTeeArrow|NotLessEqual|DownTeeArrow|LeftTriangle|varsubsetneq|Intersection|NotCongruent|DownArrowBar|LeftUpVector|LeftArrowBar|risingdotseq|GreaterTilde|RoundImplies|SquareSubset|ShortUpArrow|NotSuperset|quaternions|precnapprox|backepsilon|preccurlyeq|OverBracket|blacksquare|MediumSpace|VerticalBar|circledcirc|circleddash|CircleMinus|CircleTimes|LessGreater|curlyeqprec|curlyeqsucc|diamondsuit|UpDownArrow|Updownarrow|RuleDelayed|Rrightarrow|updownarrow|RightVector|nRightarrow|nrightarrow|eqslantless|LeftCeiling|Equilibrium|SmallCircle|expectation|NotSucceeds|thickapprox|GreaterLess|SquareUnion|NotPrecedes|NotLessLess|straightphi|succnapprox|succcurlyeq|SubsetEqual|sqsupseteq|Proportion|Laplacetrf|ImaginaryI|supsetneqq|NotGreater|gtreqqless|NotElement|ThickSpace|TildeEqual|TildeTilde|Fouriertrf|rmoustache|EqualTilde|eqslantgtr|UnderBrace|LeftVector|UpArrowBar|nLeftarrow|nsubseteqq|subsetneqq|nsupseteqq|nleftarrow|succapprox|lessapprox|UpTeeArrow|upuparrows|curlywedge|lesseqqgtr|varepsilon|varnothing|RightFloor|complement|CirclePlus|sqsubseteq|Lleftarrow|circledast|RightArrow|Rightarrow|rightarrow|lmoustache|Bernoullis|precapprox|mapstoleft|mapstodown|longmapsto|dotsquare|downarrow|DoubleDot|nsubseteq|supsetneq|leftarrow|nsupseteq|subsetneq|ThinSpace|ngeqslant|subseteqq|HumpEqual|NotSubset|triangleq|NotCupCap|lesseqgtr|heartsuit|TripleDot|Leftarrow|Coproduct|Congruent|varpropto|complexes|gvertneqq|LeftArrow|LessTilde|supseteqq|MinusPlus|CircleDot|nleqslant|NotExists|gtreqless|nparallel|UnionPlus|LeftFloor|checkmark|CenterDot|centerdot|Mellintrf|gtrapprox|bigotimes|OverBrace|spadesuit|therefore|pitchfork|rationals|PlusMinus|Backslash|Therefore|DownBreve|backsimeq|backprime|DownArrow|nshortmid|Downarrow|lvertneqq|eqvparsl|imagline|imagpart|infintie|integers|Integral|intercal|LessLess|Uarrocir|intlarhk|sqsupset|angmsdaf|sqsubset|llcorner|vartheta|cupbrcap|lnapprox|Superset|SuchThat|succnsim|succneqq|angmsdag|biguplus|curlyvee|trpezium|Succeeds|NotTilde|bigwedge|angmsdah|angrtvbd|triminus|cwconint|fpartint|lrcorner|smeparsl|subseteq|urcorner|lurdshar|laemptyv|DDotrahd|approxeq|ldrushar|awconint|mapstoup|backcong|shortmid|triangle|geqslant|gesdotol|timesbar|circledR|circledS|setminus|multimap|naturals|scpolint|ncongdot|RightTee|boxminus|gnapprox|boxtimes|andslope|thicksim|angmsdaa|varsigma|cirfnint|rtriltri|angmsdab|rppolint|angmsdac|barwedge|drbkarow|clubsuit|thetasym|bsolhsub|capbrcup|dzigrarr|doteqdot|DotEqual|dotminus|UnderBar|NotEqual|realpart|otimesas|ulcorner|hksearow|hkswarow|parallel|PartialD|elinters|emptyset|plusacir|bbrktbrk|angmsdad|pointint|bigoplus|angmsdae|Precedes|bigsqcup|varkappa|notindot|supseteq|precneqq|precnsim|profalar|profline|profsurf|leqslant|lesdotor|raemptyv|subplus|notnivb|notnivc|subrarr|zigrarr|vzigzag|submult|subedot|Element|between|cirscir|larrbfs|larrsim|lotimes|lbrksld|lbrkslu|lozenge|ldrdhar|dbkarow|bigcirc|epsilon|simrarr|simplus|ltquest|Epsilon|luruhar|gtquest|maltese|npolint|eqcolon|npreceq|bigodot|ddagger|gtrless|bnequiv|harrcir|ddotseq|equivDD|backsim|demptyv|nsqsube|nsqsupe|Upsilon|nsubset|upsilon|minusdu|nsucceq|swarrow|nsupset|coloneq|searrow|boxplus|napprox|natural|asympeq|alefsym|congdot|nearrow|bigstar|diamond|supplus|tritime|LeftTee|nvinfin|triplus|NewLine|nvltrie|nvrtrie|nwarrow|nexists|Diamond|ruluhar|Implies|supmult|angzarr|suplarr|suphsub|questeq|because|digamma|Because|olcross|bemptyv|omicron|Omicron|rotimes|NoBreak|intprod|angrtvb|orderof|uwangle|suphsol|lesdoto|orslope|DownTee|realine|cudarrl|rdldhar|OverBar|supedot|lessdot|supdsub|topfork|succsim|rbrkslu|rbrksld|pertenk|cudarrr|isindot|planckh|lessgtr|pluscir|gesdoto|plussim|plustwo|lesssim|cularrp|rarrsim|Cayleys|notinva|notinvb|notinvc|UpArrow|Uparrow|uparrow|NotLess|dwangle|precsim|Product|curarrm|Cconint|dotplus|rarrbfs|ccupssm|Cedilla|cemptyv|notniva|quatint|frac35|frac38|frac45|frac56|frac58|frac78|tridot|xoplus|gacute|gammad|Gammad|lfisht|lfloor|bigcup|sqsupe|gbreve|Gbreve|lharul|sqsube|sqcups|Gcedil|apacir|llhard|lmidot|Lmidot|lmoust|andand|sqcaps|approx|Abreve|spades|circeq|tprime|divide|topcir|Assign|topbot|gesdot|divonx|xuplus|timesd|gesles|atilde|solbar|SOFTcy|loplus|timesb|lowast|lowbar|dlcorn|dlcrop|softcy|dollar|lparlt|thksim|lrhard|Atilde|lsaquo|smashp|bigvee|thinsp|wreath|bkarow|lsquor|lstrok|Lstrok|lthree|ltimes|ltlarr|DotDot|simdot|ltrPar|weierp|xsqcup|angmsd|sigmav|sigmaf|zeetrf|Zcaron|zcaron|mapsto|vsupne|thetav|cirmid|marker|mcomma|Zacute|vsubnE|there4|gtlPar|vsubne|bottom|gtrarr|SHCHcy|shchcy|midast|midcir|middot|minusb|minusd|gtrdot|bowtie|sfrown|mnplus|models|colone|seswar|Colone|mstpos|searhk|gtrsim|nacute|Nacute|boxbox|telrec|hairsp|Tcedil|nbumpe|scnsim|ncaron|Ncaron|ncedil|Ncedil|hamilt|Scedil|nearhk|hardcy|HARDcy|tcedil|Tcaron|commat|nequiv|nesear|tcaron|target|hearts|nexist|varrho|scedil|Scaron|scaron|hellip|Sacute|sacute|hercon|swnwar|compfn|rtimes|rthree|rsquor|rsaquo|zacute|wedgeq|homtht|barvee|barwed|Barwed|rpargt|horbar|conint|swarhk|roplus|nltrie|hslash|hstrok|Hstrok|rmoust|Conint|bprime|hybull|hyphen|iacute|Iacute|supsup|supsub|supsim|varphi|coprod|brvbar|agrave|Supset|supset|igrave|Igrave|notinE|Agrave|iiiint|iinfin|copysr|wedbar|Verbar|vangrt|becaus|incare|verbar|inodot|bullet|drcorn|intcal|drcrop|cularr|vellip|Utilde|bumpeq|cupcap|dstrok|Dstrok|CupCap|cupcup|cupdot|eacute|Eacute|supdot|iquest|easter|ecaron|Ecaron|ecolon|isinsv|utilde|itilde|Itilde|curarr|succeq|Bumpeq|cacute|ulcrop|nparsl|Cacute|nprcue|egrave|Egrave|nrarrc|nrarrw|subsup|subsub|nrtrie|jsercy|nsccue|Jsercy|kappav|kcedil|Kcedil|subsim|ulcorn|nsimeq|egsdot|veebar|kgreen|capand|elsdot|Subset|subset|curren|aacute|lacute|Lacute|emptyv|ntilde|Ntilde|lagran|lambda|Lambda|capcap|Ugrave|langle|subdot|emsp13|numero|emsp14|nvdash|nvDash|nVdash|nVDash|ugrave|ufisht|nvHarr|larrfs|nvlArr|larrhk|larrlp|larrpl|nvrArr|Udblac|nwarhk|larrtl|nwnear|oacute|Oacute|latail|lAtail|sstarf|lbrace|odblac|Odblac|lbrack|udblac|odsold|eparsl|lcaron|Lcaron|ograve|Ograve|lcedil|Lcedil|Aacute|ssmile|ssetmn|squarf|ldquor|capcup|ominus|cylcty|rharul|eqcirc|dagger|rfloor|rfisht|Dagger|daleth|equals|origof|capdot|equest|dcaron|Dcaron|rdquor|oslash|Oslash|otilde|Otilde|otimes|Otimes|urcrop|Ubreve|ubreve|Yacute|Uacute|uacute|Rcedil|rcedil|urcorn|parsim|Rcaron|Vdashl|rcaron|Tstrok|percnt|period|permil|Exists|yacute|rbrack|rbrace|phmmat|ccaron|Ccaron|planck|ccedil|plankv|tstrok|female|plusdo|plusdu|ffilig|plusmn|ffllig|Ccedil|rAtail|dfisht|bernou|ratail|Rarrtl|rarrtl|angsph|rarrpl|rarrlp|rarrhk|xwedge|xotime|forall|ForAll|Vvdash|vsupnE|preceq|bigcap|frac12|frac13|frac14|primes|rarrfs|prnsim|frac15|Square|frac16|square|lesdot|frac18|frac23|propto|prurel|rarrap|rangle|puncsp|frac25|Racute|qprime|racute|lesges|frac34|abreve|AElig|eqsim|utdot|setmn|urtri|Equal|Uring|seArr|uring|searr|dashv|Dashv|mumap|nabla|iogon|Iogon|sdote|sdotb|scsim|napid|napos|equiv|natur|Acirc|dblac|erarr|nbump|iprod|erDot|ucirc|awint|esdot|angrt|ncong|isinE|scnap|Scirc|scirc|ndash|isins|Ubrcy|nearr|neArr|isinv|nedot|ubrcy|acute|Ycirc|iukcy|Iukcy|xutri|nesim|caret|jcirc|Jcirc|caron|twixt|ddarr|sccue|exist|jmath|sbquo|ngeqq|angst|ccaps|lceil|ngsim|UpTee|delta|Delta|rtrif|nharr|nhArr|nhpar|rtrie|jukcy|Jukcy|kappa|rsquo|Kappa|nlarr|nlArr|TSHcy|rrarr|aogon|Aogon|fflig|xrarr|tshcy|ccirc|nleqq|filig|upsih|nless|dharl|nlsim|fjlig|ropar|nltri|dharr|robrk|roarr|fllig|fltns|roang|rnmid|subnE|subne|lAarr|trisb|Ccirc|acirc|ccups|blank|VDash|forkv|Vdash|langd|cedil|blk12|blk14|laquo|strns|diams|notin|vDash|larrb|blk34|block|disin|uplus|vdash|vBarv|aelig|starf|Wedge|check|xrArr|lates|lbarr|lBarr|notni|lbbrk|bcong|frasl|lbrke|frown|vrtri|vprop|vnsup|gamma|Gamma|wedge|xodot|bdquo|srarr|doteq|ldquo|boxdl|boxdL|gcirc|Gcirc|boxDl|boxDL|boxdr|boxdR|boxDr|TRADE|trade|rlhar|boxDR|vnsub|npart|vltri|rlarr|boxhd|boxhD|nprec|gescc|nrarr|nrArr|boxHd|boxHD|boxhu|boxhU|nrtri|boxHu|clubs|boxHU|times|colon|Colon|gimel|xlArr|Tilde|nsime|tilde|nsmid|nspar|THORN|thorn|xlarr|nsube|nsubE|thkap|xhArr|comma|nsucc|boxul|boxuL|nsupe|nsupE|gneqq|gnsim|boxUl|boxUL|grave|boxur|boxuR|boxUr|boxUR|lescc|angle|bepsi|boxvh|varpi|boxvH|numsp|Theta|gsime|gsiml|theta|boxVh|boxVH|boxvl|gtcir|gtdot|boxvL|boxVl|boxVL|crarr|cross|Cross|nvsim|boxvr|nwarr|nwArr|sqsup|dtdot|Uogon|lhard|lharu|dtrif|ocirc|Ocirc|lhblk|duarr|odash|sqsub|Hacek|sqcup|llarr|duhar|oelig|OElig|ofcir|boxvR|uogon|lltri|boxVr|csube|uuarr|ohbar|csupe|ctdot|olarr|olcir|harrw|oline|sqcap|omacr|Omacr|omega|Omega|boxVR|aleph|lneqq|lnsim|loang|loarr|rharu|lobrk|hcirc|operp|oplus|rhard|Hcirc|orarr|Union|order|ecirc|Ecirc|cuepr|szlig|cuesc|breve|reals|eDDot|Breve|hoarr|lopar|utrif|rdquo|Umacr|umacr|efDot|swArr|ultri|alpha|rceil|ovbar|swarr|Wcirc|wcirc|smtes|smile|bsemi|lrarr|aring|parsl|lrhar|bsime|uhblk|lrtri|cupor|Aring|uharr|uharl|slarr|rbrke|bsolb|lsime|rbbrk|RBarr|lsimg|phone|rBarr|rbarr|icirc|lsquo|Icirc|emacr|Emacr|ratio|simne|plusb|simlE|simgE|simeq|pluse|ltcir|ltdot|empty|xharr|xdtri|iexcl|Alpha|ltrie|rarrw|pound|ltrif|xcirc|bumpe|prcue|bumpE|asymp|amacr|cuvee|Sigma|sigma|iiint|udhar|iiota|ijlig|IJlig|supnE|imacr|Imacr|prime|Prime|image|prnap|eogon|Eogon|rarrc|mdash|mDDot|cuwed|imath|supne|imped|Amacr|udarr|prsim|micro|rarrb|cwint|raquo|infin|eplus|range|rangd|Ucirc|radic|minus|amalg|veeeq|rAarr|epsiv|ycirc|quest|sharp|quot|zwnj|Qscr|race|qscr|Qopf|qopf|qint|rang|Rang|Zscr|zscr|Zopf|zopf|rarr|rArr|Rarr|Pscr|pscr|prop|prod|prnE|prec|ZHcy|zhcy|prap|Zeta|zeta|Popf|popf|Zdot|plus|zdot|Yuml|yuml|phiv|YUcy|yucy|Yscr|yscr|perp|Yopf|yopf|part|para|YIcy|Ouml|rcub|yicy|YAcy|rdca|ouml|osol|Oscr|rdsh|yacy|real|oscr|xvee|andd|rect|andv|Xscr|oror|ordm|ordf|xscr|ange|aopf|Aopf|rHar|Xopf|opar|Oopf|xopf|xnis|rhov|oopf|omid|xmap|oint|apid|apos|ogon|ascr|Ascr|odot|odiv|xcup|xcap|ocir|oast|nvlt|nvle|nvgt|nvge|nvap|Wscr|wscr|auml|ntlg|ntgl|nsup|nsub|nsim|Nscr|nscr|nsce|Wopf|ring|npre|wopf|npar|Auml|Barv|bbrk|Nopf|nopf|nmid|nLtv|beta|ropf|Ropf|Beta|beth|nles|rpar|nleq|bnot|bNot|nldr|NJcy|rscr|Rscr|Vscr|vscr|rsqb|njcy|bopf|nisd|Bopf|rtri|Vopf|nGtv|ngtr|vopf|boxh|boxH|boxv|nges|ngeq|boxV|bscr|scap|Bscr|bsim|Vert|vert|bsol|bull|bump|caps|cdot|ncup|scnE|ncap|nbsp|napE|Cdot|cent|sdot|Vbar|nang|vBar|chcy|Mscr|mscr|sect|semi|CHcy|Mopf|mopf|sext|circ|cire|mldr|mlcp|cirE|comp|shcy|SHcy|vArr|varr|cong|copf|Copf|copy|COPY|malt|male|macr|lvnE|cscr|ltri|sime|ltcc|simg|Cscr|siml|csub|Uuml|lsqb|lsim|uuml|csup|Lscr|lscr|utri|smid|lpar|cups|smte|lozf|darr|Lopf|Uscr|solb|lopf|sopf|Sopf|lneq|uscr|spar|dArr|lnap|Darr|dash|Sqrt|LJcy|ljcy|lHar|dHar|Upsi|upsi|diam|lesg|djcy|DJcy|leqq|dopf|Dopf|dscr|Dscr|dscy|ldsh|ldca|squf|DScy|sscr|Sscr|dsol|lcub|late|star|Star|Uopf|Larr|lArr|larr|uopf|dtri|dzcy|sube|subE|Lang|lang|Kscr|kscr|Kopf|kopf|KJcy|kjcy|KHcy|khcy|DZcy|ecir|edot|eDot|Jscr|jscr|succ|Jopf|jopf|Edot|uHar|emsp|ensp|Iuml|iuml|eopf|isin|Iscr|iscr|Eopf|epar|sung|epsi|escr|sup1|sup2|sup3|Iota|iota|supe|supE|Iopf|iopf|IOcy|iocy|Escr|esim|Esim|imof|Uarr|QUOT|uArr|uarr|euml|IEcy|iecy|Idot|Euml|euro|excl|Hscr|hscr|Hopf|hopf|TScy|tscy|Tscr|hbar|tscr|flat|tbrk|fnof|hArr|harr|half|fopf|Fopf|tdot|gvnE|fork|trie|gtcc|fscr|Fscr|gdot|gsim|Gscr|gscr|Gopf|gopf|gneq|Gdot|tosa|gnap|Topf|topf|geqq|toea|GJcy|gjcy|tint|gesl|mid|Sfr|ggg|top|ges|gla|glE|glj|geq|gne|gEl|gel|gnE|Gcy|gcy|gap|Tfr|tfr|Tcy|tcy|Hat|Tau|Ffr|tau|Tab|hfr|Hfr|ffr|Fcy|fcy|icy|Icy|iff|ETH|eth|ifr|Ifr|Eta|eta|int|Int|Sup|sup|ucy|Ucy|Sum|sum|jcy|ENG|ufr|Ufr|eng|Jcy|jfr|els|ell|egs|Efr|efr|Jfr|uml|kcy|Kcy|Ecy|ecy|kfr|Kfr|lap|Sub|sub|lat|lcy|Lcy|leg|Dot|dot|lEg|leq|les|squ|div|die|lfr|Lfr|lgE|Dfr|dfr|Del|deg|Dcy|dcy|lne|lnE|sol|loz|smt|Cup|lrm|cup|lsh|Lsh|sim|shy|map|Map|mcy|Mcy|mfr|Mfr|mho|gfr|Gfr|sfr|cir|Chi|chi|nap|Cfr|vcy|Vcy|cfr|Scy|scy|ncy|Ncy|vee|Vee|Cap|cap|nfr|scE|sce|Nfr|nge|ngE|nGg|vfr|Vfr|ngt|bot|nGt|nis|niv|Rsh|rsh|nle|nlE|bne|Bfr|bfr|nLl|nlt|nLt|Bcy|bcy|not|Not|rlm|wfr|Wfr|npr|nsc|num|ocy|ast|Ocy|ofr|xfr|Xfr|Ofr|ogt|ohm|apE|olt|Rho|ape|rho|Rfr|rfr|ord|REG|ang|reg|orv|And|and|AMP|Rcy|amp|Afr|ycy|Ycy|yen|yfr|Yfr|rcy|par|pcy|Pcy|pfr|Pfr|phi|Phi|afr|Acy|acy|zcy|Zcy|piv|acE|acd|zfr|Zfr|pre|prE|psi|Psi|qfr|Qfr|zwj|Or|ge|Gg|gt|gg|el|oS|lt|Lt|LT|Re|lg|gl|eg|ne|Im|it|le|DD|wp|wr|nu|Nu|dd|lE|Sc|sc|pi|Pi|ee|af|ll|Ll|rx|gE|xi|pm|Xi|ic|pr|Pr|in|ni|mp|mu|ac|Mu|or|ap|Gt|GT|ii);|&(Aacute|Agrave|Atilde|Ccedil|Eacute|Egrave|Iacute|Igrave|Ntilde|Oacute|Ograve|Oslash|Otilde|Uacute|Ugrave|Yacute|aacute|agrave|atilde|brvbar|ccedil|curren|divide|eacute|egrave|frac12|frac14|frac34|iacute|igrave|iquest|middot|ntilde|oacute|ograve|oslash|otilde|plusmn|uacute|ugrave|yacute|AElig|Acirc|Aring|Ecirc|Icirc|Ocirc|THORN|Ucirc|acirc|acute|aelig|aring|cedil|ecirc|icirc|iexcl|laquo|micro|ocirc|pound|raquo|szlig|thorn|times|ucirc|Auml|COPY|Euml|Iuml|Ouml|QUOT|Uuml|auml|cent|copy|euml|iuml|macr|nbsp|ordf|ordm|ouml|para|quot|sect|sup1|sup2|sup3|uuml|yuml|AMP|ETH|REG|amp|deg|eth|not|reg|shy|uml|yen|GT|LT|gt|lt)(?!;)([=a-zA-Z0-9]?)|&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+)/g;
  12084. var decodeMap = {'aacute':'\xE1','Aacute':'\xC1','abreve':'\u0103','Abreve':'\u0102','ac':'\u223E','acd':'\u223F','acE':'\u223E\u0333','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','acy':'\u0430','Acy':'\u0410','aelig':'\xE6','AElig':'\xC6','af':'\u2061','afr':'\uD835\uDD1E','Afr':'\uD835\uDD04','agrave':'\xE0','Agrave':'\xC0','alefsym':'\u2135','aleph':'\u2135','alpha':'\u03B1','Alpha':'\u0391','amacr':'\u0101','Amacr':'\u0100','amalg':'\u2A3F','amp':'&','AMP':'&','and':'\u2227','And':'\u2A53','andand':'\u2A55','andd':'\u2A5C','andslope':'\u2A58','andv':'\u2A5A','ang':'\u2220','ange':'\u29A4','angle':'\u2220','angmsd':'\u2221','angmsdaa':'\u29A8','angmsdab':'\u29A9','angmsdac':'\u29AA','angmsdad':'\u29AB','angmsdae':'\u29AC','angmsdaf':'\u29AD','angmsdag':'\u29AE','angmsdah':'\u29AF','angrt':'\u221F','angrtvb':'\u22BE','angrtvbd':'\u299D','angsph':'\u2222','angst':'\xC5','angzarr':'\u237C','aogon':'\u0105','Aogon':'\u0104','aopf':'\uD835\uDD52','Aopf':'\uD835\uDD38','ap':'\u2248','apacir':'\u2A6F','ape':'\u224A','apE':'\u2A70','apid':'\u224B','apos':'\'','ApplyFunction':'\u2061','approx':'\u2248','approxeq':'\u224A','aring':'\xE5','Aring':'\xC5','ascr':'\uD835\uDCB6','Ascr':'\uD835\uDC9C','Assign':'\u2254','ast':'*','asymp':'\u2248','asympeq':'\u224D','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','awconint':'\u2233','awint':'\u2A11','backcong':'\u224C','backepsilon':'\u03F6','backprime':'\u2035','backsim':'\u223D','backsimeq':'\u22CD','Backslash':'\u2216','Barv':'\u2AE7','barvee':'\u22BD','barwed':'\u2305','Barwed':'\u2306','barwedge':'\u2305','bbrk':'\u23B5','bbrktbrk':'\u23B6','bcong':'\u224C','bcy':'\u0431','Bcy':'\u0411','bdquo':'\u201E','becaus':'\u2235','because':'\u2235','Because':'\u2235','bemptyv':'\u29B0','bepsi':'\u03F6','bernou':'\u212C','Bernoullis':'\u212C','beta':'\u03B2','Beta':'\u0392','beth':'\u2136','between':'\u226C','bfr':'\uD835\uDD1F','Bfr':'\uD835\uDD05','bigcap':'\u22C2','bigcirc':'\u25EF','bigcup':'\u22C3','bigodot':'\u2A00','bigoplus':'\u2A01','bigotimes':'\u2A02','bigsqcup':'\u2A06','bigstar':'\u2605','bigtriangledown':'\u25BD','bigtriangleup':'\u25B3','biguplus':'\u2A04','bigvee':'\u22C1','bigwedge':'\u22C0','bkarow':'\u290D','blacklozenge':'\u29EB','blacksquare':'\u25AA','blacktriangle':'\u25B4','blacktriangledown':'\u25BE','blacktriangleleft':'\u25C2','blacktriangleright':'\u25B8','blank':'\u2423','blk12':'\u2592','blk14':'\u2591','blk34':'\u2593','block':'\u2588','bne':'=\u20E5','bnequiv':'\u2261\u20E5','bnot':'\u2310','bNot':'\u2AED','bopf':'\uD835\uDD53','Bopf':'\uD835\uDD39','bot':'\u22A5','bottom':'\u22A5','bowtie':'\u22C8','boxbox':'\u29C9','boxdl':'\u2510','boxdL':'\u2555','boxDl':'\u2556','boxDL':'\u2557','boxdr':'\u250C','boxdR':'\u2552','boxDr':'\u2553','boxDR':'\u2554','boxh':'\u2500','boxH':'\u2550','boxhd':'\u252C','boxhD':'\u2565','boxHd':'\u2564','boxHD':'\u2566','boxhu':'\u2534','boxhU':'\u2568','boxHu':'\u2567','boxHU':'\u2569','boxminus':'\u229F','boxplus':'\u229E','boxtimes':'\u22A0','boxul':'\u2518','boxuL':'\u255B','boxUl':'\u255C','boxUL':'\u255D','boxur':'\u2514','boxuR':'\u2558','boxUr':'\u2559','boxUR':'\u255A','boxv':'\u2502','boxV':'\u2551','boxvh':'\u253C','boxvH':'\u256A','boxVh':'\u256B','boxVH':'\u256C','boxvl':'\u2524','boxvL':'\u2561','boxVl':'\u2562','boxVL':'\u2563','boxvr':'\u251C','boxvR':'\u255E','boxVr':'\u255F','boxVR':'\u2560','bprime':'\u2035','breve':'\u02D8','Breve':'\u02D8','brvbar':'\xA6','bscr':'\uD835\uDCB7','Bscr':'\u212C','bsemi':'\u204F','bsim':'\u223D','bsime':'\u22CD','bsol':'\\','bsolb':'\u29C5','bsolhsub':'\u27C8','bull':'\u2022','bullet':'\u2022','bump':'\u224E','bumpe':'\u224F','bumpE':'\u2AAE','bumpeq':'\u224F','Bumpeq':'\u224E','cacute':'\u0107','Cacute':'\u0106','cap':'\u2229','Cap':'\u22D2','capand':'\u2A44','capbrcup':'\u2A49','capcap':'\u2A4B','capcup':'\u2A47','capdot':'\u2A40','CapitalDifferentialD':'\u2145','caps':'\u2229\uFE00','caret':'\u2041','caron':'\u02C7','Cayleys':'\u212D','ccaps':'\u2A4D','ccaron':'\u010D','Ccaron':'\u010C','ccedil':'\xE7','Ccedil':'\xC7','ccirc':'\u0109','Ccirc':'\u0108','Cconint':'\u2230','ccups':'\u2A4C','ccupssm':'\u2A50','cdot':'\u010B','Cdot':'\u010A','cedil':'\xB8','Cedilla':'\xB8','cemptyv':'\u29B2','cent':'\xA2','centerdot':'\xB7','CenterDot':'\xB7','cfr':'\uD835\uDD20','Cfr':'\u212D','chcy':'\u0447','CHcy':'\u0427','check':'\u2713','checkmark':'\u2713','chi':'\u03C7','Chi':'\u03A7','cir':'\u25CB','circ':'\u02C6','circeq':'\u2257','circlearrowleft':'\u21BA','circlearrowright':'\u21BB','circledast':'\u229B','circledcirc':'\u229A','circleddash':'\u229D','CircleDot':'\u2299','circledR':'\xAE','circledS':'\u24C8','CircleMinus':'\u2296','CirclePlus':'\u2295','CircleTimes':'\u2297','cire':'\u2257','cirE':'\u29C3','cirfnint':'\u2A10','cirmid':'\u2AEF','cirscir':'\u29C2','ClockwiseContourIntegral':'\u2232','CloseCurlyDoubleQuote':'\u201D','CloseCurlyQuote':'\u2019','clubs':'\u2663','clubsuit':'\u2663','colon':':','Colon':'\u2237','colone':'\u2254','Colone':'\u2A74','coloneq':'\u2254','comma':',','commat':'@','comp':'\u2201','compfn':'\u2218','complement':'\u2201','complexes':'\u2102','cong':'\u2245','congdot':'\u2A6D','Congruent':'\u2261','conint':'\u222E','Conint':'\u222F','ContourIntegral':'\u222E','copf':'\uD835\uDD54','Copf':'\u2102','coprod':'\u2210','Coproduct':'\u2210','copy':'\xA9','COPY':'\xA9','copysr':'\u2117','CounterClockwiseContourIntegral':'\u2233','crarr':'\u21B5','cross':'\u2717','Cross':'\u2A2F','cscr':'\uD835\uDCB8','Cscr':'\uD835\uDC9E','csub':'\u2ACF','csube':'\u2AD1','csup':'\u2AD0','csupe':'\u2AD2','ctdot':'\u22EF','cudarrl':'\u2938','cudarrr':'\u2935','cuepr':'\u22DE','cuesc':'\u22DF','cularr':'\u21B6','cularrp':'\u293D','cup':'\u222A','Cup':'\u22D3','cupbrcap':'\u2A48','cupcap':'\u2A46','CupCap':'\u224D','cupcup':'\u2A4A','cupdot':'\u228D','cupor':'\u2A45','cups':'\u222A\uFE00','curarr':'\u21B7','curarrm':'\u293C','curlyeqprec':'\u22DE','curlyeqsucc':'\u22DF','curlyvee':'\u22CE','curlywedge':'\u22CF','curren':'\xA4','curvearrowleft':'\u21B6','curvearrowright':'\u21B7','cuvee':'\u22CE','cuwed':'\u22CF','cwconint':'\u2232','cwint':'\u2231','cylcty':'\u232D','dagger':'\u2020','Dagger':'\u2021','daleth':'\u2138','darr':'\u2193','dArr':'\u21D3','Darr':'\u21A1','dash':'\u2010','dashv':'\u22A3','Dashv':'\u2AE4','dbkarow':'\u290F','dblac':'\u02DD','dcaron':'\u010F','Dcaron':'\u010E','dcy':'\u0434','Dcy':'\u0414','dd':'\u2146','DD':'\u2145','ddagger':'\u2021','ddarr':'\u21CA','DDotrahd':'\u2911','ddotseq':'\u2A77','deg':'\xB0','Del':'\u2207','delta':'\u03B4','Delta':'\u0394','demptyv':'\u29B1','dfisht':'\u297F','dfr':'\uD835\uDD21','Dfr':'\uD835\uDD07','dHar':'\u2965','dharl':'\u21C3','dharr':'\u21C2','DiacriticalAcute':'\xB4','DiacriticalDot':'\u02D9','DiacriticalDoubleAcute':'\u02DD','DiacriticalGrave':'`','DiacriticalTilde':'\u02DC','diam':'\u22C4','diamond':'\u22C4','Diamond':'\u22C4','diamondsuit':'\u2666','diams':'\u2666','die':'\xA8','DifferentialD':'\u2146','digamma':'\u03DD','disin':'\u22F2','div':'\xF7','divide':'\xF7','divideontimes':'\u22C7','divonx':'\u22C7','djcy':'\u0452','DJcy':'\u0402','dlcorn':'\u231E','dlcrop':'\u230D','dollar':'$','dopf':'\uD835\uDD55','Dopf':'\uD835\uDD3B','dot':'\u02D9','Dot':'\xA8','DotDot':'\u20DC','doteq':'\u2250','doteqdot':'\u2251','DotEqual':'\u2250','dotminus':'\u2238','dotplus':'\u2214','dotsquare':'\u22A1','doublebarwedge':'\u2306','DoubleContourIntegral':'\u222F','DoubleDot':'\xA8','DoubleDownArrow':'\u21D3','DoubleLeftArrow':'\u21D0','DoubleLeftRightArrow':'\u21D4','DoubleLeftTee':'\u2AE4','DoubleLongLeftArrow':'\u27F8','DoubleLongLeftRightArrow':'\u27FA','DoubleLongRightArrow':'\u27F9','DoubleRightArrow':'\u21D2','DoubleRightTee':'\u22A8','DoubleUpArrow':'\u21D1','DoubleUpDownArrow':'\u21D5','DoubleVerticalBar':'\u2225','downarrow':'\u2193','Downarrow':'\u21D3','DownArrow':'\u2193','DownArrowBar':'\u2913','DownArrowUpArrow':'\u21F5','DownBreve':'\u0311','downdownarrows':'\u21CA','downharpoonleft':'\u21C3','downharpoonright':'\u21C2','DownLeftRightVector':'\u2950','DownLeftTeeVector':'\u295E','DownLeftVector':'\u21BD','DownLeftVectorBar':'\u2956','DownRightTeeVector':'\u295F','DownRightVector':'\u21C1','DownRightVectorBar':'\u2957','DownTee':'\u22A4','DownTeeArrow':'\u21A7','drbkarow':'\u2910','drcorn':'\u231F','drcrop':'\u230C','dscr':'\uD835\uDCB9','Dscr':'\uD835\uDC9F','dscy':'\u0455','DScy':'\u0405','dsol':'\u29F6','dstrok':'\u0111','Dstrok':'\u0110','dtdot':'\u22F1','dtri':'\u25BF','dtrif':'\u25BE','duarr':'\u21F5','duhar':'\u296F','dwangle':'\u29A6','dzcy':'\u045F','DZcy':'\u040F','dzigrarr':'\u27FF','eacute':'\xE9','Eacute':'\xC9','easter':'\u2A6E','ecaron':'\u011B','Ecaron':'\u011A','ecir':'\u2256','ecirc':'\xEA','Ecirc':'\xCA','ecolon':'\u2255','ecy':'\u044D','Ecy':'\u042D','eDDot':'\u2A77','edot':'\u0117','eDot':'\u2251','Edot':'\u0116','ee':'\u2147','efDot':'\u2252','efr':'\uD835\uDD22','Efr':'\uD835\uDD08','eg':'\u2A9A','egrave':'\xE8','Egrave':'\xC8','egs':'\u2A96','egsdot':'\u2A98','el':'\u2A99','Element':'\u2208','elinters':'\u23E7','ell':'\u2113','els':'\u2A95','elsdot':'\u2A97','emacr':'\u0113','Emacr':'\u0112','empty':'\u2205','emptyset':'\u2205','EmptySmallSquare':'\u25FB','emptyv':'\u2205','EmptyVerySmallSquare':'\u25AB','emsp':'\u2003','emsp13':'\u2004','emsp14':'\u2005','eng':'\u014B','ENG':'\u014A','ensp':'\u2002','eogon':'\u0119','Eogon':'\u0118','eopf':'\uD835\uDD56','Eopf':'\uD835\uDD3C','epar':'\u22D5','eparsl':'\u29E3','eplus':'\u2A71','epsi':'\u03B5','epsilon':'\u03B5','Epsilon':'\u0395','epsiv':'\u03F5','eqcirc':'\u2256','eqcolon':'\u2255','eqsim':'\u2242','eqslantgtr':'\u2A96','eqslantless':'\u2A95','Equal':'\u2A75','equals':'=','EqualTilde':'\u2242','equest':'\u225F','Equilibrium':'\u21CC','equiv':'\u2261','equivDD':'\u2A78','eqvparsl':'\u29E5','erarr':'\u2971','erDot':'\u2253','escr':'\u212F','Escr':'\u2130','esdot':'\u2250','esim':'\u2242','Esim':'\u2A73','eta':'\u03B7','Eta':'\u0397','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','euro':'\u20AC','excl':'!','exist':'\u2203','Exists':'\u2203','expectation':'\u2130','exponentiale':'\u2147','ExponentialE':'\u2147','fallingdotseq':'\u2252','fcy':'\u0444','Fcy':'\u0424','female':'\u2640','ffilig':'\uFB03','fflig':'\uFB00','ffllig':'\uFB04','ffr':'\uD835\uDD23','Ffr':'\uD835\uDD09','filig':'\uFB01','FilledSmallSquare':'\u25FC','FilledVerySmallSquare':'\u25AA','fjlig':'fj','flat':'\u266D','fllig':'\uFB02','fltns':'\u25B1','fnof':'\u0192','fopf':'\uD835\uDD57','Fopf':'\uD835\uDD3D','forall':'\u2200','ForAll':'\u2200','fork':'\u22D4','forkv':'\u2AD9','Fouriertrf':'\u2131','fpartint':'\u2A0D','frac12':'\xBD','frac13':'\u2153','frac14':'\xBC','frac15':'\u2155','frac16':'\u2159','frac18':'\u215B','frac23':'\u2154','frac25':'\u2156','frac34':'\xBE','frac35':'\u2157','frac38':'\u215C','frac45':'\u2158','frac56':'\u215A','frac58':'\u215D','frac78':'\u215E','frasl':'\u2044','frown':'\u2322','fscr':'\uD835\uDCBB','Fscr':'\u2131','gacute':'\u01F5','gamma':'\u03B3','Gamma':'\u0393','gammad':'\u03DD','Gammad':'\u03DC','gap':'\u2A86','gbreve':'\u011F','Gbreve':'\u011E','Gcedil':'\u0122','gcirc':'\u011D','Gcirc':'\u011C','gcy':'\u0433','Gcy':'\u0413','gdot':'\u0121','Gdot':'\u0120','ge':'\u2265','gE':'\u2267','gel':'\u22DB','gEl':'\u2A8C','geq':'\u2265','geqq':'\u2267','geqslant':'\u2A7E','ges':'\u2A7E','gescc':'\u2AA9','gesdot':'\u2A80','gesdoto':'\u2A82','gesdotol':'\u2A84','gesl':'\u22DB\uFE00','gesles':'\u2A94','gfr':'\uD835\uDD24','Gfr':'\uD835\uDD0A','gg':'\u226B','Gg':'\u22D9','ggg':'\u22D9','gimel':'\u2137','gjcy':'\u0453','GJcy':'\u0403','gl':'\u2277','gla':'\u2AA5','glE':'\u2A92','glj':'\u2AA4','gnap':'\u2A8A','gnapprox':'\u2A8A','gne':'\u2A88','gnE':'\u2269','gneq':'\u2A88','gneqq':'\u2269','gnsim':'\u22E7','gopf':'\uD835\uDD58','Gopf':'\uD835\uDD3E','grave':'`','GreaterEqual':'\u2265','GreaterEqualLess':'\u22DB','GreaterFullEqual':'\u2267','GreaterGreater':'\u2AA2','GreaterLess':'\u2277','GreaterSlantEqual':'\u2A7E','GreaterTilde':'\u2273','gscr':'\u210A','Gscr':'\uD835\uDCA2','gsim':'\u2273','gsime':'\u2A8E','gsiml':'\u2A90','gt':'>','Gt':'\u226B','GT':'>','gtcc':'\u2AA7','gtcir':'\u2A7A','gtdot':'\u22D7','gtlPar':'\u2995','gtquest':'\u2A7C','gtrapprox':'\u2A86','gtrarr':'\u2978','gtrdot':'\u22D7','gtreqless':'\u22DB','gtreqqless':'\u2A8C','gtrless':'\u2277','gtrsim':'\u2273','gvertneqq':'\u2269\uFE00','gvnE':'\u2269\uFE00','Hacek':'\u02C7','hairsp':'\u200A','half':'\xBD','hamilt':'\u210B','hardcy':'\u044A','HARDcy':'\u042A','harr':'\u2194','hArr':'\u21D4','harrcir':'\u2948','harrw':'\u21AD','Hat':'^','hbar':'\u210F','hcirc':'\u0125','Hcirc':'\u0124','hearts':'\u2665','heartsuit':'\u2665','hellip':'\u2026','hercon':'\u22B9','hfr':'\uD835\uDD25','Hfr':'\u210C','HilbertSpace':'\u210B','hksearow':'\u2925','hkswarow':'\u2926','hoarr':'\u21FF','homtht':'\u223B','hookleftarrow':'\u21A9','hookrightarrow':'\u21AA','hopf':'\uD835\uDD59','Hopf':'\u210D','horbar':'\u2015','HorizontalLine':'\u2500','hscr':'\uD835\uDCBD','Hscr':'\u210B','hslash':'\u210F','hstrok':'\u0127','Hstrok':'\u0126','HumpDownHump':'\u224E','HumpEqual':'\u224F','hybull':'\u2043','hyphen':'\u2010','iacute':'\xED','Iacute':'\xCD','ic':'\u2063','icirc':'\xEE','Icirc':'\xCE','icy':'\u0438','Icy':'\u0418','Idot':'\u0130','iecy':'\u0435','IEcy':'\u0415','iexcl':'\xA1','iff':'\u21D4','ifr':'\uD835\uDD26','Ifr':'\u2111','igrave':'\xEC','Igrave':'\xCC','ii':'\u2148','iiiint':'\u2A0C','iiint':'\u222D','iinfin':'\u29DC','iiota':'\u2129','ijlig':'\u0133','IJlig':'\u0132','Im':'\u2111','imacr':'\u012B','Imacr':'\u012A','image':'\u2111','ImaginaryI':'\u2148','imagline':'\u2110','imagpart':'\u2111','imath':'\u0131','imof':'\u22B7','imped':'\u01B5','Implies':'\u21D2','in':'\u2208','incare':'\u2105','infin':'\u221E','infintie':'\u29DD','inodot':'\u0131','int':'\u222B','Int':'\u222C','intcal':'\u22BA','integers':'\u2124','Integral':'\u222B','intercal':'\u22BA','Intersection':'\u22C2','intlarhk':'\u2A17','intprod':'\u2A3C','InvisibleComma':'\u2063','InvisibleTimes':'\u2062','iocy':'\u0451','IOcy':'\u0401','iogon':'\u012F','Iogon':'\u012E','iopf':'\uD835\uDD5A','Iopf':'\uD835\uDD40','iota':'\u03B9','Iota':'\u0399','iprod':'\u2A3C','iquest':'\xBF','iscr':'\uD835\uDCBE','Iscr':'\u2110','isin':'\u2208','isindot':'\u22F5','isinE':'\u22F9','isins':'\u22F4','isinsv':'\u22F3','isinv':'\u2208','it':'\u2062','itilde':'\u0129','Itilde':'\u0128','iukcy':'\u0456','Iukcy':'\u0406','iuml':'\xEF','Iuml':'\xCF','jcirc':'\u0135','Jcirc':'\u0134','jcy':'\u0439','Jcy':'\u0419','jfr':'\uD835\uDD27','Jfr':'\uD835\uDD0D','jmath':'\u0237','jopf':'\uD835\uDD5B','Jopf':'\uD835\uDD41','jscr':'\uD835\uDCBF','Jscr':'\uD835\uDCA5','jsercy':'\u0458','Jsercy':'\u0408','jukcy':'\u0454','Jukcy':'\u0404','kappa':'\u03BA','Kappa':'\u039A','kappav':'\u03F0','kcedil':'\u0137','Kcedil':'\u0136','kcy':'\u043A','Kcy':'\u041A','kfr':'\uD835\uDD28','Kfr':'\uD835\uDD0E','kgreen':'\u0138','khcy':'\u0445','KHcy':'\u0425','kjcy':'\u045C','KJcy':'\u040C','kopf':'\uD835\uDD5C','Kopf':'\uD835\uDD42','kscr':'\uD835\uDCC0','Kscr':'\uD835\uDCA6','lAarr':'\u21DA','lacute':'\u013A','Lacute':'\u0139','laemptyv':'\u29B4','lagran':'\u2112','lambda':'\u03BB','Lambda':'\u039B','lang':'\u27E8','Lang':'\u27EA','langd':'\u2991','langle':'\u27E8','lap':'\u2A85','Laplacetrf':'\u2112','laquo':'\xAB','larr':'\u2190','lArr':'\u21D0','Larr':'\u219E','larrb':'\u21E4','larrbfs':'\u291F','larrfs':'\u291D','larrhk':'\u21A9','larrlp':'\u21AB','larrpl':'\u2939','larrsim':'\u2973','larrtl':'\u21A2','lat':'\u2AAB','latail':'\u2919','lAtail':'\u291B','late':'\u2AAD','lates':'\u2AAD\uFE00','lbarr':'\u290C','lBarr':'\u290E','lbbrk':'\u2772','lbrace':'{','lbrack':'[','lbrke':'\u298B','lbrksld':'\u298F','lbrkslu':'\u298D','lcaron':'\u013E','Lcaron':'\u013D','lcedil':'\u013C','Lcedil':'\u013B','lceil':'\u2308','lcub':'{','lcy':'\u043B','Lcy':'\u041B','ldca':'\u2936','ldquo':'\u201C','ldquor':'\u201E','ldrdhar':'\u2967','ldrushar':'\u294B','ldsh':'\u21B2','le':'\u2264','lE':'\u2266','LeftAngleBracket':'\u27E8','leftarrow':'\u2190','Leftarrow':'\u21D0','LeftArrow':'\u2190','LeftArrowBar':'\u21E4','LeftArrowRightArrow':'\u21C6','leftarrowtail':'\u21A2','LeftCeiling':'\u2308','LeftDoubleBracket':'\u27E6','LeftDownTeeVector':'\u2961','LeftDownVector':'\u21C3','LeftDownVectorBar':'\u2959','LeftFloor':'\u230A','leftharpoondown':'\u21BD','leftharpoonup':'\u21BC','leftleftarrows':'\u21C7','leftrightarrow':'\u2194','Leftrightarrow':'\u21D4','LeftRightArrow':'\u2194','leftrightarrows':'\u21C6','leftrightharpoons':'\u21CB','leftrightsquigarrow':'\u21AD','LeftRightVector':'\u294E','LeftTee':'\u22A3','LeftTeeArrow':'\u21A4','LeftTeeVector':'\u295A','leftthreetimes':'\u22CB','LeftTriangle':'\u22B2','LeftTriangleBar':'\u29CF','LeftTriangleEqual':'\u22B4','LeftUpDownVector':'\u2951','LeftUpTeeVector':'\u2960','LeftUpVector':'\u21BF','LeftUpVectorBar':'\u2958','LeftVector':'\u21BC','LeftVectorBar':'\u2952','leg':'\u22DA','lEg':'\u2A8B','leq':'\u2264','leqq':'\u2266','leqslant':'\u2A7D','les':'\u2A7D','lescc':'\u2AA8','lesdot':'\u2A7F','lesdoto':'\u2A81','lesdotor':'\u2A83','lesg':'\u22DA\uFE00','lesges':'\u2A93','lessapprox':'\u2A85','lessdot':'\u22D6','lesseqgtr':'\u22DA','lesseqqgtr':'\u2A8B','LessEqualGreater':'\u22DA','LessFullEqual':'\u2266','LessGreater':'\u2276','lessgtr':'\u2276','LessLess':'\u2AA1','lesssim':'\u2272','LessSlantEqual':'\u2A7D','LessTilde':'\u2272','lfisht':'\u297C','lfloor':'\u230A','lfr':'\uD835\uDD29','Lfr':'\uD835\uDD0F','lg':'\u2276','lgE':'\u2A91','lHar':'\u2962','lhard':'\u21BD','lharu':'\u21BC','lharul':'\u296A','lhblk':'\u2584','ljcy':'\u0459','LJcy':'\u0409','ll':'\u226A','Ll':'\u22D8','llarr':'\u21C7','llcorner':'\u231E','Lleftarrow':'\u21DA','llhard':'\u296B','lltri':'\u25FA','lmidot':'\u0140','Lmidot':'\u013F','lmoust':'\u23B0','lmoustache':'\u23B0','lnap':'\u2A89','lnapprox':'\u2A89','lne':'\u2A87','lnE':'\u2268','lneq':'\u2A87','lneqq':'\u2268','lnsim':'\u22E6','loang':'\u27EC','loarr':'\u21FD','lobrk':'\u27E6','longleftarrow':'\u27F5','Longleftarrow':'\u27F8','LongLeftArrow':'\u27F5','longleftrightarrow':'\u27F7','Longleftrightarrow':'\u27FA','LongLeftRightArrow':'\u27F7','longmapsto':'\u27FC','longrightarrow':'\u27F6','Longrightarrow':'\u27F9','LongRightArrow':'\u27F6','looparrowleft':'\u21AB','looparrowright':'\u21AC','lopar':'\u2985','lopf':'\uD835\uDD5D','Lopf':'\uD835\uDD43','loplus':'\u2A2D','lotimes':'\u2A34','lowast':'\u2217','lowbar':'_','LowerLeftArrow':'\u2199','LowerRightArrow':'\u2198','loz':'\u25CA','lozenge':'\u25CA','lozf':'\u29EB','lpar':'(','lparlt':'\u2993','lrarr':'\u21C6','lrcorner':'\u231F','lrhar':'\u21CB','lrhard':'\u296D','lrm':'\u200E','lrtri':'\u22BF','lsaquo':'\u2039','lscr':'\uD835\uDCC1','Lscr':'\u2112','lsh':'\u21B0','Lsh':'\u21B0','lsim':'\u2272','lsime':'\u2A8D','lsimg':'\u2A8F','lsqb':'[','lsquo':'\u2018','lsquor':'\u201A','lstrok':'\u0142','Lstrok':'\u0141','lt':'<','Lt':'\u226A','LT':'<','ltcc':'\u2AA6','ltcir':'\u2A79','ltdot':'\u22D6','lthree':'\u22CB','ltimes':'\u22C9','ltlarr':'\u2976','ltquest':'\u2A7B','ltri':'\u25C3','ltrie':'\u22B4','ltrif':'\u25C2','ltrPar':'\u2996','lurdshar':'\u294A','luruhar':'\u2966','lvertneqq':'\u2268\uFE00','lvnE':'\u2268\uFE00','macr':'\xAF','male':'\u2642','malt':'\u2720','maltese':'\u2720','map':'\u21A6','Map':'\u2905','mapsto':'\u21A6','mapstodown':'\u21A7','mapstoleft':'\u21A4','mapstoup':'\u21A5','marker':'\u25AE','mcomma':'\u2A29','mcy':'\u043C','Mcy':'\u041C','mdash':'\u2014','mDDot':'\u223A','measuredangle':'\u2221','MediumSpace':'\u205F','Mellintrf':'\u2133','mfr':'\uD835\uDD2A','Mfr':'\uD835\uDD10','mho':'\u2127','micro':'\xB5','mid':'\u2223','midast':'*','midcir':'\u2AF0','middot':'\xB7','minus':'\u2212','minusb':'\u229F','minusd':'\u2238','minusdu':'\u2A2A','MinusPlus':'\u2213','mlcp':'\u2ADB','mldr':'\u2026','mnplus':'\u2213','models':'\u22A7','mopf':'\uD835\uDD5E','Mopf':'\uD835\uDD44','mp':'\u2213','mscr':'\uD835\uDCC2','Mscr':'\u2133','mstpos':'\u223E','mu':'\u03BC','Mu':'\u039C','multimap':'\u22B8','mumap':'\u22B8','nabla':'\u2207','nacute':'\u0144','Nacute':'\u0143','nang':'\u2220\u20D2','nap':'\u2249','napE':'\u2A70\u0338','napid':'\u224B\u0338','napos':'\u0149','napprox':'\u2249','natur':'\u266E','natural':'\u266E','naturals':'\u2115','nbsp':'\xA0','nbump':'\u224E\u0338','nbumpe':'\u224F\u0338','ncap':'\u2A43','ncaron':'\u0148','Ncaron':'\u0147','ncedil':'\u0146','Ncedil':'\u0145','ncong':'\u2247','ncongdot':'\u2A6D\u0338','ncup':'\u2A42','ncy':'\u043D','Ncy':'\u041D','ndash':'\u2013','ne':'\u2260','nearhk':'\u2924','nearr':'\u2197','neArr':'\u21D7','nearrow':'\u2197','nedot':'\u2250\u0338','NegativeMediumSpace':'\u200B','NegativeThickSpace':'\u200B','NegativeThinSpace':'\u200B','NegativeVeryThinSpace':'\u200B','nequiv':'\u2262','nesear':'\u2928','nesim':'\u2242\u0338','NestedGreaterGreater':'\u226B','NestedLessLess':'\u226A','NewLine':'\n','nexist':'\u2204','nexists':'\u2204','nfr':'\uD835\uDD2B','Nfr':'\uD835\uDD11','nge':'\u2271','ngE':'\u2267\u0338','ngeq':'\u2271','ngeqq':'\u2267\u0338','ngeqslant':'\u2A7E\u0338','nges':'\u2A7E\u0338','nGg':'\u22D9\u0338','ngsim':'\u2275','ngt':'\u226F','nGt':'\u226B\u20D2','ngtr':'\u226F','nGtv':'\u226B\u0338','nharr':'\u21AE','nhArr':'\u21CE','nhpar':'\u2AF2','ni':'\u220B','nis':'\u22FC','nisd':'\u22FA','niv':'\u220B','njcy':'\u045A','NJcy':'\u040A','nlarr':'\u219A','nlArr':'\u21CD','nldr':'\u2025','nle':'\u2270','nlE':'\u2266\u0338','nleftarrow':'\u219A','nLeftarrow':'\u21CD','nleftrightarrow':'\u21AE','nLeftrightarrow':'\u21CE','nleq':'\u2270','nleqq':'\u2266\u0338','nleqslant':'\u2A7D\u0338','nles':'\u2A7D\u0338','nless':'\u226E','nLl':'\u22D8\u0338','nlsim':'\u2274','nlt':'\u226E','nLt':'\u226A\u20D2','nltri':'\u22EA','nltrie':'\u22EC','nLtv':'\u226A\u0338','nmid':'\u2224','NoBreak':'\u2060','NonBreakingSpace':'\xA0','nopf':'\uD835\uDD5F','Nopf':'\u2115','not':'\xAC','Not':'\u2AEC','NotCongruent':'\u2262','NotCupCap':'\u226D','NotDoubleVerticalBar':'\u2226','NotElement':'\u2209','NotEqual':'\u2260','NotEqualTilde':'\u2242\u0338','NotExists':'\u2204','NotGreater':'\u226F','NotGreaterEqual':'\u2271','NotGreaterFullEqual':'\u2267\u0338','NotGreaterGreater':'\u226B\u0338','NotGreaterLess':'\u2279','NotGreaterSlantEqual':'\u2A7E\u0338','NotGreaterTilde':'\u2275','NotHumpDownHump':'\u224E\u0338','NotHumpEqual':'\u224F\u0338','notin':'\u2209','notindot':'\u22F5\u0338','notinE':'\u22F9\u0338','notinva':'\u2209','notinvb':'\u22F7','notinvc':'\u22F6','NotLeftTriangle':'\u22EA','NotLeftTriangleBar':'\u29CF\u0338','NotLeftTriangleEqual':'\u22EC','NotLess':'\u226E','NotLessEqual':'\u2270','NotLessGreater':'\u2278','NotLessLess':'\u226A\u0338','NotLessSlantEqual':'\u2A7D\u0338','NotLessTilde':'\u2274','NotNestedGreaterGreater':'\u2AA2\u0338','NotNestedLessLess':'\u2AA1\u0338','notni':'\u220C','notniva':'\u220C','notnivb':'\u22FE','notnivc':'\u22FD','NotPrecedes':'\u2280','NotPrecedesEqual':'\u2AAF\u0338','NotPrecedesSlantEqual':'\u22E0','NotReverseElement':'\u220C','NotRightTriangle':'\u22EB','NotRightTriangleBar':'\u29D0\u0338','NotRightTriangleEqual':'\u22ED','NotSquareSubset':'\u228F\u0338','NotSquareSubsetEqual':'\u22E2','NotSquareSuperset':'\u2290\u0338','NotSquareSupersetEqual':'\u22E3','NotSubset':'\u2282\u20D2','NotSubsetEqual':'\u2288','NotSucceeds':'\u2281','NotSucceedsEqual':'\u2AB0\u0338','NotSucceedsSlantEqual':'\u22E1','NotSucceedsTilde':'\u227F\u0338','NotSuperset':'\u2283\u20D2','NotSupersetEqual':'\u2289','NotTilde':'\u2241','NotTildeEqual':'\u2244','NotTildeFullEqual':'\u2247','NotTildeTilde':'\u2249','NotVerticalBar':'\u2224','npar':'\u2226','nparallel':'\u2226','nparsl':'\u2AFD\u20E5','npart':'\u2202\u0338','npolint':'\u2A14','npr':'\u2280','nprcue':'\u22E0','npre':'\u2AAF\u0338','nprec':'\u2280','npreceq':'\u2AAF\u0338','nrarr':'\u219B','nrArr':'\u21CF','nrarrc':'\u2933\u0338','nrarrw':'\u219D\u0338','nrightarrow':'\u219B','nRightarrow':'\u21CF','nrtri':'\u22EB','nrtrie':'\u22ED','nsc':'\u2281','nsccue':'\u22E1','nsce':'\u2AB0\u0338','nscr':'\uD835\uDCC3','Nscr':'\uD835\uDCA9','nshortmid':'\u2224','nshortparallel':'\u2226','nsim':'\u2241','nsime':'\u2244','nsimeq':'\u2244','nsmid':'\u2224','nspar':'\u2226','nsqsube':'\u22E2','nsqsupe':'\u22E3','nsub':'\u2284','nsube':'\u2288','nsubE':'\u2AC5\u0338','nsubset':'\u2282\u20D2','nsubseteq':'\u2288','nsubseteqq':'\u2AC5\u0338','nsucc':'\u2281','nsucceq':'\u2AB0\u0338','nsup':'\u2285','nsupe':'\u2289','nsupE':'\u2AC6\u0338','nsupset':'\u2283\u20D2','nsupseteq':'\u2289','nsupseteqq':'\u2AC6\u0338','ntgl':'\u2279','ntilde':'\xF1','Ntilde':'\xD1','ntlg':'\u2278','ntriangleleft':'\u22EA','ntrianglelefteq':'\u22EC','ntriangleright':'\u22EB','ntrianglerighteq':'\u22ED','nu':'\u03BD','Nu':'\u039D','num':'#','numero':'\u2116','numsp':'\u2007','nvap':'\u224D\u20D2','nvdash':'\u22AC','nvDash':'\u22AD','nVdash':'\u22AE','nVDash':'\u22AF','nvge':'\u2265\u20D2','nvgt':'>\u20D2','nvHarr':'\u2904','nvinfin':'\u29DE','nvlArr':'\u2902','nvle':'\u2264\u20D2','nvlt':'<\u20D2','nvltrie':'\u22B4\u20D2','nvrArr':'\u2903','nvrtrie':'\u22B5\u20D2','nvsim':'\u223C\u20D2','nwarhk':'\u2923','nwarr':'\u2196','nwArr':'\u21D6','nwarrow':'\u2196','nwnear':'\u2927','oacute':'\xF3','Oacute':'\xD3','oast':'\u229B','ocir':'\u229A','ocirc':'\xF4','Ocirc':'\xD4','ocy':'\u043E','Ocy':'\u041E','odash':'\u229D','odblac':'\u0151','Odblac':'\u0150','odiv':'\u2A38','odot':'\u2299','odsold':'\u29BC','oelig':'\u0153','OElig':'\u0152','ofcir':'\u29BF','ofr':'\uD835\uDD2C','Ofr':'\uD835\uDD12','ogon':'\u02DB','ograve':'\xF2','Ograve':'\xD2','ogt':'\u29C1','ohbar':'\u29B5','ohm':'\u03A9','oint':'\u222E','olarr':'\u21BA','olcir':'\u29BE','olcross':'\u29BB','oline':'\u203E','olt':'\u29C0','omacr':'\u014D','Omacr':'\u014C','omega':'\u03C9','Omega':'\u03A9','omicron':'\u03BF','Omicron':'\u039F','omid':'\u29B6','ominus':'\u2296','oopf':'\uD835\uDD60','Oopf':'\uD835\uDD46','opar':'\u29B7','OpenCurlyDoubleQuote':'\u201C','OpenCurlyQuote':'\u2018','operp':'\u29B9','oplus':'\u2295','or':'\u2228','Or':'\u2A54','orarr':'\u21BB','ord':'\u2A5D','order':'\u2134','orderof':'\u2134','ordf':'\xAA','ordm':'\xBA','origof':'\u22B6','oror':'\u2A56','orslope':'\u2A57','orv':'\u2A5B','oS':'\u24C8','oscr':'\u2134','Oscr':'\uD835\uDCAA','oslash':'\xF8','Oslash':'\xD8','osol':'\u2298','otilde':'\xF5','Otilde':'\xD5','otimes':'\u2297','Otimes':'\u2A37','otimesas':'\u2A36','ouml':'\xF6','Ouml':'\xD6','ovbar':'\u233D','OverBar':'\u203E','OverBrace':'\u23DE','OverBracket':'\u23B4','OverParenthesis':'\u23DC','par':'\u2225','para':'\xB6','parallel':'\u2225','parsim':'\u2AF3','parsl':'\u2AFD','part':'\u2202','PartialD':'\u2202','pcy':'\u043F','Pcy':'\u041F','percnt':'%','period':'.','permil':'\u2030','perp':'\u22A5','pertenk':'\u2031','pfr':'\uD835\uDD2D','Pfr':'\uD835\uDD13','phi':'\u03C6','Phi':'\u03A6','phiv':'\u03D5','phmmat':'\u2133','phone':'\u260E','pi':'\u03C0','Pi':'\u03A0','pitchfork':'\u22D4','piv':'\u03D6','planck':'\u210F','planckh':'\u210E','plankv':'\u210F','plus':'+','plusacir':'\u2A23','plusb':'\u229E','pluscir':'\u2A22','plusdo':'\u2214','plusdu':'\u2A25','pluse':'\u2A72','PlusMinus':'\xB1','plusmn':'\xB1','plussim':'\u2A26','plustwo':'\u2A27','pm':'\xB1','Poincareplane':'\u210C','pointint':'\u2A15','popf':'\uD835\uDD61','Popf':'\u2119','pound':'\xA3','pr':'\u227A','Pr':'\u2ABB','prap':'\u2AB7','prcue':'\u227C','pre':'\u2AAF','prE':'\u2AB3','prec':'\u227A','precapprox':'\u2AB7','preccurlyeq':'\u227C','Precedes':'\u227A','PrecedesEqual':'\u2AAF','PrecedesSlantEqual':'\u227C','PrecedesTilde':'\u227E','preceq':'\u2AAF','precnapprox':'\u2AB9','precneqq':'\u2AB5','precnsim':'\u22E8','precsim':'\u227E','prime':'\u2032','Prime':'\u2033','primes':'\u2119','prnap':'\u2AB9','prnE':'\u2AB5','prnsim':'\u22E8','prod':'\u220F','Product':'\u220F','profalar':'\u232E','profline':'\u2312','profsurf':'\u2313','prop':'\u221D','Proportion':'\u2237','Proportional':'\u221D','propto':'\u221D','prsim':'\u227E','prurel':'\u22B0','pscr':'\uD835\uDCC5','Pscr':'\uD835\uDCAB','psi':'\u03C8','Psi':'\u03A8','puncsp':'\u2008','qfr':'\uD835\uDD2E','Qfr':'\uD835\uDD14','qint':'\u2A0C','qopf':'\uD835\uDD62','Qopf':'\u211A','qprime':'\u2057','qscr':'\uD835\uDCC6','Qscr':'\uD835\uDCAC','quaternions':'\u210D','quatint':'\u2A16','quest':'?','questeq':'\u225F','quot':'"','QUOT':'"','rAarr':'\u21DB','race':'\u223D\u0331','racute':'\u0155','Racute':'\u0154','radic':'\u221A','raemptyv':'\u29B3','rang':'\u27E9','Rang':'\u27EB','rangd':'\u2992','range':'\u29A5','rangle':'\u27E9','raquo':'\xBB','rarr':'\u2192','rArr':'\u21D2','Rarr':'\u21A0','rarrap':'\u2975','rarrb':'\u21E5','rarrbfs':'\u2920','rarrc':'\u2933','rarrfs':'\u291E','rarrhk':'\u21AA','rarrlp':'\u21AC','rarrpl':'\u2945','rarrsim':'\u2974','rarrtl':'\u21A3','Rarrtl':'\u2916','rarrw':'\u219D','ratail':'\u291A','rAtail':'\u291C','ratio':'\u2236','rationals':'\u211A','rbarr':'\u290D','rBarr':'\u290F','RBarr':'\u2910','rbbrk':'\u2773','rbrace':'}','rbrack':']','rbrke':'\u298C','rbrksld':'\u298E','rbrkslu':'\u2990','rcaron':'\u0159','Rcaron':'\u0158','rcedil':'\u0157','Rcedil':'\u0156','rceil':'\u2309','rcub':'}','rcy':'\u0440','Rcy':'\u0420','rdca':'\u2937','rdldhar':'\u2969','rdquo':'\u201D','rdquor':'\u201D','rdsh':'\u21B3','Re':'\u211C','real':'\u211C','realine':'\u211B','realpart':'\u211C','reals':'\u211D','rect':'\u25AD','reg':'\xAE','REG':'\xAE','ReverseElement':'\u220B','ReverseEquilibrium':'\u21CB','ReverseUpEquilibrium':'\u296F','rfisht':'\u297D','rfloor':'\u230B','rfr':'\uD835\uDD2F','Rfr':'\u211C','rHar':'\u2964','rhard':'\u21C1','rharu':'\u21C0','rharul':'\u296C','rho':'\u03C1','Rho':'\u03A1','rhov':'\u03F1','RightAngleBracket':'\u27E9','rightarrow':'\u2192','Rightarrow':'\u21D2','RightArrow':'\u2192','RightArrowBar':'\u21E5','RightArrowLeftArrow':'\u21C4','rightarrowtail':'\u21A3','RightCeiling':'\u2309','RightDoubleBracket':'\u27E7','RightDownTeeVector':'\u295D','RightDownVector':'\u21C2','RightDownVectorBar':'\u2955','RightFloor':'\u230B','rightharpoondown':'\u21C1','rightharpoonup':'\u21C0','rightleftarrows':'\u21C4','rightleftharpoons':'\u21CC','rightrightarrows':'\u21C9','rightsquigarrow':'\u219D','RightTee':'\u22A2','RightTeeArrow':'\u21A6','RightTeeVector':'\u295B','rightthreetimes':'\u22CC','RightTriangle':'\u22B3','RightTriangleBar':'\u29D0','RightTriangleEqual':'\u22B5','RightUpDownVector':'\u294F','RightUpTeeVector':'\u295C','RightUpVector':'\u21BE','RightUpVectorBar':'\u2954','RightVector':'\u21C0','RightVectorBar':'\u2953','ring':'\u02DA','risingdotseq':'\u2253','rlarr':'\u21C4','rlhar':'\u21CC','rlm':'\u200F','rmoust':'\u23B1','rmoustache':'\u23B1','rnmid':'\u2AEE','roang':'\u27ED','roarr':'\u21FE','robrk':'\u27E7','ropar':'\u2986','ropf':'\uD835\uDD63','Ropf':'\u211D','roplus':'\u2A2E','rotimes':'\u2A35','RoundImplies':'\u2970','rpar':')','rpargt':'\u2994','rppolint':'\u2A12','rrarr':'\u21C9','Rrightarrow':'\u21DB','rsaquo':'\u203A','rscr':'\uD835\uDCC7','Rscr':'\u211B','rsh':'\u21B1','Rsh':'\u21B1','rsqb':']','rsquo':'\u2019','rsquor':'\u2019','rthree':'\u22CC','rtimes':'\u22CA','rtri':'\u25B9','rtrie':'\u22B5','rtrif':'\u25B8','rtriltri':'\u29CE','RuleDelayed':'\u29F4','ruluhar':'\u2968','rx':'\u211E','sacute':'\u015B','Sacute':'\u015A','sbquo':'\u201A','sc':'\u227B','Sc':'\u2ABC','scap':'\u2AB8','scaron':'\u0161','Scaron':'\u0160','sccue':'\u227D','sce':'\u2AB0','scE':'\u2AB4','scedil':'\u015F','Scedil':'\u015E','scirc':'\u015D','Scirc':'\u015C','scnap':'\u2ABA','scnE':'\u2AB6','scnsim':'\u22E9','scpolint':'\u2A13','scsim':'\u227F','scy':'\u0441','Scy':'\u0421','sdot':'\u22C5','sdotb':'\u22A1','sdote':'\u2A66','searhk':'\u2925','searr':'\u2198','seArr':'\u21D8','searrow':'\u2198','sect':'\xA7','semi':';','seswar':'\u2929','setminus':'\u2216','setmn':'\u2216','sext':'\u2736','sfr':'\uD835\uDD30','Sfr':'\uD835\uDD16','sfrown':'\u2322','sharp':'\u266F','shchcy':'\u0449','SHCHcy':'\u0429','shcy':'\u0448','SHcy':'\u0428','ShortDownArrow':'\u2193','ShortLeftArrow':'\u2190','shortmid':'\u2223','shortparallel':'\u2225','ShortRightArrow':'\u2192','ShortUpArrow':'\u2191','shy':'\xAD','sigma':'\u03C3','Sigma':'\u03A3','sigmaf':'\u03C2','sigmav':'\u03C2','sim':'\u223C','simdot':'\u2A6A','sime':'\u2243','simeq':'\u2243','simg':'\u2A9E','simgE':'\u2AA0','siml':'\u2A9D','simlE':'\u2A9F','simne':'\u2246','simplus':'\u2A24','simrarr':'\u2972','slarr':'\u2190','SmallCircle':'\u2218','smallsetminus':'\u2216','smashp':'\u2A33','smeparsl':'\u29E4','smid':'\u2223','smile':'\u2323','smt':'\u2AAA','smte':'\u2AAC','smtes':'\u2AAC\uFE00','softcy':'\u044C','SOFTcy':'\u042C','sol':'/','solb':'\u29C4','solbar':'\u233F','sopf':'\uD835\uDD64','Sopf':'\uD835\uDD4A','spades':'\u2660','spadesuit':'\u2660','spar':'\u2225','sqcap':'\u2293','sqcaps':'\u2293\uFE00','sqcup':'\u2294','sqcups':'\u2294\uFE00','Sqrt':'\u221A','sqsub':'\u228F','sqsube':'\u2291','sqsubset':'\u228F','sqsubseteq':'\u2291','sqsup':'\u2290','sqsupe':'\u2292','sqsupset':'\u2290','sqsupseteq':'\u2292','squ':'\u25A1','square':'\u25A1','Square':'\u25A1','SquareIntersection':'\u2293','SquareSubset':'\u228F','SquareSubsetEqual':'\u2291','SquareSuperset':'\u2290','SquareSupersetEqual':'\u2292','SquareUnion':'\u2294','squarf':'\u25AA','squf':'\u25AA','srarr':'\u2192','sscr':'\uD835\uDCC8','Sscr':'\uD835\uDCAE','ssetmn':'\u2216','ssmile':'\u2323','sstarf':'\u22C6','star':'\u2606','Star':'\u22C6','starf':'\u2605','straightepsilon':'\u03F5','straightphi':'\u03D5','strns':'\xAF','sub':'\u2282','Sub':'\u22D0','subdot':'\u2ABD','sube':'\u2286','subE':'\u2AC5','subedot':'\u2AC3','submult':'\u2AC1','subne':'\u228A','subnE':'\u2ACB','subplus':'\u2ABF','subrarr':'\u2979','subset':'\u2282','Subset':'\u22D0','subseteq':'\u2286','subseteqq':'\u2AC5','SubsetEqual':'\u2286','subsetneq':'\u228A','subsetneqq':'\u2ACB','subsim':'\u2AC7','subsub':'\u2AD5','subsup':'\u2AD3','succ':'\u227B','succapprox':'\u2AB8','succcurlyeq':'\u227D','Succeeds':'\u227B','SucceedsEqual':'\u2AB0','SucceedsSlantEqual':'\u227D','SucceedsTilde':'\u227F','succeq':'\u2AB0','succnapprox':'\u2ABA','succneqq':'\u2AB6','succnsim':'\u22E9','succsim':'\u227F','SuchThat':'\u220B','sum':'\u2211','Sum':'\u2211','sung':'\u266A','sup':'\u2283','Sup':'\u22D1','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','supdot':'\u2ABE','supdsub':'\u2AD8','supe':'\u2287','supE':'\u2AC6','supedot':'\u2AC4','Superset':'\u2283','SupersetEqual':'\u2287','suphsol':'\u27C9','suphsub':'\u2AD7','suplarr':'\u297B','supmult':'\u2AC2','supne':'\u228B','supnE':'\u2ACC','supplus':'\u2AC0','supset':'\u2283','Supset':'\u22D1','supseteq':'\u2287','supseteqq':'\u2AC6','supsetneq':'\u228B','supsetneqq':'\u2ACC','supsim':'\u2AC8','supsub':'\u2AD4','supsup':'\u2AD6','swarhk':'\u2926','swarr':'\u2199','swArr':'\u21D9','swarrow':'\u2199','swnwar':'\u292A','szlig':'\xDF','Tab':'\t','target':'\u2316','tau':'\u03C4','Tau':'\u03A4','tbrk':'\u23B4','tcaron':'\u0165','Tcaron':'\u0164','tcedil':'\u0163','Tcedil':'\u0162','tcy':'\u0442','Tcy':'\u0422','tdot':'\u20DB','telrec':'\u2315','tfr':'\uD835\uDD31','Tfr':'\uD835\uDD17','there4':'\u2234','therefore':'\u2234','Therefore':'\u2234','theta':'\u03B8','Theta':'\u0398','thetasym':'\u03D1','thetav':'\u03D1','thickapprox':'\u2248','thicksim':'\u223C','ThickSpace':'\u205F\u200A','thinsp':'\u2009','ThinSpace':'\u2009','thkap':'\u2248','thksim':'\u223C','thorn':'\xFE','THORN':'\xDE','tilde':'\u02DC','Tilde':'\u223C','TildeEqual':'\u2243','TildeFullEqual':'\u2245','TildeTilde':'\u2248','times':'\xD7','timesb':'\u22A0','timesbar':'\u2A31','timesd':'\u2A30','tint':'\u222D','toea':'\u2928','top':'\u22A4','topbot':'\u2336','topcir':'\u2AF1','topf':'\uD835\uDD65','Topf':'\uD835\uDD4B','topfork':'\u2ADA','tosa':'\u2929','tprime':'\u2034','trade':'\u2122','TRADE':'\u2122','triangle':'\u25B5','triangledown':'\u25BF','triangleleft':'\u25C3','trianglelefteq':'\u22B4','triangleq':'\u225C','triangleright':'\u25B9','trianglerighteq':'\u22B5','tridot':'\u25EC','trie':'\u225C','triminus':'\u2A3A','TripleDot':'\u20DB','triplus':'\u2A39','trisb':'\u29CD','tritime':'\u2A3B','trpezium':'\u23E2','tscr':'\uD835\uDCC9','Tscr':'\uD835\uDCAF','tscy':'\u0446','TScy':'\u0426','tshcy':'\u045B','TSHcy':'\u040B','tstrok':'\u0167','Tstrok':'\u0166','twixt':'\u226C','twoheadleftarrow':'\u219E','twoheadrightarrow':'\u21A0','uacute':'\xFA','Uacute':'\xDA','uarr':'\u2191','uArr':'\u21D1','Uarr':'\u219F','Uarrocir':'\u2949','ubrcy':'\u045E','Ubrcy':'\u040E','ubreve':'\u016D','Ubreve':'\u016C','ucirc':'\xFB','Ucirc':'\xDB','ucy':'\u0443','Ucy':'\u0423','udarr':'\u21C5','udblac':'\u0171','Udblac':'\u0170','udhar':'\u296E','ufisht':'\u297E','ufr':'\uD835\uDD32','Ufr':'\uD835\uDD18','ugrave':'\xF9','Ugrave':'\xD9','uHar':'\u2963','uharl':'\u21BF','uharr':'\u21BE','uhblk':'\u2580','ulcorn':'\u231C','ulcorner':'\u231C','ulcrop':'\u230F','ultri':'\u25F8','umacr':'\u016B','Umacr':'\u016A','uml':'\xA8','UnderBar':'_','UnderBrace':'\u23DF','UnderBracket':'\u23B5','UnderParenthesis':'\u23DD','Union':'\u22C3','UnionPlus':'\u228E','uogon':'\u0173','Uogon':'\u0172','uopf':'\uD835\uDD66','Uopf':'\uD835\uDD4C','uparrow':'\u2191','Uparrow':'\u21D1','UpArrow':'\u2191','UpArrowBar':'\u2912','UpArrowDownArrow':'\u21C5','updownarrow':'\u2195','Updownarrow':'\u21D5','UpDownArrow':'\u2195','UpEquilibrium':'\u296E','upharpoonleft':'\u21BF','upharpoonright':'\u21BE','uplus':'\u228E','UpperLeftArrow':'\u2196','UpperRightArrow':'\u2197','upsi':'\u03C5','Upsi':'\u03D2','upsih':'\u03D2','upsilon':'\u03C5','Upsilon':'\u03A5','UpTee':'\u22A5','UpTeeArrow':'\u21A5','upuparrows':'\u21C8','urcorn':'\u231D','urcorner':'\u231D','urcrop':'\u230E','uring':'\u016F','Uring':'\u016E','urtri':'\u25F9','uscr':'\uD835\uDCCA','Uscr':'\uD835\uDCB0','utdot':'\u22F0','utilde':'\u0169','Utilde':'\u0168','utri':'\u25B5','utrif':'\u25B4','uuarr':'\u21C8','uuml':'\xFC','Uuml':'\xDC','uwangle':'\u29A7','vangrt':'\u299C','varepsilon':'\u03F5','varkappa':'\u03F0','varnothing':'\u2205','varphi':'\u03D5','varpi':'\u03D6','varpropto':'\u221D','varr':'\u2195','vArr':'\u21D5','varrho':'\u03F1','varsigma':'\u03C2','varsubsetneq':'\u228A\uFE00','varsubsetneqq':'\u2ACB\uFE00','varsupsetneq':'\u228B\uFE00','varsupsetneqq':'\u2ACC\uFE00','vartheta':'\u03D1','vartriangleleft':'\u22B2','vartriangleright':'\u22B3','vBar':'\u2AE8','Vbar':'\u2AEB','vBarv':'\u2AE9','vcy':'\u0432','Vcy':'\u0412','vdash':'\u22A2','vDash':'\u22A8','Vdash':'\u22A9','VDash':'\u22AB','Vdashl':'\u2AE6','vee':'\u2228','Vee':'\u22C1','veebar':'\u22BB','veeeq':'\u225A','vellip':'\u22EE','verbar':'|','Verbar':'\u2016','vert':'|','Vert':'\u2016','VerticalBar':'\u2223','VerticalLine':'|','VerticalSeparator':'\u2758','VerticalTilde':'\u2240','VeryThinSpace':'\u200A','vfr':'\uD835\uDD33','Vfr':'\uD835\uDD19','vltri':'\u22B2','vnsub':'\u2282\u20D2','vnsup':'\u2283\u20D2','vopf':'\uD835\uDD67','Vopf':'\uD835\uDD4D','vprop':'\u221D','vrtri':'\u22B3','vscr':'\uD835\uDCCB','Vscr':'\uD835\uDCB1','vsubne':'\u228A\uFE00','vsubnE':'\u2ACB\uFE00','vsupne':'\u228B\uFE00','vsupnE':'\u2ACC\uFE00','Vvdash':'\u22AA','vzigzag':'\u299A','wcirc':'\u0175','Wcirc':'\u0174','wedbar':'\u2A5F','wedge':'\u2227','Wedge':'\u22C0','wedgeq':'\u2259','weierp':'\u2118','wfr':'\uD835\uDD34','Wfr':'\uD835\uDD1A','wopf':'\uD835\uDD68','Wopf':'\uD835\uDD4E','wp':'\u2118','wr':'\u2240','wreath':'\u2240','wscr':'\uD835\uDCCC','Wscr':'\uD835\uDCB2','xcap':'\u22C2','xcirc':'\u25EF','xcup':'\u22C3','xdtri':'\u25BD','xfr':'\uD835\uDD35','Xfr':'\uD835\uDD1B','xharr':'\u27F7','xhArr':'\u27FA','xi':'\u03BE','Xi':'\u039E','xlarr':'\u27F5','xlArr':'\u27F8','xmap':'\u27FC','xnis':'\u22FB','xodot':'\u2A00','xopf':'\uD835\uDD69','Xopf':'\uD835\uDD4F','xoplus':'\u2A01','xotime':'\u2A02','xrarr':'\u27F6','xrArr':'\u27F9','xscr':'\uD835\uDCCD','Xscr':'\uD835\uDCB3','xsqcup':'\u2A06','xuplus':'\u2A04','xutri':'\u25B3','xvee':'\u22C1','xwedge':'\u22C0','yacute':'\xFD','Yacute':'\xDD','yacy':'\u044F','YAcy':'\u042F','ycirc':'\u0177','Ycirc':'\u0176','ycy':'\u044B','Ycy':'\u042B','yen':'\xA5','yfr':'\uD835\uDD36','Yfr':'\uD835\uDD1C','yicy':'\u0457','YIcy':'\u0407','yopf':'\uD835\uDD6A','Yopf':'\uD835\uDD50','yscr':'\uD835\uDCCE','Yscr':'\uD835\uDCB4','yucy':'\u044E','YUcy':'\u042E','yuml':'\xFF','Yuml':'\u0178','zacute':'\u017A','Zacute':'\u0179','zcaron':'\u017E','Zcaron':'\u017D','zcy':'\u0437','Zcy':'\u0417','zdot':'\u017C','Zdot':'\u017B','zeetrf':'\u2128','ZeroWidthSpace':'\u200B','zeta':'\u03B6','Zeta':'\u0396','zfr':'\uD835\uDD37','Zfr':'\u2128','zhcy':'\u0436','ZHcy':'\u0416','zigrarr':'\u21DD','zopf':'\uD835\uDD6B','Zopf':'\u2124','zscr':'\uD835\uDCCF','Zscr':'\uD835\uDCB5','zwj':'\u200D','zwnj':'\u200C'};
  12085. var decodeMapLegacy = {'aacute':'\xE1','Aacute':'\xC1','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','aelig':'\xE6','AElig':'\xC6','agrave':'\xE0','Agrave':'\xC0','amp':'&','AMP':'&','aring':'\xE5','Aring':'\xC5','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','brvbar':'\xA6','ccedil':'\xE7','Ccedil':'\xC7','cedil':'\xB8','cent':'\xA2','copy':'\xA9','COPY':'\xA9','curren':'\xA4','deg':'\xB0','divide':'\xF7','eacute':'\xE9','Eacute':'\xC9','ecirc':'\xEA','Ecirc':'\xCA','egrave':'\xE8','Egrave':'\xC8','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','frac12':'\xBD','frac14':'\xBC','frac34':'\xBE','gt':'>','GT':'>','iacute':'\xED','Iacute':'\xCD','icirc':'\xEE','Icirc':'\xCE','iexcl':'\xA1','igrave':'\xEC','Igrave':'\xCC','iquest':'\xBF','iuml':'\xEF','Iuml':'\xCF','laquo':'\xAB','lt':'<','LT':'<','macr':'\xAF','micro':'\xB5','middot':'\xB7','nbsp':'\xA0','not':'\xAC','ntilde':'\xF1','Ntilde':'\xD1','oacute':'\xF3','Oacute':'\xD3','ocirc':'\xF4','Ocirc':'\xD4','ograve':'\xF2','Ograve':'\xD2','ordf':'\xAA','ordm':'\xBA','oslash':'\xF8','Oslash':'\xD8','otilde':'\xF5','Otilde':'\xD5','ouml':'\xF6','Ouml':'\xD6','para':'\xB6','plusmn':'\xB1','pound':'\xA3','quot':'"','QUOT':'"','raquo':'\xBB','reg':'\xAE','REG':'\xAE','sect':'\xA7','shy':'\xAD','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','szlig':'\xDF','thorn':'\xFE','THORN':'\xDE','times':'\xD7','uacute':'\xFA','Uacute':'\xDA','ucirc':'\xFB','Ucirc':'\xDB','ugrave':'\xF9','Ugrave':'\xD9','uml':'\xA8','uuml':'\xFC','Uuml':'\xDC','yacute':'\xFD','Yacute':'\xDD','yen':'\xA5','yuml':'\xFF'};
  12086. var decodeMapNumeric = {'0':'\uFFFD','128':'\u20AC','130':'\u201A','131':'\u0192','132':'\u201E','133':'\u2026','134':'\u2020','135':'\u2021','136':'\u02C6','137':'\u2030','138':'\u0160','139':'\u2039','140':'\u0152','142':'\u017D','145':'\u2018','146':'\u2019','147':'\u201C','148':'\u201D','149':'\u2022','150':'\u2013','151':'\u2014','152':'\u02DC','153':'\u2122','154':'\u0161','155':'\u203A','156':'\u0153','158':'\u017E','159':'\u0178'};
  12087. var invalidReferenceCodePoints = [1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65000,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111];
  12088. /*--------------------------------------------------------------------------*/
  12089. var stringFromCharCode = String.fromCharCode;
  12090. var object = {};
  12091. var hasOwnProperty = object.hasOwnProperty;
  12092. var has = function(object, propertyName) {
  12093. return hasOwnProperty.call(object, propertyName);
  12094. };
  12095. var contains = function(array, value) {
  12096. var index = -1;
  12097. var length = array.length;
  12098. while (++index < length) {
  12099. if (array[index] == value) {
  12100. return true;
  12101. }
  12102. }
  12103. return false;
  12104. };
  12105. var merge = function(options, defaults) {
  12106. if (!options) {
  12107. return defaults;
  12108. }
  12109. var result = {};
  12110. var key;
  12111. for (key in defaults) {
  12112. // A `hasOwnProperty` check is not needed here, since only recognized
  12113. // option names are used anyway. Any others are ignored.
  12114. result[key] = has(options, key) ? options[key] : defaults[key];
  12115. }
  12116. return result;
  12117. };
  12118. // Modified version of `ucs2encode`; see https://mths.be/punycode.
  12119. var codePointToSymbol = function(codePoint, strict) {
  12120. var output = '';
  12121. if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
  12122. // See issue #4:
  12123. // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
  12124. // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
  12125. // REPLACEMENT CHARACTER.”
  12126. if (strict) {
  12127. parseError('character reference outside the permissible Unicode range');
  12128. }
  12129. return '\uFFFD';
  12130. }
  12131. if (has(decodeMapNumeric, codePoint)) {
  12132. if (strict) {
  12133. parseError('disallowed character reference');
  12134. }
  12135. return decodeMapNumeric[codePoint];
  12136. }
  12137. if (strict && contains(invalidReferenceCodePoints, codePoint)) {
  12138. parseError('disallowed character reference');
  12139. }
  12140. if (codePoint > 0xFFFF) {
  12141. codePoint -= 0x10000;
  12142. output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
  12143. codePoint = 0xDC00 | codePoint & 0x3FF;
  12144. }
  12145. output += stringFromCharCode(codePoint);
  12146. return output;
  12147. };
  12148. var hexEscape = function(codePoint) {
  12149. return '&#x' + codePoint.toString(16).toUpperCase() + ';';
  12150. };
  12151. var decEscape = function(codePoint) {
  12152. return '&#' + codePoint + ';';
  12153. };
  12154. var parseError = function(message) {
  12155. throw Error('Parse error: ' + message);
  12156. };
  12157. /*--------------------------------------------------------------------------*/
  12158. var encode = function(string, options) {
  12159. options = merge(options, encode.options);
  12160. var strict = options.strict;
  12161. if (strict && regexInvalidRawCodePoint.test(string)) {
  12162. parseError('forbidden code point');
  12163. }
  12164. var encodeEverything = options.encodeEverything;
  12165. var useNamedReferences = options.useNamedReferences;
  12166. var allowUnsafeSymbols = options.allowUnsafeSymbols;
  12167. var escapeCodePoint = options.decimal ? decEscape : hexEscape;
  12168. var escapeBmpSymbol = function(symbol) {
  12169. return escapeCodePoint(symbol.charCodeAt(0));
  12170. };
  12171. if (encodeEverything) {
  12172. // Encode ASCII symbols.
  12173. string = string.replace(regexAsciiWhitelist, function(symbol) {
  12174. // Use named references if requested & possible.
  12175. if (useNamedReferences && has(encodeMap, symbol)) {
  12176. return '&' + encodeMap[symbol] + ';';
  12177. }
  12178. return escapeBmpSymbol(symbol);
  12179. });
  12180. // Shorten a few escapes that represent two symbols, of which at least one
  12181. // is within the ASCII range.
  12182. if (useNamedReferences) {
  12183. string = string
  12184. .replace(/&gt;\u20D2/g, '&nvgt;')
  12185. .replace(/&lt;\u20D2/g, '&nvlt;')
  12186. .replace(/&#x66;&#x6A;/g, '&fjlig;');
  12187. }
  12188. // Encode non-ASCII symbols.
  12189. if (useNamedReferences) {
  12190. // Encode non-ASCII symbols that can be replaced with a named reference.
  12191. string = string.replace(regexEncodeNonAscii, function(string) {
  12192. // Note: there is no need to check `has(encodeMap, string)` here.
  12193. return '&' + encodeMap[string] + ';';
  12194. });
  12195. }
  12196. // Note: any remaining non-ASCII symbols are handled outside of the `if`.
  12197. } else if (useNamedReferences) {
  12198. // Apply named character references.
  12199. // Encode `<>"'&` using named character references.
  12200. if (!allowUnsafeSymbols) {
  12201. string = string.replace(regexEscape, function(string) {
  12202. return '&' + encodeMap[string] + ';'; // no need to check `has()` here
  12203. });
  12204. }
  12205. // Shorten escapes that represent two symbols, of which at least one is
  12206. // `<>"'&`.
  12207. string = string
  12208. .replace(/&gt;\u20D2/g, '&nvgt;')
  12209. .replace(/&lt;\u20D2/g, '&nvlt;');
  12210. // Encode non-ASCII symbols that can be replaced with a named reference.
  12211. string = string.replace(regexEncodeNonAscii, function(string) {
  12212. // Note: there is no need to check `has(encodeMap, string)` here.
  12213. return '&' + encodeMap[string] + ';';
  12214. });
  12215. } else if (!allowUnsafeSymbols) {
  12216. // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
  12217. // using named character references.
  12218. string = string.replace(regexEscape, escapeBmpSymbol);
  12219. }
  12220. return string
  12221. // Encode astral symbols.
  12222. .replace(regexAstralSymbols, function($0) {
  12223. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  12224. var high = $0.charCodeAt(0);
  12225. var low = $0.charCodeAt(1);
  12226. var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
  12227. return escapeCodePoint(codePoint);
  12228. })
  12229. // Encode any remaining BMP symbols that are not printable ASCII symbols
  12230. // using a hexadecimal escape.
  12231. .replace(regexBmpWhitelist, escapeBmpSymbol);
  12232. };
  12233. // Expose default options (so they can be overridden globally).
  12234. encode.options = {
  12235. 'allowUnsafeSymbols': false,
  12236. 'encodeEverything': false,
  12237. 'strict': false,
  12238. 'useNamedReferences': false,
  12239. 'decimal' : false
  12240. };
  12241. var decode = function(html, options) {
  12242. options = merge(options, decode.options);
  12243. var strict = options.strict;
  12244. if (strict && regexInvalidEntity.test(html)) {
  12245. parseError('malformed character reference');
  12246. }
  12247. return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7, $8) {
  12248. var codePoint;
  12249. var semicolon;
  12250. var decDigits;
  12251. var hexDigits;
  12252. var reference;
  12253. var next;
  12254. if ($1) {
  12255. reference = $1;
  12256. // Note: there is no need to check `has(decodeMap, reference)`.
  12257. return decodeMap[reference];
  12258. }
  12259. if ($2) {
  12260. // Decode named character references without trailing `;`, e.g. `&amp`.
  12261. // This is only a parse error if it gets converted to `&`, or if it is
  12262. // followed by `=` in an attribute context.
  12263. reference = $2;
  12264. next = $3;
  12265. if (next && options.isAttributeValue) {
  12266. if (strict && next == '=') {
  12267. parseError('`&` did not start a character reference');
  12268. }
  12269. return $0;
  12270. } else {
  12271. if (strict) {
  12272. parseError(
  12273. 'named character reference was not terminated by a semicolon'
  12274. );
  12275. }
  12276. // Note: there is no need to check `has(decodeMapLegacy, reference)`.
  12277. return decodeMapLegacy[reference] + (next || '');
  12278. }
  12279. }
  12280. if ($4) {
  12281. // Decode decimal escapes, e.g. `&#119558;`.
  12282. decDigits = $4;
  12283. semicolon = $5;
  12284. if (strict && !semicolon) {
  12285. parseError('character reference was not terminated by a semicolon');
  12286. }
  12287. codePoint = parseInt(decDigits, 10);
  12288. return codePointToSymbol(codePoint, strict);
  12289. }
  12290. if ($6) {
  12291. // Decode hexadecimal escapes, e.g. `&#x1D306;`.
  12292. hexDigits = $6;
  12293. semicolon = $7;
  12294. if (strict && !semicolon) {
  12295. parseError('character reference was not terminated by a semicolon');
  12296. }
  12297. codePoint = parseInt(hexDigits, 16);
  12298. return codePointToSymbol(codePoint, strict);
  12299. }
  12300. // If we’re still here, `if ($7)` is implied; it’s an ambiguous
  12301. // ampersand for sure. https://mths.be/notes/ambiguous-ampersands
  12302. if (strict) {
  12303. parseError(
  12304. 'named character reference was not terminated by a semicolon'
  12305. );
  12306. }
  12307. return $0;
  12308. });
  12309. };
  12310. // Expose default options (so they can be overridden globally).
  12311. decode.options = {
  12312. 'isAttributeValue': false,
  12313. 'strict': false
  12314. };
  12315. var escape = function(string) {
  12316. return string.replace(regexEscape, function($0) {
  12317. // Note: there is no need to check `has(escapeMap, $0)` here.
  12318. return escapeMap[$0];
  12319. });
  12320. };
  12321. /*--------------------------------------------------------------------------*/
  12322. var he = {
  12323. 'version': '1.2.0',
  12324. 'encode': encode,
  12325. 'decode': decode,
  12326. 'escape': escape,
  12327. 'unescape': decode
  12328. };
  12329. // Some AMD build optimizers, like r.js, check for specific condition patterns
  12330. // like the following:
  12331. if (
  12332. false
  12333. ) {
  12334. define(function() {
  12335. return he;
  12336. });
  12337. } else if (freeExports && !freeExports.nodeType) {
  12338. if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
  12339. freeModule.exports = he;
  12340. } else { // in Narwhal or RingoJS v0.7.0-
  12341. for (var key in he) {
  12342. has(he, key) && (freeExports[key] = he[key]);
  12343. }
  12344. }
  12345. } else { // in Rhino or a web browser
  12346. root.he = he;
  12347. }
  12348. }(this));
  12349. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  12350. },{}],55:[function(require,module,exports){
  12351. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  12352. var e, m
  12353. var eLen = (nBytes * 8) - mLen - 1
  12354. var eMax = (1 << eLen) - 1
  12355. var eBias = eMax >> 1
  12356. var nBits = -7
  12357. var i = isLE ? (nBytes - 1) : 0
  12358. var d = isLE ? -1 : 1
  12359. var s = buffer[offset + i]
  12360. i += d
  12361. e = s & ((1 << (-nBits)) - 1)
  12362. s >>= (-nBits)
  12363. nBits += eLen
  12364. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  12365. m = e & ((1 << (-nBits)) - 1)
  12366. e >>= (-nBits)
  12367. nBits += mLen
  12368. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  12369. if (e === 0) {
  12370. e = 1 - eBias
  12371. } else if (e === eMax) {
  12372. return m ? NaN : ((s ? -1 : 1) * Infinity)
  12373. } else {
  12374. m = m + Math.pow(2, mLen)
  12375. e = e - eBias
  12376. }
  12377. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  12378. }
  12379. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  12380. var e, m, c
  12381. var eLen = (nBytes * 8) - mLen - 1
  12382. var eMax = (1 << eLen) - 1
  12383. var eBias = eMax >> 1
  12384. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  12385. var i = isLE ? 0 : (nBytes - 1)
  12386. var d = isLE ? 1 : -1
  12387. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  12388. value = Math.abs(value)
  12389. if (isNaN(value) || value === Infinity) {
  12390. m = isNaN(value) ? 1 : 0
  12391. e = eMax
  12392. } else {
  12393. e = Math.floor(Math.log(value) / Math.LN2)
  12394. if (value * (c = Math.pow(2, -e)) < 1) {
  12395. e--
  12396. c *= 2
  12397. }
  12398. if (e + eBias >= 1) {
  12399. value += rt / c
  12400. } else {
  12401. value += rt * Math.pow(2, 1 - eBias)
  12402. }
  12403. if (value * c >= 2) {
  12404. e++
  12405. c /= 2
  12406. }
  12407. if (e + eBias >= eMax) {
  12408. m = 0
  12409. e = eMax
  12410. } else if (e + eBias >= 1) {
  12411. m = ((value * c) - 1) * Math.pow(2, mLen)
  12412. e = e + eBias
  12413. } else {
  12414. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  12415. e = 0
  12416. }
  12417. }
  12418. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  12419. e = (e << mLen) | m
  12420. eLen += mLen
  12421. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  12422. buffer[offset + i - d] |= s * 128
  12423. }
  12424. },{}],56:[function(require,module,exports){
  12425. if (typeof Object.create === 'function') {
  12426. // implementation from standard node.js 'util' module
  12427. module.exports = function inherits(ctor, superCtor) {
  12428. ctor.super_ = superCtor
  12429. ctor.prototype = Object.create(superCtor.prototype, {
  12430. constructor: {
  12431. value: ctor,
  12432. enumerable: false,
  12433. writable: true,
  12434. configurable: true
  12435. }
  12436. });
  12437. };
  12438. } else {
  12439. // old school shim for old browsers
  12440. module.exports = function inherits(ctor, superCtor) {
  12441. ctor.super_ = superCtor
  12442. var TempCtor = function () {}
  12443. TempCtor.prototype = superCtor.prototype
  12444. ctor.prototype = new TempCtor()
  12445. ctor.prototype.constructor = ctor
  12446. }
  12447. }
  12448. },{}],57:[function(require,module,exports){
  12449. /*!
  12450. * Determine if an object is a Buffer
  12451. *
  12452. * @author Feross Aboukhadijeh <https://feross.org>
  12453. * @license MIT
  12454. */
  12455. // The _isBuffer check is for Safari 5-7 support, because it's missing
  12456. // Object.prototype.constructor. Remove this eventually
  12457. module.exports = function (obj) {
  12458. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  12459. }
  12460. function isBuffer (obj) {
  12461. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  12462. }
  12463. // For Node v0.10 support. Remove this eventually.
  12464. function isSlowBuffer (obj) {
  12465. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  12466. }
  12467. },{}],58:[function(require,module,exports){
  12468. var toString = {}.toString;
  12469. module.exports = Array.isArray || function (arr) {
  12470. return toString.call(arr) == '[object Array]';
  12471. };
  12472. },{}],59:[function(require,module,exports){
  12473. var path = require('path');
  12474. var fs = require('fs');
  12475. var _0777 = parseInt('0777', 8);
  12476. module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
  12477. function mkdirP (p, opts, f, made) {
  12478. if (typeof opts === 'function') {
  12479. f = opts;
  12480. opts = {};
  12481. }
  12482. else if (!opts || typeof opts !== 'object') {
  12483. opts = { mode: opts };
  12484. }
  12485. var mode = opts.mode;
  12486. var xfs = opts.fs || fs;
  12487. if (mode === undefined) {
  12488. mode = _0777
  12489. }
  12490. if (!made) made = null;
  12491. var cb = f || function () {};
  12492. p = path.resolve(p);
  12493. xfs.mkdir(p, mode, function (er) {
  12494. if (!er) {
  12495. made = made || p;
  12496. return cb(null, made);
  12497. }
  12498. switch (er.code) {
  12499. case 'ENOENT':
  12500. if (path.dirname(p) === p) return cb(er);
  12501. mkdirP(path.dirname(p), opts, function (er, made) {
  12502. if (er) cb(er, made);
  12503. else mkdirP(p, opts, cb, made);
  12504. });
  12505. break;
  12506. // In the case of any other error, just see if there's a dir
  12507. // there already. If so, then hooray! If not, then something
  12508. // is borked.
  12509. default:
  12510. xfs.stat(p, function (er2, stat) {
  12511. // if the stat fails, then that's super weird.
  12512. // let the original error be the failure reason.
  12513. if (er2 || !stat.isDirectory()) cb(er, made)
  12514. else cb(null, made);
  12515. });
  12516. break;
  12517. }
  12518. });
  12519. }
  12520. mkdirP.sync = function sync (p, opts, made) {
  12521. if (!opts || typeof opts !== 'object') {
  12522. opts = { mode: opts };
  12523. }
  12524. var mode = opts.mode;
  12525. var xfs = opts.fs || fs;
  12526. if (mode === undefined) {
  12527. mode = _0777
  12528. }
  12529. if (!made) made = null;
  12530. p = path.resolve(p);
  12531. try {
  12532. xfs.mkdirSync(p, mode);
  12533. made = made || p;
  12534. }
  12535. catch (err0) {
  12536. switch (err0.code) {
  12537. case 'ENOENT' :
  12538. made = sync(path.dirname(p), opts, made);
  12539. sync(p, opts, made);
  12540. break;
  12541. // In the case of any other error, just see if there's a dir
  12542. // there already. If so, then hooray! If not, then something
  12543. // is borked.
  12544. default:
  12545. var stat;
  12546. try {
  12547. stat = xfs.statSync(p);
  12548. }
  12549. catch (err1) {
  12550. throw err0;
  12551. }
  12552. if (!stat.isDirectory()) throw err0;
  12553. break;
  12554. }
  12555. }
  12556. return made;
  12557. };
  12558. },{"fs":42,"path":42}],60:[function(require,module,exports){
  12559. /**
  12560. * Helpers.
  12561. */
  12562. var s = 1000;
  12563. var m = s * 60;
  12564. var h = m * 60;
  12565. var d = h * 24;
  12566. var w = d * 7;
  12567. var y = d * 365.25;
  12568. /**
  12569. * Parse or format the given `val`.
  12570. *
  12571. * Options:
  12572. *
  12573. * - `long` verbose formatting [false]
  12574. *
  12575. * @param {String|Number} val
  12576. * @param {Object} [options]
  12577. * @throws {Error} throw an error if val is not a non-empty string or a number
  12578. * @return {String|Number}
  12579. * @api public
  12580. */
  12581. module.exports = function(val, options) {
  12582. options = options || {};
  12583. var type = typeof val;
  12584. if (type === 'string' && val.length > 0) {
  12585. return parse(val);
  12586. } else if (type === 'number' && isNaN(val) === false) {
  12587. return options.long ? fmtLong(val) : fmtShort(val);
  12588. }
  12589. throw new Error(
  12590. 'val is not a non-empty string or a valid number. val=' +
  12591. JSON.stringify(val)
  12592. );
  12593. };
  12594. /**
  12595. * Parse the given `str` and return milliseconds.
  12596. *
  12597. * @param {String} str
  12598. * @return {Number}
  12599. * @api private
  12600. */
  12601. function parse(str) {
  12602. str = String(str);
  12603. if (str.length > 100) {
  12604. return;
  12605. }
  12606. var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
  12607. str
  12608. );
  12609. if (!match) {
  12610. return;
  12611. }
  12612. var n = parseFloat(match[1]);
  12613. var type = (match[2] || 'ms').toLowerCase();
  12614. switch (type) {
  12615. case 'years':
  12616. case 'year':
  12617. case 'yrs':
  12618. case 'yr':
  12619. case 'y':
  12620. return n * y;
  12621. case 'weeks':
  12622. case 'week':
  12623. case 'w':
  12624. return n * w;
  12625. case 'days':
  12626. case 'day':
  12627. case 'd':
  12628. return n * d;
  12629. case 'hours':
  12630. case 'hour':
  12631. case 'hrs':
  12632. case 'hr':
  12633. case 'h':
  12634. return n * h;
  12635. case 'minutes':
  12636. case 'minute':
  12637. case 'mins':
  12638. case 'min':
  12639. case 'm':
  12640. return n * m;
  12641. case 'seconds':
  12642. case 'second':
  12643. case 'secs':
  12644. case 'sec':
  12645. case 's':
  12646. return n * s;
  12647. case 'milliseconds':
  12648. case 'millisecond':
  12649. case 'msecs':
  12650. case 'msec':
  12651. case 'ms':
  12652. return n;
  12653. default:
  12654. return undefined;
  12655. }
  12656. }
  12657. /**
  12658. * Short format for `ms`.
  12659. *
  12660. * @param {Number} ms
  12661. * @return {String}
  12662. * @api private
  12663. */
  12664. function fmtShort(ms) {
  12665. var msAbs = Math.abs(ms);
  12666. if (msAbs >= d) {
  12667. return Math.round(ms / d) + 'd';
  12668. }
  12669. if (msAbs >= h) {
  12670. return Math.round(ms / h) + 'h';
  12671. }
  12672. if (msAbs >= m) {
  12673. return Math.round(ms / m) + 'm';
  12674. }
  12675. if (msAbs >= s) {
  12676. return Math.round(ms / s) + 's';
  12677. }
  12678. return ms + 'ms';
  12679. }
  12680. /**
  12681. * Long format for `ms`.
  12682. *
  12683. * @param {Number} ms
  12684. * @return {String}
  12685. * @api private
  12686. */
  12687. function fmtLong(ms) {
  12688. var msAbs = Math.abs(ms);
  12689. if (msAbs >= d) {
  12690. return plural(ms, msAbs, d, 'day');
  12691. }
  12692. if (msAbs >= h) {
  12693. return plural(ms, msAbs, h, 'hour');
  12694. }
  12695. if (msAbs >= m) {
  12696. return plural(ms, msAbs, m, 'minute');
  12697. }
  12698. if (msAbs >= s) {
  12699. return plural(ms, msAbs, s, 'second');
  12700. }
  12701. return ms + ' ms';
  12702. }
  12703. /**
  12704. * Pluralization helper.
  12705. */
  12706. function plural(ms, msAbs, n, name) {
  12707. var isPlural = msAbs >= n * 1.5;
  12708. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  12709. }
  12710. },{}],61:[function(require,module,exports){
  12711. 'use strict';
  12712. var keysShim;
  12713. if (!Object.keys) {
  12714. // modified from https://github.com/es-shims/es5-shim
  12715. var has = Object.prototype.hasOwnProperty;
  12716. var toStr = Object.prototype.toString;
  12717. var isArgs = require('./isArguments'); // eslint-disable-line global-require
  12718. var isEnumerable = Object.prototype.propertyIsEnumerable;
  12719. var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
  12720. var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
  12721. var dontEnums = [
  12722. 'toString',
  12723. 'toLocaleString',
  12724. 'valueOf',
  12725. 'hasOwnProperty',
  12726. 'isPrototypeOf',
  12727. 'propertyIsEnumerable',
  12728. 'constructor'
  12729. ];
  12730. var equalsConstructorPrototype = function (o) {
  12731. var ctor = o.constructor;
  12732. return ctor && ctor.prototype === o;
  12733. };
  12734. var excludedKeys = {
  12735. $applicationCache: true,
  12736. $console: true,
  12737. $external: true,
  12738. $frame: true,
  12739. $frameElement: true,
  12740. $frames: true,
  12741. $innerHeight: true,
  12742. $innerWidth: true,
  12743. $outerHeight: true,
  12744. $outerWidth: true,
  12745. $pageXOffset: true,
  12746. $pageYOffset: true,
  12747. $parent: true,
  12748. $scrollLeft: true,
  12749. $scrollTop: true,
  12750. $scrollX: true,
  12751. $scrollY: true,
  12752. $self: true,
  12753. $webkitIndexedDB: true,
  12754. $webkitStorageInfo: true,
  12755. $window: true
  12756. };
  12757. var hasAutomationEqualityBug = (function () {
  12758. /* global window */
  12759. if (typeof window === 'undefined') { return false; }
  12760. for (var k in window) {
  12761. try {
  12762. if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  12763. try {
  12764. equalsConstructorPrototype(window[k]);
  12765. } catch (e) {
  12766. return true;
  12767. }
  12768. }
  12769. } catch (e) {
  12770. return true;
  12771. }
  12772. }
  12773. return false;
  12774. }());
  12775. var equalsConstructorPrototypeIfNotBuggy = function (o) {
  12776. /* global window */
  12777. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  12778. return equalsConstructorPrototype(o);
  12779. }
  12780. try {
  12781. return equalsConstructorPrototype(o);
  12782. } catch (e) {
  12783. return false;
  12784. }
  12785. };
  12786. keysShim = function keys(object) {
  12787. var isObject = object !== null && typeof object === 'object';
  12788. var isFunction = toStr.call(object) === '[object Function]';
  12789. var isArguments = isArgs(object);
  12790. var isString = isObject && toStr.call(object) === '[object String]';
  12791. var theKeys = [];
  12792. if (!isObject && !isFunction && !isArguments) {
  12793. throw new TypeError('Object.keys called on a non-object');
  12794. }
  12795. var skipProto = hasProtoEnumBug && isFunction;
  12796. if (isString && object.length > 0 && !has.call(object, 0)) {
  12797. for (var i = 0; i < object.length; ++i) {
  12798. theKeys.push(String(i));
  12799. }
  12800. }
  12801. if (isArguments && object.length > 0) {
  12802. for (var j = 0; j < object.length; ++j) {
  12803. theKeys.push(String(j));
  12804. }
  12805. } else {
  12806. for (var name in object) {
  12807. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  12808. theKeys.push(String(name));
  12809. }
  12810. }
  12811. }
  12812. if (hasDontEnumBug) {
  12813. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  12814. for (var k = 0; k < dontEnums.length; ++k) {
  12815. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  12816. theKeys.push(dontEnums[k]);
  12817. }
  12818. }
  12819. }
  12820. return theKeys;
  12821. };
  12822. }
  12823. module.exports = keysShim;
  12824. },{"./isArguments":63}],62:[function(require,module,exports){
  12825. 'use strict';
  12826. var slice = Array.prototype.slice;
  12827. var isArgs = require('./isArguments');
  12828. var origKeys = Object.keys;
  12829. var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation');
  12830. var originalKeys = Object.keys;
  12831. keysShim.shim = function shimObjectKeys() {
  12832. if (Object.keys) {
  12833. var keysWorksWithArguments = (function () {
  12834. // Safari 5.0 bug
  12835. var args = Object.keys(arguments);
  12836. return args && args.length === arguments.length;
  12837. }(1, 2));
  12838. if (!keysWorksWithArguments) {
  12839. Object.keys = function keys(object) { // eslint-disable-line func-name-matching
  12840. if (isArgs(object)) {
  12841. return originalKeys(slice.call(object));
  12842. }
  12843. return originalKeys(object);
  12844. };
  12845. }
  12846. } else {
  12847. Object.keys = keysShim;
  12848. }
  12849. return Object.keys || keysShim;
  12850. };
  12851. module.exports = keysShim;
  12852. },{"./implementation":61,"./isArguments":63}],63:[function(require,module,exports){
  12853. 'use strict';
  12854. var toStr = Object.prototype.toString;
  12855. module.exports = function isArguments(value) {
  12856. var str = toStr.call(value);
  12857. var isArgs = str === '[object Arguments]';
  12858. if (!isArgs) {
  12859. isArgs = str !== '[object Array]' &&
  12860. value !== null &&
  12861. typeof value === 'object' &&
  12862. typeof value.length === 'number' &&
  12863. value.length >= 0 &&
  12864. toStr.call(value.callee) === '[object Function]';
  12865. }
  12866. return isArgs;
  12867. };
  12868. },{}],64:[function(require,module,exports){
  12869. 'use strict';
  12870. // modified from https://github.com/es-shims/es6-shim
  12871. var keys = require('object-keys');
  12872. var bind = require('function-bind');
  12873. var canBeObject = function (obj) {
  12874. return typeof obj !== 'undefined' && obj !== null;
  12875. };
  12876. var hasSymbols = require('has-symbols/shams')();
  12877. var toObject = Object;
  12878. var push = bind.call(Function.call, Array.prototype.push);
  12879. var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
  12880. var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
  12881. module.exports = function assign(target, source1) {
  12882. if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
  12883. var objTarget = toObject(target);
  12884. var s, source, i, props, syms, value, key;
  12885. for (s = 1; s < arguments.length; ++s) {
  12886. source = toObject(arguments[s]);
  12887. props = keys(source);
  12888. var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
  12889. if (getSymbols) {
  12890. syms = getSymbols(source);
  12891. for (i = 0; i < syms.length; ++i) {
  12892. key = syms[i];
  12893. if (propIsEnumerable(source, key)) {
  12894. push(props, key);
  12895. }
  12896. }
  12897. }
  12898. for (i = 0; i < props.length; ++i) {
  12899. key = props[i];
  12900. value = source[key];
  12901. if (propIsEnumerable(source, key)) {
  12902. objTarget[key] = value;
  12903. }
  12904. }
  12905. }
  12906. return objTarget;
  12907. };
  12908. },{"function-bind":52,"has-symbols/shams":53,"object-keys":62}],65:[function(require,module,exports){
  12909. 'use strict';
  12910. var defineProperties = require('define-properties');
  12911. var implementation = require('./implementation');
  12912. var getPolyfill = require('./polyfill');
  12913. var shim = require('./shim');
  12914. var polyfill = getPolyfill();
  12915. defineProperties(polyfill, {
  12916. getPolyfill: getPolyfill,
  12917. implementation: implementation,
  12918. shim: shim
  12919. });
  12920. module.exports = polyfill;
  12921. },{"./implementation":64,"./polyfill":66,"./shim":67,"define-properties":47}],66:[function(require,module,exports){
  12922. 'use strict';
  12923. var implementation = require('./implementation');
  12924. var lacksProperEnumerationOrder = function () {
  12925. if (!Object.assign) {
  12926. return false;
  12927. }
  12928. // v8, specifically in node 4.x, has a bug with incorrect property enumeration order
  12929. // note: this does not detect the bug unless there's 20 characters
  12930. var str = 'abcdefghijklmnopqrst';
  12931. var letters = str.split('');
  12932. var map = {};
  12933. for (var i = 0; i < letters.length; ++i) {
  12934. map[letters[i]] = letters[i];
  12935. }
  12936. var obj = Object.assign({}, map);
  12937. var actual = '';
  12938. for (var k in obj) {
  12939. actual += k;
  12940. }
  12941. return str !== actual;
  12942. };
  12943. var assignHasPendingExceptions = function () {
  12944. if (!Object.assign || !Object.preventExtensions) {
  12945. return false;
  12946. }
  12947. // Firefox 37 still has "pending exception" logic in its Object.assign implementation,
  12948. // which is 72% slower than our shim, and Firefox 40's native implementation.
  12949. var thrower = Object.preventExtensions({ 1: 2 });
  12950. try {
  12951. Object.assign(thrower, 'xy');
  12952. } catch (e) {
  12953. return thrower[1] === 'y';
  12954. }
  12955. return false;
  12956. };
  12957. module.exports = function getPolyfill() {
  12958. if (!Object.assign) {
  12959. return implementation;
  12960. }
  12961. if (lacksProperEnumerationOrder()) {
  12962. return implementation;
  12963. }
  12964. if (assignHasPendingExceptions()) {
  12965. return implementation;
  12966. }
  12967. return Object.assign;
  12968. };
  12969. },{"./implementation":64}],67:[function(require,module,exports){
  12970. 'use strict';
  12971. var define = require('define-properties');
  12972. var getPolyfill = require('./polyfill');
  12973. module.exports = function shimAssign() {
  12974. var polyfill = getPolyfill();
  12975. define(
  12976. Object,
  12977. { assign: polyfill },
  12978. { assign: function () { return Object.assign !== polyfill; } }
  12979. );
  12980. return polyfill;
  12981. };
  12982. },{"./polyfill":66,"define-properties":47}],68:[function(require,module,exports){
  12983. (function (process){
  12984. 'use strict';
  12985. if (!process.version ||
  12986. process.version.indexOf('v0.') === 0 ||
  12987. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  12988. module.exports = { nextTick: nextTick };
  12989. } else {
  12990. module.exports = process
  12991. }
  12992. function nextTick(fn, arg1, arg2, arg3) {
  12993. if (typeof fn !== 'function') {
  12994. throw new TypeError('"callback" argument must be a function');
  12995. }
  12996. var len = arguments.length;
  12997. var args, i;
  12998. switch (len) {
  12999. case 0:
  13000. case 1:
  13001. return process.nextTick(fn);
  13002. case 2:
  13003. return process.nextTick(function afterTickOne() {
  13004. fn.call(null, arg1);
  13005. });
  13006. case 3:
  13007. return process.nextTick(function afterTickTwo() {
  13008. fn.call(null, arg1, arg2);
  13009. });
  13010. case 4:
  13011. return process.nextTick(function afterTickThree() {
  13012. fn.call(null, arg1, arg2, arg3);
  13013. });
  13014. default:
  13015. args = new Array(len - 1);
  13016. i = 0;
  13017. while (i < args.length) {
  13018. args[i++] = arguments[i];
  13019. }
  13020. return process.nextTick(function afterTick() {
  13021. fn.apply(null, args);
  13022. });
  13023. }
  13024. }
  13025. }).call(this,require('_process'))
  13026. },{"_process":69}],69:[function(require,module,exports){
  13027. // shim for using process in browser
  13028. var process = module.exports = {};
  13029. // cached from whatever global is present so that test runners that stub it
  13030. // don't break things. But we need to wrap it in a try catch in case it is
  13031. // wrapped in strict mode code which doesn't define any globals. It's inside a
  13032. // function because try/catches deoptimize in certain engines.
  13033. var cachedSetTimeout;
  13034. var cachedClearTimeout;
  13035. function defaultSetTimout() {
  13036. throw new Error('setTimeout has not been defined');
  13037. }
  13038. function defaultClearTimeout () {
  13039. throw new Error('clearTimeout has not been defined');
  13040. }
  13041. (function () {
  13042. try {
  13043. if (typeof setTimeout === 'function') {
  13044. cachedSetTimeout = setTimeout;
  13045. } else {
  13046. cachedSetTimeout = defaultSetTimout;
  13047. }
  13048. } catch (e) {
  13049. cachedSetTimeout = defaultSetTimout;
  13050. }
  13051. try {
  13052. if (typeof clearTimeout === 'function') {
  13053. cachedClearTimeout = clearTimeout;
  13054. } else {
  13055. cachedClearTimeout = defaultClearTimeout;
  13056. }
  13057. } catch (e) {
  13058. cachedClearTimeout = defaultClearTimeout;
  13059. }
  13060. } ())
  13061. function runTimeout(fun) {
  13062. if (cachedSetTimeout === setTimeout) {
  13063. //normal enviroments in sane situations
  13064. return setTimeout(fun, 0);
  13065. }
  13066. // if setTimeout wasn't available but was latter defined
  13067. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  13068. cachedSetTimeout = setTimeout;
  13069. return setTimeout(fun, 0);
  13070. }
  13071. try {
  13072. // when when somebody has screwed with setTimeout but no I.E. maddness
  13073. return cachedSetTimeout(fun, 0);
  13074. } catch(e){
  13075. try {
  13076. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  13077. return cachedSetTimeout.call(null, fun, 0);
  13078. } catch(e){
  13079. // 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
  13080. return cachedSetTimeout.call(this, fun, 0);
  13081. }
  13082. }
  13083. }
  13084. function runClearTimeout(marker) {
  13085. if (cachedClearTimeout === clearTimeout) {
  13086. //normal enviroments in sane situations
  13087. return clearTimeout(marker);
  13088. }
  13089. // if clearTimeout wasn't available but was latter defined
  13090. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  13091. cachedClearTimeout = clearTimeout;
  13092. return clearTimeout(marker);
  13093. }
  13094. try {
  13095. // when when somebody has screwed with setTimeout but no I.E. maddness
  13096. return cachedClearTimeout(marker);
  13097. } catch (e){
  13098. try {
  13099. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  13100. return cachedClearTimeout.call(null, marker);
  13101. } catch (e){
  13102. // 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.
  13103. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  13104. return cachedClearTimeout.call(this, marker);
  13105. }
  13106. }
  13107. }
  13108. var queue = [];
  13109. var draining = false;
  13110. var currentQueue;
  13111. var queueIndex = -1;
  13112. function cleanUpNextTick() {
  13113. if (!draining || !currentQueue) {
  13114. return;
  13115. }
  13116. draining = false;
  13117. if (currentQueue.length) {
  13118. queue = currentQueue.concat(queue);
  13119. } else {
  13120. queueIndex = -1;
  13121. }
  13122. if (queue.length) {
  13123. drainQueue();
  13124. }
  13125. }
  13126. function drainQueue() {
  13127. if (draining) {
  13128. return;
  13129. }
  13130. var timeout = runTimeout(cleanUpNextTick);
  13131. draining = true;
  13132. var len = queue.length;
  13133. while(len) {
  13134. currentQueue = queue;
  13135. queue = [];
  13136. while (++queueIndex < len) {
  13137. if (currentQueue) {
  13138. currentQueue[queueIndex].run();
  13139. }
  13140. }
  13141. queueIndex = -1;
  13142. len = queue.length;
  13143. }
  13144. currentQueue = null;
  13145. draining = false;
  13146. runClearTimeout(timeout);
  13147. }
  13148. process.nextTick = function (fun) {
  13149. var args = new Array(arguments.length - 1);
  13150. if (arguments.length > 1) {
  13151. for (var i = 1; i < arguments.length; i++) {
  13152. args[i - 1] = arguments[i];
  13153. }
  13154. }
  13155. queue.push(new Item(fun, args));
  13156. if (queue.length === 1 && !draining) {
  13157. runTimeout(drainQueue);
  13158. }
  13159. };
  13160. // v8 likes predictible objects
  13161. function Item(fun, array) {
  13162. this.fun = fun;
  13163. this.array = array;
  13164. }
  13165. Item.prototype.run = function () {
  13166. this.fun.apply(null, this.array);
  13167. };
  13168. process.title = 'browser';
  13169. process.browser = true;
  13170. process.env = {};
  13171. process.argv = [];
  13172. process.version = ''; // empty string to avoid regexp issues
  13173. process.versions = {};
  13174. function noop() {}
  13175. process.on = noop;
  13176. process.addListener = noop;
  13177. process.once = noop;
  13178. process.off = noop;
  13179. process.removeListener = noop;
  13180. process.removeAllListeners = noop;
  13181. process.emit = noop;
  13182. process.prependListener = noop;
  13183. process.prependOnceListener = noop;
  13184. process.listeners = function (name) { return [] }
  13185. process.binding = function (name) {
  13186. throw new Error('process.binding is not supported');
  13187. };
  13188. process.cwd = function () { return '/' };
  13189. process.chdir = function (dir) {
  13190. throw new Error('process.chdir is not supported');
  13191. };
  13192. process.umask = function() { return 0; };
  13193. },{}],70:[function(require,module,exports){
  13194. module.exports = require('./lib/_stream_duplex.js');
  13195. },{"./lib/_stream_duplex.js":71}],71:[function(require,module,exports){
  13196. // Copyright Joyent, Inc. and other Node contributors.
  13197. //
  13198. // Permission is hereby granted, free of charge, to any person obtaining a
  13199. // copy of this software and associated documentation files (the
  13200. // "Software"), to deal in the Software without restriction, including
  13201. // without limitation the rights to use, copy, modify, merge, publish,
  13202. // distribute, sublicense, and/or sell copies of the Software, and to permit
  13203. // persons to whom the Software is furnished to do so, subject to the
  13204. // following conditions:
  13205. //
  13206. // The above copyright notice and this permission notice shall be included
  13207. // in all copies or substantial portions of the Software.
  13208. //
  13209. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13210. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13211. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  13212. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  13213. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  13214. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  13215. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  13216. // a duplex stream is just a stream that is both readable and writable.
  13217. // Since JS doesn't have multiple prototypal inheritance, this class
  13218. // prototypally inherits from Readable, and then parasitically from
  13219. // Writable.
  13220. 'use strict';
  13221. /*<replacement>*/
  13222. var pna = require('process-nextick-args');
  13223. /*</replacement>*/
  13224. /*<replacement>*/
  13225. var objectKeys = Object.keys || function (obj) {
  13226. var keys = [];
  13227. for (var key in obj) {
  13228. keys.push(key);
  13229. }return keys;
  13230. };
  13231. /*</replacement>*/
  13232. module.exports = Duplex;
  13233. /*<replacement>*/
  13234. var util = require('core-util-is');
  13235. util.inherits = require('inherits');
  13236. /*</replacement>*/
  13237. var Readable = require('./_stream_readable');
  13238. var Writable = require('./_stream_writable');
  13239. util.inherits(Duplex, Readable);
  13240. {
  13241. // avoid scope creep, the keys array can then be collected
  13242. var keys = objectKeys(Writable.prototype);
  13243. for (var v = 0; v < keys.length; v++) {
  13244. var method = keys[v];
  13245. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  13246. }
  13247. }
  13248. function Duplex(options) {
  13249. if (!(this instanceof Duplex)) return new Duplex(options);
  13250. Readable.call(this, options);
  13251. Writable.call(this, options);
  13252. if (options && options.readable === false) this.readable = false;
  13253. if (options && options.writable === false) this.writable = false;
  13254. this.allowHalfOpen = true;
  13255. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  13256. this.once('end', onend);
  13257. }
  13258. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  13259. // making it explicit this property is not enumerable
  13260. // because otherwise some prototype manipulation in
  13261. // userland will fail
  13262. enumerable: false,
  13263. get: function () {
  13264. return this._writableState.highWaterMark;
  13265. }
  13266. });
  13267. // the no-half-open enforcer
  13268. function onend() {
  13269. // if we allow half-open state, or if the writable side ended,
  13270. // then we're ok.
  13271. if (this.allowHalfOpen || this._writableState.ended) return;
  13272. // no more data can be written.
  13273. // But allow more writes to happen in this tick.
  13274. pna.nextTick(onEndNT, this);
  13275. }
  13276. function onEndNT(self) {
  13277. self.end();
  13278. }
  13279. Object.defineProperty(Duplex.prototype, 'destroyed', {
  13280. get: function () {
  13281. if (this._readableState === undefined || this._writableState === undefined) {
  13282. return false;
  13283. }
  13284. return this._readableState.destroyed && this._writableState.destroyed;
  13285. },
  13286. set: function (value) {
  13287. // we ignore the value if the stream
  13288. // has not been initialized yet
  13289. if (this._readableState === undefined || this._writableState === undefined) {
  13290. return;
  13291. }
  13292. // backward compatibility, the user is explicitly
  13293. // managing destroyed
  13294. this._readableState.destroyed = value;
  13295. this._writableState.destroyed = value;
  13296. }
  13297. });
  13298. Duplex.prototype._destroy = function (err, cb) {
  13299. this.push(null);
  13300. this.end();
  13301. pna.nextTick(cb, err);
  13302. };
  13303. },{"./_stream_readable":73,"./_stream_writable":75,"core-util-is":44,"inherits":56,"process-nextick-args":68}],72:[function(require,module,exports){
  13304. // Copyright Joyent, Inc. and other Node contributors.
  13305. //
  13306. // Permission is hereby granted, free of charge, to any person obtaining a
  13307. // copy of this software and associated documentation files (the
  13308. // "Software"), to deal in the Software without restriction, including
  13309. // without limitation the rights to use, copy, modify, merge, publish,
  13310. // distribute, sublicense, and/or sell copies of the Software, and to permit
  13311. // persons to whom the Software is furnished to do so, subject to the
  13312. // following conditions:
  13313. //
  13314. // The above copyright notice and this permission notice shall be included
  13315. // in all copies or substantial portions of the Software.
  13316. //
  13317. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13318. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13319. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  13320. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  13321. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  13322. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  13323. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  13324. // a passthrough stream.
  13325. // basically just the most minimal sort of Transform stream.
  13326. // Every written chunk gets output as-is.
  13327. 'use strict';
  13328. module.exports = PassThrough;
  13329. var Transform = require('./_stream_transform');
  13330. /*<replacement>*/
  13331. var util = require('core-util-is');
  13332. util.inherits = require('inherits');
  13333. /*</replacement>*/
  13334. util.inherits(PassThrough, Transform);
  13335. function PassThrough(options) {
  13336. if (!(this instanceof PassThrough)) return new PassThrough(options);
  13337. Transform.call(this, options);
  13338. }
  13339. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  13340. cb(null, chunk);
  13341. };
  13342. },{"./_stream_transform":74,"core-util-is":44,"inherits":56}],73:[function(require,module,exports){
  13343. (function (process,global){
  13344. // Copyright Joyent, Inc. and other Node contributors.
  13345. //
  13346. // Permission is hereby granted, free of charge, to any person obtaining a
  13347. // copy of this software and associated documentation files (the
  13348. // "Software"), to deal in the Software without restriction, including
  13349. // without limitation the rights to use, copy, modify, merge, publish,
  13350. // distribute, sublicense, and/or sell copies of the Software, and to permit
  13351. // persons to whom the Software is furnished to do so, subject to the
  13352. // following conditions:
  13353. //
  13354. // The above copyright notice and this permission notice shall be included
  13355. // in all copies or substantial portions of the Software.
  13356. //
  13357. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13358. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13359. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  13360. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  13361. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  13362. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  13363. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  13364. 'use strict';
  13365. /*<replacement>*/
  13366. var pna = require('process-nextick-args');
  13367. /*</replacement>*/
  13368. module.exports = Readable;
  13369. /*<replacement>*/
  13370. var isArray = require('isarray');
  13371. /*</replacement>*/
  13372. /*<replacement>*/
  13373. var Duplex;
  13374. /*</replacement>*/
  13375. Readable.ReadableState = ReadableState;
  13376. /*<replacement>*/
  13377. var EE = require('events').EventEmitter;
  13378. var EElistenerCount = function (emitter, type) {
  13379. return emitter.listeners(type).length;
  13380. };
  13381. /*</replacement>*/
  13382. /*<replacement>*/
  13383. var Stream = require('./internal/streams/stream');
  13384. /*</replacement>*/
  13385. /*<replacement>*/
  13386. var Buffer = require('safe-buffer').Buffer;
  13387. var OurUint8Array = global.Uint8Array || function () {};
  13388. function _uint8ArrayToBuffer(chunk) {
  13389. return Buffer.from(chunk);
  13390. }
  13391. function _isUint8Array(obj) {
  13392. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  13393. }
  13394. /*</replacement>*/
  13395. /*<replacement>*/
  13396. var util = require('core-util-is');
  13397. util.inherits = require('inherits');
  13398. /*</replacement>*/
  13399. /*<replacement>*/
  13400. var debugUtil = require('util');
  13401. var debug = void 0;
  13402. if (debugUtil && debugUtil.debuglog) {
  13403. debug = debugUtil.debuglog('stream');
  13404. } else {
  13405. debug = function () {};
  13406. }
  13407. /*</replacement>*/
  13408. var BufferList = require('./internal/streams/BufferList');
  13409. var destroyImpl = require('./internal/streams/destroy');
  13410. var StringDecoder;
  13411. util.inherits(Readable, Stream);
  13412. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  13413. function prependListener(emitter, event, fn) {
  13414. // Sadly this is not cacheable as some libraries bundle their own
  13415. // event emitter implementation with them.
  13416. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
  13417. // This is a hack to make sure that our error handler is attached before any
  13418. // userland ones. NEVER DO THIS. This is here only because this code needs
  13419. // to continue to work with older versions of Node.js that do not include
  13420. // the prependListener() method. The goal is to eventually remove this hack.
  13421. 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]];
  13422. }
  13423. function ReadableState(options, stream) {
  13424. Duplex = Duplex || require('./_stream_duplex');
  13425. options = options || {};
  13426. // Duplex streams are both readable and writable, but share
  13427. // the same options object.
  13428. // However, some cases require setting options to different
  13429. // values for the readable and the writable sides of the duplex stream.
  13430. // These options can be provided separately as readableXXX and writableXXX.
  13431. var isDuplex = stream instanceof Duplex;
  13432. // object stream flag. Used to make read(n) ignore n and to
  13433. // make all the buffer merging and length checks go away
  13434. this.objectMode = !!options.objectMode;
  13435. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  13436. // the point at which it stops calling _read() to fill the buffer
  13437. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  13438. var hwm = options.highWaterMark;
  13439. var readableHwm = options.readableHighWaterMark;
  13440. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  13441. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
  13442. // cast to ints.
  13443. this.highWaterMark = Math.floor(this.highWaterMark);
  13444. // A linked list is used to store data chunks instead of an array because the
  13445. // linked list can remove elements from the beginning faster than
  13446. // array.shift()
  13447. this.buffer = new BufferList();
  13448. this.length = 0;
  13449. this.pipes = null;
  13450. this.pipesCount = 0;
  13451. this.flowing = null;
  13452. this.ended = false;
  13453. this.endEmitted = false;
  13454. this.reading = false;
  13455. // a flag to be able to tell if the event 'readable'/'data' is emitted
  13456. // immediately, or on a later tick. We set this to true at first, because
  13457. // any actions that shouldn't happen until "later" should generally also
  13458. // not happen before the first read call.
  13459. this.sync = true;
  13460. // whenever we return null, then we set a flag to say
  13461. // that we're awaiting a 'readable' event emission.
  13462. this.needReadable = false;
  13463. this.emittedReadable = false;
  13464. this.readableListening = false;
  13465. this.resumeScheduled = false;
  13466. // has it been destroyed
  13467. this.destroyed = false;
  13468. // Crypto is kind of old and crusty. Historically, its default string
  13469. // encoding is 'binary' so we have to make this configurable.
  13470. // Everything else in the universe uses 'utf8', though.
  13471. this.defaultEncoding = options.defaultEncoding || 'utf8';
  13472. // the number of writers that are awaiting a drain event in .pipe()s
  13473. this.awaitDrain = 0;
  13474. // if true, a maybeReadMore has been scheduled
  13475. this.readingMore = false;
  13476. this.decoder = null;
  13477. this.encoding = null;
  13478. if (options.encoding) {
  13479. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  13480. this.decoder = new StringDecoder(options.encoding);
  13481. this.encoding = options.encoding;
  13482. }
  13483. }
  13484. function Readable(options) {
  13485. Duplex = Duplex || require('./_stream_duplex');
  13486. if (!(this instanceof Readable)) return new Readable(options);
  13487. this._readableState = new ReadableState(options, this);
  13488. // legacy
  13489. this.readable = true;
  13490. if (options) {
  13491. if (typeof options.read === 'function') this._read = options.read;
  13492. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  13493. }
  13494. Stream.call(this);
  13495. }
  13496. Object.defineProperty(Readable.prototype, 'destroyed', {
  13497. get: function () {
  13498. if (this._readableState === undefined) {
  13499. return false;
  13500. }
  13501. return this._readableState.destroyed;
  13502. },
  13503. set: function (value) {
  13504. // we ignore the value if the stream
  13505. // has not been initialized yet
  13506. if (!this._readableState) {
  13507. return;
  13508. }
  13509. // backward compatibility, the user is explicitly
  13510. // managing destroyed
  13511. this._readableState.destroyed = value;
  13512. }
  13513. });
  13514. Readable.prototype.destroy = destroyImpl.destroy;
  13515. Readable.prototype._undestroy = destroyImpl.undestroy;
  13516. Readable.prototype._destroy = function (err, cb) {
  13517. this.push(null);
  13518. cb(err);
  13519. };
  13520. // Manually shove something into the read() buffer.
  13521. // This returns true if the highWaterMark has not been hit yet,
  13522. // similar to how Writable.write() returns true if you should
  13523. // write() some more.
  13524. Readable.prototype.push = function (chunk, encoding) {
  13525. var state = this._readableState;
  13526. var skipChunkCheck;
  13527. if (!state.objectMode) {
  13528. if (typeof chunk === 'string') {
  13529. encoding = encoding || state.defaultEncoding;
  13530. if (encoding !== state.encoding) {
  13531. chunk = Buffer.from(chunk, encoding);
  13532. encoding = '';
  13533. }
  13534. skipChunkCheck = true;
  13535. }
  13536. } else {
  13537. skipChunkCheck = true;
  13538. }
  13539. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  13540. };
  13541. // Unshift should *always* be something directly out of read()
  13542. Readable.prototype.unshift = function (chunk) {
  13543. return readableAddChunk(this, chunk, null, true, false);
  13544. };
  13545. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  13546. var state = stream._readableState;
  13547. if (chunk === null) {
  13548. state.reading = false;
  13549. onEofChunk(stream, state);
  13550. } else {
  13551. var er;
  13552. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  13553. if (er) {
  13554. stream.emit('error', er);
  13555. } else if (state.objectMode || chunk && chunk.length > 0) {
  13556. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  13557. chunk = _uint8ArrayToBuffer(chunk);
  13558. }
  13559. if (addToFront) {
  13560. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
  13561. } else if (state.ended) {
  13562. stream.emit('error', new Error('stream.push() after EOF'));
  13563. } else {
  13564. state.reading = false;
  13565. if (state.decoder && !encoding) {
  13566. chunk = state.decoder.write(chunk);
  13567. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  13568. } else {
  13569. addChunk(stream, state, chunk, false);
  13570. }
  13571. }
  13572. } else if (!addToFront) {
  13573. state.reading = false;
  13574. }
  13575. }
  13576. return needMoreData(state);
  13577. }
  13578. function addChunk(stream, state, chunk, addToFront) {
  13579. if (state.flowing && state.length === 0 && !state.sync) {
  13580. stream.emit('data', chunk);
  13581. stream.read(0);
  13582. } else {
  13583. // update the buffer info.
  13584. state.length += state.objectMode ? 1 : chunk.length;
  13585. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  13586. if (state.needReadable) emitReadable(stream);
  13587. }
  13588. maybeReadMore(stream, state);
  13589. }
  13590. function chunkInvalid(state, chunk) {
  13591. var er;
  13592. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  13593. er = new TypeError('Invalid non-string/buffer chunk');
  13594. }
  13595. return er;
  13596. }
  13597. // if it's past the high water mark, we can push in some more.
  13598. // Also, if we have no data yet, we can stand some
  13599. // more bytes. This is to work around cases where hwm=0,
  13600. // such as the repl. Also, if the push() triggered a
  13601. // readable event, and the user called read(largeNumber) such that
  13602. // needReadable was set, then we ought to push more, so that another
  13603. // 'readable' event will be triggered.
  13604. function needMoreData(state) {
  13605. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  13606. }
  13607. Readable.prototype.isPaused = function () {
  13608. return this._readableState.flowing === false;
  13609. };
  13610. // backwards compatibility.
  13611. Readable.prototype.setEncoding = function (enc) {
  13612. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  13613. this._readableState.decoder = new StringDecoder(enc);
  13614. this._readableState.encoding = enc;
  13615. return this;
  13616. };
  13617. // Don't raise the hwm > 8MB
  13618. var MAX_HWM = 0x800000;
  13619. function computeNewHighWaterMark(n) {
  13620. if (n >= MAX_HWM) {
  13621. n = MAX_HWM;
  13622. } else {
  13623. // Get the next highest power of 2 to prevent increasing hwm excessively in
  13624. // tiny amounts
  13625. n--;
  13626. n |= n >>> 1;
  13627. n |= n >>> 2;
  13628. n |= n >>> 4;
  13629. n |= n >>> 8;
  13630. n |= n >>> 16;
  13631. n++;
  13632. }
  13633. return n;
  13634. }
  13635. // This function is designed to be inlinable, so please take care when making
  13636. // changes to the function body.
  13637. function howMuchToRead(n, state) {
  13638. if (n <= 0 || state.length === 0 && state.ended) return 0;
  13639. if (state.objectMode) return 1;
  13640. if (n !== n) {
  13641. // Only flow one buffer at a time
  13642. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  13643. }
  13644. // If we're asking for more than the current hwm, then raise the hwm.
  13645. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  13646. if (n <= state.length) return n;
  13647. // Don't have enough
  13648. if (!state.ended) {
  13649. state.needReadable = true;
  13650. return 0;
  13651. }
  13652. return state.length;
  13653. }
  13654. // you can override either this method, or the async _read(n) below.
  13655. Readable.prototype.read = function (n) {
  13656. debug('read', n);
  13657. n = parseInt(n, 10);
  13658. var state = this._readableState;
  13659. var nOrig = n;
  13660. if (n !== 0) state.emittedReadable = false;
  13661. // if we're doing read(0) to trigger a readable event, but we
  13662. // already have a bunch of data in the buffer, then just trigger
  13663. // the 'readable' event and move on.
  13664. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  13665. debug('read: emitReadable', state.length, state.ended);
  13666. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  13667. return null;
  13668. }
  13669. n = howMuchToRead(n, state);
  13670. // if we've ended, and we're now clear, then finish it up.
  13671. if (n === 0 && state.ended) {
  13672. if (state.length === 0) endReadable(this);
  13673. return null;
  13674. }
  13675. // All the actual chunk generation logic needs to be
  13676. // *below* the call to _read. The reason is that in certain
  13677. // synthetic stream cases, such as passthrough streams, _read
  13678. // may be a completely synchronous operation which may change
  13679. // the state of the read buffer, providing enough data when
  13680. // before there was *not* enough.
  13681. //
  13682. // So, the steps are:
  13683. // 1. Figure out what the state of things will be after we do
  13684. // a read from the buffer.
  13685. //
  13686. // 2. If that resulting state will trigger a _read, then call _read.
  13687. // Note that this may be asynchronous, or synchronous. Yes, it is
  13688. // deeply ugly to write APIs this way, but that still doesn't mean
  13689. // that the Readable class should behave improperly, as streams are
  13690. // designed to be sync/async agnostic.
  13691. // Take note if the _read call is sync or async (ie, if the read call
  13692. // has returned yet), so that we know whether or not it's safe to emit
  13693. // 'readable' etc.
  13694. //
  13695. // 3. Actually pull the requested chunks out of the buffer and return.
  13696. // if we need a readable event, then we need to do some reading.
  13697. var doRead = state.needReadable;
  13698. debug('need readable', doRead);
  13699. // if we currently have less than the highWaterMark, then also read some
  13700. if (state.length === 0 || state.length - n < state.highWaterMark) {
  13701. doRead = true;
  13702. debug('length less than watermark', doRead);
  13703. }
  13704. // however, if we've ended, then there's no point, and if we're already
  13705. // reading, then it's unnecessary.
  13706. if (state.ended || state.reading) {
  13707. doRead = false;
  13708. debug('reading or ended', doRead);
  13709. } else if (doRead) {
  13710. debug('do read');
  13711. state.reading = true;
  13712. state.sync = true;
  13713. // if the length is currently zero, then we *need* a readable event.
  13714. if (state.length === 0) state.needReadable = true;
  13715. // call internal read method
  13716. this._read(state.highWaterMark);
  13717. state.sync = false;
  13718. // If _read pushed data synchronously, then `reading` will be false,
  13719. // and we need to re-evaluate how much data we can return to the user.
  13720. if (!state.reading) n = howMuchToRead(nOrig, state);
  13721. }
  13722. var ret;
  13723. if (n > 0) ret = fromList(n, state);else ret = null;
  13724. if (ret === null) {
  13725. state.needReadable = true;
  13726. n = 0;
  13727. } else {
  13728. state.length -= n;
  13729. }
  13730. if (state.length === 0) {
  13731. // If we have nothing in the buffer, then we want to know
  13732. // as soon as we *do* get something into the buffer.
  13733. if (!state.ended) state.needReadable = true;
  13734. // If we tried to read() past the EOF, then emit end on the next tick.
  13735. if (nOrig !== n && state.ended) endReadable(this);
  13736. }
  13737. if (ret !== null) this.emit('data', ret);
  13738. return ret;
  13739. };
  13740. function onEofChunk(stream, state) {
  13741. if (state.ended) return;
  13742. if (state.decoder) {
  13743. var chunk = state.decoder.end();
  13744. if (chunk && chunk.length) {
  13745. state.buffer.push(chunk);
  13746. state.length += state.objectMode ? 1 : chunk.length;
  13747. }
  13748. }
  13749. state.ended = true;
  13750. // emit 'readable' now to make sure it gets picked up.
  13751. emitReadable(stream);
  13752. }
  13753. // Don't emit readable right away in sync mode, because this can trigger
  13754. // another read() call => stack overflow. This way, it might trigger
  13755. // a nextTick recursion warning, but that's not so bad.
  13756. function emitReadable(stream) {
  13757. var state = stream._readableState;
  13758. state.needReadable = false;
  13759. if (!state.emittedReadable) {
  13760. debug('emitReadable', state.flowing);
  13761. state.emittedReadable = true;
  13762. if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
  13763. }
  13764. }
  13765. function emitReadable_(stream) {
  13766. debug('emit readable');
  13767. stream.emit('readable');
  13768. flow(stream);
  13769. }
  13770. // at this point, the user has presumably seen the 'readable' event,
  13771. // and called read() to consume some data. that may have triggered
  13772. // in turn another _read(n) call, in which case reading = true if
  13773. // it's in progress.
  13774. // However, if we're not ended, or reading, and the length < hwm,
  13775. // then go ahead and try to read some more preemptively.
  13776. function maybeReadMore(stream, state) {
  13777. if (!state.readingMore) {
  13778. state.readingMore = true;
  13779. pna.nextTick(maybeReadMore_, stream, state);
  13780. }
  13781. }
  13782. function maybeReadMore_(stream, state) {
  13783. var len = state.length;
  13784. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  13785. debug('maybeReadMore read 0');
  13786. stream.read(0);
  13787. if (len === state.length)
  13788. // didn't get any data, stop spinning.
  13789. break;else len = state.length;
  13790. }
  13791. state.readingMore = false;
  13792. }
  13793. // abstract method. to be overridden in specific implementation classes.
  13794. // call cb(er, data) where data is <= n in length.
  13795. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  13796. // arbitrary, and perhaps not very meaningful.
  13797. Readable.prototype._read = function (n) {
  13798. this.emit('error', new Error('_read() is not implemented'));
  13799. };
  13800. Readable.prototype.pipe = function (dest, pipeOpts) {
  13801. var src = this;
  13802. var state = this._readableState;
  13803. switch (state.pipesCount) {
  13804. case 0:
  13805. state.pipes = dest;
  13806. break;
  13807. case 1:
  13808. state.pipes = [state.pipes, dest];
  13809. break;
  13810. default:
  13811. state.pipes.push(dest);
  13812. break;
  13813. }
  13814. state.pipesCount += 1;
  13815. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  13816. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  13817. var endFn = doEnd ? onend : unpipe;
  13818. if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
  13819. dest.on('unpipe', onunpipe);
  13820. function onunpipe(readable, unpipeInfo) {
  13821. debug('onunpipe');
  13822. if (readable === src) {
  13823. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  13824. unpipeInfo.hasUnpiped = true;
  13825. cleanup();
  13826. }
  13827. }
  13828. }
  13829. function onend() {
  13830. debug('onend');
  13831. dest.end();
  13832. }
  13833. // when the dest drains, it reduces the awaitDrain counter
  13834. // on the source. This would be more elegant with a .once()
  13835. // handler in flow(), but adding and removing repeatedly is
  13836. // too slow.
  13837. var ondrain = pipeOnDrain(src);
  13838. dest.on('drain', ondrain);
  13839. var cleanedUp = false;
  13840. function cleanup() {
  13841. debug('cleanup');
  13842. // cleanup event handlers once the pipe is broken
  13843. dest.removeListener('close', onclose);
  13844. dest.removeListener('finish', onfinish);
  13845. dest.removeListener('drain', ondrain);
  13846. dest.removeListener('error', onerror);
  13847. dest.removeListener('unpipe', onunpipe);
  13848. src.removeListener('end', onend);
  13849. src.removeListener('end', unpipe);
  13850. src.removeListener('data', ondata);
  13851. cleanedUp = true;
  13852. // if the reader is waiting for a drain event from this
  13853. // specific writer, then it would cause it to never start
  13854. // flowing again.
  13855. // So, if this is awaiting a drain, then we just call it now.
  13856. // If we don't know, then assume that we are waiting for one.
  13857. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  13858. }
  13859. // If the user pushes more data while we're writing to dest then we'll end up
  13860. // in ondata again. However, we only want to increase awaitDrain once because
  13861. // dest will only emit one 'drain' event for the multiple writes.
  13862. // => Introduce a guard on increasing awaitDrain.
  13863. var increasedAwaitDrain = false;
  13864. src.on('data', ondata);
  13865. function ondata(chunk) {
  13866. debug('ondata');
  13867. increasedAwaitDrain = false;
  13868. var ret = dest.write(chunk);
  13869. if (false === ret && !increasedAwaitDrain) {
  13870. // If the user unpiped during `dest.write()`, it is possible
  13871. // to get stuck in a permanently paused state if that write
  13872. // also returned false.
  13873. // => Check whether `dest` is still a piping destination.
  13874. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  13875. debug('false write response, pause', src._readableState.awaitDrain);
  13876. src._readableState.awaitDrain++;
  13877. increasedAwaitDrain = true;
  13878. }
  13879. src.pause();
  13880. }
  13881. }
  13882. // if the dest has an error, then stop piping into it.
  13883. // however, don't suppress the throwing behavior for this.
  13884. function onerror(er) {
  13885. debug('onerror', er);
  13886. unpipe();
  13887. dest.removeListener('error', onerror);
  13888. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  13889. }
  13890. // Make sure our error handler is attached before userland ones.
  13891. prependListener(dest, 'error', onerror);
  13892. // Both close and finish should trigger unpipe, but only once.
  13893. function onclose() {
  13894. dest.removeListener('finish', onfinish);
  13895. unpipe();
  13896. }
  13897. dest.once('close', onclose);
  13898. function onfinish() {
  13899. debug('onfinish');
  13900. dest.removeListener('close', onclose);
  13901. unpipe();
  13902. }
  13903. dest.once('finish', onfinish);
  13904. function unpipe() {
  13905. debug('unpipe');
  13906. src.unpipe(dest);
  13907. }
  13908. // tell the dest that it's being piped to
  13909. dest.emit('pipe', src);
  13910. // start the flow if it hasn't been started already.
  13911. if (!state.flowing) {
  13912. debug('pipe resume');
  13913. src.resume();
  13914. }
  13915. return dest;
  13916. };
  13917. function pipeOnDrain(src) {
  13918. return function () {
  13919. var state = src._readableState;
  13920. debug('pipeOnDrain', state.awaitDrain);
  13921. if (state.awaitDrain) state.awaitDrain--;
  13922. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  13923. state.flowing = true;
  13924. flow(src);
  13925. }
  13926. };
  13927. }
  13928. Readable.prototype.unpipe = function (dest) {
  13929. var state = this._readableState;
  13930. var unpipeInfo = { hasUnpiped: false };
  13931. // if we're not piping anywhere, then do nothing.
  13932. if (state.pipesCount === 0) return this;
  13933. // just one destination. most common case.
  13934. if (state.pipesCount === 1) {
  13935. // passed in one, but it's not the right one.
  13936. if (dest && dest !== state.pipes) return this;
  13937. if (!dest) dest = state.pipes;
  13938. // got a match.
  13939. state.pipes = null;
  13940. state.pipesCount = 0;
  13941. state.flowing = false;
  13942. if (dest) dest.emit('unpipe', this, unpipeInfo);
  13943. return this;
  13944. }
  13945. // slow case. multiple pipe destinations.
  13946. if (!dest) {
  13947. // remove all.
  13948. var dests = state.pipes;
  13949. var len = state.pipesCount;
  13950. state.pipes = null;
  13951. state.pipesCount = 0;
  13952. state.flowing = false;
  13953. for (var i = 0; i < len; i++) {
  13954. dests[i].emit('unpipe', this, unpipeInfo);
  13955. }return this;
  13956. }
  13957. // try to find the right one.
  13958. var index = indexOf(state.pipes, dest);
  13959. if (index === -1) return this;
  13960. state.pipes.splice(index, 1);
  13961. state.pipesCount -= 1;
  13962. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  13963. dest.emit('unpipe', this, unpipeInfo);
  13964. return this;
  13965. };
  13966. // set up data events if they are asked for
  13967. // Ensure readable listeners eventually get something
  13968. Readable.prototype.on = function (ev, fn) {
  13969. var res = Stream.prototype.on.call(this, ev, fn);
  13970. if (ev === 'data') {
  13971. // Start flowing on next tick if stream isn't explicitly paused
  13972. if (this._readableState.flowing !== false) this.resume();
  13973. } else if (ev === 'readable') {
  13974. var state = this._readableState;
  13975. if (!state.endEmitted && !state.readableListening) {
  13976. state.readableListening = state.needReadable = true;
  13977. state.emittedReadable = false;
  13978. if (!state.reading) {
  13979. pna.nextTick(nReadingNextTick, this);
  13980. } else if (state.length) {
  13981. emitReadable(this);
  13982. }
  13983. }
  13984. }
  13985. return res;
  13986. };
  13987. Readable.prototype.addListener = Readable.prototype.on;
  13988. function nReadingNextTick(self) {
  13989. debug('readable nexttick read 0');
  13990. self.read(0);
  13991. }
  13992. // pause() and resume() are remnants of the legacy readable stream API
  13993. // If the user uses them, then switch into old mode.
  13994. Readable.prototype.resume = function () {
  13995. var state = this._readableState;
  13996. if (!state.flowing) {
  13997. debug('resume');
  13998. state.flowing = true;
  13999. resume(this, state);
  14000. }
  14001. return this;
  14002. };
  14003. function resume(stream, state) {
  14004. if (!state.resumeScheduled) {
  14005. state.resumeScheduled = true;
  14006. pna.nextTick(resume_, stream, state);
  14007. }
  14008. }
  14009. function resume_(stream, state) {
  14010. if (!state.reading) {
  14011. debug('resume read 0');
  14012. stream.read(0);
  14013. }
  14014. state.resumeScheduled = false;
  14015. state.awaitDrain = 0;
  14016. stream.emit('resume');
  14017. flow(stream);
  14018. if (state.flowing && !state.reading) stream.read(0);
  14019. }
  14020. Readable.prototype.pause = function () {
  14021. debug('call pause flowing=%j', this._readableState.flowing);
  14022. if (false !== this._readableState.flowing) {
  14023. debug('pause');
  14024. this._readableState.flowing = false;
  14025. this.emit('pause');
  14026. }
  14027. return this;
  14028. };
  14029. function flow(stream) {
  14030. var state = stream._readableState;
  14031. debug('flow', state.flowing);
  14032. while (state.flowing && stream.read() !== null) {}
  14033. }
  14034. // wrap an old-style stream as the async data source.
  14035. // This is *not* part of the readable stream interface.
  14036. // It is an ugly unfortunate mess of history.
  14037. Readable.prototype.wrap = function (stream) {
  14038. var _this = this;
  14039. var state = this._readableState;
  14040. var paused = false;
  14041. stream.on('end', function () {
  14042. debug('wrapped end');
  14043. if (state.decoder && !state.ended) {
  14044. var chunk = state.decoder.end();
  14045. if (chunk && chunk.length) _this.push(chunk);
  14046. }
  14047. _this.push(null);
  14048. });
  14049. stream.on('data', function (chunk) {
  14050. debug('wrapped data');
  14051. if (state.decoder) chunk = state.decoder.write(chunk);
  14052. // don't skip over falsy values in objectMode
  14053. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  14054. var ret = _this.push(chunk);
  14055. if (!ret) {
  14056. paused = true;
  14057. stream.pause();
  14058. }
  14059. });
  14060. // proxy all the other methods.
  14061. // important when wrapping filters and duplexes.
  14062. for (var i in stream) {
  14063. if (this[i] === undefined && typeof stream[i] === 'function') {
  14064. this[i] = function (method) {
  14065. return function () {
  14066. return stream[method].apply(stream, arguments);
  14067. };
  14068. }(i);
  14069. }
  14070. }
  14071. // proxy certain important events.
  14072. for (var n = 0; n < kProxyEvents.length; n++) {
  14073. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  14074. }
  14075. // when we try to consume some more bytes, simply unpause the
  14076. // underlying stream.
  14077. this._read = function (n) {
  14078. debug('wrapped _read', n);
  14079. if (paused) {
  14080. paused = false;
  14081. stream.resume();
  14082. }
  14083. };
  14084. return this;
  14085. };
  14086. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  14087. // making it explicit this property is not enumerable
  14088. // because otherwise some prototype manipulation in
  14089. // userland will fail
  14090. enumerable: false,
  14091. get: function () {
  14092. return this._readableState.highWaterMark;
  14093. }
  14094. });
  14095. // exposed for testing purposes only.
  14096. Readable._fromList = fromList;
  14097. // Pluck off n bytes from an array of buffers.
  14098. // Length is the combined lengths of all the buffers in the list.
  14099. // This function is designed to be inlinable, so please take care when making
  14100. // changes to the function body.
  14101. function fromList(n, state) {
  14102. // nothing buffered
  14103. if (state.length === 0) return null;
  14104. var ret;
  14105. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  14106. // read it all, truncate the list
  14107. 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);
  14108. state.buffer.clear();
  14109. } else {
  14110. // read part of list
  14111. ret = fromListPartial(n, state.buffer, state.decoder);
  14112. }
  14113. return ret;
  14114. }
  14115. // Extracts only enough buffered data to satisfy the amount requested.
  14116. // This function is designed to be inlinable, so please take care when making
  14117. // changes to the function body.
  14118. function fromListPartial(n, list, hasStrings) {
  14119. var ret;
  14120. if (n < list.head.data.length) {
  14121. // slice is the same for buffers and strings
  14122. ret = list.head.data.slice(0, n);
  14123. list.head.data = list.head.data.slice(n);
  14124. } else if (n === list.head.data.length) {
  14125. // first chunk is a perfect match
  14126. ret = list.shift();
  14127. } else {
  14128. // result spans more than one buffer
  14129. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  14130. }
  14131. return ret;
  14132. }
  14133. // Copies a specified amount of characters from the list of buffered data
  14134. // chunks.
  14135. // This function is designed to be inlinable, so please take care when making
  14136. // changes to the function body.
  14137. function copyFromBufferString(n, list) {
  14138. var p = list.head;
  14139. var c = 1;
  14140. var ret = p.data;
  14141. n -= ret.length;
  14142. while (p = p.next) {
  14143. var str = p.data;
  14144. var nb = n > str.length ? str.length : n;
  14145. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  14146. n -= nb;
  14147. if (n === 0) {
  14148. if (nb === str.length) {
  14149. ++c;
  14150. if (p.next) list.head = p.next;else list.head = list.tail = null;
  14151. } else {
  14152. list.head = p;
  14153. p.data = str.slice(nb);
  14154. }
  14155. break;
  14156. }
  14157. ++c;
  14158. }
  14159. list.length -= c;
  14160. return ret;
  14161. }
  14162. // Copies a specified amount of bytes from the list of buffered data chunks.
  14163. // This function is designed to be inlinable, so please take care when making
  14164. // changes to the function body.
  14165. function copyFromBuffer(n, list) {
  14166. var ret = Buffer.allocUnsafe(n);
  14167. var p = list.head;
  14168. var c = 1;
  14169. p.data.copy(ret);
  14170. n -= p.data.length;
  14171. while (p = p.next) {
  14172. var buf = p.data;
  14173. var nb = n > buf.length ? buf.length : n;
  14174. buf.copy(ret, ret.length - n, 0, nb);
  14175. n -= nb;
  14176. if (n === 0) {
  14177. if (nb === buf.length) {
  14178. ++c;
  14179. if (p.next) list.head = p.next;else list.head = list.tail = null;
  14180. } else {
  14181. list.head = p;
  14182. p.data = buf.slice(nb);
  14183. }
  14184. break;
  14185. }
  14186. ++c;
  14187. }
  14188. list.length -= c;
  14189. return ret;
  14190. }
  14191. function endReadable(stream) {
  14192. var state = stream._readableState;
  14193. // If we get here before consuming all the bytes, then that is a
  14194. // bug in node. Should never happen.
  14195. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  14196. if (!state.endEmitted) {
  14197. state.ended = true;
  14198. pna.nextTick(endReadableNT, state, stream);
  14199. }
  14200. }
  14201. function endReadableNT(state, stream) {
  14202. // Check that we didn't get one last unshift.
  14203. if (!state.endEmitted && state.length === 0) {
  14204. state.endEmitted = true;
  14205. stream.readable = false;
  14206. stream.emit('end');
  14207. }
  14208. }
  14209. function indexOf(xs, x) {
  14210. for (var i = 0, l = xs.length; i < l; i++) {
  14211. if (xs[i] === x) return i;
  14212. }
  14213. return -1;
  14214. }
  14215. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  14216. },{"./_stream_duplex":71,"./internal/streams/BufferList":76,"./internal/streams/destroy":77,"./internal/streams/stream":78,"_process":69,"core-util-is":44,"events":50,"inherits":56,"isarray":58,"process-nextick-args":68,"safe-buffer":83,"string_decoder/":85,"util":40}],74:[function(require,module,exports){
  14217. // Copyright Joyent, Inc. and other Node contributors.
  14218. //
  14219. // Permission is hereby granted, free of charge, to any person obtaining a
  14220. // copy of this software and associated documentation files (the
  14221. // "Software"), to deal in the Software without restriction, including
  14222. // without limitation the rights to use, copy, modify, merge, publish,
  14223. // distribute, sublicense, and/or sell copies of the Software, and to permit
  14224. // persons to whom the Software is furnished to do so, subject to the
  14225. // following conditions:
  14226. //
  14227. // The above copyright notice and this permission notice shall be included
  14228. // in all copies or substantial portions of the Software.
  14229. //
  14230. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14231. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14232. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  14233. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14234. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  14235. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  14236. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  14237. // a transform stream is a readable/writable stream where you do
  14238. // something with the data. Sometimes it's called a "filter",
  14239. // but that's not a great name for it, since that implies a thing where
  14240. // some bits pass through, and others are simply ignored. (That would
  14241. // be a valid example of a transform, of course.)
  14242. //
  14243. // While the output is causally related to the input, it's not a
  14244. // necessarily symmetric or synchronous transformation. For example,
  14245. // a zlib stream might take multiple plain-text writes(), and then
  14246. // emit a single compressed chunk some time in the future.
  14247. //
  14248. // Here's how this works:
  14249. //
  14250. // The Transform stream has all the aspects of the readable and writable
  14251. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  14252. // internally, and returns false if there's a lot of pending writes
  14253. // buffered up. When you call read(), that calls _read(n) until
  14254. // there's enough pending readable data buffered up.
  14255. //
  14256. // In a transform stream, the written data is placed in a buffer. When
  14257. // _read(n) is called, it transforms the queued up data, calling the
  14258. // buffered _write cb's as it consumes chunks. If consuming a single
  14259. // written chunk would result in multiple output chunks, then the first
  14260. // outputted bit calls the readcb, and subsequent chunks just go into
  14261. // the read buffer, and will cause it to emit 'readable' if necessary.
  14262. //
  14263. // This way, back-pressure is actually determined by the reading side,
  14264. // since _read has to be called to start processing a new chunk. However,
  14265. // a pathological inflate type of transform can cause excessive buffering
  14266. // here. For example, imagine a stream where every byte of input is
  14267. // interpreted as an integer from 0-255, and then results in that many
  14268. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  14269. // 1kb of data being output. In this case, you could write a very small
  14270. // amount of input, and end up with a very large amount of output. In
  14271. // such a pathological inflating mechanism, there'd be no way to tell
  14272. // the system to stop doing the transform. A single 4MB write could
  14273. // cause the system to run out of memory.
  14274. //
  14275. // However, even in such a pathological case, only a single written chunk
  14276. // would be consumed, and then the rest would wait (un-transformed) until
  14277. // the results of the previous transformed chunk were consumed.
  14278. 'use strict';
  14279. module.exports = Transform;
  14280. var Duplex = require('./_stream_duplex');
  14281. /*<replacement>*/
  14282. var util = require('core-util-is');
  14283. util.inherits = require('inherits');
  14284. /*</replacement>*/
  14285. util.inherits(Transform, Duplex);
  14286. function afterTransform(er, data) {
  14287. var ts = this._transformState;
  14288. ts.transforming = false;
  14289. var cb = ts.writecb;
  14290. if (!cb) {
  14291. return this.emit('error', new Error('write callback called multiple times'));
  14292. }
  14293. ts.writechunk = null;
  14294. ts.writecb = null;
  14295. if (data != null) // single equals check for both `null` and `undefined`
  14296. this.push(data);
  14297. cb(er);
  14298. var rs = this._readableState;
  14299. rs.reading = false;
  14300. if (rs.needReadable || rs.length < rs.highWaterMark) {
  14301. this._read(rs.highWaterMark);
  14302. }
  14303. }
  14304. function Transform(options) {
  14305. if (!(this instanceof Transform)) return new Transform(options);
  14306. Duplex.call(this, options);
  14307. this._transformState = {
  14308. afterTransform: afterTransform.bind(this),
  14309. needTransform: false,
  14310. transforming: false,
  14311. writecb: null,
  14312. writechunk: null,
  14313. writeencoding: null
  14314. };
  14315. // start out asking for a readable event once data is transformed.
  14316. this._readableState.needReadable = true;
  14317. // we have implemented the _read method, and done the other things
  14318. // that Readable wants before the first _read call, so unset the
  14319. // sync guard flag.
  14320. this._readableState.sync = false;
  14321. if (options) {
  14322. if (typeof options.transform === 'function') this._transform = options.transform;
  14323. if (typeof options.flush === 'function') this._flush = options.flush;
  14324. }
  14325. // When the writable side finishes, then flush out anything remaining.
  14326. this.on('prefinish', prefinish);
  14327. }
  14328. function prefinish() {
  14329. var _this = this;
  14330. if (typeof this._flush === 'function') {
  14331. this._flush(function (er, data) {
  14332. done(_this, er, data);
  14333. });
  14334. } else {
  14335. done(this, null, null);
  14336. }
  14337. }
  14338. Transform.prototype.push = function (chunk, encoding) {
  14339. this._transformState.needTransform = false;
  14340. return Duplex.prototype.push.call(this, chunk, encoding);
  14341. };
  14342. // This is the part where you do stuff!
  14343. // override this function in implementation classes.
  14344. // 'chunk' is an input chunk.
  14345. //
  14346. // Call `push(newChunk)` to pass along transformed output
  14347. // to the readable side. You may call 'push' zero or more times.
  14348. //
  14349. // Call `cb(err)` when you are done with this chunk. If you pass
  14350. // an error, then that'll put the hurt on the whole operation. If you
  14351. // never call cb(), then you'll never get another chunk.
  14352. Transform.prototype._transform = function (chunk, encoding, cb) {
  14353. throw new Error('_transform() is not implemented');
  14354. };
  14355. Transform.prototype._write = function (chunk, encoding, cb) {
  14356. var ts = this._transformState;
  14357. ts.writecb = cb;
  14358. ts.writechunk = chunk;
  14359. ts.writeencoding = encoding;
  14360. if (!ts.transforming) {
  14361. var rs = this._readableState;
  14362. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  14363. }
  14364. };
  14365. // Doesn't matter what the args are here.
  14366. // _transform does all the work.
  14367. // That we got here means that the readable side wants more data.
  14368. Transform.prototype._read = function (n) {
  14369. var ts = this._transformState;
  14370. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  14371. ts.transforming = true;
  14372. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  14373. } else {
  14374. // mark that we need a transform, so that any data that comes in
  14375. // will get processed, now that we've asked for it.
  14376. ts.needTransform = true;
  14377. }
  14378. };
  14379. Transform.prototype._destroy = function (err, cb) {
  14380. var _this2 = this;
  14381. Duplex.prototype._destroy.call(this, err, function (err2) {
  14382. cb(err2);
  14383. _this2.emit('close');
  14384. });
  14385. };
  14386. function done(stream, er, data) {
  14387. if (er) return stream.emit('error', er);
  14388. if (data != null) // single equals check for both `null` and `undefined`
  14389. stream.push(data);
  14390. // if there's nothing in the write buffer, then that means
  14391. // that nothing more will ever be provided
  14392. if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
  14393. if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
  14394. return stream.push(null);
  14395. }
  14396. },{"./_stream_duplex":71,"core-util-is":44,"inherits":56}],75:[function(require,module,exports){
  14397. (function (process,global,setImmediate){
  14398. // Copyright Joyent, Inc. and other Node contributors.
  14399. //
  14400. // Permission is hereby granted, free of charge, to any person obtaining a
  14401. // copy of this software and associated documentation files (the
  14402. // "Software"), to deal in the Software without restriction, including
  14403. // without limitation the rights to use, copy, modify, merge, publish,
  14404. // distribute, sublicense, and/or sell copies of the Software, and to permit
  14405. // persons to whom the Software is furnished to do so, subject to the
  14406. // following conditions:
  14407. //
  14408. // The above copyright notice and this permission notice shall be included
  14409. // in all copies or substantial portions of the Software.
  14410. //
  14411. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14412. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14413. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  14414. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14415. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  14416. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  14417. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  14418. // A bit simpler than readable streams.
  14419. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  14420. // the drain event emission and buffering.
  14421. 'use strict';
  14422. /*<replacement>*/
  14423. var pna = require('process-nextick-args');
  14424. /*</replacement>*/
  14425. module.exports = Writable;
  14426. /* <replacement> */
  14427. function WriteReq(chunk, encoding, cb) {
  14428. this.chunk = chunk;
  14429. this.encoding = encoding;
  14430. this.callback = cb;
  14431. this.next = null;
  14432. }
  14433. // It seems a linked list but it is not
  14434. // there will be only 2 of these for each stream
  14435. function CorkedRequest(state) {
  14436. var _this = this;
  14437. this.next = null;
  14438. this.entry = null;
  14439. this.finish = function () {
  14440. onCorkedFinish(_this, state);
  14441. };
  14442. }
  14443. /* </replacement> */
  14444. /*<replacement>*/
  14445. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
  14446. /*</replacement>*/
  14447. /*<replacement>*/
  14448. var Duplex;
  14449. /*</replacement>*/
  14450. Writable.WritableState = WritableState;
  14451. /*<replacement>*/
  14452. var util = require('core-util-is');
  14453. util.inherits = require('inherits');
  14454. /*</replacement>*/
  14455. /*<replacement>*/
  14456. var internalUtil = {
  14457. deprecate: require('util-deprecate')
  14458. };
  14459. /*</replacement>*/
  14460. /*<replacement>*/
  14461. var Stream = require('./internal/streams/stream');
  14462. /*</replacement>*/
  14463. /*<replacement>*/
  14464. var Buffer = require('safe-buffer').Buffer;
  14465. var OurUint8Array = global.Uint8Array || function () {};
  14466. function _uint8ArrayToBuffer(chunk) {
  14467. return Buffer.from(chunk);
  14468. }
  14469. function _isUint8Array(obj) {
  14470. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  14471. }
  14472. /*</replacement>*/
  14473. var destroyImpl = require('./internal/streams/destroy');
  14474. util.inherits(Writable, Stream);
  14475. function nop() {}
  14476. function WritableState(options, stream) {
  14477. Duplex = Duplex || require('./_stream_duplex');
  14478. options = options || {};
  14479. // Duplex streams are both readable and writable, but share
  14480. // the same options object.
  14481. // However, some cases require setting options to different
  14482. // values for the readable and the writable sides of the duplex stream.
  14483. // These options can be provided separately as readableXXX and writableXXX.
  14484. var isDuplex = stream instanceof Duplex;
  14485. // object stream flag to indicate whether or not this stream
  14486. // contains buffers or objects.
  14487. this.objectMode = !!options.objectMode;
  14488. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  14489. // the point at which write() starts returning false
  14490. // Note: 0 is a valid value, means that we always return false if
  14491. // the entire buffer is not flushed immediately on write()
  14492. var hwm = options.highWaterMark;
  14493. var writableHwm = options.writableHighWaterMark;
  14494. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  14495. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
  14496. // cast to ints.
  14497. this.highWaterMark = Math.floor(this.highWaterMark);
  14498. // if _final has been called
  14499. this.finalCalled = false;
  14500. // drain event flag.
  14501. this.needDrain = false;
  14502. // at the start of calling end()
  14503. this.ending = false;
  14504. // when end() has been called, and returned
  14505. this.ended = false;
  14506. // when 'finish' is emitted
  14507. this.finished = false;
  14508. // has it been destroyed
  14509. this.destroyed = false;
  14510. // should we decode strings into buffers before passing to _write?
  14511. // this is here so that some node-core streams can optimize string
  14512. // handling at a lower level.
  14513. var noDecode = options.decodeStrings === false;
  14514. this.decodeStrings = !noDecode;
  14515. // Crypto is kind of old and crusty. Historically, its default string
  14516. // encoding is 'binary' so we have to make this configurable.
  14517. // Everything else in the universe uses 'utf8', though.
  14518. this.defaultEncoding = options.defaultEncoding || 'utf8';
  14519. // not an actual buffer we keep track of, but a measurement
  14520. // of how much we're waiting to get pushed to some underlying
  14521. // socket or file.
  14522. this.length = 0;
  14523. // a flag to see when we're in the middle of a write.
  14524. this.writing = false;
  14525. // when true all writes will be buffered until .uncork() call
  14526. this.corked = 0;
  14527. // a flag to be able to tell if the onwrite cb is called immediately,
  14528. // or on a later tick. We set this to true at first, because any
  14529. // actions that shouldn't happen until "later" should generally also
  14530. // not happen before the first write call.
  14531. this.sync = true;
  14532. // a flag to know if we're processing previously buffered items, which
  14533. // may call the _write() callback in the same tick, so that we don't
  14534. // end up in an overlapped onwrite situation.
  14535. this.bufferProcessing = false;
  14536. // the callback that's passed to _write(chunk,cb)
  14537. this.onwrite = function (er) {
  14538. onwrite(stream, er);
  14539. };
  14540. // the callback that the user supplies to write(chunk,encoding,cb)
  14541. this.writecb = null;
  14542. // the amount that is being written when _write is called.
  14543. this.writelen = 0;
  14544. this.bufferedRequest = null;
  14545. this.lastBufferedRequest = null;
  14546. // number of pending user-supplied write callbacks
  14547. // this must be 0 before 'finish' can be emitted
  14548. this.pendingcb = 0;
  14549. // emit prefinish if the only thing we're waiting for is _write cbs
  14550. // This is relevant for synchronous Transform streams
  14551. this.prefinished = false;
  14552. // True if the error was already emitted and should not be thrown again
  14553. this.errorEmitted = false;
  14554. // count buffered requests
  14555. this.bufferedRequestCount = 0;
  14556. // allocate the first CorkedRequest, there is always
  14557. // one allocated and free to use, and we maintain at most two
  14558. this.corkedRequestsFree = new CorkedRequest(this);
  14559. }
  14560. WritableState.prototype.getBuffer = function getBuffer() {
  14561. var current = this.bufferedRequest;
  14562. var out = [];
  14563. while (current) {
  14564. out.push(current);
  14565. current = current.next;
  14566. }
  14567. return out;
  14568. };
  14569. (function () {
  14570. try {
  14571. Object.defineProperty(WritableState.prototype, 'buffer', {
  14572. get: internalUtil.deprecate(function () {
  14573. return this.getBuffer();
  14574. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  14575. });
  14576. } catch (_) {}
  14577. })();
  14578. // Test _writableState for inheritance to account for Duplex streams,
  14579. // whose prototype chain only points to Readable.
  14580. var realHasInstance;
  14581. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  14582. realHasInstance = Function.prototype[Symbol.hasInstance];
  14583. Object.defineProperty(Writable, Symbol.hasInstance, {
  14584. value: function (object) {
  14585. if (realHasInstance.call(this, object)) return true;
  14586. if (this !== Writable) return false;
  14587. return object && object._writableState instanceof WritableState;
  14588. }
  14589. });
  14590. } else {
  14591. realHasInstance = function (object) {
  14592. return object instanceof this;
  14593. };
  14594. }
  14595. function Writable(options) {
  14596. Duplex = Duplex || require('./_stream_duplex');
  14597. // Writable ctor is applied to Duplexes, too.
  14598. // `realHasInstance` is necessary because using plain `instanceof`
  14599. // would return false, as no `_writableState` property is attached.
  14600. // Trying to use the custom `instanceof` for Writable here will also break the
  14601. // Node.js LazyTransform implementation, which has a non-trivial getter for
  14602. // `_writableState` that would lead to infinite recursion.
  14603. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  14604. return new Writable(options);
  14605. }
  14606. this._writableState = new WritableState(options, this);
  14607. // legacy.
  14608. this.writable = true;
  14609. if (options) {
  14610. if (typeof options.write === 'function') this._write = options.write;
  14611. if (typeof options.writev === 'function') this._writev = options.writev;
  14612. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  14613. if (typeof options.final === 'function') this._final = options.final;
  14614. }
  14615. Stream.call(this);
  14616. }
  14617. // Otherwise people can pipe Writable streams, which is just wrong.
  14618. Writable.prototype.pipe = function () {
  14619. this.emit('error', new Error('Cannot pipe, not readable'));
  14620. };
  14621. function writeAfterEnd(stream, cb) {
  14622. var er = new Error('write after end');
  14623. // TODO: defer error events consistently everywhere, not just the cb
  14624. stream.emit('error', er);
  14625. pna.nextTick(cb, er);
  14626. }
  14627. // Checks that a user-supplied chunk is valid, especially for the particular
  14628. // mode the stream is in. Currently this means that `null` is never accepted
  14629. // and undefined/non-string values are only allowed in object mode.
  14630. function validChunk(stream, state, chunk, cb) {
  14631. var valid = true;
  14632. var er = false;
  14633. if (chunk === null) {
  14634. er = new TypeError('May not write null values to stream');
  14635. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  14636. er = new TypeError('Invalid non-string/buffer chunk');
  14637. }
  14638. if (er) {
  14639. stream.emit('error', er);
  14640. pna.nextTick(cb, er);
  14641. valid = false;
  14642. }
  14643. return valid;
  14644. }
  14645. Writable.prototype.write = function (chunk, encoding, cb) {
  14646. var state = this._writableState;
  14647. var ret = false;
  14648. var isBuf = !state.objectMode && _isUint8Array(chunk);
  14649. if (isBuf && !Buffer.isBuffer(chunk)) {
  14650. chunk = _uint8ArrayToBuffer(chunk);
  14651. }
  14652. if (typeof encoding === 'function') {
  14653. cb = encoding;
  14654. encoding = null;
  14655. }
  14656. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  14657. if (typeof cb !== 'function') cb = nop;
  14658. if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  14659. state.pendingcb++;
  14660. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  14661. }
  14662. return ret;
  14663. };
  14664. Writable.prototype.cork = function () {
  14665. var state = this._writableState;
  14666. state.corked++;
  14667. };
  14668. Writable.prototype.uncork = function () {
  14669. var state = this._writableState;
  14670. if (state.corked) {
  14671. state.corked--;
  14672. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  14673. }
  14674. };
  14675. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  14676. // node::ParseEncoding() requires lower case.
  14677. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  14678. 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);
  14679. this._writableState.defaultEncoding = encoding;
  14680. return this;
  14681. };
  14682. function decodeChunk(state, chunk, encoding) {
  14683. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  14684. chunk = Buffer.from(chunk, encoding);
  14685. }
  14686. return chunk;
  14687. }
  14688. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  14689. // making it explicit this property is not enumerable
  14690. // because otherwise some prototype manipulation in
  14691. // userland will fail
  14692. enumerable: false,
  14693. get: function () {
  14694. return this._writableState.highWaterMark;
  14695. }
  14696. });
  14697. // if we're already writing something, then just put this
  14698. // in the queue, and wait our turn. Otherwise, call _write
  14699. // If we return false, then we need a drain event, so set that flag.
  14700. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  14701. if (!isBuf) {
  14702. var newChunk = decodeChunk(state, chunk, encoding);
  14703. if (chunk !== newChunk) {
  14704. isBuf = true;
  14705. encoding = 'buffer';
  14706. chunk = newChunk;
  14707. }
  14708. }
  14709. var len = state.objectMode ? 1 : chunk.length;
  14710. state.length += len;
  14711. var ret = state.length < state.highWaterMark;
  14712. // we must ensure that previous needDrain will not be reset to false.
  14713. if (!ret) state.needDrain = true;
  14714. if (state.writing || state.corked) {
  14715. var last = state.lastBufferedRequest;
  14716. state.lastBufferedRequest = {
  14717. chunk: chunk,
  14718. encoding: encoding,
  14719. isBuf: isBuf,
  14720. callback: cb,
  14721. next: null
  14722. };
  14723. if (last) {
  14724. last.next = state.lastBufferedRequest;
  14725. } else {
  14726. state.bufferedRequest = state.lastBufferedRequest;
  14727. }
  14728. state.bufferedRequestCount += 1;
  14729. } else {
  14730. doWrite(stream, state, false, len, chunk, encoding, cb);
  14731. }
  14732. return ret;
  14733. }
  14734. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  14735. state.writelen = len;
  14736. state.writecb = cb;
  14737. state.writing = true;
  14738. state.sync = true;
  14739. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  14740. state.sync = false;
  14741. }
  14742. function onwriteError(stream, state, sync, er, cb) {
  14743. --state.pendingcb;
  14744. if (sync) {
  14745. // defer the callback if we are being called synchronously
  14746. // to avoid piling up things on the stack
  14747. pna.nextTick(cb, er);
  14748. // this can emit finish, and it will always happen
  14749. // after error
  14750. pna.nextTick(finishMaybe, stream, state);
  14751. stream._writableState.errorEmitted = true;
  14752. stream.emit('error', er);
  14753. } else {
  14754. // the caller expect this to happen before if
  14755. // it is async
  14756. cb(er);
  14757. stream._writableState.errorEmitted = true;
  14758. stream.emit('error', er);
  14759. // this can emit finish, but finish must
  14760. // always follow error
  14761. finishMaybe(stream, state);
  14762. }
  14763. }
  14764. function onwriteStateUpdate(state) {
  14765. state.writing = false;
  14766. state.writecb = null;
  14767. state.length -= state.writelen;
  14768. state.writelen = 0;
  14769. }
  14770. function onwrite(stream, er) {
  14771. var state = stream._writableState;
  14772. var sync = state.sync;
  14773. var cb = state.writecb;
  14774. onwriteStateUpdate(state);
  14775. if (er) onwriteError(stream, state, sync, er, cb);else {
  14776. // Check if we're actually ready to finish, but don't emit yet
  14777. var finished = needFinish(state);
  14778. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  14779. clearBuffer(stream, state);
  14780. }
  14781. if (sync) {
  14782. /*<replacement>*/
  14783. asyncWrite(afterWrite, stream, state, finished, cb);
  14784. /*</replacement>*/
  14785. } else {
  14786. afterWrite(stream, state, finished, cb);
  14787. }
  14788. }
  14789. }
  14790. function afterWrite(stream, state, finished, cb) {
  14791. if (!finished) onwriteDrain(stream, state);
  14792. state.pendingcb--;
  14793. cb();
  14794. finishMaybe(stream, state);
  14795. }
  14796. // Must force callback to be called on nextTick, so that we don't
  14797. // emit 'drain' before the write() consumer gets the 'false' return
  14798. // value, and has a chance to attach a 'drain' listener.
  14799. function onwriteDrain(stream, state) {
  14800. if (state.length === 0 && state.needDrain) {
  14801. state.needDrain = false;
  14802. stream.emit('drain');
  14803. }
  14804. }
  14805. // if there's something in the buffer waiting, then process it
  14806. function clearBuffer(stream, state) {
  14807. state.bufferProcessing = true;
  14808. var entry = state.bufferedRequest;
  14809. if (stream._writev && entry && entry.next) {
  14810. // Fast case, write everything using _writev()
  14811. var l = state.bufferedRequestCount;
  14812. var buffer = new Array(l);
  14813. var holder = state.corkedRequestsFree;
  14814. holder.entry = entry;
  14815. var count = 0;
  14816. var allBuffers = true;
  14817. while (entry) {
  14818. buffer[count] = entry;
  14819. if (!entry.isBuf) allBuffers = false;
  14820. entry = entry.next;
  14821. count += 1;
  14822. }
  14823. buffer.allBuffers = allBuffers;
  14824. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  14825. // doWrite is almost always async, defer these to save a bit of time
  14826. // as the hot path ends with doWrite
  14827. state.pendingcb++;
  14828. state.lastBufferedRequest = null;
  14829. if (holder.next) {
  14830. state.corkedRequestsFree = holder.next;
  14831. holder.next = null;
  14832. } else {
  14833. state.corkedRequestsFree = new CorkedRequest(state);
  14834. }
  14835. state.bufferedRequestCount = 0;
  14836. } else {
  14837. // Slow case, write chunks one-by-one
  14838. while (entry) {
  14839. var chunk = entry.chunk;
  14840. var encoding = entry.encoding;
  14841. var cb = entry.callback;
  14842. var len = state.objectMode ? 1 : chunk.length;
  14843. doWrite(stream, state, false, len, chunk, encoding, cb);
  14844. entry = entry.next;
  14845. state.bufferedRequestCount--;
  14846. // if we didn't call the onwrite immediately, then
  14847. // it means that we need to wait until it does.
  14848. // also, that means that the chunk and cb are currently
  14849. // being processed, so move the buffer counter past them.
  14850. if (state.writing) {
  14851. break;
  14852. }
  14853. }
  14854. if (entry === null) state.lastBufferedRequest = null;
  14855. }
  14856. state.bufferedRequest = entry;
  14857. state.bufferProcessing = false;
  14858. }
  14859. Writable.prototype._write = function (chunk, encoding, cb) {
  14860. cb(new Error('_write() is not implemented'));
  14861. };
  14862. Writable.prototype._writev = null;
  14863. Writable.prototype.end = function (chunk, encoding, cb) {
  14864. var state = this._writableState;
  14865. if (typeof chunk === 'function') {
  14866. cb = chunk;
  14867. chunk = null;
  14868. encoding = null;
  14869. } else if (typeof encoding === 'function') {
  14870. cb = encoding;
  14871. encoding = null;
  14872. }
  14873. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  14874. // .end() fully uncorks
  14875. if (state.corked) {
  14876. state.corked = 1;
  14877. this.uncork();
  14878. }
  14879. // ignore unnecessary end() calls.
  14880. if (!state.ending && !state.finished) endWritable(this, state, cb);
  14881. };
  14882. function needFinish(state) {
  14883. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  14884. }
  14885. function callFinal(stream, state) {
  14886. stream._final(function (err) {
  14887. state.pendingcb--;
  14888. if (err) {
  14889. stream.emit('error', err);
  14890. }
  14891. state.prefinished = true;
  14892. stream.emit('prefinish');
  14893. finishMaybe(stream, state);
  14894. });
  14895. }
  14896. function prefinish(stream, state) {
  14897. if (!state.prefinished && !state.finalCalled) {
  14898. if (typeof stream._final === 'function') {
  14899. state.pendingcb++;
  14900. state.finalCalled = true;
  14901. pna.nextTick(callFinal, stream, state);
  14902. } else {
  14903. state.prefinished = true;
  14904. stream.emit('prefinish');
  14905. }
  14906. }
  14907. }
  14908. function finishMaybe(stream, state) {
  14909. var need = needFinish(state);
  14910. if (need) {
  14911. prefinish(stream, state);
  14912. if (state.pendingcb === 0) {
  14913. state.finished = true;
  14914. stream.emit('finish');
  14915. }
  14916. }
  14917. return need;
  14918. }
  14919. function endWritable(stream, state, cb) {
  14920. state.ending = true;
  14921. finishMaybe(stream, state);
  14922. if (cb) {
  14923. if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
  14924. }
  14925. state.ended = true;
  14926. stream.writable = false;
  14927. }
  14928. function onCorkedFinish(corkReq, state, err) {
  14929. var entry = corkReq.entry;
  14930. corkReq.entry = null;
  14931. while (entry) {
  14932. var cb = entry.callback;
  14933. state.pendingcb--;
  14934. cb(err);
  14935. entry = entry.next;
  14936. }
  14937. if (state.corkedRequestsFree) {
  14938. state.corkedRequestsFree.next = corkReq;
  14939. } else {
  14940. state.corkedRequestsFree = corkReq;
  14941. }
  14942. }
  14943. Object.defineProperty(Writable.prototype, 'destroyed', {
  14944. get: function () {
  14945. if (this._writableState === undefined) {
  14946. return false;
  14947. }
  14948. return this._writableState.destroyed;
  14949. },
  14950. set: function (value) {
  14951. // we ignore the value if the stream
  14952. // has not been initialized yet
  14953. if (!this._writableState) {
  14954. return;
  14955. }
  14956. // backward compatibility, the user is explicitly
  14957. // managing destroyed
  14958. this._writableState.destroyed = value;
  14959. }
  14960. });
  14961. Writable.prototype.destroy = destroyImpl.destroy;
  14962. Writable.prototype._undestroy = destroyImpl.undestroy;
  14963. Writable.prototype._destroy = function (err, cb) {
  14964. this.end();
  14965. cb(err);
  14966. };
  14967. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
  14968. },{"./_stream_duplex":71,"./internal/streams/destroy":77,"./internal/streams/stream":78,"_process":69,"core-util-is":44,"inherits":56,"process-nextick-args":68,"safe-buffer":83,"timers":86,"util-deprecate":87}],76:[function(require,module,exports){
  14969. 'use strict';
  14970. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14971. var Buffer = require('safe-buffer').Buffer;
  14972. var util = require('util');
  14973. function copyBuffer(src, target, offset) {
  14974. src.copy(target, offset);
  14975. }
  14976. module.exports = function () {
  14977. function BufferList() {
  14978. _classCallCheck(this, BufferList);
  14979. this.head = null;
  14980. this.tail = null;
  14981. this.length = 0;
  14982. }
  14983. BufferList.prototype.push = function push(v) {
  14984. var entry = { data: v, next: null };
  14985. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  14986. this.tail = entry;
  14987. ++this.length;
  14988. };
  14989. BufferList.prototype.unshift = function unshift(v) {
  14990. var entry = { data: v, next: this.head };
  14991. if (this.length === 0) this.tail = entry;
  14992. this.head = entry;
  14993. ++this.length;
  14994. };
  14995. BufferList.prototype.shift = function shift() {
  14996. if (this.length === 0) return;
  14997. var ret = this.head.data;
  14998. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  14999. --this.length;
  15000. return ret;
  15001. };
  15002. BufferList.prototype.clear = function clear() {
  15003. this.head = this.tail = null;
  15004. this.length = 0;
  15005. };
  15006. BufferList.prototype.join = function join(s) {
  15007. if (this.length === 0) return '';
  15008. var p = this.head;
  15009. var ret = '' + p.data;
  15010. while (p = p.next) {
  15011. ret += s + p.data;
  15012. }return ret;
  15013. };
  15014. BufferList.prototype.concat = function concat(n) {
  15015. if (this.length === 0) return Buffer.alloc(0);
  15016. if (this.length === 1) return this.head.data;
  15017. var ret = Buffer.allocUnsafe(n >>> 0);
  15018. var p = this.head;
  15019. var i = 0;
  15020. while (p) {
  15021. copyBuffer(p.data, ret, i);
  15022. i += p.data.length;
  15023. p = p.next;
  15024. }
  15025. return ret;
  15026. };
  15027. return BufferList;
  15028. }();
  15029. if (util && util.inspect && util.inspect.custom) {
  15030. module.exports.prototype[util.inspect.custom] = function () {
  15031. var obj = util.inspect({ length: this.length });
  15032. return this.constructor.name + ' ' + obj;
  15033. };
  15034. }
  15035. },{"safe-buffer":83,"util":40}],77:[function(require,module,exports){
  15036. 'use strict';
  15037. /*<replacement>*/
  15038. var pna = require('process-nextick-args');
  15039. /*</replacement>*/
  15040. // undocumented cb() API, needed for core, not for public API
  15041. function destroy(err, cb) {
  15042. var _this = this;
  15043. var readableDestroyed = this._readableState && this._readableState.destroyed;
  15044. var writableDestroyed = this._writableState && this._writableState.destroyed;
  15045. if (readableDestroyed || writableDestroyed) {
  15046. if (cb) {
  15047. cb(err);
  15048. } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
  15049. pna.nextTick(emitErrorNT, this, err);
  15050. }
  15051. return this;
  15052. }
  15053. // we set destroyed to true before firing error callbacks in order
  15054. // to make it re-entrance safe in case destroy() is called within callbacks
  15055. if (this._readableState) {
  15056. this._readableState.destroyed = true;
  15057. }
  15058. // if this is a duplex stream mark the writable part as destroyed as well
  15059. if (this._writableState) {
  15060. this._writableState.destroyed = true;
  15061. }
  15062. this._destroy(err || null, function (err) {
  15063. if (!cb && err) {
  15064. pna.nextTick(emitErrorNT, _this, err);
  15065. if (_this._writableState) {
  15066. _this._writableState.errorEmitted = true;
  15067. }
  15068. } else if (cb) {
  15069. cb(err);
  15070. }
  15071. });
  15072. return this;
  15073. }
  15074. function undestroy() {
  15075. if (this._readableState) {
  15076. this._readableState.destroyed = false;
  15077. this._readableState.reading = false;
  15078. this._readableState.ended = false;
  15079. this._readableState.endEmitted = false;
  15080. }
  15081. if (this._writableState) {
  15082. this._writableState.destroyed = false;
  15083. this._writableState.ended = false;
  15084. this._writableState.ending = false;
  15085. this._writableState.finished = false;
  15086. this._writableState.errorEmitted = false;
  15087. }
  15088. }
  15089. function emitErrorNT(self, err) {
  15090. self.emit('error', err);
  15091. }
  15092. module.exports = {
  15093. destroy: destroy,
  15094. undestroy: undestroy
  15095. };
  15096. },{"process-nextick-args":68}],78:[function(require,module,exports){
  15097. module.exports = require('events').EventEmitter;
  15098. },{"events":50}],79:[function(require,module,exports){
  15099. module.exports = require('./readable').PassThrough
  15100. },{"./readable":80}],80:[function(require,module,exports){
  15101. exports = module.exports = require('./lib/_stream_readable.js');
  15102. exports.Stream = exports;
  15103. exports.Readable = exports;
  15104. exports.Writable = require('./lib/_stream_writable.js');
  15105. exports.Duplex = require('./lib/_stream_duplex.js');
  15106. exports.Transform = require('./lib/_stream_transform.js');
  15107. exports.PassThrough = require('./lib/_stream_passthrough.js');
  15108. },{"./lib/_stream_duplex.js":71,"./lib/_stream_passthrough.js":72,"./lib/_stream_readable.js":73,"./lib/_stream_transform.js":74,"./lib/_stream_writable.js":75}],81:[function(require,module,exports){
  15109. module.exports = require('./readable').Transform
  15110. },{"./readable":80}],82:[function(require,module,exports){
  15111. module.exports = require('./lib/_stream_writable.js');
  15112. },{"./lib/_stream_writable.js":75}],83:[function(require,module,exports){
  15113. /* eslint-disable node/no-deprecated-api */
  15114. var buffer = require('buffer')
  15115. var Buffer = buffer.Buffer
  15116. // alternative to using Object.keys for old browsers
  15117. function copyProps (src, dst) {
  15118. for (var key in src) {
  15119. dst[key] = src[key]
  15120. }
  15121. }
  15122. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  15123. module.exports = buffer
  15124. } else {
  15125. // Copy properties from require('buffer')
  15126. copyProps(buffer, exports)
  15127. exports.Buffer = SafeBuffer
  15128. }
  15129. function SafeBuffer (arg, encodingOrOffset, length) {
  15130. return Buffer(arg, encodingOrOffset, length)
  15131. }
  15132. // Copy static methods from Buffer
  15133. copyProps(Buffer, SafeBuffer)
  15134. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  15135. if (typeof arg === 'number') {
  15136. throw new TypeError('Argument must not be a number')
  15137. }
  15138. return Buffer(arg, encodingOrOffset, length)
  15139. }
  15140. SafeBuffer.alloc = function (size, fill, encoding) {
  15141. if (typeof size !== 'number') {
  15142. throw new TypeError('Argument must be a number')
  15143. }
  15144. var buf = Buffer(size)
  15145. if (fill !== undefined) {
  15146. if (typeof encoding === 'string') {
  15147. buf.fill(fill, encoding)
  15148. } else {
  15149. buf.fill(fill)
  15150. }
  15151. } else {
  15152. buf.fill(0)
  15153. }
  15154. return buf
  15155. }
  15156. SafeBuffer.allocUnsafe = function (size) {
  15157. if (typeof size !== 'number') {
  15158. throw new TypeError('Argument must be a number')
  15159. }
  15160. return Buffer(size)
  15161. }
  15162. SafeBuffer.allocUnsafeSlow = function (size) {
  15163. if (typeof size !== 'number') {
  15164. throw new TypeError('Argument must be a number')
  15165. }
  15166. return buffer.SlowBuffer(size)
  15167. }
  15168. },{"buffer":43}],84:[function(require,module,exports){
  15169. // Copyright Joyent, Inc. and other Node contributors.
  15170. //
  15171. // Permission is hereby granted, free of charge, to any person obtaining a
  15172. // copy of this software and associated documentation files (the
  15173. // "Software"), to deal in the Software without restriction, including
  15174. // without limitation the rights to use, copy, modify, merge, publish,
  15175. // distribute, sublicense, and/or sell copies of the Software, and to permit
  15176. // persons to whom the Software is furnished to do so, subject to the
  15177. // following conditions:
  15178. //
  15179. // The above copyright notice and this permission notice shall be included
  15180. // in all copies or substantial portions of the Software.
  15181. //
  15182. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15183. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15184. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  15185. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15186. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15187. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  15188. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  15189. module.exports = Stream;
  15190. var EE = require('events').EventEmitter;
  15191. var inherits = require('inherits');
  15192. inherits(Stream, EE);
  15193. Stream.Readable = require('readable-stream/readable.js');
  15194. Stream.Writable = require('readable-stream/writable.js');
  15195. Stream.Duplex = require('readable-stream/duplex.js');
  15196. Stream.Transform = require('readable-stream/transform.js');
  15197. Stream.PassThrough = require('readable-stream/passthrough.js');
  15198. // Backwards-compat with node 0.4.x
  15199. Stream.Stream = Stream;
  15200. // old-style streams. Note that the pipe method (the only relevant
  15201. // part of this class) is overridden in the Readable class.
  15202. function Stream() {
  15203. EE.call(this);
  15204. }
  15205. Stream.prototype.pipe = function(dest, options) {
  15206. var source = this;
  15207. function ondata(chunk) {
  15208. if (dest.writable) {
  15209. if (false === dest.write(chunk) && source.pause) {
  15210. source.pause();
  15211. }
  15212. }
  15213. }
  15214. source.on('data', ondata);
  15215. function ondrain() {
  15216. if (source.readable && source.resume) {
  15217. source.resume();
  15218. }
  15219. }
  15220. dest.on('drain', ondrain);
  15221. // If the 'end' option is not supplied, dest.end() will be called when
  15222. // source gets the 'end' or 'close' events. Only dest.end() once.
  15223. if (!dest._isStdio && (!options || options.end !== false)) {
  15224. source.on('end', onend);
  15225. source.on('close', onclose);
  15226. }
  15227. var didOnEnd = false;
  15228. function onend() {
  15229. if (didOnEnd) return;
  15230. didOnEnd = true;
  15231. dest.end();
  15232. }
  15233. function onclose() {
  15234. if (didOnEnd) return;
  15235. didOnEnd = true;
  15236. if (typeof dest.destroy === 'function') dest.destroy();
  15237. }
  15238. // don't leave dangling pipes when there are errors.
  15239. function onerror(er) {
  15240. cleanup();
  15241. if (EE.listenerCount(this, 'error') === 0) {
  15242. throw er; // Unhandled stream error in pipe.
  15243. }
  15244. }
  15245. source.on('error', onerror);
  15246. dest.on('error', onerror);
  15247. // remove all the event listeners that were added.
  15248. function cleanup() {
  15249. source.removeListener('data', ondata);
  15250. dest.removeListener('drain', ondrain);
  15251. source.removeListener('end', onend);
  15252. source.removeListener('close', onclose);
  15253. source.removeListener('error', onerror);
  15254. dest.removeListener('error', onerror);
  15255. source.removeListener('end', cleanup);
  15256. source.removeListener('close', cleanup);
  15257. dest.removeListener('close', cleanup);
  15258. }
  15259. source.on('end', cleanup);
  15260. source.on('close', cleanup);
  15261. dest.on('close', cleanup);
  15262. dest.emit('pipe', source);
  15263. // Allow for unix-like usage: A.pipe(B).pipe(C)
  15264. return dest;
  15265. };
  15266. },{"events":50,"inherits":56,"readable-stream/duplex.js":70,"readable-stream/passthrough.js":79,"readable-stream/readable.js":80,"readable-stream/transform.js":81,"readable-stream/writable.js":82}],85:[function(require,module,exports){
  15267. // Copyright Joyent, Inc. and other Node contributors.
  15268. //
  15269. // Permission is hereby granted, free of charge, to any person obtaining a
  15270. // copy of this software and associated documentation files (the
  15271. // "Software"), to deal in the Software without restriction, including
  15272. // without limitation the rights to use, copy, modify, merge, publish,
  15273. // distribute, sublicense, and/or sell copies of the Software, and to permit
  15274. // persons to whom the Software is furnished to do so, subject to the
  15275. // following conditions:
  15276. //
  15277. // The above copyright notice and this permission notice shall be included
  15278. // in all copies or substantial portions of the Software.
  15279. //
  15280. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15281. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15282. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  15283. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15284. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15285. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  15286. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  15287. 'use strict';
  15288. /*<replacement>*/
  15289. var Buffer = require('safe-buffer').Buffer;
  15290. /*</replacement>*/
  15291. var isEncoding = Buffer.isEncoding || function (encoding) {
  15292. encoding = '' + encoding;
  15293. switch (encoding && encoding.toLowerCase()) {
  15294. 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':
  15295. return true;
  15296. default:
  15297. return false;
  15298. }
  15299. };
  15300. function _normalizeEncoding(enc) {
  15301. if (!enc) return 'utf8';
  15302. var retried;
  15303. while (true) {
  15304. switch (enc) {
  15305. case 'utf8':
  15306. case 'utf-8':
  15307. return 'utf8';
  15308. case 'ucs2':
  15309. case 'ucs-2':
  15310. case 'utf16le':
  15311. case 'utf-16le':
  15312. return 'utf16le';
  15313. case 'latin1':
  15314. case 'binary':
  15315. return 'latin1';
  15316. case 'base64':
  15317. case 'ascii':
  15318. case 'hex':
  15319. return enc;
  15320. default:
  15321. if (retried) return; // undefined
  15322. enc = ('' + enc).toLowerCase();
  15323. retried = true;
  15324. }
  15325. }
  15326. };
  15327. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  15328. // modules monkey-patch it to support additional encodings
  15329. function normalizeEncoding(enc) {
  15330. var nenc = _normalizeEncoding(enc);
  15331. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  15332. return nenc || enc;
  15333. }
  15334. // StringDecoder provides an interface for efficiently splitting a series of
  15335. // buffers into a series of JS strings without breaking apart multi-byte
  15336. // characters.
  15337. exports.StringDecoder = StringDecoder;
  15338. function StringDecoder(encoding) {
  15339. this.encoding = normalizeEncoding(encoding);
  15340. var nb;
  15341. switch (this.encoding) {
  15342. case 'utf16le':
  15343. this.text = utf16Text;
  15344. this.end = utf16End;
  15345. nb = 4;
  15346. break;
  15347. case 'utf8':
  15348. this.fillLast = utf8FillLast;
  15349. nb = 4;
  15350. break;
  15351. case 'base64':
  15352. this.text = base64Text;
  15353. this.end = base64End;
  15354. nb = 3;
  15355. break;
  15356. default:
  15357. this.write = simpleWrite;
  15358. this.end = simpleEnd;
  15359. return;
  15360. }
  15361. this.lastNeed = 0;
  15362. this.lastTotal = 0;
  15363. this.lastChar = Buffer.allocUnsafe(nb);
  15364. }
  15365. StringDecoder.prototype.write = function (buf) {
  15366. if (buf.length === 0) return '';
  15367. var r;
  15368. var i;
  15369. if (this.lastNeed) {
  15370. r = this.fillLast(buf);
  15371. if (r === undefined) return '';
  15372. i = this.lastNeed;
  15373. this.lastNeed = 0;
  15374. } else {
  15375. i = 0;
  15376. }
  15377. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  15378. return r || '';
  15379. };
  15380. StringDecoder.prototype.end = utf8End;
  15381. // Returns only complete characters in a Buffer
  15382. StringDecoder.prototype.text = utf8Text;
  15383. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  15384. StringDecoder.prototype.fillLast = function (buf) {
  15385. if (this.lastNeed <= buf.length) {
  15386. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  15387. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  15388. }
  15389. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  15390. this.lastNeed -= buf.length;
  15391. };
  15392. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  15393. // continuation byte. If an invalid byte is detected, -2 is returned.
  15394. function utf8CheckByte(byte) {
  15395. 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;
  15396. return byte >> 6 === 0x02 ? -1 : -2;
  15397. }
  15398. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  15399. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  15400. // needed to complete the UTF-8 character (if applicable) are returned.
  15401. function utf8CheckIncomplete(self, buf, i) {
  15402. var j = buf.length - 1;
  15403. if (j < i) return 0;
  15404. var nb = utf8CheckByte(buf[j]);
  15405. if (nb >= 0) {
  15406. if (nb > 0) self.lastNeed = nb - 1;
  15407. return nb;
  15408. }
  15409. if (--j < i || nb === -2) return 0;
  15410. nb = utf8CheckByte(buf[j]);
  15411. if (nb >= 0) {
  15412. if (nb > 0) self.lastNeed = nb - 2;
  15413. return nb;
  15414. }
  15415. if (--j < i || nb === -2) return 0;
  15416. nb = utf8CheckByte(buf[j]);
  15417. if (nb >= 0) {
  15418. if (nb > 0) {
  15419. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  15420. }
  15421. return nb;
  15422. }
  15423. return 0;
  15424. }
  15425. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  15426. // needed or are available. If we see a non-continuation byte where we expect
  15427. // one, we "replace" the validated continuation bytes we've seen so far with
  15428. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  15429. // behavior. The continuation byte check is included three times in the case
  15430. // where all of the continuation bytes for a character exist in the same buffer.
  15431. // It is also done this way as a slight performance increase instead of using a
  15432. // loop.
  15433. function utf8CheckExtraBytes(self, buf, p) {
  15434. if ((buf[0] & 0xC0) !== 0x80) {
  15435. self.lastNeed = 0;
  15436. return '\ufffd';
  15437. }
  15438. if (self.lastNeed > 1 && buf.length > 1) {
  15439. if ((buf[1] & 0xC0) !== 0x80) {
  15440. self.lastNeed = 1;
  15441. return '\ufffd';
  15442. }
  15443. if (self.lastNeed > 2 && buf.length > 2) {
  15444. if ((buf[2] & 0xC0) !== 0x80) {
  15445. self.lastNeed = 2;
  15446. return '\ufffd';
  15447. }
  15448. }
  15449. }
  15450. }
  15451. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  15452. function utf8FillLast(buf) {
  15453. var p = this.lastTotal - this.lastNeed;
  15454. var r = utf8CheckExtraBytes(this, buf, p);
  15455. if (r !== undefined) return r;
  15456. if (this.lastNeed <= buf.length) {
  15457. buf.copy(this.lastChar, p, 0, this.lastNeed);
  15458. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  15459. }
  15460. buf.copy(this.lastChar, p, 0, buf.length);
  15461. this.lastNeed -= buf.length;
  15462. }
  15463. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  15464. // partial character, the character's bytes are buffered until the required
  15465. // number of bytes are available.
  15466. function utf8Text(buf, i) {
  15467. var total = utf8CheckIncomplete(this, buf, i);
  15468. if (!this.lastNeed) return buf.toString('utf8', i);
  15469. this.lastTotal = total;
  15470. var end = buf.length - (total - this.lastNeed);
  15471. buf.copy(this.lastChar, 0, end);
  15472. return buf.toString('utf8', i, end);
  15473. }
  15474. // For UTF-8, a replacement character is added when ending on a partial
  15475. // character.
  15476. function utf8End(buf) {
  15477. var r = buf && buf.length ? this.write(buf) : '';
  15478. if (this.lastNeed) return r + '\ufffd';
  15479. return r;
  15480. }
  15481. // UTF-16LE typically needs two bytes per character, but even if we have an even
  15482. // number of bytes available, we need to check if we end on a leading/high
  15483. // surrogate. In that case, we need to wait for the next two bytes in order to
  15484. // decode the last character properly.
  15485. function utf16Text(buf, i) {
  15486. if ((buf.length - i) % 2 === 0) {
  15487. var r = buf.toString('utf16le', i);
  15488. if (r) {
  15489. var c = r.charCodeAt(r.length - 1);
  15490. if (c >= 0xD800 && c <= 0xDBFF) {
  15491. this.lastNeed = 2;
  15492. this.lastTotal = 4;
  15493. this.lastChar[0] = buf[buf.length - 2];
  15494. this.lastChar[1] = buf[buf.length - 1];
  15495. return r.slice(0, -1);
  15496. }
  15497. }
  15498. return r;
  15499. }
  15500. this.lastNeed = 1;
  15501. this.lastTotal = 2;
  15502. this.lastChar[0] = buf[buf.length - 1];
  15503. return buf.toString('utf16le', i, buf.length - 1);
  15504. }
  15505. // For UTF-16LE we do not explicitly append special replacement characters if we
  15506. // end on a partial character, we simply let v8 handle that.
  15507. function utf16End(buf) {
  15508. var r = buf && buf.length ? this.write(buf) : '';
  15509. if (this.lastNeed) {
  15510. var end = this.lastTotal - this.lastNeed;
  15511. return r + this.lastChar.toString('utf16le', 0, end);
  15512. }
  15513. return r;
  15514. }
  15515. function base64Text(buf, i) {
  15516. var n = (buf.length - i) % 3;
  15517. if (n === 0) return buf.toString('base64', i);
  15518. this.lastNeed = 3 - n;
  15519. this.lastTotal = 3;
  15520. if (n === 1) {
  15521. this.lastChar[0] = buf[buf.length - 1];
  15522. } else {
  15523. this.lastChar[0] = buf[buf.length - 2];
  15524. this.lastChar[1] = buf[buf.length - 1];
  15525. }
  15526. return buf.toString('base64', i, buf.length - n);
  15527. }
  15528. function base64End(buf) {
  15529. var r = buf && buf.length ? this.write(buf) : '';
  15530. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  15531. return r;
  15532. }
  15533. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  15534. function simpleWrite(buf) {
  15535. return buf.toString(this.encoding);
  15536. }
  15537. function simpleEnd(buf) {
  15538. return buf && buf.length ? this.write(buf) : '';
  15539. }
  15540. },{"safe-buffer":83}],86:[function(require,module,exports){
  15541. (function (setImmediate,clearImmediate){
  15542. var nextTick = require('process/browser.js').nextTick;
  15543. var apply = Function.prototype.apply;
  15544. var slice = Array.prototype.slice;
  15545. var immediateIds = {};
  15546. var nextImmediateId = 0;
  15547. // DOM APIs, for completeness
  15548. exports.setTimeout = function() {
  15549. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  15550. };
  15551. exports.setInterval = function() {
  15552. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  15553. };
  15554. exports.clearTimeout =
  15555. exports.clearInterval = function(timeout) { timeout.close(); };
  15556. function Timeout(id, clearFn) {
  15557. this._id = id;
  15558. this._clearFn = clearFn;
  15559. }
  15560. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  15561. Timeout.prototype.close = function() {
  15562. this._clearFn.call(window, this._id);
  15563. };
  15564. // Does not start the time, just sets up the members needed.
  15565. exports.enroll = function(item, msecs) {
  15566. clearTimeout(item._idleTimeoutId);
  15567. item._idleTimeout = msecs;
  15568. };
  15569. exports.unenroll = function(item) {
  15570. clearTimeout(item._idleTimeoutId);
  15571. item._idleTimeout = -1;
  15572. };
  15573. exports._unrefActive = exports.active = function(item) {
  15574. clearTimeout(item._idleTimeoutId);
  15575. var msecs = item._idleTimeout;
  15576. if (msecs >= 0) {
  15577. item._idleTimeoutId = setTimeout(function onTimeout() {
  15578. if (item._onTimeout)
  15579. item._onTimeout();
  15580. }, msecs);
  15581. }
  15582. };
  15583. // That's not how node.js implements it but the exposed api is the same.
  15584. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
  15585. var id = nextImmediateId++;
  15586. var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  15587. immediateIds[id] = true;
  15588. nextTick(function onNextTick() {
  15589. if (immediateIds[id]) {
  15590. // fn.call() is faster so we optimize for the common use-case
  15591. // @see http://jsperf.com/call-apply-segu
  15592. if (args) {
  15593. fn.apply(null, args);
  15594. } else {
  15595. fn.call(null);
  15596. }
  15597. // Prevent ids from leaking
  15598. exports.clearImmediate(id);
  15599. }
  15600. });
  15601. return id;
  15602. };
  15603. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
  15604. delete immediateIds[id];
  15605. };
  15606. }).call(this,require("timers").setImmediate,require("timers").clearImmediate)
  15607. },{"process/browser.js":69,"timers":86}],87:[function(require,module,exports){
  15608. (function (global){
  15609. /**
  15610. * Module exports.
  15611. */
  15612. module.exports = deprecate;
  15613. /**
  15614. * Mark that a method should not be used.
  15615. * Returns a modified function which warns once by default.
  15616. *
  15617. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  15618. *
  15619. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  15620. * will throw an Error when invoked.
  15621. *
  15622. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  15623. * will invoke `console.trace()` instead of `console.error()`.
  15624. *
  15625. * @param {Function} fn - the function to deprecate
  15626. * @param {String} msg - the string to print to the console when `fn` is invoked
  15627. * @returns {Function} a new "deprecated" version of `fn`
  15628. * @api public
  15629. */
  15630. function deprecate (fn, msg) {
  15631. if (config('noDeprecation')) {
  15632. return fn;
  15633. }
  15634. var warned = false;
  15635. function deprecated() {
  15636. if (!warned) {
  15637. if (config('throwDeprecation')) {
  15638. throw new Error(msg);
  15639. } else if (config('traceDeprecation')) {
  15640. console.trace(msg);
  15641. } else {
  15642. console.warn(msg);
  15643. }
  15644. warned = true;
  15645. }
  15646. return fn.apply(this, arguments);
  15647. }
  15648. return deprecated;
  15649. }
  15650. /**
  15651. * Checks `localStorage` for boolean values for the given `name`.
  15652. *
  15653. * @param {String} name
  15654. * @returns {Boolean}
  15655. * @api private
  15656. */
  15657. function config (name) {
  15658. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  15659. try {
  15660. if (!global.localStorage) return false;
  15661. } catch (_) {
  15662. return false;
  15663. }
  15664. var val = global.localStorage[name];
  15665. if (null == val) return false;
  15666. return String(val).toLowerCase() === 'true';
  15667. }
  15668. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  15669. },{}],88:[function(require,module,exports){
  15670. module.exports = function isBuffer(arg) {
  15671. return arg && typeof arg === 'object'
  15672. && typeof arg.copy === 'function'
  15673. && typeof arg.fill === 'function'
  15674. && typeof arg.readUInt8 === 'function';
  15675. }
  15676. },{}],89:[function(require,module,exports){
  15677. (function (process,global){
  15678. // Copyright Joyent, Inc. and other Node contributors.
  15679. //
  15680. // Permission is hereby granted, free of charge, to any person obtaining a
  15681. // copy of this software and associated documentation files (the
  15682. // "Software"), to deal in the Software without restriction, including
  15683. // without limitation the rights to use, copy, modify, merge, publish,
  15684. // distribute, sublicense, and/or sell copies of the Software, and to permit
  15685. // persons to whom the Software is furnished to do so, subject to the
  15686. // following conditions:
  15687. //
  15688. // The above copyright notice and this permission notice shall be included
  15689. // in all copies or substantial portions of the Software.
  15690. //
  15691. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15692. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15693. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  15694. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15695. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15696. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  15697. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  15698. var formatRegExp = /%[sdj%]/g;
  15699. exports.format = function(f) {
  15700. if (!isString(f)) {
  15701. var objects = [];
  15702. for (var i = 0; i < arguments.length; i++) {
  15703. objects.push(inspect(arguments[i]));
  15704. }
  15705. return objects.join(' ');
  15706. }
  15707. var i = 1;
  15708. var args = arguments;
  15709. var len = args.length;
  15710. var str = String(f).replace(formatRegExp, function(x) {
  15711. if (x === '%%') return '%';
  15712. if (i >= len) return x;
  15713. switch (x) {
  15714. case '%s': return String(args[i++]);
  15715. case '%d': return Number(args[i++]);
  15716. case '%j':
  15717. try {
  15718. return JSON.stringify(args[i++]);
  15719. } catch (_) {
  15720. return '[Circular]';
  15721. }
  15722. default:
  15723. return x;
  15724. }
  15725. });
  15726. for (var x = args[i]; i < len; x = args[++i]) {
  15727. if (isNull(x) || !isObject(x)) {
  15728. str += ' ' + x;
  15729. } else {
  15730. str += ' ' + inspect(x);
  15731. }
  15732. }
  15733. return str;
  15734. };
  15735. // Mark that a method should not be used.
  15736. // Returns a modified function which warns once by default.
  15737. // If --no-deprecation is set, then it is a no-op.
  15738. exports.deprecate = function(fn, msg) {
  15739. // Allow for deprecating things in the process of starting up.
  15740. if (isUndefined(global.process)) {
  15741. return function() {
  15742. return exports.deprecate(fn, msg).apply(this, arguments);
  15743. };
  15744. }
  15745. if (process.noDeprecation === true) {
  15746. return fn;
  15747. }
  15748. var warned = false;
  15749. function deprecated() {
  15750. if (!warned) {
  15751. if (process.throwDeprecation) {
  15752. throw new Error(msg);
  15753. } else if (process.traceDeprecation) {
  15754. console.trace(msg);
  15755. } else {
  15756. console.error(msg);
  15757. }
  15758. warned = true;
  15759. }
  15760. return fn.apply(this, arguments);
  15761. }
  15762. return deprecated;
  15763. };
  15764. var debugs = {};
  15765. var debugEnviron;
  15766. exports.debuglog = function(set) {
  15767. if (isUndefined(debugEnviron))
  15768. debugEnviron = process.env.NODE_DEBUG || '';
  15769. set = set.toUpperCase();
  15770. if (!debugs[set]) {
  15771. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  15772. var pid = process.pid;
  15773. debugs[set] = function() {
  15774. var msg = exports.format.apply(exports, arguments);
  15775. console.error('%s %d: %s', set, pid, msg);
  15776. };
  15777. } else {
  15778. debugs[set] = function() {};
  15779. }
  15780. }
  15781. return debugs[set];
  15782. };
  15783. /**
  15784. * Echos the value of a value. Trys to print the value out
  15785. * in the best way possible given the different types.
  15786. *
  15787. * @param {Object} obj The object to print out.
  15788. * @param {Object} opts Optional options object that alters the output.
  15789. */
  15790. /* legacy: obj, showHidden, depth, colors*/
  15791. function inspect(obj, opts) {
  15792. // default options
  15793. var ctx = {
  15794. seen: [],
  15795. stylize: stylizeNoColor
  15796. };
  15797. // legacy...
  15798. if (arguments.length >= 3) ctx.depth = arguments[2];
  15799. if (arguments.length >= 4) ctx.colors = arguments[3];
  15800. if (isBoolean(opts)) {
  15801. // legacy...
  15802. ctx.showHidden = opts;
  15803. } else if (opts) {
  15804. // got an "options" object
  15805. exports._extend(ctx, opts);
  15806. }
  15807. // set default options
  15808. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  15809. if (isUndefined(ctx.depth)) ctx.depth = 2;
  15810. if (isUndefined(ctx.colors)) ctx.colors = false;
  15811. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  15812. if (ctx.colors) ctx.stylize = stylizeWithColor;
  15813. return formatValue(ctx, obj, ctx.depth);
  15814. }
  15815. exports.inspect = inspect;
  15816. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  15817. inspect.colors = {
  15818. 'bold' : [1, 22],
  15819. 'italic' : [3, 23],
  15820. 'underline' : [4, 24],
  15821. 'inverse' : [7, 27],
  15822. 'white' : [37, 39],
  15823. 'grey' : [90, 39],
  15824. 'black' : [30, 39],
  15825. 'blue' : [34, 39],
  15826. 'cyan' : [36, 39],
  15827. 'green' : [32, 39],
  15828. 'magenta' : [35, 39],
  15829. 'red' : [31, 39],
  15830. 'yellow' : [33, 39]
  15831. };
  15832. // Don't use 'blue' not visible on cmd.exe
  15833. inspect.styles = {
  15834. 'special': 'cyan',
  15835. 'number': 'yellow',
  15836. 'boolean': 'yellow',
  15837. 'undefined': 'grey',
  15838. 'null': 'bold',
  15839. 'string': 'green',
  15840. 'date': 'magenta',
  15841. // "name": intentionally not styling
  15842. 'regexp': 'red'
  15843. };
  15844. function stylizeWithColor(str, styleType) {
  15845. var style = inspect.styles[styleType];
  15846. if (style) {
  15847. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  15848. '\u001b[' + inspect.colors[style][1] + 'm';
  15849. } else {
  15850. return str;
  15851. }
  15852. }
  15853. function stylizeNoColor(str, styleType) {
  15854. return str;
  15855. }
  15856. function arrayToHash(array) {
  15857. var hash = {};
  15858. array.forEach(function(val, idx) {
  15859. hash[val] = true;
  15860. });
  15861. return hash;
  15862. }
  15863. function formatValue(ctx, value, recurseTimes) {
  15864. // Provide a hook for user-specified inspect functions.
  15865. // Check that value is an object with an inspect function on it
  15866. if (ctx.customInspect &&
  15867. value &&
  15868. isFunction(value.inspect) &&
  15869. // Filter out the util module, it's inspect function is special
  15870. value.inspect !== exports.inspect &&
  15871. // Also filter out any prototype objects using the circular check.
  15872. !(value.constructor && value.constructor.prototype === value)) {
  15873. var ret = value.inspect(recurseTimes, ctx);
  15874. if (!isString(ret)) {
  15875. ret = formatValue(ctx, ret, recurseTimes);
  15876. }
  15877. return ret;
  15878. }
  15879. // Primitive types cannot have properties
  15880. var primitive = formatPrimitive(ctx, value);
  15881. if (primitive) {
  15882. return primitive;
  15883. }
  15884. // Look up the keys of the object.
  15885. var keys = Object.keys(value);
  15886. var visibleKeys = arrayToHash(keys);
  15887. if (ctx.showHidden) {
  15888. keys = Object.getOwnPropertyNames(value);
  15889. }
  15890. // IE doesn't make error fields non-enumerable
  15891. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  15892. if (isError(value)
  15893. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  15894. return formatError(value);
  15895. }
  15896. // Some type of object without properties can be shortcutted.
  15897. if (keys.length === 0) {
  15898. if (isFunction(value)) {
  15899. var name = value.name ? ': ' + value.name : '';
  15900. return ctx.stylize('[Function' + name + ']', 'special');
  15901. }
  15902. if (isRegExp(value)) {
  15903. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  15904. }
  15905. if (isDate(value)) {
  15906. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  15907. }
  15908. if (isError(value)) {
  15909. return formatError(value);
  15910. }
  15911. }
  15912. var base = '', array = false, braces = ['{', '}'];
  15913. // Make Array say that they are Array
  15914. if (isArray(value)) {
  15915. array = true;
  15916. braces = ['[', ']'];
  15917. }
  15918. // Make functions say that they are functions
  15919. if (isFunction(value)) {
  15920. var n = value.name ? ': ' + value.name : '';
  15921. base = ' [Function' + n + ']';
  15922. }
  15923. // Make RegExps say that they are RegExps
  15924. if (isRegExp(value)) {
  15925. base = ' ' + RegExp.prototype.toString.call(value);
  15926. }
  15927. // Make dates with properties first say the date
  15928. if (isDate(value)) {
  15929. base = ' ' + Date.prototype.toUTCString.call(value);
  15930. }
  15931. // Make error with message first say the error
  15932. if (isError(value)) {
  15933. base = ' ' + formatError(value);
  15934. }
  15935. if (keys.length === 0 && (!array || value.length == 0)) {
  15936. return braces[0] + base + braces[1];
  15937. }
  15938. if (recurseTimes < 0) {
  15939. if (isRegExp(value)) {
  15940. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  15941. } else {
  15942. return ctx.stylize('[Object]', 'special');
  15943. }
  15944. }
  15945. ctx.seen.push(value);
  15946. var output;
  15947. if (array) {
  15948. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  15949. } else {
  15950. output = keys.map(function(key) {
  15951. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  15952. });
  15953. }
  15954. ctx.seen.pop();
  15955. return reduceToSingleString(output, base, braces);
  15956. }
  15957. function formatPrimitive(ctx, value) {
  15958. if (isUndefined(value))
  15959. return ctx.stylize('undefined', 'undefined');
  15960. if (isString(value)) {
  15961. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  15962. .replace(/'/g, "\\'")
  15963. .replace(/\\"/g, '"') + '\'';
  15964. return ctx.stylize(simple, 'string');
  15965. }
  15966. if (isNumber(value))
  15967. return ctx.stylize('' + value, 'number');
  15968. if (isBoolean(value))
  15969. return ctx.stylize('' + value, 'boolean');
  15970. // For some reason typeof null is "object", so special case here.
  15971. if (isNull(value))
  15972. return ctx.stylize('null', 'null');
  15973. }
  15974. function formatError(value) {
  15975. return '[' + Error.prototype.toString.call(value) + ']';
  15976. }
  15977. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  15978. var output = [];
  15979. for (var i = 0, l = value.length; i < l; ++i) {
  15980. if (hasOwnProperty(value, String(i))) {
  15981. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  15982. String(i), true));
  15983. } else {
  15984. output.push('');
  15985. }
  15986. }
  15987. keys.forEach(function(key) {
  15988. if (!key.match(/^\d+$/)) {
  15989. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  15990. key, true));
  15991. }
  15992. });
  15993. return output;
  15994. }
  15995. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  15996. var name, str, desc;
  15997. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  15998. if (desc.get) {
  15999. if (desc.set) {
  16000. str = ctx.stylize('[Getter/Setter]', 'special');
  16001. } else {
  16002. str = ctx.stylize('[Getter]', 'special');
  16003. }
  16004. } else {
  16005. if (desc.set) {
  16006. str = ctx.stylize('[Setter]', 'special');
  16007. }
  16008. }
  16009. if (!hasOwnProperty(visibleKeys, key)) {
  16010. name = '[' + key + ']';
  16011. }
  16012. if (!str) {
  16013. if (ctx.seen.indexOf(desc.value) < 0) {
  16014. if (isNull(recurseTimes)) {
  16015. str = formatValue(ctx, desc.value, null);
  16016. } else {
  16017. str = formatValue(ctx, desc.value, recurseTimes - 1);
  16018. }
  16019. if (str.indexOf('\n') > -1) {
  16020. if (array) {
  16021. str = str.split('\n').map(function(line) {
  16022. return ' ' + line;
  16023. }).join('\n').substr(2);
  16024. } else {
  16025. str = '\n' + str.split('\n').map(function(line) {
  16026. return ' ' + line;
  16027. }).join('\n');
  16028. }
  16029. }
  16030. } else {
  16031. str = ctx.stylize('[Circular]', 'special');
  16032. }
  16033. }
  16034. if (isUndefined(name)) {
  16035. if (array && key.match(/^\d+$/)) {
  16036. return str;
  16037. }
  16038. name = JSON.stringify('' + key);
  16039. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  16040. name = name.substr(1, name.length - 2);
  16041. name = ctx.stylize(name, 'name');
  16042. } else {
  16043. name = name.replace(/'/g, "\\'")
  16044. .replace(/\\"/g, '"')
  16045. .replace(/(^"|"$)/g, "'");
  16046. name = ctx.stylize(name, 'string');
  16047. }
  16048. }
  16049. return name + ': ' + str;
  16050. }
  16051. function reduceToSingleString(output, base, braces) {
  16052. var numLinesEst = 0;
  16053. var length = output.reduce(function(prev, cur) {
  16054. numLinesEst++;
  16055. if (cur.indexOf('\n') >= 0) numLinesEst++;
  16056. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  16057. }, 0);
  16058. if (length > 60) {
  16059. return braces[0] +
  16060. (base === '' ? '' : base + '\n ') +
  16061. ' ' +
  16062. output.join(',\n ') +
  16063. ' ' +
  16064. braces[1];
  16065. }
  16066. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  16067. }
  16068. // NOTE: These type checking functions intentionally don't use `instanceof`
  16069. // because it is fragile and can be easily faked with `Object.create()`.
  16070. function isArray(ar) {
  16071. return Array.isArray(ar);
  16072. }
  16073. exports.isArray = isArray;
  16074. function isBoolean(arg) {
  16075. return typeof arg === 'boolean';
  16076. }
  16077. exports.isBoolean = isBoolean;
  16078. function isNull(arg) {
  16079. return arg === null;
  16080. }
  16081. exports.isNull = isNull;
  16082. function isNullOrUndefined(arg) {
  16083. return arg == null;
  16084. }
  16085. exports.isNullOrUndefined = isNullOrUndefined;
  16086. function isNumber(arg) {
  16087. return typeof arg === 'number';
  16088. }
  16089. exports.isNumber = isNumber;
  16090. function isString(arg) {
  16091. return typeof arg === 'string';
  16092. }
  16093. exports.isString = isString;
  16094. function isSymbol(arg) {
  16095. return typeof arg === 'symbol';
  16096. }
  16097. exports.isSymbol = isSymbol;
  16098. function isUndefined(arg) {
  16099. return arg === void 0;
  16100. }
  16101. exports.isUndefined = isUndefined;
  16102. function isRegExp(re) {
  16103. return isObject(re) && objectToString(re) === '[object RegExp]';
  16104. }
  16105. exports.isRegExp = isRegExp;
  16106. function isObject(arg) {
  16107. return typeof arg === 'object' && arg !== null;
  16108. }
  16109. exports.isObject = isObject;
  16110. function isDate(d) {
  16111. return isObject(d) && objectToString(d) === '[object Date]';
  16112. }
  16113. exports.isDate = isDate;
  16114. function isError(e) {
  16115. return isObject(e) &&
  16116. (objectToString(e) === '[object Error]' || e instanceof Error);
  16117. }
  16118. exports.isError = isError;
  16119. function isFunction(arg) {
  16120. return typeof arg === 'function';
  16121. }
  16122. exports.isFunction = isFunction;
  16123. function isPrimitive(arg) {
  16124. return arg === null ||
  16125. typeof arg === 'boolean' ||
  16126. typeof arg === 'number' ||
  16127. typeof arg === 'string' ||
  16128. typeof arg === 'symbol' || // ES6 symbol
  16129. typeof arg === 'undefined';
  16130. }
  16131. exports.isPrimitive = isPrimitive;
  16132. exports.isBuffer = require('./support/isBuffer');
  16133. function objectToString(o) {
  16134. return Object.prototype.toString.call(o);
  16135. }
  16136. function pad(n) {
  16137. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  16138. }
  16139. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  16140. 'Oct', 'Nov', 'Dec'];
  16141. // 26 Feb 16:19:34
  16142. function timestamp() {
  16143. var d = new Date();
  16144. var time = [pad(d.getHours()),
  16145. pad(d.getMinutes()),
  16146. pad(d.getSeconds())].join(':');
  16147. return [d.getDate(), months[d.getMonth()], time].join(' ');
  16148. }
  16149. // log is just a thin wrapper to console.log that prepends a timestamp
  16150. exports.log = function() {
  16151. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  16152. };
  16153. /**
  16154. * Inherit the prototype methods from one constructor into another.
  16155. *
  16156. * The Function.prototype.inherits from lang.js rewritten as a standalone
  16157. * function (not on Function.prototype). NOTE: If this file is to be loaded
  16158. * during bootstrapping this function needs to be rewritten using some native
  16159. * functions as prototype setup using normal JavaScript does not work as
  16160. * expected during bootstrapping (see mirror.js in r114903).
  16161. *
  16162. * @param {function} ctor Constructor function which needs to inherit the
  16163. * prototype.
  16164. * @param {function} superCtor Constructor function to inherit prototype from.
  16165. */
  16166. exports.inherits = require('inherits');
  16167. exports._extend = function(origin, add) {
  16168. // Don't do anything if add isn't an object
  16169. if (!add || !isObject(add)) return origin;
  16170. var keys = Object.keys(add);
  16171. var i = keys.length;
  16172. while (i--) {
  16173. origin[keys[i]] = add[keys[i]];
  16174. }
  16175. return origin;
  16176. };
  16177. function hasOwnProperty(obj, prop) {
  16178. return Object.prototype.hasOwnProperty.call(obj, prop);
  16179. }
  16180. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  16181. },{"./support/isBuffer":88,"_process":69,"inherits":56}],90:[function(require,module,exports){
  16182. module.exports={
  16183. "name": "mocha",
  16184. "version": "7.2.0",
  16185. "homepage": "https://mochajs.org/",
  16186. "notifyLogo": "https://ibin.co/4QuRuGjXvl36.png"
  16187. }
  16188. },{}]},{},[1]);