mocha.js 490 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046
  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')({level: 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 uncaughtException listener.
  46. */
  47. process.on = function(e, fn) {
  48. if (e === 'uncaughtException') {
  49. global.onerror = function(err, url, line) {
  50. fn(new Error(err + ' (' + url + ':' + line + ')'));
  51. return !mocha.allowUncaught;
  52. };
  53. uncaughtExceptionHandlers.push(fn);
  54. }
  55. };
  56. // The BDD UI is registered by default, but no UI will be functional in the
  57. // browser without an explicit call to the overridden `mocha.ui` (see below).
  58. // Ensure that this default UI does not expose its methods to the global scope.
  59. mocha.suite.removeAllListeners('pre-require');
  60. var immediateQueue = [];
  61. var immediateTimeout;
  62. function timeslice() {
  63. var immediateStart = new Date().getTime();
  64. while (immediateQueue.length && new Date().getTime() - immediateStart < 100) {
  65. immediateQueue.shift()();
  66. }
  67. if (immediateQueue.length) {
  68. immediateTimeout = setTimeout(timeslice, 0);
  69. } else {
  70. immediateTimeout = null;
  71. }
  72. }
  73. /**
  74. * High-performance override of Runner.immediately.
  75. */
  76. Mocha.Runner.immediately = function(callback) {
  77. immediateQueue.push(callback);
  78. if (!immediateTimeout) {
  79. immediateTimeout = setTimeout(timeslice, 0);
  80. }
  81. };
  82. /**
  83. * Function to allow assertion libraries to throw errors directly into mocha.
  84. * This is useful when running tests in a browser because window.onerror will
  85. * only receive the 'message' attribute of the Error.
  86. */
  87. mocha.throwError = function(err) {
  88. uncaughtExceptionHandlers.forEach(function(fn) {
  89. fn(err);
  90. });
  91. throw err;
  92. };
  93. /**
  94. * Override ui to ensure that the ui functions are initialized.
  95. * Normally this would happen in Mocha.prototype.loadFiles.
  96. */
  97. mocha.ui = function(ui) {
  98. Mocha.prototype.ui.call(this, ui);
  99. this.suite.emit('pre-require', global, null, this);
  100. return this;
  101. };
  102. /**
  103. * Setup mocha with the given setting options.
  104. */
  105. mocha.setup = function(opts) {
  106. if (typeof opts === 'string') {
  107. opts = {ui: opts};
  108. }
  109. for (var opt in opts) {
  110. if (opts.hasOwnProperty(opt)) {
  111. this[opt](opts[opt]);
  112. }
  113. }
  114. return this;
  115. };
  116. /**
  117. * Run mocha, returning the Runner.
  118. */
  119. mocha.run = function(fn) {
  120. var options = mocha.options;
  121. mocha.globals('location');
  122. var query = Mocha.utils.parseQuery(global.location.search || '');
  123. if (query.grep) {
  124. mocha.grep(query.grep);
  125. }
  126. if (query.fgrep) {
  127. mocha.fgrep(query.fgrep);
  128. }
  129. if (query.invert) {
  130. mocha.invert();
  131. }
  132. return Mocha.prototype.run.call(mocha, function(err) {
  133. // The DOM Document is not available in Web Workers.
  134. var document = global.document;
  135. if (
  136. document &&
  137. document.getElementById('mocha') &&
  138. options.noHighlighting !== true
  139. ) {
  140. Mocha.utils.highlightTags('code');
  141. }
  142. if (fn) {
  143. fn(err);
  144. }
  145. });
  146. };
  147. /**
  148. * Expose the process shim.
  149. * https://github.com/mochajs/mocha/pull/916
  150. */
  151. Mocha.process = process;
  152. /**
  153. * Expose mocha.
  154. */
  155. global.Mocha = Mocha;
  156. global.mocha = mocha;
  157. // this allows test/acceptance/required-tokens.js to pass; thus,
  158. // you can now do `const describe = require('mocha').describe` in a
  159. // browser context (assuming browserification). should fix #880
  160. module.exports = global;
  161. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  162. },{"./lib/mocha":13,"_process":56,"browser-stdout":39}],2:[function(require,module,exports){
  163. 'use strict';
  164. // just stub out growl
  165. module.exports = require('../utils').noop;
  166. },{"../utils":36}],3:[function(require,module,exports){
  167. 'use strict';
  168. /**
  169. * Expose `Progress`.
  170. */
  171. module.exports = Progress;
  172. /**
  173. * Initialize a new `Progress` indicator.
  174. */
  175. function Progress() {
  176. this.percent = 0;
  177. this.size(0);
  178. this.fontSize(11);
  179. this.font('helvetica, arial, sans-serif');
  180. }
  181. /**
  182. * Set progress size to `size`.
  183. *
  184. * @api public
  185. * @param {number} size
  186. * @return {Progress} Progress instance.
  187. */
  188. Progress.prototype.size = function(size) {
  189. this._size = size;
  190. return this;
  191. };
  192. /**
  193. * Set text to `text`.
  194. *
  195. * @api public
  196. * @param {string} text
  197. * @return {Progress} Progress instance.
  198. */
  199. Progress.prototype.text = function(text) {
  200. this._text = text;
  201. return this;
  202. };
  203. /**
  204. * Set font size to `size`.
  205. *
  206. * @api public
  207. * @param {number} size
  208. * @return {Progress} Progress instance.
  209. */
  210. Progress.prototype.fontSize = function(size) {
  211. this._fontSize = size;
  212. return this;
  213. };
  214. /**
  215. * Set font to `family`.
  216. *
  217. * @param {string} family
  218. * @return {Progress} Progress instance.
  219. */
  220. Progress.prototype.font = function(family) {
  221. this._font = family;
  222. return this;
  223. };
  224. /**
  225. * Update percentage to `n`.
  226. *
  227. * @param {number} n
  228. * @return {Progress} Progress instance.
  229. */
  230. Progress.prototype.update = function(n) {
  231. this.percent = n;
  232. return this;
  233. };
  234. /**
  235. * Draw on `ctx`.
  236. *
  237. * @param {CanvasRenderingContext2d} ctx
  238. * @return {Progress} Progress instance.
  239. */
  240. Progress.prototype.draw = function(ctx) {
  241. try {
  242. var percent = Math.min(this.percent, 100);
  243. var size = this._size;
  244. var half = size / 2;
  245. var x = half;
  246. var y = half;
  247. var rad = half - 1;
  248. var fontSize = this._fontSize;
  249. ctx.font = fontSize + 'px ' + this._font;
  250. var angle = Math.PI * 2 * (percent / 100);
  251. ctx.clearRect(0, 0, size, size);
  252. // outer circle
  253. ctx.strokeStyle = '#9f9f9f';
  254. ctx.beginPath();
  255. ctx.arc(x, y, rad, 0, angle, false);
  256. ctx.stroke();
  257. // inner circle
  258. ctx.strokeStyle = '#eee';
  259. ctx.beginPath();
  260. ctx.arc(x, y, rad - 1, 0, angle, true);
  261. ctx.stroke();
  262. // text
  263. var text = this._text || (percent | 0) + '%';
  264. var w = ctx.measureText(text).width;
  265. ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
  266. } catch (ignore) {
  267. // don't fail if we can't render progress
  268. }
  269. return this;
  270. };
  271. },{}],4:[function(require,module,exports){
  272. (function (global){
  273. 'use strict';
  274. exports.isatty = function isatty() {
  275. return true;
  276. };
  277. exports.getWindowSize = function getWindowSize() {
  278. if ('innerHeight' in global) {
  279. return [global.innerHeight, global.innerWidth];
  280. }
  281. // In a Web Worker, the DOM Window is not available.
  282. return [640, 480];
  283. };
  284. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  285. },{}],5:[function(require,module,exports){
  286. 'use strict';
  287. /**
  288. * @module Context
  289. */
  290. /**
  291. * Expose `Context`.
  292. */
  293. module.exports = Context;
  294. /**
  295. * Initialize a new `Context`.
  296. *
  297. * @api private
  298. */
  299. function Context() {}
  300. /**
  301. * Set or get the context `Runnable` to `runnable`.
  302. *
  303. * @api private
  304. * @param {Runnable} runnable
  305. * @return {Context} context
  306. */
  307. Context.prototype.runnable = function(runnable) {
  308. if (!arguments.length) {
  309. return this._runnable;
  310. }
  311. this.test = this._runnable = runnable;
  312. return this;
  313. };
  314. /**
  315. * Set or get test timeout `ms`.
  316. *
  317. * @api private
  318. * @param {number} ms
  319. * @return {Context} self
  320. */
  321. Context.prototype.timeout = function(ms) {
  322. if (!arguments.length) {
  323. return this.runnable().timeout();
  324. }
  325. this.runnable().timeout(ms);
  326. return this;
  327. };
  328. /**
  329. * Set test timeout `enabled`.
  330. *
  331. * @api private
  332. * @param {boolean} enabled
  333. * @return {Context} self
  334. */
  335. Context.prototype.enableTimeouts = function(enabled) {
  336. if (!arguments.length) {
  337. return this.runnable().enableTimeouts();
  338. }
  339. this.runnable().enableTimeouts(enabled);
  340. return this;
  341. };
  342. /**
  343. * Set or get test slowness threshold `ms`.
  344. *
  345. * @api private
  346. * @param {number} ms
  347. * @return {Context} self
  348. */
  349. Context.prototype.slow = function(ms) {
  350. if (!arguments.length) {
  351. return this.runnable().slow();
  352. }
  353. this.runnable().slow(ms);
  354. return this;
  355. };
  356. /**
  357. * Mark a test as skipped.
  358. *
  359. * @api private
  360. * @throws Pending
  361. */
  362. Context.prototype.skip = function() {
  363. this.runnable().skip();
  364. };
  365. /**
  366. * Set or get a number of allowed retries on failed tests
  367. *
  368. * @api private
  369. * @param {number} n
  370. * @return {Context} self
  371. */
  372. Context.prototype.retries = function(n) {
  373. if (!arguments.length) {
  374. return this.runnable().retries();
  375. }
  376. this.runnable().retries(n);
  377. return this;
  378. };
  379. },{}],6:[function(require,module,exports){
  380. 'use strict';
  381. var Runnable = require('./runnable');
  382. var inherits = require('./utils').inherits;
  383. /**
  384. * Expose `Hook`.
  385. */
  386. module.exports = Hook;
  387. /**
  388. * Initialize a new `Hook` with the given `title` and callback `fn`
  389. *
  390. * @class
  391. * @extends Runnable
  392. * @param {String} title
  393. * @param {Function} fn
  394. */
  395. function Hook(title, fn) {
  396. Runnable.call(this, title, fn);
  397. this.type = 'hook';
  398. }
  399. /**
  400. * Inherit from `Runnable.prototype`.
  401. */
  402. inherits(Hook, Runnable);
  403. /**
  404. * Get or set the test `err`.
  405. *
  406. * @memberof Hook
  407. * @public
  408. * @param {Error} err
  409. * @return {Error}
  410. */
  411. Hook.prototype.error = function(err) {
  412. if (!arguments.length) {
  413. err = this._error;
  414. this._error = null;
  415. return err;
  416. }
  417. this._error = err;
  418. };
  419. },{"./runnable":32,"./utils":36}],7:[function(require,module,exports){
  420. 'use strict';
  421. var Test = require('../test');
  422. /**
  423. * BDD-style interface:
  424. *
  425. * describe('Array', function() {
  426. * describe('#indexOf()', function() {
  427. * it('should return -1 when not present', function() {
  428. * // ...
  429. * });
  430. *
  431. * it('should return the index when present', function() {
  432. * // ...
  433. * });
  434. * });
  435. * });
  436. *
  437. * @param {Suite} suite Root suite.
  438. */
  439. module.exports = function bddInterface(suite) {
  440. var suites = [suite];
  441. suite.on('pre-require', function(context, file, mocha) {
  442. var common = require('./common')(suites, context, mocha);
  443. context.before = common.before;
  444. context.after = common.after;
  445. context.beforeEach = common.beforeEach;
  446. context.afterEach = common.afterEach;
  447. context.run = mocha.options.delay && common.runWithSuite(suite);
  448. /**
  449. * Describe a "suite" with the given `title`
  450. * and callback `fn` containing nested suites
  451. * and/or tests.
  452. */
  453. context.describe = context.context = function(title, fn) {
  454. return common.suite.create({
  455. title: title,
  456. file: file,
  457. fn: fn
  458. });
  459. };
  460. /**
  461. * Pending describe.
  462. */
  463. context.xdescribe = context.xcontext = context.describe.skip = function(
  464. title,
  465. fn
  466. ) {
  467. return common.suite.skip({
  468. title: title,
  469. file: file,
  470. fn: fn
  471. });
  472. };
  473. /**
  474. * Exclusive suite.
  475. */
  476. context.describe.only = function(title, fn) {
  477. return common.suite.only({
  478. title: title,
  479. file: file,
  480. fn: fn
  481. });
  482. };
  483. /**
  484. * Describe a specification or test-case
  485. * with the given `title` and callback `fn`
  486. * acting as a thunk.
  487. */
  488. context.it = context.specify = function(title, fn) {
  489. var suite = suites[0];
  490. if (suite.isPending()) {
  491. fn = null;
  492. }
  493. var test = new Test(title, fn);
  494. test.file = file;
  495. suite.addTest(test);
  496. return test;
  497. };
  498. /**
  499. * Exclusive test-case.
  500. */
  501. context.it.only = function(title, fn) {
  502. return common.test.only(mocha, context.it(title, fn));
  503. };
  504. /**
  505. * Pending test case.
  506. */
  507. context.xit = context.xspecify = context.it.skip = function(title) {
  508. return context.it(title);
  509. };
  510. /**
  511. * Number of attempts to retry.
  512. */
  513. context.it.retries = function(n) {
  514. context.retries(n);
  515. };
  516. });
  517. };
  518. },{"../test":35,"./common":8}],8:[function(require,module,exports){
  519. 'use strict';
  520. var Suite = require('../suite');
  521. /**
  522. * Functions common to more than one interface.
  523. *
  524. * @param {Suite[]} suites
  525. * @param {Context} context
  526. * @param {Mocha} mocha
  527. * @return {Object} An object containing common functions.
  528. */
  529. module.exports = function(suites, context, mocha) {
  530. return {
  531. /**
  532. * This is only present if flag --delay is passed into Mocha. It triggers
  533. * root suite execution.
  534. *
  535. * @param {Suite} suite The root suite.
  536. * @return {Function} A function which runs the root suite
  537. */
  538. runWithSuite: function runWithSuite(suite) {
  539. return function run() {
  540. suite.run();
  541. };
  542. },
  543. /**
  544. * Execute before running tests.
  545. *
  546. * @param {string} name
  547. * @param {Function} fn
  548. */
  549. before: function(name, fn) {
  550. suites[0].beforeAll(name, fn);
  551. },
  552. /**
  553. * Execute after running tests.
  554. *
  555. * @param {string} name
  556. * @param {Function} fn
  557. */
  558. after: function(name, fn) {
  559. suites[0].afterAll(name, fn);
  560. },
  561. /**
  562. * Execute before each test case.
  563. *
  564. * @param {string} name
  565. * @param {Function} fn
  566. */
  567. beforeEach: function(name, fn) {
  568. suites[0].beforeEach(name, fn);
  569. },
  570. /**
  571. * Execute after each test case.
  572. *
  573. * @param {string} name
  574. * @param {Function} fn
  575. */
  576. afterEach: function(name, fn) {
  577. suites[0].afterEach(name, fn);
  578. },
  579. suite: {
  580. /**
  581. * Create an exclusive Suite; convenience function
  582. * See docstring for create() below.
  583. *
  584. * @param {Object} opts
  585. * @returns {Suite}
  586. */
  587. only: function only(opts) {
  588. opts.isOnly = true;
  589. return this.create(opts);
  590. },
  591. /**
  592. * Create a Suite, but skip it; convenience function
  593. * See docstring for create() below.
  594. *
  595. * @param {Object} opts
  596. * @returns {Suite}
  597. */
  598. skip: function skip(opts) {
  599. opts.pending = true;
  600. return this.create(opts);
  601. },
  602. /**
  603. * Creates a suite.
  604. * @param {Object} opts Options
  605. * @param {string} opts.title Title of Suite
  606. * @param {Function} [opts.fn] Suite Function (not always applicable)
  607. * @param {boolean} [opts.pending] Is Suite pending?
  608. * @param {string} [opts.file] Filepath where this Suite resides
  609. * @param {boolean} [opts.isOnly] Is Suite exclusive?
  610. * @returns {Suite}
  611. */
  612. create: function create(opts) {
  613. var suite = Suite.create(suites[0], opts.title);
  614. suite.pending = Boolean(opts.pending);
  615. suite.file = opts.file;
  616. suites.unshift(suite);
  617. if (opts.isOnly) {
  618. suite.parent._onlySuites = suite.parent._onlySuites.concat(suite);
  619. }
  620. if (typeof opts.fn === 'function') {
  621. opts.fn.call(suite);
  622. suites.shift();
  623. } else if (typeof opts.fn === 'undefined' && !suite.pending) {
  624. throw new Error(
  625. 'Suite "' +
  626. suite.fullTitle() +
  627. '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.'
  628. );
  629. } else if (!opts.fn && suite.pending) {
  630. suites.shift();
  631. }
  632. return suite;
  633. }
  634. },
  635. test: {
  636. /**
  637. * Exclusive test-case.
  638. *
  639. * @param {Object} mocha
  640. * @param {Function} test
  641. * @returns {*}
  642. */
  643. only: function(mocha, test) {
  644. test.parent._onlyTests = test.parent._onlyTests.concat(test);
  645. return test;
  646. },
  647. /**
  648. * Pending test case.
  649. *
  650. * @param {string} title
  651. */
  652. skip: function(title) {
  653. context.test(title);
  654. },
  655. /**
  656. * Number of retry attempts
  657. *
  658. * @param {number} n
  659. */
  660. retries: function(n) {
  661. context.retries(n);
  662. }
  663. }
  664. };
  665. };
  666. },{"../suite":34}],9:[function(require,module,exports){
  667. 'use strict';
  668. var Suite = require('../suite');
  669. var Test = require('../test');
  670. /**
  671. * Exports-style (as Node.js module) interface:
  672. *
  673. * exports.Array = {
  674. * '#indexOf()': {
  675. * 'should return -1 when the value is not present': function() {
  676. *
  677. * },
  678. *
  679. * 'should return the correct index when the value is present': function() {
  680. *
  681. * }
  682. * }
  683. * };
  684. *
  685. * @param {Suite} suite Root suite.
  686. */
  687. module.exports = function(suite) {
  688. var suites = [suite];
  689. suite.on('require', visit);
  690. function visit(obj, file) {
  691. var suite;
  692. for (var key in obj) {
  693. if (typeof obj[key] === 'function') {
  694. var fn = obj[key];
  695. switch (key) {
  696. case 'before':
  697. suites[0].beforeAll(fn);
  698. break;
  699. case 'after':
  700. suites[0].afterAll(fn);
  701. break;
  702. case 'beforeEach':
  703. suites[0].beforeEach(fn);
  704. break;
  705. case 'afterEach':
  706. suites[0].afterEach(fn);
  707. break;
  708. default:
  709. var test = new Test(key, fn);
  710. test.file = file;
  711. suites[0].addTest(test);
  712. }
  713. } else {
  714. suite = Suite.create(suites[0], key);
  715. suites.unshift(suite);
  716. visit(obj[key], file);
  717. suites.shift();
  718. }
  719. }
  720. }
  721. };
  722. },{"../suite":34,"../test":35}],10:[function(require,module,exports){
  723. 'use strict';
  724. exports.bdd = require('./bdd');
  725. exports.tdd = require('./tdd');
  726. exports.qunit = require('./qunit');
  727. exports.exports = require('./exports');
  728. },{"./bdd":7,"./exports":9,"./qunit":11,"./tdd":12}],11:[function(require,module,exports){
  729. 'use strict';
  730. var Test = require('../test');
  731. /**
  732. * QUnit-style interface:
  733. *
  734. * suite('Array');
  735. *
  736. * test('#length', function() {
  737. * var arr = [1,2,3];
  738. * ok(arr.length == 3);
  739. * });
  740. *
  741. * test('#indexOf()', function() {
  742. * var arr = [1,2,3];
  743. * ok(arr.indexOf(1) == 0);
  744. * ok(arr.indexOf(2) == 1);
  745. * ok(arr.indexOf(3) == 2);
  746. * });
  747. *
  748. * suite('String');
  749. *
  750. * test('#length', function() {
  751. * ok('foo'.length == 3);
  752. * });
  753. *
  754. * @param {Suite} suite Root suite.
  755. */
  756. module.exports = function qUnitInterface(suite) {
  757. var suites = [suite];
  758. suite.on('pre-require', function(context, file, mocha) {
  759. var common = require('./common')(suites, context, mocha);
  760. context.before = common.before;
  761. context.after = common.after;
  762. context.beforeEach = common.beforeEach;
  763. context.afterEach = common.afterEach;
  764. context.run = mocha.options.delay && common.runWithSuite(suite);
  765. /**
  766. * Describe a "suite" with the given `title`.
  767. */
  768. context.suite = function(title) {
  769. if (suites.length > 1) {
  770. suites.shift();
  771. }
  772. return common.suite.create({
  773. title: title,
  774. file: file,
  775. fn: false
  776. });
  777. };
  778. /**
  779. * Exclusive Suite.
  780. */
  781. context.suite.only = function(title) {
  782. if (suites.length > 1) {
  783. suites.shift();
  784. }
  785. return common.suite.only({
  786. title: title,
  787. file: file,
  788. fn: false
  789. });
  790. };
  791. /**
  792. * Describe a specification or test-case
  793. * with the given `title` and callback `fn`
  794. * acting as a thunk.
  795. */
  796. context.test = function(title, fn) {
  797. var test = new Test(title, fn);
  798. test.file = file;
  799. suites[0].addTest(test);
  800. return test;
  801. };
  802. /**
  803. * Exclusive test-case.
  804. */
  805. context.test.only = function(title, fn) {
  806. return common.test.only(mocha, context.test(title, fn));
  807. };
  808. context.test.skip = common.test.skip;
  809. context.test.retries = common.test.retries;
  810. });
  811. };
  812. },{"../test":35,"./common":8}],12:[function(require,module,exports){
  813. 'use strict';
  814. var Test = require('../test');
  815. /**
  816. * TDD-style interface:
  817. *
  818. * suite('Array', function() {
  819. * suite('#indexOf()', function() {
  820. * suiteSetup(function() {
  821. *
  822. * });
  823. *
  824. * test('should return -1 when not present', function() {
  825. *
  826. * });
  827. *
  828. * test('should return the index when present', function() {
  829. *
  830. * });
  831. *
  832. * suiteTeardown(function() {
  833. *
  834. * });
  835. * });
  836. * });
  837. *
  838. * @param {Suite} suite Root suite.
  839. */
  840. module.exports = function(suite) {
  841. var suites = [suite];
  842. suite.on('pre-require', function(context, file, mocha) {
  843. var common = require('./common')(suites, context, mocha);
  844. context.setup = common.beforeEach;
  845. context.teardown = common.afterEach;
  846. context.suiteSetup = common.before;
  847. context.suiteTeardown = common.after;
  848. context.run = mocha.options.delay && common.runWithSuite(suite);
  849. /**
  850. * Describe a "suite" with the given `title` and callback `fn` containing
  851. * nested suites and/or tests.
  852. */
  853. context.suite = function(title, fn) {
  854. return common.suite.create({
  855. title: title,
  856. file: file,
  857. fn: fn
  858. });
  859. };
  860. /**
  861. * Pending suite.
  862. */
  863. context.suite.skip = function(title, fn) {
  864. return common.suite.skip({
  865. title: title,
  866. file: file,
  867. fn: fn
  868. });
  869. };
  870. /**
  871. * Exclusive test-case.
  872. */
  873. context.suite.only = function(title, fn) {
  874. return common.suite.only({
  875. title: title,
  876. file: file,
  877. fn: fn
  878. });
  879. };
  880. /**
  881. * Describe a specification or test-case with the given `title` and
  882. * callback `fn` acting as a thunk.
  883. */
  884. context.test = function(title, fn) {
  885. var suite = suites[0];
  886. if (suite.isPending()) {
  887. fn = null;
  888. }
  889. var test = new Test(title, fn);
  890. test.file = file;
  891. suite.addTest(test);
  892. return test;
  893. };
  894. /**
  895. * Exclusive test-case.
  896. */
  897. context.test.only = function(title, fn) {
  898. return common.test.only(mocha, context.test(title, fn));
  899. };
  900. context.test.skip = common.test.skip;
  901. context.test.retries = common.test.retries;
  902. });
  903. };
  904. },{"../test":35,"./common":8}],13:[function(require,module,exports){
  905. (function (process,global,__dirname){
  906. 'use strict';
  907. /*!
  908. * mocha
  909. * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
  910. * MIT Licensed
  911. */
  912. var escapeRe = require('escape-string-regexp');
  913. var path = require('path');
  914. var reporters = require('./reporters');
  915. var utils = require('./utils');
  916. exports = module.exports = Mocha;
  917. /**
  918. * To require local UIs and reporters when running in node.
  919. */
  920. if (!process.browser) {
  921. var cwd = process.cwd();
  922. module.paths.push(cwd, path.join(cwd, 'node_modules'));
  923. }
  924. /**
  925. * Expose internals.
  926. */
  927. /**
  928. * @public
  929. * @class utils
  930. * @memberof Mocha
  931. */
  932. exports.utils = utils;
  933. exports.interfaces = require('./interfaces');
  934. /**
  935. *
  936. * @memberof Mocha
  937. * @public
  938. */
  939. exports.reporters = reporters;
  940. exports.Runnable = require('./runnable');
  941. exports.Context = require('./context');
  942. /**
  943. *
  944. * @memberof Mocha
  945. */
  946. exports.Runner = require('./runner');
  947. exports.Suite = require('./suite');
  948. exports.Hook = require('./hook');
  949. exports.Test = require('./test');
  950. /**
  951. * Return image `name` path.
  952. *
  953. * @private
  954. * @param {string} name
  955. * @return {string}
  956. */
  957. function image(name) {
  958. return path.join(__dirname, '..', 'assets', 'growl', name + '.png');
  959. }
  960. /**
  961. * Set up mocha with `options`.
  962. *
  963. * Options:
  964. *
  965. * - `ui` name "bdd", "tdd", "exports" etc
  966. * - `reporter` reporter instance, defaults to `mocha.reporters.spec`
  967. * - `globals` array of accepted globals
  968. * - `timeout` timeout in milliseconds
  969. * - `retries` number of times to retry failed tests
  970. * - `bail` bail on the first test failure
  971. * - `slow` milliseconds to wait before considering a test slow
  972. * - `ignoreLeaks` ignore global leaks
  973. * - `fullTrace` display the full stack-trace on failing
  974. * - `grep` string or regexp to filter tests with
  975. *
  976. * @class Mocha
  977. * @param {Object} options
  978. */
  979. function Mocha(options) {
  980. options = options || {};
  981. this.files = [];
  982. this.options = options;
  983. if (options.grep) {
  984. this.grep(new RegExp(options.grep));
  985. }
  986. if (options.fgrep) {
  987. this.fgrep(options.fgrep);
  988. }
  989. this.suite = new exports.Suite('', new exports.Context());
  990. this.ui(options.ui);
  991. this.bail(options.bail);
  992. this.reporter(options.reporter, options.reporterOptions);
  993. if (typeof options.timeout !== 'undefined' && options.timeout !== null) {
  994. this.timeout(options.timeout);
  995. }
  996. if (typeof options.retries !== 'undefined' && options.retries !== null) {
  997. this.retries(options.retries);
  998. }
  999. this.useColors(options.useColors);
  1000. if (options.enableTimeouts !== null) {
  1001. this.enableTimeouts(options.enableTimeouts);
  1002. }
  1003. if (options.slow) {
  1004. this.slow(options.slow);
  1005. }
  1006. }
  1007. /**
  1008. * Enable or disable bailing on the first failure.
  1009. *
  1010. * @public
  1011. * @api public
  1012. * @param {boolean} [bail]
  1013. */
  1014. Mocha.prototype.bail = function(bail) {
  1015. if (!arguments.length) {
  1016. bail = true;
  1017. }
  1018. this.suite.bail(bail);
  1019. return this;
  1020. };
  1021. /**
  1022. * Add test `file`.
  1023. *
  1024. * @public
  1025. * @api public
  1026. * @param {string} file
  1027. */
  1028. Mocha.prototype.addFile = function(file) {
  1029. this.files.push(file);
  1030. return this;
  1031. };
  1032. /**
  1033. * Set reporter to `reporter`, defaults to "spec".
  1034. *
  1035. * @public
  1036. * @param {String|Function} reporter name or constructor
  1037. * @param {Object} reporterOptions optional options
  1038. * @api public
  1039. * @param {string|Function} reporter name or constructor
  1040. * @param {Object} reporterOptions optional options
  1041. */
  1042. Mocha.prototype.reporter = function(reporter, reporterOptions) {
  1043. if (typeof reporter === 'function') {
  1044. this._reporter = reporter;
  1045. } else {
  1046. reporter = reporter || 'spec';
  1047. var _reporter;
  1048. // Try to load a built-in reporter.
  1049. if (reporters[reporter]) {
  1050. _reporter = reporters[reporter];
  1051. }
  1052. // Try to load reporters from process.cwd() and node_modules
  1053. if (!_reporter) {
  1054. try {
  1055. _reporter = require(reporter);
  1056. } catch (err) {
  1057. if (err.message.indexOf('Cannot find module') !== -1) {
  1058. // Try to load reporters from a path (absolute or relative)
  1059. try {
  1060. _reporter = require(path.resolve(process.cwd(), reporter));
  1061. } catch (_err) {
  1062. err.message.indexOf('Cannot find module') !== -1
  1063. ? console.warn('"' + reporter + '" reporter not found')
  1064. : console.warn(
  1065. '"' +
  1066. reporter +
  1067. '" reporter blew up with error:\n' +
  1068. err.stack
  1069. );
  1070. }
  1071. } else {
  1072. console.warn(
  1073. '"' + reporter + '" reporter blew up with error:\n' + err.stack
  1074. );
  1075. }
  1076. }
  1077. }
  1078. if (!_reporter && reporter === 'teamcity') {
  1079. console.warn(
  1080. 'The Teamcity reporter was moved to a package named ' +
  1081. 'mocha-teamcity-reporter ' +
  1082. '(https://npmjs.org/package/mocha-teamcity-reporter).'
  1083. );
  1084. }
  1085. if (!_reporter) {
  1086. throw new Error('invalid reporter "' + reporter + '"');
  1087. }
  1088. this._reporter = _reporter;
  1089. }
  1090. this.options.reporterOptions = reporterOptions;
  1091. return this;
  1092. };
  1093. /**
  1094. * Set test UI `name`, defaults to "bdd".
  1095. * @public
  1096. * @api public
  1097. * @param {string} bdd
  1098. */
  1099. Mocha.prototype.ui = function(name) {
  1100. name = name || 'bdd';
  1101. this._ui = exports.interfaces[name];
  1102. if (!this._ui) {
  1103. try {
  1104. this._ui = require(name);
  1105. } catch (err) {
  1106. throw new Error('invalid interface "' + name + '"');
  1107. }
  1108. }
  1109. this._ui = this._ui(this.suite);
  1110. this.suite.on('pre-require', function(context) {
  1111. exports.afterEach = context.afterEach || context.teardown;
  1112. exports.after = context.after || context.suiteTeardown;
  1113. exports.beforeEach = context.beforeEach || context.setup;
  1114. exports.before = context.before || context.suiteSetup;
  1115. exports.describe = context.describe || context.suite;
  1116. exports.it = context.it || context.test;
  1117. exports.xit = context.xit || context.test.skip;
  1118. exports.setup = context.setup || context.beforeEach;
  1119. exports.suiteSetup = context.suiteSetup || context.before;
  1120. exports.suiteTeardown = context.suiteTeardown || context.after;
  1121. exports.suite = context.suite || context.describe;
  1122. exports.teardown = context.teardown || context.afterEach;
  1123. exports.test = context.test || context.it;
  1124. exports.run = context.run;
  1125. });
  1126. return this;
  1127. };
  1128. /**
  1129. * Load registered files.
  1130. *
  1131. * @api private
  1132. */
  1133. Mocha.prototype.loadFiles = function(fn) {
  1134. var self = this;
  1135. var suite = this.suite;
  1136. this.files.forEach(function(file) {
  1137. file = path.resolve(file);
  1138. suite.emit('pre-require', global, file, self);
  1139. suite.emit('require', require(file), file, self);
  1140. suite.emit('post-require', global, file, self);
  1141. });
  1142. fn && fn();
  1143. };
  1144. /**
  1145. * Enable growl support.
  1146. *
  1147. * @api private
  1148. */
  1149. Mocha.prototype._growl = function(runner, reporter) {
  1150. var notify = require('growl');
  1151. runner.on('end', function() {
  1152. var stats = reporter.stats;
  1153. if (stats.failures) {
  1154. var msg = stats.failures + ' of ' + runner.total + ' tests failed';
  1155. notify(msg, {name: 'mocha', title: 'Failed', image: image('error')});
  1156. } else {
  1157. notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', {
  1158. name: 'mocha',
  1159. title: 'Passed',
  1160. image: image('ok')
  1161. });
  1162. }
  1163. });
  1164. };
  1165. /**
  1166. * Escape string and add it to grep as a regexp.
  1167. *
  1168. * @public
  1169. * @api public
  1170. * @param str
  1171. * @returns {Mocha}
  1172. */
  1173. Mocha.prototype.fgrep = function(str) {
  1174. return this.grep(new RegExp(escapeRe(str)));
  1175. };
  1176. /**
  1177. * Add regexp to grep, if `re` is a string it is escaped.
  1178. *
  1179. * @public
  1180. * @param {RegExp|String} re
  1181. * @return {Mocha}
  1182. * @api public
  1183. * @param {RegExp|string} re
  1184. * @return {Mocha}
  1185. */
  1186. Mocha.prototype.grep = function(re) {
  1187. if (utils.isString(re)) {
  1188. // extract args if it's regex-like, i.e: [string, pattern, flag]
  1189. var arg = re.match(/^\/(.*)\/(g|i|)$|.*/);
  1190. this.options.grep = new RegExp(arg[1] || arg[0], arg[2]);
  1191. } else {
  1192. this.options.grep = re;
  1193. }
  1194. return this;
  1195. };
  1196. /**
  1197. * Invert `.grep()` matches.
  1198. *
  1199. * @public
  1200. * @return {Mocha}
  1201. * @api public
  1202. */
  1203. Mocha.prototype.invert = function() {
  1204. this.options.invert = true;
  1205. return this;
  1206. };
  1207. /**
  1208. * Ignore global leaks.
  1209. *
  1210. * @public
  1211. * @param {Boolean} ignore
  1212. * @return {Mocha}
  1213. * @api public
  1214. * @param {boolean} ignore
  1215. * @return {Mocha}
  1216. */
  1217. Mocha.prototype.ignoreLeaks = function(ignore) {
  1218. this.options.ignoreLeaks = Boolean(ignore);
  1219. return this;
  1220. };
  1221. /**
  1222. * Enable global leak checking.
  1223. *
  1224. * @return {Mocha}
  1225. * @api public
  1226. * @public
  1227. */
  1228. Mocha.prototype.checkLeaks = function() {
  1229. this.options.ignoreLeaks = false;
  1230. return this;
  1231. };
  1232. /**
  1233. * Display long stack-trace on failing
  1234. *
  1235. * @return {Mocha}
  1236. * @api public
  1237. * @public
  1238. */
  1239. Mocha.prototype.fullTrace = function() {
  1240. this.options.fullStackTrace = true;
  1241. return this;
  1242. };
  1243. /**
  1244. * Enable growl support.
  1245. *
  1246. * @return {Mocha}
  1247. * @api public
  1248. * @public
  1249. */
  1250. Mocha.prototype.growl = function() {
  1251. this.options.growl = true;
  1252. return this;
  1253. };
  1254. /**
  1255. * Ignore `globals` array or string.
  1256. *
  1257. * @param {Array|String} globals
  1258. * @return {Mocha}
  1259. * @api public
  1260. * @public
  1261. * @param {Array|string} globals
  1262. * @return {Mocha}
  1263. */
  1264. Mocha.prototype.globals = function(globals) {
  1265. this.options.globals = (this.options.globals || []).concat(globals);
  1266. return this;
  1267. };
  1268. /**
  1269. * Emit color output.
  1270. *
  1271. * @param {Boolean} colors
  1272. * @return {Mocha}
  1273. * @api public
  1274. * @public
  1275. * @param {boolean} colors
  1276. * @return {Mocha}
  1277. */
  1278. Mocha.prototype.useColors = function(colors) {
  1279. if (colors !== undefined) {
  1280. this.options.useColors = colors;
  1281. }
  1282. return this;
  1283. };
  1284. /**
  1285. * Use inline diffs rather than +/-.
  1286. *
  1287. * @param {Boolean} inlineDiffs
  1288. * @return {Mocha}
  1289. * @api public
  1290. * @public
  1291. * @param {boolean} inlineDiffs
  1292. * @return {Mocha}
  1293. */
  1294. Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
  1295. this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs;
  1296. return this;
  1297. };
  1298. /**
  1299. * Do not show diffs at all.
  1300. *
  1301. * @param {Boolean} hideDiff
  1302. * @return {Mocha}
  1303. * @api public
  1304. * @public
  1305. * @param {boolean} hideDiff
  1306. * @return {Mocha}
  1307. */
  1308. Mocha.prototype.hideDiff = function(hideDiff) {
  1309. this.options.hideDiff = hideDiff !== undefined && hideDiff;
  1310. return this;
  1311. };
  1312. /**
  1313. * Set the timeout in milliseconds.
  1314. *
  1315. * @param {Number} timeout
  1316. * @return {Mocha}
  1317. * @api public
  1318. * @public
  1319. * @param {number} timeout
  1320. * @return {Mocha}
  1321. */
  1322. Mocha.prototype.timeout = function(timeout) {
  1323. this.suite.timeout(timeout);
  1324. return this;
  1325. };
  1326. /**
  1327. * Set the number of times to retry failed tests.
  1328. *
  1329. * @param {Number} retry times
  1330. * @return {Mocha}
  1331. * @api public
  1332. * @public
  1333. */
  1334. Mocha.prototype.retries = function(n) {
  1335. this.suite.retries(n);
  1336. return this;
  1337. };
  1338. /**
  1339. * Set slowness threshold in milliseconds.
  1340. *
  1341. * @param {Number} slow
  1342. * @return {Mocha}
  1343. * @api public
  1344. * @public
  1345. * @param {number} slow
  1346. * @return {Mocha}
  1347. */
  1348. Mocha.prototype.slow = function(slow) {
  1349. this.suite.slow(slow);
  1350. return this;
  1351. };
  1352. /**
  1353. * Enable timeouts.
  1354. *
  1355. * @param {Boolean} enabled
  1356. * @return {Mocha}
  1357. * @api public
  1358. * @public
  1359. * @param {boolean} enabled
  1360. * @return {Mocha}
  1361. */
  1362. Mocha.prototype.enableTimeouts = function(enabled) {
  1363. this.suite.enableTimeouts(
  1364. arguments.length && enabled !== undefined ? enabled : true
  1365. );
  1366. return this;
  1367. };
  1368. /**
  1369. * Makes all tests async (accepting a callback)
  1370. *
  1371. * @return {Mocha}
  1372. * @api public
  1373. * @public
  1374. */
  1375. Mocha.prototype.asyncOnly = function() {
  1376. this.options.asyncOnly = true;
  1377. return this;
  1378. };
  1379. /**
  1380. * Disable syntax highlighting (in browser).
  1381. *
  1382. * @api public
  1383. * @public
  1384. */
  1385. Mocha.prototype.noHighlighting = function() {
  1386. this.options.noHighlighting = true;
  1387. return this;
  1388. };
  1389. /**
  1390. * Enable uncaught errors to propagate (in browser).
  1391. *
  1392. * @return {Mocha}
  1393. * @api public
  1394. * @public
  1395. */
  1396. Mocha.prototype.allowUncaught = function() {
  1397. this.options.allowUncaught = true;
  1398. return this;
  1399. };
  1400. /**
  1401. * Delay root suite execution.
  1402. * @returns {Mocha}
  1403. */
  1404. Mocha.prototype.delay = function delay() {
  1405. this.options.delay = true;
  1406. return this;
  1407. };
  1408. /**
  1409. * Tests marked only fail the suite
  1410. * @returns {Mocha}
  1411. */
  1412. Mocha.prototype.forbidOnly = function() {
  1413. this.options.forbidOnly = true;
  1414. return this;
  1415. };
  1416. /**
  1417. * Pending tests and tests marked skip fail the suite
  1418. * @returns {Mocha}
  1419. */
  1420. Mocha.prototype.forbidPending = function() {
  1421. this.options.forbidPending = true;
  1422. return this;
  1423. };
  1424. /**
  1425. * Run tests and invoke `fn()` when complete.
  1426. *
  1427. * Note that `loadFiles` relies on Node's `require` to execute
  1428. * the test interface functions and will be subject to the
  1429. * cache - if the files are already in the `require` cache,
  1430. * they will effectively be skipped. Therefore, to run tests
  1431. * multiple times or to run tests in files that are already
  1432. * in the `require` cache, make sure to clear them from the
  1433. * cache first in whichever manner best suits your needs.
  1434. *
  1435. * @api public
  1436. * @public
  1437. * @param {Function} fn
  1438. * @return {Runner}
  1439. */
  1440. Mocha.prototype.run = function(fn) {
  1441. if (this.files.length) {
  1442. this.loadFiles();
  1443. }
  1444. var suite = this.suite;
  1445. var options = this.options;
  1446. options.files = this.files;
  1447. var runner = new exports.Runner(suite, options.delay);
  1448. var reporter = new this._reporter(runner, options);
  1449. runner.ignoreLeaks = options.ignoreLeaks !== false;
  1450. runner.fullStackTrace = options.fullStackTrace;
  1451. runner.asyncOnly = options.asyncOnly;
  1452. runner.allowUncaught = options.allowUncaught;
  1453. runner.forbidOnly = options.forbidOnly;
  1454. runner.forbidPending = options.forbidPending;
  1455. if (options.grep) {
  1456. runner.grep(options.grep, options.invert);
  1457. }
  1458. if (options.globals) {
  1459. runner.globals(options.globals);
  1460. }
  1461. if (options.growl) {
  1462. this._growl(runner, reporter);
  1463. }
  1464. if (options.useColors !== undefined) {
  1465. exports.reporters.Base.useColors = options.useColors;
  1466. }
  1467. exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
  1468. exports.reporters.Base.hideDiff = options.hideDiff;
  1469. function done(failures) {
  1470. if (reporter.done) {
  1471. reporter.done(failures, fn);
  1472. } else {
  1473. fn && fn(failures);
  1474. }
  1475. }
  1476. return runner.run(done);
  1477. };
  1478. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},"/lib")
  1479. },{"./context":5,"./hook":6,"./interfaces":10,"./reporters":20,"./runnable":32,"./runner":33,"./suite":34,"./test":35,"./utils":36,"_process":56,"escape-string-regexp":46,"growl":2,"path":40}],14:[function(require,module,exports){
  1480. 'use strict';
  1481. /**
  1482. * @module milliseconds
  1483. */
  1484. /**
  1485. * Helpers.
  1486. */
  1487. var s = 1000;
  1488. var m = s * 60;
  1489. var h = m * 60;
  1490. var d = h * 24;
  1491. var y = d * 365.25;
  1492. /**
  1493. * Parse or format the given `val`.
  1494. *
  1495. * @memberof Mocha
  1496. * @public
  1497. * @api public
  1498. * @param {string|number} val
  1499. * @return {string|number}
  1500. */
  1501. module.exports = function(val) {
  1502. if (typeof val === 'string') {
  1503. return parse(val);
  1504. }
  1505. return format(val);
  1506. };
  1507. /**
  1508. * Parse the given `str` and return milliseconds.
  1509. *
  1510. * @api private
  1511. * @param {string} str
  1512. * @return {number}
  1513. */
  1514. function parse(str) {
  1515. var match = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(
  1516. str
  1517. );
  1518. if (!match) {
  1519. return;
  1520. }
  1521. var n = parseFloat(match[1]);
  1522. var type = (match[2] || 'ms').toLowerCase();
  1523. switch (type) {
  1524. case 'years':
  1525. case 'year':
  1526. case 'y':
  1527. return n * y;
  1528. case 'days':
  1529. case 'day':
  1530. case 'd':
  1531. return n * d;
  1532. case 'hours':
  1533. case 'hour':
  1534. case 'h':
  1535. return n * h;
  1536. case 'minutes':
  1537. case 'minute':
  1538. case 'm':
  1539. return n * m;
  1540. case 'seconds':
  1541. case 'second':
  1542. case 's':
  1543. return n * s;
  1544. case 'ms':
  1545. return n;
  1546. default:
  1547. // No default case
  1548. }
  1549. }
  1550. /**
  1551. * Format for `ms`.
  1552. *
  1553. * @api private
  1554. * @param {number} ms
  1555. * @return {string}
  1556. */
  1557. function format(ms) {
  1558. if (ms >= d) {
  1559. return Math.round(ms / d) + 'd';
  1560. }
  1561. if (ms >= h) {
  1562. return Math.round(ms / h) + 'h';
  1563. }
  1564. if (ms >= m) {
  1565. return Math.round(ms / m) + 'm';
  1566. }
  1567. if (ms >= s) {
  1568. return Math.round(ms / s) + 's';
  1569. }
  1570. return ms + 'ms';
  1571. }
  1572. },{}],15:[function(require,module,exports){
  1573. 'use strict';
  1574. module.exports = Pending;
  1575. /**
  1576. * Initialize a new `Pending` error with the given message.
  1577. *
  1578. * @param {string} message
  1579. */
  1580. function Pending(message) {
  1581. this.message = message;
  1582. }
  1583. },{}],16:[function(require,module,exports){
  1584. (function (process,global){
  1585. 'use strict';
  1586. /**
  1587. * @module Base
  1588. */
  1589. /**
  1590. * Module dependencies.
  1591. */
  1592. var tty = require('tty');
  1593. var diff = require('diff');
  1594. var ms = require('../ms');
  1595. var utils = require('../utils');
  1596. var supportsColor = process.browser ? null : require('supports-color');
  1597. /**
  1598. * Expose `Base`.
  1599. */
  1600. exports = module.exports = Base;
  1601. /**
  1602. * Save timer references to avoid Sinon interfering.
  1603. * See: https://github.com/mochajs/mocha/issues/237
  1604. */
  1605. /* eslint-disable no-unused-vars, no-native-reassign */
  1606. var Date = global.Date;
  1607. var setTimeout = global.setTimeout;
  1608. var setInterval = global.setInterval;
  1609. var clearTimeout = global.clearTimeout;
  1610. var clearInterval = global.clearInterval;
  1611. /* eslint-enable no-unused-vars, no-native-reassign */
  1612. /**
  1613. * Check if both stdio streams are associated with a tty.
  1614. */
  1615. var isatty = tty.isatty(1) && tty.isatty(2);
  1616. /**
  1617. * Enable coloring by default, except in the browser interface.
  1618. */
  1619. exports.useColors =
  1620. !process.browser &&
  1621. (supportsColor.stdout || process.env.MOCHA_COLORS !== undefined);
  1622. /**
  1623. * Inline diffs instead of +/-
  1624. */
  1625. exports.inlineDiffs = false;
  1626. /**
  1627. * Default color map.
  1628. */
  1629. exports.colors = {
  1630. pass: 90,
  1631. fail: 31,
  1632. 'bright pass': 92,
  1633. 'bright fail': 91,
  1634. 'bright yellow': 93,
  1635. pending: 36,
  1636. suite: 0,
  1637. 'error title': 0,
  1638. 'error message': 31,
  1639. 'error stack': 90,
  1640. checkmark: 32,
  1641. fast: 90,
  1642. medium: 33,
  1643. slow: 31,
  1644. green: 32,
  1645. light: 90,
  1646. 'diff gutter': 90,
  1647. 'diff added': 32,
  1648. 'diff removed': 31
  1649. };
  1650. /**
  1651. * Default symbol map.
  1652. */
  1653. exports.symbols = {
  1654. ok: '✓',
  1655. err: '✖',
  1656. dot: '․',
  1657. comma: ',',
  1658. bang: '!'
  1659. };
  1660. // With node.js on Windows: use symbols available in terminal default fonts
  1661. if (process.platform === 'win32') {
  1662. exports.symbols.ok = '\u221A';
  1663. exports.symbols.err = '\u00D7';
  1664. exports.symbols.dot = '.';
  1665. }
  1666. /**
  1667. * Color `str` with the given `type`,
  1668. * allowing colors to be disabled,
  1669. * as well as user-defined color
  1670. * schemes.
  1671. *
  1672. * @param {string} type
  1673. * @param {string} str
  1674. * @return {string}
  1675. * @api private
  1676. */
  1677. var color = (exports.color = function(type, str) {
  1678. if (!exports.useColors) {
  1679. return String(str);
  1680. }
  1681. return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
  1682. });
  1683. /**
  1684. * Expose term window size, with some defaults for when stderr is not a tty.
  1685. */
  1686. exports.window = {
  1687. width: 75
  1688. };
  1689. if (isatty) {
  1690. exports.window.width = process.stdout.getWindowSize
  1691. ? process.stdout.getWindowSize(1)[0]
  1692. : tty.getWindowSize()[1];
  1693. }
  1694. /**
  1695. * Expose some basic cursor interactions that are common among reporters.
  1696. */
  1697. exports.cursor = {
  1698. hide: function() {
  1699. isatty && process.stdout.write('\u001b[?25l');
  1700. },
  1701. show: function() {
  1702. isatty && process.stdout.write('\u001b[?25h');
  1703. },
  1704. deleteLine: function() {
  1705. isatty && process.stdout.write('\u001b[2K');
  1706. },
  1707. beginningOfLine: function() {
  1708. isatty && process.stdout.write('\u001b[0G');
  1709. },
  1710. CR: function() {
  1711. if (isatty) {
  1712. exports.cursor.deleteLine();
  1713. exports.cursor.beginningOfLine();
  1714. } else {
  1715. process.stdout.write('\r');
  1716. }
  1717. }
  1718. };
  1719. function showDiff(err) {
  1720. return (
  1721. err &&
  1722. err.showDiff !== false &&
  1723. sameType(err.actual, err.expected) &&
  1724. err.expected !== undefined
  1725. );
  1726. }
  1727. function stringifyDiffObjs(err) {
  1728. if (!utils.isString(err.actual) || !utils.isString(err.expected)) {
  1729. err.actual = utils.stringify(err.actual);
  1730. err.expected = utils.stringify(err.expected);
  1731. }
  1732. }
  1733. /**
  1734. * Returns a diff between 2 strings with coloured ANSI output.
  1735. *
  1736. * The diff will be either inline or unified dependant on the value
  1737. * of `Base.inlineDiff`.
  1738. *
  1739. * @param {string} actual
  1740. * @param {string} expected
  1741. * @return {string} Diff
  1742. */
  1743. var generateDiff = (exports.generateDiff = function(actual, expected) {
  1744. return exports.inlineDiffs
  1745. ? inlineDiff(actual, expected)
  1746. : unifiedDiff(actual, expected);
  1747. });
  1748. /**
  1749. * Output the given `failures` as a list.
  1750. *
  1751. * @public
  1752. * @memberof Mocha.reporters.Base
  1753. * @variation 1
  1754. * @param {Array} failures
  1755. * @api public
  1756. */
  1757. exports.list = function(failures) {
  1758. console.log();
  1759. failures.forEach(function(test, i) {
  1760. // format
  1761. var fmt =
  1762. color('error title', ' %s) %s:\n') +
  1763. color('error message', ' %s') +
  1764. color('error stack', '\n%s\n');
  1765. // msg
  1766. var msg;
  1767. var err = test.err;
  1768. var message;
  1769. if (err.message && typeof err.message.toString === 'function') {
  1770. message = err.message + '';
  1771. } else if (typeof err.inspect === 'function') {
  1772. message = err.inspect() + '';
  1773. } else {
  1774. message = '';
  1775. }
  1776. var stack = err.stack || message;
  1777. var index = message ? stack.indexOf(message) : -1;
  1778. if (index === -1) {
  1779. msg = message;
  1780. } else {
  1781. index += message.length;
  1782. msg = stack.slice(0, index);
  1783. // remove msg from stack
  1784. stack = stack.slice(index + 1);
  1785. }
  1786. // uncaught
  1787. if (err.uncaught) {
  1788. msg = 'Uncaught ' + msg;
  1789. }
  1790. // explicitly show diff
  1791. if (!exports.hideDiff && showDiff(err)) {
  1792. stringifyDiffObjs(err);
  1793. fmt =
  1794. color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
  1795. var match = message.match(/^([^:]+): expected/);
  1796. msg = '\n ' + color('error message', match ? match[1] : msg);
  1797. msg += generateDiff(err.actual, err.expected);
  1798. }
  1799. // indent stack trace
  1800. stack = stack.replace(/^/gm, ' ');
  1801. // indented test title
  1802. var testTitle = '';
  1803. test.titlePath().forEach(function(str, index) {
  1804. if (index !== 0) {
  1805. testTitle += '\n ';
  1806. }
  1807. for (var i = 0; i < index; i++) {
  1808. testTitle += ' ';
  1809. }
  1810. testTitle += str;
  1811. });
  1812. console.log(fmt, i + 1, testTitle, msg, stack);
  1813. });
  1814. };
  1815. /**
  1816. * Initialize a new `Base` reporter.
  1817. *
  1818. * All other reporters generally
  1819. * inherit from this reporter, providing
  1820. * stats such as test duration, number
  1821. * of tests passed / failed etc.
  1822. *
  1823. * @memberof Mocha.reporters
  1824. * @public
  1825. * @class
  1826. * @param {Runner} runner
  1827. * @api public
  1828. */
  1829. function Base(runner) {
  1830. var stats = (this.stats = {
  1831. suites: 0,
  1832. tests: 0,
  1833. passes: 0,
  1834. pending: 0,
  1835. failures: 0
  1836. });
  1837. var failures = (this.failures = []);
  1838. if (!runner) {
  1839. return;
  1840. }
  1841. this.runner = runner;
  1842. runner.stats = stats;
  1843. runner.on('start', function() {
  1844. stats.start = new Date();
  1845. });
  1846. runner.on('suite', function(suite) {
  1847. stats.suites = stats.suites || 0;
  1848. suite.root || stats.suites++;
  1849. });
  1850. runner.on('test end', function() {
  1851. stats.tests = stats.tests || 0;
  1852. stats.tests++;
  1853. });
  1854. runner.on('pass', function(test) {
  1855. stats.passes = stats.passes || 0;
  1856. if (test.duration > test.slow()) {
  1857. test.speed = 'slow';
  1858. } else if (test.duration > test.slow() / 2) {
  1859. test.speed = 'medium';
  1860. } else {
  1861. test.speed = 'fast';
  1862. }
  1863. stats.passes++;
  1864. });
  1865. runner.on('fail', function(test, err) {
  1866. stats.failures = stats.failures || 0;
  1867. stats.failures++;
  1868. if (showDiff(err)) {
  1869. stringifyDiffObjs(err);
  1870. }
  1871. test.err = err;
  1872. failures.push(test);
  1873. });
  1874. runner.once('end', function() {
  1875. stats.end = new Date();
  1876. stats.duration = stats.end - stats.start;
  1877. });
  1878. runner.on('pending', function() {
  1879. stats.pending++;
  1880. });
  1881. }
  1882. /**
  1883. * Output common epilogue used by many of
  1884. * the bundled reporters.
  1885. *
  1886. * @memberof Mocha.reporters.Base
  1887. * @public
  1888. * @api public
  1889. */
  1890. Base.prototype.epilogue = function() {
  1891. var stats = this.stats;
  1892. var fmt;
  1893. console.log();
  1894. // passes
  1895. fmt =
  1896. color('bright pass', ' ') +
  1897. color('green', ' %d passing') +
  1898. color('light', ' (%s)');
  1899. console.log(fmt, stats.passes || 0, ms(stats.duration));
  1900. // pending
  1901. if (stats.pending) {
  1902. fmt = color('pending', ' ') + color('pending', ' %d pending');
  1903. console.log(fmt, stats.pending);
  1904. }
  1905. // failures
  1906. if (stats.failures) {
  1907. fmt = color('fail', ' %d failing');
  1908. console.log(fmt, stats.failures);
  1909. Base.list(this.failures);
  1910. console.log();
  1911. }
  1912. console.log();
  1913. };
  1914. /**
  1915. * Pad the given `str` to `len`.
  1916. *
  1917. * @api private
  1918. * @param {string} str
  1919. * @param {string} len
  1920. * @return {string}
  1921. */
  1922. function pad(str, len) {
  1923. str = String(str);
  1924. return Array(len - str.length + 1).join(' ') + str;
  1925. }
  1926. /**
  1927. * Returns an inline diff between 2 strings with coloured ANSI output.
  1928. *
  1929. * @api private
  1930. * @param {String} actual
  1931. * @param {String} expected
  1932. * @return {string} Diff
  1933. */
  1934. function inlineDiff(actual, expected) {
  1935. var msg = errorDiff(actual, expected);
  1936. // linenos
  1937. var lines = msg.split('\n');
  1938. if (lines.length > 4) {
  1939. var width = String(lines.length).length;
  1940. msg = lines
  1941. .map(function(str, i) {
  1942. return pad(++i, width) + ' |' + ' ' + str;
  1943. })
  1944. .join('\n');
  1945. }
  1946. // legend
  1947. msg =
  1948. '\n' +
  1949. color('diff removed', 'actual') +
  1950. ' ' +
  1951. color('diff added', 'expected') +
  1952. '\n\n' +
  1953. msg +
  1954. '\n';
  1955. // indent
  1956. msg = msg.replace(/^/gm, ' ');
  1957. return msg;
  1958. }
  1959. /**
  1960. * Returns a unified diff between two strings with coloured ANSI output.
  1961. *
  1962. * @api private
  1963. * @param {String} actual
  1964. * @param {String} expected
  1965. * @return {string} The diff.
  1966. */
  1967. function unifiedDiff(actual, expected) {
  1968. var indent = ' ';
  1969. function cleanUp(line) {
  1970. if (line[0] === '+') {
  1971. return indent + colorLines('diff added', line);
  1972. }
  1973. if (line[0] === '-') {
  1974. return indent + colorLines('diff removed', line);
  1975. }
  1976. if (line.match(/@@/)) {
  1977. return '--';
  1978. }
  1979. if (line.match(/\\ No newline/)) {
  1980. return null;
  1981. }
  1982. return indent + line;
  1983. }
  1984. function notBlank(line) {
  1985. return typeof line !== 'undefined' && line !== null;
  1986. }
  1987. var msg = diff.createPatch('string', actual, expected);
  1988. var lines = msg.split('\n').splice(5);
  1989. return (
  1990. '\n ' +
  1991. colorLines('diff added', '+ expected') +
  1992. ' ' +
  1993. colorLines('diff removed', '- actual') +
  1994. '\n\n' +
  1995. lines
  1996. .map(cleanUp)
  1997. .filter(notBlank)
  1998. .join('\n')
  1999. );
  2000. }
  2001. /**
  2002. * Return a character diff for `err`.
  2003. *
  2004. * @api private
  2005. * @param {String} actual
  2006. * @param {String} expected
  2007. * @return {string} the diff
  2008. */
  2009. function errorDiff(actual, expected) {
  2010. return diff
  2011. .diffWordsWithSpace(actual, expected)
  2012. .map(function(str) {
  2013. if (str.added) {
  2014. return colorLines('diff added', str.value);
  2015. }
  2016. if (str.removed) {
  2017. return colorLines('diff removed', str.value);
  2018. }
  2019. return str.value;
  2020. })
  2021. .join('');
  2022. }
  2023. /**
  2024. * Color lines for `str`, using the color `name`.
  2025. *
  2026. * @api private
  2027. * @param {string} name
  2028. * @param {string} str
  2029. * @return {string}
  2030. */
  2031. function colorLines(name, str) {
  2032. return str
  2033. .split('\n')
  2034. .map(function(str) {
  2035. return color(name, str);
  2036. })
  2037. .join('\n');
  2038. }
  2039. /**
  2040. * Object#toString reference.
  2041. */
  2042. var objToString = Object.prototype.toString;
  2043. /**
  2044. * Check that a / b have the same type.
  2045. *
  2046. * @api private
  2047. * @param {Object} a
  2048. * @param {Object} b
  2049. * @return {boolean}
  2050. */
  2051. function sameType(a, b) {
  2052. return objToString.call(a) === objToString.call(b);
  2053. }
  2054. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2055. },{"../ms":14,"../utils":36,"_process":56,"diff":45,"supports-color":40,"tty":4}],17:[function(require,module,exports){
  2056. 'use strict';
  2057. /**
  2058. * @module Doc
  2059. */
  2060. /**
  2061. * Module dependencies.
  2062. */
  2063. var Base = require('./base');
  2064. var utils = require('../utils');
  2065. /**
  2066. * Expose `Doc`.
  2067. */
  2068. exports = module.exports = Doc;
  2069. /**
  2070. * Initialize a new `Doc` reporter.
  2071. *
  2072. * @class
  2073. * @memberof Mocha.reporters
  2074. * @extends {Base}
  2075. * @public
  2076. * @param {Runner} runner
  2077. * @api public
  2078. */
  2079. function Doc(runner) {
  2080. Base.call(this, runner);
  2081. var indents = 2;
  2082. function indent() {
  2083. return Array(indents).join(' ');
  2084. }
  2085. runner.on('suite', function(suite) {
  2086. if (suite.root) {
  2087. return;
  2088. }
  2089. ++indents;
  2090. console.log('%s<section class="suite">', indent());
  2091. ++indents;
  2092. console.log('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
  2093. console.log('%s<dl>', indent());
  2094. });
  2095. runner.on('suite end', function(suite) {
  2096. if (suite.root) {
  2097. return;
  2098. }
  2099. console.log('%s</dl>', indent());
  2100. --indents;
  2101. console.log('%s</section>', indent());
  2102. --indents;
  2103. });
  2104. runner.on('pass', function(test) {
  2105. console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title));
  2106. var code = utils.escape(utils.clean(test.body));
  2107. console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
  2108. });
  2109. runner.on('fail', function(test, err) {
  2110. console.log(
  2111. '%s <dt class="error">%s</dt>',
  2112. indent(),
  2113. utils.escape(test.title)
  2114. );
  2115. var code = utils.escape(utils.clean(test.body));
  2116. console.log(
  2117. '%s <dd class="error"><pre><code>%s</code></pre></dd>',
  2118. indent(),
  2119. code
  2120. );
  2121. console.log('%s <dd class="error">%s</dd>', indent(), utils.escape(err));
  2122. });
  2123. }
  2124. },{"../utils":36,"./base":16}],18:[function(require,module,exports){
  2125. (function (process){
  2126. 'use strict';
  2127. /**
  2128. * @module Dot
  2129. */
  2130. /**
  2131. * Module dependencies.
  2132. */
  2133. var Base = require('./base');
  2134. var inherits = require('../utils').inherits;
  2135. var color = Base.color;
  2136. /**
  2137. * Expose `Dot`.
  2138. */
  2139. exports = module.exports = Dot;
  2140. /**
  2141. * Initialize a new `Dot` matrix test reporter.
  2142. *
  2143. * @class
  2144. * @memberof Mocha.reporters
  2145. * @extends Mocha.reporters.Base
  2146. * @public
  2147. * @api public
  2148. * @param {Runner} runner
  2149. */
  2150. function Dot(runner) {
  2151. Base.call(this, runner);
  2152. var self = this;
  2153. var width = (Base.window.width * 0.75) | 0;
  2154. var n = -1;
  2155. runner.on('start', function() {
  2156. process.stdout.write('\n');
  2157. });
  2158. runner.on('pending', function() {
  2159. if (++n % width === 0) {
  2160. process.stdout.write('\n ');
  2161. }
  2162. process.stdout.write(color('pending', Base.symbols.comma));
  2163. });
  2164. runner.on('pass', function(test) {
  2165. if (++n % width === 0) {
  2166. process.stdout.write('\n ');
  2167. }
  2168. if (test.speed === 'slow') {
  2169. process.stdout.write(color('bright yellow', Base.symbols.dot));
  2170. } else {
  2171. process.stdout.write(color(test.speed, Base.symbols.dot));
  2172. }
  2173. });
  2174. runner.on('fail', function() {
  2175. if (++n % width === 0) {
  2176. process.stdout.write('\n ');
  2177. }
  2178. process.stdout.write(color('fail', Base.symbols.bang));
  2179. });
  2180. runner.once('end', function() {
  2181. console.log();
  2182. self.epilogue();
  2183. });
  2184. }
  2185. /**
  2186. * Inherit from `Base.prototype`.
  2187. */
  2188. inherits(Dot, Base);
  2189. }).call(this,require('_process'))
  2190. },{"../utils":36,"./base":16,"_process":56}],19:[function(require,module,exports){
  2191. (function (global){
  2192. 'use strict';
  2193. /* eslint-env browser */
  2194. /**
  2195. * @module HTML
  2196. */
  2197. /**
  2198. * Module dependencies.
  2199. */
  2200. var Base = require('./base');
  2201. var utils = require('../utils');
  2202. var Progress = require('../browser/progress');
  2203. var escapeRe = require('escape-string-regexp');
  2204. var escape = utils.escape;
  2205. /**
  2206. * Save timer references to avoid Sinon interfering (see GH-237).
  2207. */
  2208. /* eslint-disable no-unused-vars, no-native-reassign */
  2209. var Date = global.Date;
  2210. var setTimeout = global.setTimeout;
  2211. var setInterval = global.setInterval;
  2212. var clearTimeout = global.clearTimeout;
  2213. var clearInterval = global.clearInterval;
  2214. /* eslint-enable no-unused-vars, no-native-reassign */
  2215. /**
  2216. * Expose `HTML`.
  2217. */
  2218. exports = module.exports = HTML;
  2219. /**
  2220. * Stats template.
  2221. */
  2222. var statsTemplate =
  2223. '<ul id="mocha-stats">' +
  2224. '<li class="progress"><canvas width="40" height="40"></canvas></li>' +
  2225. '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
  2226. '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
  2227. '<li class="duration">duration: <em>0</em>s</li>' +
  2228. '</ul>';
  2229. var playIcon = '&#x2023;';
  2230. /**
  2231. * Initialize a new `HTML` reporter.
  2232. *
  2233. * @public
  2234. * @class
  2235. * @memberof Mocha.reporters
  2236. * @extends Mocha.reporters.Base
  2237. * @api public
  2238. * @param {Runner} runner
  2239. */
  2240. function HTML(runner) {
  2241. Base.call(this, runner);
  2242. var self = this;
  2243. var stats = this.stats;
  2244. var stat = fragment(statsTemplate);
  2245. var items = stat.getElementsByTagName('li');
  2246. var passes = items[1].getElementsByTagName('em')[0];
  2247. var passesLink = items[1].getElementsByTagName('a')[0];
  2248. var failures = items[2].getElementsByTagName('em')[0];
  2249. var failuresLink = items[2].getElementsByTagName('a')[0];
  2250. var duration = items[3].getElementsByTagName('em')[0];
  2251. var canvas = stat.getElementsByTagName('canvas')[0];
  2252. var report = fragment('<ul id="mocha-report"></ul>');
  2253. var stack = [report];
  2254. var progress;
  2255. var ctx;
  2256. var root = document.getElementById('mocha');
  2257. if (canvas.getContext) {
  2258. var ratio = window.devicePixelRatio || 1;
  2259. canvas.style.width = canvas.width;
  2260. canvas.style.height = canvas.height;
  2261. canvas.width *= ratio;
  2262. canvas.height *= ratio;
  2263. ctx = canvas.getContext('2d');
  2264. ctx.scale(ratio, ratio);
  2265. progress = new Progress();
  2266. }
  2267. if (!root) {
  2268. return error('#mocha div missing, add it to your document');
  2269. }
  2270. // pass toggle
  2271. on(passesLink, 'click', function(evt) {
  2272. evt.preventDefault();
  2273. unhide();
  2274. var name = /pass/.test(report.className) ? '' : ' pass';
  2275. report.className = report.className.replace(/fail|pass/g, '') + name;
  2276. if (report.className.trim()) {
  2277. hideSuitesWithout('test pass');
  2278. }
  2279. });
  2280. // failure toggle
  2281. on(failuresLink, 'click', function(evt) {
  2282. evt.preventDefault();
  2283. unhide();
  2284. var name = /fail/.test(report.className) ? '' : ' fail';
  2285. report.className = report.className.replace(/fail|pass/g, '') + name;
  2286. if (report.className.trim()) {
  2287. hideSuitesWithout('test fail');
  2288. }
  2289. });
  2290. root.appendChild(stat);
  2291. root.appendChild(report);
  2292. if (progress) {
  2293. progress.size(40);
  2294. }
  2295. runner.on('suite', function(suite) {
  2296. if (suite.root) {
  2297. return;
  2298. }
  2299. // suite
  2300. var url = self.suiteURL(suite);
  2301. var el = fragment(
  2302. '<li class="suite"><h1><a href="%s">%s</a></h1></li>',
  2303. url,
  2304. escape(suite.title)
  2305. );
  2306. // container
  2307. stack[0].appendChild(el);
  2308. stack.unshift(document.createElement('ul'));
  2309. el.appendChild(stack[0]);
  2310. });
  2311. runner.on('suite end', function(suite) {
  2312. if (suite.root) {
  2313. updateStats();
  2314. return;
  2315. }
  2316. stack.shift();
  2317. });
  2318. runner.on('pass', function(test) {
  2319. var url = self.testURL(test);
  2320. var markup =
  2321. '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
  2322. '<a href="%s" class="replay">' +
  2323. playIcon +
  2324. '</a></h2></li>';
  2325. var el = fragment(markup, test.speed, test.title, test.duration, url);
  2326. self.addCodeToggle(el, test.body);
  2327. appendToStack(el);
  2328. updateStats();
  2329. });
  2330. runner.on('fail', function(test) {
  2331. var el = fragment(
  2332. '<li class="test fail"><h2>%e <a href="%e" class="replay">' +
  2333. playIcon +
  2334. '</a></h2></li>',
  2335. test.title,
  2336. self.testURL(test)
  2337. );
  2338. var stackString; // Note: Includes leading newline
  2339. var message = test.err.toString();
  2340. // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
  2341. // check for the result of the stringifying.
  2342. if (message === '[object Error]') {
  2343. message = test.err.message;
  2344. }
  2345. if (test.err.stack) {
  2346. var indexOfMessage = test.err.stack.indexOf(test.err.message);
  2347. if (indexOfMessage === -1) {
  2348. stackString = test.err.stack;
  2349. } else {
  2350. stackString = test.err.stack.substr(
  2351. test.err.message.length + indexOfMessage
  2352. );
  2353. }
  2354. } else if (test.err.sourceURL && test.err.line !== undefined) {
  2355. // Safari doesn't give you a stack. Let's at least provide a source line.
  2356. stackString = '\n(' + test.err.sourceURL + ':' + test.err.line + ')';
  2357. }
  2358. stackString = stackString || '';
  2359. if (test.err.htmlMessage && stackString) {
  2360. el.appendChild(
  2361. fragment(
  2362. '<div class="html-error">%s\n<pre class="error">%e</pre></div>',
  2363. test.err.htmlMessage,
  2364. stackString
  2365. )
  2366. );
  2367. } else if (test.err.htmlMessage) {
  2368. el.appendChild(
  2369. fragment('<div class="html-error">%s</div>', test.err.htmlMessage)
  2370. );
  2371. } else {
  2372. el.appendChild(
  2373. fragment('<pre class="error">%e%e</pre>', message, stackString)
  2374. );
  2375. }
  2376. self.addCodeToggle(el, test.body);
  2377. appendToStack(el);
  2378. updateStats();
  2379. });
  2380. runner.on('pending', function(test) {
  2381. var el = fragment(
  2382. '<li class="test pass pending"><h2>%e</h2></li>',
  2383. test.title
  2384. );
  2385. appendToStack(el);
  2386. updateStats();
  2387. });
  2388. function appendToStack(el) {
  2389. // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
  2390. if (stack[0]) {
  2391. stack[0].appendChild(el);
  2392. }
  2393. }
  2394. function updateStats() {
  2395. // TODO: add to stats
  2396. var percent = (stats.tests / runner.total * 100) | 0;
  2397. if (progress) {
  2398. progress.update(percent).draw(ctx);
  2399. }
  2400. // update stats
  2401. var ms = new Date() - stats.start;
  2402. text(passes, stats.passes);
  2403. text(failures, stats.failures);
  2404. text(duration, (ms / 1000).toFixed(2));
  2405. }
  2406. }
  2407. /**
  2408. * Makes a URL, preserving querystring ("search") parameters.
  2409. *
  2410. * @param {string} s
  2411. * @return {string} A new URL.
  2412. */
  2413. function makeUrl(s) {
  2414. var search = window.location.search;
  2415. // Remove previous grep query parameter if present
  2416. if (search) {
  2417. search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
  2418. }
  2419. return (
  2420. window.location.pathname +
  2421. (search ? search + '&' : '?') +
  2422. 'grep=' +
  2423. encodeURIComponent(escapeRe(s))
  2424. );
  2425. }
  2426. /**
  2427. * Provide suite URL.
  2428. *
  2429. * @param {Object} [suite]
  2430. */
  2431. HTML.prototype.suiteURL = function(suite) {
  2432. return makeUrl(suite.fullTitle());
  2433. };
  2434. /**
  2435. * Provide test URL.
  2436. *
  2437. * @param {Object} [test]
  2438. */
  2439. HTML.prototype.testURL = function(test) {
  2440. return makeUrl(test.fullTitle());
  2441. };
  2442. /**
  2443. * Adds code toggle functionality for the provided test's list element.
  2444. *
  2445. * @param {HTMLLIElement} el
  2446. * @param {string} contents
  2447. */
  2448. HTML.prototype.addCodeToggle = function(el, contents) {
  2449. var h2 = el.getElementsByTagName('h2')[0];
  2450. on(h2, 'click', function() {
  2451. pre.style.display = pre.style.display === 'none' ? 'block' : 'none';
  2452. });
  2453. var pre = fragment('<pre><code>%e</code></pre>', utils.clean(contents));
  2454. el.appendChild(pre);
  2455. pre.style.display = 'none';
  2456. };
  2457. /**
  2458. * Display error `msg`.
  2459. *
  2460. * @param {string} msg
  2461. */
  2462. function error(msg) {
  2463. document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));
  2464. }
  2465. /**
  2466. * Return a DOM fragment from `html`.
  2467. *
  2468. * @param {string} html
  2469. */
  2470. function fragment(html) {
  2471. var args = arguments;
  2472. var div = document.createElement('div');
  2473. var i = 1;
  2474. div.innerHTML = html.replace(/%([se])/g, function(_, type) {
  2475. switch (type) {
  2476. case 's':
  2477. return String(args[i++]);
  2478. case 'e':
  2479. return escape(args[i++]);
  2480. // no default
  2481. }
  2482. });
  2483. return div.firstChild;
  2484. }
  2485. /**
  2486. * Check for suites that do not have elements
  2487. * with `classname`, and hide them.
  2488. *
  2489. * @param {text} classname
  2490. */
  2491. function hideSuitesWithout(classname) {
  2492. var suites = document.getElementsByClassName('suite');
  2493. for (var i = 0; i < suites.length; i++) {
  2494. var els = suites[i].getElementsByClassName(classname);
  2495. if (!els.length) {
  2496. suites[i].className += ' hidden';
  2497. }
  2498. }
  2499. }
  2500. /**
  2501. * Unhide .hidden suites.
  2502. */
  2503. function unhide() {
  2504. var els = document.getElementsByClassName('suite hidden');
  2505. for (var i = 0; i < els.length; ++i) {
  2506. els[i].className = els[i].className.replace('suite hidden', 'suite');
  2507. }
  2508. }
  2509. /**
  2510. * Set an element's text contents.
  2511. *
  2512. * @param {HTMLElement} el
  2513. * @param {string} contents
  2514. */
  2515. function text(el, contents) {
  2516. if (el.textContent) {
  2517. el.textContent = contents;
  2518. } else {
  2519. el.innerText = contents;
  2520. }
  2521. }
  2522. /**
  2523. * Listen on `event` with callback `fn`.
  2524. */
  2525. function on(el, event, fn) {
  2526. if (el.addEventListener) {
  2527. el.addEventListener(event, fn, false);
  2528. } else {
  2529. el.attachEvent('on' + event, fn);
  2530. }
  2531. }
  2532. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2533. },{"../browser/progress":3,"../utils":36,"./base":16,"escape-string-regexp":46}],20:[function(require,module,exports){
  2534. 'use strict';
  2535. // Alias exports to a their normalized format Mocha#reporter to prevent a need
  2536. // for dynamic (try/catch) requires, which Browserify doesn't handle.
  2537. exports.Base = exports.base = require('./base');
  2538. exports.Dot = exports.dot = require('./dot');
  2539. exports.Doc = exports.doc = require('./doc');
  2540. exports.TAP = exports.tap = require('./tap');
  2541. exports.JSON = exports.json = require('./json');
  2542. exports.HTML = exports.html = require('./html');
  2543. exports.List = exports.list = require('./list');
  2544. exports.Min = exports.min = require('./min');
  2545. exports.Spec = exports.spec = require('./spec');
  2546. exports.Nyan = exports.nyan = require('./nyan');
  2547. exports.XUnit = exports.xunit = require('./xunit');
  2548. exports.Markdown = exports.markdown = require('./markdown');
  2549. exports.Progress = exports.progress = require('./progress');
  2550. exports.Landing = exports.landing = require('./landing');
  2551. exports.JSONStream = exports['json-stream'] = require('./json-stream');
  2552. },{"./base":16,"./doc":17,"./dot":18,"./html":19,"./json":22,"./json-stream":21,"./landing":23,"./list":24,"./markdown":25,"./min":26,"./nyan":27,"./progress":28,"./spec":29,"./tap":30,"./xunit":31}],21:[function(require,module,exports){
  2553. (function (process){
  2554. 'use strict';
  2555. /**
  2556. * @module JSONStream
  2557. */
  2558. /**
  2559. * Module dependencies.
  2560. */
  2561. var Base = require('./base');
  2562. /**
  2563. * Expose `List`.
  2564. */
  2565. exports = module.exports = List;
  2566. /**
  2567. * Initialize a new `JSONStream` test reporter.
  2568. *
  2569. * @public
  2570. * @name JSONStream
  2571. * @class JSONStream
  2572. * @memberof Mocha.reporters
  2573. * @extends Mocha.reporters.Base
  2574. * @api public
  2575. * @param {Runner} runner
  2576. */
  2577. function List(runner) {
  2578. Base.call(this, runner);
  2579. var self = this;
  2580. var total = runner.total;
  2581. runner.on('start', function() {
  2582. console.log(JSON.stringify(['start', {total: total}]));
  2583. });
  2584. runner.on('pass', function(test) {
  2585. console.log(JSON.stringify(['pass', clean(test)]));
  2586. });
  2587. runner.on('fail', function(test, err) {
  2588. test = clean(test);
  2589. test.err = err.message;
  2590. test.stack = err.stack || null;
  2591. console.log(JSON.stringify(['fail', test]));
  2592. });
  2593. runner.once('end', function() {
  2594. process.stdout.write(JSON.stringify(['end', self.stats]));
  2595. });
  2596. }
  2597. /**
  2598. * Return a plain-object representation of `test`
  2599. * free of cyclic properties etc.
  2600. *
  2601. * @api private
  2602. * @param {Object} test
  2603. * @return {Object}
  2604. */
  2605. function clean(test) {
  2606. return {
  2607. title: test.title,
  2608. fullTitle: test.fullTitle(),
  2609. duration: test.duration,
  2610. currentRetry: test.currentRetry()
  2611. };
  2612. }
  2613. }).call(this,require('_process'))
  2614. },{"./base":16,"_process":56}],22:[function(require,module,exports){
  2615. (function (process){
  2616. 'use strict';
  2617. /**
  2618. * @module JSON
  2619. */
  2620. /**
  2621. * Module dependencies.
  2622. */
  2623. var Base = require('./base');
  2624. /**
  2625. * Expose `JSON`.
  2626. */
  2627. exports = module.exports = JSONReporter;
  2628. /**
  2629. * Initialize a new `JSON` reporter.
  2630. *
  2631. * @public
  2632. * @class JSON
  2633. * @memberof Mocha.reporters
  2634. * @extends Mocha.reporters.Base
  2635. * @api public
  2636. * @param {Runner} runner
  2637. */
  2638. function JSONReporter(runner) {
  2639. Base.call(this, runner);
  2640. var self = this;
  2641. var tests = [];
  2642. var pending = [];
  2643. var failures = [];
  2644. var passes = [];
  2645. runner.on('test end', function(test) {
  2646. tests.push(test);
  2647. });
  2648. runner.on('pass', function(test) {
  2649. passes.push(test);
  2650. });
  2651. runner.on('fail', function(test) {
  2652. failures.push(test);
  2653. });
  2654. runner.on('pending', function(test) {
  2655. pending.push(test);
  2656. });
  2657. runner.once('end', function() {
  2658. var obj = {
  2659. stats: self.stats,
  2660. tests: tests.map(clean),
  2661. pending: pending.map(clean),
  2662. failures: failures.map(clean),
  2663. passes: passes.map(clean)
  2664. };
  2665. runner.testResults = obj;
  2666. process.stdout.write(JSON.stringify(obj, null, 2));
  2667. });
  2668. }
  2669. /**
  2670. * Return a plain-object representation of `test`
  2671. * free of cyclic properties etc.
  2672. *
  2673. * @api private
  2674. * @param {Object} test
  2675. * @return {Object}
  2676. */
  2677. function clean(test) {
  2678. var err = test.err || {};
  2679. if (err instanceof Error) {
  2680. err = errorJSON(err);
  2681. }
  2682. return {
  2683. title: test.title,
  2684. fullTitle: test.fullTitle(),
  2685. duration: test.duration,
  2686. currentRetry: test.currentRetry(),
  2687. err: cleanCycles(err)
  2688. };
  2689. }
  2690. /**
  2691. * Replaces any circular references inside `obj` with '[object Object]'
  2692. *
  2693. * @api private
  2694. * @param {Object} obj
  2695. * @return {Object}
  2696. */
  2697. function cleanCycles(obj) {
  2698. var cache = [];
  2699. return JSON.parse(
  2700. JSON.stringify(obj, function(key, value) {
  2701. if (typeof value === 'object' && value !== null) {
  2702. if (cache.indexOf(value) !== -1) {
  2703. // Instead of going in a circle, we'll print [object Object]
  2704. return '' + value;
  2705. }
  2706. cache.push(value);
  2707. }
  2708. return value;
  2709. })
  2710. );
  2711. }
  2712. /**
  2713. * Transform an Error object into a JSON object.
  2714. *
  2715. * @api private
  2716. * @param {Error} err
  2717. * @return {Object}
  2718. */
  2719. function errorJSON(err) {
  2720. var res = {};
  2721. Object.getOwnPropertyNames(err).forEach(function(key) {
  2722. res[key] = err[key];
  2723. }, err);
  2724. return res;
  2725. }
  2726. }).call(this,require('_process'))
  2727. },{"./base":16,"_process":56}],23:[function(require,module,exports){
  2728. (function (process){
  2729. 'use strict';
  2730. /**
  2731. * @module Landing
  2732. */
  2733. /**
  2734. * Module dependencies.
  2735. */
  2736. var Base = require('./base');
  2737. var inherits = require('../utils').inherits;
  2738. var cursor = Base.cursor;
  2739. var color = Base.color;
  2740. /**
  2741. * Expose `Landing`.
  2742. */
  2743. exports = module.exports = Landing;
  2744. /**
  2745. * Airplane color.
  2746. */
  2747. Base.colors.plane = 0;
  2748. /**
  2749. * Airplane crash color.
  2750. */
  2751. Base.colors['plane crash'] = 31;
  2752. /**
  2753. * Runway color.
  2754. */
  2755. Base.colors.runway = 90;
  2756. /**
  2757. * Initialize a new `Landing` reporter.
  2758. *
  2759. * @public
  2760. * @class
  2761. * @memberof Mocha.reporters
  2762. * @extends Mocha.reporters.Base
  2763. * @api public
  2764. * @param {Runner} runner
  2765. */
  2766. function Landing(runner) {
  2767. Base.call(this, runner);
  2768. var self = this;
  2769. var width = (Base.window.width * 0.75) | 0;
  2770. var total = runner.total;
  2771. var stream = process.stdout;
  2772. var plane = color('plane', '✈');
  2773. var crashed = -1;
  2774. var n = 0;
  2775. function runway() {
  2776. var buf = Array(width).join('-');
  2777. return ' ' + color('runway', buf);
  2778. }
  2779. runner.on('start', function() {
  2780. stream.write('\n\n\n ');
  2781. cursor.hide();
  2782. });
  2783. runner.on('test end', function(test) {
  2784. // check if the plane crashed
  2785. var col = crashed === -1 ? (width * ++n / total) | 0 : crashed;
  2786. // show the crash
  2787. if (test.state === 'failed') {
  2788. plane = color('plane crash', '✈');
  2789. crashed = col;
  2790. }
  2791. // render landing strip
  2792. stream.write('\u001b[' + (width + 1) + 'D\u001b[2A');
  2793. stream.write(runway());
  2794. stream.write('\n ');
  2795. stream.write(color('runway', Array(col).join('⋅')));
  2796. stream.write(plane);
  2797. stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
  2798. stream.write(runway());
  2799. stream.write('\u001b[0m');
  2800. });
  2801. runner.once('end', function() {
  2802. cursor.show();
  2803. console.log();
  2804. self.epilogue();
  2805. });
  2806. }
  2807. /**
  2808. * Inherit from `Base.prototype`.
  2809. */
  2810. inherits(Landing, Base);
  2811. }).call(this,require('_process'))
  2812. },{"../utils":36,"./base":16,"_process":56}],24:[function(require,module,exports){
  2813. (function (process){
  2814. 'use strict';
  2815. /**
  2816. * @module List
  2817. */
  2818. /**
  2819. * Module dependencies.
  2820. */
  2821. var Base = require('./base');
  2822. var inherits = require('../utils').inherits;
  2823. var color = Base.color;
  2824. var cursor = Base.cursor;
  2825. /**
  2826. * Expose `List`.
  2827. */
  2828. exports = module.exports = List;
  2829. /**
  2830. * Initialize a new `List` test reporter.
  2831. *
  2832. * @public
  2833. * @class
  2834. * @memberof Mocha.reporters
  2835. * @extends Mocha.reporters.Base
  2836. * @api public
  2837. * @param {Runner} runner
  2838. */
  2839. function List(runner) {
  2840. Base.call(this, runner);
  2841. var self = this;
  2842. var n = 0;
  2843. runner.on('start', function() {
  2844. console.log();
  2845. });
  2846. runner.on('test', function(test) {
  2847. process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
  2848. });
  2849. runner.on('pending', function(test) {
  2850. var fmt = color('checkmark', ' -') + color('pending', ' %s');
  2851. console.log(fmt, test.fullTitle());
  2852. });
  2853. runner.on('pass', function(test) {
  2854. var fmt =
  2855. color('checkmark', ' ' + Base.symbols.ok) +
  2856. color('pass', ' %s: ') +
  2857. color(test.speed, '%dms');
  2858. cursor.CR();
  2859. console.log(fmt, test.fullTitle(), test.duration);
  2860. });
  2861. runner.on('fail', function(test) {
  2862. cursor.CR();
  2863. console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
  2864. });
  2865. runner.once('end', self.epilogue.bind(self));
  2866. }
  2867. /**
  2868. * Inherit from `Base.prototype`.
  2869. */
  2870. inherits(List, Base);
  2871. }).call(this,require('_process'))
  2872. },{"../utils":36,"./base":16,"_process":56}],25:[function(require,module,exports){
  2873. (function (process){
  2874. 'use strict';
  2875. /**
  2876. * @module Markdown
  2877. */
  2878. /**
  2879. * Module dependencies.
  2880. */
  2881. var Base = require('./base');
  2882. var utils = require('../utils');
  2883. /**
  2884. * Constants
  2885. */
  2886. var SUITE_PREFIX = '$';
  2887. /**
  2888. * Expose `Markdown`.
  2889. */
  2890. exports = module.exports = Markdown;
  2891. /**
  2892. * Initialize a new `Markdown` reporter.
  2893. *
  2894. * @public
  2895. * @class
  2896. * @memberof Mocha.reporters
  2897. * @extends Mocha.reporters.Base
  2898. * @api public
  2899. * @param {Runner} runner
  2900. */
  2901. function Markdown(runner) {
  2902. Base.call(this, runner);
  2903. var level = 0;
  2904. var buf = '';
  2905. function title(str) {
  2906. return Array(level).join('#') + ' ' + str;
  2907. }
  2908. function mapTOC(suite, obj) {
  2909. var ret = obj;
  2910. var key = SUITE_PREFIX + suite.title;
  2911. obj = obj[key] = obj[key] || {suite: suite};
  2912. suite.suites.forEach(function(suite) {
  2913. mapTOC(suite, obj);
  2914. });
  2915. return ret;
  2916. }
  2917. function stringifyTOC(obj, level) {
  2918. ++level;
  2919. var buf = '';
  2920. var link;
  2921. for (var key in obj) {
  2922. if (key === 'suite') {
  2923. continue;
  2924. }
  2925. if (key !== SUITE_PREFIX) {
  2926. link = ' - [' + key.substring(1) + ']';
  2927. link += '(#' + utils.slug(obj[key].suite.fullTitle()) + ')\n';
  2928. buf += Array(level).join(' ') + link;
  2929. }
  2930. buf += stringifyTOC(obj[key], level);
  2931. }
  2932. return buf;
  2933. }
  2934. function generateTOC(suite) {
  2935. var obj = mapTOC(suite, {});
  2936. return stringifyTOC(obj, 0);
  2937. }
  2938. generateTOC(runner.suite);
  2939. runner.on('suite', function(suite) {
  2940. ++level;
  2941. var slug = utils.slug(suite.fullTitle());
  2942. buf += '<a name="' + slug + '"></a>' + '\n';
  2943. buf += title(suite.title) + '\n';
  2944. });
  2945. runner.on('suite end', function() {
  2946. --level;
  2947. });
  2948. runner.on('pass', function(test) {
  2949. var code = utils.clean(test.body);
  2950. buf += test.title + '.\n';
  2951. buf += '\n```js\n';
  2952. buf += code + '\n';
  2953. buf += '```\n\n';
  2954. });
  2955. runner.once('end', function() {
  2956. process.stdout.write('# TOC\n');
  2957. process.stdout.write(generateTOC(runner.suite));
  2958. process.stdout.write(buf);
  2959. });
  2960. }
  2961. }).call(this,require('_process'))
  2962. },{"../utils":36,"./base":16,"_process":56}],26:[function(require,module,exports){
  2963. (function (process){
  2964. 'use strict';
  2965. /**
  2966. * @module Min
  2967. */
  2968. /**
  2969. * Module dependencies.
  2970. */
  2971. var Base = require('./base');
  2972. var inherits = require('../utils').inherits;
  2973. /**
  2974. * Expose `Min`.
  2975. */
  2976. exports = module.exports = Min;
  2977. /**
  2978. * Initialize a new `Min` minimal test reporter (best used with --watch).
  2979. *
  2980. * @public
  2981. * @class
  2982. * @memberof Mocha.reporters
  2983. * @extends Mocha.reporters.Base
  2984. * @api public
  2985. * @param {Runner} runner
  2986. */
  2987. function Min(runner) {
  2988. Base.call(this, runner);
  2989. runner.on('start', function() {
  2990. // clear screen
  2991. process.stdout.write('\u001b[2J');
  2992. // set cursor position
  2993. process.stdout.write('\u001b[1;3H');
  2994. });
  2995. runner.once('end', this.epilogue.bind(this));
  2996. }
  2997. /**
  2998. * Inherit from `Base.prototype`.
  2999. */
  3000. inherits(Min, Base);
  3001. }).call(this,require('_process'))
  3002. },{"../utils":36,"./base":16,"_process":56}],27:[function(require,module,exports){
  3003. (function (process){
  3004. 'use strict';
  3005. /**
  3006. * @module Nyan
  3007. */
  3008. /**
  3009. * Module dependencies.
  3010. */
  3011. var Base = require('./base');
  3012. var inherits = require('../utils').inherits;
  3013. /**
  3014. * Expose `Dot`.
  3015. */
  3016. exports = module.exports = NyanCat;
  3017. /**
  3018. * Initialize a new `Dot` matrix test reporter.
  3019. *
  3020. * @param {Runner} runner
  3021. * @api public
  3022. * @public
  3023. * @class Nyan
  3024. * @memberof Mocha.reporters
  3025. * @extends Mocha.reporters.Base
  3026. */
  3027. function NyanCat(runner) {
  3028. Base.call(this, runner);
  3029. var self = this;
  3030. var width = (Base.window.width * 0.75) | 0;
  3031. var nyanCatWidth = (this.nyanCatWidth = 11);
  3032. this.colorIndex = 0;
  3033. this.numberOfLines = 4;
  3034. this.rainbowColors = self.generateColors();
  3035. this.scoreboardWidth = 5;
  3036. this.tick = 0;
  3037. this.trajectories = [[], [], [], []];
  3038. this.trajectoryWidthMax = width - nyanCatWidth;
  3039. runner.on('start', function() {
  3040. Base.cursor.hide();
  3041. self.draw();
  3042. });
  3043. runner.on('pending', function() {
  3044. self.draw();
  3045. });
  3046. runner.on('pass', function() {
  3047. self.draw();
  3048. });
  3049. runner.on('fail', function() {
  3050. self.draw();
  3051. });
  3052. runner.once('end', function() {
  3053. Base.cursor.show();
  3054. for (var i = 0; i < self.numberOfLines; i++) {
  3055. write('\n');
  3056. }
  3057. self.epilogue();
  3058. });
  3059. }
  3060. /**
  3061. * Inherit from `Base.prototype`.
  3062. */
  3063. inherits(NyanCat, Base);
  3064. /**
  3065. * Draw the nyan cat
  3066. *
  3067. * @api private
  3068. */
  3069. NyanCat.prototype.draw = function() {
  3070. this.appendRainbow();
  3071. this.drawScoreboard();
  3072. this.drawRainbow();
  3073. this.drawNyanCat();
  3074. this.tick = !this.tick;
  3075. };
  3076. /**
  3077. * Draw the "scoreboard" showing the number
  3078. * of passes, failures and pending tests.
  3079. *
  3080. * @api private
  3081. */
  3082. NyanCat.prototype.drawScoreboard = function() {
  3083. var stats = this.stats;
  3084. function draw(type, n) {
  3085. write(' ');
  3086. write(Base.color(type, n));
  3087. write('\n');
  3088. }
  3089. draw('green', stats.passes);
  3090. draw('fail', stats.failures);
  3091. draw('pending', stats.pending);
  3092. write('\n');
  3093. this.cursorUp(this.numberOfLines);
  3094. };
  3095. /**
  3096. * Append the rainbow.
  3097. *
  3098. * @api private
  3099. */
  3100. NyanCat.prototype.appendRainbow = function() {
  3101. var segment = this.tick ? '_' : '-';
  3102. var rainbowified = this.rainbowify(segment);
  3103. for (var index = 0; index < this.numberOfLines; index++) {
  3104. var trajectory = this.trajectories[index];
  3105. if (trajectory.length >= this.trajectoryWidthMax) {
  3106. trajectory.shift();
  3107. }
  3108. trajectory.push(rainbowified);
  3109. }
  3110. };
  3111. /**
  3112. * Draw the rainbow.
  3113. *
  3114. * @api private
  3115. */
  3116. NyanCat.prototype.drawRainbow = function() {
  3117. var self = this;
  3118. this.trajectories.forEach(function(line) {
  3119. write('\u001b[' + self.scoreboardWidth + 'C');
  3120. write(line.join(''));
  3121. write('\n');
  3122. });
  3123. this.cursorUp(this.numberOfLines);
  3124. };
  3125. /**
  3126. * Draw the nyan cat
  3127. *
  3128. * @api private
  3129. */
  3130. NyanCat.prototype.drawNyanCat = function() {
  3131. var self = this;
  3132. var startWidth = this.scoreboardWidth + this.trajectories[0].length;
  3133. var dist = '\u001b[' + startWidth + 'C';
  3134. var padding = '';
  3135. write(dist);
  3136. write('_,------,');
  3137. write('\n');
  3138. write(dist);
  3139. padding = self.tick ? ' ' : ' ';
  3140. write('_|' + padding + '/\\_/\\ ');
  3141. write('\n');
  3142. write(dist);
  3143. padding = self.tick ? '_' : '__';
  3144. var tail = self.tick ? '~' : '^';
  3145. write(tail + '|' + padding + this.face() + ' ');
  3146. write('\n');
  3147. write(dist);
  3148. padding = self.tick ? ' ' : ' ';
  3149. write(padding + '"" "" ');
  3150. write('\n');
  3151. this.cursorUp(this.numberOfLines);
  3152. };
  3153. /**
  3154. * Draw nyan cat face.
  3155. *
  3156. * @api private
  3157. * @return {string}
  3158. */
  3159. NyanCat.prototype.face = function() {
  3160. var stats = this.stats;
  3161. if (stats.failures) {
  3162. return '( x .x)';
  3163. } else if (stats.pending) {
  3164. return '( o .o)';
  3165. } else if (stats.passes) {
  3166. return '( ^ .^)';
  3167. }
  3168. return '( - .-)';
  3169. };
  3170. /**
  3171. * Move cursor up `n`.
  3172. *
  3173. * @api private
  3174. * @param {number} n
  3175. */
  3176. NyanCat.prototype.cursorUp = function(n) {
  3177. write('\u001b[' + n + 'A');
  3178. };
  3179. /**
  3180. * Move cursor down `n`.
  3181. *
  3182. * @api private
  3183. * @param {number} n
  3184. */
  3185. NyanCat.prototype.cursorDown = function(n) {
  3186. write('\u001b[' + n + 'B');
  3187. };
  3188. /**
  3189. * Generate rainbow colors.
  3190. *
  3191. * @api private
  3192. * @return {Array}
  3193. */
  3194. NyanCat.prototype.generateColors = function() {
  3195. var colors = [];
  3196. for (var i = 0; i < 6 * 7; i++) {
  3197. var pi3 = Math.floor(Math.PI / 3);
  3198. var n = i * (1.0 / 6);
  3199. var r = Math.floor(3 * Math.sin(n) + 3);
  3200. var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
  3201. var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
  3202. colors.push(36 * r + 6 * g + b + 16);
  3203. }
  3204. return colors;
  3205. };
  3206. /**
  3207. * Apply rainbow to the given `str`.
  3208. *
  3209. * @api private
  3210. * @param {string} str
  3211. * @return {string}
  3212. */
  3213. NyanCat.prototype.rainbowify = function(str) {
  3214. if (!Base.useColors) {
  3215. return str;
  3216. }
  3217. var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
  3218. this.colorIndex += 1;
  3219. return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
  3220. };
  3221. /**
  3222. * Stdout helper.
  3223. *
  3224. * @param {string} string A message to write to stdout.
  3225. */
  3226. function write(string) {
  3227. process.stdout.write(string);
  3228. }
  3229. }).call(this,require('_process'))
  3230. },{"../utils":36,"./base":16,"_process":56}],28:[function(require,module,exports){
  3231. (function (process){
  3232. 'use strict';
  3233. /**
  3234. * @module Progress
  3235. */
  3236. /**
  3237. * Module dependencies.
  3238. */
  3239. var Base = require('./base');
  3240. var inherits = require('../utils').inherits;
  3241. var color = Base.color;
  3242. var cursor = Base.cursor;
  3243. /**
  3244. * Expose `Progress`.
  3245. */
  3246. exports = module.exports = Progress;
  3247. /**
  3248. * General progress bar color.
  3249. */
  3250. Base.colors.progress = 90;
  3251. /**
  3252. * Initialize a new `Progress` bar test reporter.
  3253. *
  3254. * @public
  3255. * @class
  3256. * @memberof Mocha.reporters
  3257. * @extends Mocha.reporters.Base
  3258. * @api public
  3259. * @param {Runner} runner
  3260. * @param {Object} options
  3261. */
  3262. function Progress(runner, options) {
  3263. Base.call(this, runner);
  3264. var self = this;
  3265. var width = (Base.window.width * 0.5) | 0;
  3266. var total = runner.total;
  3267. var complete = 0;
  3268. var lastN = -1;
  3269. // default chars
  3270. options = options || {};
  3271. var reporterOptions = options.reporterOptions || {};
  3272. options.open = reporterOptions.open || '[';
  3273. options.complete = reporterOptions.complete || '▬';
  3274. options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
  3275. options.close = reporterOptions.close || ']';
  3276. options.verbose = reporterOptions.verbose || false;
  3277. // tests started
  3278. runner.on('start', function() {
  3279. console.log();
  3280. cursor.hide();
  3281. });
  3282. // tests complete
  3283. runner.on('test end', function() {
  3284. complete++;
  3285. var percent = complete / total;
  3286. var n = (width * percent) | 0;
  3287. var i = width - n;
  3288. if (n === lastN && !options.verbose) {
  3289. // Don't re-render the line if it hasn't changed
  3290. return;
  3291. }
  3292. lastN = n;
  3293. cursor.CR();
  3294. process.stdout.write('\u001b[J');
  3295. process.stdout.write(color('progress', ' ' + options.open));
  3296. process.stdout.write(Array(n).join(options.complete));
  3297. process.stdout.write(Array(i).join(options.incomplete));
  3298. process.stdout.write(color('progress', options.close));
  3299. if (options.verbose) {
  3300. process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
  3301. }
  3302. });
  3303. // tests are complete, output some stats
  3304. // and the failures if any
  3305. runner.once('end', function() {
  3306. cursor.show();
  3307. console.log();
  3308. self.epilogue();
  3309. });
  3310. }
  3311. /**
  3312. * Inherit from `Base.prototype`.
  3313. */
  3314. inherits(Progress, Base);
  3315. }).call(this,require('_process'))
  3316. },{"../utils":36,"./base":16,"_process":56}],29:[function(require,module,exports){
  3317. 'use strict';
  3318. /**
  3319. * @module Spec
  3320. */
  3321. /**
  3322. * Module dependencies.
  3323. */
  3324. var Base = require('./base');
  3325. var inherits = require('../utils').inherits;
  3326. var color = Base.color;
  3327. /**
  3328. * Expose `Spec`.
  3329. */
  3330. exports = module.exports = Spec;
  3331. /**
  3332. * Initialize a new `Spec` test reporter.
  3333. *
  3334. * @public
  3335. * @class
  3336. * @memberof Mocha.reporters
  3337. * @extends Mocha.reporters.Base
  3338. * @api public
  3339. * @param {Runner} runner
  3340. */
  3341. function Spec(runner) {
  3342. Base.call(this, runner);
  3343. var self = this;
  3344. var indents = 0;
  3345. var n = 0;
  3346. function indent() {
  3347. return Array(indents).join(' ');
  3348. }
  3349. runner.on('start', function() {
  3350. console.log();
  3351. });
  3352. runner.on('suite', function(suite) {
  3353. ++indents;
  3354. console.log(color('suite', '%s%s'), indent(), suite.title);
  3355. });
  3356. runner.on('suite end', function() {
  3357. --indents;
  3358. if (indents === 1) {
  3359. console.log();
  3360. }
  3361. });
  3362. runner.on('pending', function(test) {
  3363. var fmt = indent() + color('pending', ' - %s');
  3364. console.log(fmt, test.title);
  3365. });
  3366. runner.on('pass', function(test) {
  3367. var fmt;
  3368. if (test.speed === 'fast') {
  3369. fmt =
  3370. indent() +
  3371. color('checkmark', ' ' + Base.symbols.ok) +
  3372. color('pass', ' %s');
  3373. console.log(fmt, test.title);
  3374. } else {
  3375. fmt =
  3376. indent() +
  3377. color('checkmark', ' ' + Base.symbols.ok) +
  3378. color('pass', ' %s') +
  3379. color(test.speed, ' (%dms)');
  3380. console.log(fmt, test.title, test.duration);
  3381. }
  3382. });
  3383. runner.on('fail', function(test) {
  3384. console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
  3385. });
  3386. runner.once('end', self.epilogue.bind(self));
  3387. }
  3388. /**
  3389. * Inherit from `Base.prototype`.
  3390. */
  3391. inherits(Spec, Base);
  3392. },{"../utils":36,"./base":16}],30:[function(require,module,exports){
  3393. 'use strict';
  3394. /**
  3395. * @module TAP
  3396. */
  3397. /**
  3398. * Module dependencies.
  3399. */
  3400. var Base = require('./base');
  3401. /**
  3402. * Expose `TAP`.
  3403. */
  3404. exports = module.exports = TAP;
  3405. /**
  3406. * Initialize a new `TAP` reporter.
  3407. *
  3408. * @public
  3409. * @class
  3410. * @memberof Mocha.reporters
  3411. * @extends Mocha.reporters.Base
  3412. * @api public
  3413. * @param {Runner} runner
  3414. */
  3415. function TAP(runner) {
  3416. Base.call(this, runner);
  3417. var n = 1;
  3418. var passes = 0;
  3419. var failures = 0;
  3420. runner.on('start', function() {
  3421. var total = runner.grepTotal(runner.suite);
  3422. console.log('%d..%d', 1, total);
  3423. });
  3424. runner.on('test end', function() {
  3425. ++n;
  3426. });
  3427. runner.on('pending', function(test) {
  3428. console.log('ok %d %s # SKIP -', n, title(test));
  3429. });
  3430. runner.on('pass', function(test) {
  3431. passes++;
  3432. console.log('ok %d %s', n, title(test));
  3433. });
  3434. runner.on('fail', function(test, err) {
  3435. failures++;
  3436. console.log('not ok %d %s', n, title(test));
  3437. if (err.stack) {
  3438. console.log(err.stack.replace(/^/gm, ' '));
  3439. }
  3440. });
  3441. runner.once('end', function() {
  3442. console.log('# tests ' + (passes + failures));
  3443. console.log('# pass ' + passes);
  3444. console.log('# fail ' + failures);
  3445. });
  3446. }
  3447. /**
  3448. * Return a TAP-safe title of `test`
  3449. *
  3450. * @api private
  3451. * @param {Object} test
  3452. * @return {String}
  3453. */
  3454. function title(test) {
  3455. return test.fullTitle().replace(/#/g, '');
  3456. }
  3457. },{"./base":16}],31:[function(require,module,exports){
  3458. (function (process,global){
  3459. 'use strict';
  3460. /**
  3461. * @module XUnit
  3462. */
  3463. /**
  3464. * Module dependencies.
  3465. */
  3466. var Base = require('./base');
  3467. var utils = require('../utils');
  3468. var inherits = utils.inherits;
  3469. var fs = require('fs');
  3470. var escape = utils.escape;
  3471. var mkdirp = require('mkdirp');
  3472. var path = require('path');
  3473. /**
  3474. * Save timer references to avoid Sinon interfering (see GH-237).
  3475. */
  3476. /* eslint-disable no-unused-vars, no-native-reassign */
  3477. var Date = global.Date;
  3478. var setTimeout = global.setTimeout;
  3479. var setInterval = global.setInterval;
  3480. var clearTimeout = global.clearTimeout;
  3481. var clearInterval = global.clearInterval;
  3482. /* eslint-enable no-unused-vars, no-native-reassign */
  3483. /**
  3484. * Expose `XUnit`.
  3485. */
  3486. exports = module.exports = XUnit;
  3487. /**
  3488. * Initialize a new `XUnit` reporter.
  3489. *
  3490. * @public
  3491. * @class
  3492. * @memberof Mocha.reporters
  3493. * @extends Mocha.reporters.Base
  3494. * @api public
  3495. * @param {Runner} runner
  3496. */
  3497. function XUnit(runner, options) {
  3498. Base.call(this, runner);
  3499. var stats = this.stats;
  3500. var tests = [];
  3501. var self = this;
  3502. // the name of the test suite, as it will appear in the resulting XML file
  3503. var suiteName;
  3504. // the default name of the test suite if none is provided
  3505. var DEFAULT_SUITE_NAME = 'Mocha Tests';
  3506. if (options && options.reporterOptions) {
  3507. if (options.reporterOptions.output) {
  3508. if (!fs.createWriteStream) {
  3509. throw new Error('file output not supported in browser');
  3510. }
  3511. mkdirp.sync(path.dirname(options.reporterOptions.output));
  3512. self.fileStream = fs.createWriteStream(options.reporterOptions.output);
  3513. }
  3514. // get the suite name from the reporter options (if provided)
  3515. suiteName = options.reporterOptions.suiteName;
  3516. }
  3517. // fall back to the default suite name
  3518. suiteName = suiteName || DEFAULT_SUITE_NAME;
  3519. runner.on('pending', function(test) {
  3520. tests.push(test);
  3521. });
  3522. runner.on('pass', function(test) {
  3523. tests.push(test);
  3524. });
  3525. runner.on('fail', function(test) {
  3526. tests.push(test);
  3527. });
  3528. runner.once('end', function() {
  3529. self.write(
  3530. tag(
  3531. 'testsuite',
  3532. {
  3533. name: suiteName,
  3534. tests: stats.tests,
  3535. failures: stats.failures,
  3536. errors: stats.failures,
  3537. skipped: stats.tests - stats.failures - stats.passes,
  3538. timestamp: new Date().toUTCString(),
  3539. time: stats.duration / 1000 || 0
  3540. },
  3541. false
  3542. )
  3543. );
  3544. tests.forEach(function(t) {
  3545. self.test(t);
  3546. });
  3547. self.write('</testsuite>');
  3548. });
  3549. }
  3550. /**
  3551. * Inherit from `Base.prototype`.
  3552. */
  3553. inherits(XUnit, Base);
  3554. /**
  3555. * Override done to close the stream (if it's a file).
  3556. *
  3557. * @param failures
  3558. * @param {Function} fn
  3559. */
  3560. XUnit.prototype.done = function(failures, fn) {
  3561. if (this.fileStream) {
  3562. this.fileStream.end(function() {
  3563. fn(failures);
  3564. });
  3565. } else {
  3566. fn(failures);
  3567. }
  3568. };
  3569. /**
  3570. * Write out the given line.
  3571. *
  3572. * @param {string} line
  3573. */
  3574. XUnit.prototype.write = function(line) {
  3575. if (this.fileStream) {
  3576. this.fileStream.write(line + '\n');
  3577. } else if (typeof process === 'object' && process.stdout) {
  3578. process.stdout.write(line + '\n');
  3579. } else {
  3580. console.log(line);
  3581. }
  3582. };
  3583. /**
  3584. * Output tag for the given `test.`
  3585. *
  3586. * @param {Test} test
  3587. */
  3588. XUnit.prototype.test = function(test) {
  3589. var attrs = {
  3590. classname: test.parent.fullTitle(),
  3591. name: test.title,
  3592. time: test.duration / 1000 || 0
  3593. };
  3594. if (test.state === 'failed') {
  3595. var err = test.err;
  3596. this.write(
  3597. tag(
  3598. 'testcase',
  3599. attrs,
  3600. false,
  3601. tag(
  3602. 'failure',
  3603. {},
  3604. false,
  3605. escape(err.message) + '\n' + escape(err.stack)
  3606. )
  3607. )
  3608. );
  3609. } else if (test.isPending()) {
  3610. this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));
  3611. } else {
  3612. this.write(tag('testcase', attrs, true));
  3613. }
  3614. };
  3615. /**
  3616. * HTML tag helper.
  3617. *
  3618. * @param name
  3619. * @param attrs
  3620. * @param close
  3621. * @param content
  3622. * @return {string}
  3623. */
  3624. function tag(name, attrs, close, content) {
  3625. var end = close ? '/>' : '>';
  3626. var pairs = [];
  3627. var tag;
  3628. for (var key in attrs) {
  3629. if (Object.prototype.hasOwnProperty.call(attrs, key)) {
  3630. pairs.push(key + '="' + escape(attrs[key]) + '"');
  3631. }
  3632. }
  3633. tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
  3634. if (content) {
  3635. tag += content + '</' + name + end;
  3636. }
  3637. return tag;
  3638. }
  3639. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  3640. },{"../utils":36,"./base":16,"_process":56,"fs":40,"mkdirp":53,"path":40}],32:[function(require,module,exports){
  3641. (function (global){
  3642. 'use strict';
  3643. var EventEmitter = require('events').EventEmitter;
  3644. var Pending = require('./pending');
  3645. var debug = require('debug')('mocha:runnable');
  3646. var milliseconds = require('./ms');
  3647. var utils = require('./utils');
  3648. /**
  3649. * Save timer references to avoid Sinon interfering (see GH-237).
  3650. */
  3651. /* eslint-disable no-unused-vars, no-native-reassign */
  3652. var Date = global.Date;
  3653. var setTimeout = global.setTimeout;
  3654. var setInterval = global.setInterval;
  3655. var clearTimeout = global.clearTimeout;
  3656. var clearInterval = global.clearInterval;
  3657. /* eslint-enable no-unused-vars, no-native-reassign */
  3658. var toString = Object.prototype.toString;
  3659. module.exports = Runnable;
  3660. /**
  3661. * Initialize a new `Runnable` with the given `title` and callback `fn`. Derived from [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
  3662. *
  3663. * @class
  3664. * @extends EventEmitter
  3665. * @param {String} title
  3666. * @param {Function} fn
  3667. */
  3668. function Runnable(title, fn) {
  3669. this.title = title;
  3670. this.fn = fn;
  3671. this.body = (fn || '').toString();
  3672. this.async = fn && fn.length;
  3673. this.sync = !this.async;
  3674. this._timeout = 2000;
  3675. this._slow = 75;
  3676. this._enableTimeouts = true;
  3677. this.timedOut = false;
  3678. this._retries = -1;
  3679. this._currentRetry = 0;
  3680. this.pending = false;
  3681. }
  3682. /**
  3683. * Inherit from `EventEmitter.prototype`.
  3684. */
  3685. utils.inherits(Runnable, EventEmitter);
  3686. /**
  3687. * Set & get timeout `ms`.
  3688. *
  3689. * @api private
  3690. * @param {number|string} ms
  3691. * @return {Runnable|number} ms or Runnable instance.
  3692. */
  3693. Runnable.prototype.timeout = function(ms) {
  3694. if (!arguments.length) {
  3695. return this._timeout;
  3696. }
  3697. // see #1652 for reasoning
  3698. if (ms === 0 || ms > Math.pow(2, 31)) {
  3699. this._enableTimeouts = false;
  3700. }
  3701. if (typeof ms === 'string') {
  3702. ms = milliseconds(ms);
  3703. }
  3704. debug('timeout %d', ms);
  3705. this._timeout = ms;
  3706. if (this.timer) {
  3707. this.resetTimeout();
  3708. }
  3709. return this;
  3710. };
  3711. /**
  3712. * Set or get slow `ms`.
  3713. *
  3714. * @api private
  3715. * @param {number|string} ms
  3716. * @return {Runnable|number} ms or Runnable instance.
  3717. */
  3718. Runnable.prototype.slow = function(ms) {
  3719. if (!arguments.length || typeof ms === 'undefined') {
  3720. return this._slow;
  3721. }
  3722. if (typeof ms === 'string') {
  3723. ms = milliseconds(ms);
  3724. }
  3725. debug('slow %d', ms);
  3726. this._slow = ms;
  3727. return this;
  3728. };
  3729. /**
  3730. * Set and get whether timeout is `enabled`.
  3731. *
  3732. * @api private
  3733. * @param {boolean} enabled
  3734. * @return {Runnable|boolean} enabled or Runnable instance.
  3735. */
  3736. Runnable.prototype.enableTimeouts = function(enabled) {
  3737. if (!arguments.length) {
  3738. return this._enableTimeouts;
  3739. }
  3740. debug('enableTimeouts %s', enabled);
  3741. this._enableTimeouts = enabled;
  3742. return this;
  3743. };
  3744. /**
  3745. * Halt and mark as pending.
  3746. *
  3747. * @memberof Mocha.Runnable
  3748. * @public
  3749. * @api public
  3750. */
  3751. Runnable.prototype.skip = function() {
  3752. throw new Pending('sync skip');
  3753. };
  3754. /**
  3755. * Check if this runnable or its parent suite is marked as pending.
  3756. *
  3757. * @api private
  3758. */
  3759. Runnable.prototype.isPending = function() {
  3760. return this.pending || (this.parent && this.parent.isPending());
  3761. };
  3762. /**
  3763. * Return `true` if this Runnable has failed.
  3764. * @return {boolean}
  3765. * @private
  3766. */
  3767. Runnable.prototype.isFailed = function() {
  3768. return !this.isPending() && this.state === 'failed';
  3769. };
  3770. /**
  3771. * Return `true` if this Runnable has passed.
  3772. * @return {boolean}
  3773. * @private
  3774. */
  3775. Runnable.prototype.isPassed = function() {
  3776. return !this.isPending() && this.state === 'passed';
  3777. };
  3778. /**
  3779. * Set or get number of retries.
  3780. *
  3781. * @api private
  3782. */
  3783. Runnable.prototype.retries = function(n) {
  3784. if (!arguments.length) {
  3785. return this._retries;
  3786. }
  3787. this._retries = n;
  3788. };
  3789. /**
  3790. * Set or get current retry
  3791. *
  3792. * @api private
  3793. */
  3794. Runnable.prototype.currentRetry = function(n) {
  3795. if (!arguments.length) {
  3796. return this._currentRetry;
  3797. }
  3798. this._currentRetry = n;
  3799. };
  3800. /**
  3801. * Return the full title generated by recursively concatenating the parent's
  3802. * full title.
  3803. *
  3804. * @memberof Mocha.Runnable
  3805. * @public
  3806. * @api public
  3807. * @return {string}
  3808. */
  3809. Runnable.prototype.fullTitle = function() {
  3810. return this.titlePath().join(' ');
  3811. };
  3812. /**
  3813. * Return the title path generated by concatenating the parent's title path with the title.
  3814. *
  3815. * @memberof Mocha.Runnable
  3816. * @public
  3817. * @api public
  3818. * @return {string}
  3819. */
  3820. Runnable.prototype.titlePath = function() {
  3821. return this.parent.titlePath().concat([this.title]);
  3822. };
  3823. /**
  3824. * Clear the timeout.
  3825. *
  3826. * @api private
  3827. */
  3828. Runnable.prototype.clearTimeout = function() {
  3829. clearTimeout(this.timer);
  3830. };
  3831. /**
  3832. * Inspect the runnable void of private properties.
  3833. *
  3834. * @api private
  3835. * @return {string}
  3836. */
  3837. Runnable.prototype.inspect = function() {
  3838. return JSON.stringify(
  3839. this,
  3840. function(key, val) {
  3841. if (key[0] === '_') {
  3842. return;
  3843. }
  3844. if (key === 'parent') {
  3845. return '#<Suite>';
  3846. }
  3847. if (key === 'ctx') {
  3848. return '#<Context>';
  3849. }
  3850. return val;
  3851. },
  3852. 2
  3853. );
  3854. };
  3855. /**
  3856. * Reset the timeout.
  3857. *
  3858. * @api private
  3859. */
  3860. Runnable.prototype.resetTimeout = function() {
  3861. var self = this;
  3862. var ms = this.timeout() || 1e9;
  3863. if (!this._enableTimeouts) {
  3864. return;
  3865. }
  3866. this.clearTimeout();
  3867. this.timer = setTimeout(function() {
  3868. if (!self._enableTimeouts) {
  3869. return;
  3870. }
  3871. self.callback(self._timeoutError(ms));
  3872. self.timedOut = true;
  3873. }, ms);
  3874. };
  3875. /**
  3876. * Set or get a list of whitelisted globals for this test run.
  3877. *
  3878. * @api private
  3879. * @param {string[]} globals
  3880. */
  3881. Runnable.prototype.globals = function(globals) {
  3882. if (!arguments.length) {
  3883. return this._allowedGlobals;
  3884. }
  3885. this._allowedGlobals = globals;
  3886. };
  3887. /**
  3888. * Run the test and invoke `fn(err)`.
  3889. *
  3890. * @param {Function} fn
  3891. * @api private
  3892. */
  3893. Runnable.prototype.run = function(fn) {
  3894. var self = this;
  3895. var start = new Date();
  3896. var ctx = this.ctx;
  3897. var finished;
  3898. var emitted;
  3899. // Sometimes the ctx exists, but it is not runnable
  3900. if (ctx && ctx.runnable) {
  3901. ctx.runnable(this);
  3902. }
  3903. // called multiple times
  3904. function multiple(err) {
  3905. if (emitted) {
  3906. return;
  3907. }
  3908. emitted = true;
  3909. var msg = 'done() called multiple times';
  3910. if (err && err.message) {
  3911. err.message += " (and Mocha's " + msg + ')';
  3912. self.emit('error', err);
  3913. } else {
  3914. self.emit('error', new Error(msg));
  3915. }
  3916. }
  3917. // finished
  3918. function done(err) {
  3919. var ms = self.timeout();
  3920. if (self.timedOut) {
  3921. return;
  3922. }
  3923. if (finished) {
  3924. return multiple(err);
  3925. }
  3926. self.clearTimeout();
  3927. self.duration = new Date() - start;
  3928. finished = true;
  3929. if (!err && self.duration > ms && self._enableTimeouts) {
  3930. err = self._timeoutError(ms);
  3931. }
  3932. fn(err);
  3933. }
  3934. // for .resetTimeout()
  3935. this.callback = done;
  3936. // explicit async with `done` argument
  3937. if (this.async) {
  3938. this.resetTimeout();
  3939. // allows skip() to be used in an explicit async context
  3940. this.skip = function asyncSkip() {
  3941. done(new Pending('async skip call'));
  3942. // halt execution. the Runnable will be marked pending
  3943. // by the previous call, and the uncaught handler will ignore
  3944. // the failure.
  3945. throw new Pending('async skip; aborting execution');
  3946. };
  3947. if (this.allowUncaught) {
  3948. return callFnAsync(this.fn);
  3949. }
  3950. try {
  3951. callFnAsync(this.fn);
  3952. } catch (err) {
  3953. emitted = true;
  3954. done(utils.getError(err));
  3955. }
  3956. return;
  3957. }
  3958. if (this.allowUncaught) {
  3959. if (this.isPending()) {
  3960. done();
  3961. } else {
  3962. callFn(this.fn);
  3963. }
  3964. return;
  3965. }
  3966. // sync or promise-returning
  3967. try {
  3968. if (this.isPending()) {
  3969. done();
  3970. } else {
  3971. callFn(this.fn);
  3972. }
  3973. } catch (err) {
  3974. emitted = true;
  3975. done(utils.getError(err));
  3976. }
  3977. function callFn(fn) {
  3978. var result = fn.call(ctx);
  3979. if (result && typeof result.then === 'function') {
  3980. self.resetTimeout();
  3981. result.then(
  3982. function() {
  3983. done();
  3984. // Return null so libraries like bluebird do not warn about
  3985. // subsequently constructed Promises.
  3986. return null;
  3987. },
  3988. function(reason) {
  3989. done(reason || new Error('Promise rejected with no or falsy reason'));
  3990. }
  3991. );
  3992. } else {
  3993. if (self.asyncOnly) {
  3994. return done(
  3995. new Error(
  3996. '--async-only option in use without declaring `done()` or returning a promise'
  3997. )
  3998. );
  3999. }
  4000. done();
  4001. }
  4002. }
  4003. function callFnAsync(fn) {
  4004. var result = fn.call(ctx, function(err) {
  4005. if (err instanceof Error || toString.call(err) === '[object Error]') {
  4006. return done(err);
  4007. }
  4008. if (err) {
  4009. if (Object.prototype.toString.call(err) === '[object Object]') {
  4010. return done(
  4011. new Error('done() invoked with non-Error: ' + JSON.stringify(err))
  4012. );
  4013. }
  4014. return done(new Error('done() invoked with non-Error: ' + err));
  4015. }
  4016. if (result && utils.isPromise(result)) {
  4017. return done(
  4018. new Error(
  4019. 'Resolution method is overspecified. Specify a callback *or* return a Promise; not both.'
  4020. )
  4021. );
  4022. }
  4023. done();
  4024. });
  4025. }
  4026. };
  4027. /**
  4028. * Instantiates a "timeout" error
  4029. *
  4030. * @param {number} ms - Timeout (in milliseconds)
  4031. * @returns {Error} a "timeout" error
  4032. * @private
  4033. */
  4034. Runnable.prototype._timeoutError = function(ms) {
  4035. var msg =
  4036. 'Timeout of ' +
  4037. ms +
  4038. 'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
  4039. if (this.file) {
  4040. msg += ' (' + this.file + ')';
  4041. }
  4042. return new Error(msg);
  4043. };
  4044. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  4045. },{"./ms":14,"./pending":15,"./utils":36,"debug":43,"events":47}],33:[function(require,module,exports){
  4046. (function (process,global){
  4047. 'use strict';
  4048. /**
  4049. * @module Runner
  4050. */
  4051. /**
  4052. * Module dependencies.
  4053. */
  4054. var EventEmitter = require('events').EventEmitter;
  4055. var Pending = require('./pending');
  4056. var utils = require('./utils');
  4057. var inherits = utils.inherits;
  4058. var debug = require('debug')('mocha:runner');
  4059. var Runnable = require('./runnable');
  4060. var stackFilter = utils.stackTraceFilter();
  4061. var stringify = utils.stringify;
  4062. var type = utils.type;
  4063. var undefinedError = utils.undefinedError;
  4064. /**
  4065. * Non-enumerable globals.
  4066. */
  4067. var globals = [
  4068. 'setTimeout',
  4069. 'clearTimeout',
  4070. 'setInterval',
  4071. 'clearInterval',
  4072. 'XMLHttpRequest',
  4073. 'Date',
  4074. 'setImmediate',
  4075. 'clearImmediate'
  4076. ];
  4077. /**
  4078. * Expose `Runner`.
  4079. */
  4080. module.exports = Runner;
  4081. /**
  4082. * Initialize a `Runner` for the given `suite`. Derived from [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
  4083. *
  4084. * Events:
  4085. *
  4086. * - `start` execution started
  4087. * - `end` execution complete
  4088. * - `suite` (suite) test suite execution started
  4089. * - `suite end` (suite) all tests (and sub-suites) have finished
  4090. * - `test` (test) test execution started
  4091. * - `test end` (test) test completed
  4092. * - `hook` (hook) hook execution started
  4093. * - `hook end` (hook) hook complete
  4094. * - `pass` (test) test passed
  4095. * - `fail` (test, err) test failed
  4096. * - `pending` (test) test pending
  4097. *
  4098. * @memberof Mocha
  4099. * @public
  4100. * @class
  4101. * @api public
  4102. * @param {Suite} [suite] Root suite
  4103. * @param {boolean} [delay] Whether or not to delay execution of root suite
  4104. * until ready.
  4105. */
  4106. function Runner(suite, delay) {
  4107. var self = this;
  4108. this._globals = [];
  4109. this._abort = false;
  4110. this._delay = delay;
  4111. this.suite = suite;
  4112. this.started = false;
  4113. this.total = suite.total();
  4114. this.failures = 0;
  4115. this.on('test end', function(test) {
  4116. self.checkGlobals(test);
  4117. });
  4118. this.on('hook end', function(hook) {
  4119. self.checkGlobals(hook);
  4120. });
  4121. this._defaultGrep = /.*/;
  4122. this.grep(this._defaultGrep);
  4123. this.globals(this.globalProps().concat(extraGlobals()));
  4124. }
  4125. /**
  4126. * Wrapper for setImmediate, process.nextTick, or browser polyfill.
  4127. *
  4128. * @param {Function} fn
  4129. * @api private
  4130. */
  4131. Runner.immediately = global.setImmediate || process.nextTick;
  4132. /**
  4133. * Inherit from `EventEmitter.prototype`.
  4134. */
  4135. inherits(Runner, EventEmitter);
  4136. /**
  4137. * Run tests with full titles matching `re`. Updates runner.total
  4138. * with number of tests matched.
  4139. *
  4140. * @api public
  4141. * @public
  4142. * @memberof Mocha.Runner
  4143. * @param {RegExp} re
  4144. * @param {boolean} invert
  4145. * @return {Runner} Runner instance.
  4146. */
  4147. Runner.prototype.grep = function(re, invert) {
  4148. debug('grep %s', re);
  4149. this._grep = re;
  4150. this._invert = invert;
  4151. this.total = this.grepTotal(this.suite);
  4152. return this;
  4153. };
  4154. /**
  4155. * Returns the number of tests matching the grep search for the
  4156. * given suite.
  4157. *
  4158. * @memberof Mocha.Runner
  4159. * @api public
  4160. * @public
  4161. * @param {Suite} suite
  4162. * @return {number}
  4163. */
  4164. Runner.prototype.grepTotal = function(suite) {
  4165. var self = this;
  4166. var total = 0;
  4167. suite.eachTest(function(test) {
  4168. var match = self._grep.test(test.fullTitle());
  4169. if (self._invert) {
  4170. match = !match;
  4171. }
  4172. if (match) {
  4173. total++;
  4174. }
  4175. });
  4176. return total;
  4177. };
  4178. /**
  4179. * Return a list of global properties.
  4180. *
  4181. * @return {Array}
  4182. * @api private
  4183. */
  4184. Runner.prototype.globalProps = function() {
  4185. var props = Object.keys(global);
  4186. // non-enumerables
  4187. for (var i = 0; i < globals.length; ++i) {
  4188. if (~props.indexOf(globals[i])) {
  4189. continue;
  4190. }
  4191. props.push(globals[i]);
  4192. }
  4193. return props;
  4194. };
  4195. /**
  4196. * Allow the given `arr` of globals.
  4197. *
  4198. * @api public
  4199. * @public
  4200. * @memberof Mocha.Runner
  4201. * @param {Array} arr
  4202. * @return {Runner} Runner instance.
  4203. */
  4204. Runner.prototype.globals = function(arr) {
  4205. if (!arguments.length) {
  4206. return this._globals;
  4207. }
  4208. debug('globals %j', arr);
  4209. this._globals = this._globals.concat(arr);
  4210. return this;
  4211. };
  4212. /**
  4213. * Check for global variable leaks.
  4214. *
  4215. * @api private
  4216. */
  4217. Runner.prototype.checkGlobals = function(test) {
  4218. if (this.ignoreLeaks) {
  4219. return;
  4220. }
  4221. var ok = this._globals;
  4222. var globals = this.globalProps();
  4223. var leaks;
  4224. if (test) {
  4225. ok = ok.concat(test._allowedGlobals || []);
  4226. }
  4227. if (this.prevGlobalsLength === globals.length) {
  4228. return;
  4229. }
  4230. this.prevGlobalsLength = globals.length;
  4231. leaks = filterLeaks(ok, globals);
  4232. this._globals = this._globals.concat(leaks);
  4233. if (leaks.length > 1) {
  4234. this.fail(
  4235. test,
  4236. new Error('global leaks detected: ' + leaks.join(', ') + '')
  4237. );
  4238. } else if (leaks.length) {
  4239. this.fail(test, new Error('global leak detected: ' + leaks[0]));
  4240. }
  4241. };
  4242. /**
  4243. * Fail the given `test`.
  4244. *
  4245. * @api private
  4246. * @param {Test} test
  4247. * @param {Error} err
  4248. */
  4249. Runner.prototype.fail = function(test, err) {
  4250. if (test.isPending()) {
  4251. return;
  4252. }
  4253. ++this.failures;
  4254. test.state = 'failed';
  4255. if (!(err instanceof Error || (err && typeof err.message === 'string'))) {
  4256. err = new Error(
  4257. 'the ' +
  4258. type(err) +
  4259. ' ' +
  4260. stringify(err) +
  4261. ' was thrown, throw an Error :)'
  4262. );
  4263. }
  4264. try {
  4265. err.stack =
  4266. this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack);
  4267. } catch (ignore) {
  4268. // some environments do not take kindly to monkeying with the stack
  4269. }
  4270. this.emit('fail', test, err);
  4271. if (this.suite.bail()) {
  4272. this.emit('end');
  4273. }
  4274. };
  4275. /**
  4276. * Fail the given `hook` with `err`.
  4277. *
  4278. * Hook failures work in the following pattern:
  4279. * - If bail, then exit
  4280. * - Failed `before` hook skips all tests in a suite and subsuites,
  4281. * but jumps to corresponding `after` hook
  4282. * - Failed `before each` hook skips remaining tests in a
  4283. * suite and jumps to corresponding `after each` hook,
  4284. * which is run only once
  4285. * - Failed `after` hook does not alter
  4286. * execution order
  4287. * - Failed `after each` hook skips remaining tests in a
  4288. * suite and subsuites, but executes other `after each`
  4289. * hooks
  4290. *
  4291. * @api private
  4292. * @param {Hook} hook
  4293. * @param {Error} err
  4294. */
  4295. Runner.prototype.failHook = function(hook, err) {
  4296. if (hook.ctx && hook.ctx.currentTest) {
  4297. hook.originalTitle = hook.originalTitle || hook.title;
  4298. hook.title =
  4299. hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"';
  4300. }
  4301. this.fail(hook, err);
  4302. };
  4303. /**
  4304. * Run hook `name` callbacks and then invoke `fn()`.
  4305. *
  4306. * @api private
  4307. * @param {string} name
  4308. * @param {Function} fn
  4309. */
  4310. Runner.prototype.hook = function(name, fn) {
  4311. var suite = this.suite;
  4312. var hooks = suite['_' + name];
  4313. var self = this;
  4314. function next(i) {
  4315. var hook = hooks[i];
  4316. if (!hook) {
  4317. return fn();
  4318. }
  4319. self.currentRunnable = hook;
  4320. hook.ctx.currentTest = self.test;
  4321. self.emit('hook', hook);
  4322. if (!hook.listeners('error').length) {
  4323. hook.on('error', function(err) {
  4324. self.failHook(hook, err);
  4325. });
  4326. }
  4327. hook.run(function(err) {
  4328. var testError = hook.error();
  4329. if (testError) {
  4330. self.fail(self.test, testError);
  4331. }
  4332. if (err) {
  4333. if (err instanceof Pending) {
  4334. if (name === 'beforeEach' || name === 'afterEach') {
  4335. self.test.pending = true;
  4336. } else {
  4337. suite.tests.forEach(function(test) {
  4338. test.pending = true;
  4339. });
  4340. // a pending hook won't be executed twice.
  4341. hook.pending = true;
  4342. }
  4343. } else {
  4344. self.failHook(hook, err);
  4345. // stop executing hooks, notify callee of hook err
  4346. return fn(err);
  4347. }
  4348. }
  4349. self.emit('hook end', hook);
  4350. delete hook.ctx.currentTest;
  4351. next(++i);
  4352. });
  4353. }
  4354. Runner.immediately(function() {
  4355. next(0);
  4356. });
  4357. };
  4358. /**
  4359. * Run hook `name` for the given array of `suites`
  4360. * in order, and callback `fn(err, errSuite)`.
  4361. *
  4362. * @api private
  4363. * @param {string} name
  4364. * @param {Array} suites
  4365. * @param {Function} fn
  4366. */
  4367. Runner.prototype.hooks = function(name, suites, fn) {
  4368. var self = this;
  4369. var orig = this.suite;
  4370. function next(suite) {
  4371. self.suite = suite;
  4372. if (!suite) {
  4373. self.suite = orig;
  4374. return fn();
  4375. }
  4376. self.hook(name, function(err) {
  4377. if (err) {
  4378. var errSuite = self.suite;
  4379. self.suite = orig;
  4380. return fn(err, errSuite);
  4381. }
  4382. next(suites.pop());
  4383. });
  4384. }
  4385. next(suites.pop());
  4386. };
  4387. /**
  4388. * Run hooks from the top level down.
  4389. *
  4390. * @param {String} name
  4391. * @param {Function} fn
  4392. * @api private
  4393. */
  4394. Runner.prototype.hookUp = function(name, fn) {
  4395. var suites = [this.suite].concat(this.parents()).reverse();
  4396. this.hooks(name, suites, fn);
  4397. };
  4398. /**
  4399. * Run hooks from the bottom up.
  4400. *
  4401. * @param {String} name
  4402. * @param {Function} fn
  4403. * @api private
  4404. */
  4405. Runner.prototype.hookDown = function(name, fn) {
  4406. var suites = [this.suite].concat(this.parents());
  4407. this.hooks(name, suites, fn);
  4408. };
  4409. /**
  4410. * Return an array of parent Suites from
  4411. * closest to furthest.
  4412. *
  4413. * @return {Array}
  4414. * @api private
  4415. */
  4416. Runner.prototype.parents = function() {
  4417. var suite = this.suite;
  4418. var suites = [];
  4419. while (suite.parent) {
  4420. suite = suite.parent;
  4421. suites.push(suite);
  4422. }
  4423. return suites;
  4424. };
  4425. /**
  4426. * Run the current test and callback `fn(err)`.
  4427. *
  4428. * @param {Function} fn
  4429. * @api private
  4430. */
  4431. Runner.prototype.runTest = function(fn) {
  4432. var self = this;
  4433. var test = this.test;
  4434. if (!test) {
  4435. return;
  4436. }
  4437. if (this.forbidOnly && hasOnly(this.parents().reverse()[0] || this.suite)) {
  4438. fn(new Error('`.only` forbidden'));
  4439. return;
  4440. }
  4441. if (this.asyncOnly) {
  4442. test.asyncOnly = true;
  4443. }
  4444. test.on('error', function(err) {
  4445. self.fail(test, err);
  4446. });
  4447. if (this.allowUncaught) {
  4448. test.allowUncaught = true;
  4449. return test.run(fn);
  4450. }
  4451. try {
  4452. test.run(fn);
  4453. } catch (err) {
  4454. fn(err);
  4455. }
  4456. };
  4457. /**
  4458. * Run tests in the given `suite` and invoke the callback `fn()` when complete.
  4459. *
  4460. * @api private
  4461. * @param {Suite} suite
  4462. * @param {Function} fn
  4463. */
  4464. Runner.prototype.runTests = function(suite, fn) {
  4465. var self = this;
  4466. var tests = suite.tests.slice();
  4467. var test;
  4468. function hookErr(_, errSuite, after) {
  4469. // before/after Each hook for errSuite failed:
  4470. var orig = self.suite;
  4471. // for failed 'after each' hook start from errSuite parent,
  4472. // otherwise start from errSuite itself
  4473. self.suite = after ? errSuite.parent : errSuite;
  4474. if (self.suite) {
  4475. // call hookUp afterEach
  4476. self.hookUp('afterEach', function(err2, errSuite2) {
  4477. self.suite = orig;
  4478. // some hooks may fail even now
  4479. if (err2) {
  4480. return hookErr(err2, errSuite2, true);
  4481. }
  4482. // report error suite
  4483. fn(errSuite);
  4484. });
  4485. } else {
  4486. // there is no need calling other 'after each' hooks
  4487. self.suite = orig;
  4488. fn(errSuite);
  4489. }
  4490. }
  4491. function next(err, errSuite) {
  4492. // if we bail after first err
  4493. if (self.failures && suite._bail) {
  4494. return fn();
  4495. }
  4496. if (self._abort) {
  4497. return fn();
  4498. }
  4499. if (err) {
  4500. return hookErr(err, errSuite, true);
  4501. }
  4502. // next test
  4503. test = tests.shift();
  4504. // all done
  4505. if (!test) {
  4506. return fn();
  4507. }
  4508. // grep
  4509. var match = self._grep.test(test.fullTitle());
  4510. if (self._invert) {
  4511. match = !match;
  4512. }
  4513. if (!match) {
  4514. // Run immediately only if we have defined a grep. When we
  4515. // define a grep — It can cause maximum callstack error if
  4516. // the grep is doing a large recursive loop by neglecting
  4517. // all tests. The run immediately function also comes with
  4518. // a performance cost. So we don't want to run immediately
  4519. // if we run the whole test suite, because running the whole
  4520. // test suite don't do any immediate recursive loops. Thus,
  4521. // allowing a JS runtime to breathe.
  4522. if (self._grep !== self._defaultGrep) {
  4523. Runner.immediately(next);
  4524. } else {
  4525. next();
  4526. }
  4527. return;
  4528. }
  4529. if (test.isPending()) {
  4530. if (self.forbidPending) {
  4531. test.isPending = alwaysFalse;
  4532. self.fail(test, new Error('Pending test forbidden'));
  4533. delete test.isPending;
  4534. } else {
  4535. self.emit('pending', test);
  4536. }
  4537. self.emit('test end', test);
  4538. return next();
  4539. }
  4540. // execute test and hook(s)
  4541. self.emit('test', (self.test = test));
  4542. self.hookDown('beforeEach', function(err, errSuite) {
  4543. if (test.isPending()) {
  4544. if (self.forbidPending) {
  4545. test.isPending = alwaysFalse;
  4546. self.fail(test, new Error('Pending test forbidden'));
  4547. delete test.isPending;
  4548. } else {
  4549. self.emit('pending', test);
  4550. }
  4551. self.emit('test end', test);
  4552. return next();
  4553. }
  4554. if (err) {
  4555. return hookErr(err, errSuite, false);
  4556. }
  4557. self.currentRunnable = self.test;
  4558. self.runTest(function(err) {
  4559. test = self.test;
  4560. if (err) {
  4561. var retry = test.currentRetry();
  4562. if (err instanceof Pending && self.forbidPending) {
  4563. self.fail(test, new Error('Pending test forbidden'));
  4564. } else if (err instanceof Pending) {
  4565. test.pending = true;
  4566. self.emit('pending', test);
  4567. } else if (retry < test.retries()) {
  4568. var clonedTest = test.clone();
  4569. clonedTest.currentRetry(retry + 1);
  4570. tests.unshift(clonedTest);
  4571. // Early return + hook trigger so that it doesn't
  4572. // increment the count wrong
  4573. return self.hookUp('afterEach', next);
  4574. } else {
  4575. self.fail(test, err);
  4576. }
  4577. self.emit('test end', test);
  4578. if (err instanceof Pending) {
  4579. return next();
  4580. }
  4581. return self.hookUp('afterEach', next);
  4582. }
  4583. test.state = 'passed';
  4584. self.emit('pass', test);
  4585. self.emit('test end', test);
  4586. self.hookUp('afterEach', next);
  4587. });
  4588. });
  4589. }
  4590. this.next = next;
  4591. this.hookErr = hookErr;
  4592. next();
  4593. };
  4594. function alwaysFalse() {
  4595. return false;
  4596. }
  4597. /**
  4598. * Run the given `suite` and invoke the callback `fn()` when complete.
  4599. *
  4600. * @api private
  4601. * @param {Suite} suite
  4602. * @param {Function} fn
  4603. */
  4604. Runner.prototype.runSuite = function(suite, fn) {
  4605. var i = 0;
  4606. var self = this;
  4607. var total = this.grepTotal(suite);
  4608. var afterAllHookCalled = false;
  4609. debug('run suite %s', suite.fullTitle());
  4610. if (!total || (self.failures && suite._bail)) {
  4611. return fn();
  4612. }
  4613. this.emit('suite', (this.suite = suite));
  4614. function next(errSuite) {
  4615. if (errSuite) {
  4616. // current suite failed on a hook from errSuite
  4617. if (errSuite === suite) {
  4618. // if errSuite is current suite
  4619. // continue to the next sibling suite
  4620. return done();
  4621. }
  4622. // errSuite is among the parents of current suite
  4623. // stop execution of errSuite and all sub-suites
  4624. return done(errSuite);
  4625. }
  4626. if (self._abort) {
  4627. return done();
  4628. }
  4629. var curr = suite.suites[i++];
  4630. if (!curr) {
  4631. return done();
  4632. }
  4633. // Avoid grep neglecting large number of tests causing a
  4634. // huge recursive loop and thus a maximum call stack error.
  4635. // See comment in `this.runTests()` for more information.
  4636. if (self._grep !== self._defaultGrep) {
  4637. Runner.immediately(function() {
  4638. self.runSuite(curr, next);
  4639. });
  4640. } else {
  4641. self.runSuite(curr, next);
  4642. }
  4643. }
  4644. function done(errSuite) {
  4645. self.suite = suite;
  4646. self.nextSuite = next;
  4647. if (afterAllHookCalled) {
  4648. fn(errSuite);
  4649. } else {
  4650. // mark that the afterAll block has been called once
  4651. // and so can be skipped if there is an error in it.
  4652. afterAllHookCalled = true;
  4653. // remove reference to test
  4654. delete self.test;
  4655. self.hook('afterAll', function() {
  4656. self.emit('suite end', suite);
  4657. fn(errSuite);
  4658. });
  4659. }
  4660. }
  4661. this.nextSuite = next;
  4662. this.hook('beforeAll', function(err) {
  4663. if (err) {
  4664. return done();
  4665. }
  4666. self.runTests(suite, next);
  4667. });
  4668. };
  4669. /**
  4670. * Handle uncaught exceptions.
  4671. *
  4672. * @param {Error} err
  4673. * @api private
  4674. */
  4675. Runner.prototype.uncaught = function(err) {
  4676. if (err) {
  4677. debug(
  4678. 'uncaught exception %s',
  4679. err ===
  4680. function() {
  4681. return this;
  4682. }.call(err)
  4683. ? err.message || err
  4684. : err
  4685. );
  4686. } else {
  4687. debug('uncaught undefined exception');
  4688. err = undefinedError();
  4689. }
  4690. err.uncaught = true;
  4691. var runnable = this.currentRunnable;
  4692. if (!runnable) {
  4693. runnable = new Runnable('Uncaught error outside test suite');
  4694. runnable.parent = this.suite;
  4695. if (this.started) {
  4696. this.fail(runnable, err);
  4697. } else {
  4698. // Can't recover from this failure
  4699. this.emit('start');
  4700. this.fail(runnable, err);
  4701. this.emit('end');
  4702. }
  4703. return;
  4704. }
  4705. runnable.clearTimeout();
  4706. // Ignore errors if already failed or pending
  4707. // See #3226
  4708. if (runnable.isFailed() || runnable.isPending()) {
  4709. return;
  4710. }
  4711. // we cannot recover gracefully if a Runnable has already passed
  4712. // then fails asynchronously
  4713. var alreadyPassed = runnable.isPassed();
  4714. // this will change the state to "failed" regardless of the current value
  4715. this.fail(runnable, err);
  4716. if (!alreadyPassed) {
  4717. // recover from test
  4718. if (runnable.type === 'test') {
  4719. this.emit('test end', runnable);
  4720. this.hookUp('afterEach', this.next);
  4721. return;
  4722. }
  4723. // recover from hooks
  4724. var errSuite = this.suite;
  4725. // if hook failure is in afterEach block
  4726. if (runnable.fullTitle().indexOf('after each') > -1) {
  4727. return this.hookErr(err, errSuite, true);
  4728. }
  4729. // if hook failure is in beforeEach block
  4730. if (runnable.fullTitle().indexOf('before each') > -1) {
  4731. return this.hookErr(err, errSuite, false);
  4732. }
  4733. // if hook failure is in after or before blocks
  4734. return this.nextSuite(errSuite);
  4735. }
  4736. // bail
  4737. this.emit('end');
  4738. };
  4739. /**
  4740. * Cleans up the references to all the deferred functions
  4741. * (before/after/beforeEach/afterEach) and tests of a Suite.
  4742. * These must be deleted otherwise a memory leak can happen,
  4743. * as those functions may reference variables from closures,
  4744. * thus those variables can never be garbage collected as long
  4745. * as the deferred functions exist.
  4746. *
  4747. * @param {Suite} suite
  4748. */
  4749. function cleanSuiteReferences(suite) {
  4750. function cleanArrReferences(arr) {
  4751. for (var i = 0; i < arr.length; i++) {
  4752. delete arr[i].fn;
  4753. }
  4754. }
  4755. if (Array.isArray(suite._beforeAll)) {
  4756. cleanArrReferences(suite._beforeAll);
  4757. }
  4758. if (Array.isArray(suite._beforeEach)) {
  4759. cleanArrReferences(suite._beforeEach);
  4760. }
  4761. if (Array.isArray(suite._afterAll)) {
  4762. cleanArrReferences(suite._afterAll);
  4763. }
  4764. if (Array.isArray(suite._afterEach)) {
  4765. cleanArrReferences(suite._afterEach);
  4766. }
  4767. for (var i = 0; i < suite.tests.length; i++) {
  4768. delete suite.tests[i].fn;
  4769. }
  4770. }
  4771. /**
  4772. * Run the root suite and invoke `fn(failures)`
  4773. * on completion.
  4774. *
  4775. * @api public
  4776. * @public
  4777. * @memberof Mocha.Runner
  4778. * @param {Function} fn
  4779. * @return {Runner} Runner instance.
  4780. */
  4781. Runner.prototype.run = function(fn) {
  4782. var self = this;
  4783. var rootSuite = this.suite;
  4784. fn = fn || function() {};
  4785. function uncaught(err) {
  4786. self.uncaught(err);
  4787. }
  4788. function start() {
  4789. // If there is an `only` filter
  4790. if (hasOnly(rootSuite)) {
  4791. filterOnly(rootSuite);
  4792. }
  4793. self.started = true;
  4794. self.emit('start');
  4795. self.runSuite(rootSuite, function() {
  4796. debug('finished running');
  4797. self.emit('end');
  4798. });
  4799. }
  4800. debug('start');
  4801. // references cleanup to avoid memory leaks
  4802. this.on('suite end', cleanSuiteReferences);
  4803. // callback
  4804. this.on('end', function() {
  4805. debug('end');
  4806. process.removeListener('uncaughtException', uncaught);
  4807. fn(self.failures);
  4808. });
  4809. // uncaught exception
  4810. process.on('uncaughtException', uncaught);
  4811. if (this._delay) {
  4812. // for reporters, I guess.
  4813. // might be nice to debounce some dots while we wait.
  4814. this.emit('waiting', rootSuite);
  4815. rootSuite.once('run', start);
  4816. } else {
  4817. start();
  4818. }
  4819. return this;
  4820. };
  4821. /**
  4822. * Cleanly abort execution.
  4823. *
  4824. * @memberof Mocha.Runner
  4825. * @public
  4826. * @api public
  4827. * @return {Runner} Runner instance.
  4828. */
  4829. Runner.prototype.abort = function() {
  4830. debug('aborting');
  4831. this._abort = true;
  4832. return this;
  4833. };
  4834. /**
  4835. * Filter suites based on `isOnly` logic.
  4836. *
  4837. * @param {Array} suite
  4838. * @returns {Boolean}
  4839. * @api private
  4840. */
  4841. function filterOnly(suite) {
  4842. if (suite._onlyTests.length) {
  4843. // If the suite contains `only` tests, run those and ignore any nested suites.
  4844. suite.tests = suite._onlyTests;
  4845. suite.suites = [];
  4846. } else {
  4847. // Otherwise, do not run any of the tests in this suite.
  4848. suite.tests = [];
  4849. suite._onlySuites.forEach(function(onlySuite) {
  4850. // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.
  4851. // Otherwise, all of the tests on this `only` suite should be run, so don't filter it.
  4852. if (hasOnly(onlySuite)) {
  4853. filterOnly(onlySuite);
  4854. }
  4855. });
  4856. // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.
  4857. suite.suites = suite.suites.filter(function(childSuite) {
  4858. return (
  4859. suite._onlySuites.indexOf(childSuite) !== -1 || filterOnly(childSuite)
  4860. );
  4861. });
  4862. }
  4863. // Keep the suite only if there is something to run
  4864. return suite.tests.length || suite.suites.length;
  4865. }
  4866. /**
  4867. * Determines whether a suite has an `only` test or suite as a descendant.
  4868. *
  4869. * @param {Array} suite
  4870. * @returns {Boolean}
  4871. * @api private
  4872. */
  4873. function hasOnly(suite) {
  4874. return (
  4875. suite._onlyTests.length ||
  4876. suite._onlySuites.length ||
  4877. suite.suites.some(hasOnly)
  4878. );
  4879. }
  4880. /**
  4881. * Filter leaks with the given globals flagged as `ok`.
  4882. *
  4883. * @api private
  4884. * @param {Array} ok
  4885. * @param {Array} globals
  4886. * @return {Array}
  4887. */
  4888. function filterLeaks(ok, globals) {
  4889. return globals.filter(function(key) {
  4890. // Firefox and Chrome exposes iframes as index inside the window object
  4891. if (/^\d+/.test(key)) {
  4892. return false;
  4893. }
  4894. // in firefox
  4895. // if runner runs in an iframe, this iframe's window.getInterface method
  4896. // not init at first it is assigned in some seconds
  4897. if (global.navigator && /^getInterface/.test(key)) {
  4898. return false;
  4899. }
  4900. // an iframe could be approached by window[iframeIndex]
  4901. // in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak
  4902. if (global.navigator && /^\d+/.test(key)) {
  4903. return false;
  4904. }
  4905. // Opera and IE expose global variables for HTML element IDs (issue #243)
  4906. if (/^mocha-/.test(key)) {
  4907. return false;
  4908. }
  4909. var matched = ok.filter(function(ok) {
  4910. if (~ok.indexOf('*')) {
  4911. return key.indexOf(ok.split('*')[0]) === 0;
  4912. }
  4913. return key === ok;
  4914. });
  4915. return !matched.length && (!global.navigator || key !== 'onerror');
  4916. });
  4917. }
  4918. /**
  4919. * Array of globals dependent on the environment.
  4920. *
  4921. * @return {Array}
  4922. * @api private
  4923. */
  4924. function extraGlobals() {
  4925. if (typeof process === 'object' && typeof process.version === 'string') {
  4926. var parts = process.version.split('.');
  4927. var nodeVersion = parts.reduce(function(a, v) {
  4928. return (a << 8) | v;
  4929. });
  4930. // 'errno' was renamed to process._errno in v0.9.11.
  4931. if (nodeVersion < 0x00090b) {
  4932. return ['errno'];
  4933. }
  4934. }
  4935. return [];
  4936. }
  4937. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  4938. },{"./pending":15,"./runnable":32,"./utils":36,"_process":56,"debug":43,"events":47}],34:[function(require,module,exports){
  4939. 'use strict';
  4940. /**
  4941. * @module Suite
  4942. */
  4943. /**
  4944. * Module dependencies.
  4945. */
  4946. var EventEmitter = require('events').EventEmitter;
  4947. var Hook = require('./hook');
  4948. var utils = require('./utils');
  4949. var inherits = utils.inherits;
  4950. var debug = require('debug')('mocha:suite');
  4951. var milliseconds = require('./ms');
  4952. /**
  4953. * Expose `Suite`.
  4954. */
  4955. exports = module.exports = Suite;
  4956. /**
  4957. * Create a new `Suite` with the given `title` and parent `Suite`. When a suite
  4958. * with the same title is already present, that suite is returned to provide
  4959. * nicer reporter and more flexible meta-testing.
  4960. *
  4961. * @memberof Mocha
  4962. * @public
  4963. * @api public
  4964. * @param {Suite} parent
  4965. * @param {string} title
  4966. * @return {Suite}
  4967. */
  4968. exports.create = function(parent, title) {
  4969. var suite = new Suite(title, parent.ctx);
  4970. suite.parent = parent;
  4971. title = suite.fullTitle();
  4972. parent.addSuite(suite);
  4973. return suite;
  4974. };
  4975. /**
  4976. * Initialize a new `Suite` with the given `title` and `ctx`. Derived from [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
  4977. *
  4978. * @memberof Mocha
  4979. * @public
  4980. * @class
  4981. * @param {string} title
  4982. * @param {Context} parentContext
  4983. */
  4984. function Suite(title, parentContext) {
  4985. if (!utils.isString(title)) {
  4986. throw new Error(
  4987. 'Suite `title` should be a "string" but "' +
  4988. typeof title +
  4989. '" was given instead.'
  4990. );
  4991. }
  4992. this.title = title;
  4993. function Context() {}
  4994. Context.prototype = parentContext;
  4995. this.ctx = new Context();
  4996. this.suites = [];
  4997. this.tests = [];
  4998. this.pending = false;
  4999. this._beforeEach = [];
  5000. this._beforeAll = [];
  5001. this._afterEach = [];
  5002. this._afterAll = [];
  5003. this.root = !title;
  5004. this._timeout = 2000;
  5005. this._enableTimeouts = true;
  5006. this._slow = 75;
  5007. this._bail = false;
  5008. this._retries = -1;
  5009. this._onlyTests = [];
  5010. this._onlySuites = [];
  5011. this.delayed = false;
  5012. }
  5013. /**
  5014. * Inherit from `EventEmitter.prototype`.
  5015. */
  5016. inherits(Suite, EventEmitter);
  5017. /**
  5018. * Return a clone of this `Suite`.
  5019. *
  5020. * @api private
  5021. * @return {Suite}
  5022. */
  5023. Suite.prototype.clone = function() {
  5024. var suite = new Suite(this.title);
  5025. debug('clone');
  5026. suite.ctx = this.ctx;
  5027. suite.timeout(this.timeout());
  5028. suite.retries(this.retries());
  5029. suite.enableTimeouts(this.enableTimeouts());
  5030. suite.slow(this.slow());
  5031. suite.bail(this.bail());
  5032. return suite;
  5033. };
  5034. /**
  5035. * Set or get timeout `ms` or short-hand such as "2s".
  5036. *
  5037. * @api private
  5038. * @param {number|string} ms
  5039. * @return {Suite|number} for chaining
  5040. */
  5041. Suite.prototype.timeout = function(ms) {
  5042. if (!arguments.length) {
  5043. return this._timeout;
  5044. }
  5045. if (ms.toString() === '0') {
  5046. this._enableTimeouts = false;
  5047. }
  5048. if (typeof ms === 'string') {
  5049. ms = milliseconds(ms);
  5050. }
  5051. debug('timeout %d', ms);
  5052. this._timeout = parseInt(ms, 10);
  5053. return this;
  5054. };
  5055. /**
  5056. * Set or get number of times to retry a failed test.
  5057. *
  5058. * @api private
  5059. * @param {number|string} n
  5060. * @return {Suite|number} for chaining
  5061. */
  5062. Suite.prototype.retries = function(n) {
  5063. if (!arguments.length) {
  5064. return this._retries;
  5065. }
  5066. debug('retries %d', n);
  5067. this._retries = parseInt(n, 10) || 0;
  5068. return this;
  5069. };
  5070. /**
  5071. * Set or get timeout to `enabled`.
  5072. *
  5073. * @api private
  5074. * @param {boolean} enabled
  5075. * @return {Suite|boolean} self or enabled
  5076. */
  5077. Suite.prototype.enableTimeouts = function(enabled) {
  5078. if (!arguments.length) {
  5079. return this._enableTimeouts;
  5080. }
  5081. debug('enableTimeouts %s', enabled);
  5082. this._enableTimeouts = enabled;
  5083. return this;
  5084. };
  5085. /**
  5086. * Set or get slow `ms` or short-hand such as "2s".
  5087. *
  5088. * @api private
  5089. * @param {number|string} ms
  5090. * @return {Suite|number} for chaining
  5091. */
  5092. Suite.prototype.slow = function(ms) {
  5093. if (!arguments.length) {
  5094. return this._slow;
  5095. }
  5096. if (typeof ms === 'string') {
  5097. ms = milliseconds(ms);
  5098. }
  5099. debug('slow %d', ms);
  5100. this._slow = ms;
  5101. return this;
  5102. };
  5103. /**
  5104. * Set or get whether to bail after first error.
  5105. *
  5106. * @api private
  5107. * @param {boolean} bail
  5108. * @return {Suite|number} for chaining
  5109. */
  5110. Suite.prototype.bail = function(bail) {
  5111. if (!arguments.length) {
  5112. return this._bail;
  5113. }
  5114. debug('bail %s', bail);
  5115. this._bail = bail;
  5116. return this;
  5117. };
  5118. /**
  5119. * Check if this suite or its parent suite is marked as pending.
  5120. *
  5121. * @api private
  5122. */
  5123. Suite.prototype.isPending = function() {
  5124. return this.pending || (this.parent && this.parent.isPending());
  5125. };
  5126. /**
  5127. * Generic hook-creator.
  5128. * @private
  5129. * @param {string} title - Title of hook
  5130. * @param {Function} fn - Hook callback
  5131. * @returns {Hook} A new hook
  5132. */
  5133. Suite.prototype._createHook = function(title, fn) {
  5134. var hook = new Hook(title, fn);
  5135. hook.parent = this;
  5136. hook.timeout(this.timeout());
  5137. hook.retries(this.retries());
  5138. hook.enableTimeouts(this.enableTimeouts());
  5139. hook.slow(this.slow());
  5140. hook.ctx = this.ctx;
  5141. hook.file = this.file;
  5142. return hook;
  5143. };
  5144. /**
  5145. * Run `fn(test[, done])` before running tests.
  5146. *
  5147. * @api private
  5148. * @param {string} title
  5149. * @param {Function} fn
  5150. * @return {Suite} for chaining
  5151. */
  5152. Suite.prototype.beforeAll = function(title, fn) {
  5153. if (this.isPending()) {
  5154. return this;
  5155. }
  5156. if (typeof title === 'function') {
  5157. fn = title;
  5158. title = fn.name;
  5159. }
  5160. title = '"before all" hook' + (title ? ': ' + title : '');
  5161. var hook = this._createHook(title, fn);
  5162. this._beforeAll.push(hook);
  5163. this.emit('beforeAll', hook);
  5164. return this;
  5165. };
  5166. /**
  5167. * Run `fn(test[, done])` after running tests.
  5168. *
  5169. * @api private
  5170. * @param {string} title
  5171. * @param {Function} fn
  5172. * @return {Suite} for chaining
  5173. */
  5174. Suite.prototype.afterAll = function(title, fn) {
  5175. if (this.isPending()) {
  5176. return this;
  5177. }
  5178. if (typeof title === 'function') {
  5179. fn = title;
  5180. title = fn.name;
  5181. }
  5182. title = '"after all" hook' + (title ? ': ' + title : '');
  5183. var hook = this._createHook(title, fn);
  5184. this._afterAll.push(hook);
  5185. this.emit('afterAll', hook);
  5186. return this;
  5187. };
  5188. /**
  5189. * Run `fn(test[, done])` before each test case.
  5190. *
  5191. * @api private
  5192. * @param {string} title
  5193. * @param {Function} fn
  5194. * @return {Suite} for chaining
  5195. */
  5196. Suite.prototype.beforeEach = function(title, fn) {
  5197. if (this.isPending()) {
  5198. return this;
  5199. }
  5200. if (typeof title === 'function') {
  5201. fn = title;
  5202. title = fn.name;
  5203. }
  5204. title = '"before each" hook' + (title ? ': ' + title : '');
  5205. var hook = this._createHook(title, fn);
  5206. this._beforeEach.push(hook);
  5207. this.emit('beforeEach', hook);
  5208. return this;
  5209. };
  5210. /**
  5211. * Run `fn(test[, done])` after each test case.
  5212. *
  5213. * @api private
  5214. * @param {string} title
  5215. * @param {Function} fn
  5216. * @return {Suite} for chaining
  5217. */
  5218. Suite.prototype.afterEach = function(title, fn) {
  5219. if (this.isPending()) {
  5220. return this;
  5221. }
  5222. if (typeof title === 'function') {
  5223. fn = title;
  5224. title = fn.name;
  5225. }
  5226. title = '"after each" hook' + (title ? ': ' + title : '');
  5227. var hook = this._createHook(title, fn);
  5228. this._afterEach.push(hook);
  5229. this.emit('afterEach', hook);
  5230. return this;
  5231. };
  5232. /**
  5233. * Add a test `suite`.
  5234. *
  5235. * @api private
  5236. * @param {Suite} suite
  5237. * @return {Suite} for chaining
  5238. */
  5239. Suite.prototype.addSuite = function(suite) {
  5240. suite.parent = this;
  5241. suite.timeout(this.timeout());
  5242. suite.retries(this.retries());
  5243. suite.enableTimeouts(this.enableTimeouts());
  5244. suite.slow(this.slow());
  5245. suite.bail(this.bail());
  5246. this.suites.push(suite);
  5247. this.emit('suite', suite);
  5248. return this;
  5249. };
  5250. /**
  5251. * Add a `test` to this suite.
  5252. *
  5253. * @api private
  5254. * @param {Test} test
  5255. * @return {Suite} for chaining
  5256. */
  5257. Suite.prototype.addTest = function(test) {
  5258. test.parent = this;
  5259. test.timeout(this.timeout());
  5260. test.retries(this.retries());
  5261. test.enableTimeouts(this.enableTimeouts());
  5262. test.slow(this.slow());
  5263. test.ctx = this.ctx;
  5264. this.tests.push(test);
  5265. this.emit('test', test);
  5266. return this;
  5267. };
  5268. /**
  5269. * Return the full title generated by recursively concatenating the parent's
  5270. * full title.
  5271. *
  5272. * @memberof Mocha.Suite
  5273. * @public
  5274. * @api public
  5275. * @return {string}
  5276. */
  5277. Suite.prototype.fullTitle = function() {
  5278. return this.titlePath().join(' ');
  5279. };
  5280. /**
  5281. * Return the title path generated by recursively concatenating the parent's
  5282. * title path.
  5283. *
  5284. * @memberof Mocha.Suite
  5285. * @public
  5286. * @api public
  5287. * @return {string}
  5288. */
  5289. Suite.prototype.titlePath = function() {
  5290. var result = [];
  5291. if (this.parent) {
  5292. result = result.concat(this.parent.titlePath());
  5293. }
  5294. if (!this.root) {
  5295. result.push(this.title);
  5296. }
  5297. return result;
  5298. };
  5299. /**
  5300. * Return the total number of tests.
  5301. *
  5302. * @memberof Mocha.Suite
  5303. * @public
  5304. * @api public
  5305. * @return {number}
  5306. */
  5307. Suite.prototype.total = function() {
  5308. return (
  5309. this.suites.reduce(function(sum, suite) {
  5310. return sum + suite.total();
  5311. }, 0) + this.tests.length
  5312. );
  5313. };
  5314. /**
  5315. * Iterates through each suite recursively to find all tests. Applies a
  5316. * function in the format `fn(test)`.
  5317. *
  5318. * @api private
  5319. * @param {Function} fn
  5320. * @return {Suite}
  5321. */
  5322. Suite.prototype.eachTest = function(fn) {
  5323. this.tests.forEach(fn);
  5324. this.suites.forEach(function(suite) {
  5325. suite.eachTest(fn);
  5326. });
  5327. return this;
  5328. };
  5329. /**
  5330. * This will run the root suite if we happen to be running in delayed mode.
  5331. */
  5332. Suite.prototype.run = function run() {
  5333. if (this.root) {
  5334. this.emit('run');
  5335. }
  5336. };
  5337. },{"./hook":6,"./ms":14,"./utils":36,"debug":43,"events":47}],35:[function(require,module,exports){
  5338. 'use strict';
  5339. var Runnable = require('./runnable');
  5340. var utils = require('./utils');
  5341. var isString = utils.isString;
  5342. module.exports = Test;
  5343. /**
  5344. * Initialize a new `Test` with the given `title` and callback `fn`.
  5345. *
  5346. * @class
  5347. * @extends Runnable
  5348. * @param {String} title
  5349. * @param {Function} fn
  5350. */
  5351. function Test(title, fn) {
  5352. if (!isString(title)) {
  5353. throw new Error(
  5354. 'Test `title` should be a "string" but "' +
  5355. typeof title +
  5356. '" was given instead.'
  5357. );
  5358. }
  5359. Runnable.call(this, title, fn);
  5360. this.pending = !fn;
  5361. this.type = 'test';
  5362. }
  5363. /**
  5364. * Inherit from `Runnable.prototype`.
  5365. */
  5366. utils.inherits(Test, Runnable);
  5367. Test.prototype.clone = function() {
  5368. var test = new Test(this.title, this.fn);
  5369. test.timeout(this.timeout());
  5370. test.slow(this.slow());
  5371. test.enableTimeouts(this.enableTimeouts());
  5372. test.retries(this.retries());
  5373. test.currentRetry(this.currentRetry());
  5374. test.globals(this.globals());
  5375. test.parent = this.parent;
  5376. test.file = this.file;
  5377. test.ctx = this.ctx;
  5378. return test;
  5379. };
  5380. },{"./runnable":32,"./utils":36}],36:[function(require,module,exports){
  5381. (function (process,Buffer){
  5382. 'use strict';
  5383. /**
  5384. * @module
  5385. */
  5386. /**
  5387. * Module dependencies.
  5388. */
  5389. var debug = require('debug')('mocha:watch');
  5390. var fs = require('fs');
  5391. var glob = require('glob');
  5392. var path = require('path');
  5393. var join = path.join;
  5394. var he = require('he');
  5395. /**
  5396. * Ignored directories.
  5397. */
  5398. var ignore = ['node_modules', '.git'];
  5399. exports.inherits = require('util').inherits;
  5400. /**
  5401. * Escape special characters in the given string of html.
  5402. *
  5403. * @api private
  5404. * @param {string} html
  5405. * @return {string}
  5406. */
  5407. exports.escape = function(html) {
  5408. return he.encode(String(html), {useNamedReferences: false});
  5409. };
  5410. /**
  5411. * Test if the given obj is type of string.
  5412. *
  5413. * @api private
  5414. * @param {Object} obj
  5415. * @return {boolean}
  5416. */
  5417. exports.isString = function(obj) {
  5418. return typeof obj === 'string';
  5419. };
  5420. /**
  5421. * Watch the given `files` for changes
  5422. * and invoke `fn(file)` on modification.
  5423. *
  5424. * @api private
  5425. * @param {Array} files
  5426. * @param {Function} fn
  5427. */
  5428. exports.watch = function(files, fn) {
  5429. var options = {interval: 100};
  5430. files.forEach(function(file) {
  5431. debug('file %s', file);
  5432. fs.watchFile(file, options, function(curr, prev) {
  5433. if (prev.mtime < curr.mtime) {
  5434. fn(file);
  5435. }
  5436. });
  5437. });
  5438. };
  5439. /**
  5440. * Ignored files.
  5441. *
  5442. * @api private
  5443. * @param {string} path
  5444. * @return {boolean}
  5445. */
  5446. function ignored(path) {
  5447. return !~ignore.indexOf(path);
  5448. }
  5449. /**
  5450. * Lookup files in the given `dir`.
  5451. *
  5452. * @api private
  5453. * @param {string} dir
  5454. * @param {string[]} [ext=['.js']]
  5455. * @param {Array} [ret=[]]
  5456. * @return {Array}
  5457. */
  5458. exports.files = function(dir, ext, ret) {
  5459. ret = ret || [];
  5460. ext = ext || ['js'];
  5461. var re = new RegExp('\\.(' + ext.join('|') + ')$');
  5462. fs
  5463. .readdirSync(dir)
  5464. .filter(ignored)
  5465. .forEach(function(path) {
  5466. path = join(dir, path);
  5467. if (fs.lstatSync(path).isDirectory()) {
  5468. exports.files(path, ext, ret);
  5469. } else if (path.match(re)) {
  5470. ret.push(path);
  5471. }
  5472. });
  5473. return ret;
  5474. };
  5475. /**
  5476. * Compute a slug from the given `str`.
  5477. *
  5478. * @api private
  5479. * @param {string} str
  5480. * @return {string}
  5481. */
  5482. exports.slug = function(str) {
  5483. return str
  5484. .toLowerCase()
  5485. .replace(/ +/g, '-')
  5486. .replace(/[^-\w]/g, '');
  5487. };
  5488. /**
  5489. * Strip the function definition from `str`, and re-indent for pre whitespace.
  5490. *
  5491. * @param {string} str
  5492. * @return {string}
  5493. */
  5494. exports.clean = function(str) {
  5495. str = str
  5496. .replace(/\r\n?|[\n\u2028\u2029]/g, '\n')
  5497. .replace(/^\uFEFF/, '')
  5498. // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content
  5499. .replace(
  5500. /^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/,
  5501. '$1$2$3'
  5502. );
  5503. var spaces = str.match(/^\n?( *)/)[1].length;
  5504. var tabs = str.match(/^\n?(\t*)/)[1].length;
  5505. var re = new RegExp(
  5506. '^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}',
  5507. 'gm'
  5508. );
  5509. str = str.replace(re, '');
  5510. return str.trim();
  5511. };
  5512. /**
  5513. * Parse the given `qs`.
  5514. *
  5515. * @api private
  5516. * @param {string} qs
  5517. * @return {Object}
  5518. */
  5519. exports.parseQuery = function(qs) {
  5520. return qs
  5521. .replace('?', '')
  5522. .split('&')
  5523. .reduce(function(obj, pair) {
  5524. var i = pair.indexOf('=');
  5525. var key = pair.slice(0, i);
  5526. var val = pair.slice(++i);
  5527. // Due to how the URLSearchParams API treats spaces
  5528. obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
  5529. return obj;
  5530. }, {});
  5531. };
  5532. /**
  5533. * Highlight the given string of `js`.
  5534. *
  5535. * @api private
  5536. * @param {string} js
  5537. * @return {string}
  5538. */
  5539. function highlight(js) {
  5540. return js
  5541. .replace(/</g, '&lt;')
  5542. .replace(/>/g, '&gt;')
  5543. .replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
  5544. .replace(/('.*?')/gm, '<span class="string">$1</span>')
  5545. .replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
  5546. .replace(/(\d+)/gm, '<span class="number">$1</span>')
  5547. .replace(
  5548. /\bnew[ \t]+(\w+)/gm,
  5549. '<span class="keyword">new</span> <span class="init">$1</span>'
  5550. )
  5551. .replace(
  5552. /\b(function|new|throw|return|var|if|else)\b/gm,
  5553. '<span class="keyword">$1</span>'
  5554. );
  5555. }
  5556. /**
  5557. * Highlight the contents of tag `name`.
  5558. *
  5559. * @api private
  5560. * @param {string} name
  5561. */
  5562. exports.highlightTags = function(name) {
  5563. var code = document.getElementById('mocha').getElementsByTagName(name);
  5564. for (var i = 0, len = code.length; i < len; ++i) {
  5565. code[i].innerHTML = highlight(code[i].innerHTML);
  5566. }
  5567. };
  5568. /**
  5569. * If a value could have properties, and has none, this function is called,
  5570. * which returns a string representation of the empty value.
  5571. *
  5572. * Functions w/ no properties return `'[Function]'`
  5573. * Arrays w/ length === 0 return `'[]'`
  5574. * Objects w/ no properties return `'{}'`
  5575. * All else: return result of `value.toString()`
  5576. *
  5577. * @api private
  5578. * @param {*} value The value to inspect.
  5579. * @param {string} typeHint The type of the value
  5580. * @returns {string}
  5581. */
  5582. function emptyRepresentation(value, typeHint) {
  5583. switch (typeHint) {
  5584. case 'function':
  5585. return '[Function]';
  5586. case 'object':
  5587. return '{}';
  5588. case 'array':
  5589. return '[]';
  5590. default:
  5591. return value.toString();
  5592. }
  5593. }
  5594. /**
  5595. * Takes some variable and asks `Object.prototype.toString()` what it thinks it
  5596. * is.
  5597. *
  5598. * @api private
  5599. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
  5600. * @param {*} value The value to test.
  5601. * @returns {string} Computed type
  5602. * @example
  5603. * type({}) // 'object'
  5604. * type([]) // 'array'
  5605. * type(1) // 'number'
  5606. * type(false) // 'boolean'
  5607. * type(Infinity) // 'number'
  5608. * type(null) // 'null'
  5609. * type(new Date()) // 'date'
  5610. * type(/foo/) // 'regexp'
  5611. * type('type') // 'string'
  5612. * type(global) // 'global'
  5613. * type(new String('foo') // 'object'
  5614. */
  5615. var type = (exports.type = function type(value) {
  5616. if (value === undefined) {
  5617. return 'undefined';
  5618. } else if (value === null) {
  5619. return 'null';
  5620. } else if (Buffer.isBuffer(value)) {
  5621. return 'buffer';
  5622. }
  5623. return Object.prototype.toString
  5624. .call(value)
  5625. .replace(/^\[.+\s(.+?)]$/, '$1')
  5626. .toLowerCase();
  5627. });
  5628. /**
  5629. * Stringify `value`. Different behavior depending on type of value:
  5630. *
  5631. * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
  5632. * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
  5633. * - If `value` is an *empty* object, function, or array, return result of function
  5634. * {@link emptyRepresentation}.
  5635. * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of
  5636. * JSON.stringify().
  5637. *
  5638. * @api private
  5639. * @see exports.type
  5640. * @param {*} value
  5641. * @return {string}
  5642. */
  5643. exports.stringify = function(value) {
  5644. var typeHint = type(value);
  5645. if (!~['object', 'array', 'function'].indexOf(typeHint)) {
  5646. if (typeHint === 'buffer') {
  5647. var json = Buffer.prototype.toJSON.call(value);
  5648. // Based on the toJSON result
  5649. return jsonStringify(
  5650. json.data && json.type ? json.data : json,
  5651. 2
  5652. ).replace(/,(\n|$)/g, '$1');
  5653. }
  5654. // IE7/IE8 has a bizarre String constructor; needs to be coerced
  5655. // into an array and back to obj.
  5656. if (typeHint === 'string' && typeof value === 'object') {
  5657. value = value.split('').reduce(function(acc, char, idx) {
  5658. acc[idx] = char;
  5659. return acc;
  5660. }, {});
  5661. typeHint = 'object';
  5662. } else {
  5663. return jsonStringify(value);
  5664. }
  5665. }
  5666. for (var prop in value) {
  5667. if (Object.prototype.hasOwnProperty.call(value, prop)) {
  5668. return jsonStringify(
  5669. exports.canonicalize(value, null, typeHint),
  5670. 2
  5671. ).replace(/,(\n|$)/g, '$1');
  5672. }
  5673. }
  5674. return emptyRepresentation(value, typeHint);
  5675. };
  5676. /**
  5677. * like JSON.stringify but more sense.
  5678. *
  5679. * @api private
  5680. * @param {Object} object
  5681. * @param {number=} spaces
  5682. * @param {number=} depth
  5683. * @returns {*}
  5684. */
  5685. function jsonStringify(object, spaces, depth) {
  5686. if (typeof spaces === 'undefined') {
  5687. // primitive types
  5688. return _stringify(object);
  5689. }
  5690. depth = depth || 1;
  5691. var space = spaces * depth;
  5692. var str = Array.isArray(object) ? '[' : '{';
  5693. var end = Array.isArray(object) ? ']' : '}';
  5694. var length =
  5695. typeof object.length === 'number'
  5696. ? object.length
  5697. : Object.keys(object).length;
  5698. // `.repeat()` polyfill
  5699. function repeat(s, n) {
  5700. return new Array(n).join(s);
  5701. }
  5702. function _stringify(val) {
  5703. switch (type(val)) {
  5704. case 'null':
  5705. case 'undefined':
  5706. val = '[' + val + ']';
  5707. break;
  5708. case 'array':
  5709. case 'object':
  5710. val = jsonStringify(val, spaces, depth + 1);
  5711. break;
  5712. case 'boolean':
  5713. case 'regexp':
  5714. case 'symbol':
  5715. case 'number':
  5716. val =
  5717. val === 0 && 1 / val === -Infinity // `-0`
  5718. ? '-0'
  5719. : val.toString();
  5720. break;
  5721. case 'date':
  5722. var sDate = isNaN(val.getTime()) ? val.toString() : val.toISOString();
  5723. val = '[Date: ' + sDate + ']';
  5724. break;
  5725. case 'buffer':
  5726. var json = val.toJSON();
  5727. // Based on the toJSON result
  5728. json = json.data && json.type ? json.data : json;
  5729. val = '[Buffer: ' + jsonStringify(json, 2, depth + 1) + ']';
  5730. break;
  5731. default:
  5732. val =
  5733. val === '[Function]' || val === '[Circular]'
  5734. ? val
  5735. : JSON.stringify(val); // string
  5736. }
  5737. return val;
  5738. }
  5739. for (var i in object) {
  5740. if (!Object.prototype.hasOwnProperty.call(object, i)) {
  5741. continue; // not my business
  5742. }
  5743. --length;
  5744. str +=
  5745. '\n ' +
  5746. repeat(' ', space) +
  5747. (Array.isArray(object) ? '' : '"' + i + '": ') + // key
  5748. _stringify(object[i]) + // value
  5749. (length ? ',' : ''); // comma
  5750. }
  5751. return (
  5752. str +
  5753. // [], {}
  5754. (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end)
  5755. );
  5756. }
  5757. /**
  5758. * Return a new Thing that has the keys in sorted order. Recursive.
  5759. *
  5760. * If the Thing...
  5761. * - has already been seen, return string `'[Circular]'`
  5762. * - is `undefined`, return string `'[undefined]'`
  5763. * - is `null`, return value `null`
  5764. * - is some other primitive, return the value
  5765. * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method
  5766. * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again.
  5767. * - is an empty `Array`, `Object`, or `Function`, return the result of calling `emptyRepresentation()`
  5768. *
  5769. * @api private
  5770. * @see {@link exports.stringify}
  5771. * @param {*} value Thing to inspect. May or may not have properties.
  5772. * @param {Array} [stack=[]] Stack of seen values
  5773. * @param {string} [typeHint] Type hint
  5774. * @return {(Object|Array|Function|string|undefined)}
  5775. */
  5776. exports.canonicalize = function canonicalize(value, stack, typeHint) {
  5777. var canonicalizedObj;
  5778. /* eslint-disable no-unused-vars */
  5779. var prop;
  5780. /* eslint-enable no-unused-vars */
  5781. typeHint = typeHint || type(value);
  5782. function withStack(value, fn) {
  5783. stack.push(value);
  5784. fn();
  5785. stack.pop();
  5786. }
  5787. stack = stack || [];
  5788. if (stack.indexOf(value) !== -1) {
  5789. return '[Circular]';
  5790. }
  5791. switch (typeHint) {
  5792. case 'undefined':
  5793. case 'buffer':
  5794. case 'null':
  5795. canonicalizedObj = value;
  5796. break;
  5797. case 'array':
  5798. withStack(value, function() {
  5799. canonicalizedObj = value.map(function(item) {
  5800. return exports.canonicalize(item, stack);
  5801. });
  5802. });
  5803. break;
  5804. case 'function':
  5805. /* eslint-disable guard-for-in */
  5806. for (prop in value) {
  5807. canonicalizedObj = {};
  5808. break;
  5809. }
  5810. /* eslint-enable guard-for-in */
  5811. if (!canonicalizedObj) {
  5812. canonicalizedObj = emptyRepresentation(value, typeHint);
  5813. break;
  5814. }
  5815. /* falls through */
  5816. case 'object':
  5817. canonicalizedObj = canonicalizedObj || {};
  5818. withStack(value, function() {
  5819. Object.keys(value)
  5820. .sort()
  5821. .forEach(function(key) {
  5822. canonicalizedObj[key] = exports.canonicalize(value[key], stack);
  5823. });
  5824. });
  5825. break;
  5826. case 'date':
  5827. case 'number':
  5828. case 'regexp':
  5829. case 'boolean':
  5830. case 'symbol':
  5831. canonicalizedObj = value;
  5832. break;
  5833. default:
  5834. canonicalizedObj = value + '';
  5835. }
  5836. return canonicalizedObj;
  5837. };
  5838. /**
  5839. * Lookup file names at the given `path`.
  5840. *
  5841. * @memberof Mocha.utils
  5842. * @public
  5843. * @api public
  5844. * @param {string} filepath Base path to start searching from.
  5845. * @param {string[]} extensions File extensions to look for.
  5846. * @param {boolean} recursive Whether or not to recurse into subdirectories.
  5847. * @return {string[]} An array of paths.
  5848. */
  5849. exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {
  5850. var files = [];
  5851. if (!fs.existsSync(filepath)) {
  5852. if (fs.existsSync(filepath + '.js')) {
  5853. filepath += '.js';
  5854. } else {
  5855. files = glob.sync(filepath);
  5856. if (!files.length) {
  5857. throw new Error("cannot resolve path (or pattern) '" + filepath + "'");
  5858. }
  5859. return files;
  5860. }
  5861. }
  5862. try {
  5863. var stat = fs.statSync(filepath);
  5864. if (stat.isFile()) {
  5865. return filepath;
  5866. }
  5867. } catch (err) {
  5868. // ignore error
  5869. return;
  5870. }
  5871. fs.readdirSync(filepath).forEach(function(file) {
  5872. file = path.join(filepath, file);
  5873. try {
  5874. var stat = fs.statSync(file);
  5875. if (stat.isDirectory()) {
  5876. if (recursive) {
  5877. files = files.concat(lookupFiles(file, extensions, recursive));
  5878. }
  5879. return;
  5880. }
  5881. } catch (err) {
  5882. // ignore error
  5883. return;
  5884. }
  5885. if (!extensions) {
  5886. throw new Error(
  5887. 'extensions parameter required when filepath is a directory'
  5888. );
  5889. }
  5890. var re = new RegExp('\\.(?:' + extensions.join('|') + ')$');
  5891. if (!stat.isFile() || !re.test(file) || path.basename(file)[0] === '.') {
  5892. return;
  5893. }
  5894. files.push(file);
  5895. });
  5896. return files;
  5897. };
  5898. /**
  5899. * Generate an undefined error with a message warning the user.
  5900. *
  5901. * @return {Error}
  5902. */
  5903. exports.undefinedError = function() {
  5904. return new Error(
  5905. 'Caught undefined error, did you throw without specifying what?'
  5906. );
  5907. };
  5908. /**
  5909. * Generate an undefined error if `err` is not defined.
  5910. *
  5911. * @param {Error} err
  5912. * @return {Error}
  5913. */
  5914. exports.getError = function(err) {
  5915. return err || exports.undefinedError();
  5916. };
  5917. /**
  5918. * @summary
  5919. * This Filter based on `mocha-clean` module.(see: `github.com/rstacruz/mocha-clean`)
  5920. * @description
  5921. * When invoking this function you get a filter function that get the Error.stack as an input,
  5922. * and return a prettify output.
  5923. * (i.e: strip Mocha and internal node functions from stack trace).
  5924. * @returns {Function}
  5925. */
  5926. exports.stackTraceFilter = function() {
  5927. // TODO: Replace with `process.browser`
  5928. var is = typeof document === 'undefined' ? {node: true} : {browser: true};
  5929. var slash = path.sep;
  5930. var cwd;
  5931. if (is.node) {
  5932. cwd = process.cwd() + slash;
  5933. } else {
  5934. cwd = (typeof location === 'undefined'
  5935. ? window.location
  5936. : location
  5937. ).href.replace(/\/[^/]*$/, '/');
  5938. slash = '/';
  5939. }
  5940. function isMochaInternal(line) {
  5941. return (
  5942. ~line.indexOf('node_modules' + slash + 'mocha' + slash) ||
  5943. ~line.indexOf('node_modules' + slash + 'mocha.js') ||
  5944. ~line.indexOf('bower_components' + slash + 'mocha.js') ||
  5945. ~line.indexOf(slash + 'mocha.js')
  5946. );
  5947. }
  5948. function isNodeInternal(line) {
  5949. return (
  5950. ~line.indexOf('(timers.js:') ||
  5951. ~line.indexOf('(events.js:') ||
  5952. ~line.indexOf('(node.js:') ||
  5953. ~line.indexOf('(module.js:') ||
  5954. ~line.indexOf('GeneratorFunctionPrototype.next (native)') ||
  5955. false
  5956. );
  5957. }
  5958. return function(stack) {
  5959. stack = stack.split('\n');
  5960. stack = stack.reduce(function(list, line) {
  5961. if (isMochaInternal(line)) {
  5962. return list;
  5963. }
  5964. if (is.node && isNodeInternal(line)) {
  5965. return list;
  5966. }
  5967. // Clean up cwd(absolute)
  5968. if (/\(?.+:\d+:\d+\)?$/.test(line)) {
  5969. line = line.replace('(' + cwd, '(');
  5970. }
  5971. list.push(line);
  5972. return list;
  5973. }, []);
  5974. return stack.join('\n');
  5975. };
  5976. };
  5977. /**
  5978. * Crude, but effective.
  5979. * @api
  5980. * @param {*} value
  5981. * @returns {boolean} Whether or not `value` is a Promise
  5982. */
  5983. exports.isPromise = function isPromise(value) {
  5984. return typeof value === 'object' && typeof value.then === 'function';
  5985. };
  5986. /**
  5987. * It's a noop.
  5988. * @api
  5989. */
  5990. exports.noop = function() {};
  5991. }).call(this,require('_process'),require("buffer").Buffer)
  5992. },{"_process":56,"buffer":41,"debug":43,"fs":40,"glob":40,"he":48,"path":40,"util":76}],37:[function(require,module,exports){
  5993. 'use strict'
  5994. exports.byteLength = byteLength
  5995. exports.toByteArray = toByteArray
  5996. exports.fromByteArray = fromByteArray
  5997. var lookup = []
  5998. var revLookup = []
  5999. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  6000. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  6001. for (var i = 0, len = code.length; i < len; ++i) {
  6002. lookup[i] = code[i]
  6003. revLookup[code.charCodeAt(i)] = i
  6004. }
  6005. // Support decoding URL-safe base64 strings, as Node.js does.
  6006. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  6007. revLookup['-'.charCodeAt(0)] = 62
  6008. revLookup['_'.charCodeAt(0)] = 63
  6009. function getLens (b64) {
  6010. var len = b64.length
  6011. if (len % 4 > 0) {
  6012. throw new Error('Invalid string. Length must be a multiple of 4')
  6013. }
  6014. // Trim off extra bytes after placeholder bytes are found
  6015. // See: https://github.com/beatgammit/base64-js/issues/42
  6016. var validLen = b64.indexOf('=')
  6017. if (validLen === -1) validLen = len
  6018. var placeHoldersLen = validLen === len
  6019. ? 0
  6020. : 4 - (validLen % 4)
  6021. return [validLen, placeHoldersLen]
  6022. }
  6023. // base64 is 4/3 + up to two characters of the original data
  6024. function byteLength (b64) {
  6025. var lens = getLens(b64)
  6026. var validLen = lens[0]
  6027. var placeHoldersLen = lens[1]
  6028. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  6029. }
  6030. function _byteLength (b64, validLen, placeHoldersLen) {
  6031. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  6032. }
  6033. function toByteArray (b64) {
  6034. var tmp
  6035. var lens = getLens(b64)
  6036. var validLen = lens[0]
  6037. var placeHoldersLen = lens[1]
  6038. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  6039. var curByte = 0
  6040. // if there are placeholders, only get up to the last complete 4 chars
  6041. var len = placeHoldersLen > 0
  6042. ? validLen - 4
  6043. : validLen
  6044. for (var i = 0; i < len; i += 4) {
  6045. tmp =
  6046. (revLookup[b64.charCodeAt(i)] << 18) |
  6047. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  6048. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  6049. revLookup[b64.charCodeAt(i + 3)]
  6050. arr[curByte++] = (tmp >> 16) & 0xFF
  6051. arr[curByte++] = (tmp >> 8) & 0xFF
  6052. arr[curByte++] = tmp & 0xFF
  6053. }
  6054. if (placeHoldersLen === 2) {
  6055. tmp =
  6056. (revLookup[b64.charCodeAt(i)] << 2) |
  6057. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  6058. arr[curByte++] = tmp & 0xFF
  6059. }
  6060. if (placeHoldersLen === 1) {
  6061. tmp =
  6062. (revLookup[b64.charCodeAt(i)] << 10) |
  6063. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  6064. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  6065. arr[curByte++] = (tmp >> 8) & 0xFF
  6066. arr[curByte++] = tmp & 0xFF
  6067. }
  6068. return arr
  6069. }
  6070. function tripletToBase64 (num) {
  6071. return lookup[num >> 18 & 0x3F] +
  6072. lookup[num >> 12 & 0x3F] +
  6073. lookup[num >> 6 & 0x3F] +
  6074. lookup[num & 0x3F]
  6075. }
  6076. function encodeChunk (uint8, start, end) {
  6077. var tmp
  6078. var output = []
  6079. for (var i = start; i < end; i += 3) {
  6080. tmp =
  6081. ((uint8[i] << 16) & 0xFF0000) +
  6082. ((uint8[i + 1] << 8) & 0xFF00) +
  6083. (uint8[i + 2] & 0xFF)
  6084. output.push(tripletToBase64(tmp))
  6085. }
  6086. return output.join('')
  6087. }
  6088. function fromByteArray (uint8) {
  6089. var tmp
  6090. var len = uint8.length
  6091. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  6092. var parts = []
  6093. var maxChunkLength = 16383 // must be multiple of 3
  6094. // go through the array every three bytes, we'll deal with trailing stuff later
  6095. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  6096. parts.push(encodeChunk(
  6097. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  6098. ))
  6099. }
  6100. // pad the end with zeros, but make sure to not forget the extra bytes
  6101. if (extraBytes === 1) {
  6102. tmp = uint8[len - 1]
  6103. parts.push(
  6104. lookup[tmp >> 2] +
  6105. lookup[(tmp << 4) & 0x3F] +
  6106. '=='
  6107. )
  6108. } else if (extraBytes === 2) {
  6109. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  6110. parts.push(
  6111. lookup[tmp >> 10] +
  6112. lookup[(tmp >> 4) & 0x3F] +
  6113. lookup[(tmp << 2) & 0x3F] +
  6114. '='
  6115. )
  6116. }
  6117. return parts.join('')
  6118. }
  6119. },{}],38:[function(require,module,exports){
  6120. },{}],39:[function(require,module,exports){
  6121. (function (process){
  6122. var WritableStream = require('stream').Writable
  6123. var inherits = require('util').inherits
  6124. module.exports = BrowserStdout
  6125. inherits(BrowserStdout, WritableStream)
  6126. function BrowserStdout(opts) {
  6127. if (!(this instanceof BrowserStdout)) return new BrowserStdout(opts)
  6128. opts = opts || {}
  6129. WritableStream.call(this, opts)
  6130. this.label = (opts.label !== undefined) ? opts.label : 'stdout'
  6131. }
  6132. BrowserStdout.prototype._write = function(chunks, encoding, cb) {
  6133. var output = chunks.toString ? chunks.toString() : chunks
  6134. if (this.label === false) {
  6135. console.log(output)
  6136. } else {
  6137. console.log(this.label+':', output)
  6138. }
  6139. process.nextTick(cb)
  6140. }
  6141. }).call(this,require('_process'))
  6142. },{"_process":56,"stream":71,"util":76}],40:[function(require,module,exports){
  6143. arguments[4][38][0].apply(exports,arguments)
  6144. },{"dup":38}],41:[function(require,module,exports){
  6145. /*!
  6146. * The buffer module from node.js, for the browser.
  6147. *
  6148. * @author Feross Aboukhadijeh <https://feross.org>
  6149. * @license MIT
  6150. */
  6151. /* eslint-disable no-proto */
  6152. 'use strict'
  6153. var base64 = require('base64-js')
  6154. var ieee754 = require('ieee754')
  6155. exports.Buffer = Buffer
  6156. exports.SlowBuffer = SlowBuffer
  6157. exports.INSPECT_MAX_BYTES = 50
  6158. var K_MAX_LENGTH = 0x7fffffff
  6159. exports.kMaxLength = K_MAX_LENGTH
  6160. /**
  6161. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  6162. * === true Use Uint8Array implementation (fastest)
  6163. * === false Print warning and recommend using `buffer` v4.x which has an Object
  6164. * implementation (most compatible, even IE6)
  6165. *
  6166. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  6167. * Opera 11.6+, iOS 4.2+.
  6168. *
  6169. * We report that the browser does not support typed arrays if the are not subclassable
  6170. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  6171. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  6172. * for __proto__ and has a buggy typed array implementation.
  6173. */
  6174. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  6175. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  6176. typeof console.error === 'function') {
  6177. console.error(
  6178. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  6179. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  6180. )
  6181. }
  6182. function typedArraySupport () {
  6183. // Can typed array instances can be augmented?
  6184. try {
  6185. var arr = new Uint8Array(1)
  6186. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  6187. return arr.foo() === 42
  6188. } catch (e) {
  6189. return false
  6190. }
  6191. }
  6192. Object.defineProperty(Buffer.prototype, 'parent', {
  6193. get: function () {
  6194. if (!(this instanceof Buffer)) {
  6195. return undefined
  6196. }
  6197. return this.buffer
  6198. }
  6199. })
  6200. Object.defineProperty(Buffer.prototype, 'offset', {
  6201. get: function () {
  6202. if (!(this instanceof Buffer)) {
  6203. return undefined
  6204. }
  6205. return this.byteOffset
  6206. }
  6207. })
  6208. function createBuffer (length) {
  6209. if (length > K_MAX_LENGTH) {
  6210. throw new RangeError('Invalid typed array length')
  6211. }
  6212. // Return an augmented `Uint8Array` instance
  6213. var buf = new Uint8Array(length)
  6214. buf.__proto__ = Buffer.prototype
  6215. return buf
  6216. }
  6217. /**
  6218. * The Buffer constructor returns instances of `Uint8Array` that have their
  6219. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  6220. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  6221. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  6222. * returns a single octet.
  6223. *
  6224. * The `Uint8Array` prototype remains unmodified.
  6225. */
  6226. function Buffer (arg, encodingOrOffset, length) {
  6227. // Common case.
  6228. if (typeof arg === 'number') {
  6229. if (typeof encodingOrOffset === 'string') {
  6230. throw new Error(
  6231. 'If encoding is specified then the first argument must be a string'
  6232. )
  6233. }
  6234. return allocUnsafe(arg)
  6235. }
  6236. return from(arg, encodingOrOffset, length)
  6237. }
  6238. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  6239. if (typeof Symbol !== 'undefined' && Symbol.species &&
  6240. Buffer[Symbol.species] === Buffer) {
  6241. Object.defineProperty(Buffer, Symbol.species, {
  6242. value: null,
  6243. configurable: true,
  6244. enumerable: false,
  6245. writable: false
  6246. })
  6247. }
  6248. Buffer.poolSize = 8192 // not used by this implementation
  6249. function from (value, encodingOrOffset, length) {
  6250. if (typeof value === 'number') {
  6251. throw new TypeError('"value" argument must not be a number')
  6252. }
  6253. if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) {
  6254. return fromArrayBuffer(value, encodingOrOffset, length)
  6255. }
  6256. if (typeof value === 'string') {
  6257. return fromString(value, encodingOrOffset)
  6258. }
  6259. return fromObject(value)
  6260. }
  6261. /**
  6262. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  6263. * if value is a number.
  6264. * Buffer.from(str[, encoding])
  6265. * Buffer.from(array)
  6266. * Buffer.from(buffer)
  6267. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  6268. **/
  6269. Buffer.from = function (value, encodingOrOffset, length) {
  6270. return from(value, encodingOrOffset, length)
  6271. }
  6272. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  6273. // https://github.com/feross/buffer/pull/148
  6274. Buffer.prototype.__proto__ = Uint8Array.prototype
  6275. Buffer.__proto__ = Uint8Array
  6276. function assertSize (size) {
  6277. if (typeof size !== 'number') {
  6278. throw new TypeError('"size" argument must be of type number')
  6279. } else if (size < 0) {
  6280. throw new RangeError('"size" argument must not be negative')
  6281. }
  6282. }
  6283. function alloc (size, fill, encoding) {
  6284. assertSize(size)
  6285. if (size <= 0) {
  6286. return createBuffer(size)
  6287. }
  6288. if (fill !== undefined) {
  6289. // Only pay attention to encoding if it's a string. This
  6290. // prevents accidentally sending in a number that would
  6291. // be interpretted as a start offset.
  6292. return typeof encoding === 'string'
  6293. ? createBuffer(size).fill(fill, encoding)
  6294. : createBuffer(size).fill(fill)
  6295. }
  6296. return createBuffer(size)
  6297. }
  6298. /**
  6299. * Creates a new filled Buffer instance.
  6300. * alloc(size[, fill[, encoding]])
  6301. **/
  6302. Buffer.alloc = function (size, fill, encoding) {
  6303. return alloc(size, fill, encoding)
  6304. }
  6305. function allocUnsafe (size) {
  6306. assertSize(size)
  6307. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  6308. }
  6309. /**
  6310. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  6311. * */
  6312. Buffer.allocUnsafe = function (size) {
  6313. return allocUnsafe(size)
  6314. }
  6315. /**
  6316. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  6317. */
  6318. Buffer.allocUnsafeSlow = function (size) {
  6319. return allocUnsafe(size)
  6320. }
  6321. function fromString (string, encoding) {
  6322. if (typeof encoding !== 'string' || encoding === '') {
  6323. encoding = 'utf8'
  6324. }
  6325. if (!Buffer.isEncoding(encoding)) {
  6326. throw new TypeError('Unknown encoding: ' + encoding)
  6327. }
  6328. var length = byteLength(string, encoding) | 0
  6329. var buf = createBuffer(length)
  6330. var actual = buf.write(string, encoding)
  6331. if (actual !== length) {
  6332. // Writing a hex string, for example, that contains invalid characters will
  6333. // cause everything after the first invalid character to be ignored. (e.g.
  6334. // 'abxxcd' will be treated as 'ab')
  6335. buf = buf.slice(0, actual)
  6336. }
  6337. return buf
  6338. }
  6339. function fromArrayLike (array) {
  6340. var length = array.length < 0 ? 0 : checked(array.length) | 0
  6341. var buf = createBuffer(length)
  6342. for (var i = 0; i < length; i += 1) {
  6343. buf[i] = array[i] & 255
  6344. }
  6345. return buf
  6346. }
  6347. function fromArrayBuffer (array, byteOffset, length) {
  6348. if (byteOffset < 0 || array.byteLength < byteOffset) {
  6349. throw new RangeError('"offset" is outside of buffer bounds')
  6350. }
  6351. if (array.byteLength < byteOffset + (length || 0)) {
  6352. throw new RangeError('"length" is outside of buffer bounds')
  6353. }
  6354. var buf
  6355. if (byteOffset === undefined && length === undefined) {
  6356. buf = new Uint8Array(array)
  6357. } else if (length === undefined) {
  6358. buf = new Uint8Array(array, byteOffset)
  6359. } else {
  6360. buf = new Uint8Array(array, byteOffset, length)
  6361. }
  6362. // Return an augmented `Uint8Array` instance
  6363. buf.__proto__ = Buffer.prototype
  6364. return buf
  6365. }
  6366. function fromObject (obj) {
  6367. if (Buffer.isBuffer(obj)) {
  6368. var len = checked(obj.length) | 0
  6369. var buf = createBuffer(len)
  6370. if (buf.length === 0) {
  6371. return buf
  6372. }
  6373. obj.copy(buf, 0, 0, len)
  6374. return buf
  6375. }
  6376. if (obj) {
  6377. if (ArrayBuffer.isView(obj) || 'length' in obj) {
  6378. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  6379. return createBuffer(0)
  6380. }
  6381. return fromArrayLike(obj)
  6382. }
  6383. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  6384. return fromArrayLike(obj.data)
  6385. }
  6386. }
  6387. throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.')
  6388. }
  6389. function checked (length) {
  6390. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  6391. // length is NaN (which is otherwise coerced to zero.)
  6392. if (length >= K_MAX_LENGTH) {
  6393. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  6394. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  6395. }
  6396. return length | 0
  6397. }
  6398. function SlowBuffer (length) {
  6399. if (+length != length) { // eslint-disable-line eqeqeq
  6400. length = 0
  6401. }
  6402. return Buffer.alloc(+length)
  6403. }
  6404. Buffer.isBuffer = function isBuffer (b) {
  6405. return b != null && b._isBuffer === true
  6406. }
  6407. Buffer.compare = function compare (a, b) {
  6408. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  6409. throw new TypeError('Arguments must be Buffers')
  6410. }
  6411. if (a === b) return 0
  6412. var x = a.length
  6413. var y = b.length
  6414. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  6415. if (a[i] !== b[i]) {
  6416. x = a[i]
  6417. y = b[i]
  6418. break
  6419. }
  6420. }
  6421. if (x < y) return -1
  6422. if (y < x) return 1
  6423. return 0
  6424. }
  6425. Buffer.isEncoding = function isEncoding (encoding) {
  6426. switch (String(encoding).toLowerCase()) {
  6427. case 'hex':
  6428. case 'utf8':
  6429. case 'utf-8':
  6430. case 'ascii':
  6431. case 'latin1':
  6432. case 'binary':
  6433. case 'base64':
  6434. case 'ucs2':
  6435. case 'ucs-2':
  6436. case 'utf16le':
  6437. case 'utf-16le':
  6438. return true
  6439. default:
  6440. return false
  6441. }
  6442. }
  6443. Buffer.concat = function concat (list, length) {
  6444. if (!Array.isArray(list)) {
  6445. throw new TypeError('"list" argument must be an Array of Buffers')
  6446. }
  6447. if (list.length === 0) {
  6448. return Buffer.alloc(0)
  6449. }
  6450. var i
  6451. if (length === undefined) {
  6452. length = 0
  6453. for (i = 0; i < list.length; ++i) {
  6454. length += list[i].length
  6455. }
  6456. }
  6457. var buffer = Buffer.allocUnsafe(length)
  6458. var pos = 0
  6459. for (i = 0; i < list.length; ++i) {
  6460. var buf = list[i]
  6461. if (ArrayBuffer.isView(buf)) {
  6462. buf = Buffer.from(buf)
  6463. }
  6464. if (!Buffer.isBuffer(buf)) {
  6465. throw new TypeError('"list" argument must be an Array of Buffers')
  6466. }
  6467. buf.copy(buffer, pos)
  6468. pos += buf.length
  6469. }
  6470. return buffer
  6471. }
  6472. function byteLength (string, encoding) {
  6473. if (Buffer.isBuffer(string)) {
  6474. return string.length
  6475. }
  6476. if (ArrayBuffer.isView(string) || isArrayBuffer(string)) {
  6477. return string.byteLength
  6478. }
  6479. if (typeof string !== 'string') {
  6480. string = '' + string
  6481. }
  6482. var len = string.length
  6483. if (len === 0) return 0
  6484. // Use a for loop to avoid recursion
  6485. var loweredCase = false
  6486. for (;;) {
  6487. switch (encoding) {
  6488. case 'ascii':
  6489. case 'latin1':
  6490. case 'binary':
  6491. return len
  6492. case 'utf8':
  6493. case 'utf-8':
  6494. case undefined:
  6495. return utf8ToBytes(string).length
  6496. case 'ucs2':
  6497. case 'ucs-2':
  6498. case 'utf16le':
  6499. case 'utf-16le':
  6500. return len * 2
  6501. case 'hex':
  6502. return len >>> 1
  6503. case 'base64':
  6504. return base64ToBytes(string).length
  6505. default:
  6506. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  6507. encoding = ('' + encoding).toLowerCase()
  6508. loweredCase = true
  6509. }
  6510. }
  6511. }
  6512. Buffer.byteLength = byteLength
  6513. function slowToString (encoding, start, end) {
  6514. var loweredCase = false
  6515. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  6516. // property of a typed array.
  6517. // This behaves neither like String nor Uint8Array in that we set start/end
  6518. // to their upper/lower bounds if the value passed is out of range.
  6519. // undefined is handled specially as per ECMA-262 6th Edition,
  6520. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  6521. if (start === undefined || start < 0) {
  6522. start = 0
  6523. }
  6524. // Return early if start > this.length. Done here to prevent potential uint32
  6525. // coercion fail below.
  6526. if (start > this.length) {
  6527. return ''
  6528. }
  6529. if (end === undefined || end > this.length) {
  6530. end = this.length
  6531. }
  6532. if (end <= 0) {
  6533. return ''
  6534. }
  6535. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  6536. end >>>= 0
  6537. start >>>= 0
  6538. if (end <= start) {
  6539. return ''
  6540. }
  6541. if (!encoding) encoding = 'utf8'
  6542. while (true) {
  6543. switch (encoding) {
  6544. case 'hex':
  6545. return hexSlice(this, start, end)
  6546. case 'utf8':
  6547. case 'utf-8':
  6548. return utf8Slice(this, start, end)
  6549. case 'ascii':
  6550. return asciiSlice(this, start, end)
  6551. case 'latin1':
  6552. case 'binary':
  6553. return latin1Slice(this, start, end)
  6554. case 'base64':
  6555. return base64Slice(this, start, end)
  6556. case 'ucs2':
  6557. case 'ucs-2':
  6558. case 'utf16le':
  6559. case 'utf-16le':
  6560. return utf16leSlice(this, start, end)
  6561. default:
  6562. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6563. encoding = (encoding + '').toLowerCase()
  6564. loweredCase = true
  6565. }
  6566. }
  6567. }
  6568. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  6569. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  6570. // reliably in a browserify context because there could be multiple different
  6571. // copies of the 'buffer' package in use. This method works even for Buffer
  6572. // instances that were created from another copy of the `buffer` package.
  6573. // See: https://github.com/feross/buffer/issues/154
  6574. Buffer.prototype._isBuffer = true
  6575. function swap (b, n, m) {
  6576. var i = b[n]
  6577. b[n] = b[m]
  6578. b[m] = i
  6579. }
  6580. Buffer.prototype.swap16 = function swap16 () {
  6581. var len = this.length
  6582. if (len % 2 !== 0) {
  6583. throw new RangeError('Buffer size must be a multiple of 16-bits')
  6584. }
  6585. for (var i = 0; i < len; i += 2) {
  6586. swap(this, i, i + 1)
  6587. }
  6588. return this
  6589. }
  6590. Buffer.prototype.swap32 = function swap32 () {
  6591. var len = this.length
  6592. if (len % 4 !== 0) {
  6593. throw new RangeError('Buffer size must be a multiple of 32-bits')
  6594. }
  6595. for (var i = 0; i < len; i += 4) {
  6596. swap(this, i, i + 3)
  6597. swap(this, i + 1, i + 2)
  6598. }
  6599. return this
  6600. }
  6601. Buffer.prototype.swap64 = function swap64 () {
  6602. var len = this.length
  6603. if (len % 8 !== 0) {
  6604. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6605. }
  6606. for (var i = 0; i < len; i += 8) {
  6607. swap(this, i, i + 7)
  6608. swap(this, i + 1, i + 6)
  6609. swap(this, i + 2, i + 5)
  6610. swap(this, i + 3, i + 4)
  6611. }
  6612. return this
  6613. }
  6614. Buffer.prototype.toString = function toString () {
  6615. var length = this.length
  6616. if (length === 0) return ''
  6617. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6618. return slowToString.apply(this, arguments)
  6619. }
  6620. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  6621. Buffer.prototype.equals = function equals (b) {
  6622. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6623. if (this === b) return true
  6624. return Buffer.compare(this, b) === 0
  6625. }
  6626. Buffer.prototype.inspect = function inspect () {
  6627. var str = ''
  6628. var max = exports.INSPECT_MAX_BYTES
  6629. if (this.length > 0) {
  6630. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6631. if (this.length > max) str += ' ... '
  6632. }
  6633. return '<Buffer ' + str + '>'
  6634. }
  6635. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6636. if (!Buffer.isBuffer(target)) {
  6637. throw new TypeError('Argument must be a Buffer')
  6638. }
  6639. if (start === undefined) {
  6640. start = 0
  6641. }
  6642. if (end === undefined) {
  6643. end = target ? target.length : 0
  6644. }
  6645. if (thisStart === undefined) {
  6646. thisStart = 0
  6647. }
  6648. if (thisEnd === undefined) {
  6649. thisEnd = this.length
  6650. }
  6651. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6652. throw new RangeError('out of range index')
  6653. }
  6654. if (thisStart >= thisEnd && start >= end) {
  6655. return 0
  6656. }
  6657. if (thisStart >= thisEnd) {
  6658. return -1
  6659. }
  6660. if (start >= end) {
  6661. return 1
  6662. }
  6663. start >>>= 0
  6664. end >>>= 0
  6665. thisStart >>>= 0
  6666. thisEnd >>>= 0
  6667. if (this === target) return 0
  6668. var x = thisEnd - thisStart
  6669. var y = end - start
  6670. var len = Math.min(x, y)
  6671. var thisCopy = this.slice(thisStart, thisEnd)
  6672. var targetCopy = target.slice(start, end)
  6673. for (var i = 0; i < len; ++i) {
  6674. if (thisCopy[i] !== targetCopy[i]) {
  6675. x = thisCopy[i]
  6676. y = targetCopy[i]
  6677. break
  6678. }
  6679. }
  6680. if (x < y) return -1
  6681. if (y < x) return 1
  6682. return 0
  6683. }
  6684. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6685. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6686. //
  6687. // Arguments:
  6688. // - buffer - a Buffer to search
  6689. // - val - a string, Buffer, or number
  6690. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6691. // - encoding - an optional encoding, relevant is val is a string
  6692. // - dir - true for indexOf, false for lastIndexOf
  6693. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6694. // Empty buffer means no match
  6695. if (buffer.length === 0) return -1
  6696. // Normalize byteOffset
  6697. if (typeof byteOffset === 'string') {
  6698. encoding = byteOffset
  6699. byteOffset = 0
  6700. } else if (byteOffset > 0x7fffffff) {
  6701. byteOffset = 0x7fffffff
  6702. } else if (byteOffset < -0x80000000) {
  6703. byteOffset = -0x80000000
  6704. }
  6705. byteOffset = +byteOffset // Coerce to Number.
  6706. if (numberIsNaN(byteOffset)) {
  6707. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6708. byteOffset = dir ? 0 : (buffer.length - 1)
  6709. }
  6710. // Normalize byteOffset: negative offsets start from the end of the buffer
  6711. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6712. if (byteOffset >= buffer.length) {
  6713. if (dir) return -1
  6714. else byteOffset = buffer.length - 1
  6715. } else if (byteOffset < 0) {
  6716. if (dir) byteOffset = 0
  6717. else return -1
  6718. }
  6719. // Normalize val
  6720. if (typeof val === 'string') {
  6721. val = Buffer.from(val, encoding)
  6722. }
  6723. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6724. if (Buffer.isBuffer(val)) {
  6725. // Special case: looking for empty string/buffer always fails
  6726. if (val.length === 0) {
  6727. return -1
  6728. }
  6729. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6730. } else if (typeof val === 'number') {
  6731. val = val & 0xFF // Search for a byte value [0-255]
  6732. if (typeof Uint8Array.prototype.indexOf === 'function') {
  6733. if (dir) {
  6734. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6735. } else {
  6736. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6737. }
  6738. }
  6739. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6740. }
  6741. throw new TypeError('val must be string, number or Buffer')
  6742. }
  6743. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6744. var indexSize = 1
  6745. var arrLength = arr.length
  6746. var valLength = val.length
  6747. if (encoding !== undefined) {
  6748. encoding = String(encoding).toLowerCase()
  6749. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6750. encoding === 'utf16le' || encoding === 'utf-16le') {
  6751. if (arr.length < 2 || val.length < 2) {
  6752. return -1
  6753. }
  6754. indexSize = 2
  6755. arrLength /= 2
  6756. valLength /= 2
  6757. byteOffset /= 2
  6758. }
  6759. }
  6760. function read (buf, i) {
  6761. if (indexSize === 1) {
  6762. return buf[i]
  6763. } else {
  6764. return buf.readUInt16BE(i * indexSize)
  6765. }
  6766. }
  6767. var i
  6768. if (dir) {
  6769. var foundIndex = -1
  6770. for (i = byteOffset; i < arrLength; i++) {
  6771. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6772. if (foundIndex === -1) foundIndex = i
  6773. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6774. } else {
  6775. if (foundIndex !== -1) i -= i - foundIndex
  6776. foundIndex = -1
  6777. }
  6778. }
  6779. } else {
  6780. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6781. for (i = byteOffset; i >= 0; i--) {
  6782. var found = true
  6783. for (var j = 0; j < valLength; j++) {
  6784. if (read(arr, i + j) !== read(val, j)) {
  6785. found = false
  6786. break
  6787. }
  6788. }
  6789. if (found) return i
  6790. }
  6791. }
  6792. return -1
  6793. }
  6794. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6795. return this.indexOf(val, byteOffset, encoding) !== -1
  6796. }
  6797. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6798. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6799. }
  6800. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6801. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6802. }
  6803. function hexWrite (buf, string, offset, length) {
  6804. offset = Number(offset) || 0
  6805. var remaining = buf.length - offset
  6806. if (!length) {
  6807. length = remaining
  6808. } else {
  6809. length = Number(length)
  6810. if (length > remaining) {
  6811. length = remaining
  6812. }
  6813. }
  6814. var strLen = string.length
  6815. if (length > strLen / 2) {
  6816. length = strLen / 2
  6817. }
  6818. for (var i = 0; i < length; ++i) {
  6819. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6820. if (numberIsNaN(parsed)) return i
  6821. buf[offset + i] = parsed
  6822. }
  6823. return i
  6824. }
  6825. function utf8Write (buf, string, offset, length) {
  6826. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6827. }
  6828. function asciiWrite (buf, string, offset, length) {
  6829. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6830. }
  6831. function latin1Write (buf, string, offset, length) {
  6832. return asciiWrite(buf, string, offset, length)
  6833. }
  6834. function base64Write (buf, string, offset, length) {
  6835. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6836. }
  6837. function ucs2Write (buf, string, offset, length) {
  6838. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6839. }
  6840. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6841. // Buffer#write(string)
  6842. if (offset === undefined) {
  6843. encoding = 'utf8'
  6844. length = this.length
  6845. offset = 0
  6846. // Buffer#write(string, encoding)
  6847. } else if (length === undefined && typeof offset === 'string') {
  6848. encoding = offset
  6849. length = this.length
  6850. offset = 0
  6851. // Buffer#write(string, offset[, length][, encoding])
  6852. } else if (isFinite(offset)) {
  6853. offset = offset >>> 0
  6854. if (isFinite(length)) {
  6855. length = length >>> 0
  6856. if (encoding === undefined) encoding = 'utf8'
  6857. } else {
  6858. encoding = length
  6859. length = undefined
  6860. }
  6861. } else {
  6862. throw new Error(
  6863. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6864. )
  6865. }
  6866. var remaining = this.length - offset
  6867. if (length === undefined || length > remaining) length = remaining
  6868. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6869. throw new RangeError('Attempt to write outside buffer bounds')
  6870. }
  6871. if (!encoding) encoding = 'utf8'
  6872. var loweredCase = false
  6873. for (;;) {
  6874. switch (encoding) {
  6875. case 'hex':
  6876. return hexWrite(this, string, offset, length)
  6877. case 'utf8':
  6878. case 'utf-8':
  6879. return utf8Write(this, string, offset, length)
  6880. case 'ascii':
  6881. return asciiWrite(this, string, offset, length)
  6882. case 'latin1':
  6883. case 'binary':
  6884. return latin1Write(this, string, offset, length)
  6885. case 'base64':
  6886. // Warning: maxLength not taken into account in base64Write
  6887. return base64Write(this, string, offset, length)
  6888. case 'ucs2':
  6889. case 'ucs-2':
  6890. case 'utf16le':
  6891. case 'utf-16le':
  6892. return ucs2Write(this, string, offset, length)
  6893. default:
  6894. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6895. encoding = ('' + encoding).toLowerCase()
  6896. loweredCase = true
  6897. }
  6898. }
  6899. }
  6900. Buffer.prototype.toJSON = function toJSON () {
  6901. return {
  6902. type: 'Buffer',
  6903. data: Array.prototype.slice.call(this._arr || this, 0)
  6904. }
  6905. }
  6906. function base64Slice (buf, start, end) {
  6907. if (start === 0 && end === buf.length) {
  6908. return base64.fromByteArray(buf)
  6909. } else {
  6910. return base64.fromByteArray(buf.slice(start, end))
  6911. }
  6912. }
  6913. function utf8Slice (buf, start, end) {
  6914. end = Math.min(buf.length, end)
  6915. var res = []
  6916. var i = start
  6917. while (i < end) {
  6918. var firstByte = buf[i]
  6919. var codePoint = null
  6920. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6921. : (firstByte > 0xDF) ? 3
  6922. : (firstByte > 0xBF) ? 2
  6923. : 1
  6924. if (i + bytesPerSequence <= end) {
  6925. var secondByte, thirdByte, fourthByte, tempCodePoint
  6926. switch (bytesPerSequence) {
  6927. case 1:
  6928. if (firstByte < 0x80) {
  6929. codePoint = firstByte
  6930. }
  6931. break
  6932. case 2:
  6933. secondByte = buf[i + 1]
  6934. if ((secondByte & 0xC0) === 0x80) {
  6935. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6936. if (tempCodePoint > 0x7F) {
  6937. codePoint = tempCodePoint
  6938. }
  6939. }
  6940. break
  6941. case 3:
  6942. secondByte = buf[i + 1]
  6943. thirdByte = buf[i + 2]
  6944. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6945. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6946. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6947. codePoint = tempCodePoint
  6948. }
  6949. }
  6950. break
  6951. case 4:
  6952. secondByte = buf[i + 1]
  6953. thirdByte = buf[i + 2]
  6954. fourthByte = buf[i + 3]
  6955. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6956. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6957. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6958. codePoint = tempCodePoint
  6959. }
  6960. }
  6961. }
  6962. }
  6963. if (codePoint === null) {
  6964. // we did not generate a valid codePoint so insert a
  6965. // replacement char (U+FFFD) and advance only 1 byte
  6966. codePoint = 0xFFFD
  6967. bytesPerSequence = 1
  6968. } else if (codePoint > 0xFFFF) {
  6969. // encode to utf16 (surrogate pair dance)
  6970. codePoint -= 0x10000
  6971. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6972. codePoint = 0xDC00 | codePoint & 0x3FF
  6973. }
  6974. res.push(codePoint)
  6975. i += bytesPerSequence
  6976. }
  6977. return decodeCodePointsArray(res)
  6978. }
  6979. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6980. // the lowest limit is Chrome, with 0x10000 args.
  6981. // We go 1 magnitude less, for safety
  6982. var MAX_ARGUMENTS_LENGTH = 0x1000
  6983. function decodeCodePointsArray (codePoints) {
  6984. var len = codePoints.length
  6985. if (len <= MAX_ARGUMENTS_LENGTH) {
  6986. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6987. }
  6988. // Decode in chunks to avoid "call stack size exceeded".
  6989. var res = ''
  6990. var i = 0
  6991. while (i < len) {
  6992. res += String.fromCharCode.apply(
  6993. String,
  6994. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6995. )
  6996. }
  6997. return res
  6998. }
  6999. function asciiSlice (buf, start, end) {
  7000. var ret = ''
  7001. end = Math.min(buf.length, end)
  7002. for (var i = start; i < end; ++i) {
  7003. ret += String.fromCharCode(buf[i] & 0x7F)
  7004. }
  7005. return ret
  7006. }
  7007. function latin1Slice (buf, start, end) {
  7008. var ret = ''
  7009. end = Math.min(buf.length, end)
  7010. for (var i = start; i < end; ++i) {
  7011. ret += String.fromCharCode(buf[i])
  7012. }
  7013. return ret
  7014. }
  7015. function hexSlice (buf, start, end) {
  7016. var len = buf.length
  7017. if (!start || start < 0) start = 0
  7018. if (!end || end < 0 || end > len) end = len
  7019. var out = ''
  7020. for (var i = start; i < end; ++i) {
  7021. out += toHex(buf[i])
  7022. }
  7023. return out
  7024. }
  7025. function utf16leSlice (buf, start, end) {
  7026. var bytes = buf.slice(start, end)
  7027. var res = ''
  7028. for (var i = 0; i < bytes.length; i += 2) {
  7029. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  7030. }
  7031. return res
  7032. }
  7033. Buffer.prototype.slice = function slice (start, end) {
  7034. var len = this.length
  7035. start = ~~start
  7036. end = end === undefined ? len : ~~end
  7037. if (start < 0) {
  7038. start += len
  7039. if (start < 0) start = 0
  7040. } else if (start > len) {
  7041. start = len
  7042. }
  7043. if (end < 0) {
  7044. end += len
  7045. if (end < 0) end = 0
  7046. } else if (end > len) {
  7047. end = len
  7048. }
  7049. if (end < start) end = start
  7050. var newBuf = this.subarray(start, end)
  7051. // Return an augmented `Uint8Array` instance
  7052. newBuf.__proto__ = Buffer.prototype
  7053. return newBuf
  7054. }
  7055. /*
  7056. * Need to make sure that buffer isn't trying to write out of bounds.
  7057. */
  7058. function checkOffset (offset, ext, length) {
  7059. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  7060. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  7061. }
  7062. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  7063. offset = offset >>> 0
  7064. byteLength = byteLength >>> 0
  7065. if (!noAssert) checkOffset(offset, byteLength, this.length)
  7066. var val = this[offset]
  7067. var mul = 1
  7068. var i = 0
  7069. while (++i < byteLength && (mul *= 0x100)) {
  7070. val += this[offset + i] * mul
  7071. }
  7072. return val
  7073. }
  7074. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  7075. offset = offset >>> 0
  7076. byteLength = byteLength >>> 0
  7077. if (!noAssert) {
  7078. checkOffset(offset, byteLength, this.length)
  7079. }
  7080. var val = this[offset + --byteLength]
  7081. var mul = 1
  7082. while (byteLength > 0 && (mul *= 0x100)) {
  7083. val += this[offset + --byteLength] * mul
  7084. }
  7085. return val
  7086. }
  7087. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  7088. offset = offset >>> 0
  7089. if (!noAssert) checkOffset(offset, 1, this.length)
  7090. return this[offset]
  7091. }
  7092. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  7093. offset = offset >>> 0
  7094. if (!noAssert) checkOffset(offset, 2, this.length)
  7095. return this[offset] | (this[offset + 1] << 8)
  7096. }
  7097. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  7098. offset = offset >>> 0
  7099. if (!noAssert) checkOffset(offset, 2, this.length)
  7100. return (this[offset] << 8) | this[offset + 1]
  7101. }
  7102. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  7103. offset = offset >>> 0
  7104. if (!noAssert) checkOffset(offset, 4, this.length)
  7105. return ((this[offset]) |
  7106. (this[offset + 1] << 8) |
  7107. (this[offset + 2] << 16)) +
  7108. (this[offset + 3] * 0x1000000)
  7109. }
  7110. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  7111. offset = offset >>> 0
  7112. if (!noAssert) checkOffset(offset, 4, this.length)
  7113. return (this[offset] * 0x1000000) +
  7114. ((this[offset + 1] << 16) |
  7115. (this[offset + 2] << 8) |
  7116. this[offset + 3])
  7117. }
  7118. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  7119. offset = offset >>> 0
  7120. byteLength = byteLength >>> 0
  7121. if (!noAssert) checkOffset(offset, byteLength, this.length)
  7122. var val = this[offset]
  7123. var mul = 1
  7124. var i = 0
  7125. while (++i < byteLength && (mul *= 0x100)) {
  7126. val += this[offset + i] * mul
  7127. }
  7128. mul *= 0x80
  7129. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  7130. return val
  7131. }
  7132. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  7133. offset = offset >>> 0
  7134. byteLength = byteLength >>> 0
  7135. if (!noAssert) checkOffset(offset, byteLength, this.length)
  7136. var i = byteLength
  7137. var mul = 1
  7138. var val = this[offset + --i]
  7139. while (i > 0 && (mul *= 0x100)) {
  7140. val += this[offset + --i] * mul
  7141. }
  7142. mul *= 0x80
  7143. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  7144. return val
  7145. }
  7146. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  7147. offset = offset >>> 0
  7148. if (!noAssert) checkOffset(offset, 1, this.length)
  7149. if (!(this[offset] & 0x80)) return (this[offset])
  7150. return ((0xff - this[offset] + 1) * -1)
  7151. }
  7152. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  7153. offset = offset >>> 0
  7154. if (!noAssert) checkOffset(offset, 2, this.length)
  7155. var val = this[offset] | (this[offset + 1] << 8)
  7156. return (val & 0x8000) ? val | 0xFFFF0000 : val
  7157. }
  7158. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  7159. offset = offset >>> 0
  7160. if (!noAssert) checkOffset(offset, 2, this.length)
  7161. var val = this[offset + 1] | (this[offset] << 8)
  7162. return (val & 0x8000) ? val | 0xFFFF0000 : val
  7163. }
  7164. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  7165. offset = offset >>> 0
  7166. if (!noAssert) checkOffset(offset, 4, this.length)
  7167. return (this[offset]) |
  7168. (this[offset + 1] << 8) |
  7169. (this[offset + 2] << 16) |
  7170. (this[offset + 3] << 24)
  7171. }
  7172. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  7173. offset = offset >>> 0
  7174. if (!noAssert) checkOffset(offset, 4, this.length)
  7175. return (this[offset] << 24) |
  7176. (this[offset + 1] << 16) |
  7177. (this[offset + 2] << 8) |
  7178. (this[offset + 3])
  7179. }
  7180. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  7181. offset = offset >>> 0
  7182. if (!noAssert) checkOffset(offset, 4, this.length)
  7183. return ieee754.read(this, offset, true, 23, 4)
  7184. }
  7185. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  7186. offset = offset >>> 0
  7187. if (!noAssert) checkOffset(offset, 4, this.length)
  7188. return ieee754.read(this, offset, false, 23, 4)
  7189. }
  7190. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  7191. offset = offset >>> 0
  7192. if (!noAssert) checkOffset(offset, 8, this.length)
  7193. return ieee754.read(this, offset, true, 52, 8)
  7194. }
  7195. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  7196. offset = offset >>> 0
  7197. if (!noAssert) checkOffset(offset, 8, this.length)
  7198. return ieee754.read(this, offset, false, 52, 8)
  7199. }
  7200. function checkInt (buf, value, offset, ext, max, min) {
  7201. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  7202. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  7203. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  7204. }
  7205. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  7206. value = +value
  7207. offset = offset >>> 0
  7208. byteLength = byteLength >>> 0
  7209. if (!noAssert) {
  7210. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  7211. checkInt(this, value, offset, byteLength, maxBytes, 0)
  7212. }
  7213. var mul = 1
  7214. var i = 0
  7215. this[offset] = value & 0xFF
  7216. while (++i < byteLength && (mul *= 0x100)) {
  7217. this[offset + i] = (value / mul) & 0xFF
  7218. }
  7219. return offset + byteLength
  7220. }
  7221. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  7222. value = +value
  7223. offset = offset >>> 0
  7224. byteLength = byteLength >>> 0
  7225. if (!noAssert) {
  7226. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  7227. checkInt(this, value, offset, byteLength, maxBytes, 0)
  7228. }
  7229. var i = byteLength - 1
  7230. var mul = 1
  7231. this[offset + i] = value & 0xFF
  7232. while (--i >= 0 && (mul *= 0x100)) {
  7233. this[offset + i] = (value / mul) & 0xFF
  7234. }
  7235. return offset + byteLength
  7236. }
  7237. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  7238. value = +value
  7239. offset = offset >>> 0
  7240. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  7241. this[offset] = (value & 0xff)
  7242. return offset + 1
  7243. }
  7244. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  7245. value = +value
  7246. offset = offset >>> 0
  7247. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  7248. this[offset] = (value & 0xff)
  7249. this[offset + 1] = (value >>> 8)
  7250. return offset + 2
  7251. }
  7252. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  7253. value = +value
  7254. offset = offset >>> 0
  7255. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  7256. this[offset] = (value >>> 8)
  7257. this[offset + 1] = (value & 0xff)
  7258. return offset + 2
  7259. }
  7260. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  7261. value = +value
  7262. offset = offset >>> 0
  7263. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  7264. this[offset + 3] = (value >>> 24)
  7265. this[offset + 2] = (value >>> 16)
  7266. this[offset + 1] = (value >>> 8)
  7267. this[offset] = (value & 0xff)
  7268. return offset + 4
  7269. }
  7270. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  7271. value = +value
  7272. offset = offset >>> 0
  7273. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  7274. this[offset] = (value >>> 24)
  7275. this[offset + 1] = (value >>> 16)
  7276. this[offset + 2] = (value >>> 8)
  7277. this[offset + 3] = (value & 0xff)
  7278. return offset + 4
  7279. }
  7280. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  7281. value = +value
  7282. offset = offset >>> 0
  7283. if (!noAssert) {
  7284. var limit = Math.pow(2, (8 * byteLength) - 1)
  7285. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  7286. }
  7287. var i = 0
  7288. var mul = 1
  7289. var sub = 0
  7290. this[offset] = value & 0xFF
  7291. while (++i < byteLength && (mul *= 0x100)) {
  7292. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  7293. sub = 1
  7294. }
  7295. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  7296. }
  7297. return offset + byteLength
  7298. }
  7299. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  7300. value = +value
  7301. offset = offset >>> 0
  7302. if (!noAssert) {
  7303. var limit = Math.pow(2, (8 * byteLength) - 1)
  7304. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  7305. }
  7306. var i = byteLength - 1
  7307. var mul = 1
  7308. var sub = 0
  7309. this[offset + i] = value & 0xFF
  7310. while (--i >= 0 && (mul *= 0x100)) {
  7311. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  7312. sub = 1
  7313. }
  7314. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  7315. }
  7316. return offset + byteLength
  7317. }
  7318. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  7319. value = +value
  7320. offset = offset >>> 0
  7321. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  7322. if (value < 0) value = 0xff + value + 1
  7323. this[offset] = (value & 0xff)
  7324. return offset + 1
  7325. }
  7326. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  7327. value = +value
  7328. offset = offset >>> 0
  7329. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  7330. this[offset] = (value & 0xff)
  7331. this[offset + 1] = (value >>> 8)
  7332. return offset + 2
  7333. }
  7334. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  7335. value = +value
  7336. offset = offset >>> 0
  7337. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  7338. this[offset] = (value >>> 8)
  7339. this[offset + 1] = (value & 0xff)
  7340. return offset + 2
  7341. }
  7342. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  7343. value = +value
  7344. offset = offset >>> 0
  7345. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  7346. this[offset] = (value & 0xff)
  7347. this[offset + 1] = (value >>> 8)
  7348. this[offset + 2] = (value >>> 16)
  7349. this[offset + 3] = (value >>> 24)
  7350. return offset + 4
  7351. }
  7352. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  7353. value = +value
  7354. offset = offset >>> 0
  7355. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  7356. if (value < 0) value = 0xffffffff + value + 1
  7357. this[offset] = (value >>> 24)
  7358. this[offset + 1] = (value >>> 16)
  7359. this[offset + 2] = (value >>> 8)
  7360. this[offset + 3] = (value & 0xff)
  7361. return offset + 4
  7362. }
  7363. function checkIEEE754 (buf, value, offset, ext, max, min) {
  7364. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  7365. if (offset < 0) throw new RangeError('Index out of range')
  7366. }
  7367. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  7368. value = +value
  7369. offset = offset >>> 0
  7370. if (!noAssert) {
  7371. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  7372. }
  7373. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  7374. return offset + 4
  7375. }
  7376. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  7377. return writeFloat(this, value, offset, true, noAssert)
  7378. }
  7379. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  7380. return writeFloat(this, value, offset, false, noAssert)
  7381. }
  7382. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  7383. value = +value
  7384. offset = offset >>> 0
  7385. if (!noAssert) {
  7386. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  7387. }
  7388. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  7389. return offset + 8
  7390. }
  7391. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  7392. return writeDouble(this, value, offset, true, noAssert)
  7393. }
  7394. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  7395. return writeDouble(this, value, offset, false, noAssert)
  7396. }
  7397. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  7398. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  7399. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  7400. if (!start) start = 0
  7401. if (!end && end !== 0) end = this.length
  7402. if (targetStart >= target.length) targetStart = target.length
  7403. if (!targetStart) targetStart = 0
  7404. if (end > 0 && end < start) end = start
  7405. // Copy 0 bytes; we're done
  7406. if (end === start) return 0
  7407. if (target.length === 0 || this.length === 0) return 0
  7408. // Fatal error conditions
  7409. if (targetStart < 0) {
  7410. throw new RangeError('targetStart out of bounds')
  7411. }
  7412. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  7413. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  7414. // Are we oob?
  7415. if (end > this.length) end = this.length
  7416. if (target.length - targetStart < end - start) {
  7417. end = target.length - targetStart + start
  7418. }
  7419. var len = end - start
  7420. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  7421. // Use built-in when available, missing from IE11
  7422. this.copyWithin(targetStart, start, end)
  7423. } else if (this === target && start < targetStart && targetStart < end) {
  7424. // descending copy from end
  7425. for (var i = len - 1; i >= 0; --i) {
  7426. target[i + targetStart] = this[i + start]
  7427. }
  7428. } else {
  7429. Uint8Array.prototype.set.call(
  7430. target,
  7431. this.subarray(start, end),
  7432. targetStart
  7433. )
  7434. }
  7435. return len
  7436. }
  7437. // Usage:
  7438. // buffer.fill(number[, offset[, end]])
  7439. // buffer.fill(buffer[, offset[, end]])
  7440. // buffer.fill(string[, offset[, end]][, encoding])
  7441. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  7442. // Handle string cases:
  7443. if (typeof val === 'string') {
  7444. if (typeof start === 'string') {
  7445. encoding = start
  7446. start = 0
  7447. end = this.length
  7448. } else if (typeof end === 'string') {
  7449. encoding = end
  7450. end = this.length
  7451. }
  7452. if (encoding !== undefined && typeof encoding !== 'string') {
  7453. throw new TypeError('encoding must be a string')
  7454. }
  7455. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  7456. throw new TypeError('Unknown encoding: ' + encoding)
  7457. }
  7458. if (val.length === 1) {
  7459. var code = val.charCodeAt(0)
  7460. if ((encoding === 'utf8' && code < 128) ||
  7461. encoding === 'latin1') {
  7462. // Fast path: If `val` fits into a single byte, use that numeric value.
  7463. val = code
  7464. }
  7465. }
  7466. } else if (typeof val === 'number') {
  7467. val = val & 255
  7468. }
  7469. // Invalid ranges are not set to a default, so can range check early.
  7470. if (start < 0 || this.length < start || this.length < end) {
  7471. throw new RangeError('Out of range index')
  7472. }
  7473. if (end <= start) {
  7474. return this
  7475. }
  7476. start = start >>> 0
  7477. end = end === undefined ? this.length : end >>> 0
  7478. if (!val) val = 0
  7479. var i
  7480. if (typeof val === 'number') {
  7481. for (i = start; i < end; ++i) {
  7482. this[i] = val
  7483. }
  7484. } else {
  7485. var bytes = Buffer.isBuffer(val)
  7486. ? val
  7487. : new Buffer(val, encoding)
  7488. var len = bytes.length
  7489. if (len === 0) {
  7490. throw new TypeError('The value "' + val +
  7491. '" is invalid for argument "value"')
  7492. }
  7493. for (i = 0; i < end - start; ++i) {
  7494. this[i + start] = bytes[i % len]
  7495. }
  7496. }
  7497. return this
  7498. }
  7499. // HELPER FUNCTIONS
  7500. // ================
  7501. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  7502. function base64clean (str) {
  7503. // Node takes equal signs as end of the Base64 encoding
  7504. str = str.split('=')[0]
  7505. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  7506. str = str.trim().replace(INVALID_BASE64_RE, '')
  7507. // Node converts strings with length < 2 to ''
  7508. if (str.length < 2) return ''
  7509. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  7510. while (str.length % 4 !== 0) {
  7511. str = str + '='
  7512. }
  7513. return str
  7514. }
  7515. function toHex (n) {
  7516. if (n < 16) return '0' + n.toString(16)
  7517. return n.toString(16)
  7518. }
  7519. function utf8ToBytes (string, units) {
  7520. units = units || Infinity
  7521. var codePoint
  7522. var length = string.length
  7523. var leadSurrogate = null
  7524. var bytes = []
  7525. for (var i = 0; i < length; ++i) {
  7526. codePoint = string.charCodeAt(i)
  7527. // is surrogate component
  7528. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  7529. // last char was a lead
  7530. if (!leadSurrogate) {
  7531. // no lead yet
  7532. if (codePoint > 0xDBFF) {
  7533. // unexpected trail
  7534. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7535. continue
  7536. } else if (i + 1 === length) {
  7537. // unpaired lead
  7538. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7539. continue
  7540. }
  7541. // valid lead
  7542. leadSurrogate = codePoint
  7543. continue
  7544. }
  7545. // 2 leads in a row
  7546. if (codePoint < 0xDC00) {
  7547. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7548. leadSurrogate = codePoint
  7549. continue
  7550. }
  7551. // valid surrogate pair
  7552. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  7553. } else if (leadSurrogate) {
  7554. // valid bmp char, but last char was a lead
  7555. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7556. }
  7557. leadSurrogate = null
  7558. // encode utf8
  7559. if (codePoint < 0x80) {
  7560. if ((units -= 1) < 0) break
  7561. bytes.push(codePoint)
  7562. } else if (codePoint < 0x800) {
  7563. if ((units -= 2) < 0) break
  7564. bytes.push(
  7565. codePoint >> 0x6 | 0xC0,
  7566. codePoint & 0x3F | 0x80
  7567. )
  7568. } else if (codePoint < 0x10000) {
  7569. if ((units -= 3) < 0) break
  7570. bytes.push(
  7571. codePoint >> 0xC | 0xE0,
  7572. codePoint >> 0x6 & 0x3F | 0x80,
  7573. codePoint & 0x3F | 0x80
  7574. )
  7575. } else if (codePoint < 0x110000) {
  7576. if ((units -= 4) < 0) break
  7577. bytes.push(
  7578. codePoint >> 0x12 | 0xF0,
  7579. codePoint >> 0xC & 0x3F | 0x80,
  7580. codePoint >> 0x6 & 0x3F | 0x80,
  7581. codePoint & 0x3F | 0x80
  7582. )
  7583. } else {
  7584. throw new Error('Invalid code point')
  7585. }
  7586. }
  7587. return bytes
  7588. }
  7589. function asciiToBytes (str) {
  7590. var byteArray = []
  7591. for (var i = 0; i < str.length; ++i) {
  7592. // Node's code seems to be doing this and not & 0x7F..
  7593. byteArray.push(str.charCodeAt(i) & 0xFF)
  7594. }
  7595. return byteArray
  7596. }
  7597. function utf16leToBytes (str, units) {
  7598. var c, hi, lo
  7599. var byteArray = []
  7600. for (var i = 0; i < str.length; ++i) {
  7601. if ((units -= 2) < 0) break
  7602. c = str.charCodeAt(i)
  7603. hi = c >> 8
  7604. lo = c % 256
  7605. byteArray.push(lo)
  7606. byteArray.push(hi)
  7607. }
  7608. return byteArray
  7609. }
  7610. function base64ToBytes (str) {
  7611. return base64.toByteArray(base64clean(str))
  7612. }
  7613. function blitBuffer (src, dst, offset, length) {
  7614. for (var i = 0; i < length; ++i) {
  7615. if ((i + offset >= dst.length) || (i >= src.length)) break
  7616. dst[i + offset] = src[i]
  7617. }
  7618. return i
  7619. }
  7620. // ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
  7621. // but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
  7622. function isArrayBuffer (obj) {
  7623. return obj instanceof ArrayBuffer ||
  7624. (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
  7625. typeof obj.byteLength === 'number')
  7626. }
  7627. function numberIsNaN (obj) {
  7628. return obj !== obj // eslint-disable-line no-self-compare
  7629. }
  7630. },{"base64-js":37,"ieee754":49}],42:[function(require,module,exports){
  7631. (function (Buffer){
  7632. // Copyright Joyent, Inc. and other Node contributors.
  7633. //
  7634. // Permission is hereby granted, free of charge, to any person obtaining a
  7635. // copy of this software and associated documentation files (the
  7636. // "Software"), to deal in the Software without restriction, including
  7637. // without limitation the rights to use, copy, modify, merge, publish,
  7638. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7639. // persons to whom the Software is furnished to do so, subject to the
  7640. // following conditions:
  7641. //
  7642. // The above copyright notice and this permission notice shall be included
  7643. // in all copies or substantial portions of the Software.
  7644. //
  7645. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7646. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7647. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7648. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7649. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7650. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7651. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7652. // NOTE: These type checking functions intentionally don't use `instanceof`
  7653. // because it is fragile and can be easily faked with `Object.create()`.
  7654. function isArray(arg) {
  7655. if (Array.isArray) {
  7656. return Array.isArray(arg);
  7657. }
  7658. return objectToString(arg) === '[object Array]';
  7659. }
  7660. exports.isArray = isArray;
  7661. function isBoolean(arg) {
  7662. return typeof arg === 'boolean';
  7663. }
  7664. exports.isBoolean = isBoolean;
  7665. function isNull(arg) {
  7666. return arg === null;
  7667. }
  7668. exports.isNull = isNull;
  7669. function isNullOrUndefined(arg) {
  7670. return arg == null;
  7671. }
  7672. exports.isNullOrUndefined = isNullOrUndefined;
  7673. function isNumber(arg) {
  7674. return typeof arg === 'number';
  7675. }
  7676. exports.isNumber = isNumber;
  7677. function isString(arg) {
  7678. return typeof arg === 'string';
  7679. }
  7680. exports.isString = isString;
  7681. function isSymbol(arg) {
  7682. return typeof arg === 'symbol';
  7683. }
  7684. exports.isSymbol = isSymbol;
  7685. function isUndefined(arg) {
  7686. return arg === void 0;
  7687. }
  7688. exports.isUndefined = isUndefined;
  7689. function isRegExp(re) {
  7690. return objectToString(re) === '[object RegExp]';
  7691. }
  7692. exports.isRegExp = isRegExp;
  7693. function isObject(arg) {
  7694. return typeof arg === 'object' && arg !== null;
  7695. }
  7696. exports.isObject = isObject;
  7697. function isDate(d) {
  7698. return objectToString(d) === '[object Date]';
  7699. }
  7700. exports.isDate = isDate;
  7701. function isError(e) {
  7702. return (objectToString(e) === '[object Error]' || e instanceof Error);
  7703. }
  7704. exports.isError = isError;
  7705. function isFunction(arg) {
  7706. return typeof arg === 'function';
  7707. }
  7708. exports.isFunction = isFunction;
  7709. function isPrimitive(arg) {
  7710. return arg === null ||
  7711. typeof arg === 'boolean' ||
  7712. typeof arg === 'number' ||
  7713. typeof arg === 'string' ||
  7714. typeof arg === 'symbol' || // ES6 symbol
  7715. typeof arg === 'undefined';
  7716. }
  7717. exports.isPrimitive = isPrimitive;
  7718. exports.isBuffer = Buffer.isBuffer;
  7719. function objectToString(o) {
  7720. return Object.prototype.toString.call(o);
  7721. }
  7722. }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
  7723. },{"../../is-buffer/index.js":51}],43:[function(require,module,exports){
  7724. (function (process){
  7725. /**
  7726. * This is the web browser implementation of `debug()`.
  7727. *
  7728. * Expose `debug()` as the module.
  7729. */
  7730. exports = module.exports = require('./debug');
  7731. exports.log = log;
  7732. exports.formatArgs = formatArgs;
  7733. exports.save = save;
  7734. exports.load = load;
  7735. exports.useColors = useColors;
  7736. exports.storage = 'undefined' != typeof chrome
  7737. && 'undefined' != typeof chrome.storage
  7738. ? chrome.storage.local
  7739. : localstorage();
  7740. /**
  7741. * Colors.
  7742. */
  7743. exports.colors = [
  7744. '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
  7745. '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
  7746. '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
  7747. '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
  7748. '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
  7749. '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
  7750. '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
  7751. '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
  7752. '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
  7753. '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
  7754. '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
  7755. ];
  7756. /**
  7757. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  7758. * and the Firebug extension (any Firefox version) are known
  7759. * to support "%c" CSS customizations.
  7760. *
  7761. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  7762. */
  7763. function useColors() {
  7764. // NB: In an Electron preload script, document will be defined but not fully
  7765. // initialized. Since we know we're in Chrome, we'll just detect this case
  7766. // explicitly
  7767. if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
  7768. return true;
  7769. }
  7770. // Internet Explorer and Edge do not support colors.
  7771. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  7772. return false;
  7773. }
  7774. // is webkit? http://stackoverflow.com/a/16459606/376773
  7775. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  7776. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  7777. // is firebug? http://stackoverflow.com/a/398120/376773
  7778. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  7779. // is firefox >= v31?
  7780. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  7781. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  7782. // double check webkit in userAgent just in case we are in a worker
  7783. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  7784. }
  7785. /**
  7786. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  7787. */
  7788. exports.formatters.j = function(v) {
  7789. try {
  7790. return JSON.stringify(v);
  7791. } catch (err) {
  7792. return '[UnexpectedJSONParseError]: ' + err.message;
  7793. }
  7794. };
  7795. /**
  7796. * Colorize log arguments if enabled.
  7797. *
  7798. * @api public
  7799. */
  7800. function formatArgs(args) {
  7801. var useColors = this.useColors;
  7802. args[0] = (useColors ? '%c' : '')
  7803. + this.namespace
  7804. + (useColors ? ' %c' : ' ')
  7805. + args[0]
  7806. + (useColors ? '%c ' : ' ')
  7807. + '+' + exports.humanize(this.diff);
  7808. if (!useColors) return;
  7809. var c = 'color: ' + this.color;
  7810. args.splice(1, 0, c, 'color: inherit')
  7811. // the final "%c" is somewhat tricky, because there could be other
  7812. // arguments passed either before or after the %c, so we need to
  7813. // figure out the correct index to insert the CSS into
  7814. var index = 0;
  7815. var lastC = 0;
  7816. args[0].replace(/%[a-zA-Z%]/g, function(match) {
  7817. if ('%%' === match) return;
  7818. index++;
  7819. if ('%c' === match) {
  7820. // we only are interested in the *last* %c
  7821. // (the user may have provided their own)
  7822. lastC = index;
  7823. }
  7824. });
  7825. args.splice(lastC, 0, c);
  7826. }
  7827. /**
  7828. * Invokes `console.log()` when available.
  7829. * No-op when `console.log` is not a "function".
  7830. *
  7831. * @api public
  7832. */
  7833. function log() {
  7834. // this hackery is required for IE8/9, where
  7835. // the `console.log` function doesn't have 'apply'
  7836. return 'object' === typeof console
  7837. && console.log
  7838. && Function.prototype.apply.call(console.log, console, arguments);
  7839. }
  7840. /**
  7841. * Save `namespaces`.
  7842. *
  7843. * @param {String} namespaces
  7844. * @api private
  7845. */
  7846. function save(namespaces) {
  7847. try {
  7848. if (null == namespaces) {
  7849. exports.storage.removeItem('debug');
  7850. } else {
  7851. exports.storage.debug = namespaces;
  7852. }
  7853. } catch(e) {}
  7854. }
  7855. /**
  7856. * Load `namespaces`.
  7857. *
  7858. * @return {String} returns the previously persisted debug modes
  7859. * @api private
  7860. */
  7861. function load() {
  7862. var r;
  7863. try {
  7864. r = exports.storage.debug;
  7865. } catch(e) {}
  7866. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  7867. if (!r && typeof process !== 'undefined' && 'env' in process) {
  7868. r = process.env.DEBUG;
  7869. }
  7870. return r;
  7871. }
  7872. /**
  7873. * Enable namespaces listed in `localStorage.debug` initially.
  7874. */
  7875. exports.enable(load());
  7876. /**
  7877. * Localstorage attempts to return the localstorage.
  7878. *
  7879. * This is necessary because safari throws
  7880. * when a user disables cookies/localstorage
  7881. * and you attempt to access it.
  7882. *
  7883. * @return {LocalStorage}
  7884. * @api private
  7885. */
  7886. function localstorage() {
  7887. try {
  7888. return window.localStorage;
  7889. } catch (e) {}
  7890. }
  7891. }).call(this,require('_process'))
  7892. },{"./debug":44,"_process":56}],44:[function(require,module,exports){
  7893. /**
  7894. * This is the common logic for both the Node.js and web browser
  7895. * implementations of `debug()`.
  7896. *
  7897. * Expose `debug()` as the module.
  7898. */
  7899. exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
  7900. exports.coerce = coerce;
  7901. exports.disable = disable;
  7902. exports.enable = enable;
  7903. exports.enabled = enabled;
  7904. exports.humanize = require('ms');
  7905. /**
  7906. * Active `debug` instances.
  7907. */
  7908. exports.instances = [];
  7909. /**
  7910. * The currently active debug mode names, and names to skip.
  7911. */
  7912. exports.names = [];
  7913. exports.skips = [];
  7914. /**
  7915. * Map of special "%n" handling functions, for the debug "format" argument.
  7916. *
  7917. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  7918. */
  7919. exports.formatters = {};
  7920. /**
  7921. * Select a color.
  7922. * @param {String} namespace
  7923. * @return {Number}
  7924. * @api private
  7925. */
  7926. function selectColor(namespace) {
  7927. var hash = 0, i;
  7928. for (i in namespace) {
  7929. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  7930. hash |= 0; // Convert to 32bit integer
  7931. }
  7932. return exports.colors[Math.abs(hash) % exports.colors.length];
  7933. }
  7934. /**
  7935. * Create a debugger with the given `namespace`.
  7936. *
  7937. * @param {String} namespace
  7938. * @return {Function}
  7939. * @api public
  7940. */
  7941. function createDebug(namespace) {
  7942. var prevTime;
  7943. function debug() {
  7944. // disabled?
  7945. if (!debug.enabled) return;
  7946. var self = debug;
  7947. // set `diff` timestamp
  7948. var curr = +new Date();
  7949. var ms = curr - (prevTime || curr);
  7950. self.diff = ms;
  7951. self.prev = prevTime;
  7952. self.curr = curr;
  7953. prevTime = curr;
  7954. // turn the `arguments` into a proper Array
  7955. var args = new Array(arguments.length);
  7956. for (var i = 0; i < args.length; i++) {
  7957. args[i] = arguments[i];
  7958. }
  7959. args[0] = exports.coerce(args[0]);
  7960. if ('string' !== typeof args[0]) {
  7961. // anything else let's inspect with %O
  7962. args.unshift('%O');
  7963. }
  7964. // apply any `formatters` transformations
  7965. var index = 0;
  7966. args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
  7967. // if we encounter an escaped % then don't increase the array index
  7968. if (match === '%%') return match;
  7969. index++;
  7970. var formatter = exports.formatters[format];
  7971. if ('function' === typeof formatter) {
  7972. var val = args[index];
  7973. match = formatter.call(self, val);
  7974. // now we need to remove `args[index]` since it's inlined in the `format`
  7975. args.splice(index, 1);
  7976. index--;
  7977. }
  7978. return match;
  7979. });
  7980. // apply env-specific formatting (colors, etc.)
  7981. exports.formatArgs.call(self, args);
  7982. var logFn = debug.log || exports.log || console.log.bind(console);
  7983. logFn.apply(self, args);
  7984. }
  7985. debug.namespace = namespace;
  7986. debug.enabled = exports.enabled(namespace);
  7987. debug.useColors = exports.useColors();
  7988. debug.color = selectColor(namespace);
  7989. debug.destroy = destroy;
  7990. // env-specific initialization logic for debug instances
  7991. if ('function' === typeof exports.init) {
  7992. exports.init(debug);
  7993. }
  7994. exports.instances.push(debug);
  7995. return debug;
  7996. }
  7997. function destroy () {
  7998. var index = exports.instances.indexOf(this);
  7999. if (index !== -1) {
  8000. exports.instances.splice(index, 1);
  8001. return true;
  8002. } else {
  8003. return false;
  8004. }
  8005. }
  8006. /**
  8007. * Enables a debug mode by namespaces. This can include modes
  8008. * separated by a colon and wildcards.
  8009. *
  8010. * @param {String} namespaces
  8011. * @api public
  8012. */
  8013. function enable(namespaces) {
  8014. exports.save(namespaces);
  8015. exports.names = [];
  8016. exports.skips = [];
  8017. var i;
  8018. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  8019. var len = split.length;
  8020. for (i = 0; i < len; i++) {
  8021. if (!split[i]) continue; // ignore empty strings
  8022. namespaces = split[i].replace(/\*/g, '.*?');
  8023. if (namespaces[0] === '-') {
  8024. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  8025. } else {
  8026. exports.names.push(new RegExp('^' + namespaces + '$'));
  8027. }
  8028. }
  8029. for (i = 0; i < exports.instances.length; i++) {
  8030. var instance = exports.instances[i];
  8031. instance.enabled = exports.enabled(instance.namespace);
  8032. }
  8033. }
  8034. /**
  8035. * Disable debug output.
  8036. *
  8037. * @api public
  8038. */
  8039. function disable() {
  8040. exports.enable('');
  8041. }
  8042. /**
  8043. * Returns true if the given mode name is enabled, false otherwise.
  8044. *
  8045. * @param {String} name
  8046. * @return {Boolean}
  8047. * @api public
  8048. */
  8049. function enabled(name) {
  8050. if (name[name.length - 1] === '*') {
  8051. return true;
  8052. }
  8053. var i, len;
  8054. for (i = 0, len = exports.skips.length; i < len; i++) {
  8055. if (exports.skips[i].test(name)) {
  8056. return false;
  8057. }
  8058. }
  8059. for (i = 0, len = exports.names.length; i < len; i++) {
  8060. if (exports.names[i].test(name)) {
  8061. return true;
  8062. }
  8063. }
  8064. return false;
  8065. }
  8066. /**
  8067. * Coerce `val`.
  8068. *
  8069. * @param {Mixed} val
  8070. * @return {Mixed}
  8071. * @api private
  8072. */
  8073. function coerce(val) {
  8074. if (val instanceof Error) return val.stack || val.message;
  8075. return val;
  8076. }
  8077. },{"ms":54}],45:[function(require,module,exports){
  8078. /*!
  8079. diff v3.5.0
  8080. Software License Agreement (BSD License)
  8081. Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
  8082. All rights reserved.
  8083. Redistribution and use of this software in source and binary forms, with or without modification,
  8084. are permitted provided that the following conditions are met:
  8085. * Redistributions of source code must retain the above
  8086. copyright notice, this list of conditions and the
  8087. following disclaimer.
  8088. * Redistributions in binary form must reproduce the above
  8089. copyright notice, this list of conditions and the
  8090. following disclaimer in the documentation and/or other
  8091. materials provided with the distribution.
  8092. * Neither the name of Kevin Decker nor the names of its
  8093. contributors may be used to endorse or promote products
  8094. derived from this software without specific prior
  8095. written permission.
  8096. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  8097. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  8098. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  8099. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  8100. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  8101. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  8102. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  8103. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8104. @license
  8105. */
  8106. (function webpackUniversalModuleDefinition(root, factory) {
  8107. if(typeof exports === 'object' && typeof module === 'object')
  8108. module.exports = factory();
  8109. else if(false)
  8110. define([], factory);
  8111. else if(typeof exports === 'object')
  8112. exports["JsDiff"] = factory();
  8113. else
  8114. root["JsDiff"] = factory();
  8115. })(this, function() {
  8116. return /******/ (function(modules) { // webpackBootstrap
  8117. /******/ // The module cache
  8118. /******/ var installedModules = {};
  8119. /******/ // The require function
  8120. /******/ function __webpack_require__(moduleId) {
  8121. /******/ // Check if module is in cache
  8122. /******/ if(installedModules[moduleId])
  8123. /******/ return installedModules[moduleId].exports;
  8124. /******/ // Create a new module (and put it into the cache)
  8125. /******/ var module = installedModules[moduleId] = {
  8126. /******/ exports: {},
  8127. /******/ id: moduleId,
  8128. /******/ loaded: false
  8129. /******/ };
  8130. /******/ // Execute the module function
  8131. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  8132. /******/ // Flag the module as loaded
  8133. /******/ module.loaded = true;
  8134. /******/ // Return the exports of the module
  8135. /******/ return module.exports;
  8136. /******/ }
  8137. /******/ // expose the modules object (__webpack_modules__)
  8138. /******/ __webpack_require__.m = modules;
  8139. /******/ // expose the module cache
  8140. /******/ __webpack_require__.c = installedModules;
  8141. /******/ // __webpack_public_path__
  8142. /******/ __webpack_require__.p = "";
  8143. /******/ // Load entry module and return exports
  8144. /******/ return __webpack_require__(0);
  8145. /******/ })
  8146. /************************************************************************/
  8147. /******/ ([
  8148. /* 0 */
  8149. /***/ (function(module, exports, __webpack_require__) {
  8150. /*istanbul ignore start*/'use strict';
  8151. exports.__esModule = true;
  8152. 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;
  8153. /*istanbul ignore end*/var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  8154. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  8155. /*istanbul ignore end*/var /*istanbul ignore start*/_character = __webpack_require__(2) /*istanbul ignore end*/;
  8156. var /*istanbul ignore start*/_word = __webpack_require__(3) /*istanbul ignore end*/;
  8157. var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
  8158. var /*istanbul ignore start*/_sentence = __webpack_require__(6) /*istanbul ignore end*/;
  8159. var /*istanbul ignore start*/_css = __webpack_require__(7) /*istanbul ignore end*/;
  8160. var /*istanbul ignore start*/_json = __webpack_require__(8) /*istanbul ignore end*/;
  8161. var /*istanbul ignore start*/_array = __webpack_require__(9) /*istanbul ignore end*/;
  8162. var /*istanbul ignore start*/_apply = __webpack_require__(10) /*istanbul ignore end*/;
  8163. var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
  8164. var /*istanbul ignore start*/_merge = __webpack_require__(13) /*istanbul ignore end*/;
  8165. var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
  8166. var /*istanbul ignore start*/_dmp = __webpack_require__(16) /*istanbul ignore end*/;
  8167. var /*istanbul ignore start*/_xml = __webpack_require__(17) /*istanbul ignore end*/;
  8168. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8169. /* See LICENSE file for terms of use */
  8170. /*
  8171. * Text diff implementation.
  8172. *
  8173. * This library supports the following APIS:
  8174. * JsDiff.diffChars: Character by character diff
  8175. * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
  8176. * JsDiff.diffLines: Line based diff
  8177. *
  8178. * JsDiff.diffCss: Diff targeted at CSS content
  8179. *
  8180. * These methods are based on the implementation proposed in
  8181. * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
  8182. * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
  8183. */
  8184. exports. /*istanbul ignore end*/Diff = _base2['default'];
  8185. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars;
  8186. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords;
  8187. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace;
  8188. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines;
  8189. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines;
  8190. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences;
  8191. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss;
  8192. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson;
  8193. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays;
  8194. /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch;
  8195. /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch;
  8196. /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch;
  8197. /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch;
  8198. /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches;
  8199. /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch;
  8200. /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = _merge.merge;
  8201. /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP;
  8202. /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML;
  8203. /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize;
  8204. /***/ }),
  8205. /* 1 */
  8206. /***/ (function(module, exports) {
  8207. /*istanbul ignore start*/'use strict';
  8208. exports.__esModule = true;
  8209. exports['default'] = /*istanbul ignore end*/Diff;
  8210. function Diff() {}
  8211. Diff.prototype = {
  8212. /*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) {
  8213. /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  8214. var callback = options.callback;
  8215. if (typeof options === 'function') {
  8216. callback = options;
  8217. options = {};
  8218. }
  8219. this.options = options;
  8220. var self = this;
  8221. function done(value) {
  8222. if (callback) {
  8223. setTimeout(function () {
  8224. callback(undefined, value);
  8225. }, 0);
  8226. return true;
  8227. } else {
  8228. return value;
  8229. }
  8230. }
  8231. // Allow subclasses to massage the input prior to running
  8232. oldString = this.castInput(oldString);
  8233. newString = this.castInput(newString);
  8234. oldString = this.removeEmpty(this.tokenize(oldString));
  8235. newString = this.removeEmpty(this.tokenize(newString));
  8236. var newLen = newString.length,
  8237. oldLen = oldString.length;
  8238. var editLength = 1;
  8239. var maxEditLength = newLen + oldLen;
  8240. var bestPath = [{ newPos: -1, components: [] }];
  8241. // Seed editLength = 0, i.e. the content starts with the same values
  8242. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  8243. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  8244. // Identity per the equality and tokenizer
  8245. return done([{ value: this.join(newString), count: newString.length }]);
  8246. }
  8247. // Main worker method. checks all permutations of a given edit length for acceptance.
  8248. function execEditLength() {
  8249. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  8250. var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  8251. var addPath = bestPath[diagonalPath - 1],
  8252. removePath = bestPath[diagonalPath + 1],
  8253. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  8254. if (addPath) {
  8255. // No one else is going to attempt to use this value, clear it
  8256. bestPath[diagonalPath - 1] = undefined;
  8257. }
  8258. var canAdd = addPath && addPath.newPos + 1 < newLen,
  8259. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  8260. if (!canAdd && !canRemove) {
  8261. // If this path is a terminal then prune
  8262. bestPath[diagonalPath] = undefined;
  8263. continue;
  8264. }
  8265. // Select the diagonal that we want to branch from. We select the prior
  8266. // path whose position in the new string is the farthest from the origin
  8267. // and does not pass the bounds of the diff graph
  8268. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  8269. basePath = clonePath(removePath);
  8270. self.pushComponent(basePath.components, undefined, true);
  8271. } else {
  8272. basePath = addPath; // No need to clone, we've pulled it from the list
  8273. basePath.newPos++;
  8274. self.pushComponent(basePath.components, true, undefined);
  8275. }
  8276. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
  8277. // If we have hit the end of both strings, then we are done
  8278. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  8279. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  8280. } else {
  8281. // Otherwise track this path as a potential candidate and continue.
  8282. bestPath[diagonalPath] = basePath;
  8283. }
  8284. }
  8285. editLength++;
  8286. }
  8287. // Performs the length of edit iteration. Is a bit fugly as this has to support the
  8288. // sync and async mode which is never fun. Loops over execEditLength until a value
  8289. // is produced.
  8290. if (callback) {
  8291. (function exec() {
  8292. setTimeout(function () {
  8293. // This should not happen, but we want to be safe.
  8294. /* istanbul ignore next */
  8295. if (editLength > maxEditLength) {
  8296. return callback();
  8297. }
  8298. if (!execEditLength()) {
  8299. exec();
  8300. }
  8301. }, 0);
  8302. })();
  8303. } else {
  8304. while (editLength <= maxEditLength) {
  8305. var ret = execEditLength();
  8306. if (ret) {
  8307. return ret;
  8308. }
  8309. }
  8310. }
  8311. },
  8312. /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) {
  8313. var last = components[components.length - 1];
  8314. if (last && last.added === added && last.removed === removed) {
  8315. // We need to clone here as the component clone operation is just
  8316. // as shallow array clone
  8317. components[components.length - 1] = { count: last.count + 1, added: added, removed: removed };
  8318. } else {
  8319. components.push({ count: 1, added: added, removed: removed });
  8320. }
  8321. },
  8322. /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  8323. var newLen = newString.length,
  8324. oldLen = oldString.length,
  8325. newPos = basePath.newPos,
  8326. oldPos = newPos - diagonalPath,
  8327. commonCount = 0;
  8328. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  8329. newPos++;
  8330. oldPos++;
  8331. commonCount++;
  8332. }
  8333. if (commonCount) {
  8334. basePath.components.push({ count: commonCount });
  8335. }
  8336. basePath.newPos = newPos;
  8337. return oldPos;
  8338. },
  8339. /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
  8340. if (this.options.comparator) {
  8341. return this.options.comparator(left, right);
  8342. } else {
  8343. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  8344. }
  8345. },
  8346. /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
  8347. var ret = [];
  8348. for (var i = 0; i < array.length; i++) {
  8349. if (array[i]) {
  8350. ret.push(array[i]);
  8351. }
  8352. }
  8353. return ret;
  8354. },
  8355. /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) {
  8356. return value;
  8357. },
  8358. /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) {
  8359. return value.split('');
  8360. },
  8361. /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) {
  8362. return chars.join('');
  8363. }
  8364. };
  8365. function buildValues(diff, components, newString, oldString, useLongestToken) {
  8366. var componentPos = 0,
  8367. componentLen = components.length,
  8368. newPos = 0,
  8369. oldPos = 0;
  8370. for (; componentPos < componentLen; componentPos++) {
  8371. var component = components[componentPos];
  8372. if (!component.removed) {
  8373. if (!component.added && useLongestToken) {
  8374. var value = newString.slice(newPos, newPos + component.count);
  8375. value = value.map(function (value, i) {
  8376. var oldValue = oldString[oldPos + i];
  8377. return oldValue.length > value.length ? oldValue : value;
  8378. });
  8379. component.value = diff.join(value);
  8380. } else {
  8381. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  8382. }
  8383. newPos += component.count;
  8384. // Common case
  8385. if (!component.added) {
  8386. oldPos += component.count;
  8387. }
  8388. } else {
  8389. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  8390. oldPos += component.count;
  8391. // Reverse add and remove so removes are output first to match common convention
  8392. // The diffing algorithm is tied to add then remove output and this is the simplest
  8393. // route to get the desired output with minimal overhead.
  8394. if (componentPos && components[componentPos - 1].added) {
  8395. var tmp = components[componentPos - 1];
  8396. components[componentPos - 1] = components[componentPos];
  8397. components[componentPos] = tmp;
  8398. }
  8399. }
  8400. }
  8401. // Special case handle for when one terminal is ignored (i.e. whitespace).
  8402. // For this case we merge the terminal into the prior string and drop the change.
  8403. // This is only available for string mode.
  8404. var lastComponent = components[componentLen - 1];
  8405. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  8406. components[componentLen - 2].value += lastComponent.value;
  8407. components.pop();
  8408. }
  8409. return components;
  8410. }
  8411. function clonePath(path) {
  8412. return { newPos: path.newPos, components: path.components.slice(0) };
  8413. }
  8414. /***/ }),
  8415. /* 2 */
  8416. /***/ (function(module, exports, __webpack_require__) {
  8417. /*istanbul ignore start*/'use strict';
  8418. exports.__esModule = true;
  8419. exports.characterDiff = undefined;
  8420. exports. /*istanbul ignore end*/diffChars = diffChars;
  8421. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  8422. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  8423. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8424. /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  8425. function diffChars(oldStr, newStr, options) {
  8426. return characterDiff.diff(oldStr, newStr, options);
  8427. }
  8428. /***/ }),
  8429. /* 3 */
  8430. /***/ (function(module, exports, __webpack_require__) {
  8431. /*istanbul ignore start*/'use strict';
  8432. exports.__esModule = true;
  8433. exports.wordDiff = undefined;
  8434. exports. /*istanbul ignore end*/diffWords = diffWords;
  8435. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace;
  8436. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  8437. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  8438. /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
  8439. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8440. /*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  8441. //
  8442. // Ranges and exceptions:
  8443. // Latin-1 Supplement, 0080–00FF
  8444. // - U+00D7 × Multiplication sign
  8445. // - U+00F7 ÷ Division sign
  8446. // Latin Extended-A, 0100–017F
  8447. // Latin Extended-B, 0180–024F
  8448. // IPA Extensions, 0250–02AF
  8449. // Spacing Modifier Letters, 02B0–02FF
  8450. // - U+02C7 ˇ &#711; Caron
  8451. // - U+02D8 ˘ &#728; Breve
  8452. // - U+02D9 ˙ &#729; Dot Above
  8453. // - U+02DA ˚ &#730; Ring Above
  8454. // - U+02DB ˛ &#731; Ogonek
  8455. // - U+02DC ˜ &#732; Small Tilde
  8456. // - U+02DD ˝ &#733; Double Acute Accent
  8457. // Latin Extended Additional, 1E00–1EFF
  8458. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  8459. var reWhitespace = /\S/;
  8460. var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  8461. wordDiff.equals = function (left, right) {
  8462. if (this.options.ignoreCase) {
  8463. left = left.toLowerCase();
  8464. right = right.toLowerCase();
  8465. }
  8466. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  8467. };
  8468. wordDiff.tokenize = function (value) {
  8469. var tokens = value.split(/(\s+|\b)/);
  8470. // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  8471. for (var i = 0; i < tokens.length - 1; i++) {
  8472. // If we have an empty string in the next field and we have only word chars before and after, merge
  8473. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  8474. tokens[i] += tokens[i + 2];
  8475. tokens.splice(i + 1, 2);
  8476. i--;
  8477. }
  8478. }
  8479. return tokens;
  8480. };
  8481. function diffWords(oldStr, newStr, options) {
  8482. options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(options, { ignoreWhitespace: true });
  8483. return wordDiff.diff(oldStr, newStr, options);
  8484. }
  8485. function diffWordsWithSpace(oldStr, newStr, options) {
  8486. return wordDiff.diff(oldStr, newStr, options);
  8487. }
  8488. /***/ }),
  8489. /* 4 */
  8490. /***/ (function(module, exports) {
  8491. /*istanbul ignore start*/'use strict';
  8492. exports.__esModule = true;
  8493. exports. /*istanbul ignore end*/generateOptions = generateOptions;
  8494. function generateOptions(options, defaults) {
  8495. if (typeof options === 'function') {
  8496. defaults.callback = options;
  8497. } else if (options) {
  8498. for (var name in options) {
  8499. /* istanbul ignore else */
  8500. if (options.hasOwnProperty(name)) {
  8501. defaults[name] = options[name];
  8502. }
  8503. }
  8504. }
  8505. return defaults;
  8506. }
  8507. /***/ }),
  8508. /* 5 */
  8509. /***/ (function(module, exports, __webpack_require__) {
  8510. /*istanbul ignore start*/'use strict';
  8511. exports.__esModule = true;
  8512. exports.lineDiff = undefined;
  8513. exports. /*istanbul ignore end*/diffLines = diffLines;
  8514. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines;
  8515. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  8516. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  8517. /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
  8518. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8519. /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  8520. lineDiff.tokenize = function (value) {
  8521. var retLines = [],
  8522. linesAndNewlines = value.split(/(\n|\r\n)/);
  8523. // Ignore the final empty token that occurs if the string ends with a new line
  8524. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  8525. linesAndNewlines.pop();
  8526. }
  8527. // Merge the content and line separators into single tokens
  8528. for (var i = 0; i < linesAndNewlines.length; i++) {
  8529. var line = linesAndNewlines[i];
  8530. if (i % 2 && !this.options.newlineIsToken) {
  8531. retLines[retLines.length - 1] += line;
  8532. } else {
  8533. if (this.options.ignoreWhitespace) {
  8534. line = line.trim();
  8535. }
  8536. retLines.push(line);
  8537. }
  8538. }
  8539. return retLines;
  8540. };
  8541. function diffLines(oldStr, newStr, callback) {
  8542. return lineDiff.diff(oldStr, newStr, callback);
  8543. }
  8544. function diffTrimmedLines(oldStr, newStr, callback) {
  8545. var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
  8546. return lineDiff.diff(oldStr, newStr, options);
  8547. }
  8548. /***/ }),
  8549. /* 6 */
  8550. /***/ (function(module, exports, __webpack_require__) {
  8551. /*istanbul ignore start*/'use strict';
  8552. exports.__esModule = true;
  8553. exports.sentenceDiff = undefined;
  8554. exports. /*istanbul ignore end*/diffSentences = diffSentences;
  8555. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  8556. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  8557. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8558. /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  8559. sentenceDiff.tokenize = function (value) {
  8560. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  8561. };
  8562. function diffSentences(oldStr, newStr, callback) {
  8563. return sentenceDiff.diff(oldStr, newStr, callback);
  8564. }
  8565. /***/ }),
  8566. /* 7 */
  8567. /***/ (function(module, exports, __webpack_require__) {
  8568. /*istanbul ignore start*/'use strict';
  8569. exports.__esModule = true;
  8570. exports.cssDiff = undefined;
  8571. exports. /*istanbul ignore end*/diffCss = diffCss;
  8572. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  8573. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  8574. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8575. /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  8576. cssDiff.tokenize = function (value) {
  8577. return value.split(/([{}:;,]|\s+)/);
  8578. };
  8579. function diffCss(oldStr, newStr, callback) {
  8580. return cssDiff.diff(oldStr, newStr, callback);
  8581. }
  8582. /***/ }),
  8583. /* 8 */
  8584. /***/ (function(module, exports, __webpack_require__) {
  8585. /*istanbul ignore start*/'use strict';
  8586. exports.__esModule = true;
  8587. exports.jsonDiff = undefined;
  8588. 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; };
  8589. exports. /*istanbul ignore end*/diffJson = diffJson;
  8590. /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize;
  8591. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  8592. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  8593. /*istanbul ignore end*/var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
  8594. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8595. /*istanbul ignore end*/var objectPrototypeToString = Object.prototype.toString;
  8596. var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  8597. // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  8598. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  8599. jsonDiff.useLongestToken = true;
  8600. jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff /*istanbul ignore end*/.tokenize;
  8601. jsonDiff.castInput = function (value) {
  8602. /*istanbul ignore start*/var _options = /*istanbul ignore end*/this.options,
  8603. undefinedReplacement = _options.undefinedReplacement,
  8604. _options$stringifyRep = _options.stringifyReplacer,
  8605. stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) /*istanbul ignore start*/{
  8606. return (/*istanbul ignore end*/typeof v === 'undefined' ? undefinedReplacement : v
  8607. );
  8608. } : _options$stringifyRep;
  8609. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
  8610. };
  8611. jsonDiff.equals = function (left, right) {
  8612. 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'))
  8613. );
  8614. };
  8615. function diffJson(oldObj, newObj, options) {
  8616. return jsonDiff.diff(oldObj, newObj, options);
  8617. }
  8618. // This function handles the presence of circular references by bailing out when encountering an
  8619. // object that is already on the "stack" of items being processed. Accepts an optional replacer
  8620. function canonicalize(obj, stack, replacementStack, replacer, key) {
  8621. stack = stack || [];
  8622. replacementStack = replacementStack || [];
  8623. if (replacer) {
  8624. obj = replacer(key, obj);
  8625. }
  8626. var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  8627. for (i = 0; i < stack.length; i += 1) {
  8628. if (stack[i] === obj) {
  8629. return replacementStack[i];
  8630. }
  8631. }
  8632. var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  8633. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  8634. stack.push(obj);
  8635. canonicalizedObj = new Array(obj.length);
  8636. replacementStack.push(canonicalizedObj);
  8637. for (i = 0; i < obj.length; i += 1) {
  8638. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
  8639. }
  8640. stack.pop();
  8641. replacementStack.pop();
  8642. return canonicalizedObj;
  8643. }
  8644. if (obj && obj.toJSON) {
  8645. obj = obj.toJSON();
  8646. }
  8647. if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
  8648. stack.push(obj);
  8649. canonicalizedObj = {};
  8650. replacementStack.push(canonicalizedObj);
  8651. var sortedKeys = [],
  8652. _key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  8653. for (_key in obj) {
  8654. /* istanbul ignore else */
  8655. if (obj.hasOwnProperty(_key)) {
  8656. sortedKeys.push(_key);
  8657. }
  8658. }
  8659. sortedKeys.sort();
  8660. for (i = 0; i < sortedKeys.length; i += 1) {
  8661. _key = sortedKeys[i];
  8662. canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
  8663. }
  8664. stack.pop();
  8665. replacementStack.pop();
  8666. } else {
  8667. canonicalizedObj = obj;
  8668. }
  8669. return canonicalizedObj;
  8670. }
  8671. /***/ }),
  8672. /* 9 */
  8673. /***/ (function(module, exports, __webpack_require__) {
  8674. /*istanbul ignore start*/'use strict';
  8675. exports.__esModule = true;
  8676. exports.arrayDiff = undefined;
  8677. exports. /*istanbul ignore end*/diffArrays = diffArrays;
  8678. var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
  8679. /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
  8680. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8681. /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  8682. arrayDiff.tokenize = function (value) {
  8683. return value.slice();
  8684. };
  8685. arrayDiff.join = arrayDiff.removeEmpty = function (value) {
  8686. return value;
  8687. };
  8688. function diffArrays(oldArr, newArr, callback) {
  8689. return arrayDiff.diff(oldArr, newArr, callback);
  8690. }
  8691. /***/ }),
  8692. /* 10 */
  8693. /***/ (function(module, exports, __webpack_require__) {
  8694. /*istanbul ignore start*/'use strict';
  8695. exports.__esModule = true;
  8696. exports. /*istanbul ignore end*/applyPatch = applyPatch;
  8697. /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches;
  8698. var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
  8699. var /*istanbul ignore start*/_distanceIterator = __webpack_require__(12) /*istanbul ignore end*/;
  8700. /*istanbul ignore start*/var _distanceIterator2 = _interopRequireDefault(_distanceIterator);
  8701. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8702. /*istanbul ignore end*/function applyPatch(source, uniDiff) {
  8703. /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  8704. if (typeof uniDiff === 'string') {
  8705. uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
  8706. }
  8707. if (Array.isArray(uniDiff)) {
  8708. if (uniDiff.length > 1) {
  8709. throw new Error('applyPatch only works with a single input.');
  8710. }
  8711. uniDiff = uniDiff[0];
  8712. }
  8713. // Apply the diff to the input
  8714. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  8715. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  8716. hunks = uniDiff.hunks,
  8717. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{
  8718. return (/*istanbul ignore end*/line === patchContent
  8719. );
  8720. },
  8721. errorCount = 0,
  8722. fuzzFactor = options.fuzzFactor || 0,
  8723. minLine = 0,
  8724. offset = 0,
  8725. removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
  8726. addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  8727. /**
  8728. * Checks if the hunk exactly fits on the provided location
  8729. */
  8730. function hunkFits(hunk, toPos) {
  8731. for (var j = 0; j < hunk.lines.length; j++) {
  8732. var line = hunk.lines[j],
  8733. operation = line.length > 0 ? line[0] : ' ',
  8734. content = line.length > 0 ? line.substr(1) : line;
  8735. if (operation === ' ' || operation === '-') {
  8736. // Context sanity check
  8737. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  8738. errorCount++;
  8739. if (errorCount > fuzzFactor) {
  8740. return false;
  8741. }
  8742. }
  8743. toPos++;
  8744. }
  8745. }
  8746. return true;
  8747. }
  8748. // Search best fit offsets for each hunk based on the previous ones
  8749. for (var i = 0; i < hunks.length; i++) {
  8750. var hunk = hunks[i],
  8751. maxLine = lines.length - hunk.oldLines,
  8752. localOffset = 0,
  8753. toPos = offset + hunk.oldStart - 1;
  8754. var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine);
  8755. for (; localOffset !== undefined; localOffset = iterator()) {
  8756. if (hunkFits(hunk, toPos + localOffset)) {
  8757. hunk.offset = offset += localOffset;
  8758. break;
  8759. }
  8760. }
  8761. if (localOffset === undefined) {
  8762. return false;
  8763. }
  8764. // Set lower text limit to end of the current hunk, so next ones don't try
  8765. // to fit over already patched text
  8766. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  8767. }
  8768. // Apply patch hunks
  8769. var diffOffset = 0;
  8770. for (var _i = 0; _i < hunks.length; _i++) {
  8771. var _hunk = hunks[_i],
  8772. _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
  8773. diffOffset += _hunk.newLines - _hunk.oldLines;
  8774. if (_toPos < 0) {
  8775. // Creating a new file
  8776. _toPos = 0;
  8777. }
  8778. for (var j = 0; j < _hunk.lines.length; j++) {
  8779. var line = _hunk.lines[j],
  8780. operation = line.length > 0 ? line[0] : ' ',
  8781. content = line.length > 0 ? line.substr(1) : line,
  8782. delimiter = _hunk.linedelimiters[j];
  8783. if (operation === ' ') {
  8784. _toPos++;
  8785. } else if (operation === '-') {
  8786. lines.splice(_toPos, 1);
  8787. delimiters.splice(_toPos, 1);
  8788. /* istanbul ignore else */
  8789. } else if (operation === '+') {
  8790. lines.splice(_toPos, 0, content);
  8791. delimiters.splice(_toPos, 0, delimiter);
  8792. _toPos++;
  8793. } else if (operation === '\\') {
  8794. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  8795. if (previousOperation === '+') {
  8796. removeEOFNL = true;
  8797. } else if (previousOperation === '-') {
  8798. addEOFNL = true;
  8799. }
  8800. }
  8801. }
  8802. }
  8803. // Handle EOFNL insertion/removal
  8804. if (removeEOFNL) {
  8805. while (!lines[lines.length - 1]) {
  8806. lines.pop();
  8807. delimiters.pop();
  8808. }
  8809. } else if (addEOFNL) {
  8810. lines.push('');
  8811. delimiters.push('\n');
  8812. }
  8813. for (var _k = 0; _k < lines.length - 1; _k++) {
  8814. lines[_k] = lines[_k] + delimiters[_k];
  8815. }
  8816. return lines.join('');
  8817. }
  8818. // Wrapper that supports multiple file patches via callbacks.
  8819. function applyPatches(uniDiff, options) {
  8820. if (typeof uniDiff === 'string') {
  8821. uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
  8822. }
  8823. var currentIndex = 0;
  8824. function processIndex() {
  8825. var index = uniDiff[currentIndex++];
  8826. if (!index) {
  8827. return options.complete();
  8828. }
  8829. options.loadFile(index, function (err, data) {
  8830. if (err) {
  8831. return options.complete(err);
  8832. }
  8833. var updatedContent = applyPatch(data, index, options);
  8834. options.patched(index, updatedContent, function (err) {
  8835. if (err) {
  8836. return options.complete(err);
  8837. }
  8838. processIndex();
  8839. });
  8840. });
  8841. }
  8842. processIndex();
  8843. }
  8844. /***/ }),
  8845. /* 11 */
  8846. /***/ (function(module, exports) {
  8847. /*istanbul ignore start*/'use strict';
  8848. exports.__esModule = true;
  8849. exports. /*istanbul ignore end*/parsePatch = parsePatch;
  8850. function parsePatch(uniDiff) {
  8851. /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  8852. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  8853. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  8854. list = [],
  8855. i = 0;
  8856. function parseIndex() {
  8857. var index = {};
  8858. list.push(index);
  8859. // Parse diff metadata
  8860. while (i < diffstr.length) {
  8861. var line = diffstr[i];
  8862. // File header found, end parsing diff metadata
  8863. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  8864. break;
  8865. }
  8866. // Diff index
  8867. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  8868. if (header) {
  8869. index.index = header[1];
  8870. }
  8871. i++;
  8872. }
  8873. // Parse file headers if they are defined. Unified diff requires them, but
  8874. // there's no technical issues to have an isolated hunk without file header
  8875. parseFileHeader(index);
  8876. parseFileHeader(index);
  8877. // Parse hunks
  8878. index.hunks = [];
  8879. while (i < diffstr.length) {
  8880. var _line = diffstr[i];
  8881. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  8882. break;
  8883. } else if (/^@@/.test(_line)) {
  8884. index.hunks.push(parseHunk());
  8885. } else if (_line && options.strict) {
  8886. // Ignore unexpected content unless in strict mode
  8887. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  8888. } else {
  8889. i++;
  8890. }
  8891. }
  8892. }
  8893. // Parses the --- and +++ headers, if none are found, no lines
  8894. // are consumed.
  8895. function parseFileHeader(index) {
  8896. var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
  8897. if (fileHeader) {
  8898. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  8899. var data = fileHeader[2].split('\t', 2);
  8900. var fileName = data[0].replace(/\\\\/g, '\\');
  8901. if (/^".*"$/.test(fileName)) {
  8902. fileName = fileName.substr(1, fileName.length - 2);
  8903. }
  8904. index[keyPrefix + 'FileName'] = fileName;
  8905. index[keyPrefix + 'Header'] = (data[1] || '').trim();
  8906. i++;
  8907. }
  8908. }
  8909. // Parses a hunk
  8910. // This assumes that we are at the start of a hunk.
  8911. function parseHunk() {
  8912. var chunkHeaderIndex = i,
  8913. chunkHeaderLine = diffstr[i++],
  8914. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  8915. var hunk = {
  8916. oldStart: +chunkHeader[1],
  8917. oldLines: +chunkHeader[2] || 1,
  8918. newStart: +chunkHeader[3],
  8919. newLines: +chunkHeader[4] || 1,
  8920. lines: [],
  8921. linedelimiters: []
  8922. };
  8923. var addCount = 0,
  8924. removeCount = 0;
  8925. for (; i < diffstr.length; i++) {
  8926. // Lines starting with '---' could be mistaken for the "remove line" operation
  8927. // But they could be the header for the next file. Therefore prune such cases out.
  8928. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  8929. break;
  8930. }
  8931. var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
  8932. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  8933. hunk.lines.push(diffstr[i]);
  8934. hunk.linedelimiters.push(delimiters[i] || '\n');
  8935. if (operation === '+') {
  8936. addCount++;
  8937. } else if (operation === '-') {
  8938. removeCount++;
  8939. } else if (operation === ' ') {
  8940. addCount++;
  8941. removeCount++;
  8942. }
  8943. } else {
  8944. break;
  8945. }
  8946. }
  8947. // Handle the empty block count case
  8948. if (!addCount && hunk.newLines === 1) {
  8949. hunk.newLines = 0;
  8950. }
  8951. if (!removeCount && hunk.oldLines === 1) {
  8952. hunk.oldLines = 0;
  8953. }
  8954. // Perform optional sanity checking
  8955. if (options.strict) {
  8956. if (addCount !== hunk.newLines) {
  8957. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  8958. }
  8959. if (removeCount !== hunk.oldLines) {
  8960. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  8961. }
  8962. }
  8963. return hunk;
  8964. }
  8965. while (i < diffstr.length) {
  8966. parseIndex();
  8967. }
  8968. return list;
  8969. }
  8970. /***/ }),
  8971. /* 12 */
  8972. /***/ (function(module, exports) {
  8973. /*istanbul ignore start*/"use strict";
  8974. exports.__esModule = true;
  8975. exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) {
  8976. var wantForward = true,
  8977. backwardExhausted = false,
  8978. forwardExhausted = false,
  8979. localOffset = 1;
  8980. return function iterator() {
  8981. if (wantForward && !forwardExhausted) {
  8982. if (backwardExhausted) {
  8983. localOffset++;
  8984. } else {
  8985. wantForward = false;
  8986. }
  8987. // Check if trying to fit beyond text length, and if not, check it fits
  8988. // after offset location (or desired location on first iteration)
  8989. if (start + localOffset <= maxLine) {
  8990. return localOffset;
  8991. }
  8992. forwardExhausted = true;
  8993. }
  8994. if (!backwardExhausted) {
  8995. if (!forwardExhausted) {
  8996. wantForward = true;
  8997. }
  8998. // Check if trying to fit before text beginning, and if not, check it fits
  8999. // before offset location
  9000. if (minLine <= start - localOffset) {
  9001. return -localOffset++;
  9002. }
  9003. backwardExhausted = true;
  9004. return iterator();
  9005. }
  9006. // We tried to fit hunk before text beginning and beyond text length, then
  9007. // hunk can't fit on the text. Return undefined
  9008. };
  9009. };
  9010. /***/ }),
  9011. /* 13 */
  9012. /***/ (function(module, exports, __webpack_require__) {
  9013. /*istanbul ignore start*/'use strict';
  9014. exports.__esModule = true;
  9015. exports. /*istanbul ignore end*/calcLineCount = calcLineCount;
  9016. /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge;
  9017. var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
  9018. var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
  9019. var /*istanbul ignore start*/_array = __webpack_require__(15) /*istanbul ignore end*/;
  9020. /*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); } }
  9021. /*istanbul ignore end*/function calcLineCount(hunk) {
  9022. /*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines),
  9023. oldLines = _calcOldNewLineCount.oldLines,
  9024. newLines = _calcOldNewLineCount.newLines;
  9025. if (oldLines !== undefined) {
  9026. hunk.oldLines = oldLines;
  9027. } else {
  9028. delete hunk.oldLines;
  9029. }
  9030. if (newLines !== undefined) {
  9031. hunk.newLines = newLines;
  9032. } else {
  9033. delete hunk.newLines;
  9034. }
  9035. }
  9036. function merge(mine, theirs, base) {
  9037. mine = loadPatch(mine, base);
  9038. theirs = loadPatch(theirs, base);
  9039. var ret = {};
  9040. // For index we just let it pass through as it doesn't have any necessary meaning.
  9041. // Leaving sanity checks on this to the API consumer that may know more about the
  9042. // meaning in their own context.
  9043. if (mine.index || theirs.index) {
  9044. ret.index = mine.index || theirs.index;
  9045. }
  9046. if (mine.newFileName || theirs.newFileName) {
  9047. if (!fileNameChanged(mine)) {
  9048. // No header or no change in ours, use theirs (and ours if theirs does not exist)
  9049. ret.oldFileName = theirs.oldFileName || mine.oldFileName;
  9050. ret.newFileName = theirs.newFileName || mine.newFileName;
  9051. ret.oldHeader = theirs.oldHeader || mine.oldHeader;
  9052. ret.newHeader = theirs.newHeader || mine.newHeader;
  9053. } else if (!fileNameChanged(theirs)) {
  9054. // No header or no change in theirs, use ours
  9055. ret.oldFileName = mine.oldFileName;
  9056. ret.newFileName = mine.newFileName;
  9057. ret.oldHeader = mine.oldHeader;
  9058. ret.newHeader = mine.newHeader;
  9059. } else {
  9060. // Both changed... figure it out
  9061. ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
  9062. ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
  9063. ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
  9064. ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
  9065. }
  9066. }
  9067. ret.hunks = [];
  9068. var mineIndex = 0,
  9069. theirsIndex = 0,
  9070. mineOffset = 0,
  9071. theirsOffset = 0;
  9072. while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
  9073. var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity },
  9074. theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity };
  9075. if (hunkBefore(mineCurrent, theirsCurrent)) {
  9076. // This patch does not overlap with any of the others, yay.
  9077. ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
  9078. mineIndex++;
  9079. theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
  9080. } else if (hunkBefore(theirsCurrent, mineCurrent)) {
  9081. // This patch does not overlap with any of the others, yay.
  9082. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
  9083. theirsIndex++;
  9084. mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
  9085. } else {
  9086. // Overlap, merge as best we can
  9087. var mergedHunk = {
  9088. oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
  9089. oldLines: 0,
  9090. newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
  9091. newLines: 0,
  9092. lines: []
  9093. };
  9094. mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
  9095. theirsIndex++;
  9096. mineIndex++;
  9097. ret.hunks.push(mergedHunk);
  9098. }
  9099. }
  9100. return ret;
  9101. }
  9102. function loadPatch(param, base) {
  9103. if (typeof param === 'string') {
  9104. if (/^@@/m.test(param) || /^Index:/m.test(param)) {
  9105. return (/*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(param)[0]
  9106. );
  9107. }
  9108. if (!base) {
  9109. throw new Error('Must provide a base reference or pass in a patch');
  9110. }
  9111. return (/*istanbul ignore start*/(0, _create.structuredPatch) /*istanbul ignore end*/(undefined, undefined, base, param)
  9112. );
  9113. }
  9114. return param;
  9115. }
  9116. function fileNameChanged(patch) {
  9117. return patch.newFileName && patch.newFileName !== patch.oldFileName;
  9118. }
  9119. function selectField(index, mine, theirs) {
  9120. if (mine === theirs) {
  9121. return mine;
  9122. } else {
  9123. index.conflict = true;
  9124. return { mine: mine, theirs: theirs };
  9125. }
  9126. }
  9127. function hunkBefore(test, check) {
  9128. return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
  9129. }
  9130. function cloneHunk(hunk, offset) {
  9131. return {
  9132. oldStart: hunk.oldStart, oldLines: hunk.oldLines,
  9133. newStart: hunk.newStart + offset, newLines: hunk.newLines,
  9134. lines: hunk.lines
  9135. };
  9136. }
  9137. function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
  9138. // This will generally result in a conflicted hunk, but there are cases where the context
  9139. // is the only overlap where we can successfully merge the content here.
  9140. var mine = { offset: mineOffset, lines: mineLines, index: 0 },
  9141. their = { offset: theirOffset, lines: theirLines, index: 0 };
  9142. // Handle any leading content
  9143. insertLeading(hunk, mine, their);
  9144. insertLeading(hunk, their, mine);
  9145. // Now in the overlap content. Scan through and select the best changes from each.
  9146. while (mine.index < mine.lines.length && their.index < their.lines.length) {
  9147. var mineCurrent = mine.lines[mine.index],
  9148. theirCurrent = their.lines[their.index];
  9149. if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
  9150. // Both modified ...
  9151. mutualChange(hunk, mine, their);
  9152. } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
  9153. /*istanbul ignore start*/var _hunk$lines;
  9154. /*istanbul ignore end*/ // Mine inserted
  9155. /*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)));
  9156. } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
  9157. /*istanbul ignore start*/var _hunk$lines2;
  9158. /*istanbul ignore end*/ // Theirs inserted
  9159. /*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)));
  9160. } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
  9161. // Mine removed or edited
  9162. removal(hunk, mine, their);
  9163. } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
  9164. // Their removed or edited
  9165. removal(hunk, their, mine, true);
  9166. } else if (mineCurrent === theirCurrent) {
  9167. // Context identity
  9168. hunk.lines.push(mineCurrent);
  9169. mine.index++;
  9170. their.index++;
  9171. } else {
  9172. // Context mismatch
  9173. conflict(hunk, collectChange(mine), collectChange(their));
  9174. }
  9175. }
  9176. // Now push anything that may be remaining
  9177. insertTrailing(hunk, mine);
  9178. insertTrailing(hunk, their);
  9179. calcLineCount(hunk);
  9180. }
  9181. function mutualChange(hunk, mine, their) {
  9182. var myChanges = collectChange(mine),
  9183. theirChanges = collectChange(their);
  9184. if (allRemoves(myChanges) && allRemoves(theirChanges)) {
  9185. // Special case for remove changes that are supersets of one another
  9186. if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
  9187. /*istanbul ignore start*/var _hunk$lines3;
  9188. /*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));
  9189. return;
  9190. } else if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
  9191. /*istanbul ignore start*/var _hunk$lines4;
  9192. /*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));
  9193. return;
  9194. }
  9195. } else if ( /*istanbul ignore start*/(0, _array.arrayEqual) /*istanbul ignore end*/(myChanges, theirChanges)) {
  9196. /*istanbul ignore start*/var _hunk$lines5;
  9197. /*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));
  9198. return;
  9199. }
  9200. conflict(hunk, myChanges, theirChanges);
  9201. }
  9202. function removal(hunk, mine, their, swap) {
  9203. var myChanges = collectChange(mine),
  9204. theirChanges = collectContext(their, myChanges);
  9205. if (theirChanges.merged) {
  9206. /*istanbul ignore start*/var _hunk$lines6;
  9207. /*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));
  9208. } else {
  9209. conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
  9210. }
  9211. }
  9212. function conflict(hunk, mine, their) {
  9213. hunk.conflict = true;
  9214. hunk.lines.push({
  9215. conflict: true,
  9216. mine: mine,
  9217. theirs: their
  9218. });
  9219. }
  9220. function insertLeading(hunk, insert, their) {
  9221. while (insert.offset < their.offset && insert.index < insert.lines.length) {
  9222. var line = insert.lines[insert.index++];
  9223. hunk.lines.push(line);
  9224. insert.offset++;
  9225. }
  9226. }
  9227. function insertTrailing(hunk, insert) {
  9228. while (insert.index < insert.lines.length) {
  9229. var line = insert.lines[insert.index++];
  9230. hunk.lines.push(line);
  9231. }
  9232. }
  9233. function collectChange(state) {
  9234. var ret = [],
  9235. operation = state.lines[state.index][0];
  9236. while (state.index < state.lines.length) {
  9237. var line = state.lines[state.index];
  9238. // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
  9239. if (operation === '-' && line[0] === '+') {
  9240. operation = '+';
  9241. }
  9242. if (operation === line[0]) {
  9243. ret.push(line);
  9244. state.index++;
  9245. } else {
  9246. break;
  9247. }
  9248. }
  9249. return ret;
  9250. }
  9251. function collectContext(state, matchChanges) {
  9252. var changes = [],
  9253. merged = [],
  9254. matchIndex = 0,
  9255. contextChanges = false,
  9256. conflicted = false;
  9257. while (matchIndex < matchChanges.length && state.index < state.lines.length) {
  9258. var change = state.lines[state.index],
  9259. match = matchChanges[matchIndex];
  9260. // Once we've hit our add, then we are done
  9261. if (match[0] === '+') {
  9262. break;
  9263. }
  9264. contextChanges = contextChanges || change[0] !== ' ';
  9265. merged.push(match);
  9266. matchIndex++;
  9267. // Consume any additions in the other block as a conflict to attempt
  9268. // to pull in the remaining context after this
  9269. if (change[0] === '+') {
  9270. conflicted = true;
  9271. while (change[0] === '+') {
  9272. changes.push(change);
  9273. change = state.lines[++state.index];
  9274. }
  9275. }
  9276. if (match.substr(1) === change.substr(1)) {
  9277. changes.push(change);
  9278. state.index++;
  9279. } else {
  9280. conflicted = true;
  9281. }
  9282. }
  9283. if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
  9284. conflicted = true;
  9285. }
  9286. if (conflicted) {
  9287. return changes;
  9288. }
  9289. while (matchIndex < matchChanges.length) {
  9290. merged.push(matchChanges[matchIndex++]);
  9291. }
  9292. return {
  9293. merged: merged,
  9294. changes: changes
  9295. };
  9296. }
  9297. function allRemoves(changes) {
  9298. return changes.reduce(function (prev, change) {
  9299. return prev && change[0] === '-';
  9300. }, true);
  9301. }
  9302. function skipRemoveSuperset(state, removeChanges, delta) {
  9303. for (var i = 0; i < delta; i++) {
  9304. var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
  9305. if (state.lines[state.index + i] !== ' ' + changeContent) {
  9306. return false;
  9307. }
  9308. }
  9309. state.index += delta;
  9310. return true;
  9311. }
  9312. function calcOldNewLineCount(lines) {
  9313. var oldLines = 0;
  9314. var newLines = 0;
  9315. lines.forEach(function (line) {
  9316. if (typeof line !== 'string') {
  9317. var myCount = calcOldNewLineCount(line.mine);
  9318. var theirCount = calcOldNewLineCount(line.theirs);
  9319. if (oldLines !== undefined) {
  9320. if (myCount.oldLines === theirCount.oldLines) {
  9321. oldLines += myCount.oldLines;
  9322. } else {
  9323. oldLines = undefined;
  9324. }
  9325. }
  9326. if (newLines !== undefined) {
  9327. if (myCount.newLines === theirCount.newLines) {
  9328. newLines += myCount.newLines;
  9329. } else {
  9330. newLines = undefined;
  9331. }
  9332. }
  9333. } else {
  9334. if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
  9335. newLines++;
  9336. }
  9337. if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
  9338. oldLines++;
  9339. }
  9340. }
  9341. });
  9342. return { oldLines: oldLines, newLines: newLines };
  9343. }
  9344. /***/ }),
  9345. /* 14 */
  9346. /***/ (function(module, exports, __webpack_require__) {
  9347. /*istanbul ignore start*/'use strict';
  9348. exports.__esModule = true;
  9349. exports. /*istanbul ignore end*/structuredPatch = structuredPatch;
  9350. /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch;
  9351. /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch;
  9352. var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
  9353. /*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); } }
  9354. /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  9355. if (!options) {
  9356. options = {};
  9357. }
  9358. if (typeof options.context === 'undefined') {
  9359. options.context = 4;
  9360. }
  9361. var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options);
  9362. diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
  9363. function contextLines(lines) {
  9364. return lines.map(function (entry) {
  9365. return ' ' + entry;
  9366. });
  9367. }
  9368. var hunks = [];
  9369. var oldRangeStart = 0,
  9370. newRangeStart = 0,
  9371. curRange = [],
  9372. oldLine = 1,
  9373. newLine = 1;
  9374. /*istanbul ignore start*/var _loop = function _loop( /*istanbul ignore end*/i) {
  9375. var current = diff[i],
  9376. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  9377. current.lines = lines;
  9378. if (current.added || current.removed) {
  9379. /*istanbul ignore start*/var _curRange;
  9380. /*istanbul ignore end*/ // If we have previous context, start with that
  9381. if (!oldRangeStart) {
  9382. var prev = diff[i - 1];
  9383. oldRangeStart = oldLine;
  9384. newRangeStart = newLine;
  9385. if (prev) {
  9386. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  9387. oldRangeStart -= curRange.length;
  9388. newRangeStart -= curRange.length;
  9389. }
  9390. }
  9391. // Output our changes
  9392. /*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) {
  9393. return (current.added ? '+' : '-') + entry;
  9394. })));
  9395. // Track the updated file position
  9396. if (current.added) {
  9397. newLine += lines.length;
  9398. } else {
  9399. oldLine += lines.length;
  9400. }
  9401. } else {
  9402. // Identical context lines. Track line changes
  9403. if (oldRangeStart) {
  9404. // Close out any changes that have been output (or join overlapping)
  9405. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  9406. /*istanbul ignore start*/var _curRange2;
  9407. /*istanbul ignore end*/ // Overlapping
  9408. /*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)));
  9409. } else {
  9410. /*istanbul ignore start*/var _curRange3;
  9411. /*istanbul ignore end*/ // end the range and output
  9412. var contextSize = Math.min(lines.length, options.context);
  9413. /*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))));
  9414. var hunk = {
  9415. oldStart: oldRangeStart,
  9416. oldLines: oldLine - oldRangeStart + contextSize,
  9417. newStart: newRangeStart,
  9418. newLines: newLine - newRangeStart + contextSize,
  9419. lines: curRange
  9420. };
  9421. if (i >= diff.length - 2 && lines.length <= options.context) {
  9422. // EOF is inside this hunk
  9423. var oldEOFNewline = /\n$/.test(oldStr);
  9424. var newEOFNewline = /\n$/.test(newStr);
  9425. if (lines.length == 0 && !oldEOFNewline) {
  9426. // special case: old has no eol and no trailing context; no-nl can end up before adds
  9427. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  9428. } else if (!oldEOFNewline || !newEOFNewline) {
  9429. curRange.push('\\ No newline at end of file');
  9430. }
  9431. }
  9432. hunks.push(hunk);
  9433. oldRangeStart = 0;
  9434. newRangeStart = 0;
  9435. curRange = [];
  9436. }
  9437. }
  9438. oldLine += lines.length;
  9439. newLine += lines.length;
  9440. }
  9441. };
  9442. for (var i = 0; i < diff.length; i++) {
  9443. /*istanbul ignore start*/_loop( /*istanbul ignore end*/i);
  9444. }
  9445. return {
  9446. oldFileName: oldFileName, newFileName: newFileName,
  9447. oldHeader: oldHeader, newHeader: newHeader,
  9448. hunks: hunks
  9449. };
  9450. }
  9451. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  9452. var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
  9453. var ret = [];
  9454. if (oldFileName == newFileName) {
  9455. ret.push('Index: ' + oldFileName);
  9456. }
  9457. ret.push('===================================================================');
  9458. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  9459. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  9460. for (var i = 0; i < diff.hunks.length; i++) {
  9461. var hunk = diff.hunks[i];
  9462. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  9463. ret.push.apply(ret, hunk.lines);
  9464. }
  9465. return ret.join('\n') + '\n';
  9466. }
  9467. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  9468. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  9469. }
  9470. /***/ }),
  9471. /* 15 */
  9472. /***/ (function(module, exports) {
  9473. /*istanbul ignore start*/"use strict";
  9474. exports.__esModule = true;
  9475. exports. /*istanbul ignore end*/arrayEqual = arrayEqual;
  9476. /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayStartsWith = arrayStartsWith;
  9477. function arrayEqual(a, b) {
  9478. if (a.length !== b.length) {
  9479. return false;
  9480. }
  9481. return arrayStartsWith(a, b);
  9482. }
  9483. function arrayStartsWith(array, start) {
  9484. if (start.length > array.length) {
  9485. return false;
  9486. }
  9487. for (var i = 0; i < start.length; i++) {
  9488. if (start[i] !== array[i]) {
  9489. return false;
  9490. }
  9491. }
  9492. return true;
  9493. }
  9494. /***/ }),
  9495. /* 16 */
  9496. /***/ (function(module, exports) {
  9497. /*istanbul ignore start*/"use strict";
  9498. exports.__esModule = true;
  9499. exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP;
  9500. // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  9501. function convertChangesToDMP(changes) {
  9502. var ret = [],
  9503. change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
  9504. operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  9505. for (var i = 0; i < changes.length; i++) {
  9506. change = changes[i];
  9507. if (change.added) {
  9508. operation = 1;
  9509. } else if (change.removed) {
  9510. operation = -1;
  9511. } else {
  9512. operation = 0;
  9513. }
  9514. ret.push([operation, change.value]);
  9515. }
  9516. return ret;
  9517. }
  9518. /***/ }),
  9519. /* 17 */
  9520. /***/ (function(module, exports) {
  9521. /*istanbul ignore start*/'use strict';
  9522. exports.__esModule = true;
  9523. exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML;
  9524. function convertChangesToXML(changes) {
  9525. var ret = [];
  9526. for (var i = 0; i < changes.length; i++) {
  9527. var change = changes[i];
  9528. if (change.added) {
  9529. ret.push('<ins>');
  9530. } else if (change.removed) {
  9531. ret.push('<del>');
  9532. }
  9533. ret.push(escapeHTML(change.value));
  9534. if (change.added) {
  9535. ret.push('</ins>');
  9536. } else if (change.removed) {
  9537. ret.push('</del>');
  9538. }
  9539. }
  9540. return ret.join('');
  9541. }
  9542. function escapeHTML(s) {
  9543. var n = s;
  9544. n = n.replace(/&/g, '&amp;');
  9545. n = n.replace(/</g, '&lt;');
  9546. n = n.replace(/>/g, '&gt;');
  9547. n = n.replace(/"/g, '&quot;');
  9548. return n;
  9549. }
  9550. /***/ })
  9551. /******/ ])
  9552. });
  9553. ;
  9554. },{}],46:[function(require,module,exports){
  9555. 'use strict';
  9556. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  9557. module.exports = function (str) {
  9558. if (typeof str !== 'string') {
  9559. throw new TypeError('Expected a string');
  9560. }
  9561. return str.replace(matchOperatorsRe, '\\$&');
  9562. };
  9563. },{}],47:[function(require,module,exports){
  9564. // Copyright Joyent, Inc. and other Node contributors.
  9565. //
  9566. // Permission is hereby granted, free of charge, to any person obtaining a
  9567. // copy of this software and associated documentation files (the
  9568. // "Software"), to deal in the Software without restriction, including
  9569. // without limitation the rights to use, copy, modify, merge, publish,
  9570. // distribute, sublicense, and/or sell copies of the Software, and to permit
  9571. // persons to whom the Software is furnished to do so, subject to the
  9572. // following conditions:
  9573. //
  9574. // The above copyright notice and this permission notice shall be included
  9575. // in all copies or substantial portions of the Software.
  9576. //
  9577. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  9578. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  9579. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  9580. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  9581. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  9582. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  9583. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  9584. var objectCreate = Object.create || objectCreatePolyfill
  9585. var objectKeys = Object.keys || objectKeysPolyfill
  9586. var bind = Function.prototype.bind || functionBindPolyfill
  9587. function EventEmitter() {
  9588. if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
  9589. this._events = objectCreate(null);
  9590. this._eventsCount = 0;
  9591. }
  9592. this._maxListeners = this._maxListeners || undefined;
  9593. }
  9594. module.exports = EventEmitter;
  9595. // Backwards-compat with node 0.10.x
  9596. EventEmitter.EventEmitter = EventEmitter;
  9597. EventEmitter.prototype._events = undefined;
  9598. EventEmitter.prototype._maxListeners = undefined;
  9599. // By default EventEmitters will print a warning if more than 10 listeners are
  9600. // added to it. This is a useful default which helps finding memory leaks.
  9601. var defaultMaxListeners = 10;
  9602. var hasDefineProperty;
  9603. try {
  9604. var o = {};
  9605. if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
  9606. hasDefineProperty = o.x === 0;
  9607. } catch (err) { hasDefineProperty = false }
  9608. if (hasDefineProperty) {
  9609. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  9610. enumerable: true,
  9611. get: function() {
  9612. return defaultMaxListeners;
  9613. },
  9614. set: function(arg) {
  9615. // check whether the input is a positive number (whose value is zero or
  9616. // greater and not a NaN).
  9617. if (typeof arg !== 'number' || arg < 0 || arg !== arg)
  9618. throw new TypeError('"defaultMaxListeners" must be a positive number');
  9619. defaultMaxListeners = arg;
  9620. }
  9621. });
  9622. } else {
  9623. EventEmitter.defaultMaxListeners = defaultMaxListeners;
  9624. }
  9625. // Obviously not all Emitters should be limited to 10. This function allows
  9626. // that to be increased. Set to zero for unlimited.
  9627. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  9628. if (typeof n !== 'number' || n < 0 || isNaN(n))
  9629. throw new TypeError('"n" argument must be a positive number');
  9630. this._maxListeners = n;
  9631. return this;
  9632. };
  9633. function $getMaxListeners(that) {
  9634. if (that._maxListeners === undefined)
  9635. return EventEmitter.defaultMaxListeners;
  9636. return that._maxListeners;
  9637. }
  9638. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  9639. return $getMaxListeners(this);
  9640. };
  9641. // These standalone emit* functions are used to optimize calling of event
  9642. // handlers for fast cases because emit() itself often has a variable number of
  9643. // arguments and can be deoptimized because of that. These functions always have
  9644. // the same number of arguments and thus do not get deoptimized, so the code
  9645. // inside them can execute faster.
  9646. function emitNone(handler, isFn, self) {
  9647. if (isFn)
  9648. handler.call(self);
  9649. else {
  9650. var len = handler.length;
  9651. var listeners = arrayClone(handler, len);
  9652. for (var i = 0; i < len; ++i)
  9653. listeners[i].call(self);
  9654. }
  9655. }
  9656. function emitOne(handler, isFn, self, arg1) {
  9657. if (isFn)
  9658. handler.call(self, arg1);
  9659. else {
  9660. var len = handler.length;
  9661. var listeners = arrayClone(handler, len);
  9662. for (var i = 0; i < len; ++i)
  9663. listeners[i].call(self, arg1);
  9664. }
  9665. }
  9666. function emitTwo(handler, isFn, self, arg1, arg2) {
  9667. if (isFn)
  9668. handler.call(self, arg1, arg2);
  9669. else {
  9670. var len = handler.length;
  9671. var listeners = arrayClone(handler, len);
  9672. for (var i = 0; i < len; ++i)
  9673. listeners[i].call(self, arg1, arg2);
  9674. }
  9675. }
  9676. function emitThree(handler, isFn, self, arg1, arg2, arg3) {
  9677. if (isFn)
  9678. handler.call(self, arg1, arg2, arg3);
  9679. else {
  9680. var len = handler.length;
  9681. var listeners = arrayClone(handler, len);
  9682. for (var i = 0; i < len; ++i)
  9683. listeners[i].call(self, arg1, arg2, arg3);
  9684. }
  9685. }
  9686. function emitMany(handler, isFn, self, args) {
  9687. if (isFn)
  9688. handler.apply(self, args);
  9689. else {
  9690. var len = handler.length;
  9691. var listeners = arrayClone(handler, len);
  9692. for (var i = 0; i < len; ++i)
  9693. listeners[i].apply(self, args);
  9694. }
  9695. }
  9696. EventEmitter.prototype.emit = function emit(type) {
  9697. var er, handler, len, args, i, events;
  9698. var doError = (type === 'error');
  9699. events = this._events;
  9700. if (events)
  9701. doError = (doError && events.error == null);
  9702. else if (!doError)
  9703. return false;
  9704. // If there is no 'error' event listener then throw.
  9705. if (doError) {
  9706. if (arguments.length > 1)
  9707. er = arguments[1];
  9708. if (er instanceof Error) {
  9709. throw er; // Unhandled 'error' event
  9710. } else {
  9711. // At least give some kind of context to the user
  9712. var err = new Error('Unhandled "error" event. (' + er + ')');
  9713. err.context = er;
  9714. throw err;
  9715. }
  9716. return false;
  9717. }
  9718. handler = events[type];
  9719. if (!handler)
  9720. return false;
  9721. var isFn = typeof handler === 'function';
  9722. len = arguments.length;
  9723. switch (len) {
  9724. // fast cases
  9725. case 1:
  9726. emitNone(handler, isFn, this);
  9727. break;
  9728. case 2:
  9729. emitOne(handler, isFn, this, arguments[1]);
  9730. break;
  9731. case 3:
  9732. emitTwo(handler, isFn, this, arguments[1], arguments[2]);
  9733. break;
  9734. case 4:
  9735. emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
  9736. break;
  9737. // slower
  9738. default:
  9739. args = new Array(len - 1);
  9740. for (i = 1; i < len; i++)
  9741. args[i - 1] = arguments[i];
  9742. emitMany(handler, isFn, this, args);
  9743. }
  9744. return true;
  9745. };
  9746. function _addListener(target, type, listener, prepend) {
  9747. var m;
  9748. var events;
  9749. var existing;
  9750. if (typeof listener !== 'function')
  9751. throw new TypeError('"listener" argument must be a function');
  9752. events = target._events;
  9753. if (!events) {
  9754. events = target._events = objectCreate(null);
  9755. target._eventsCount = 0;
  9756. } else {
  9757. // To avoid recursion in the case that type === "newListener"! Before
  9758. // adding it to the listeners, first emit "newListener".
  9759. if (events.newListener) {
  9760. target.emit('newListener', type,
  9761. listener.listener ? listener.listener : listener);
  9762. // Re-assign `events` because a newListener handler could have caused the
  9763. // this._events to be assigned to a new object
  9764. events = target._events;
  9765. }
  9766. existing = events[type];
  9767. }
  9768. if (!existing) {
  9769. // Optimize the case of one listener. Don't need the extra array object.
  9770. existing = events[type] = listener;
  9771. ++target._eventsCount;
  9772. } else {
  9773. if (typeof existing === 'function') {
  9774. // Adding the second element, need to change to array.
  9775. existing = events[type] =
  9776. prepend ? [listener, existing] : [existing, listener];
  9777. } else {
  9778. // If we've already got an array, just append.
  9779. if (prepend) {
  9780. existing.unshift(listener);
  9781. } else {
  9782. existing.push(listener);
  9783. }
  9784. }
  9785. // Check for listener leak
  9786. if (!existing.warned) {
  9787. m = $getMaxListeners(target);
  9788. if (m && m > 0 && existing.length > m) {
  9789. existing.warned = true;
  9790. var w = new Error('Possible EventEmitter memory leak detected. ' +
  9791. existing.length + ' "' + String(type) + '" listeners ' +
  9792. 'added. Use emitter.setMaxListeners() to ' +
  9793. 'increase limit.');
  9794. w.name = 'MaxListenersExceededWarning';
  9795. w.emitter = target;
  9796. w.type = type;
  9797. w.count = existing.length;
  9798. if (typeof console === 'object' && console.warn) {
  9799. console.warn('%s: %s', w.name, w.message);
  9800. }
  9801. }
  9802. }
  9803. }
  9804. return target;
  9805. }
  9806. EventEmitter.prototype.addListener = function addListener(type, listener) {
  9807. return _addListener(this, type, listener, false);
  9808. };
  9809. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  9810. EventEmitter.prototype.prependListener =
  9811. function prependListener(type, listener) {
  9812. return _addListener(this, type, listener, true);
  9813. };
  9814. function onceWrapper() {
  9815. if (!this.fired) {
  9816. this.target.removeListener(this.type, this.wrapFn);
  9817. this.fired = true;
  9818. switch (arguments.length) {
  9819. case 0:
  9820. return this.listener.call(this.target);
  9821. case 1:
  9822. return this.listener.call(this.target, arguments[0]);
  9823. case 2:
  9824. return this.listener.call(this.target, arguments[0], arguments[1]);
  9825. case 3:
  9826. return this.listener.call(this.target, arguments[0], arguments[1],
  9827. arguments[2]);
  9828. default:
  9829. var args = new Array(arguments.length);
  9830. for (var i = 0; i < args.length; ++i)
  9831. args[i] = arguments[i];
  9832. this.listener.apply(this.target, args);
  9833. }
  9834. }
  9835. }
  9836. function _onceWrap(target, type, listener) {
  9837. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  9838. var wrapped = bind.call(onceWrapper, state);
  9839. wrapped.listener = listener;
  9840. state.wrapFn = wrapped;
  9841. return wrapped;
  9842. }
  9843. EventEmitter.prototype.once = function once(type, listener) {
  9844. if (typeof listener !== 'function')
  9845. throw new TypeError('"listener" argument must be a function');
  9846. this.on(type, _onceWrap(this, type, listener));
  9847. return this;
  9848. };
  9849. EventEmitter.prototype.prependOnceListener =
  9850. function prependOnceListener(type, listener) {
  9851. if (typeof listener !== 'function')
  9852. throw new TypeError('"listener" argument must be a function');
  9853. this.prependListener(type, _onceWrap(this, type, listener));
  9854. return this;
  9855. };
  9856. // Emits a 'removeListener' event if and only if the listener was removed.
  9857. EventEmitter.prototype.removeListener =
  9858. function removeListener(type, listener) {
  9859. var list, events, position, i, originalListener;
  9860. if (typeof listener !== 'function')
  9861. throw new TypeError('"listener" argument must be a function');
  9862. events = this._events;
  9863. if (!events)
  9864. return this;
  9865. list = events[type];
  9866. if (!list)
  9867. return this;
  9868. if (list === listener || list.listener === listener) {
  9869. if (--this._eventsCount === 0)
  9870. this._events = objectCreate(null);
  9871. else {
  9872. delete events[type];
  9873. if (events.removeListener)
  9874. this.emit('removeListener', type, list.listener || listener);
  9875. }
  9876. } else if (typeof list !== 'function') {
  9877. position = -1;
  9878. for (i = list.length - 1; i >= 0; i--) {
  9879. if (list[i] === listener || list[i].listener === listener) {
  9880. originalListener = list[i].listener;
  9881. position = i;
  9882. break;
  9883. }
  9884. }
  9885. if (position < 0)
  9886. return this;
  9887. if (position === 0)
  9888. list.shift();
  9889. else
  9890. spliceOne(list, position);
  9891. if (list.length === 1)
  9892. events[type] = list[0];
  9893. if (events.removeListener)
  9894. this.emit('removeListener', type, originalListener || listener);
  9895. }
  9896. return this;
  9897. };
  9898. EventEmitter.prototype.removeAllListeners =
  9899. function removeAllListeners(type) {
  9900. var listeners, events, i;
  9901. events = this._events;
  9902. if (!events)
  9903. return this;
  9904. // not listening for removeListener, no need to emit
  9905. if (!events.removeListener) {
  9906. if (arguments.length === 0) {
  9907. this._events = objectCreate(null);
  9908. this._eventsCount = 0;
  9909. } else if (events[type]) {
  9910. if (--this._eventsCount === 0)
  9911. this._events = objectCreate(null);
  9912. else
  9913. delete events[type];
  9914. }
  9915. return this;
  9916. }
  9917. // emit removeListener for all listeners on all events
  9918. if (arguments.length === 0) {
  9919. var keys = objectKeys(events);
  9920. var key;
  9921. for (i = 0; i < keys.length; ++i) {
  9922. key = keys[i];
  9923. if (key === 'removeListener') continue;
  9924. this.removeAllListeners(key);
  9925. }
  9926. this.removeAllListeners('removeListener');
  9927. this._events = objectCreate(null);
  9928. this._eventsCount = 0;
  9929. return this;
  9930. }
  9931. listeners = events[type];
  9932. if (typeof listeners === 'function') {
  9933. this.removeListener(type, listeners);
  9934. } else if (listeners) {
  9935. // LIFO order
  9936. for (i = listeners.length - 1; i >= 0; i--) {
  9937. this.removeListener(type, listeners[i]);
  9938. }
  9939. }
  9940. return this;
  9941. };
  9942. EventEmitter.prototype.listeners = function listeners(type) {
  9943. var evlistener;
  9944. var ret;
  9945. var events = this._events;
  9946. if (!events)
  9947. ret = [];
  9948. else {
  9949. evlistener = events[type];
  9950. if (!evlistener)
  9951. ret = [];
  9952. else if (typeof evlistener === 'function')
  9953. ret = [evlistener.listener || evlistener];
  9954. else
  9955. ret = unwrapListeners(evlistener);
  9956. }
  9957. return ret;
  9958. };
  9959. EventEmitter.listenerCount = function(emitter, type) {
  9960. if (typeof emitter.listenerCount === 'function') {
  9961. return emitter.listenerCount(type);
  9962. } else {
  9963. return listenerCount.call(emitter, type);
  9964. }
  9965. };
  9966. EventEmitter.prototype.listenerCount = listenerCount;
  9967. function listenerCount(type) {
  9968. var events = this._events;
  9969. if (events) {
  9970. var evlistener = events[type];
  9971. if (typeof evlistener === 'function') {
  9972. return 1;
  9973. } else if (evlistener) {
  9974. return evlistener.length;
  9975. }
  9976. }
  9977. return 0;
  9978. }
  9979. EventEmitter.prototype.eventNames = function eventNames() {
  9980. return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
  9981. };
  9982. // About 1.5x faster than the two-arg version of Array#splice().
  9983. function spliceOne(list, index) {
  9984. for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
  9985. list[i] = list[k];
  9986. list.pop();
  9987. }
  9988. function arrayClone(arr, n) {
  9989. var copy = new Array(n);
  9990. for (var i = 0; i < n; ++i)
  9991. copy[i] = arr[i];
  9992. return copy;
  9993. }
  9994. function unwrapListeners(arr) {
  9995. var ret = new Array(arr.length);
  9996. for (var i = 0; i < ret.length; ++i) {
  9997. ret[i] = arr[i].listener || arr[i];
  9998. }
  9999. return ret;
  10000. }
  10001. function objectCreatePolyfill(proto) {
  10002. var F = function() {};
  10003. F.prototype = proto;
  10004. return new F;
  10005. }
  10006. function objectKeysPolyfill(obj) {
  10007. var keys = [];
  10008. for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
  10009. keys.push(k);
  10010. }
  10011. return k;
  10012. }
  10013. function functionBindPolyfill(context) {
  10014. var fn = this;
  10015. return function () {
  10016. return fn.apply(context, arguments);
  10017. };
  10018. }
  10019. },{}],48:[function(require,module,exports){
  10020. (function (global){
  10021. /*! https://mths.be/he v1.1.1 by @mathias | MIT license */
  10022. ;(function(root) {
  10023. // Detect free variables `exports`.
  10024. var freeExports = typeof exports == 'object' && exports;
  10025. // Detect free variable `module`.
  10026. var freeModule = typeof module == 'object' && module &&
  10027. module.exports == freeExports && module;
  10028. // Detect free variable `global`, from Node.js or Browserified code,
  10029. // and use it as `root`.
  10030. var freeGlobal = typeof global == 'object' && global;
  10031. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
  10032. root = freeGlobal;
  10033. }
  10034. /*--------------------------------------------------------------------------*/
  10035. // All astral symbols.
  10036. var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
  10037. // All ASCII symbols (not just printable ASCII) except those listed in the
  10038. // first column of the overrides table.
  10039. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides
  10040. var regexAsciiWhitelist = /[\x01-\x7F]/g;
  10041. // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
  10042. // code points listed in the first column of the overrides table on
  10043. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides.
  10044. var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
  10045. 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;
  10046. 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'};
  10047. var regexEscape = /["&'<>`]/g;
  10048. var escapeMap = {
  10049. '"': '&quot;',
  10050. '&': '&amp;',
  10051. '\'': '&#x27;',
  10052. '<': '&lt;',
  10053. // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
  10054. // following is not strictly necessary unless it’s part of a tag or an
  10055. // unquoted attribute value. We’re only escaping it to support those
  10056. // situations, and for XML support.
  10057. '>': '&gt;',
  10058. // In Internet Explorer ≤ 8, the backtick character can be used
  10059. // to break out of (un)quoted attribute values or HTML comments.
  10060. // See http://html5sec.org/#102, http://html5sec.org/#108, and
  10061. // http://html5sec.org/#133.
  10062. '`': '&#x60;'
  10063. };
  10064. var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
  10065. 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]/;
  10066. var regexDecode = /&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+);|&(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])?/g;
  10067. 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'};
  10068. 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'};
  10069. 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'};
  10070. 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];
  10071. /*--------------------------------------------------------------------------*/
  10072. var stringFromCharCode = String.fromCharCode;
  10073. var object = {};
  10074. var hasOwnProperty = object.hasOwnProperty;
  10075. var has = function(object, propertyName) {
  10076. return hasOwnProperty.call(object, propertyName);
  10077. };
  10078. var contains = function(array, value) {
  10079. var index = -1;
  10080. var length = array.length;
  10081. while (++index < length) {
  10082. if (array[index] == value) {
  10083. return true;
  10084. }
  10085. }
  10086. return false;
  10087. };
  10088. var merge = function(options, defaults) {
  10089. if (!options) {
  10090. return defaults;
  10091. }
  10092. var result = {};
  10093. var key;
  10094. for (key in defaults) {
  10095. // A `hasOwnProperty` check is not needed here, since only recognized
  10096. // option names are used anyway. Any others are ignored.
  10097. result[key] = has(options, key) ? options[key] : defaults[key];
  10098. }
  10099. return result;
  10100. };
  10101. // Modified version of `ucs2encode`; see https://mths.be/punycode.
  10102. var codePointToSymbol = function(codePoint, strict) {
  10103. var output = '';
  10104. if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
  10105. // See issue #4:
  10106. // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
  10107. // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
  10108. // REPLACEMENT CHARACTER.”
  10109. if (strict) {
  10110. parseError('character reference outside the permissible Unicode range');
  10111. }
  10112. return '\uFFFD';
  10113. }
  10114. if (has(decodeMapNumeric, codePoint)) {
  10115. if (strict) {
  10116. parseError('disallowed character reference');
  10117. }
  10118. return decodeMapNumeric[codePoint];
  10119. }
  10120. if (strict && contains(invalidReferenceCodePoints, codePoint)) {
  10121. parseError('disallowed character reference');
  10122. }
  10123. if (codePoint > 0xFFFF) {
  10124. codePoint -= 0x10000;
  10125. output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
  10126. codePoint = 0xDC00 | codePoint & 0x3FF;
  10127. }
  10128. output += stringFromCharCode(codePoint);
  10129. return output;
  10130. };
  10131. var hexEscape = function(codePoint) {
  10132. return '&#x' + codePoint.toString(16).toUpperCase() + ';';
  10133. };
  10134. var decEscape = function(codePoint) {
  10135. return '&#' + codePoint + ';';
  10136. };
  10137. var parseError = function(message) {
  10138. throw Error('Parse error: ' + message);
  10139. };
  10140. /*--------------------------------------------------------------------------*/
  10141. var encode = function(string, options) {
  10142. options = merge(options, encode.options);
  10143. var strict = options.strict;
  10144. if (strict && regexInvalidRawCodePoint.test(string)) {
  10145. parseError('forbidden code point');
  10146. }
  10147. var encodeEverything = options.encodeEverything;
  10148. var useNamedReferences = options.useNamedReferences;
  10149. var allowUnsafeSymbols = options.allowUnsafeSymbols;
  10150. var escapeCodePoint = options.decimal ? decEscape : hexEscape;
  10151. var escapeBmpSymbol = function(symbol) {
  10152. return escapeCodePoint(symbol.charCodeAt(0));
  10153. };
  10154. if (encodeEverything) {
  10155. // Encode ASCII symbols.
  10156. string = string.replace(regexAsciiWhitelist, function(symbol) {
  10157. // Use named references if requested & possible.
  10158. if (useNamedReferences && has(encodeMap, symbol)) {
  10159. return '&' + encodeMap[symbol] + ';';
  10160. }
  10161. return escapeBmpSymbol(symbol);
  10162. });
  10163. // Shorten a few escapes that represent two symbols, of which at least one
  10164. // is within the ASCII range.
  10165. if (useNamedReferences) {
  10166. string = string
  10167. .replace(/&gt;\u20D2/g, '&nvgt;')
  10168. .replace(/&lt;\u20D2/g, '&nvlt;')
  10169. .replace(/&#x66;&#x6A;/g, '&fjlig;');
  10170. }
  10171. // Encode non-ASCII symbols.
  10172. if (useNamedReferences) {
  10173. // Encode non-ASCII symbols that can be replaced with a named reference.
  10174. string = string.replace(regexEncodeNonAscii, function(string) {
  10175. // Note: there is no need to check `has(encodeMap, string)` here.
  10176. return '&' + encodeMap[string] + ';';
  10177. });
  10178. }
  10179. // Note: any remaining non-ASCII symbols are handled outside of the `if`.
  10180. } else if (useNamedReferences) {
  10181. // Apply named character references.
  10182. // Encode `<>"'&` using named character references.
  10183. if (!allowUnsafeSymbols) {
  10184. string = string.replace(regexEscape, function(string) {
  10185. return '&' + encodeMap[string] + ';'; // no need to check `has()` here
  10186. });
  10187. }
  10188. // Shorten escapes that represent two symbols, of which at least one is
  10189. // `<>"'&`.
  10190. string = string
  10191. .replace(/&gt;\u20D2/g, '&nvgt;')
  10192. .replace(/&lt;\u20D2/g, '&nvlt;');
  10193. // Encode non-ASCII symbols that can be replaced with a named reference.
  10194. string = string.replace(regexEncodeNonAscii, function(string) {
  10195. // Note: there is no need to check `has(encodeMap, string)` here.
  10196. return '&' + encodeMap[string] + ';';
  10197. });
  10198. } else if (!allowUnsafeSymbols) {
  10199. // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
  10200. // using named character references.
  10201. string = string.replace(regexEscape, escapeBmpSymbol);
  10202. }
  10203. return string
  10204. // Encode astral symbols.
  10205. .replace(regexAstralSymbols, function($0) {
  10206. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  10207. var high = $0.charCodeAt(0);
  10208. var low = $0.charCodeAt(1);
  10209. var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
  10210. return escapeCodePoint(codePoint);
  10211. })
  10212. // Encode any remaining BMP symbols that are not printable ASCII symbols
  10213. // using a hexadecimal escape.
  10214. .replace(regexBmpWhitelist, escapeBmpSymbol);
  10215. };
  10216. // Expose default options (so they can be overridden globally).
  10217. encode.options = {
  10218. 'allowUnsafeSymbols': false,
  10219. 'encodeEverything': false,
  10220. 'strict': false,
  10221. 'useNamedReferences': false,
  10222. 'decimal' : false
  10223. };
  10224. var decode = function(html, options) {
  10225. options = merge(options, decode.options);
  10226. var strict = options.strict;
  10227. if (strict && regexInvalidEntity.test(html)) {
  10228. parseError('malformed character reference');
  10229. }
  10230. return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7) {
  10231. var codePoint;
  10232. var semicolon;
  10233. var decDigits;
  10234. var hexDigits;
  10235. var reference;
  10236. var next;
  10237. if ($1) {
  10238. // Decode decimal escapes, e.g. `&#119558;`.
  10239. decDigits = $1;
  10240. semicolon = $2;
  10241. if (strict && !semicolon) {
  10242. parseError('character reference was not terminated by a semicolon');
  10243. }
  10244. codePoint = parseInt(decDigits, 10);
  10245. return codePointToSymbol(codePoint, strict);
  10246. }
  10247. if ($3) {
  10248. // Decode hexadecimal escapes, e.g. `&#x1D306;`.
  10249. hexDigits = $3;
  10250. semicolon = $4;
  10251. if (strict && !semicolon) {
  10252. parseError('character reference was not terminated by a semicolon');
  10253. }
  10254. codePoint = parseInt(hexDigits, 16);
  10255. return codePointToSymbol(codePoint, strict);
  10256. }
  10257. if ($5) {
  10258. // Decode named character references with trailing `;`, e.g. `&copy;`.
  10259. reference = $5;
  10260. if (has(decodeMap, reference)) {
  10261. return decodeMap[reference];
  10262. } else {
  10263. // Ambiguous ampersand. https://mths.be/notes/ambiguous-ampersands
  10264. if (strict) {
  10265. parseError(
  10266. 'named character reference was not terminated by a semicolon'
  10267. );
  10268. }
  10269. return $0;
  10270. }
  10271. }
  10272. // If we’re still here, it’s a legacy reference for sure. No need for an
  10273. // extra `if` check.
  10274. // Decode named character references without trailing `;`, e.g. `&amp`
  10275. // This is only a parse error if it gets converted to `&`, or if it is
  10276. // followed by `=` in an attribute context.
  10277. reference = $6;
  10278. next = $7;
  10279. if (next && options.isAttributeValue) {
  10280. if (strict && next == '=') {
  10281. parseError('`&` did not start a character reference');
  10282. }
  10283. return $0;
  10284. } else {
  10285. if (strict) {
  10286. parseError(
  10287. 'named character reference was not terminated by a semicolon'
  10288. );
  10289. }
  10290. // Note: there is no need to check `has(decodeMapLegacy, reference)`.
  10291. return decodeMapLegacy[reference] + (next || '');
  10292. }
  10293. });
  10294. };
  10295. // Expose default options (so they can be overridden globally).
  10296. decode.options = {
  10297. 'isAttributeValue': false,
  10298. 'strict': false
  10299. };
  10300. var escape = function(string) {
  10301. return string.replace(regexEscape, function($0) {
  10302. // Note: there is no need to check `has(escapeMap, $0)` here.
  10303. return escapeMap[$0];
  10304. });
  10305. };
  10306. /*--------------------------------------------------------------------------*/
  10307. var he = {
  10308. 'version': '1.1.1',
  10309. 'encode': encode,
  10310. 'decode': decode,
  10311. 'escape': escape,
  10312. 'unescape': decode
  10313. };
  10314. // Some AMD build optimizers, like r.js, check for specific condition patterns
  10315. // like the following:
  10316. if (
  10317. false
  10318. ) {
  10319. define(function() {
  10320. return he;
  10321. });
  10322. } else if (freeExports && !freeExports.nodeType) {
  10323. if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
  10324. freeModule.exports = he;
  10325. } else { // in Narwhal or RingoJS v0.7.0-
  10326. for (var key in he) {
  10327. has(he, key) && (freeExports[key] = he[key]);
  10328. }
  10329. }
  10330. } else { // in Rhino or a web browser
  10331. root.he = he;
  10332. }
  10333. }(this));
  10334. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  10335. },{}],49:[function(require,module,exports){
  10336. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  10337. var e, m
  10338. var eLen = (nBytes * 8) - mLen - 1
  10339. var eMax = (1 << eLen) - 1
  10340. var eBias = eMax >> 1
  10341. var nBits = -7
  10342. var i = isLE ? (nBytes - 1) : 0
  10343. var d = isLE ? -1 : 1
  10344. var s = buffer[offset + i]
  10345. i += d
  10346. e = s & ((1 << (-nBits)) - 1)
  10347. s >>= (-nBits)
  10348. nBits += eLen
  10349. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  10350. m = e & ((1 << (-nBits)) - 1)
  10351. e >>= (-nBits)
  10352. nBits += mLen
  10353. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  10354. if (e === 0) {
  10355. e = 1 - eBias
  10356. } else if (e === eMax) {
  10357. return m ? NaN : ((s ? -1 : 1) * Infinity)
  10358. } else {
  10359. m = m + Math.pow(2, mLen)
  10360. e = e - eBias
  10361. }
  10362. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  10363. }
  10364. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  10365. var e, m, c
  10366. var eLen = (nBytes * 8) - mLen - 1
  10367. var eMax = (1 << eLen) - 1
  10368. var eBias = eMax >> 1
  10369. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  10370. var i = isLE ? 0 : (nBytes - 1)
  10371. var d = isLE ? 1 : -1
  10372. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  10373. value = Math.abs(value)
  10374. if (isNaN(value) || value === Infinity) {
  10375. m = isNaN(value) ? 1 : 0
  10376. e = eMax
  10377. } else {
  10378. e = Math.floor(Math.log(value) / Math.LN2)
  10379. if (value * (c = Math.pow(2, -e)) < 1) {
  10380. e--
  10381. c *= 2
  10382. }
  10383. if (e + eBias >= 1) {
  10384. value += rt / c
  10385. } else {
  10386. value += rt * Math.pow(2, 1 - eBias)
  10387. }
  10388. if (value * c >= 2) {
  10389. e++
  10390. c /= 2
  10391. }
  10392. if (e + eBias >= eMax) {
  10393. m = 0
  10394. e = eMax
  10395. } else if (e + eBias >= 1) {
  10396. m = ((value * c) - 1) * Math.pow(2, mLen)
  10397. e = e + eBias
  10398. } else {
  10399. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  10400. e = 0
  10401. }
  10402. }
  10403. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  10404. e = (e << mLen) | m
  10405. eLen += mLen
  10406. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  10407. buffer[offset + i - d] |= s * 128
  10408. }
  10409. },{}],50:[function(require,module,exports){
  10410. if (typeof Object.create === 'function') {
  10411. // implementation from standard node.js 'util' module
  10412. module.exports = function inherits(ctor, superCtor) {
  10413. ctor.super_ = superCtor
  10414. ctor.prototype = Object.create(superCtor.prototype, {
  10415. constructor: {
  10416. value: ctor,
  10417. enumerable: false,
  10418. writable: true,
  10419. configurable: true
  10420. }
  10421. });
  10422. };
  10423. } else {
  10424. // old school shim for old browsers
  10425. module.exports = function inherits(ctor, superCtor) {
  10426. ctor.super_ = superCtor
  10427. var TempCtor = function () {}
  10428. TempCtor.prototype = superCtor.prototype
  10429. ctor.prototype = new TempCtor()
  10430. ctor.prototype.constructor = ctor
  10431. }
  10432. }
  10433. },{}],51:[function(require,module,exports){
  10434. /*!
  10435. * Determine if an object is a Buffer
  10436. *
  10437. * @author Feross Aboukhadijeh <https://feross.org>
  10438. * @license MIT
  10439. */
  10440. // The _isBuffer check is for Safari 5-7 support, because it's missing
  10441. // Object.prototype.constructor. Remove this eventually
  10442. module.exports = function (obj) {
  10443. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  10444. }
  10445. function isBuffer (obj) {
  10446. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  10447. }
  10448. // For Node v0.10 support. Remove this eventually.
  10449. function isSlowBuffer (obj) {
  10450. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  10451. }
  10452. },{}],52:[function(require,module,exports){
  10453. var toString = {}.toString;
  10454. module.exports = Array.isArray || function (arr) {
  10455. return toString.call(arr) == '[object Array]';
  10456. };
  10457. },{}],53:[function(require,module,exports){
  10458. (function (process){
  10459. var path = require('path');
  10460. var fs = require('fs');
  10461. var _0777 = parseInt('0777', 8);
  10462. module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
  10463. function mkdirP (p, opts, f, made) {
  10464. if (typeof opts === 'function') {
  10465. f = opts;
  10466. opts = {};
  10467. }
  10468. else if (!opts || typeof opts !== 'object') {
  10469. opts = { mode: opts };
  10470. }
  10471. var mode = opts.mode;
  10472. var xfs = opts.fs || fs;
  10473. if (mode === undefined) {
  10474. mode = _0777 & (~process.umask());
  10475. }
  10476. if (!made) made = null;
  10477. var cb = f || function () {};
  10478. p = path.resolve(p);
  10479. xfs.mkdir(p, mode, function (er) {
  10480. if (!er) {
  10481. made = made || p;
  10482. return cb(null, made);
  10483. }
  10484. switch (er.code) {
  10485. case 'ENOENT':
  10486. mkdirP(path.dirname(p), opts, function (er, made) {
  10487. if (er) cb(er, made);
  10488. else mkdirP(p, opts, cb, made);
  10489. });
  10490. break;
  10491. // In the case of any other error, just see if there's a dir
  10492. // there already. If so, then hooray! If not, then something
  10493. // is borked.
  10494. default:
  10495. xfs.stat(p, function (er2, stat) {
  10496. // if the stat fails, then that's super weird.
  10497. // let the original error be the failure reason.
  10498. if (er2 || !stat.isDirectory()) cb(er, made)
  10499. else cb(null, made);
  10500. });
  10501. break;
  10502. }
  10503. });
  10504. }
  10505. mkdirP.sync = function sync (p, opts, made) {
  10506. if (!opts || typeof opts !== 'object') {
  10507. opts = { mode: opts };
  10508. }
  10509. var mode = opts.mode;
  10510. var xfs = opts.fs || fs;
  10511. if (mode === undefined) {
  10512. mode = _0777 & (~process.umask());
  10513. }
  10514. if (!made) made = null;
  10515. p = path.resolve(p);
  10516. try {
  10517. xfs.mkdirSync(p, mode);
  10518. made = made || p;
  10519. }
  10520. catch (err0) {
  10521. switch (err0.code) {
  10522. case 'ENOENT' :
  10523. made = sync(path.dirname(p), opts, made);
  10524. sync(p, opts, made);
  10525. break;
  10526. // In the case of any other error, just see if there's a dir
  10527. // there already. If so, then hooray! If not, then something
  10528. // is borked.
  10529. default:
  10530. var stat;
  10531. try {
  10532. stat = xfs.statSync(p);
  10533. }
  10534. catch (err1) {
  10535. throw err0;
  10536. }
  10537. if (!stat.isDirectory()) throw err0;
  10538. break;
  10539. }
  10540. }
  10541. return made;
  10542. };
  10543. }).call(this,require('_process'))
  10544. },{"_process":56,"fs":40,"path":40}],54:[function(require,module,exports){
  10545. /**
  10546. * Helpers.
  10547. */
  10548. var s = 1000;
  10549. var m = s * 60;
  10550. var h = m * 60;
  10551. var d = h * 24;
  10552. var y = d * 365.25;
  10553. /**
  10554. * Parse or format the given `val`.
  10555. *
  10556. * Options:
  10557. *
  10558. * - `long` verbose formatting [false]
  10559. *
  10560. * @param {String|Number} val
  10561. * @param {Object} [options]
  10562. * @throws {Error} throw an error if val is not a non-empty string or a number
  10563. * @return {String|Number}
  10564. * @api public
  10565. */
  10566. module.exports = function(val, options) {
  10567. options = options || {};
  10568. var type = typeof val;
  10569. if (type === 'string' && val.length > 0) {
  10570. return parse(val);
  10571. } else if (type === 'number' && isNaN(val) === false) {
  10572. return options.long ? fmtLong(val) : fmtShort(val);
  10573. }
  10574. throw new Error(
  10575. 'val is not a non-empty string or a valid number. val=' +
  10576. JSON.stringify(val)
  10577. );
  10578. };
  10579. /**
  10580. * Parse the given `str` and return milliseconds.
  10581. *
  10582. * @param {String} str
  10583. * @return {Number}
  10584. * @api private
  10585. */
  10586. function parse(str) {
  10587. str = String(str);
  10588. if (str.length > 100) {
  10589. return;
  10590. }
  10591. var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
  10592. str
  10593. );
  10594. if (!match) {
  10595. return;
  10596. }
  10597. var n = parseFloat(match[1]);
  10598. var type = (match[2] || 'ms').toLowerCase();
  10599. switch (type) {
  10600. case 'years':
  10601. case 'year':
  10602. case 'yrs':
  10603. case 'yr':
  10604. case 'y':
  10605. return n * y;
  10606. case 'days':
  10607. case 'day':
  10608. case 'd':
  10609. return n * d;
  10610. case 'hours':
  10611. case 'hour':
  10612. case 'hrs':
  10613. case 'hr':
  10614. case 'h':
  10615. return n * h;
  10616. case 'minutes':
  10617. case 'minute':
  10618. case 'mins':
  10619. case 'min':
  10620. case 'm':
  10621. return n * m;
  10622. case 'seconds':
  10623. case 'second':
  10624. case 'secs':
  10625. case 'sec':
  10626. case 's':
  10627. return n * s;
  10628. case 'milliseconds':
  10629. case 'millisecond':
  10630. case 'msecs':
  10631. case 'msec':
  10632. case 'ms':
  10633. return n;
  10634. default:
  10635. return undefined;
  10636. }
  10637. }
  10638. /**
  10639. * Short format for `ms`.
  10640. *
  10641. * @param {Number} ms
  10642. * @return {String}
  10643. * @api private
  10644. */
  10645. function fmtShort(ms) {
  10646. if (ms >= d) {
  10647. return Math.round(ms / d) + 'd';
  10648. }
  10649. if (ms >= h) {
  10650. return Math.round(ms / h) + 'h';
  10651. }
  10652. if (ms >= m) {
  10653. return Math.round(ms / m) + 'm';
  10654. }
  10655. if (ms >= s) {
  10656. return Math.round(ms / s) + 's';
  10657. }
  10658. return ms + 'ms';
  10659. }
  10660. /**
  10661. * Long format for `ms`.
  10662. *
  10663. * @param {Number} ms
  10664. * @return {String}
  10665. * @api private
  10666. */
  10667. function fmtLong(ms) {
  10668. return plural(ms, d, 'day') ||
  10669. plural(ms, h, 'hour') ||
  10670. plural(ms, m, 'minute') ||
  10671. plural(ms, s, 'second') ||
  10672. ms + ' ms';
  10673. }
  10674. /**
  10675. * Pluralization helper.
  10676. */
  10677. function plural(ms, n, name) {
  10678. if (ms < n) {
  10679. return;
  10680. }
  10681. if (ms < n * 1.5) {
  10682. return Math.floor(ms / n) + ' ' + name;
  10683. }
  10684. return Math.ceil(ms / n) + ' ' + name + 's';
  10685. }
  10686. },{}],55:[function(require,module,exports){
  10687. (function (process){
  10688. 'use strict';
  10689. if (!process.version ||
  10690. process.version.indexOf('v0.') === 0 ||
  10691. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  10692. module.exports = { nextTick: nextTick };
  10693. } else {
  10694. module.exports = process
  10695. }
  10696. function nextTick(fn, arg1, arg2, arg3) {
  10697. if (typeof fn !== 'function') {
  10698. throw new TypeError('"callback" argument must be a function');
  10699. }
  10700. var len = arguments.length;
  10701. var args, i;
  10702. switch (len) {
  10703. case 0:
  10704. case 1:
  10705. return process.nextTick(fn);
  10706. case 2:
  10707. return process.nextTick(function afterTickOne() {
  10708. fn.call(null, arg1);
  10709. });
  10710. case 3:
  10711. return process.nextTick(function afterTickTwo() {
  10712. fn.call(null, arg1, arg2);
  10713. });
  10714. case 4:
  10715. return process.nextTick(function afterTickThree() {
  10716. fn.call(null, arg1, arg2, arg3);
  10717. });
  10718. default:
  10719. args = new Array(len - 1);
  10720. i = 0;
  10721. while (i < args.length) {
  10722. args[i++] = arguments[i];
  10723. }
  10724. return process.nextTick(function afterTick() {
  10725. fn.apply(null, args);
  10726. });
  10727. }
  10728. }
  10729. }).call(this,require('_process'))
  10730. },{"_process":56}],56:[function(require,module,exports){
  10731. // shim for using process in browser
  10732. var process = module.exports = {};
  10733. // cached from whatever global is present so that test runners that stub it
  10734. // don't break things. But we need to wrap it in a try catch in case it is
  10735. // wrapped in strict mode code which doesn't define any globals. It's inside a
  10736. // function because try/catches deoptimize in certain engines.
  10737. var cachedSetTimeout;
  10738. var cachedClearTimeout;
  10739. function defaultSetTimout() {
  10740. throw new Error('setTimeout has not been defined');
  10741. }
  10742. function defaultClearTimeout () {
  10743. throw new Error('clearTimeout has not been defined');
  10744. }
  10745. (function () {
  10746. try {
  10747. if (typeof setTimeout === 'function') {
  10748. cachedSetTimeout = setTimeout;
  10749. } else {
  10750. cachedSetTimeout = defaultSetTimout;
  10751. }
  10752. } catch (e) {
  10753. cachedSetTimeout = defaultSetTimout;
  10754. }
  10755. try {
  10756. if (typeof clearTimeout === 'function') {
  10757. cachedClearTimeout = clearTimeout;
  10758. } else {
  10759. cachedClearTimeout = defaultClearTimeout;
  10760. }
  10761. } catch (e) {
  10762. cachedClearTimeout = defaultClearTimeout;
  10763. }
  10764. } ())
  10765. function runTimeout(fun) {
  10766. if (cachedSetTimeout === setTimeout) {
  10767. //normal enviroments in sane situations
  10768. return setTimeout(fun, 0);
  10769. }
  10770. // if setTimeout wasn't available but was latter defined
  10771. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  10772. cachedSetTimeout = setTimeout;
  10773. return setTimeout(fun, 0);
  10774. }
  10775. try {
  10776. // when when somebody has screwed with setTimeout but no I.E. maddness
  10777. return cachedSetTimeout(fun, 0);
  10778. } catch(e){
  10779. try {
  10780. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  10781. return cachedSetTimeout.call(null, fun, 0);
  10782. } catch(e){
  10783. // 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
  10784. return cachedSetTimeout.call(this, fun, 0);
  10785. }
  10786. }
  10787. }
  10788. function runClearTimeout(marker) {
  10789. if (cachedClearTimeout === clearTimeout) {
  10790. //normal enviroments in sane situations
  10791. return clearTimeout(marker);
  10792. }
  10793. // if clearTimeout wasn't available but was latter defined
  10794. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  10795. cachedClearTimeout = clearTimeout;
  10796. return clearTimeout(marker);
  10797. }
  10798. try {
  10799. // when when somebody has screwed with setTimeout but no I.E. maddness
  10800. return cachedClearTimeout(marker);
  10801. } catch (e){
  10802. try {
  10803. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  10804. return cachedClearTimeout.call(null, marker);
  10805. } catch (e){
  10806. // 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.
  10807. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  10808. return cachedClearTimeout.call(this, marker);
  10809. }
  10810. }
  10811. }
  10812. var queue = [];
  10813. var draining = false;
  10814. var currentQueue;
  10815. var queueIndex = -1;
  10816. function cleanUpNextTick() {
  10817. if (!draining || !currentQueue) {
  10818. return;
  10819. }
  10820. draining = false;
  10821. if (currentQueue.length) {
  10822. queue = currentQueue.concat(queue);
  10823. } else {
  10824. queueIndex = -1;
  10825. }
  10826. if (queue.length) {
  10827. drainQueue();
  10828. }
  10829. }
  10830. function drainQueue() {
  10831. if (draining) {
  10832. return;
  10833. }
  10834. var timeout = runTimeout(cleanUpNextTick);
  10835. draining = true;
  10836. var len = queue.length;
  10837. while(len) {
  10838. currentQueue = queue;
  10839. queue = [];
  10840. while (++queueIndex < len) {
  10841. if (currentQueue) {
  10842. currentQueue[queueIndex].run();
  10843. }
  10844. }
  10845. queueIndex = -1;
  10846. len = queue.length;
  10847. }
  10848. currentQueue = null;
  10849. draining = false;
  10850. runClearTimeout(timeout);
  10851. }
  10852. process.nextTick = function (fun) {
  10853. var args = new Array(arguments.length - 1);
  10854. if (arguments.length > 1) {
  10855. for (var i = 1; i < arguments.length; i++) {
  10856. args[i - 1] = arguments[i];
  10857. }
  10858. }
  10859. queue.push(new Item(fun, args));
  10860. if (queue.length === 1 && !draining) {
  10861. runTimeout(drainQueue);
  10862. }
  10863. };
  10864. // v8 likes predictible objects
  10865. function Item(fun, array) {
  10866. this.fun = fun;
  10867. this.array = array;
  10868. }
  10869. Item.prototype.run = function () {
  10870. this.fun.apply(null, this.array);
  10871. };
  10872. process.title = 'browser';
  10873. process.browser = true;
  10874. process.env = {};
  10875. process.argv = [];
  10876. process.version = ''; // empty string to avoid regexp issues
  10877. process.versions = {};
  10878. function noop() {}
  10879. process.on = noop;
  10880. process.addListener = noop;
  10881. process.once = noop;
  10882. process.off = noop;
  10883. process.removeListener = noop;
  10884. process.removeAllListeners = noop;
  10885. process.emit = noop;
  10886. process.prependListener = noop;
  10887. process.prependOnceListener = noop;
  10888. process.listeners = function (name) { return [] }
  10889. process.binding = function (name) {
  10890. throw new Error('process.binding is not supported');
  10891. };
  10892. process.cwd = function () { return '/' };
  10893. process.chdir = function (dir) {
  10894. throw new Error('process.chdir is not supported');
  10895. };
  10896. process.umask = function() { return 0; };
  10897. },{}],57:[function(require,module,exports){
  10898. module.exports = require('./lib/_stream_duplex.js');
  10899. },{"./lib/_stream_duplex.js":58}],58:[function(require,module,exports){
  10900. // Copyright Joyent, Inc. and other Node contributors.
  10901. //
  10902. // Permission is hereby granted, free of charge, to any person obtaining a
  10903. // copy of this software and associated documentation files (the
  10904. // "Software"), to deal in the Software without restriction, including
  10905. // without limitation the rights to use, copy, modify, merge, publish,
  10906. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10907. // persons to whom the Software is furnished to do so, subject to the
  10908. // following conditions:
  10909. //
  10910. // The above copyright notice and this permission notice shall be included
  10911. // in all copies or substantial portions of the Software.
  10912. //
  10913. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10914. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10915. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10916. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10917. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10918. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10919. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10920. // a duplex stream is just a stream that is both readable and writable.
  10921. // Since JS doesn't have multiple prototypal inheritance, this class
  10922. // prototypally inherits from Readable, and then parasitically from
  10923. // Writable.
  10924. 'use strict';
  10925. /*<replacement>*/
  10926. var pna = require('process-nextick-args');
  10927. /*</replacement>*/
  10928. /*<replacement>*/
  10929. var objectKeys = Object.keys || function (obj) {
  10930. var keys = [];
  10931. for (var key in obj) {
  10932. keys.push(key);
  10933. }return keys;
  10934. };
  10935. /*</replacement>*/
  10936. module.exports = Duplex;
  10937. /*<replacement>*/
  10938. var util = require('core-util-is');
  10939. util.inherits = require('inherits');
  10940. /*</replacement>*/
  10941. var Readable = require('./_stream_readable');
  10942. var Writable = require('./_stream_writable');
  10943. util.inherits(Duplex, Readable);
  10944. {
  10945. // avoid scope creep, the keys array can then be collected
  10946. var keys = objectKeys(Writable.prototype);
  10947. for (var v = 0; v < keys.length; v++) {
  10948. var method = keys[v];
  10949. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  10950. }
  10951. }
  10952. function Duplex(options) {
  10953. if (!(this instanceof Duplex)) return new Duplex(options);
  10954. Readable.call(this, options);
  10955. Writable.call(this, options);
  10956. if (options && options.readable === false) this.readable = false;
  10957. if (options && options.writable === false) this.writable = false;
  10958. this.allowHalfOpen = true;
  10959. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  10960. this.once('end', onend);
  10961. }
  10962. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  10963. // making it explicit this property is not enumerable
  10964. // because otherwise some prototype manipulation in
  10965. // userland will fail
  10966. enumerable: false,
  10967. get: function () {
  10968. return this._writableState.highWaterMark;
  10969. }
  10970. });
  10971. // the no-half-open enforcer
  10972. function onend() {
  10973. // if we allow half-open state, or if the writable side ended,
  10974. // then we're ok.
  10975. if (this.allowHalfOpen || this._writableState.ended) return;
  10976. // no more data can be written.
  10977. // But allow more writes to happen in this tick.
  10978. pna.nextTick(onEndNT, this);
  10979. }
  10980. function onEndNT(self) {
  10981. self.end();
  10982. }
  10983. Object.defineProperty(Duplex.prototype, 'destroyed', {
  10984. get: function () {
  10985. if (this._readableState === undefined || this._writableState === undefined) {
  10986. return false;
  10987. }
  10988. return this._readableState.destroyed && this._writableState.destroyed;
  10989. },
  10990. set: function (value) {
  10991. // we ignore the value if the stream
  10992. // has not been initialized yet
  10993. if (this._readableState === undefined || this._writableState === undefined) {
  10994. return;
  10995. }
  10996. // backward compatibility, the user is explicitly
  10997. // managing destroyed
  10998. this._readableState.destroyed = value;
  10999. this._writableState.destroyed = value;
  11000. }
  11001. });
  11002. Duplex.prototype._destroy = function (err, cb) {
  11003. this.push(null);
  11004. this.end();
  11005. pna.nextTick(cb, err);
  11006. };
  11007. },{"./_stream_readable":60,"./_stream_writable":62,"core-util-is":42,"inherits":50,"process-nextick-args":55}],59:[function(require,module,exports){
  11008. // Copyright Joyent, Inc. and other Node contributors.
  11009. //
  11010. // Permission is hereby granted, free of charge, to any person obtaining a
  11011. // copy of this software and associated documentation files (the
  11012. // "Software"), to deal in the Software without restriction, including
  11013. // without limitation the rights to use, copy, modify, merge, publish,
  11014. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11015. // persons to whom the Software is furnished to do so, subject to the
  11016. // following conditions:
  11017. //
  11018. // The above copyright notice and this permission notice shall be included
  11019. // in all copies or substantial portions of the Software.
  11020. //
  11021. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11022. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11023. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11024. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11025. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11026. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11027. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11028. // a passthrough stream.
  11029. // basically just the most minimal sort of Transform stream.
  11030. // Every written chunk gets output as-is.
  11031. 'use strict';
  11032. module.exports = PassThrough;
  11033. var Transform = require('./_stream_transform');
  11034. /*<replacement>*/
  11035. var util = require('core-util-is');
  11036. util.inherits = require('inherits');
  11037. /*</replacement>*/
  11038. util.inherits(PassThrough, Transform);
  11039. function PassThrough(options) {
  11040. if (!(this instanceof PassThrough)) return new PassThrough(options);
  11041. Transform.call(this, options);
  11042. }
  11043. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  11044. cb(null, chunk);
  11045. };
  11046. },{"./_stream_transform":61,"core-util-is":42,"inherits":50}],60:[function(require,module,exports){
  11047. (function (process,global){
  11048. // Copyright Joyent, Inc. and other Node contributors.
  11049. //
  11050. // Permission is hereby granted, free of charge, to any person obtaining a
  11051. // copy of this software and associated documentation files (the
  11052. // "Software"), to deal in the Software without restriction, including
  11053. // without limitation the rights to use, copy, modify, merge, publish,
  11054. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11055. // persons to whom the Software is furnished to do so, subject to the
  11056. // following conditions:
  11057. //
  11058. // The above copyright notice and this permission notice shall be included
  11059. // in all copies or substantial portions of the Software.
  11060. //
  11061. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11062. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11063. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11064. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11065. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11066. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11067. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11068. 'use strict';
  11069. /*<replacement>*/
  11070. var pna = require('process-nextick-args');
  11071. /*</replacement>*/
  11072. module.exports = Readable;
  11073. /*<replacement>*/
  11074. var isArray = require('isarray');
  11075. /*</replacement>*/
  11076. /*<replacement>*/
  11077. var Duplex;
  11078. /*</replacement>*/
  11079. Readable.ReadableState = ReadableState;
  11080. /*<replacement>*/
  11081. var EE = require('events').EventEmitter;
  11082. var EElistenerCount = function (emitter, type) {
  11083. return emitter.listeners(type).length;
  11084. };
  11085. /*</replacement>*/
  11086. /*<replacement>*/
  11087. var Stream = require('./internal/streams/stream');
  11088. /*</replacement>*/
  11089. /*<replacement>*/
  11090. var Buffer = require('safe-buffer').Buffer;
  11091. var OurUint8Array = global.Uint8Array || function () {};
  11092. function _uint8ArrayToBuffer(chunk) {
  11093. return Buffer.from(chunk);
  11094. }
  11095. function _isUint8Array(obj) {
  11096. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  11097. }
  11098. /*</replacement>*/
  11099. /*<replacement>*/
  11100. var util = require('core-util-is');
  11101. util.inherits = require('inherits');
  11102. /*</replacement>*/
  11103. /*<replacement>*/
  11104. var debugUtil = require('util');
  11105. var debug = void 0;
  11106. if (debugUtil && debugUtil.debuglog) {
  11107. debug = debugUtil.debuglog('stream');
  11108. } else {
  11109. debug = function () {};
  11110. }
  11111. /*</replacement>*/
  11112. var BufferList = require('./internal/streams/BufferList');
  11113. var destroyImpl = require('./internal/streams/destroy');
  11114. var StringDecoder;
  11115. util.inherits(Readable, Stream);
  11116. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  11117. function prependListener(emitter, event, fn) {
  11118. // Sadly this is not cacheable as some libraries bundle their own
  11119. // event emitter implementation with them.
  11120. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
  11121. // This is a hack to make sure that our error handler is attached before any
  11122. // userland ones. NEVER DO THIS. This is here only because this code needs
  11123. // to continue to work with older versions of Node.js that do not include
  11124. // the prependListener() method. The goal is to eventually remove this hack.
  11125. 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]];
  11126. }
  11127. function ReadableState(options, stream) {
  11128. Duplex = Duplex || require('./_stream_duplex');
  11129. options = options || {};
  11130. // Duplex streams are both readable and writable, but share
  11131. // the same options object.
  11132. // However, some cases require setting options to different
  11133. // values for the readable and the writable sides of the duplex stream.
  11134. // These options can be provided separately as readableXXX and writableXXX.
  11135. var isDuplex = stream instanceof Duplex;
  11136. // object stream flag. Used to make read(n) ignore n and to
  11137. // make all the buffer merging and length checks go away
  11138. this.objectMode = !!options.objectMode;
  11139. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  11140. // the point at which it stops calling _read() to fill the buffer
  11141. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  11142. var hwm = options.highWaterMark;
  11143. var readableHwm = options.readableHighWaterMark;
  11144. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  11145. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
  11146. // cast to ints.
  11147. this.highWaterMark = Math.floor(this.highWaterMark);
  11148. // A linked list is used to store data chunks instead of an array because the
  11149. // linked list can remove elements from the beginning faster than
  11150. // array.shift()
  11151. this.buffer = new BufferList();
  11152. this.length = 0;
  11153. this.pipes = null;
  11154. this.pipesCount = 0;
  11155. this.flowing = null;
  11156. this.ended = false;
  11157. this.endEmitted = false;
  11158. this.reading = false;
  11159. // a flag to be able to tell if the event 'readable'/'data' is emitted
  11160. // immediately, or on a later tick. We set this to true at first, because
  11161. // any actions that shouldn't happen until "later" should generally also
  11162. // not happen before the first read call.
  11163. this.sync = true;
  11164. // whenever we return null, then we set a flag to say
  11165. // that we're awaiting a 'readable' event emission.
  11166. this.needReadable = false;
  11167. this.emittedReadable = false;
  11168. this.readableListening = false;
  11169. this.resumeScheduled = false;
  11170. // has it been destroyed
  11171. this.destroyed = false;
  11172. // Crypto is kind of old and crusty. Historically, its default string
  11173. // encoding is 'binary' so we have to make this configurable.
  11174. // Everything else in the universe uses 'utf8', though.
  11175. this.defaultEncoding = options.defaultEncoding || 'utf8';
  11176. // the number of writers that are awaiting a drain event in .pipe()s
  11177. this.awaitDrain = 0;
  11178. // if true, a maybeReadMore has been scheduled
  11179. this.readingMore = false;
  11180. this.decoder = null;
  11181. this.encoding = null;
  11182. if (options.encoding) {
  11183. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  11184. this.decoder = new StringDecoder(options.encoding);
  11185. this.encoding = options.encoding;
  11186. }
  11187. }
  11188. function Readable(options) {
  11189. Duplex = Duplex || require('./_stream_duplex');
  11190. if (!(this instanceof Readable)) return new Readable(options);
  11191. this._readableState = new ReadableState(options, this);
  11192. // legacy
  11193. this.readable = true;
  11194. if (options) {
  11195. if (typeof options.read === 'function') this._read = options.read;
  11196. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  11197. }
  11198. Stream.call(this);
  11199. }
  11200. Object.defineProperty(Readable.prototype, 'destroyed', {
  11201. get: function () {
  11202. if (this._readableState === undefined) {
  11203. return false;
  11204. }
  11205. return this._readableState.destroyed;
  11206. },
  11207. set: function (value) {
  11208. // we ignore the value if the stream
  11209. // has not been initialized yet
  11210. if (!this._readableState) {
  11211. return;
  11212. }
  11213. // backward compatibility, the user is explicitly
  11214. // managing destroyed
  11215. this._readableState.destroyed = value;
  11216. }
  11217. });
  11218. Readable.prototype.destroy = destroyImpl.destroy;
  11219. Readable.prototype._undestroy = destroyImpl.undestroy;
  11220. Readable.prototype._destroy = function (err, cb) {
  11221. this.push(null);
  11222. cb(err);
  11223. };
  11224. // Manually shove something into the read() buffer.
  11225. // This returns true if the highWaterMark has not been hit yet,
  11226. // similar to how Writable.write() returns true if you should
  11227. // write() some more.
  11228. Readable.prototype.push = function (chunk, encoding) {
  11229. var state = this._readableState;
  11230. var skipChunkCheck;
  11231. if (!state.objectMode) {
  11232. if (typeof chunk === 'string') {
  11233. encoding = encoding || state.defaultEncoding;
  11234. if (encoding !== state.encoding) {
  11235. chunk = Buffer.from(chunk, encoding);
  11236. encoding = '';
  11237. }
  11238. skipChunkCheck = true;
  11239. }
  11240. } else {
  11241. skipChunkCheck = true;
  11242. }
  11243. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  11244. };
  11245. // Unshift should *always* be something directly out of read()
  11246. Readable.prototype.unshift = function (chunk) {
  11247. return readableAddChunk(this, chunk, null, true, false);
  11248. };
  11249. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  11250. var state = stream._readableState;
  11251. if (chunk === null) {
  11252. state.reading = false;
  11253. onEofChunk(stream, state);
  11254. } else {
  11255. var er;
  11256. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  11257. if (er) {
  11258. stream.emit('error', er);
  11259. } else if (state.objectMode || chunk && chunk.length > 0) {
  11260. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  11261. chunk = _uint8ArrayToBuffer(chunk);
  11262. }
  11263. if (addToFront) {
  11264. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
  11265. } else if (state.ended) {
  11266. stream.emit('error', new Error('stream.push() after EOF'));
  11267. } else {
  11268. state.reading = false;
  11269. if (state.decoder && !encoding) {
  11270. chunk = state.decoder.write(chunk);
  11271. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  11272. } else {
  11273. addChunk(stream, state, chunk, false);
  11274. }
  11275. }
  11276. } else if (!addToFront) {
  11277. state.reading = false;
  11278. }
  11279. }
  11280. return needMoreData(state);
  11281. }
  11282. function addChunk(stream, state, chunk, addToFront) {
  11283. if (state.flowing && state.length === 0 && !state.sync) {
  11284. stream.emit('data', chunk);
  11285. stream.read(0);
  11286. } else {
  11287. // update the buffer info.
  11288. state.length += state.objectMode ? 1 : chunk.length;
  11289. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  11290. if (state.needReadable) emitReadable(stream);
  11291. }
  11292. maybeReadMore(stream, state);
  11293. }
  11294. function chunkInvalid(state, chunk) {
  11295. var er;
  11296. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  11297. er = new TypeError('Invalid non-string/buffer chunk');
  11298. }
  11299. return er;
  11300. }
  11301. // if it's past the high water mark, we can push in some more.
  11302. // Also, if we have no data yet, we can stand some
  11303. // more bytes. This is to work around cases where hwm=0,
  11304. // such as the repl. Also, if the push() triggered a
  11305. // readable event, and the user called read(largeNumber) such that
  11306. // needReadable was set, then we ought to push more, so that another
  11307. // 'readable' event will be triggered.
  11308. function needMoreData(state) {
  11309. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  11310. }
  11311. Readable.prototype.isPaused = function () {
  11312. return this._readableState.flowing === false;
  11313. };
  11314. // backwards compatibility.
  11315. Readable.prototype.setEncoding = function (enc) {
  11316. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  11317. this._readableState.decoder = new StringDecoder(enc);
  11318. this._readableState.encoding = enc;
  11319. return this;
  11320. };
  11321. // Don't raise the hwm > 8MB
  11322. var MAX_HWM = 0x800000;
  11323. function computeNewHighWaterMark(n) {
  11324. if (n >= MAX_HWM) {
  11325. n = MAX_HWM;
  11326. } else {
  11327. // Get the next highest power of 2 to prevent increasing hwm excessively in
  11328. // tiny amounts
  11329. n--;
  11330. n |= n >>> 1;
  11331. n |= n >>> 2;
  11332. n |= n >>> 4;
  11333. n |= n >>> 8;
  11334. n |= n >>> 16;
  11335. n++;
  11336. }
  11337. return n;
  11338. }
  11339. // This function is designed to be inlinable, so please take care when making
  11340. // changes to the function body.
  11341. function howMuchToRead(n, state) {
  11342. if (n <= 0 || state.length === 0 && state.ended) return 0;
  11343. if (state.objectMode) return 1;
  11344. if (n !== n) {
  11345. // Only flow one buffer at a time
  11346. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  11347. }
  11348. // If we're asking for more than the current hwm, then raise the hwm.
  11349. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  11350. if (n <= state.length) return n;
  11351. // Don't have enough
  11352. if (!state.ended) {
  11353. state.needReadable = true;
  11354. return 0;
  11355. }
  11356. return state.length;
  11357. }
  11358. // you can override either this method, or the async _read(n) below.
  11359. Readable.prototype.read = function (n) {
  11360. debug('read', n);
  11361. n = parseInt(n, 10);
  11362. var state = this._readableState;
  11363. var nOrig = n;
  11364. if (n !== 0) state.emittedReadable = false;
  11365. // if we're doing read(0) to trigger a readable event, but we
  11366. // already have a bunch of data in the buffer, then just trigger
  11367. // the 'readable' event and move on.
  11368. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  11369. debug('read: emitReadable', state.length, state.ended);
  11370. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  11371. return null;
  11372. }
  11373. n = howMuchToRead(n, state);
  11374. // if we've ended, and we're now clear, then finish it up.
  11375. if (n === 0 && state.ended) {
  11376. if (state.length === 0) endReadable(this);
  11377. return null;
  11378. }
  11379. // All the actual chunk generation logic needs to be
  11380. // *below* the call to _read. The reason is that in certain
  11381. // synthetic stream cases, such as passthrough streams, _read
  11382. // may be a completely synchronous operation which may change
  11383. // the state of the read buffer, providing enough data when
  11384. // before there was *not* enough.
  11385. //
  11386. // So, the steps are:
  11387. // 1. Figure out what the state of things will be after we do
  11388. // a read from the buffer.
  11389. //
  11390. // 2. If that resulting state will trigger a _read, then call _read.
  11391. // Note that this may be asynchronous, or synchronous. Yes, it is
  11392. // deeply ugly to write APIs this way, but that still doesn't mean
  11393. // that the Readable class should behave improperly, as streams are
  11394. // designed to be sync/async agnostic.
  11395. // Take note if the _read call is sync or async (ie, if the read call
  11396. // has returned yet), so that we know whether or not it's safe to emit
  11397. // 'readable' etc.
  11398. //
  11399. // 3. Actually pull the requested chunks out of the buffer and return.
  11400. // if we need a readable event, then we need to do some reading.
  11401. var doRead = state.needReadable;
  11402. debug('need readable', doRead);
  11403. // if we currently have less than the highWaterMark, then also read some
  11404. if (state.length === 0 || state.length - n < state.highWaterMark) {
  11405. doRead = true;
  11406. debug('length less than watermark', doRead);
  11407. }
  11408. // however, if we've ended, then there's no point, and if we're already
  11409. // reading, then it's unnecessary.
  11410. if (state.ended || state.reading) {
  11411. doRead = false;
  11412. debug('reading or ended', doRead);
  11413. } else if (doRead) {
  11414. debug('do read');
  11415. state.reading = true;
  11416. state.sync = true;
  11417. // if the length is currently zero, then we *need* a readable event.
  11418. if (state.length === 0) state.needReadable = true;
  11419. // call internal read method
  11420. this._read(state.highWaterMark);
  11421. state.sync = false;
  11422. // If _read pushed data synchronously, then `reading` will be false,
  11423. // and we need to re-evaluate how much data we can return to the user.
  11424. if (!state.reading) n = howMuchToRead(nOrig, state);
  11425. }
  11426. var ret;
  11427. if (n > 0) ret = fromList(n, state);else ret = null;
  11428. if (ret === null) {
  11429. state.needReadable = true;
  11430. n = 0;
  11431. } else {
  11432. state.length -= n;
  11433. }
  11434. if (state.length === 0) {
  11435. // If we have nothing in the buffer, then we want to know
  11436. // as soon as we *do* get something into the buffer.
  11437. if (!state.ended) state.needReadable = true;
  11438. // If we tried to read() past the EOF, then emit end on the next tick.
  11439. if (nOrig !== n && state.ended) endReadable(this);
  11440. }
  11441. if (ret !== null) this.emit('data', ret);
  11442. return ret;
  11443. };
  11444. function onEofChunk(stream, state) {
  11445. if (state.ended) return;
  11446. if (state.decoder) {
  11447. var chunk = state.decoder.end();
  11448. if (chunk && chunk.length) {
  11449. state.buffer.push(chunk);
  11450. state.length += state.objectMode ? 1 : chunk.length;
  11451. }
  11452. }
  11453. state.ended = true;
  11454. // emit 'readable' now to make sure it gets picked up.
  11455. emitReadable(stream);
  11456. }
  11457. // Don't emit readable right away in sync mode, because this can trigger
  11458. // another read() call => stack overflow. This way, it might trigger
  11459. // a nextTick recursion warning, but that's not so bad.
  11460. function emitReadable(stream) {
  11461. var state = stream._readableState;
  11462. state.needReadable = false;
  11463. if (!state.emittedReadable) {
  11464. debug('emitReadable', state.flowing);
  11465. state.emittedReadable = true;
  11466. if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
  11467. }
  11468. }
  11469. function emitReadable_(stream) {
  11470. debug('emit readable');
  11471. stream.emit('readable');
  11472. flow(stream);
  11473. }
  11474. // at this point, the user has presumably seen the 'readable' event,
  11475. // and called read() to consume some data. that may have triggered
  11476. // in turn another _read(n) call, in which case reading = true if
  11477. // it's in progress.
  11478. // However, if we're not ended, or reading, and the length < hwm,
  11479. // then go ahead and try to read some more preemptively.
  11480. function maybeReadMore(stream, state) {
  11481. if (!state.readingMore) {
  11482. state.readingMore = true;
  11483. pna.nextTick(maybeReadMore_, stream, state);
  11484. }
  11485. }
  11486. function maybeReadMore_(stream, state) {
  11487. var len = state.length;
  11488. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  11489. debug('maybeReadMore read 0');
  11490. stream.read(0);
  11491. if (len === state.length)
  11492. // didn't get any data, stop spinning.
  11493. break;else len = state.length;
  11494. }
  11495. state.readingMore = false;
  11496. }
  11497. // abstract method. to be overridden in specific implementation classes.
  11498. // call cb(er, data) where data is <= n in length.
  11499. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  11500. // arbitrary, and perhaps not very meaningful.
  11501. Readable.prototype._read = function (n) {
  11502. this.emit('error', new Error('_read() is not implemented'));
  11503. };
  11504. Readable.prototype.pipe = function (dest, pipeOpts) {
  11505. var src = this;
  11506. var state = this._readableState;
  11507. switch (state.pipesCount) {
  11508. case 0:
  11509. state.pipes = dest;
  11510. break;
  11511. case 1:
  11512. state.pipes = [state.pipes, dest];
  11513. break;
  11514. default:
  11515. state.pipes.push(dest);
  11516. break;
  11517. }
  11518. state.pipesCount += 1;
  11519. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  11520. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  11521. var endFn = doEnd ? onend : unpipe;
  11522. if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
  11523. dest.on('unpipe', onunpipe);
  11524. function onunpipe(readable, unpipeInfo) {
  11525. debug('onunpipe');
  11526. if (readable === src) {
  11527. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  11528. unpipeInfo.hasUnpiped = true;
  11529. cleanup();
  11530. }
  11531. }
  11532. }
  11533. function onend() {
  11534. debug('onend');
  11535. dest.end();
  11536. }
  11537. // when the dest drains, it reduces the awaitDrain counter
  11538. // on the source. This would be more elegant with a .once()
  11539. // handler in flow(), but adding and removing repeatedly is
  11540. // too slow.
  11541. var ondrain = pipeOnDrain(src);
  11542. dest.on('drain', ondrain);
  11543. var cleanedUp = false;
  11544. function cleanup() {
  11545. debug('cleanup');
  11546. // cleanup event handlers once the pipe is broken
  11547. dest.removeListener('close', onclose);
  11548. dest.removeListener('finish', onfinish);
  11549. dest.removeListener('drain', ondrain);
  11550. dest.removeListener('error', onerror);
  11551. dest.removeListener('unpipe', onunpipe);
  11552. src.removeListener('end', onend);
  11553. src.removeListener('end', unpipe);
  11554. src.removeListener('data', ondata);
  11555. cleanedUp = true;
  11556. // if the reader is waiting for a drain event from this
  11557. // specific writer, then it would cause it to never start
  11558. // flowing again.
  11559. // So, if this is awaiting a drain, then we just call it now.
  11560. // If we don't know, then assume that we are waiting for one.
  11561. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  11562. }
  11563. // If the user pushes more data while we're writing to dest then we'll end up
  11564. // in ondata again. However, we only want to increase awaitDrain once because
  11565. // dest will only emit one 'drain' event for the multiple writes.
  11566. // => Introduce a guard on increasing awaitDrain.
  11567. var increasedAwaitDrain = false;
  11568. src.on('data', ondata);
  11569. function ondata(chunk) {
  11570. debug('ondata');
  11571. increasedAwaitDrain = false;
  11572. var ret = dest.write(chunk);
  11573. if (false === ret && !increasedAwaitDrain) {
  11574. // If the user unpiped during `dest.write()`, it is possible
  11575. // to get stuck in a permanently paused state if that write
  11576. // also returned false.
  11577. // => Check whether `dest` is still a piping destination.
  11578. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  11579. debug('false write response, pause', src._readableState.awaitDrain);
  11580. src._readableState.awaitDrain++;
  11581. increasedAwaitDrain = true;
  11582. }
  11583. src.pause();
  11584. }
  11585. }
  11586. // if the dest has an error, then stop piping into it.
  11587. // however, don't suppress the throwing behavior for this.
  11588. function onerror(er) {
  11589. debug('onerror', er);
  11590. unpipe();
  11591. dest.removeListener('error', onerror);
  11592. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  11593. }
  11594. // Make sure our error handler is attached before userland ones.
  11595. prependListener(dest, 'error', onerror);
  11596. // Both close and finish should trigger unpipe, but only once.
  11597. function onclose() {
  11598. dest.removeListener('finish', onfinish);
  11599. unpipe();
  11600. }
  11601. dest.once('close', onclose);
  11602. function onfinish() {
  11603. debug('onfinish');
  11604. dest.removeListener('close', onclose);
  11605. unpipe();
  11606. }
  11607. dest.once('finish', onfinish);
  11608. function unpipe() {
  11609. debug('unpipe');
  11610. src.unpipe(dest);
  11611. }
  11612. // tell the dest that it's being piped to
  11613. dest.emit('pipe', src);
  11614. // start the flow if it hasn't been started already.
  11615. if (!state.flowing) {
  11616. debug('pipe resume');
  11617. src.resume();
  11618. }
  11619. return dest;
  11620. };
  11621. function pipeOnDrain(src) {
  11622. return function () {
  11623. var state = src._readableState;
  11624. debug('pipeOnDrain', state.awaitDrain);
  11625. if (state.awaitDrain) state.awaitDrain--;
  11626. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  11627. state.flowing = true;
  11628. flow(src);
  11629. }
  11630. };
  11631. }
  11632. Readable.prototype.unpipe = function (dest) {
  11633. var state = this._readableState;
  11634. var unpipeInfo = { hasUnpiped: false };
  11635. // if we're not piping anywhere, then do nothing.
  11636. if (state.pipesCount === 0) return this;
  11637. // just one destination. most common case.
  11638. if (state.pipesCount === 1) {
  11639. // passed in one, but it's not the right one.
  11640. if (dest && dest !== state.pipes) return this;
  11641. if (!dest) dest = state.pipes;
  11642. // got a match.
  11643. state.pipes = null;
  11644. state.pipesCount = 0;
  11645. state.flowing = false;
  11646. if (dest) dest.emit('unpipe', this, unpipeInfo);
  11647. return this;
  11648. }
  11649. // slow case. multiple pipe destinations.
  11650. if (!dest) {
  11651. // remove all.
  11652. var dests = state.pipes;
  11653. var len = state.pipesCount;
  11654. state.pipes = null;
  11655. state.pipesCount = 0;
  11656. state.flowing = false;
  11657. for (var i = 0; i < len; i++) {
  11658. dests[i].emit('unpipe', this, unpipeInfo);
  11659. }return this;
  11660. }
  11661. // try to find the right one.
  11662. var index = indexOf(state.pipes, dest);
  11663. if (index === -1) return this;
  11664. state.pipes.splice(index, 1);
  11665. state.pipesCount -= 1;
  11666. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  11667. dest.emit('unpipe', this, unpipeInfo);
  11668. return this;
  11669. };
  11670. // set up data events if they are asked for
  11671. // Ensure readable listeners eventually get something
  11672. Readable.prototype.on = function (ev, fn) {
  11673. var res = Stream.prototype.on.call(this, ev, fn);
  11674. if (ev === 'data') {
  11675. // Start flowing on next tick if stream isn't explicitly paused
  11676. if (this._readableState.flowing !== false) this.resume();
  11677. } else if (ev === 'readable') {
  11678. var state = this._readableState;
  11679. if (!state.endEmitted && !state.readableListening) {
  11680. state.readableListening = state.needReadable = true;
  11681. state.emittedReadable = false;
  11682. if (!state.reading) {
  11683. pna.nextTick(nReadingNextTick, this);
  11684. } else if (state.length) {
  11685. emitReadable(this);
  11686. }
  11687. }
  11688. }
  11689. return res;
  11690. };
  11691. Readable.prototype.addListener = Readable.prototype.on;
  11692. function nReadingNextTick(self) {
  11693. debug('readable nexttick read 0');
  11694. self.read(0);
  11695. }
  11696. // pause() and resume() are remnants of the legacy readable stream API
  11697. // If the user uses them, then switch into old mode.
  11698. Readable.prototype.resume = function () {
  11699. var state = this._readableState;
  11700. if (!state.flowing) {
  11701. debug('resume');
  11702. state.flowing = true;
  11703. resume(this, state);
  11704. }
  11705. return this;
  11706. };
  11707. function resume(stream, state) {
  11708. if (!state.resumeScheduled) {
  11709. state.resumeScheduled = true;
  11710. pna.nextTick(resume_, stream, state);
  11711. }
  11712. }
  11713. function resume_(stream, state) {
  11714. if (!state.reading) {
  11715. debug('resume read 0');
  11716. stream.read(0);
  11717. }
  11718. state.resumeScheduled = false;
  11719. state.awaitDrain = 0;
  11720. stream.emit('resume');
  11721. flow(stream);
  11722. if (state.flowing && !state.reading) stream.read(0);
  11723. }
  11724. Readable.prototype.pause = function () {
  11725. debug('call pause flowing=%j', this._readableState.flowing);
  11726. if (false !== this._readableState.flowing) {
  11727. debug('pause');
  11728. this._readableState.flowing = false;
  11729. this.emit('pause');
  11730. }
  11731. return this;
  11732. };
  11733. function flow(stream) {
  11734. var state = stream._readableState;
  11735. debug('flow', state.flowing);
  11736. while (state.flowing && stream.read() !== null) {}
  11737. }
  11738. // wrap an old-style stream as the async data source.
  11739. // This is *not* part of the readable stream interface.
  11740. // It is an ugly unfortunate mess of history.
  11741. Readable.prototype.wrap = function (stream) {
  11742. var _this = this;
  11743. var state = this._readableState;
  11744. var paused = false;
  11745. stream.on('end', function () {
  11746. debug('wrapped end');
  11747. if (state.decoder && !state.ended) {
  11748. var chunk = state.decoder.end();
  11749. if (chunk && chunk.length) _this.push(chunk);
  11750. }
  11751. _this.push(null);
  11752. });
  11753. stream.on('data', function (chunk) {
  11754. debug('wrapped data');
  11755. if (state.decoder) chunk = state.decoder.write(chunk);
  11756. // don't skip over falsy values in objectMode
  11757. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  11758. var ret = _this.push(chunk);
  11759. if (!ret) {
  11760. paused = true;
  11761. stream.pause();
  11762. }
  11763. });
  11764. // proxy all the other methods.
  11765. // important when wrapping filters and duplexes.
  11766. for (var i in stream) {
  11767. if (this[i] === undefined && typeof stream[i] === 'function') {
  11768. this[i] = function (method) {
  11769. return function () {
  11770. return stream[method].apply(stream, arguments);
  11771. };
  11772. }(i);
  11773. }
  11774. }
  11775. // proxy certain important events.
  11776. for (var n = 0; n < kProxyEvents.length; n++) {
  11777. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  11778. }
  11779. // when we try to consume some more bytes, simply unpause the
  11780. // underlying stream.
  11781. this._read = function (n) {
  11782. debug('wrapped _read', n);
  11783. if (paused) {
  11784. paused = false;
  11785. stream.resume();
  11786. }
  11787. };
  11788. return this;
  11789. };
  11790. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  11791. // making it explicit this property is not enumerable
  11792. // because otherwise some prototype manipulation in
  11793. // userland will fail
  11794. enumerable: false,
  11795. get: function () {
  11796. return this._readableState.highWaterMark;
  11797. }
  11798. });
  11799. // exposed for testing purposes only.
  11800. Readable._fromList = fromList;
  11801. // Pluck off n bytes from an array of buffers.
  11802. // Length is the combined lengths of all the buffers in the list.
  11803. // This function is designed to be inlinable, so please take care when making
  11804. // changes to the function body.
  11805. function fromList(n, state) {
  11806. // nothing buffered
  11807. if (state.length === 0) return null;
  11808. var ret;
  11809. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  11810. // read it all, truncate the list
  11811. 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);
  11812. state.buffer.clear();
  11813. } else {
  11814. // read part of list
  11815. ret = fromListPartial(n, state.buffer, state.decoder);
  11816. }
  11817. return ret;
  11818. }
  11819. // Extracts only enough buffered data to satisfy the amount requested.
  11820. // This function is designed to be inlinable, so please take care when making
  11821. // changes to the function body.
  11822. function fromListPartial(n, list, hasStrings) {
  11823. var ret;
  11824. if (n < list.head.data.length) {
  11825. // slice is the same for buffers and strings
  11826. ret = list.head.data.slice(0, n);
  11827. list.head.data = list.head.data.slice(n);
  11828. } else if (n === list.head.data.length) {
  11829. // first chunk is a perfect match
  11830. ret = list.shift();
  11831. } else {
  11832. // result spans more than one buffer
  11833. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  11834. }
  11835. return ret;
  11836. }
  11837. // Copies a specified amount of characters from the list of buffered data
  11838. // chunks.
  11839. // This function is designed to be inlinable, so please take care when making
  11840. // changes to the function body.
  11841. function copyFromBufferString(n, list) {
  11842. var p = list.head;
  11843. var c = 1;
  11844. var ret = p.data;
  11845. n -= ret.length;
  11846. while (p = p.next) {
  11847. var str = p.data;
  11848. var nb = n > str.length ? str.length : n;
  11849. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  11850. n -= nb;
  11851. if (n === 0) {
  11852. if (nb === str.length) {
  11853. ++c;
  11854. if (p.next) list.head = p.next;else list.head = list.tail = null;
  11855. } else {
  11856. list.head = p;
  11857. p.data = str.slice(nb);
  11858. }
  11859. break;
  11860. }
  11861. ++c;
  11862. }
  11863. list.length -= c;
  11864. return ret;
  11865. }
  11866. // Copies a specified amount of bytes from the list of buffered data chunks.
  11867. // This function is designed to be inlinable, so please take care when making
  11868. // changes to the function body.
  11869. function copyFromBuffer(n, list) {
  11870. var ret = Buffer.allocUnsafe(n);
  11871. var p = list.head;
  11872. var c = 1;
  11873. p.data.copy(ret);
  11874. n -= p.data.length;
  11875. while (p = p.next) {
  11876. var buf = p.data;
  11877. var nb = n > buf.length ? buf.length : n;
  11878. buf.copy(ret, ret.length - n, 0, nb);
  11879. n -= nb;
  11880. if (n === 0) {
  11881. if (nb === buf.length) {
  11882. ++c;
  11883. if (p.next) list.head = p.next;else list.head = list.tail = null;
  11884. } else {
  11885. list.head = p;
  11886. p.data = buf.slice(nb);
  11887. }
  11888. break;
  11889. }
  11890. ++c;
  11891. }
  11892. list.length -= c;
  11893. return ret;
  11894. }
  11895. function endReadable(stream) {
  11896. var state = stream._readableState;
  11897. // If we get here before consuming all the bytes, then that is a
  11898. // bug in node. Should never happen.
  11899. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  11900. if (!state.endEmitted) {
  11901. state.ended = true;
  11902. pna.nextTick(endReadableNT, state, stream);
  11903. }
  11904. }
  11905. function endReadableNT(state, stream) {
  11906. // Check that we didn't get one last unshift.
  11907. if (!state.endEmitted && state.length === 0) {
  11908. state.endEmitted = true;
  11909. stream.readable = false;
  11910. stream.emit('end');
  11911. }
  11912. }
  11913. function indexOf(xs, x) {
  11914. for (var i = 0, l = xs.length; i < l; i++) {
  11915. if (xs[i] === x) return i;
  11916. }
  11917. return -1;
  11918. }
  11919. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  11920. },{"./_stream_duplex":58,"./internal/streams/BufferList":63,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":56,"core-util-is":42,"events":47,"inherits":50,"isarray":52,"process-nextick-args":55,"safe-buffer":70,"string_decoder/":72,"util":38}],61:[function(require,module,exports){
  11921. // Copyright Joyent, Inc. and other Node contributors.
  11922. //
  11923. // Permission is hereby granted, free of charge, to any person obtaining a
  11924. // copy of this software and associated documentation files (the
  11925. // "Software"), to deal in the Software without restriction, including
  11926. // without limitation the rights to use, copy, modify, merge, publish,
  11927. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11928. // persons to whom the Software is furnished to do so, subject to the
  11929. // following conditions:
  11930. //
  11931. // The above copyright notice and this permission notice shall be included
  11932. // in all copies or substantial portions of the Software.
  11933. //
  11934. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11935. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11936. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11937. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11938. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11939. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11940. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11941. // a transform stream is a readable/writable stream where you do
  11942. // something with the data. Sometimes it's called a "filter",
  11943. // but that's not a great name for it, since that implies a thing where
  11944. // some bits pass through, and others are simply ignored. (That would
  11945. // be a valid example of a transform, of course.)
  11946. //
  11947. // While the output is causally related to the input, it's not a
  11948. // necessarily symmetric or synchronous transformation. For example,
  11949. // a zlib stream might take multiple plain-text writes(), and then
  11950. // emit a single compressed chunk some time in the future.
  11951. //
  11952. // Here's how this works:
  11953. //
  11954. // The Transform stream has all the aspects of the readable and writable
  11955. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  11956. // internally, and returns false if there's a lot of pending writes
  11957. // buffered up. When you call read(), that calls _read(n) until
  11958. // there's enough pending readable data buffered up.
  11959. //
  11960. // In a transform stream, the written data is placed in a buffer. When
  11961. // _read(n) is called, it transforms the queued up data, calling the
  11962. // buffered _write cb's as it consumes chunks. If consuming a single
  11963. // written chunk would result in multiple output chunks, then the first
  11964. // outputted bit calls the readcb, and subsequent chunks just go into
  11965. // the read buffer, and will cause it to emit 'readable' if necessary.
  11966. //
  11967. // This way, back-pressure is actually determined by the reading side,
  11968. // since _read has to be called to start processing a new chunk. However,
  11969. // a pathological inflate type of transform can cause excessive buffering
  11970. // here. For example, imagine a stream where every byte of input is
  11971. // interpreted as an integer from 0-255, and then results in that many
  11972. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  11973. // 1kb of data being output. In this case, you could write a very small
  11974. // amount of input, and end up with a very large amount of output. In
  11975. // such a pathological inflating mechanism, there'd be no way to tell
  11976. // the system to stop doing the transform. A single 4MB write could
  11977. // cause the system to run out of memory.
  11978. //
  11979. // However, even in such a pathological case, only a single written chunk
  11980. // would be consumed, and then the rest would wait (un-transformed) until
  11981. // the results of the previous transformed chunk were consumed.
  11982. 'use strict';
  11983. module.exports = Transform;
  11984. var Duplex = require('./_stream_duplex');
  11985. /*<replacement>*/
  11986. var util = require('core-util-is');
  11987. util.inherits = require('inherits');
  11988. /*</replacement>*/
  11989. util.inherits(Transform, Duplex);
  11990. function afterTransform(er, data) {
  11991. var ts = this._transformState;
  11992. ts.transforming = false;
  11993. var cb = ts.writecb;
  11994. if (!cb) {
  11995. return this.emit('error', new Error('write callback called multiple times'));
  11996. }
  11997. ts.writechunk = null;
  11998. ts.writecb = null;
  11999. if (data != null) // single equals check for both `null` and `undefined`
  12000. this.push(data);
  12001. cb(er);
  12002. var rs = this._readableState;
  12003. rs.reading = false;
  12004. if (rs.needReadable || rs.length < rs.highWaterMark) {
  12005. this._read(rs.highWaterMark);
  12006. }
  12007. }
  12008. function Transform(options) {
  12009. if (!(this instanceof Transform)) return new Transform(options);
  12010. Duplex.call(this, options);
  12011. this._transformState = {
  12012. afterTransform: afterTransform.bind(this),
  12013. needTransform: false,
  12014. transforming: false,
  12015. writecb: null,
  12016. writechunk: null,
  12017. writeencoding: null
  12018. };
  12019. // start out asking for a readable event once data is transformed.
  12020. this._readableState.needReadable = true;
  12021. // we have implemented the _read method, and done the other things
  12022. // that Readable wants before the first _read call, so unset the
  12023. // sync guard flag.
  12024. this._readableState.sync = false;
  12025. if (options) {
  12026. if (typeof options.transform === 'function') this._transform = options.transform;
  12027. if (typeof options.flush === 'function') this._flush = options.flush;
  12028. }
  12029. // When the writable side finishes, then flush out anything remaining.
  12030. this.on('prefinish', prefinish);
  12031. }
  12032. function prefinish() {
  12033. var _this = this;
  12034. if (typeof this._flush === 'function') {
  12035. this._flush(function (er, data) {
  12036. done(_this, er, data);
  12037. });
  12038. } else {
  12039. done(this, null, null);
  12040. }
  12041. }
  12042. Transform.prototype.push = function (chunk, encoding) {
  12043. this._transformState.needTransform = false;
  12044. return Duplex.prototype.push.call(this, chunk, encoding);
  12045. };
  12046. // This is the part where you do stuff!
  12047. // override this function in implementation classes.
  12048. // 'chunk' is an input chunk.
  12049. //
  12050. // Call `push(newChunk)` to pass along transformed output
  12051. // to the readable side. You may call 'push' zero or more times.
  12052. //
  12053. // Call `cb(err)` when you are done with this chunk. If you pass
  12054. // an error, then that'll put the hurt on the whole operation. If you
  12055. // never call cb(), then you'll never get another chunk.
  12056. Transform.prototype._transform = function (chunk, encoding, cb) {
  12057. throw new Error('_transform() is not implemented');
  12058. };
  12059. Transform.prototype._write = function (chunk, encoding, cb) {
  12060. var ts = this._transformState;
  12061. ts.writecb = cb;
  12062. ts.writechunk = chunk;
  12063. ts.writeencoding = encoding;
  12064. if (!ts.transforming) {
  12065. var rs = this._readableState;
  12066. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  12067. }
  12068. };
  12069. // Doesn't matter what the args are here.
  12070. // _transform does all the work.
  12071. // That we got here means that the readable side wants more data.
  12072. Transform.prototype._read = function (n) {
  12073. var ts = this._transformState;
  12074. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  12075. ts.transforming = true;
  12076. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  12077. } else {
  12078. // mark that we need a transform, so that any data that comes in
  12079. // will get processed, now that we've asked for it.
  12080. ts.needTransform = true;
  12081. }
  12082. };
  12083. Transform.prototype._destroy = function (err, cb) {
  12084. var _this2 = this;
  12085. Duplex.prototype._destroy.call(this, err, function (err2) {
  12086. cb(err2);
  12087. _this2.emit('close');
  12088. });
  12089. };
  12090. function done(stream, er, data) {
  12091. if (er) return stream.emit('error', er);
  12092. if (data != null) // single equals check for both `null` and `undefined`
  12093. stream.push(data);
  12094. // if there's nothing in the write buffer, then that means
  12095. // that nothing more will ever be provided
  12096. if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
  12097. if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
  12098. return stream.push(null);
  12099. }
  12100. },{"./_stream_duplex":58,"core-util-is":42,"inherits":50}],62:[function(require,module,exports){
  12101. (function (process,global){
  12102. // Copyright Joyent, Inc. and other Node contributors.
  12103. //
  12104. // Permission is hereby granted, free of charge, to any person obtaining a
  12105. // copy of this software and associated documentation files (the
  12106. // "Software"), to deal in the Software without restriction, including
  12107. // without limitation the rights to use, copy, modify, merge, publish,
  12108. // distribute, sublicense, and/or sell copies of the Software, and to permit
  12109. // persons to whom the Software is furnished to do so, subject to the
  12110. // following conditions:
  12111. //
  12112. // The above copyright notice and this permission notice shall be included
  12113. // in all copies or substantial portions of the Software.
  12114. //
  12115. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  12116. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  12117. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  12118. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  12119. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  12120. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  12121. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  12122. // A bit simpler than readable streams.
  12123. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  12124. // the drain event emission and buffering.
  12125. 'use strict';
  12126. /*<replacement>*/
  12127. var pna = require('process-nextick-args');
  12128. /*</replacement>*/
  12129. module.exports = Writable;
  12130. /* <replacement> */
  12131. function WriteReq(chunk, encoding, cb) {
  12132. this.chunk = chunk;
  12133. this.encoding = encoding;
  12134. this.callback = cb;
  12135. this.next = null;
  12136. }
  12137. // It seems a linked list but it is not
  12138. // there will be only 2 of these for each stream
  12139. function CorkedRequest(state) {
  12140. var _this = this;
  12141. this.next = null;
  12142. this.entry = null;
  12143. this.finish = function () {
  12144. onCorkedFinish(_this, state);
  12145. };
  12146. }
  12147. /* </replacement> */
  12148. /*<replacement>*/
  12149. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
  12150. /*</replacement>*/
  12151. /*<replacement>*/
  12152. var Duplex;
  12153. /*</replacement>*/
  12154. Writable.WritableState = WritableState;
  12155. /*<replacement>*/
  12156. var util = require('core-util-is');
  12157. util.inherits = require('inherits');
  12158. /*</replacement>*/
  12159. /*<replacement>*/
  12160. var internalUtil = {
  12161. deprecate: require('util-deprecate')
  12162. };
  12163. /*</replacement>*/
  12164. /*<replacement>*/
  12165. var Stream = require('./internal/streams/stream');
  12166. /*</replacement>*/
  12167. /*<replacement>*/
  12168. var Buffer = require('safe-buffer').Buffer;
  12169. var OurUint8Array = global.Uint8Array || function () {};
  12170. function _uint8ArrayToBuffer(chunk) {
  12171. return Buffer.from(chunk);
  12172. }
  12173. function _isUint8Array(obj) {
  12174. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  12175. }
  12176. /*</replacement>*/
  12177. var destroyImpl = require('./internal/streams/destroy');
  12178. util.inherits(Writable, Stream);
  12179. function nop() {}
  12180. function WritableState(options, stream) {
  12181. Duplex = Duplex || require('./_stream_duplex');
  12182. options = options || {};
  12183. // Duplex streams are both readable and writable, but share
  12184. // the same options object.
  12185. // However, some cases require setting options to different
  12186. // values for the readable and the writable sides of the duplex stream.
  12187. // These options can be provided separately as readableXXX and writableXXX.
  12188. var isDuplex = stream instanceof Duplex;
  12189. // object stream flag to indicate whether or not this stream
  12190. // contains buffers or objects.
  12191. this.objectMode = !!options.objectMode;
  12192. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  12193. // the point at which write() starts returning false
  12194. // Note: 0 is a valid value, means that we always return false if
  12195. // the entire buffer is not flushed immediately on write()
  12196. var hwm = options.highWaterMark;
  12197. var writableHwm = options.writableHighWaterMark;
  12198. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  12199. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
  12200. // cast to ints.
  12201. this.highWaterMark = Math.floor(this.highWaterMark);
  12202. // if _final has been called
  12203. this.finalCalled = false;
  12204. // drain event flag.
  12205. this.needDrain = false;
  12206. // at the start of calling end()
  12207. this.ending = false;
  12208. // when end() has been called, and returned
  12209. this.ended = false;
  12210. // when 'finish' is emitted
  12211. this.finished = false;
  12212. // has it been destroyed
  12213. this.destroyed = false;
  12214. // should we decode strings into buffers before passing to _write?
  12215. // this is here so that some node-core streams can optimize string
  12216. // handling at a lower level.
  12217. var noDecode = options.decodeStrings === false;
  12218. this.decodeStrings = !noDecode;
  12219. // Crypto is kind of old and crusty. Historically, its default string
  12220. // encoding is 'binary' so we have to make this configurable.
  12221. // Everything else in the universe uses 'utf8', though.
  12222. this.defaultEncoding = options.defaultEncoding || 'utf8';
  12223. // not an actual buffer we keep track of, but a measurement
  12224. // of how much we're waiting to get pushed to some underlying
  12225. // socket or file.
  12226. this.length = 0;
  12227. // a flag to see when we're in the middle of a write.
  12228. this.writing = false;
  12229. // when true all writes will be buffered until .uncork() call
  12230. this.corked = 0;
  12231. // a flag to be able to tell if the onwrite cb is called immediately,
  12232. // or on a later tick. We set this to true at first, because any
  12233. // actions that shouldn't happen until "later" should generally also
  12234. // not happen before the first write call.
  12235. this.sync = true;
  12236. // a flag to know if we're processing previously buffered items, which
  12237. // may call the _write() callback in the same tick, so that we don't
  12238. // end up in an overlapped onwrite situation.
  12239. this.bufferProcessing = false;
  12240. // the callback that's passed to _write(chunk,cb)
  12241. this.onwrite = function (er) {
  12242. onwrite(stream, er);
  12243. };
  12244. // the callback that the user supplies to write(chunk,encoding,cb)
  12245. this.writecb = null;
  12246. // the amount that is being written when _write is called.
  12247. this.writelen = 0;
  12248. this.bufferedRequest = null;
  12249. this.lastBufferedRequest = null;
  12250. // number of pending user-supplied write callbacks
  12251. // this must be 0 before 'finish' can be emitted
  12252. this.pendingcb = 0;
  12253. // emit prefinish if the only thing we're waiting for is _write cbs
  12254. // This is relevant for synchronous Transform streams
  12255. this.prefinished = false;
  12256. // True if the error was already emitted and should not be thrown again
  12257. this.errorEmitted = false;
  12258. // count buffered requests
  12259. this.bufferedRequestCount = 0;
  12260. // allocate the first CorkedRequest, there is always
  12261. // one allocated and free to use, and we maintain at most two
  12262. this.corkedRequestsFree = new CorkedRequest(this);
  12263. }
  12264. WritableState.prototype.getBuffer = function getBuffer() {
  12265. var current = this.bufferedRequest;
  12266. var out = [];
  12267. while (current) {
  12268. out.push(current);
  12269. current = current.next;
  12270. }
  12271. return out;
  12272. };
  12273. (function () {
  12274. try {
  12275. Object.defineProperty(WritableState.prototype, 'buffer', {
  12276. get: internalUtil.deprecate(function () {
  12277. return this.getBuffer();
  12278. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  12279. });
  12280. } catch (_) {}
  12281. })();
  12282. // Test _writableState for inheritance to account for Duplex streams,
  12283. // whose prototype chain only points to Readable.
  12284. var realHasInstance;
  12285. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  12286. realHasInstance = Function.prototype[Symbol.hasInstance];
  12287. Object.defineProperty(Writable, Symbol.hasInstance, {
  12288. value: function (object) {
  12289. if (realHasInstance.call(this, object)) return true;
  12290. if (this !== Writable) return false;
  12291. return object && object._writableState instanceof WritableState;
  12292. }
  12293. });
  12294. } else {
  12295. realHasInstance = function (object) {
  12296. return object instanceof this;
  12297. };
  12298. }
  12299. function Writable(options) {
  12300. Duplex = Duplex || require('./_stream_duplex');
  12301. // Writable ctor is applied to Duplexes, too.
  12302. // `realHasInstance` is necessary because using plain `instanceof`
  12303. // would return false, as no `_writableState` property is attached.
  12304. // Trying to use the custom `instanceof` for Writable here will also break the
  12305. // Node.js LazyTransform implementation, which has a non-trivial getter for
  12306. // `_writableState` that would lead to infinite recursion.
  12307. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  12308. return new Writable(options);
  12309. }
  12310. this._writableState = new WritableState(options, this);
  12311. // legacy.
  12312. this.writable = true;
  12313. if (options) {
  12314. if (typeof options.write === 'function') this._write = options.write;
  12315. if (typeof options.writev === 'function') this._writev = options.writev;
  12316. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  12317. if (typeof options.final === 'function') this._final = options.final;
  12318. }
  12319. Stream.call(this);
  12320. }
  12321. // Otherwise people can pipe Writable streams, which is just wrong.
  12322. Writable.prototype.pipe = function () {
  12323. this.emit('error', new Error('Cannot pipe, not readable'));
  12324. };
  12325. function writeAfterEnd(stream, cb) {
  12326. var er = new Error('write after end');
  12327. // TODO: defer error events consistently everywhere, not just the cb
  12328. stream.emit('error', er);
  12329. pna.nextTick(cb, er);
  12330. }
  12331. // Checks that a user-supplied chunk is valid, especially for the particular
  12332. // mode the stream is in. Currently this means that `null` is never accepted
  12333. // and undefined/non-string values are only allowed in object mode.
  12334. function validChunk(stream, state, chunk, cb) {
  12335. var valid = true;
  12336. var er = false;
  12337. if (chunk === null) {
  12338. er = new TypeError('May not write null values to stream');
  12339. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  12340. er = new TypeError('Invalid non-string/buffer chunk');
  12341. }
  12342. if (er) {
  12343. stream.emit('error', er);
  12344. pna.nextTick(cb, er);
  12345. valid = false;
  12346. }
  12347. return valid;
  12348. }
  12349. Writable.prototype.write = function (chunk, encoding, cb) {
  12350. var state = this._writableState;
  12351. var ret = false;
  12352. var isBuf = !state.objectMode && _isUint8Array(chunk);
  12353. if (isBuf && !Buffer.isBuffer(chunk)) {
  12354. chunk = _uint8ArrayToBuffer(chunk);
  12355. }
  12356. if (typeof encoding === 'function') {
  12357. cb = encoding;
  12358. encoding = null;
  12359. }
  12360. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  12361. if (typeof cb !== 'function') cb = nop;
  12362. if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  12363. state.pendingcb++;
  12364. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  12365. }
  12366. return ret;
  12367. };
  12368. Writable.prototype.cork = function () {
  12369. var state = this._writableState;
  12370. state.corked++;
  12371. };
  12372. Writable.prototype.uncork = function () {
  12373. var state = this._writableState;
  12374. if (state.corked) {
  12375. state.corked--;
  12376. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  12377. }
  12378. };
  12379. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  12380. // node::ParseEncoding() requires lower case.
  12381. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  12382. 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);
  12383. this._writableState.defaultEncoding = encoding;
  12384. return this;
  12385. };
  12386. function decodeChunk(state, chunk, encoding) {
  12387. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  12388. chunk = Buffer.from(chunk, encoding);
  12389. }
  12390. return chunk;
  12391. }
  12392. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  12393. // making it explicit this property is not enumerable
  12394. // because otherwise some prototype manipulation in
  12395. // userland will fail
  12396. enumerable: false,
  12397. get: function () {
  12398. return this._writableState.highWaterMark;
  12399. }
  12400. });
  12401. // if we're already writing something, then just put this
  12402. // in the queue, and wait our turn. Otherwise, call _write
  12403. // If we return false, then we need a drain event, so set that flag.
  12404. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  12405. if (!isBuf) {
  12406. var newChunk = decodeChunk(state, chunk, encoding);
  12407. if (chunk !== newChunk) {
  12408. isBuf = true;
  12409. encoding = 'buffer';
  12410. chunk = newChunk;
  12411. }
  12412. }
  12413. var len = state.objectMode ? 1 : chunk.length;
  12414. state.length += len;
  12415. var ret = state.length < state.highWaterMark;
  12416. // we must ensure that previous needDrain will not be reset to false.
  12417. if (!ret) state.needDrain = true;
  12418. if (state.writing || state.corked) {
  12419. var last = state.lastBufferedRequest;
  12420. state.lastBufferedRequest = {
  12421. chunk: chunk,
  12422. encoding: encoding,
  12423. isBuf: isBuf,
  12424. callback: cb,
  12425. next: null
  12426. };
  12427. if (last) {
  12428. last.next = state.lastBufferedRequest;
  12429. } else {
  12430. state.bufferedRequest = state.lastBufferedRequest;
  12431. }
  12432. state.bufferedRequestCount += 1;
  12433. } else {
  12434. doWrite(stream, state, false, len, chunk, encoding, cb);
  12435. }
  12436. return ret;
  12437. }
  12438. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  12439. state.writelen = len;
  12440. state.writecb = cb;
  12441. state.writing = true;
  12442. state.sync = true;
  12443. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  12444. state.sync = false;
  12445. }
  12446. function onwriteError(stream, state, sync, er, cb) {
  12447. --state.pendingcb;
  12448. if (sync) {
  12449. // defer the callback if we are being called synchronously
  12450. // to avoid piling up things on the stack
  12451. pna.nextTick(cb, er);
  12452. // this can emit finish, and it will always happen
  12453. // after error
  12454. pna.nextTick(finishMaybe, stream, state);
  12455. stream._writableState.errorEmitted = true;
  12456. stream.emit('error', er);
  12457. } else {
  12458. // the caller expect this to happen before if
  12459. // it is async
  12460. cb(er);
  12461. stream._writableState.errorEmitted = true;
  12462. stream.emit('error', er);
  12463. // this can emit finish, but finish must
  12464. // always follow error
  12465. finishMaybe(stream, state);
  12466. }
  12467. }
  12468. function onwriteStateUpdate(state) {
  12469. state.writing = false;
  12470. state.writecb = null;
  12471. state.length -= state.writelen;
  12472. state.writelen = 0;
  12473. }
  12474. function onwrite(stream, er) {
  12475. var state = stream._writableState;
  12476. var sync = state.sync;
  12477. var cb = state.writecb;
  12478. onwriteStateUpdate(state);
  12479. if (er) onwriteError(stream, state, sync, er, cb);else {
  12480. // Check if we're actually ready to finish, but don't emit yet
  12481. var finished = needFinish(state);
  12482. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  12483. clearBuffer(stream, state);
  12484. }
  12485. if (sync) {
  12486. /*<replacement>*/
  12487. asyncWrite(afterWrite, stream, state, finished, cb);
  12488. /*</replacement>*/
  12489. } else {
  12490. afterWrite(stream, state, finished, cb);
  12491. }
  12492. }
  12493. }
  12494. function afterWrite(stream, state, finished, cb) {
  12495. if (!finished) onwriteDrain(stream, state);
  12496. state.pendingcb--;
  12497. cb();
  12498. finishMaybe(stream, state);
  12499. }
  12500. // Must force callback to be called on nextTick, so that we don't
  12501. // emit 'drain' before the write() consumer gets the 'false' return
  12502. // value, and has a chance to attach a 'drain' listener.
  12503. function onwriteDrain(stream, state) {
  12504. if (state.length === 0 && state.needDrain) {
  12505. state.needDrain = false;
  12506. stream.emit('drain');
  12507. }
  12508. }
  12509. // if there's something in the buffer waiting, then process it
  12510. function clearBuffer(stream, state) {
  12511. state.bufferProcessing = true;
  12512. var entry = state.bufferedRequest;
  12513. if (stream._writev && entry && entry.next) {
  12514. // Fast case, write everything using _writev()
  12515. var l = state.bufferedRequestCount;
  12516. var buffer = new Array(l);
  12517. var holder = state.corkedRequestsFree;
  12518. holder.entry = entry;
  12519. var count = 0;
  12520. var allBuffers = true;
  12521. while (entry) {
  12522. buffer[count] = entry;
  12523. if (!entry.isBuf) allBuffers = false;
  12524. entry = entry.next;
  12525. count += 1;
  12526. }
  12527. buffer.allBuffers = allBuffers;
  12528. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  12529. // doWrite is almost always async, defer these to save a bit of time
  12530. // as the hot path ends with doWrite
  12531. state.pendingcb++;
  12532. state.lastBufferedRequest = null;
  12533. if (holder.next) {
  12534. state.corkedRequestsFree = holder.next;
  12535. holder.next = null;
  12536. } else {
  12537. state.corkedRequestsFree = new CorkedRequest(state);
  12538. }
  12539. state.bufferedRequestCount = 0;
  12540. } else {
  12541. // Slow case, write chunks one-by-one
  12542. while (entry) {
  12543. var chunk = entry.chunk;
  12544. var encoding = entry.encoding;
  12545. var cb = entry.callback;
  12546. var len = state.objectMode ? 1 : chunk.length;
  12547. doWrite(stream, state, false, len, chunk, encoding, cb);
  12548. entry = entry.next;
  12549. state.bufferedRequestCount--;
  12550. // if we didn't call the onwrite immediately, then
  12551. // it means that we need to wait until it does.
  12552. // also, that means that the chunk and cb are currently
  12553. // being processed, so move the buffer counter past them.
  12554. if (state.writing) {
  12555. break;
  12556. }
  12557. }
  12558. if (entry === null) state.lastBufferedRequest = null;
  12559. }
  12560. state.bufferedRequest = entry;
  12561. state.bufferProcessing = false;
  12562. }
  12563. Writable.prototype._write = function (chunk, encoding, cb) {
  12564. cb(new Error('_write() is not implemented'));
  12565. };
  12566. Writable.prototype._writev = null;
  12567. Writable.prototype.end = function (chunk, encoding, cb) {
  12568. var state = this._writableState;
  12569. if (typeof chunk === 'function') {
  12570. cb = chunk;
  12571. chunk = null;
  12572. encoding = null;
  12573. } else if (typeof encoding === 'function') {
  12574. cb = encoding;
  12575. encoding = null;
  12576. }
  12577. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  12578. // .end() fully uncorks
  12579. if (state.corked) {
  12580. state.corked = 1;
  12581. this.uncork();
  12582. }
  12583. // ignore unnecessary end() calls.
  12584. if (!state.ending && !state.finished) endWritable(this, state, cb);
  12585. };
  12586. function needFinish(state) {
  12587. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  12588. }
  12589. function callFinal(stream, state) {
  12590. stream._final(function (err) {
  12591. state.pendingcb--;
  12592. if (err) {
  12593. stream.emit('error', err);
  12594. }
  12595. state.prefinished = true;
  12596. stream.emit('prefinish');
  12597. finishMaybe(stream, state);
  12598. });
  12599. }
  12600. function prefinish(stream, state) {
  12601. if (!state.prefinished && !state.finalCalled) {
  12602. if (typeof stream._final === 'function') {
  12603. state.pendingcb++;
  12604. state.finalCalled = true;
  12605. pna.nextTick(callFinal, stream, state);
  12606. } else {
  12607. state.prefinished = true;
  12608. stream.emit('prefinish');
  12609. }
  12610. }
  12611. }
  12612. function finishMaybe(stream, state) {
  12613. var need = needFinish(state);
  12614. if (need) {
  12615. prefinish(stream, state);
  12616. if (state.pendingcb === 0) {
  12617. state.finished = true;
  12618. stream.emit('finish');
  12619. }
  12620. }
  12621. return need;
  12622. }
  12623. function endWritable(stream, state, cb) {
  12624. state.ending = true;
  12625. finishMaybe(stream, state);
  12626. if (cb) {
  12627. if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
  12628. }
  12629. state.ended = true;
  12630. stream.writable = false;
  12631. }
  12632. function onCorkedFinish(corkReq, state, err) {
  12633. var entry = corkReq.entry;
  12634. corkReq.entry = null;
  12635. while (entry) {
  12636. var cb = entry.callback;
  12637. state.pendingcb--;
  12638. cb(err);
  12639. entry = entry.next;
  12640. }
  12641. if (state.corkedRequestsFree) {
  12642. state.corkedRequestsFree.next = corkReq;
  12643. } else {
  12644. state.corkedRequestsFree = corkReq;
  12645. }
  12646. }
  12647. Object.defineProperty(Writable.prototype, 'destroyed', {
  12648. get: function () {
  12649. if (this._writableState === undefined) {
  12650. return false;
  12651. }
  12652. return this._writableState.destroyed;
  12653. },
  12654. set: function (value) {
  12655. // we ignore the value if the stream
  12656. // has not been initialized yet
  12657. if (!this._writableState) {
  12658. return;
  12659. }
  12660. // backward compatibility, the user is explicitly
  12661. // managing destroyed
  12662. this._writableState.destroyed = value;
  12663. }
  12664. });
  12665. Writable.prototype.destroy = destroyImpl.destroy;
  12666. Writable.prototype._undestroy = destroyImpl.undestroy;
  12667. Writable.prototype._destroy = function (err, cb) {
  12668. this.end();
  12669. cb(err);
  12670. };
  12671. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  12672. },{"./_stream_duplex":58,"./internal/streams/destroy":64,"./internal/streams/stream":65,"_process":56,"core-util-is":42,"inherits":50,"process-nextick-args":55,"safe-buffer":70,"util-deprecate":73}],63:[function(require,module,exports){
  12673. 'use strict';
  12674. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12675. var Buffer = require('safe-buffer').Buffer;
  12676. var util = require('util');
  12677. function copyBuffer(src, target, offset) {
  12678. src.copy(target, offset);
  12679. }
  12680. module.exports = function () {
  12681. function BufferList() {
  12682. _classCallCheck(this, BufferList);
  12683. this.head = null;
  12684. this.tail = null;
  12685. this.length = 0;
  12686. }
  12687. BufferList.prototype.push = function push(v) {
  12688. var entry = { data: v, next: null };
  12689. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  12690. this.tail = entry;
  12691. ++this.length;
  12692. };
  12693. BufferList.prototype.unshift = function unshift(v) {
  12694. var entry = { data: v, next: this.head };
  12695. if (this.length === 0) this.tail = entry;
  12696. this.head = entry;
  12697. ++this.length;
  12698. };
  12699. BufferList.prototype.shift = function shift() {
  12700. if (this.length === 0) return;
  12701. var ret = this.head.data;
  12702. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  12703. --this.length;
  12704. return ret;
  12705. };
  12706. BufferList.prototype.clear = function clear() {
  12707. this.head = this.tail = null;
  12708. this.length = 0;
  12709. };
  12710. BufferList.prototype.join = function join(s) {
  12711. if (this.length === 0) return '';
  12712. var p = this.head;
  12713. var ret = '' + p.data;
  12714. while (p = p.next) {
  12715. ret += s + p.data;
  12716. }return ret;
  12717. };
  12718. BufferList.prototype.concat = function concat(n) {
  12719. if (this.length === 0) return Buffer.alloc(0);
  12720. if (this.length === 1) return this.head.data;
  12721. var ret = Buffer.allocUnsafe(n >>> 0);
  12722. var p = this.head;
  12723. var i = 0;
  12724. while (p) {
  12725. copyBuffer(p.data, ret, i);
  12726. i += p.data.length;
  12727. p = p.next;
  12728. }
  12729. return ret;
  12730. };
  12731. return BufferList;
  12732. }();
  12733. if (util && util.inspect && util.inspect.custom) {
  12734. module.exports.prototype[util.inspect.custom] = function () {
  12735. var obj = util.inspect({ length: this.length });
  12736. return this.constructor.name + ' ' + obj;
  12737. };
  12738. }
  12739. },{"safe-buffer":70,"util":38}],64:[function(require,module,exports){
  12740. 'use strict';
  12741. /*<replacement>*/
  12742. var pna = require('process-nextick-args');
  12743. /*</replacement>*/
  12744. // undocumented cb() API, needed for core, not for public API
  12745. function destroy(err, cb) {
  12746. var _this = this;
  12747. var readableDestroyed = this._readableState && this._readableState.destroyed;
  12748. var writableDestroyed = this._writableState && this._writableState.destroyed;
  12749. if (readableDestroyed || writableDestroyed) {
  12750. if (cb) {
  12751. cb(err);
  12752. } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
  12753. pna.nextTick(emitErrorNT, this, err);
  12754. }
  12755. return this;
  12756. }
  12757. // we set destroyed to true before firing error callbacks in order
  12758. // to make it re-entrance safe in case destroy() is called within callbacks
  12759. if (this._readableState) {
  12760. this._readableState.destroyed = true;
  12761. }
  12762. // if this is a duplex stream mark the writable part as destroyed as well
  12763. if (this._writableState) {
  12764. this._writableState.destroyed = true;
  12765. }
  12766. this._destroy(err || null, function (err) {
  12767. if (!cb && err) {
  12768. pna.nextTick(emitErrorNT, _this, err);
  12769. if (_this._writableState) {
  12770. _this._writableState.errorEmitted = true;
  12771. }
  12772. } else if (cb) {
  12773. cb(err);
  12774. }
  12775. });
  12776. return this;
  12777. }
  12778. function undestroy() {
  12779. if (this._readableState) {
  12780. this._readableState.destroyed = false;
  12781. this._readableState.reading = false;
  12782. this._readableState.ended = false;
  12783. this._readableState.endEmitted = false;
  12784. }
  12785. if (this._writableState) {
  12786. this._writableState.destroyed = false;
  12787. this._writableState.ended = false;
  12788. this._writableState.ending = false;
  12789. this._writableState.finished = false;
  12790. this._writableState.errorEmitted = false;
  12791. }
  12792. }
  12793. function emitErrorNT(self, err) {
  12794. self.emit('error', err);
  12795. }
  12796. module.exports = {
  12797. destroy: destroy,
  12798. undestroy: undestroy
  12799. };
  12800. },{"process-nextick-args":55}],65:[function(require,module,exports){
  12801. module.exports = require('events').EventEmitter;
  12802. },{"events":47}],66:[function(require,module,exports){
  12803. module.exports = require('./readable').PassThrough
  12804. },{"./readable":67}],67:[function(require,module,exports){
  12805. exports = module.exports = require('./lib/_stream_readable.js');
  12806. exports.Stream = exports;
  12807. exports.Readable = exports;
  12808. exports.Writable = require('./lib/_stream_writable.js');
  12809. exports.Duplex = require('./lib/_stream_duplex.js');
  12810. exports.Transform = require('./lib/_stream_transform.js');
  12811. exports.PassThrough = require('./lib/_stream_passthrough.js');
  12812. },{"./lib/_stream_duplex.js":58,"./lib/_stream_passthrough.js":59,"./lib/_stream_readable.js":60,"./lib/_stream_transform.js":61,"./lib/_stream_writable.js":62}],68:[function(require,module,exports){
  12813. module.exports = require('./readable').Transform
  12814. },{"./readable":67}],69:[function(require,module,exports){
  12815. module.exports = require('./lib/_stream_writable.js');
  12816. },{"./lib/_stream_writable.js":62}],70:[function(require,module,exports){
  12817. /* eslint-disable node/no-deprecated-api */
  12818. var buffer = require('buffer')
  12819. var Buffer = buffer.Buffer
  12820. // alternative to using Object.keys for old browsers
  12821. function copyProps (src, dst) {
  12822. for (var key in src) {
  12823. dst[key] = src[key]
  12824. }
  12825. }
  12826. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  12827. module.exports = buffer
  12828. } else {
  12829. // Copy properties from require('buffer')
  12830. copyProps(buffer, exports)
  12831. exports.Buffer = SafeBuffer
  12832. }
  12833. function SafeBuffer (arg, encodingOrOffset, length) {
  12834. return Buffer(arg, encodingOrOffset, length)
  12835. }
  12836. // Copy static methods from Buffer
  12837. copyProps(Buffer, SafeBuffer)
  12838. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  12839. if (typeof arg === 'number') {
  12840. throw new TypeError('Argument must not be a number')
  12841. }
  12842. return Buffer(arg, encodingOrOffset, length)
  12843. }
  12844. SafeBuffer.alloc = function (size, fill, encoding) {
  12845. if (typeof size !== 'number') {
  12846. throw new TypeError('Argument must be a number')
  12847. }
  12848. var buf = Buffer(size)
  12849. if (fill !== undefined) {
  12850. if (typeof encoding === 'string') {
  12851. buf.fill(fill, encoding)
  12852. } else {
  12853. buf.fill(fill)
  12854. }
  12855. } else {
  12856. buf.fill(0)
  12857. }
  12858. return buf
  12859. }
  12860. SafeBuffer.allocUnsafe = function (size) {
  12861. if (typeof size !== 'number') {
  12862. throw new TypeError('Argument must be a number')
  12863. }
  12864. return Buffer(size)
  12865. }
  12866. SafeBuffer.allocUnsafeSlow = function (size) {
  12867. if (typeof size !== 'number') {
  12868. throw new TypeError('Argument must be a number')
  12869. }
  12870. return buffer.SlowBuffer(size)
  12871. }
  12872. },{"buffer":41}],71:[function(require,module,exports){
  12873. // Copyright Joyent, Inc. and other Node contributors.
  12874. //
  12875. // Permission is hereby granted, free of charge, to any person obtaining a
  12876. // copy of this software and associated documentation files (the
  12877. // "Software"), to deal in the Software without restriction, including
  12878. // without limitation the rights to use, copy, modify, merge, publish,
  12879. // distribute, sublicense, and/or sell copies of the Software, and to permit
  12880. // persons to whom the Software is furnished to do so, subject to the
  12881. // following conditions:
  12882. //
  12883. // The above copyright notice and this permission notice shall be included
  12884. // in all copies or substantial portions of the Software.
  12885. //
  12886. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  12887. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  12888. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  12889. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  12890. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  12891. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  12892. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  12893. module.exports = Stream;
  12894. var EE = require('events').EventEmitter;
  12895. var inherits = require('inherits');
  12896. inherits(Stream, EE);
  12897. Stream.Readable = require('readable-stream/readable.js');
  12898. Stream.Writable = require('readable-stream/writable.js');
  12899. Stream.Duplex = require('readable-stream/duplex.js');
  12900. Stream.Transform = require('readable-stream/transform.js');
  12901. Stream.PassThrough = require('readable-stream/passthrough.js');
  12902. // Backwards-compat with node 0.4.x
  12903. Stream.Stream = Stream;
  12904. // old-style streams. Note that the pipe method (the only relevant
  12905. // part of this class) is overridden in the Readable class.
  12906. function Stream() {
  12907. EE.call(this);
  12908. }
  12909. Stream.prototype.pipe = function(dest, options) {
  12910. var source = this;
  12911. function ondata(chunk) {
  12912. if (dest.writable) {
  12913. if (false === dest.write(chunk) && source.pause) {
  12914. source.pause();
  12915. }
  12916. }
  12917. }
  12918. source.on('data', ondata);
  12919. function ondrain() {
  12920. if (source.readable && source.resume) {
  12921. source.resume();
  12922. }
  12923. }
  12924. dest.on('drain', ondrain);
  12925. // If the 'end' option is not supplied, dest.end() will be called when
  12926. // source gets the 'end' or 'close' events. Only dest.end() once.
  12927. if (!dest._isStdio && (!options || options.end !== false)) {
  12928. source.on('end', onend);
  12929. source.on('close', onclose);
  12930. }
  12931. var didOnEnd = false;
  12932. function onend() {
  12933. if (didOnEnd) return;
  12934. didOnEnd = true;
  12935. dest.end();
  12936. }
  12937. function onclose() {
  12938. if (didOnEnd) return;
  12939. didOnEnd = true;
  12940. if (typeof dest.destroy === 'function') dest.destroy();
  12941. }
  12942. // don't leave dangling pipes when there are errors.
  12943. function onerror(er) {
  12944. cleanup();
  12945. if (EE.listenerCount(this, 'error') === 0) {
  12946. throw er; // Unhandled stream error in pipe.
  12947. }
  12948. }
  12949. source.on('error', onerror);
  12950. dest.on('error', onerror);
  12951. // remove all the event listeners that were added.
  12952. function cleanup() {
  12953. source.removeListener('data', ondata);
  12954. dest.removeListener('drain', ondrain);
  12955. source.removeListener('end', onend);
  12956. source.removeListener('close', onclose);
  12957. source.removeListener('error', onerror);
  12958. dest.removeListener('error', onerror);
  12959. source.removeListener('end', cleanup);
  12960. source.removeListener('close', cleanup);
  12961. dest.removeListener('close', cleanup);
  12962. }
  12963. source.on('end', cleanup);
  12964. source.on('close', cleanup);
  12965. dest.on('close', cleanup);
  12966. dest.emit('pipe', source);
  12967. // Allow for unix-like usage: A.pipe(B).pipe(C)
  12968. return dest;
  12969. };
  12970. },{"events":47,"inherits":50,"readable-stream/duplex.js":57,"readable-stream/passthrough.js":66,"readable-stream/readable.js":67,"readable-stream/transform.js":68,"readable-stream/writable.js":69}],72:[function(require,module,exports){
  12971. // Copyright Joyent, Inc. and other Node contributors.
  12972. //
  12973. // Permission is hereby granted, free of charge, to any person obtaining a
  12974. // copy of this software and associated documentation files (the
  12975. // "Software"), to deal in the Software without restriction, including
  12976. // without limitation the rights to use, copy, modify, merge, publish,
  12977. // distribute, sublicense, and/or sell copies of the Software, and to permit
  12978. // persons to whom the Software is furnished to do so, subject to the
  12979. // following conditions:
  12980. //
  12981. // The above copyright notice and this permission notice shall be included
  12982. // in all copies or substantial portions of the Software.
  12983. //
  12984. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  12985. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  12986. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  12987. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  12988. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  12989. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  12990. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  12991. 'use strict';
  12992. /*<replacement>*/
  12993. var Buffer = require('safe-buffer').Buffer;
  12994. /*</replacement>*/
  12995. var isEncoding = Buffer.isEncoding || function (encoding) {
  12996. encoding = '' + encoding;
  12997. switch (encoding && encoding.toLowerCase()) {
  12998. 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':
  12999. return true;
  13000. default:
  13001. return false;
  13002. }
  13003. };
  13004. function _normalizeEncoding(enc) {
  13005. if (!enc) return 'utf8';
  13006. var retried;
  13007. while (true) {
  13008. switch (enc) {
  13009. case 'utf8':
  13010. case 'utf-8':
  13011. return 'utf8';
  13012. case 'ucs2':
  13013. case 'ucs-2':
  13014. case 'utf16le':
  13015. case 'utf-16le':
  13016. return 'utf16le';
  13017. case 'latin1':
  13018. case 'binary':
  13019. return 'latin1';
  13020. case 'base64':
  13021. case 'ascii':
  13022. case 'hex':
  13023. return enc;
  13024. default:
  13025. if (retried) return; // undefined
  13026. enc = ('' + enc).toLowerCase();
  13027. retried = true;
  13028. }
  13029. }
  13030. };
  13031. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  13032. // modules monkey-patch it to support additional encodings
  13033. function normalizeEncoding(enc) {
  13034. var nenc = _normalizeEncoding(enc);
  13035. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  13036. return nenc || enc;
  13037. }
  13038. // StringDecoder provides an interface for efficiently splitting a series of
  13039. // buffers into a series of JS strings without breaking apart multi-byte
  13040. // characters.
  13041. exports.StringDecoder = StringDecoder;
  13042. function StringDecoder(encoding) {
  13043. this.encoding = normalizeEncoding(encoding);
  13044. var nb;
  13045. switch (this.encoding) {
  13046. case 'utf16le':
  13047. this.text = utf16Text;
  13048. this.end = utf16End;
  13049. nb = 4;
  13050. break;
  13051. case 'utf8':
  13052. this.fillLast = utf8FillLast;
  13053. nb = 4;
  13054. break;
  13055. case 'base64':
  13056. this.text = base64Text;
  13057. this.end = base64End;
  13058. nb = 3;
  13059. break;
  13060. default:
  13061. this.write = simpleWrite;
  13062. this.end = simpleEnd;
  13063. return;
  13064. }
  13065. this.lastNeed = 0;
  13066. this.lastTotal = 0;
  13067. this.lastChar = Buffer.allocUnsafe(nb);
  13068. }
  13069. StringDecoder.prototype.write = function (buf) {
  13070. if (buf.length === 0) return '';
  13071. var r;
  13072. var i;
  13073. if (this.lastNeed) {
  13074. r = this.fillLast(buf);
  13075. if (r === undefined) return '';
  13076. i = this.lastNeed;
  13077. this.lastNeed = 0;
  13078. } else {
  13079. i = 0;
  13080. }
  13081. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  13082. return r || '';
  13083. };
  13084. StringDecoder.prototype.end = utf8End;
  13085. // Returns only complete characters in a Buffer
  13086. StringDecoder.prototype.text = utf8Text;
  13087. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  13088. StringDecoder.prototype.fillLast = function (buf) {
  13089. if (this.lastNeed <= buf.length) {
  13090. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  13091. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  13092. }
  13093. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  13094. this.lastNeed -= buf.length;
  13095. };
  13096. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  13097. // continuation byte. If an invalid byte is detected, -2 is returned.
  13098. function utf8CheckByte(byte) {
  13099. 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;
  13100. return byte >> 6 === 0x02 ? -1 : -2;
  13101. }
  13102. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  13103. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  13104. // needed to complete the UTF-8 character (if applicable) are returned.
  13105. function utf8CheckIncomplete(self, buf, i) {
  13106. var j = buf.length - 1;
  13107. if (j < i) return 0;
  13108. var nb = utf8CheckByte(buf[j]);
  13109. if (nb >= 0) {
  13110. if (nb > 0) self.lastNeed = nb - 1;
  13111. return nb;
  13112. }
  13113. if (--j < i || nb === -2) return 0;
  13114. nb = utf8CheckByte(buf[j]);
  13115. if (nb >= 0) {
  13116. if (nb > 0) self.lastNeed = nb - 2;
  13117. return nb;
  13118. }
  13119. if (--j < i || nb === -2) return 0;
  13120. nb = utf8CheckByte(buf[j]);
  13121. if (nb >= 0) {
  13122. if (nb > 0) {
  13123. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  13124. }
  13125. return nb;
  13126. }
  13127. return 0;
  13128. }
  13129. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  13130. // needed or are available. If we see a non-continuation byte where we expect
  13131. // one, we "replace" the validated continuation bytes we've seen so far with
  13132. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  13133. // behavior. The continuation byte check is included three times in the case
  13134. // where all of the continuation bytes for a character exist in the same buffer.
  13135. // It is also done this way as a slight performance increase instead of using a
  13136. // loop.
  13137. function utf8CheckExtraBytes(self, buf, p) {
  13138. if ((buf[0] & 0xC0) !== 0x80) {
  13139. self.lastNeed = 0;
  13140. return '\ufffd';
  13141. }
  13142. if (self.lastNeed > 1 && buf.length > 1) {
  13143. if ((buf[1] & 0xC0) !== 0x80) {
  13144. self.lastNeed = 1;
  13145. return '\ufffd';
  13146. }
  13147. if (self.lastNeed > 2 && buf.length > 2) {
  13148. if ((buf[2] & 0xC0) !== 0x80) {
  13149. self.lastNeed = 2;
  13150. return '\ufffd';
  13151. }
  13152. }
  13153. }
  13154. }
  13155. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  13156. function utf8FillLast(buf) {
  13157. var p = this.lastTotal - this.lastNeed;
  13158. var r = utf8CheckExtraBytes(this, buf, p);
  13159. if (r !== undefined) return r;
  13160. if (this.lastNeed <= buf.length) {
  13161. buf.copy(this.lastChar, p, 0, this.lastNeed);
  13162. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  13163. }
  13164. buf.copy(this.lastChar, p, 0, buf.length);
  13165. this.lastNeed -= buf.length;
  13166. }
  13167. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  13168. // partial character, the character's bytes are buffered until the required
  13169. // number of bytes are available.
  13170. function utf8Text(buf, i) {
  13171. var total = utf8CheckIncomplete(this, buf, i);
  13172. if (!this.lastNeed) return buf.toString('utf8', i);
  13173. this.lastTotal = total;
  13174. var end = buf.length - (total - this.lastNeed);
  13175. buf.copy(this.lastChar, 0, end);
  13176. return buf.toString('utf8', i, end);
  13177. }
  13178. // For UTF-8, a replacement character is added when ending on a partial
  13179. // character.
  13180. function utf8End(buf) {
  13181. var r = buf && buf.length ? this.write(buf) : '';
  13182. if (this.lastNeed) return r + '\ufffd';
  13183. return r;
  13184. }
  13185. // UTF-16LE typically needs two bytes per character, but even if we have an even
  13186. // number of bytes available, we need to check if we end on a leading/high
  13187. // surrogate. In that case, we need to wait for the next two bytes in order to
  13188. // decode the last character properly.
  13189. function utf16Text(buf, i) {
  13190. if ((buf.length - i) % 2 === 0) {
  13191. var r = buf.toString('utf16le', i);
  13192. if (r) {
  13193. var c = r.charCodeAt(r.length - 1);
  13194. if (c >= 0xD800 && c <= 0xDBFF) {
  13195. this.lastNeed = 2;
  13196. this.lastTotal = 4;
  13197. this.lastChar[0] = buf[buf.length - 2];
  13198. this.lastChar[1] = buf[buf.length - 1];
  13199. return r.slice(0, -1);
  13200. }
  13201. }
  13202. return r;
  13203. }
  13204. this.lastNeed = 1;
  13205. this.lastTotal = 2;
  13206. this.lastChar[0] = buf[buf.length - 1];
  13207. return buf.toString('utf16le', i, buf.length - 1);
  13208. }
  13209. // For UTF-16LE we do not explicitly append special replacement characters if we
  13210. // end on a partial character, we simply let v8 handle that.
  13211. function utf16End(buf) {
  13212. var r = buf && buf.length ? this.write(buf) : '';
  13213. if (this.lastNeed) {
  13214. var end = this.lastTotal - this.lastNeed;
  13215. return r + this.lastChar.toString('utf16le', 0, end);
  13216. }
  13217. return r;
  13218. }
  13219. function base64Text(buf, i) {
  13220. var n = (buf.length - i) % 3;
  13221. if (n === 0) return buf.toString('base64', i);
  13222. this.lastNeed = 3 - n;
  13223. this.lastTotal = 3;
  13224. if (n === 1) {
  13225. this.lastChar[0] = buf[buf.length - 1];
  13226. } else {
  13227. this.lastChar[0] = buf[buf.length - 2];
  13228. this.lastChar[1] = buf[buf.length - 1];
  13229. }
  13230. return buf.toString('base64', i, buf.length - n);
  13231. }
  13232. function base64End(buf) {
  13233. var r = buf && buf.length ? this.write(buf) : '';
  13234. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  13235. return r;
  13236. }
  13237. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  13238. function simpleWrite(buf) {
  13239. return buf.toString(this.encoding);
  13240. }
  13241. function simpleEnd(buf) {
  13242. return buf && buf.length ? this.write(buf) : '';
  13243. }
  13244. },{"safe-buffer":70}],73:[function(require,module,exports){
  13245. (function (global){
  13246. /**
  13247. * Module exports.
  13248. */
  13249. module.exports = deprecate;
  13250. /**
  13251. * Mark that a method should not be used.
  13252. * Returns a modified function which warns once by default.
  13253. *
  13254. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  13255. *
  13256. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  13257. * will throw an Error when invoked.
  13258. *
  13259. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  13260. * will invoke `console.trace()` instead of `console.error()`.
  13261. *
  13262. * @param {Function} fn - the function to deprecate
  13263. * @param {String} msg - the string to print to the console when `fn` is invoked
  13264. * @returns {Function} a new "deprecated" version of `fn`
  13265. * @api public
  13266. */
  13267. function deprecate (fn, msg) {
  13268. if (config('noDeprecation')) {
  13269. return fn;
  13270. }
  13271. var warned = false;
  13272. function deprecated() {
  13273. if (!warned) {
  13274. if (config('throwDeprecation')) {
  13275. throw new Error(msg);
  13276. } else if (config('traceDeprecation')) {
  13277. console.trace(msg);
  13278. } else {
  13279. console.warn(msg);
  13280. }
  13281. warned = true;
  13282. }
  13283. return fn.apply(this, arguments);
  13284. }
  13285. return deprecated;
  13286. }
  13287. /**
  13288. * Checks `localStorage` for boolean values for the given `name`.
  13289. *
  13290. * @param {String} name
  13291. * @returns {Boolean}
  13292. * @api private
  13293. */
  13294. function config (name) {
  13295. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  13296. try {
  13297. if (!global.localStorage) return false;
  13298. } catch (_) {
  13299. return false;
  13300. }
  13301. var val = global.localStorage[name];
  13302. if (null == val) return false;
  13303. return String(val).toLowerCase() === 'true';
  13304. }
  13305. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  13306. },{}],74:[function(require,module,exports){
  13307. arguments[4][50][0].apply(exports,arguments)
  13308. },{"dup":50}],75:[function(require,module,exports){
  13309. module.exports = function isBuffer(arg) {
  13310. return arg && typeof arg === 'object'
  13311. && typeof arg.copy === 'function'
  13312. && typeof arg.fill === 'function'
  13313. && typeof arg.readUInt8 === 'function';
  13314. }
  13315. },{}],76:[function(require,module,exports){
  13316. (function (process,global){
  13317. // Copyright Joyent, Inc. and other Node contributors.
  13318. //
  13319. // Permission is hereby granted, free of charge, to any person obtaining a
  13320. // copy of this software and associated documentation files (the
  13321. // "Software"), to deal in the Software without restriction, including
  13322. // without limitation the rights to use, copy, modify, merge, publish,
  13323. // distribute, sublicense, and/or sell copies of the Software, and to permit
  13324. // persons to whom the Software is furnished to do so, subject to the
  13325. // following conditions:
  13326. //
  13327. // The above copyright notice and this permission notice shall be included
  13328. // in all copies or substantial portions of the Software.
  13329. //
  13330. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13331. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13332. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  13333. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  13334. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  13335. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  13336. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  13337. var formatRegExp = /%[sdj%]/g;
  13338. exports.format = function(f) {
  13339. if (!isString(f)) {
  13340. var objects = [];
  13341. for (var i = 0; i < arguments.length; i++) {
  13342. objects.push(inspect(arguments[i]));
  13343. }
  13344. return objects.join(' ');
  13345. }
  13346. var i = 1;
  13347. var args = arguments;
  13348. var len = args.length;
  13349. var str = String(f).replace(formatRegExp, function(x) {
  13350. if (x === '%%') return '%';
  13351. if (i >= len) return x;
  13352. switch (x) {
  13353. case '%s': return String(args[i++]);
  13354. case '%d': return Number(args[i++]);
  13355. case '%j':
  13356. try {
  13357. return JSON.stringify(args[i++]);
  13358. } catch (_) {
  13359. return '[Circular]';
  13360. }
  13361. default:
  13362. return x;
  13363. }
  13364. });
  13365. for (var x = args[i]; i < len; x = args[++i]) {
  13366. if (isNull(x) || !isObject(x)) {
  13367. str += ' ' + x;
  13368. } else {
  13369. str += ' ' + inspect(x);
  13370. }
  13371. }
  13372. return str;
  13373. };
  13374. // Mark that a method should not be used.
  13375. // Returns a modified function which warns once by default.
  13376. // If --no-deprecation is set, then it is a no-op.
  13377. exports.deprecate = function(fn, msg) {
  13378. // Allow for deprecating things in the process of starting up.
  13379. if (isUndefined(global.process)) {
  13380. return function() {
  13381. return exports.deprecate(fn, msg).apply(this, arguments);
  13382. };
  13383. }
  13384. if (process.noDeprecation === true) {
  13385. return fn;
  13386. }
  13387. var warned = false;
  13388. function deprecated() {
  13389. if (!warned) {
  13390. if (process.throwDeprecation) {
  13391. throw new Error(msg);
  13392. } else if (process.traceDeprecation) {
  13393. console.trace(msg);
  13394. } else {
  13395. console.error(msg);
  13396. }
  13397. warned = true;
  13398. }
  13399. return fn.apply(this, arguments);
  13400. }
  13401. return deprecated;
  13402. };
  13403. var debugs = {};
  13404. var debugEnviron;
  13405. exports.debuglog = function(set) {
  13406. if (isUndefined(debugEnviron))
  13407. debugEnviron = process.env.NODE_DEBUG || '';
  13408. set = set.toUpperCase();
  13409. if (!debugs[set]) {
  13410. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  13411. var pid = process.pid;
  13412. debugs[set] = function() {
  13413. var msg = exports.format.apply(exports, arguments);
  13414. console.error('%s %d: %s', set, pid, msg);
  13415. };
  13416. } else {
  13417. debugs[set] = function() {};
  13418. }
  13419. }
  13420. return debugs[set];
  13421. };
  13422. /**
  13423. * Echos the value of a value. Trys to print the value out
  13424. * in the best way possible given the different types.
  13425. *
  13426. * @param {Object} obj The object to print out.
  13427. * @param {Object} opts Optional options object that alters the output.
  13428. */
  13429. /* legacy: obj, showHidden, depth, colors*/
  13430. function inspect(obj, opts) {
  13431. // default options
  13432. var ctx = {
  13433. seen: [],
  13434. stylize: stylizeNoColor
  13435. };
  13436. // legacy...
  13437. if (arguments.length >= 3) ctx.depth = arguments[2];
  13438. if (arguments.length >= 4) ctx.colors = arguments[3];
  13439. if (isBoolean(opts)) {
  13440. // legacy...
  13441. ctx.showHidden = opts;
  13442. } else if (opts) {
  13443. // got an "options" object
  13444. exports._extend(ctx, opts);
  13445. }
  13446. // set default options
  13447. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  13448. if (isUndefined(ctx.depth)) ctx.depth = 2;
  13449. if (isUndefined(ctx.colors)) ctx.colors = false;
  13450. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  13451. if (ctx.colors) ctx.stylize = stylizeWithColor;
  13452. return formatValue(ctx, obj, ctx.depth);
  13453. }
  13454. exports.inspect = inspect;
  13455. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  13456. inspect.colors = {
  13457. 'bold' : [1, 22],
  13458. 'italic' : [3, 23],
  13459. 'underline' : [4, 24],
  13460. 'inverse' : [7, 27],
  13461. 'white' : [37, 39],
  13462. 'grey' : [90, 39],
  13463. 'black' : [30, 39],
  13464. 'blue' : [34, 39],
  13465. 'cyan' : [36, 39],
  13466. 'green' : [32, 39],
  13467. 'magenta' : [35, 39],
  13468. 'red' : [31, 39],
  13469. 'yellow' : [33, 39]
  13470. };
  13471. // Don't use 'blue' not visible on cmd.exe
  13472. inspect.styles = {
  13473. 'special': 'cyan',
  13474. 'number': 'yellow',
  13475. 'boolean': 'yellow',
  13476. 'undefined': 'grey',
  13477. 'null': 'bold',
  13478. 'string': 'green',
  13479. 'date': 'magenta',
  13480. // "name": intentionally not styling
  13481. 'regexp': 'red'
  13482. };
  13483. function stylizeWithColor(str, styleType) {
  13484. var style = inspect.styles[styleType];
  13485. if (style) {
  13486. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  13487. '\u001b[' + inspect.colors[style][1] + 'm';
  13488. } else {
  13489. return str;
  13490. }
  13491. }
  13492. function stylizeNoColor(str, styleType) {
  13493. return str;
  13494. }
  13495. function arrayToHash(array) {
  13496. var hash = {};
  13497. array.forEach(function(val, idx) {
  13498. hash[val] = true;
  13499. });
  13500. return hash;
  13501. }
  13502. function formatValue(ctx, value, recurseTimes) {
  13503. // Provide a hook for user-specified inspect functions.
  13504. // Check that value is an object with an inspect function on it
  13505. if (ctx.customInspect &&
  13506. value &&
  13507. isFunction(value.inspect) &&
  13508. // Filter out the util module, it's inspect function is special
  13509. value.inspect !== exports.inspect &&
  13510. // Also filter out any prototype objects using the circular check.
  13511. !(value.constructor && value.constructor.prototype === value)) {
  13512. var ret = value.inspect(recurseTimes, ctx);
  13513. if (!isString(ret)) {
  13514. ret = formatValue(ctx, ret, recurseTimes);
  13515. }
  13516. return ret;
  13517. }
  13518. // Primitive types cannot have properties
  13519. var primitive = formatPrimitive(ctx, value);
  13520. if (primitive) {
  13521. return primitive;
  13522. }
  13523. // Look up the keys of the object.
  13524. var keys = Object.keys(value);
  13525. var visibleKeys = arrayToHash(keys);
  13526. if (ctx.showHidden) {
  13527. keys = Object.getOwnPropertyNames(value);
  13528. }
  13529. // IE doesn't make error fields non-enumerable
  13530. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  13531. if (isError(value)
  13532. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  13533. return formatError(value);
  13534. }
  13535. // Some type of object without properties can be shortcutted.
  13536. if (keys.length === 0) {
  13537. if (isFunction(value)) {
  13538. var name = value.name ? ': ' + value.name : '';
  13539. return ctx.stylize('[Function' + name + ']', 'special');
  13540. }
  13541. if (isRegExp(value)) {
  13542. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  13543. }
  13544. if (isDate(value)) {
  13545. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  13546. }
  13547. if (isError(value)) {
  13548. return formatError(value);
  13549. }
  13550. }
  13551. var base = '', array = false, braces = ['{', '}'];
  13552. // Make Array say that they are Array
  13553. if (isArray(value)) {
  13554. array = true;
  13555. braces = ['[', ']'];
  13556. }
  13557. // Make functions say that they are functions
  13558. if (isFunction(value)) {
  13559. var n = value.name ? ': ' + value.name : '';
  13560. base = ' [Function' + n + ']';
  13561. }
  13562. // Make RegExps say that they are RegExps
  13563. if (isRegExp(value)) {
  13564. base = ' ' + RegExp.prototype.toString.call(value);
  13565. }
  13566. // Make dates with properties first say the date
  13567. if (isDate(value)) {
  13568. base = ' ' + Date.prototype.toUTCString.call(value);
  13569. }
  13570. // Make error with message first say the error
  13571. if (isError(value)) {
  13572. base = ' ' + formatError(value);
  13573. }
  13574. if (keys.length === 0 && (!array || value.length == 0)) {
  13575. return braces[0] + base + braces[1];
  13576. }
  13577. if (recurseTimes < 0) {
  13578. if (isRegExp(value)) {
  13579. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  13580. } else {
  13581. return ctx.stylize('[Object]', 'special');
  13582. }
  13583. }
  13584. ctx.seen.push(value);
  13585. var output;
  13586. if (array) {
  13587. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  13588. } else {
  13589. output = keys.map(function(key) {
  13590. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  13591. });
  13592. }
  13593. ctx.seen.pop();
  13594. return reduceToSingleString(output, base, braces);
  13595. }
  13596. function formatPrimitive(ctx, value) {
  13597. if (isUndefined(value))
  13598. return ctx.stylize('undefined', 'undefined');
  13599. if (isString(value)) {
  13600. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  13601. .replace(/'/g, "\\'")
  13602. .replace(/\\"/g, '"') + '\'';
  13603. return ctx.stylize(simple, 'string');
  13604. }
  13605. if (isNumber(value))
  13606. return ctx.stylize('' + value, 'number');
  13607. if (isBoolean(value))
  13608. return ctx.stylize('' + value, 'boolean');
  13609. // For some reason typeof null is "object", so special case here.
  13610. if (isNull(value))
  13611. return ctx.stylize('null', 'null');
  13612. }
  13613. function formatError(value) {
  13614. return '[' + Error.prototype.toString.call(value) + ']';
  13615. }
  13616. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  13617. var output = [];
  13618. for (var i = 0, l = value.length; i < l; ++i) {
  13619. if (hasOwnProperty(value, String(i))) {
  13620. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  13621. String(i), true));
  13622. } else {
  13623. output.push('');
  13624. }
  13625. }
  13626. keys.forEach(function(key) {
  13627. if (!key.match(/^\d+$/)) {
  13628. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  13629. key, true));
  13630. }
  13631. });
  13632. return output;
  13633. }
  13634. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  13635. var name, str, desc;
  13636. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  13637. if (desc.get) {
  13638. if (desc.set) {
  13639. str = ctx.stylize('[Getter/Setter]', 'special');
  13640. } else {
  13641. str = ctx.stylize('[Getter]', 'special');
  13642. }
  13643. } else {
  13644. if (desc.set) {
  13645. str = ctx.stylize('[Setter]', 'special');
  13646. }
  13647. }
  13648. if (!hasOwnProperty(visibleKeys, key)) {
  13649. name = '[' + key + ']';
  13650. }
  13651. if (!str) {
  13652. if (ctx.seen.indexOf(desc.value) < 0) {
  13653. if (isNull(recurseTimes)) {
  13654. str = formatValue(ctx, desc.value, null);
  13655. } else {
  13656. str = formatValue(ctx, desc.value, recurseTimes - 1);
  13657. }
  13658. if (str.indexOf('\n') > -1) {
  13659. if (array) {
  13660. str = str.split('\n').map(function(line) {
  13661. return ' ' + line;
  13662. }).join('\n').substr(2);
  13663. } else {
  13664. str = '\n' + str.split('\n').map(function(line) {
  13665. return ' ' + line;
  13666. }).join('\n');
  13667. }
  13668. }
  13669. } else {
  13670. str = ctx.stylize('[Circular]', 'special');
  13671. }
  13672. }
  13673. if (isUndefined(name)) {
  13674. if (array && key.match(/^\d+$/)) {
  13675. return str;
  13676. }
  13677. name = JSON.stringify('' + key);
  13678. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  13679. name = name.substr(1, name.length - 2);
  13680. name = ctx.stylize(name, 'name');
  13681. } else {
  13682. name = name.replace(/'/g, "\\'")
  13683. .replace(/\\"/g, '"')
  13684. .replace(/(^"|"$)/g, "'");
  13685. name = ctx.stylize(name, 'string');
  13686. }
  13687. }
  13688. return name + ': ' + str;
  13689. }
  13690. function reduceToSingleString(output, base, braces) {
  13691. var numLinesEst = 0;
  13692. var length = output.reduce(function(prev, cur) {
  13693. numLinesEst++;
  13694. if (cur.indexOf('\n') >= 0) numLinesEst++;
  13695. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  13696. }, 0);
  13697. if (length > 60) {
  13698. return braces[0] +
  13699. (base === '' ? '' : base + '\n ') +
  13700. ' ' +
  13701. output.join(',\n ') +
  13702. ' ' +
  13703. braces[1];
  13704. }
  13705. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  13706. }
  13707. // NOTE: These type checking functions intentionally don't use `instanceof`
  13708. // because it is fragile and can be easily faked with `Object.create()`.
  13709. function isArray(ar) {
  13710. return Array.isArray(ar);
  13711. }
  13712. exports.isArray = isArray;
  13713. function isBoolean(arg) {
  13714. return typeof arg === 'boolean';
  13715. }
  13716. exports.isBoolean = isBoolean;
  13717. function isNull(arg) {
  13718. return arg === null;
  13719. }
  13720. exports.isNull = isNull;
  13721. function isNullOrUndefined(arg) {
  13722. return arg == null;
  13723. }
  13724. exports.isNullOrUndefined = isNullOrUndefined;
  13725. function isNumber(arg) {
  13726. return typeof arg === 'number';
  13727. }
  13728. exports.isNumber = isNumber;
  13729. function isString(arg) {
  13730. return typeof arg === 'string';
  13731. }
  13732. exports.isString = isString;
  13733. function isSymbol(arg) {
  13734. return typeof arg === 'symbol';
  13735. }
  13736. exports.isSymbol = isSymbol;
  13737. function isUndefined(arg) {
  13738. return arg === void 0;
  13739. }
  13740. exports.isUndefined = isUndefined;
  13741. function isRegExp(re) {
  13742. return isObject(re) && objectToString(re) === '[object RegExp]';
  13743. }
  13744. exports.isRegExp = isRegExp;
  13745. function isObject(arg) {
  13746. return typeof arg === 'object' && arg !== null;
  13747. }
  13748. exports.isObject = isObject;
  13749. function isDate(d) {
  13750. return isObject(d) && objectToString(d) === '[object Date]';
  13751. }
  13752. exports.isDate = isDate;
  13753. function isError(e) {
  13754. return isObject(e) &&
  13755. (objectToString(e) === '[object Error]' || e instanceof Error);
  13756. }
  13757. exports.isError = isError;
  13758. function isFunction(arg) {
  13759. return typeof arg === 'function';
  13760. }
  13761. exports.isFunction = isFunction;
  13762. function isPrimitive(arg) {
  13763. return arg === null ||
  13764. typeof arg === 'boolean' ||
  13765. typeof arg === 'number' ||
  13766. typeof arg === 'string' ||
  13767. typeof arg === 'symbol' || // ES6 symbol
  13768. typeof arg === 'undefined';
  13769. }
  13770. exports.isPrimitive = isPrimitive;
  13771. exports.isBuffer = require('./support/isBuffer');
  13772. function objectToString(o) {
  13773. return Object.prototype.toString.call(o);
  13774. }
  13775. function pad(n) {
  13776. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  13777. }
  13778. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  13779. 'Oct', 'Nov', 'Dec'];
  13780. // 26 Feb 16:19:34
  13781. function timestamp() {
  13782. var d = new Date();
  13783. var time = [pad(d.getHours()),
  13784. pad(d.getMinutes()),
  13785. pad(d.getSeconds())].join(':');
  13786. return [d.getDate(), months[d.getMonth()], time].join(' ');
  13787. }
  13788. // log is just a thin wrapper to console.log that prepends a timestamp
  13789. exports.log = function() {
  13790. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  13791. };
  13792. /**
  13793. * Inherit the prototype methods from one constructor into another.
  13794. *
  13795. * The Function.prototype.inherits from lang.js rewritten as a standalone
  13796. * function (not on Function.prototype). NOTE: If this file is to be loaded
  13797. * during bootstrapping this function needs to be rewritten using some native
  13798. * functions as prototype setup using normal JavaScript does not work as
  13799. * expected during bootstrapping (see mirror.js in r114903).
  13800. *
  13801. * @param {function} ctor Constructor function which needs to inherit the
  13802. * prototype.
  13803. * @param {function} superCtor Constructor function to inherit prototype from.
  13804. */
  13805. exports.inherits = require('inherits');
  13806. exports._extend = function(origin, add) {
  13807. // Don't do anything if add isn't an object
  13808. if (!add || !isObject(add)) return origin;
  13809. var keys = Object.keys(add);
  13810. var i = keys.length;
  13811. while (i--) {
  13812. origin[keys[i]] = add[keys[i]];
  13813. }
  13814. return origin;
  13815. };
  13816. function hasOwnProperty(obj, prop) {
  13817. return Object.prototype.hasOwnProperty.call(obj, prop);
  13818. }
  13819. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  13820. },{"./support/isBuffer":75,"_process":56,"inherits":74}]},{},[1]);