power-assert.js 574 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980
  1. /**
  2. * Modules in this bundle
  3. * @license
  4. *
  5. * power-assert:
  6. * license: MIT (http://opensource.org/licenses/MIT)
  7. * author: Takuto Wada <takuto.wada@gmail.com>
  8. * contributors: azu, Masahiro Wakame, Yosuke Furukawa, Teppei Sato, Kenta Mori, falsandtru, James Talmage, Lesha Koss, Daijirō Wachi
  9. * homepage: https://github.com/power-assert-js/power-assert
  10. * version: 1.6.1
  11. *
  12. * acorn:
  13. * license: MIT (http://opensource.org/licenses/MIT)
  14. * maintainers: Marijn Haverbeke <marijnh@gmail.com>, Ingvar Stepanyan <me@rreverser.com>, Adrian Heine <http://adrianheine.de>
  15. * contributors: List of Acorn contributors. Updated before every release., Adrian Heine, Adrian Rakovsky, Alistair Braidwood, Amila Welihinda, Andres Suarez, Angelo, Aparajita Fishman, Arian Stolwijk, Artem Govorov, Boopesh Mahendran, Bradley Heinz, Brandon Mills, Charles Hughes, Charmander, Chris McKnight, Conrad Irwin, Daniel Tschinder, David Bonnet, Domenico Matteo, ehmicky, Eugene Obrezkov, Felix Maier, Forbes Lindesay, Gilad Peleg, impinball, Ingvar Stepanyan, Jackson Ray Hamilton, Jesse McCarthy, Jiaxing Wang, Joel Kemp, Johannes Herr, John-David Dalton, Jordan Klassen, Jürg Lehni, Kai Cataldo, keeyipchan, Keheliya Gallaba, Kevin Irish, Kevin Kwok, krator, laosb, Marek, Marijn Haverbeke, Martin Carlberg, Mat Garcia, Mathias Bynens, Mathieu 'p01' Henri, Matthew Bastien, Max Schaefer, Max Zerzouri, Mihai Bazon, Mike Rennie, naoh, Nicholas C. Zakas, Nick Fitzgerald, Olivier Thomann, Oskar Schöldström, Paul Harper, Peter Rust, PlNG, Prayag Verma, ReadmeCritic, r-e-d, Richard Gibson, Rich Harris, Sebastian McKenzie, Shahar Soel, Sheel Bedi, Simen Bekkhus, Teddy Katz, Timothy Gu, Toru Nagashima, Victor Homyakov, Wexpo Lyu, zsjforcn
  16. * homepage: https://github.com/acornjs/acorn
  17. * version: 5.7.2
  18. *
  19. * acorn-es7-plugin:
  20. * license: MIT (http://opensource.org/licenses/MIT)
  21. * author: matatbread
  22. * homepage: https://github.com/MatAtBread/acorn-es7-plugin#readme
  23. * version: 1.1.7
  24. *
  25. * array-filter:
  26. * license: MIT (http://opensource.org/licenses/MIT)
  27. * author: Julian Gruber <mail@juliangruber.com>
  28. * homepage: https://github.com/juliangruber/array-filter
  29. * version: 1.0.0
  30. *
  31. * assert:
  32. * license: MIT (http://opensource.org/licenses/MIT)
  33. * homepage: https://github.com/defunctzombie/commonjs-assert
  34. * version: 1.4.1
  35. *
  36. * base64-js:
  37. * license: MIT (http://opensource.org/licenses/MIT)
  38. * author: T. Jameson Little <t.jameson.little@gmail.com>
  39. * homepage: https://github.com/beatgammit/base64-js
  40. * version: 1.3.0
  41. *
  42. * buffer:
  43. * license: MIT (http://opensource.org/licenses/MIT)
  44. * author: Feross Aboukhadijeh <feross@feross.org>
  45. * contributors: Romain Beauxis <toots@rastageeks.org>, James Halliday <mail@substack.net>
  46. * homepage: https://github.com/feross/buffer
  47. * version: 4.9.1
  48. *
  49. * call-signature:
  50. * license: MIT (http://opensource.org/licenses/MIT)
  51. * author: James Talmage <james@talmage.io>
  52. * homepage: https://github.com/jamestalmage/call-signature#readme
  53. * version: 0.0.2
  54. *
  55. * core-js:
  56. * license: MIT (http://opensource.org/licenses/MIT)
  57. * homepage: https://github.com/zloirock/core-js#readme
  58. * version: 2.5.7
  59. *
  60. * define-properties:
  61. * license: MIT (http://opensource.org/licenses/MIT)
  62. * author: Jordan Harband
  63. * homepage: https://github.com/ljharb/define-properties#readme
  64. * version: 1.1.3
  65. *
  66. * diff-match-patch:
  67. * license: Apache-2.0 (http://opensource.org/licenses/Apache-2.0)
  68. * homepage: https://github.com/JackuB/diff-match-patch#readme
  69. * version: 1.0.4
  70. *
  71. * eastasianwidth:
  72. * license: MIT (http://opensource.org/licenses/MIT)
  73. * author: Masaki Komagata
  74. * homepage: https://github.com/komagata/eastasianwidth#readme
  75. * version: 0.2.0
  76. *
  77. * empower:
  78. * license: MIT (http://opensource.org/licenses/MIT)
  79. * author: Takuto Wada <takuto.wada@gmail.com>
  80. * contributors: James Talmage
  81. * homepage: https://github.com/power-assert-js/empower
  82. * version: 1.3.1
  83. *
  84. * empower-core:
  85. * license: MIT (http://opensource.org/licenses/MIT)
  86. * author: Takuto Wada <takuto.wada@gmail.com>
  87. * contributors: James Talmage
  88. * homepage: https://github.com/twada/power-assert-runtime
  89. * version: 1.2.0
  90. *
  91. * espurify:
  92. * license: MIT (http://opensource.org/licenses/MIT)
  93. * author: Takuto Wada <takuto.wada@gmail.com>
  94. * homepage: https://github.com/estools/espurify
  95. * version: 1.8.1
  96. *
  97. * estraverse:
  98. * license: BSD-2-Clause (http://opensource.org/licenses/BSD-2-Clause)
  99. * maintainers: Yusuke Suzuki <utatane.tea@gmail.com>
  100. * homepage: https://github.com/estools/estraverse
  101. * version: 4.2.0
  102. *
  103. * events:
  104. * license: MIT (http://opensource.org/licenses/MIT)
  105. * author: Irakli Gozalishvili <rfobic@gmail.com>
  106. * homepage: https://github.com/Gozala/events#readme
  107. * version: 1.1.1
  108. *
  109. * ieee754:
  110. * license: BSD-3-Clause (http://opensource.org/licenses/BSD-3-Clause)
  111. * author: Feross Aboukhadijeh <feross@feross.org>
  112. * contributors: Romain Beauxis <toots@rastageeks.org>
  113. * homepage: https://github.com/feross/ieee754#readme
  114. * version: 1.1.12
  115. *
  116. * indexof:
  117. * version: 0.0.1
  118. *
  119. * inherits:
  120. * license: ISC (http://opensource.org/licenses/ISC)
  121. * homepage: https://github.com/isaacs/inherits#readme
  122. * version: 2.0.1
  123. *
  124. * isarray:
  125. * license: MIT (http://opensource.org/licenses/MIT)
  126. * author: Julian Gruber <mail@juliangruber.com>
  127. * homepage: https://github.com/juliangruber/isarray
  128. * version: 1.0.0
  129. *
  130. * object-keys:
  131. * license: MIT (http://opensource.org/licenses/MIT)
  132. * author: Jordan Harband <ljharb@gmail.com>
  133. * contributors: Jordan Harband <ljharb@gmail.com>, Raynos <raynos2@gmail.com>, Nathan Rajlich <nathan@tootallnate.net>, Ivan Starkov <istarkov@gmail.com>, Gary Katsevman <git@gkatsev.com>
  134. * homepage: https://github.com/ljharb/object-keys#readme
  135. * version: 1.0.12
  136. *
  137. * power-assert-context-formatter:
  138. * license: MIT (http://opensource.org/licenses/MIT)
  139. * author: Takuto Wada <takuto.wada@gmail.com>
  140. * homepage: https://github.com/twada/power-assert-runtime
  141. * version: 1.2.0
  142. *
  143. * power-assert-context-reducer-ast:
  144. * license: MIT (http://opensource.org/licenses/MIT)
  145. * author: Takuto Wada <takuto.wada@gmail.com>
  146. * contributors: Haoliang Gao
  147. * homepage: https://github.com/twada/power-assert-runtime
  148. * version: 1.2.0
  149. *
  150. * power-assert-context-traversal:
  151. * license: MIT (http://opensource.org/licenses/MIT)
  152. * author: Takuto Wada <takuto.wada@gmail.com>
  153. * homepage: https://github.com/twada/power-assert-runtime
  154. * version: 1.2.0
  155. *
  156. * power-assert-formatter:
  157. * license: MIT (http://opensource.org/licenses/MIT)
  158. * author: Takuto Wada <takuto.wada@gmail.com>
  159. * contributors: James Talmage
  160. * homepage: https://github.com/power-assert-js/power-assert-formatter
  161. * version: 1.4.1
  162. *
  163. * power-assert-renderer-assertion:
  164. * license: MIT (http://opensource.org/licenses/MIT)
  165. * author: Takuto Wada <takuto.wada@gmail.com>
  166. * homepage: https://github.com/twada/power-assert-runtime
  167. * version: 1.2.0
  168. *
  169. * power-assert-renderer-base:
  170. * license: MIT (http://opensource.org/licenses/MIT)
  171. * author: Takuto Wada <takuto.wada@gmail.com>
  172. * homepage: https://github.com/twada/power-assert-runtime
  173. * version: 1.1.1
  174. *
  175. * power-assert-renderer-comparison:
  176. * license: MIT (http://opensource.org/licenses/MIT)
  177. * author: Takuto Wada <takuto.wada@gmail.com>
  178. * homepage: https://github.com/twada/power-assert-runtime
  179. * version: 1.2.0
  180. *
  181. * power-assert-renderer-diagram:
  182. * license: MIT (http://opensource.org/licenses/MIT)
  183. * author: Takuto Wada <takuto.wada@gmail.com>
  184. * homepage: https://github.com/twada/power-assert-runtime
  185. * version: 1.2.0
  186. *
  187. * power-assert-renderer-file:
  188. * license: MIT (http://opensource.org/licenses/MIT)
  189. * author: Takuto Wada <takuto.wada@gmail.com>
  190. * homepage: https://github.com/twada/power-assert-runtime
  191. * version: 1.2.0
  192. *
  193. * power-assert-util-string-width:
  194. * license: MIT (http://opensource.org/licenses/MIT)
  195. * author: Takuto Wada <takuto.wada@gmail.com>
  196. * homepage: https://github.com/twada/power-assert-runtime
  197. * version: 1.2.0
  198. *
  199. * process:
  200. * license: MIT (http://opensource.org/licenses/MIT)
  201. * author: Roman Shtylman <shtylman@gmail.com>
  202. * homepage: https://github.com/shtylman/node-process#readme
  203. * version: 0.11.10
  204. *
  205. * stringifier:
  206. * license: MIT (http://opensource.org/licenses/MIT)
  207. * author: Takuto Wada <takuto.wada@gmail.com>
  208. * homepage: https://github.com/twada/stringifier
  209. * version: 1.4.0
  210. *
  211. * traverse:
  212. * license: MIT (http://opensource.org/licenses/MIT)
  213. * author: James Halliday <mail@substack.net>
  214. * homepage: https://github.com/substack/js-traverse
  215. * version: 0.6.6
  216. *
  217. * type-name:
  218. * license: MIT (http://opensource.org/licenses/MIT)
  219. * author: Takuto Wada <takuto.wada@gmail.com>
  220. * contributors: azu, Yosuke Furukawa, Athan, Andrew Moss
  221. * homepage: https://github.com/twada/type-name
  222. * version: 2.0.2
  223. *
  224. * universal-deep-strict-equal:
  225. * license: MIT (http://opensource.org/licenses/MIT)
  226. * author: Takuto Wada <takuto.wada@gmail.com>
  227. * contributors: azu
  228. * homepage: https://github.com/twada/universal-deep-strict-equal
  229. * version: 1.2.2
  230. *
  231. * util:
  232. * license: MIT (http://opensource.org/licenses/MIT)
  233. * author: Joyent
  234. * homepage: https://github.com/defunctzombie/node-util
  235. * version: 0.10.3
  236. *
  237. * xtend:
  238. * license: MIT (http://opensource.org/licenses/MIT)
  239. * author: Raynos <raynos2@gmail.com>
  240. * contributors: Jake Verbaten, Matt Esch
  241. * homepage: https://github.com/Raynos/xtend
  242. * version: 4.0.1
  243. *
  244. * This header is generated by licensify (https://github.com/twada/licensify)
  245. */
  246. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.assert = f()}})(function(){var define,module,exports;return (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(_dereq_,module,exports){
  247. /**
  248. * power-assert.js - Power Assert in JavaScript.
  249. *
  250. * https://github.com/power-assert-js/power-assert
  251. *
  252. * Copyright (c) 2013-2018 Takuto Wada
  253. * Licensed under the MIT license.
  254. * https://github.com/power-assert-js/power-assert/blob/master/MIT-LICENSE.txt
  255. */
  256. 'use strict';
  257. var baseAssert = _dereq_('assert');
  258. var _deepEqual = _dereq_('universal-deep-strict-equal');
  259. var empower = _dereq_('empower');
  260. var formatter = _dereq_('power-assert-formatter');
  261. var assign = _dereq_('xtend/mutable');
  262. var define = _dereq_('define-properties');
  263. var empowerOptions = {
  264. modifyMessageOnRethrow: true,
  265. saveContextOnRethrow: true
  266. };
  267. if (typeof baseAssert.deepStrictEqual !== 'function') {
  268. baseAssert.deepStrictEqual = function deepStrictEqual (actual, expected, message) {
  269. if (!_deepEqual(actual, expected, true)) {
  270. baseAssert.fail(actual, expected, message, 'deepStrictEqual');
  271. }
  272. };
  273. }
  274. if (typeof baseAssert.notDeepStrictEqual !== 'function') {
  275. baseAssert.notDeepStrictEqual = function notDeepStrictEqual (actual, expected, message) {
  276. if (_deepEqual(actual, expected, true)) {
  277. baseAssert.fail(actual, expected, message, 'notDeepStrictEqual');
  278. }
  279. };
  280. }
  281. function customize (customOptions) {
  282. var options = customOptions || {};
  283. var applyEmpower = function (fn) {
  284. return empower(
  285. fn,
  286. formatter(options.output),
  287. assign({}, empowerOptions, options.assertion)
  288. );
  289. };
  290. var poweredAssert = applyEmpower(baseAssert);
  291. poweredAssert.customize = customize;
  292. if (typeof baseAssert.strict === 'function') {
  293. poweredAssert.strict = applyEmpower(baseAssert.strict);
  294. } else {
  295. var strict = applyEmpower(baseAssert);
  296. poweredAssert.strict = assign(strict, {
  297. equal: strict.strictEqual,
  298. deepEqual: strict.deepStrictEqual,
  299. notEqual: strict.notStrictEqual,
  300. notDeepEqual: strict.notDeepStrictEqual
  301. });
  302. }
  303. poweredAssert.strict.strict = poweredAssert.strict;
  304. return poweredAssert;
  305. }
  306. var defaultAssert = customize();
  307. define(defaultAssert, { '__esModule': true });
  308. defaultAssert['default'] = defaultAssert;
  309. module.exports = defaultAssert;
  310. },{"assert":7,"define-properties":123,"empower":131,"power-assert-formatter":157,"universal-deep-strict-equal":174,"xtend/mutable":177}],2:[function(_dereq_,module,exports){
  311. module.exports = function(acorn) {
  312. switch (parseInt(acorn.version)) {
  313. case 2:
  314. case 3:
  315. acorn.plugins.asyncawait = _dereq_('./acorn-v3') ;
  316. break ;
  317. case 4:
  318. acorn.plugins.asyncawait = _dereq_('./acorn-v4') ;
  319. break ;
  320. case 5:
  321. acorn.plugins.asyncawait = _dereq_('./acorn-v4') ;
  322. break ;
  323. default:
  324. throw new Error("acorn-es7-plugin requires Acorn v2, 3, 4 or 5") ;
  325. }
  326. return acorn
  327. }
  328. },{"./acorn-v3":3,"./acorn-v4":4}],3:[function(_dereq_,module,exports){
  329. var NotAsync = {} ;
  330. var asyncExit = /^async[\t ]+(return|throw)/ ;
  331. var asyncFunction = /^async[\t ]+function/ ;
  332. var atomOrPropertyOrLabel = /^\s*[():;]/ ;
  333. var removeComments = /([^\n])\/\*(\*(?!\/)|[^\n*])*\*\/([^\n])/g ;
  334. var matchAsyncGet = /\s*(get|set)\s*\(/ ;
  335. function hasLineTerminatorBeforeNext(st, since) {
  336. return st.lineStart >= since;
  337. }
  338. function test(regex,st,noComment) {
  339. var src = st.input.slice(st.start) ;
  340. if (noComment) {
  341. src = src.replace(removeComments,"$1 $3") ;
  342. }
  343. return regex.test(src);
  344. }
  345. /* Create a new parser derived from the specified parser, so that in the
  346. * event of an error we can back out and try again */
  347. function subParse(parser, pos, extensions,parens) {
  348. var p = new parser.constructor(parser.options, parser.input, pos);
  349. if (extensions)
  350. for (var k in extensions)
  351. p[k] = extensions[k] ;
  352. var src = parser ;
  353. var dest = p ;
  354. ['inFunction','inAsyncFunction','inAsync','inGenerator','inModule'].forEach(function(k){
  355. if (k in src)
  356. dest[k] = src[k] ;
  357. }) ;
  358. if (parens)
  359. p.options.preserveParens = true ;
  360. p.nextToken();
  361. return p;
  362. }
  363. //TODO: Implement option noAsyncGetters
  364. function asyncAwaitPlugin (parser,options){
  365. var es7check = function(){} ;
  366. parser.extend("initialContext",function(base){
  367. return function(){
  368. if (this.options.ecmaVersion < 7) {
  369. es7check = function(node) {
  370. parser.raise(node.start,"async/await keywords only available when ecmaVersion>=7") ;
  371. } ;
  372. }
  373. this.reservedWords = new RegExp(this.reservedWords.toString().replace(/await|async/g,"").replace("|/","/").replace("/|","/").replace("||","|")) ;
  374. this.reservedWordsStrict = new RegExp(this.reservedWordsStrict.toString().replace(/await|async/g,"").replace("|/","/").replace("/|","/").replace("||","|")) ;
  375. this.reservedWordsStrictBind = new RegExp(this.reservedWordsStrictBind.toString().replace(/await|async/g,"").replace("|/","/").replace("/|","/").replace("||","|")) ;
  376. this.inAsyncFunction = options.inAsyncFunction ;
  377. if (options.awaitAnywhere && options.inAsyncFunction)
  378. parser.raise(node.start,"The options awaitAnywhere and inAsyncFunction are mutually exclusive") ;
  379. return base.apply(this,arguments);
  380. }
  381. }) ;
  382. parser.extend("shouldParseExportStatement",function(base){
  383. return function(){
  384. if (this.type.label==='name' && this.value==='async' && test(asyncFunction,this)) {
  385. return true ;
  386. }
  387. return base.apply(this,arguments) ;
  388. }
  389. }) ;
  390. parser.extend("parseStatement",function(base){
  391. return function (declaration, topLevel) {
  392. var start = this.start;
  393. var startLoc = this.startLoc;
  394. if (this.type.label==='name') {
  395. if (test(asyncFunction,this,true)) {
  396. var wasAsync = this.inAsyncFunction ;
  397. try {
  398. this.inAsyncFunction = true ;
  399. this.next() ;
  400. var r = this.parseStatement(declaration, topLevel) ;
  401. r.async = true ;
  402. r.start = start;
  403. r.loc && (r.loc.start = startLoc);
  404. r.range && (r.range[0] = start);
  405. return r ;
  406. } finally {
  407. this.inAsyncFunction = wasAsync ;
  408. }
  409. } else if ((typeof options==="object" && options.asyncExits) && test(asyncExit,this)) {
  410. // NON-STANDARD EXTENSION iff. options.asyncExits is set, the
  411. // extensions 'async return <expr>?' and 'async throw <expr>?'
  412. // are enabled. In each case they are the standard ESTree nodes
  413. // with the flag 'async:true'
  414. this.next() ;
  415. var r = this.parseStatement(declaration, topLevel) ;
  416. r.async = true ;
  417. r.start = start;
  418. r.loc && (r.loc.start = startLoc);
  419. r.range && (r.range[0] = start);
  420. return r ;
  421. }
  422. }
  423. return base.apply(this,arguments);
  424. }
  425. }) ;
  426. parser.extend("parseIdent",function(base){
  427. return function(liberal){
  428. var id = base.apply(this,arguments);
  429. if (this.inAsyncFunction && id.name==='await') {
  430. if (arguments.length===0) {
  431. this.raise(id.start,"'await' is reserved within async functions") ;
  432. }
  433. }
  434. return id ;
  435. }
  436. }) ;
  437. parser.extend("parseExprAtom",function(base){
  438. return function(refShorthandDefaultPos){
  439. var start = this.start ;
  440. var startLoc = this.startLoc;
  441. var rhs,r = base.apply(this,arguments);
  442. if (r.type==='Identifier') {
  443. if (r.name==='async' && !hasLineTerminatorBeforeNext(this, r.end)) {
  444. // Is this really an async function?
  445. var isAsync = this.inAsyncFunction ;
  446. try {
  447. this.inAsyncFunction = true ;
  448. var pp = this ;
  449. var inBody = false ;
  450. var parseHooks = {
  451. parseFunctionBody:function(node,isArrowFunction){
  452. try {
  453. var wasInBody = inBody ;
  454. inBody = true ;
  455. return pp.parseFunctionBody.apply(this,arguments) ;
  456. } finally {
  457. inBody = wasInBody ;
  458. }
  459. },
  460. raise:function(){
  461. try {
  462. return pp.raise.apply(this,arguments) ;
  463. } catch(ex) {
  464. throw inBody?ex:NotAsync ;
  465. }
  466. }
  467. } ;
  468. rhs = subParse(this,this.start,parseHooks,true).parseExpression() ;
  469. if (rhs.type==='SequenceExpression')
  470. rhs = rhs.expressions[0] ;
  471. if (rhs.type === 'CallExpression')
  472. rhs = rhs.callee ;
  473. if (rhs.type==='FunctionExpression' || rhs.type==='FunctionDeclaration' || rhs.type==='ArrowFunctionExpression') {
  474. // Because we don't know if the top level parser supprts preserveParens, we have to re-parse
  475. // without it set
  476. rhs = subParse(this,this.start,parseHooks).parseExpression() ;
  477. if (rhs.type==='SequenceExpression')
  478. rhs = rhs.expressions[0] ;
  479. if (rhs.type === 'CallExpression')
  480. rhs = rhs.callee ;
  481. rhs.async = true ;
  482. rhs.start = start;
  483. rhs.loc && (rhs.loc.start = startLoc);
  484. rhs.range && (rhs.range[0] = start);
  485. this.pos = rhs.end;
  486. this.end = rhs.end ;
  487. this.endLoc = rhs.endLoc ;
  488. this.next();
  489. es7check(rhs) ;
  490. return rhs ;
  491. }
  492. } catch (ex) {
  493. if (ex!==NotAsync)
  494. throw ex ;
  495. }
  496. finally {
  497. this.inAsyncFunction = isAsync ;
  498. }
  499. }
  500. else if (r.name==='await') {
  501. var n = this.startNodeAt(r.start, r.loc && r.loc.start);
  502. if (this.inAsyncFunction) {
  503. rhs = this.parseExprSubscripts() ;
  504. n.operator = 'await' ;
  505. n.argument = rhs ;
  506. n = this.finishNodeAt(n,'AwaitExpression', rhs.end, rhs.loc && rhs.loc.end) ;
  507. es7check(n) ;
  508. return n ;
  509. }
  510. // NON-STANDARD EXTENSION iff. options.awaitAnywhere is true,
  511. // an 'AwaitExpression' is allowed anywhere the token 'await'
  512. // could not be an identifier with the name 'await'.
  513. // Look-ahead to see if this is really a property or label called async or await
  514. if (this.input.slice(r.end).match(atomOrPropertyOrLabel)) {
  515. if (!options.awaitAnywhere && this.options.sourceType === 'module')
  516. return this.raise(r.start,"'await' is reserved within modules") ;
  517. return r ; // This is a valid property name or label
  518. }
  519. if (typeof options==="object" && options.awaitAnywhere) {
  520. start = this.start ;
  521. rhs = subParse(this,start-4).parseExprSubscripts() ;
  522. if (rhs.end<=start) {
  523. rhs = subParse(this,start).parseExprSubscripts() ;
  524. n.operator = 'await' ;
  525. n.argument = rhs ;
  526. n = this.finishNodeAt(n,'AwaitExpression', rhs.end, rhs.loc && rhs.loc.end) ;
  527. this.pos = rhs.end;
  528. this.end = rhs.end ;
  529. this.endLoc = rhs.endLoc ;
  530. this.next();
  531. es7check(n) ;
  532. return n ;
  533. }
  534. }
  535. if (!options.awaitAnywhere && this.options.sourceType === 'module')
  536. return this.raise(r.start,"'await' is reserved within modules") ;
  537. }
  538. }
  539. return r ;
  540. }
  541. }) ;
  542. parser.extend('finishNodeAt',function(base){
  543. return function(node,type,pos,loc) {
  544. if (node.__asyncValue) {
  545. delete node.__asyncValue ;
  546. node.value.async = true ;
  547. }
  548. return base.apply(this,arguments) ;
  549. }
  550. }) ;
  551. parser.extend('finishNode',function(base){
  552. return function(node,type) {
  553. if (node.__asyncValue) {
  554. delete node.__asyncValue ;
  555. node.value.async = true ;
  556. }
  557. return base.apply(this,arguments) ;
  558. }
  559. }) ;
  560. var allowedPropSpecifiers = {
  561. get:true,
  562. set:true,
  563. async:true
  564. };
  565. parser.extend("parsePropertyName",function(base){
  566. return function (prop) {
  567. var prevName = prop.key && prop.key.name ;
  568. var key = base.apply(this,arguments) ;
  569. if (key.type === "Identifier" && (key.name === "async") && !hasLineTerminatorBeforeNext(this, key.end)) {
  570. // Look-ahead to see if this is really a property or label called async or await
  571. if (!this.input.slice(key.end).match(atomOrPropertyOrLabel)){
  572. // Cheese - eliminate the cases 'async get(){}' and async set(){}'
  573. if (matchAsyncGet.test(this.input.slice(key.end))) {
  574. key = base.apply(this,arguments) ;
  575. prop.__asyncValue = true ;
  576. } else {
  577. es7check(prop) ;
  578. if (prop.kind === 'set')
  579. this.raise(key.start,"'set <member>(value)' cannot be be async") ;
  580. key = base.apply(this,arguments) ;
  581. if (key.type==='Identifier') {
  582. if (key.name==='set')
  583. this.raise(key.start,"'set <member>(value)' cannot be be async") ;
  584. }
  585. prop.__asyncValue = true ;
  586. }
  587. }
  588. }
  589. return key;
  590. };
  591. }) ;
  592. parser.extend("parseClassMethod",function(base){
  593. return function (classBody, method, isGenerator) {
  594. var wasAsync ;
  595. if (method.__asyncValue) {
  596. if (method.kind==='constructor')
  597. this.raise(method.start,"class constructor() cannot be be async") ;
  598. wasAsync = this.inAsyncFunction ;
  599. this.inAsyncFunction = true ;
  600. }
  601. var r = base.apply(this,arguments) ;
  602. this.inAsyncFunction = wasAsync ;
  603. return r ;
  604. }
  605. }) ;
  606. parser.extend("parseMethod",function(base){
  607. return function (isGenerator) {
  608. var wasAsync ;
  609. if (this.__currentProperty && this.__currentProperty.__asyncValue) {
  610. wasAsync = this.inAsyncFunction ;
  611. this.inAsyncFunction = true ;
  612. }
  613. var r = base.apply(this,arguments) ;
  614. this.inAsyncFunction = wasAsync ;
  615. return r ;
  616. }
  617. }) ;
  618. parser.extend("parsePropertyValue",function(base){
  619. return function (prop, isPattern, isGenerator, startPos, startLoc, refDestructuringErrors) {
  620. var prevProp = this.__currentProperty ;
  621. this.__currentProperty = prop ;
  622. var wasAsync ;
  623. if (prop.__asyncValue) {
  624. wasAsync = this.inAsyncFunction ;
  625. this.inAsyncFunction = true ;
  626. }
  627. var r = base.apply(this,arguments) ;
  628. this.inAsyncFunction = wasAsync ;
  629. this.__currentProperty = prevProp ;
  630. return r ;
  631. }
  632. }) ;
  633. }
  634. module.exports = asyncAwaitPlugin ;
  635. },{}],4:[function(_dereq_,module,exports){
  636. var asyncExit = /^async[\t ]+(return|throw)/ ;
  637. var atomOrPropertyOrLabel = /^\s*[):;]/ ;
  638. var removeComments = /([^\n])\/\*(\*(?!\/)|[^\n*])*\*\/([^\n])/g ;
  639. function hasLineTerminatorBeforeNext(st, since) {
  640. return st.lineStart >= since;
  641. }
  642. function test(regex,st,noComment) {
  643. var src = st.input.slice(st.start) ;
  644. if (noComment) {
  645. src = src.replace(removeComments,"$1 $3") ;
  646. }
  647. return regex.test(src);
  648. }
  649. /* Create a new parser derived from the specified parser, so that in the
  650. * event of an error we can back out and try again */
  651. function subParse(parser, pos, extensions) {
  652. var p = new parser.constructor(parser.options, parser.input, pos);
  653. if (extensions)
  654. for (var k in extensions)
  655. p[k] = extensions[k] ;
  656. var src = parser ;
  657. var dest = p ;
  658. ['inFunction','inAsync','inGenerator','inModule'].forEach(function(k){
  659. if (k in src)
  660. dest[k] = src[k] ;
  661. }) ;
  662. p.nextToken();
  663. return p;
  664. }
  665. function asyncAwaitPlugin (parser,options){
  666. if (!options || typeof options !== "object")
  667. options = {} ;
  668. parser.extend("parse",function(base){
  669. return function(){
  670. this.inAsync = options.inAsyncFunction ;
  671. if (options.awaitAnywhere && options.inAsyncFunction)
  672. parser.raise(node.start,"The options awaitAnywhere and inAsyncFunction are mutually exclusive") ;
  673. return base.apply(this,arguments);
  674. }
  675. }) ;
  676. parser.extend("parseStatement",function(base){
  677. return function (declaration, topLevel) {
  678. var start = this.start;
  679. var startLoc = this.startLoc;
  680. if (this.type.label==='name') {
  681. if ((options.asyncExits) && test(asyncExit,this)) {
  682. // TODO: Ensure this function is itself nested in an async function or Method
  683. this.next() ;
  684. var r = this.parseStatement(declaration, topLevel) ;
  685. r.async = true ;
  686. r.start = start;
  687. r.loc && (r.loc.start = startLoc);
  688. r.range && (r.range[0] = start);
  689. return r ;
  690. }
  691. }
  692. return base.apply(this,arguments);
  693. }
  694. }) ;
  695. parser.extend("parseIdent",function(base){
  696. return function(liberal) {
  697. if (this.options.sourceType==='module' && this.options.ecmaVersion >= 8 && options.awaitAnywhere)
  698. return base.call(this,true) ; // Force liberal mode if awaitAnywhere is set
  699. return base.apply(this,arguments) ;
  700. }
  701. }) ;
  702. parser.extend("parseExprAtom",function(base){
  703. var NotAsync = {};
  704. return function(refShorthandDefaultPos){
  705. var start = this.start ;
  706. var startLoc = this.startLoc;
  707. var rhs,r = base.apply(this,arguments);
  708. if (r.type==='Identifier') {
  709. if (r.name==='await' && !this.inAsync) {
  710. if (options.awaitAnywhere) {
  711. var n = this.startNodeAt(r.start, r.loc && r.loc.start);
  712. start = this.start ;
  713. var parseHooks = {
  714. raise:function(){
  715. try {
  716. return pp.raise.apply(this,arguments) ;
  717. } catch(ex) {
  718. throw /*inBody?ex:*/NotAsync ;
  719. }
  720. }
  721. } ;
  722. try {
  723. rhs = subParse(this,start-4,parseHooks).parseExprSubscripts() ;
  724. if (rhs.end<=start) {
  725. rhs = subParse(this,start,parseHooks).parseExprSubscripts() ;
  726. n.argument = rhs ;
  727. n = this.finishNodeAt(n,'AwaitExpression', rhs.end, rhs.loc && rhs.loc.end) ;
  728. this.pos = rhs.end;
  729. this.end = rhs.end ;
  730. this.endLoc = rhs.endLoc ;
  731. this.next();
  732. return n ;
  733. }
  734. } catch (ex) {
  735. if (ex===NotAsync)
  736. return r ;
  737. throw ex ;
  738. }
  739. }
  740. }
  741. }
  742. return r ;
  743. }
  744. }) ;
  745. var allowedPropValues = {
  746. undefined:true,
  747. get:true,
  748. set:true,
  749. "static":true,
  750. async:true,
  751. constructor:true
  752. };
  753. parser.extend("parsePropertyName",function(base){
  754. return function (prop) {
  755. var prevName = prop.key && prop.key.name ;
  756. var key = base.apply(this,arguments) ;
  757. if (this.value==='get') {
  758. prop.__maybeStaticAsyncGetter = true ;
  759. }
  760. var next ;
  761. if (allowedPropValues[this.value])
  762. return key ;
  763. if (key.type === "Identifier" && (key.name === "async" || prevName === "async") && !hasLineTerminatorBeforeNext(this, key.end)
  764. // Look-ahead to see if this is really a property or label called async or await
  765. && !this.input.slice(key.end).match(atomOrPropertyOrLabel)) {
  766. if (prop.kind === 'set' || key.name === 'set')
  767. this.raise(key.start,"'set <member>(value)' cannot be be async") ;
  768. else {
  769. this.__isAsyncProp = true ;
  770. key = base.apply(this,arguments) ;
  771. if (key.type==='Identifier') {
  772. if (key.name==='set')
  773. this.raise(key.start,"'set <member>(value)' cannot be be async") ;
  774. }
  775. }
  776. } else {
  777. delete prop.__maybeStaticAsyncGetter ;
  778. }
  779. return key;
  780. };
  781. }) ;
  782. parser.extend("parseClassMethod",function(base){
  783. return function (classBody, method, isGenerator) {
  784. var r = base.apply(this,arguments) ;
  785. if (method.__maybeStaticAsyncGetter) {
  786. delete method.__maybeStaticAsyncGetter ;
  787. if (method.key.name!=='get')
  788. method.kind = "get" ;
  789. }
  790. return r ;
  791. }
  792. }) ;
  793. parser.extend("parseFunctionBody",function(base){
  794. return function (node, isArrowFunction) {
  795. var wasAsync = this.inAsync ;
  796. if (this.__isAsyncProp) {
  797. node.async = true ;
  798. this.inAsync = true ;
  799. delete this.__isAsyncProp ;
  800. }
  801. var r = base.apply(this,arguments) ;
  802. this.inAsync = wasAsync ;
  803. return r ;
  804. }
  805. }) ;
  806. }
  807. module.exports = asyncAwaitPlugin ;
  808. },{}],5:[function(_dereq_,module,exports){
  809. (function (global, factory) {
  810. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  811. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  812. (factory((global.acorn = {})));
  813. }(this, (function (exports) { 'use strict';
  814. // Reserved word lists for various dialects of the language
  815. var reservedWords = {
  816. 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
  817. 5: "class enum extends super const export import",
  818. 6: "enum",
  819. strict: "implements interface let package private protected public static yield",
  820. strictBind: "eval arguments"
  821. };
  822. // And the keywords
  823. var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
  824. var keywords = {
  825. 5: ecma5AndLessKeywords,
  826. 6: ecma5AndLessKeywords + " const class extends export import super"
  827. };
  828. var keywordRelationalOperator = /^in(stanceof)?$/;
  829. // ## Character categories
  830. // Big ugly regular expressions that match characters in the
  831. // whitespace, identifier, and identifier-start categories. These
  832. // are only applied when a character is found to actually have a
  833. // code point above 128.
  834. // Generated by `bin/generate-identifier-regex.js`.
  835. var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7b9\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
  836. var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
  837. var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  838. var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  839. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  840. // These are a run-length and offset encoded representation of the
  841. // >0xffff code points that are a valid part of identifiers. The
  842. // offset starts at 0x10000, and each pair of numbers represents an
  843. // offset to the next range, and then a size of the range. They were
  844. // generated by bin/generate-identifier-regex.js
  845. // eslint-disable-next-line comma-spacing
  846. var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,190,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,26,230,43,117,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,68,12,0,67,12,65,1,31,6129,15,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541];
  847. // eslint-disable-next-line comma-spacing
  848. var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239];
  849. // This has a complexity linear to the value of the code. The
  850. // assumption is that looking up astral identifier characters is
  851. // rare.
  852. function isInAstralSet(code, set) {
  853. var pos = 0x10000;
  854. for (var i = 0; i < set.length; i += 2) {
  855. pos += set[i];
  856. if (pos > code) { return false }
  857. pos += set[i + 1];
  858. if (pos >= code) { return true }
  859. }
  860. }
  861. // Test whether a given character code starts an identifier.
  862. function isIdentifierStart(code, astral) {
  863. if (code < 65) { return code === 36 }
  864. if (code < 91) { return true }
  865. if (code < 97) { return code === 95 }
  866. if (code < 123) { return true }
  867. if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) }
  868. if (astral === false) { return false }
  869. return isInAstralSet(code, astralIdentifierStartCodes)
  870. }
  871. // Test whether a given character is part of an identifier.
  872. function isIdentifierChar(code, astral) {
  873. if (code < 48) { return code === 36 }
  874. if (code < 58) { return true }
  875. if (code < 65) { return false }
  876. if (code < 91) { return true }
  877. if (code < 97) { return code === 95 }
  878. if (code < 123) { return true }
  879. if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) }
  880. if (astral === false) { return false }
  881. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)
  882. }
  883. // ## Token types
  884. // The assignment of fine-grained, information-carrying type objects
  885. // allows the tokenizer to store the information it has about a
  886. // token in a way that is very cheap for the parser to look up.
  887. // All token type variables start with an underscore, to make them
  888. // easy to recognize.
  889. // The `beforeExpr` property is used to disambiguate between regular
  890. // expressions and divisions. It is set on all token types that can
  891. // be followed by an expression (thus, a slash after them would be a
  892. // regular expression).
  893. //
  894. // The `startsExpr` property is used to check if the token ends a
  895. // `yield` expression. It is set on all token types that either can
  896. // directly start an expression (like a quotation mark) or can
  897. // continue an expression (like the body of a string).
  898. //
  899. // `isLoop` marks a keyword as starting a loop, which is important
  900. // to know when parsing a label, in order to allow or disallow
  901. // continue jumps to that label.
  902. var TokenType = function TokenType(label, conf) {
  903. if ( conf === void 0 ) conf = {};
  904. this.label = label;
  905. this.keyword = conf.keyword;
  906. this.beforeExpr = !!conf.beforeExpr;
  907. this.startsExpr = !!conf.startsExpr;
  908. this.isLoop = !!conf.isLoop;
  909. this.isAssign = !!conf.isAssign;
  910. this.prefix = !!conf.prefix;
  911. this.postfix = !!conf.postfix;
  912. this.binop = conf.binop || null;
  913. this.updateContext = null;
  914. };
  915. function binop(name, prec) {
  916. return new TokenType(name, {beforeExpr: true, binop: prec})
  917. }
  918. var beforeExpr = {beforeExpr: true};
  919. var startsExpr = {startsExpr: true};
  920. // Map keyword names to token types.
  921. var keywords$1 = {};
  922. // Succinct definitions of keyword token types
  923. function kw(name, options) {
  924. if ( options === void 0 ) options = {};
  925. options.keyword = name;
  926. return keywords$1[name] = new TokenType(name, options)
  927. }
  928. var types = {
  929. num: new TokenType("num", startsExpr),
  930. regexp: new TokenType("regexp", startsExpr),
  931. string: new TokenType("string", startsExpr),
  932. name: new TokenType("name", startsExpr),
  933. eof: new TokenType("eof"),
  934. // Punctuation token types.
  935. bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}),
  936. bracketR: new TokenType("]"),
  937. braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}),
  938. braceR: new TokenType("}"),
  939. parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}),
  940. parenR: new TokenType(")"),
  941. comma: new TokenType(",", beforeExpr),
  942. semi: new TokenType(";", beforeExpr),
  943. colon: new TokenType(":", beforeExpr),
  944. dot: new TokenType("."),
  945. question: new TokenType("?", beforeExpr),
  946. arrow: new TokenType("=>", beforeExpr),
  947. template: new TokenType("template"),
  948. invalidTemplate: new TokenType("invalidTemplate"),
  949. ellipsis: new TokenType("...", beforeExpr),
  950. backQuote: new TokenType("`", startsExpr),
  951. dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
  952. // Operators. These carry several kinds of properties to help the
  953. // parser use them properly (the presence of these properties is
  954. // what categorizes them as operators).
  955. //
  956. // `binop`, when present, specifies that this operator is a binary
  957. // operator, and will refer to its precedence.
  958. //
  959. // `prefix` and `postfix` mark the operator as a prefix or postfix
  960. // unary operator.
  961. //
  962. // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
  963. // binary operators with a very low precedence, that should result
  964. // in AssignmentExpression nodes.
  965. eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
  966. assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
  967. incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
  968. prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
  969. logicalOR: binop("||", 1),
  970. logicalAND: binop("&&", 2),
  971. bitwiseOR: binop("|", 3),
  972. bitwiseXOR: binop("^", 4),
  973. bitwiseAND: binop("&", 5),
  974. equality: binop("==/!=/===/!==", 6),
  975. relational: binop("</>/<=/>=", 7),
  976. bitShift: binop("<</>>/>>>", 8),
  977. plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
  978. modulo: binop("%", 10),
  979. star: binop("*", 10),
  980. slash: binop("/", 10),
  981. starstar: new TokenType("**", {beforeExpr: true}),
  982. // Keyword token types.
  983. _break: kw("break"),
  984. _case: kw("case", beforeExpr),
  985. _catch: kw("catch"),
  986. _continue: kw("continue"),
  987. _debugger: kw("debugger"),
  988. _default: kw("default", beforeExpr),
  989. _do: kw("do", {isLoop: true, beforeExpr: true}),
  990. _else: kw("else", beforeExpr),
  991. _finally: kw("finally"),
  992. _for: kw("for", {isLoop: true}),
  993. _function: kw("function", startsExpr),
  994. _if: kw("if"),
  995. _return: kw("return", beforeExpr),
  996. _switch: kw("switch"),
  997. _throw: kw("throw", beforeExpr),
  998. _try: kw("try"),
  999. _var: kw("var"),
  1000. _const: kw("const"),
  1001. _while: kw("while", {isLoop: true}),
  1002. _with: kw("with"),
  1003. _new: kw("new", {beforeExpr: true, startsExpr: true}),
  1004. _this: kw("this", startsExpr),
  1005. _super: kw("super", startsExpr),
  1006. _class: kw("class", startsExpr),
  1007. _extends: kw("extends", beforeExpr),
  1008. _export: kw("export"),
  1009. _import: kw("import"),
  1010. _null: kw("null", startsExpr),
  1011. _true: kw("true", startsExpr),
  1012. _false: kw("false", startsExpr),
  1013. _in: kw("in", {beforeExpr: true, binop: 7}),
  1014. _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}),
  1015. _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}),
  1016. _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}),
  1017. _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
  1018. };
  1019. // Matches a whole line break (where CRLF is considered a single
  1020. // line break). Used to count lines.
  1021. var lineBreak = /\r\n?|\n|\u2028|\u2029/;
  1022. var lineBreakG = new RegExp(lineBreak.source, "g");
  1023. function isNewLine(code, ecma2019String) {
  1024. return code === 10 || code === 13 || (!ecma2019String && (code === 0x2028 || code === 0x2029))
  1025. }
  1026. var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
  1027. var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  1028. var ref = Object.prototype;
  1029. var hasOwnProperty = ref.hasOwnProperty;
  1030. var toString = ref.toString;
  1031. // Checks if an object has a property.
  1032. function has(obj, propName) {
  1033. return hasOwnProperty.call(obj, propName)
  1034. }
  1035. var isArray = Array.isArray || (function (obj) { return (
  1036. toString.call(obj) === "[object Array]"
  1037. ); });
  1038. // These are used when `options.locations` is on, for the
  1039. // `startLoc` and `endLoc` properties.
  1040. var Position = function Position(line, col) {
  1041. this.line = line;
  1042. this.column = col;
  1043. };
  1044. Position.prototype.offset = function offset (n) {
  1045. return new Position(this.line, this.column + n)
  1046. };
  1047. var SourceLocation = function SourceLocation(p, start, end) {
  1048. this.start = start;
  1049. this.end = end;
  1050. if (p.sourceFile !== null) { this.source = p.sourceFile; }
  1051. };
  1052. // The `getLineInfo` function is mostly useful when the
  1053. // `locations` option is off (for performance reasons) and you
  1054. // want to find the line/column position for a given character
  1055. // offset. `input` should be the code string that the offset refers
  1056. // into.
  1057. function getLineInfo(input, offset) {
  1058. for (var line = 1, cur = 0;;) {
  1059. lineBreakG.lastIndex = cur;
  1060. var match = lineBreakG.exec(input);
  1061. if (match && match.index < offset) {
  1062. ++line;
  1063. cur = match.index + match[0].length;
  1064. } else {
  1065. return new Position(line, offset - cur)
  1066. }
  1067. }
  1068. }
  1069. // A second optional argument can be given to further configure
  1070. // the parser process. These options are recognized:
  1071. var defaultOptions = {
  1072. // `ecmaVersion` indicates the ECMAScript version to parse. Must
  1073. // be either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support
  1074. // for strict mode, the set of reserved words, and support for
  1075. // new syntax features. The default is 7.
  1076. ecmaVersion: 7,
  1077. // `sourceType` indicates the mode the code should be parsed in.
  1078. // Can be either `"script"` or `"module"`. This influences global
  1079. // strict mode and parsing of `import` and `export` declarations.
  1080. sourceType: "script",
  1081. // `onInsertedSemicolon` can be a callback that will be called
  1082. // when a semicolon is automatically inserted. It will be passed
  1083. // th position of the comma as an offset, and if `locations` is
  1084. // enabled, it is given the location as a `{line, column}` object
  1085. // as second argument.
  1086. onInsertedSemicolon: null,
  1087. // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
  1088. // trailing commas.
  1089. onTrailingComma: null,
  1090. // By default, reserved words are only enforced if ecmaVersion >= 5.
  1091. // Set `allowReserved` to a boolean value to explicitly turn this on
  1092. // an off. When this option has the value "never", reserved words
  1093. // and keywords can also not be used as property names.
  1094. allowReserved: null,
  1095. // When enabled, a return at the top level is not considered an
  1096. // error.
  1097. allowReturnOutsideFunction: false,
  1098. // When enabled, import/export statements are not constrained to
  1099. // appearing at the top of the program.
  1100. allowImportExportEverywhere: false,
  1101. // When enabled, await identifiers are allowed to appear at the top-level scope,
  1102. // but they are still not allowed in non-async functions.
  1103. allowAwaitOutsideFunction: false,
  1104. // When enabled, hashbang directive in the beginning of file
  1105. // is allowed and treated as a line comment.
  1106. allowHashBang: false,
  1107. // When `locations` is on, `loc` properties holding objects with
  1108. // `start` and `end` properties in `{line, column}` form (with
  1109. // line being 1-based and column 0-based) will be attached to the
  1110. // nodes.
  1111. locations: false,
  1112. // A function can be passed as `onToken` option, which will
  1113. // cause Acorn to call that function with object in the same
  1114. // format as tokens returned from `tokenizer().getToken()`. Note
  1115. // that you are not allowed to call the parser from the
  1116. // callback—that will corrupt its internal state.
  1117. onToken: null,
  1118. // A function can be passed as `onComment` option, which will
  1119. // cause Acorn to call that function with `(block, text, start,
  1120. // end)` parameters whenever a comment is skipped. `block` is a
  1121. // boolean indicating whether this is a block (`/* */`) comment,
  1122. // `text` is the content of the comment, and `start` and `end` are
  1123. // character offsets that denote the start and end of the comment.
  1124. // When the `locations` option is on, two more parameters are
  1125. // passed, the full `{line, column}` locations of the start and
  1126. // end of the comments. Note that you are not allowed to call the
  1127. // parser from the callback—that will corrupt its internal state.
  1128. onComment: null,
  1129. // Nodes have their start and end characters offsets recorded in
  1130. // `start` and `end` properties (directly on the node, rather than
  1131. // the `loc` object, which holds line/column data. To also add a
  1132. // [semi-standardized][range] `range` property holding a `[start,
  1133. // end]` array with the same numbers, set the `ranges` option to
  1134. // `true`.
  1135. //
  1136. // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
  1137. ranges: false,
  1138. // It is possible to parse multiple files into a single AST by
  1139. // passing the tree produced by parsing the first file as
  1140. // `program` option in subsequent parses. This will add the
  1141. // toplevel forms of the parsed file to the `Program` (top) node
  1142. // of an existing parse tree.
  1143. program: null,
  1144. // When `locations` is on, you can pass this to record the source
  1145. // file in every node's `loc` object.
  1146. sourceFile: null,
  1147. // This value, if given, is stored in every node, whether
  1148. // `locations` is on or off.
  1149. directSourceFile: null,
  1150. // When enabled, parenthesized expressions are represented by
  1151. // (non-standard) ParenthesizedExpression nodes
  1152. preserveParens: false,
  1153. plugins: {}
  1154. };
  1155. // Interpret and default an options object
  1156. function getOptions(opts) {
  1157. var options = {};
  1158. for (var opt in defaultOptions)
  1159. { options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]; }
  1160. if (options.ecmaVersion >= 2015)
  1161. { options.ecmaVersion -= 2009; }
  1162. if (options.allowReserved == null)
  1163. { options.allowReserved = options.ecmaVersion < 5; }
  1164. if (isArray(options.onToken)) {
  1165. var tokens = options.onToken;
  1166. options.onToken = function (token) { return tokens.push(token); };
  1167. }
  1168. if (isArray(options.onComment))
  1169. { options.onComment = pushComment(options, options.onComment); }
  1170. return options
  1171. }
  1172. function pushComment(options, array) {
  1173. return function(block, text, start, end, startLoc, endLoc) {
  1174. var comment = {
  1175. type: block ? "Block" : "Line",
  1176. value: text,
  1177. start: start,
  1178. end: end
  1179. };
  1180. if (options.locations)
  1181. { comment.loc = new SourceLocation(this, startLoc, endLoc); }
  1182. if (options.ranges)
  1183. { comment.range = [start, end]; }
  1184. array.push(comment);
  1185. }
  1186. }
  1187. // Registered plugins
  1188. var plugins = {};
  1189. function keywordRegexp(words) {
  1190. return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")
  1191. }
  1192. var Parser = function Parser(options, input, startPos) {
  1193. this.options = options = getOptions(options);
  1194. this.sourceFile = options.sourceFile;
  1195. this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5]);
  1196. var reserved = "";
  1197. if (!options.allowReserved) {
  1198. for (var v = options.ecmaVersion;; v--)
  1199. { if (reserved = reservedWords[v]) { break } }
  1200. if (options.sourceType === "module") { reserved += " await"; }
  1201. }
  1202. this.reservedWords = keywordRegexp(reserved);
  1203. var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
  1204. this.reservedWordsStrict = keywordRegexp(reservedStrict);
  1205. this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind);
  1206. this.input = String(input);
  1207. // Used to signal to callers of `readWord1` whether the word
  1208. // contained any escape sequences. This is needed because words with
  1209. // escape sequences must not be interpreted as keywords.
  1210. this.containsEsc = false;
  1211. // Load plugins
  1212. this.loadPlugins(options.plugins);
  1213. // Set up token state
  1214. // The current position of the tokenizer in the input.
  1215. if (startPos) {
  1216. this.pos = startPos;
  1217. this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
  1218. this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
  1219. } else {
  1220. this.pos = this.lineStart = 0;
  1221. this.curLine = 1;
  1222. }
  1223. // Properties of the current token:
  1224. // Its type
  1225. this.type = types.eof;
  1226. // For tokens that include more information than their type, the value
  1227. this.value = null;
  1228. // Its start and end offset
  1229. this.start = this.end = this.pos;
  1230. // And, if locations are used, the {line, column} object
  1231. // corresponding to those offsets
  1232. this.startLoc = this.endLoc = this.curPosition();
  1233. // Position information for the previous token
  1234. this.lastTokEndLoc = this.lastTokStartLoc = null;
  1235. this.lastTokStart = this.lastTokEnd = this.pos;
  1236. // The context stack is used to superficially track syntactic
  1237. // context to predict whether a regular expression is allowed in a
  1238. // given position.
  1239. this.context = this.initialContext();
  1240. this.exprAllowed = true;
  1241. // Figure out if it's a module code.
  1242. this.inModule = options.sourceType === "module";
  1243. this.strict = this.inModule || this.strictDirective(this.pos);
  1244. // Used to signify the start of a potential arrow function
  1245. this.potentialArrowAt = -1;
  1246. // Flags to track whether we are in a function, a generator, an async function.
  1247. this.inFunction = this.inGenerator = this.inAsync = false;
  1248. // Positions to delayed-check that yield/await does not exist in default parameters.
  1249. this.yieldPos = this.awaitPos = 0;
  1250. // Labels in scope.
  1251. this.labels = [];
  1252. // If enabled, skip leading hashbang line.
  1253. if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!")
  1254. { this.skipLineComment(2); }
  1255. // Scope tracking for duplicate variable names (see scope.js)
  1256. this.scopeStack = [];
  1257. this.enterFunctionScope();
  1258. // For RegExp validation
  1259. this.regexpState = null;
  1260. };
  1261. // DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them
  1262. Parser.prototype.isKeyword = function isKeyword (word) { return this.keywords.test(word) };
  1263. Parser.prototype.isReservedWord = function isReservedWord (word) { return this.reservedWords.test(word) };
  1264. Parser.prototype.extend = function extend (name, f) {
  1265. this[name] = f(this[name]);
  1266. };
  1267. Parser.prototype.loadPlugins = function loadPlugins (pluginConfigs) {
  1268. var this$1 = this;
  1269. for (var name in pluginConfigs) {
  1270. var plugin = plugins[name];
  1271. if (!plugin) { throw new Error("Plugin '" + name + "' not found") }
  1272. plugin(this$1, pluginConfigs[name]);
  1273. }
  1274. };
  1275. Parser.prototype.parse = function parse () {
  1276. var node = this.options.program || this.startNode();
  1277. this.nextToken();
  1278. return this.parseTopLevel(node)
  1279. };
  1280. var pp = Parser.prototype;
  1281. // ## Parser utilities
  1282. var literal = /^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;
  1283. pp.strictDirective = function(start) {
  1284. var this$1 = this;
  1285. for (;;) {
  1286. skipWhiteSpace.lastIndex = start;
  1287. start += skipWhiteSpace.exec(this$1.input)[0].length;
  1288. var match = literal.exec(this$1.input.slice(start));
  1289. if (!match) { return false }
  1290. if ((match[1] || match[2]) === "use strict") { return true }
  1291. start += match[0].length;
  1292. }
  1293. };
  1294. // Predicate that tests whether the next token is of the given
  1295. // type, and if yes, consumes it as a side effect.
  1296. pp.eat = function(type) {
  1297. if (this.type === type) {
  1298. this.next();
  1299. return true
  1300. } else {
  1301. return false
  1302. }
  1303. };
  1304. // Tests whether parsed token is a contextual keyword.
  1305. pp.isContextual = function(name) {
  1306. return this.type === types.name && this.value === name && !this.containsEsc
  1307. };
  1308. // Consumes contextual keyword if possible.
  1309. pp.eatContextual = function(name) {
  1310. if (!this.isContextual(name)) { return false }
  1311. this.next();
  1312. return true
  1313. };
  1314. // Asserts that following token is given contextual keyword.
  1315. pp.expectContextual = function(name) {
  1316. if (!this.eatContextual(name)) { this.unexpected(); }
  1317. };
  1318. // Test whether a semicolon can be inserted at the current position.
  1319. pp.canInsertSemicolon = function() {
  1320. return this.type === types.eof ||
  1321. this.type === types.braceR ||
  1322. lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
  1323. };
  1324. pp.insertSemicolon = function() {
  1325. if (this.canInsertSemicolon()) {
  1326. if (this.options.onInsertedSemicolon)
  1327. { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }
  1328. return true
  1329. }
  1330. };
  1331. // Consume a semicolon, or, failing that, see if we are allowed to
  1332. // pretend that there is a semicolon at this position.
  1333. pp.semicolon = function() {
  1334. if (!this.eat(types.semi) && !this.insertSemicolon()) { this.unexpected(); }
  1335. };
  1336. pp.afterTrailingComma = function(tokType, notNext) {
  1337. if (this.type === tokType) {
  1338. if (this.options.onTrailingComma)
  1339. { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }
  1340. if (!notNext)
  1341. { this.next(); }
  1342. return true
  1343. }
  1344. };
  1345. // Expect a token of a given type. If found, consume it, otherwise,
  1346. // raise an unexpected token error.
  1347. pp.expect = function(type) {
  1348. this.eat(type) || this.unexpected();
  1349. };
  1350. // Raise an unexpected token error.
  1351. pp.unexpected = function(pos) {
  1352. this.raise(pos != null ? pos : this.start, "Unexpected token");
  1353. };
  1354. function DestructuringErrors() {
  1355. this.shorthandAssign =
  1356. this.trailingComma =
  1357. this.parenthesizedAssign =
  1358. this.parenthesizedBind =
  1359. this.doubleProto =
  1360. -1;
  1361. }
  1362. pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
  1363. if (!refDestructuringErrors) { return }
  1364. if (refDestructuringErrors.trailingComma > -1)
  1365. { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
  1366. var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
  1367. if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
  1368. };
  1369. pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
  1370. if (!refDestructuringErrors) { return false }
  1371. var shorthandAssign = refDestructuringErrors.shorthandAssign;
  1372. var doubleProto = refDestructuringErrors.doubleProto;
  1373. if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 }
  1374. if (shorthandAssign >= 0)
  1375. { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); }
  1376. if (doubleProto >= 0)
  1377. { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); }
  1378. };
  1379. pp.checkYieldAwaitInDefaultParams = function() {
  1380. if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
  1381. { this.raise(this.yieldPos, "Yield expression cannot be a default value"); }
  1382. if (this.awaitPos)
  1383. { this.raise(this.awaitPos, "Await expression cannot be a default value"); }
  1384. };
  1385. pp.isSimpleAssignTarget = function(expr) {
  1386. if (expr.type === "ParenthesizedExpression")
  1387. { return this.isSimpleAssignTarget(expr.expression) }
  1388. return expr.type === "Identifier" || expr.type === "MemberExpression"
  1389. };
  1390. var pp$1 = Parser.prototype;
  1391. // ### Statement parsing
  1392. // Parse a program. Initializes the parser, reads any number of
  1393. // statements, and wraps them in a Program node. Optionally takes a
  1394. // `program` argument. If present, the statements will be appended
  1395. // to its body instead of creating a new node.
  1396. pp$1.parseTopLevel = function(node) {
  1397. var this$1 = this;
  1398. var exports = {};
  1399. if (!node.body) { node.body = []; }
  1400. while (this.type !== types.eof) {
  1401. var stmt = this$1.parseStatement(true, true, exports);
  1402. node.body.push(stmt);
  1403. }
  1404. this.adaptDirectivePrologue(node.body);
  1405. this.next();
  1406. if (this.options.ecmaVersion >= 6) {
  1407. node.sourceType = this.options.sourceType;
  1408. }
  1409. return this.finishNode(node, "Program")
  1410. };
  1411. var loopLabel = {kind: "loop"};
  1412. var switchLabel = {kind: "switch"};
  1413. pp$1.isLet = function() {
  1414. if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
  1415. skipWhiteSpace.lastIndex = this.pos;
  1416. var skip = skipWhiteSpace.exec(this.input);
  1417. var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
  1418. if (nextCh === 91 || nextCh === 123) { return true } // '{' and '['
  1419. if (isIdentifierStart(nextCh, true)) {
  1420. var pos = next + 1;
  1421. while (isIdentifierChar(this.input.charCodeAt(pos), true)) { ++pos; }
  1422. var ident = this.input.slice(next, pos);
  1423. if (!keywordRelationalOperator.test(ident)) { return true }
  1424. }
  1425. return false
  1426. };
  1427. // check 'async [no LineTerminator here] function'
  1428. // - 'async /*foo*/ function' is OK.
  1429. // - 'async /*\n*/ function' is invalid.
  1430. pp$1.isAsyncFunction = function() {
  1431. if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
  1432. { return false }
  1433. skipWhiteSpace.lastIndex = this.pos;
  1434. var skip = skipWhiteSpace.exec(this.input);
  1435. var next = this.pos + skip[0].length;
  1436. return !lineBreak.test(this.input.slice(this.pos, next)) &&
  1437. this.input.slice(next, next + 8) === "function" &&
  1438. (next + 8 === this.input.length || !isIdentifierChar(this.input.charAt(next + 8)))
  1439. };
  1440. // Parse a single statement.
  1441. //
  1442. // If expecting a statement and finding a slash operator, parse a
  1443. // regular expression literal. This is to handle cases like
  1444. // `if (foo) /blah/.exec(foo)`, where looking at the previous token
  1445. // does not help.
  1446. pp$1.parseStatement = function(declaration, topLevel, exports) {
  1447. var starttype = this.type, node = this.startNode(), kind;
  1448. if (this.isLet()) {
  1449. starttype = types._var;
  1450. kind = "let";
  1451. }
  1452. // Most types of statements are recognized by the keyword they
  1453. // start with. Many are trivial to parse, some require a bit of
  1454. // complexity.
  1455. switch (starttype) {
  1456. case types._break: case types._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
  1457. case types._debugger: return this.parseDebuggerStatement(node)
  1458. case types._do: return this.parseDoStatement(node)
  1459. case types._for: return this.parseForStatement(node)
  1460. case types._function:
  1461. if (!declaration && this.options.ecmaVersion >= 6) { this.unexpected(); }
  1462. return this.parseFunctionStatement(node, false)
  1463. case types._class:
  1464. if (!declaration) { this.unexpected(); }
  1465. return this.parseClass(node, true)
  1466. case types._if: return this.parseIfStatement(node)
  1467. case types._return: return this.parseReturnStatement(node)
  1468. case types._switch: return this.parseSwitchStatement(node)
  1469. case types._throw: return this.parseThrowStatement(node)
  1470. case types._try: return this.parseTryStatement(node)
  1471. case types._const: case types._var:
  1472. kind = kind || this.value;
  1473. if (!declaration && kind !== "var") { this.unexpected(); }
  1474. return this.parseVarStatement(node, kind)
  1475. case types._while: return this.parseWhileStatement(node)
  1476. case types._with: return this.parseWithStatement(node)
  1477. case types.braceL: return this.parseBlock()
  1478. case types.semi: return this.parseEmptyStatement(node)
  1479. case types._export:
  1480. case types._import:
  1481. if (!this.options.allowImportExportEverywhere) {
  1482. if (!topLevel)
  1483. { this.raise(this.start, "'import' and 'export' may only appear at the top level"); }
  1484. if (!this.inModule)
  1485. { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
  1486. }
  1487. return starttype === types._import ? this.parseImport(node) : this.parseExport(node, exports)
  1488. // If the statement does not start with a statement keyword or a
  1489. // brace, it's an ExpressionStatement or LabeledStatement. We
  1490. // simply start parsing an expression, and afterwards, if the
  1491. // next token is a colon and the expression was a simple
  1492. // Identifier node, we switch to interpreting it as a label.
  1493. default:
  1494. if (this.isAsyncFunction()) {
  1495. if (!declaration) { this.unexpected(); }
  1496. this.next();
  1497. return this.parseFunctionStatement(node, true)
  1498. }
  1499. var maybeName = this.value, expr = this.parseExpression();
  1500. if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon))
  1501. { return this.parseLabeledStatement(node, maybeName, expr) }
  1502. else { return this.parseExpressionStatement(node, expr) }
  1503. }
  1504. };
  1505. pp$1.parseBreakContinueStatement = function(node, keyword) {
  1506. var this$1 = this;
  1507. var isBreak = keyword === "break";
  1508. this.next();
  1509. if (this.eat(types.semi) || this.insertSemicolon()) { node.label = null; }
  1510. else if (this.type !== types.name) { this.unexpected(); }
  1511. else {
  1512. node.label = this.parseIdent();
  1513. this.semicolon();
  1514. }
  1515. // Verify that there is an actual destination to break or
  1516. // continue to.
  1517. var i = 0;
  1518. for (; i < this.labels.length; ++i) {
  1519. var lab = this$1.labels[i];
  1520. if (node.label == null || lab.name === node.label.name) {
  1521. if (lab.kind != null && (isBreak || lab.kind === "loop")) { break }
  1522. if (node.label && isBreak) { break }
  1523. }
  1524. }
  1525. if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); }
  1526. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
  1527. };
  1528. pp$1.parseDebuggerStatement = function(node) {
  1529. this.next();
  1530. this.semicolon();
  1531. return this.finishNode(node, "DebuggerStatement")
  1532. };
  1533. pp$1.parseDoStatement = function(node) {
  1534. this.next();
  1535. this.labels.push(loopLabel);
  1536. node.body = this.parseStatement(false);
  1537. this.labels.pop();
  1538. this.expect(types._while);
  1539. node.test = this.parseParenExpression();
  1540. if (this.options.ecmaVersion >= 6)
  1541. { this.eat(types.semi); }
  1542. else
  1543. { this.semicolon(); }
  1544. return this.finishNode(node, "DoWhileStatement")
  1545. };
  1546. // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  1547. // loop is non-trivial. Basically, we have to parse the init `var`
  1548. // statement or expression, disallowing the `in` operator (see
  1549. // the second parameter to `parseExpression`), and then check
  1550. // whether the next token is `in` or `of`. When there is no init
  1551. // part (semicolon immediately after the opening parenthesis), it
  1552. // is a regular `for` loop.
  1553. pp$1.parseForStatement = function(node) {
  1554. this.next();
  1555. var awaitAt = (this.options.ecmaVersion >= 9 && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction)) && this.eatContextual("await")) ? this.lastTokStart : -1;
  1556. this.labels.push(loopLabel);
  1557. this.enterLexicalScope();
  1558. this.expect(types.parenL);
  1559. if (this.type === types.semi) {
  1560. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1561. return this.parseFor(node, null)
  1562. }
  1563. var isLet = this.isLet();
  1564. if (this.type === types._var || this.type === types._const || isLet) {
  1565. var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
  1566. this.next();
  1567. this.parseVar(init$1, true, kind);
  1568. this.finishNode(init$1, "VariableDeclaration");
  1569. if ((this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1 &&
  1570. !(kind !== "var" && init$1.declarations[0].init)) {
  1571. if (this.options.ecmaVersion >= 9) {
  1572. if (this.type === types._in) {
  1573. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1574. } else { node.await = awaitAt > -1; }
  1575. }
  1576. return this.parseForIn(node, init$1)
  1577. }
  1578. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1579. return this.parseFor(node, init$1)
  1580. }
  1581. var refDestructuringErrors = new DestructuringErrors;
  1582. var init = this.parseExpression(true, refDestructuringErrors);
  1583. if (this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
  1584. if (this.options.ecmaVersion >= 9) {
  1585. if (this.type === types._in) {
  1586. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1587. } else { node.await = awaitAt > -1; }
  1588. }
  1589. this.toAssignable(init, false, refDestructuringErrors);
  1590. this.checkLVal(init);
  1591. return this.parseForIn(node, init)
  1592. } else {
  1593. this.checkExpressionErrors(refDestructuringErrors, true);
  1594. }
  1595. if (awaitAt > -1) { this.unexpected(awaitAt); }
  1596. return this.parseFor(node, init)
  1597. };
  1598. pp$1.parseFunctionStatement = function(node, isAsync) {
  1599. this.next();
  1600. return this.parseFunction(node, true, false, isAsync)
  1601. };
  1602. pp$1.parseIfStatement = function(node) {
  1603. this.next();
  1604. node.test = this.parseParenExpression();
  1605. // allow function declarations in branches, but only in non-strict mode
  1606. node.consequent = this.parseStatement(!this.strict && this.type === types._function);
  1607. node.alternate = this.eat(types._else) ? this.parseStatement(!this.strict && this.type === types._function) : null;
  1608. return this.finishNode(node, "IfStatement")
  1609. };
  1610. pp$1.parseReturnStatement = function(node) {
  1611. if (!this.inFunction && !this.options.allowReturnOutsideFunction)
  1612. { this.raise(this.start, "'return' outside of function"); }
  1613. this.next();
  1614. // In `return` (and `break`/`continue`), the keywords with
  1615. // optional arguments, we eagerly look for a semicolon or the
  1616. // possibility to insert one.
  1617. if (this.eat(types.semi) || this.insertSemicolon()) { node.argument = null; }
  1618. else { node.argument = this.parseExpression(); this.semicolon(); }
  1619. return this.finishNode(node, "ReturnStatement")
  1620. };
  1621. pp$1.parseSwitchStatement = function(node) {
  1622. var this$1 = this;
  1623. this.next();
  1624. node.discriminant = this.parseParenExpression();
  1625. node.cases = [];
  1626. this.expect(types.braceL);
  1627. this.labels.push(switchLabel);
  1628. this.enterLexicalScope();
  1629. // Statements under must be grouped (by label) in SwitchCase
  1630. // nodes. `cur` is used to keep the node that we are currently
  1631. // adding statements to.
  1632. var cur;
  1633. for (var sawDefault = false; this.type !== types.braceR;) {
  1634. if (this$1.type === types._case || this$1.type === types._default) {
  1635. var isCase = this$1.type === types._case;
  1636. if (cur) { this$1.finishNode(cur, "SwitchCase"); }
  1637. node.cases.push(cur = this$1.startNode());
  1638. cur.consequent = [];
  1639. this$1.next();
  1640. if (isCase) {
  1641. cur.test = this$1.parseExpression();
  1642. } else {
  1643. if (sawDefault) { this$1.raiseRecoverable(this$1.lastTokStart, "Multiple default clauses"); }
  1644. sawDefault = true;
  1645. cur.test = null;
  1646. }
  1647. this$1.expect(types.colon);
  1648. } else {
  1649. if (!cur) { this$1.unexpected(); }
  1650. cur.consequent.push(this$1.parseStatement(true));
  1651. }
  1652. }
  1653. this.exitLexicalScope();
  1654. if (cur) { this.finishNode(cur, "SwitchCase"); }
  1655. this.next(); // Closing brace
  1656. this.labels.pop();
  1657. return this.finishNode(node, "SwitchStatement")
  1658. };
  1659. pp$1.parseThrowStatement = function(node) {
  1660. this.next();
  1661. if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
  1662. { this.raise(this.lastTokEnd, "Illegal newline after throw"); }
  1663. node.argument = this.parseExpression();
  1664. this.semicolon();
  1665. return this.finishNode(node, "ThrowStatement")
  1666. };
  1667. // Reused empty array added for node fields that are always empty.
  1668. var empty = [];
  1669. pp$1.parseTryStatement = function(node) {
  1670. this.next();
  1671. node.block = this.parseBlock();
  1672. node.handler = null;
  1673. if (this.type === types._catch) {
  1674. var clause = this.startNode();
  1675. this.next();
  1676. if (this.eat(types.parenL)) {
  1677. clause.param = this.parseBindingAtom();
  1678. this.enterLexicalScope();
  1679. this.checkLVal(clause.param, "let");
  1680. this.expect(types.parenR);
  1681. } else {
  1682. if (this.options.ecmaVersion < 10) { this.unexpected(); }
  1683. clause.param = null;
  1684. this.enterLexicalScope();
  1685. }
  1686. clause.body = this.parseBlock(false);
  1687. this.exitLexicalScope();
  1688. node.handler = this.finishNode(clause, "CatchClause");
  1689. }
  1690. node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
  1691. if (!node.handler && !node.finalizer)
  1692. { this.raise(node.start, "Missing catch or finally clause"); }
  1693. return this.finishNode(node, "TryStatement")
  1694. };
  1695. pp$1.parseVarStatement = function(node, kind) {
  1696. this.next();
  1697. this.parseVar(node, false, kind);
  1698. this.semicolon();
  1699. return this.finishNode(node, "VariableDeclaration")
  1700. };
  1701. pp$1.parseWhileStatement = function(node) {
  1702. this.next();
  1703. node.test = this.parseParenExpression();
  1704. this.labels.push(loopLabel);
  1705. node.body = this.parseStatement(false);
  1706. this.labels.pop();
  1707. return this.finishNode(node, "WhileStatement")
  1708. };
  1709. pp$1.parseWithStatement = function(node) {
  1710. if (this.strict) { this.raise(this.start, "'with' in strict mode"); }
  1711. this.next();
  1712. node.object = this.parseParenExpression();
  1713. node.body = this.parseStatement(false);
  1714. return this.finishNode(node, "WithStatement")
  1715. };
  1716. pp$1.parseEmptyStatement = function(node) {
  1717. this.next();
  1718. return this.finishNode(node, "EmptyStatement")
  1719. };
  1720. pp$1.parseLabeledStatement = function(node, maybeName, expr) {
  1721. var this$1 = this;
  1722. for (var i$1 = 0, list = this$1.labels; i$1 < list.length; i$1 += 1)
  1723. {
  1724. var label = list[i$1];
  1725. if (label.name === maybeName)
  1726. { this$1.raise(expr.start, "Label '" + maybeName + "' is already declared");
  1727. } }
  1728. var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
  1729. for (var i = this.labels.length - 1; i >= 0; i--) {
  1730. var label$1 = this$1.labels[i];
  1731. if (label$1.statementStart === node.start) {
  1732. // Update information about previous labels on this node
  1733. label$1.statementStart = this$1.start;
  1734. label$1.kind = kind;
  1735. } else { break }
  1736. }
  1737. this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
  1738. node.body = this.parseStatement(true);
  1739. if (node.body.type === "ClassDeclaration" ||
  1740. node.body.type === "VariableDeclaration" && node.body.kind !== "var" ||
  1741. node.body.type === "FunctionDeclaration" && (this.strict || node.body.generator || node.body.async))
  1742. { this.raiseRecoverable(node.body.start, "Invalid labeled declaration"); }
  1743. this.labels.pop();
  1744. node.label = expr;
  1745. return this.finishNode(node, "LabeledStatement")
  1746. };
  1747. pp$1.parseExpressionStatement = function(node, expr) {
  1748. node.expression = expr;
  1749. this.semicolon();
  1750. return this.finishNode(node, "ExpressionStatement")
  1751. };
  1752. // Parse a semicolon-enclosed block of statements, handling `"use
  1753. // strict"` declarations when `allowStrict` is true (used for
  1754. // function bodies).
  1755. pp$1.parseBlock = function(createNewLexicalScope) {
  1756. var this$1 = this;
  1757. if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
  1758. var node = this.startNode();
  1759. node.body = [];
  1760. this.expect(types.braceL);
  1761. if (createNewLexicalScope) {
  1762. this.enterLexicalScope();
  1763. }
  1764. while (!this.eat(types.braceR)) {
  1765. var stmt = this$1.parseStatement(true);
  1766. node.body.push(stmt);
  1767. }
  1768. if (createNewLexicalScope) {
  1769. this.exitLexicalScope();
  1770. }
  1771. return this.finishNode(node, "BlockStatement")
  1772. };
  1773. // Parse a regular `for` loop. The disambiguation code in
  1774. // `parseStatement` will already have parsed the init statement or
  1775. // expression.
  1776. pp$1.parseFor = function(node, init) {
  1777. node.init = init;
  1778. this.expect(types.semi);
  1779. node.test = this.type === types.semi ? null : this.parseExpression();
  1780. this.expect(types.semi);
  1781. node.update = this.type === types.parenR ? null : this.parseExpression();
  1782. this.expect(types.parenR);
  1783. this.exitLexicalScope();
  1784. node.body = this.parseStatement(false);
  1785. this.labels.pop();
  1786. return this.finishNode(node, "ForStatement")
  1787. };
  1788. // Parse a `for`/`in` and `for`/`of` loop, which are almost
  1789. // same from parser's perspective.
  1790. pp$1.parseForIn = function(node, init) {
  1791. var type = this.type === types._in ? "ForInStatement" : "ForOfStatement";
  1792. this.next();
  1793. if (type === "ForInStatement") {
  1794. if (init.type === "AssignmentPattern" ||
  1795. (init.type === "VariableDeclaration" && init.declarations[0].init != null &&
  1796. (this.strict || init.declarations[0].id.type !== "Identifier")))
  1797. { this.raise(init.start, "Invalid assignment in for-in loop head"); }
  1798. }
  1799. node.left = init;
  1800. node.right = type === "ForInStatement" ? this.parseExpression() : this.parseMaybeAssign();
  1801. this.expect(types.parenR);
  1802. this.exitLexicalScope();
  1803. node.body = this.parseStatement(false);
  1804. this.labels.pop();
  1805. return this.finishNode(node, type)
  1806. };
  1807. // Parse a list of variable declarations.
  1808. pp$1.parseVar = function(node, isFor, kind) {
  1809. var this$1 = this;
  1810. node.declarations = [];
  1811. node.kind = kind;
  1812. for (;;) {
  1813. var decl = this$1.startNode();
  1814. this$1.parseVarId(decl, kind);
  1815. if (this$1.eat(types.eq)) {
  1816. decl.init = this$1.parseMaybeAssign(isFor);
  1817. } else if (kind === "const" && !(this$1.type === types._in || (this$1.options.ecmaVersion >= 6 && this$1.isContextual("of")))) {
  1818. this$1.unexpected();
  1819. } else if (decl.id.type !== "Identifier" && !(isFor && (this$1.type === types._in || this$1.isContextual("of")))) {
  1820. this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value");
  1821. } else {
  1822. decl.init = null;
  1823. }
  1824. node.declarations.push(this$1.finishNode(decl, "VariableDeclarator"));
  1825. if (!this$1.eat(types.comma)) { break }
  1826. }
  1827. return node
  1828. };
  1829. pp$1.parseVarId = function(decl, kind) {
  1830. decl.id = this.parseBindingAtom(kind);
  1831. this.checkLVal(decl.id, kind, false);
  1832. };
  1833. // Parse a function declaration or literal (depending on the
  1834. // `isStatement` parameter).
  1835. pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) {
  1836. this.initFunction(node);
  1837. if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync)
  1838. { node.generator = this.eat(types.star); }
  1839. if (this.options.ecmaVersion >= 8)
  1840. { node.async = !!isAsync; }
  1841. if (isStatement) {
  1842. node.id = isStatement === "nullableID" && this.type !== types.name ? null : this.parseIdent();
  1843. if (node.id) {
  1844. this.checkLVal(node.id, this.inModule && !this.inFunction ? "let" : "var");
  1845. }
  1846. }
  1847. var oldInGen = this.inGenerator, oldInAsync = this.inAsync,
  1848. oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction;
  1849. this.inGenerator = node.generator;
  1850. this.inAsync = node.async;
  1851. this.yieldPos = 0;
  1852. this.awaitPos = 0;
  1853. this.inFunction = true;
  1854. this.enterFunctionScope();
  1855. if (!isStatement)
  1856. { node.id = this.type === types.name ? this.parseIdent() : null; }
  1857. this.parseFunctionParams(node);
  1858. this.parseFunctionBody(node, allowExpressionBody);
  1859. this.inGenerator = oldInGen;
  1860. this.inAsync = oldInAsync;
  1861. this.yieldPos = oldYieldPos;
  1862. this.awaitPos = oldAwaitPos;
  1863. this.inFunction = oldInFunc;
  1864. return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression")
  1865. };
  1866. pp$1.parseFunctionParams = function(node) {
  1867. this.expect(types.parenL);
  1868. node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
  1869. this.checkYieldAwaitInDefaultParams();
  1870. };
  1871. // Parse a class declaration or literal (depending on the
  1872. // `isStatement` parameter).
  1873. pp$1.parseClass = function(node, isStatement) {
  1874. var this$1 = this;
  1875. this.next();
  1876. this.parseClassId(node, isStatement);
  1877. this.parseClassSuper(node);
  1878. var classBody = this.startNode();
  1879. var hadConstructor = false;
  1880. classBody.body = [];
  1881. this.expect(types.braceL);
  1882. while (!this.eat(types.braceR)) {
  1883. var member = this$1.parseClassMember(classBody);
  1884. if (member && member.type === "MethodDefinition" && member.kind === "constructor") {
  1885. if (hadConstructor) { this$1.raise(member.start, "Duplicate constructor in the same class"); }
  1886. hadConstructor = true;
  1887. }
  1888. }
  1889. node.body = this.finishNode(classBody, "ClassBody");
  1890. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
  1891. };
  1892. pp$1.parseClassMember = function(classBody) {
  1893. var this$1 = this;
  1894. if (this.eat(types.semi)) { return null }
  1895. var method = this.startNode();
  1896. var tryContextual = function (k, noLineBreak) {
  1897. if ( noLineBreak === void 0 ) noLineBreak = false;
  1898. var start = this$1.start, startLoc = this$1.startLoc;
  1899. if (!this$1.eatContextual(k)) { return false }
  1900. if (this$1.type !== types.parenL && (!noLineBreak || !this$1.canInsertSemicolon())) { return true }
  1901. if (method.key) { this$1.unexpected(); }
  1902. method.computed = false;
  1903. method.key = this$1.startNodeAt(start, startLoc);
  1904. method.key.name = k;
  1905. this$1.finishNode(method.key, "Identifier");
  1906. return false
  1907. };
  1908. method.kind = "method";
  1909. method["static"] = tryContextual("static");
  1910. var isGenerator = this.eat(types.star);
  1911. var isAsync = false;
  1912. if (!isGenerator) {
  1913. if (this.options.ecmaVersion >= 8 && tryContextual("async", true)) {
  1914. isAsync = true;
  1915. isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
  1916. } else if (tryContextual("get")) {
  1917. method.kind = "get";
  1918. } else if (tryContextual("set")) {
  1919. method.kind = "set";
  1920. }
  1921. }
  1922. if (!method.key) { this.parsePropertyName(method); }
  1923. var key = method.key;
  1924. if (!method.computed && !method["static"] && (key.type === "Identifier" && key.name === "constructor" ||
  1925. key.type === "Literal" && key.value === "constructor")) {
  1926. if (method.kind !== "method") { this.raise(key.start, "Constructor can't have get/set modifier"); }
  1927. if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); }
  1928. if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); }
  1929. method.kind = "constructor";
  1930. } else if (method["static"] && key.type === "Identifier" && key.name === "prototype") {
  1931. this.raise(key.start, "Classes may not have a static property named prototype");
  1932. }
  1933. this.parseClassMethod(classBody, method, isGenerator, isAsync);
  1934. if (method.kind === "get" && method.value.params.length !== 0)
  1935. { this.raiseRecoverable(method.value.start, "getter should have no params"); }
  1936. if (method.kind === "set" && method.value.params.length !== 1)
  1937. { this.raiseRecoverable(method.value.start, "setter should have exactly one param"); }
  1938. if (method.kind === "set" && method.value.params[0].type === "RestElement")
  1939. { this.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params"); }
  1940. return method
  1941. };
  1942. pp$1.parseClassMethod = function(classBody, method, isGenerator, isAsync) {
  1943. method.value = this.parseMethod(isGenerator, isAsync);
  1944. classBody.body.push(this.finishNode(method, "MethodDefinition"));
  1945. };
  1946. pp$1.parseClassId = function(node, isStatement) {
  1947. node.id = this.type === types.name ? this.parseIdent() : isStatement === true ? this.unexpected() : null;
  1948. };
  1949. pp$1.parseClassSuper = function(node) {
  1950. node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
  1951. };
  1952. // Parses module export declaration.
  1953. pp$1.parseExport = function(node, exports) {
  1954. var this$1 = this;
  1955. this.next();
  1956. // export * from '...'
  1957. if (this.eat(types.star)) {
  1958. this.expectContextual("from");
  1959. if (this.type !== types.string) { this.unexpected(); }
  1960. node.source = this.parseExprAtom();
  1961. this.semicolon();
  1962. return this.finishNode(node, "ExportAllDeclaration")
  1963. }
  1964. if (this.eat(types._default)) { // export default ...
  1965. this.checkExport(exports, "default", this.lastTokStart);
  1966. var isAsync;
  1967. if (this.type === types._function || (isAsync = this.isAsyncFunction())) {
  1968. var fNode = this.startNode();
  1969. this.next();
  1970. if (isAsync) { this.next(); }
  1971. node.declaration = this.parseFunction(fNode, "nullableID", false, isAsync);
  1972. } else if (this.type === types._class) {
  1973. var cNode = this.startNode();
  1974. node.declaration = this.parseClass(cNode, "nullableID");
  1975. } else {
  1976. node.declaration = this.parseMaybeAssign();
  1977. this.semicolon();
  1978. }
  1979. return this.finishNode(node, "ExportDefaultDeclaration")
  1980. }
  1981. // export var|const|let|function|class ...
  1982. if (this.shouldParseExportStatement()) {
  1983. node.declaration = this.parseStatement(true);
  1984. if (node.declaration.type === "VariableDeclaration")
  1985. { this.checkVariableExport(exports, node.declaration.declarations); }
  1986. else
  1987. { this.checkExport(exports, node.declaration.id.name, node.declaration.id.start); }
  1988. node.specifiers = [];
  1989. node.source = null;
  1990. } else { // export { x, y as z } [from '...']
  1991. node.declaration = null;
  1992. node.specifiers = this.parseExportSpecifiers(exports);
  1993. if (this.eatContextual("from")) {
  1994. if (this.type !== types.string) { this.unexpected(); }
  1995. node.source = this.parseExprAtom();
  1996. } else {
  1997. // check for keywords used as local names
  1998. for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
  1999. var spec = list[i];
  2000. this$1.checkUnreserved(spec.local);
  2001. }
  2002. node.source = null;
  2003. }
  2004. this.semicolon();
  2005. }
  2006. return this.finishNode(node, "ExportNamedDeclaration")
  2007. };
  2008. pp$1.checkExport = function(exports, name, pos) {
  2009. if (!exports) { return }
  2010. if (has(exports, name))
  2011. { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
  2012. exports[name] = true;
  2013. };
  2014. pp$1.checkPatternExport = function(exports, pat) {
  2015. var this$1 = this;
  2016. var type = pat.type;
  2017. if (type === "Identifier")
  2018. { this.checkExport(exports, pat.name, pat.start); }
  2019. else if (type === "ObjectPattern")
  2020. { for (var i = 0, list = pat.properties; i < list.length; i += 1)
  2021. {
  2022. var prop = list[i];
  2023. this$1.checkPatternExport(exports, prop);
  2024. } }
  2025. else if (type === "ArrayPattern")
  2026. { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
  2027. var elt = list$1[i$1];
  2028. if (elt) { this$1.checkPatternExport(exports, elt); }
  2029. } }
  2030. else if (type === "Property")
  2031. { this.checkPatternExport(exports, pat.value); }
  2032. else if (type === "AssignmentPattern")
  2033. { this.checkPatternExport(exports, pat.left); }
  2034. else if (type === "RestElement")
  2035. { this.checkPatternExport(exports, pat.argument); }
  2036. else if (type === "ParenthesizedExpression")
  2037. { this.checkPatternExport(exports, pat.expression); }
  2038. };
  2039. pp$1.checkVariableExport = function(exports, decls) {
  2040. var this$1 = this;
  2041. if (!exports) { return }
  2042. for (var i = 0, list = decls; i < list.length; i += 1)
  2043. {
  2044. var decl = list[i];
  2045. this$1.checkPatternExport(exports, decl.id);
  2046. }
  2047. };
  2048. pp$1.shouldParseExportStatement = function() {
  2049. return this.type.keyword === "var" ||
  2050. this.type.keyword === "const" ||
  2051. this.type.keyword === "class" ||
  2052. this.type.keyword === "function" ||
  2053. this.isLet() ||
  2054. this.isAsyncFunction()
  2055. };
  2056. // Parses a comma-separated list of module exports.
  2057. pp$1.parseExportSpecifiers = function(exports) {
  2058. var this$1 = this;
  2059. var nodes = [], first = true;
  2060. // export { x, y as z } [from '...']
  2061. this.expect(types.braceL);
  2062. while (!this.eat(types.braceR)) {
  2063. if (!first) {
  2064. this$1.expect(types.comma);
  2065. if (this$1.afterTrailingComma(types.braceR)) { break }
  2066. } else { first = false; }
  2067. var node = this$1.startNode();
  2068. node.local = this$1.parseIdent(true);
  2069. node.exported = this$1.eatContextual("as") ? this$1.parseIdent(true) : node.local;
  2070. this$1.checkExport(exports, node.exported.name, node.exported.start);
  2071. nodes.push(this$1.finishNode(node, "ExportSpecifier"));
  2072. }
  2073. return nodes
  2074. };
  2075. // Parses import declaration.
  2076. pp$1.parseImport = function(node) {
  2077. this.next();
  2078. // import '...'
  2079. if (this.type === types.string) {
  2080. node.specifiers = empty;
  2081. node.source = this.parseExprAtom();
  2082. } else {
  2083. node.specifiers = this.parseImportSpecifiers();
  2084. this.expectContextual("from");
  2085. node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
  2086. }
  2087. this.semicolon();
  2088. return this.finishNode(node, "ImportDeclaration")
  2089. };
  2090. // Parses a comma-separated list of module imports.
  2091. pp$1.parseImportSpecifiers = function() {
  2092. var this$1 = this;
  2093. var nodes = [], first = true;
  2094. if (this.type === types.name) {
  2095. // import defaultObj, { x, y as z } from '...'
  2096. var node = this.startNode();
  2097. node.local = this.parseIdent();
  2098. this.checkLVal(node.local, "let");
  2099. nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
  2100. if (!this.eat(types.comma)) { return nodes }
  2101. }
  2102. if (this.type === types.star) {
  2103. var node$1 = this.startNode();
  2104. this.next();
  2105. this.expectContextual("as");
  2106. node$1.local = this.parseIdent();
  2107. this.checkLVal(node$1.local, "let");
  2108. nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
  2109. return nodes
  2110. }
  2111. this.expect(types.braceL);
  2112. while (!this.eat(types.braceR)) {
  2113. if (!first) {
  2114. this$1.expect(types.comma);
  2115. if (this$1.afterTrailingComma(types.braceR)) { break }
  2116. } else { first = false; }
  2117. var node$2 = this$1.startNode();
  2118. node$2.imported = this$1.parseIdent(true);
  2119. if (this$1.eatContextual("as")) {
  2120. node$2.local = this$1.parseIdent();
  2121. } else {
  2122. this$1.checkUnreserved(node$2.imported);
  2123. node$2.local = node$2.imported;
  2124. }
  2125. this$1.checkLVal(node$2.local, "let");
  2126. nodes.push(this$1.finishNode(node$2, "ImportSpecifier"));
  2127. }
  2128. return nodes
  2129. };
  2130. // Set `ExpressionStatement#directive` property for directive prologues.
  2131. pp$1.adaptDirectivePrologue = function(statements) {
  2132. for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
  2133. statements[i].directive = statements[i].expression.raw.slice(1, -1);
  2134. }
  2135. };
  2136. pp$1.isDirectiveCandidate = function(statement) {
  2137. return (
  2138. statement.type === "ExpressionStatement" &&
  2139. statement.expression.type === "Literal" &&
  2140. typeof statement.expression.value === "string" &&
  2141. // Reject parenthesized strings.
  2142. (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
  2143. )
  2144. };
  2145. var pp$2 = Parser.prototype;
  2146. // Convert existing expression atom to assignable pattern
  2147. // if possible.
  2148. pp$2.toAssignable = function(node, isBinding, refDestructuringErrors) {
  2149. var this$1 = this;
  2150. if (this.options.ecmaVersion >= 6 && node) {
  2151. switch (node.type) {
  2152. case "Identifier":
  2153. if (this.inAsync && node.name === "await")
  2154. { this.raise(node.start, "Can not use 'await' as identifier inside an async function"); }
  2155. break
  2156. case "ObjectPattern":
  2157. case "ArrayPattern":
  2158. case "RestElement":
  2159. break
  2160. case "ObjectExpression":
  2161. node.type = "ObjectPattern";
  2162. if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  2163. for (var i = 0, list = node.properties; i < list.length; i += 1) {
  2164. var prop = list[i];
  2165. this$1.toAssignable(prop, isBinding);
  2166. // Early error:
  2167. // AssignmentRestProperty[Yield, Await] :
  2168. // `...` DestructuringAssignmentTarget[Yield, Await]
  2169. //
  2170. // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
  2171. if (
  2172. prop.type === "RestElement" &&
  2173. (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")
  2174. ) {
  2175. this$1.raise(prop.argument.start, "Unexpected token");
  2176. }
  2177. }
  2178. break
  2179. case "Property":
  2180. // AssignmentProperty has type === "Property"
  2181. if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); }
  2182. this.toAssignable(node.value, isBinding);
  2183. break
  2184. case "ArrayExpression":
  2185. node.type = "ArrayPattern";
  2186. if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  2187. this.toAssignableList(node.elements, isBinding);
  2188. break
  2189. case "SpreadElement":
  2190. node.type = "RestElement";
  2191. this.toAssignable(node.argument, isBinding);
  2192. if (node.argument.type === "AssignmentPattern")
  2193. { this.raise(node.argument.start, "Rest elements cannot have a default value"); }
  2194. break
  2195. case "AssignmentExpression":
  2196. if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); }
  2197. node.type = "AssignmentPattern";
  2198. delete node.operator;
  2199. this.toAssignable(node.left, isBinding);
  2200. // falls through to AssignmentPattern
  2201. case "AssignmentPattern":
  2202. break
  2203. case "ParenthesizedExpression":
  2204. this.toAssignable(node.expression, isBinding);
  2205. break
  2206. case "MemberExpression":
  2207. if (!isBinding) { break }
  2208. default:
  2209. this.raise(node.start, "Assigning to rvalue");
  2210. }
  2211. } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
  2212. return node
  2213. };
  2214. // Convert list of expression atoms to binding list.
  2215. pp$2.toAssignableList = function(exprList, isBinding) {
  2216. var this$1 = this;
  2217. var end = exprList.length;
  2218. for (var i = 0; i < end; i++) {
  2219. var elt = exprList[i];
  2220. if (elt) { this$1.toAssignable(elt, isBinding); }
  2221. }
  2222. if (end) {
  2223. var last = exprList[end - 1];
  2224. if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
  2225. { this.unexpected(last.argument.start); }
  2226. }
  2227. return exprList
  2228. };
  2229. // Parses spread element.
  2230. pp$2.parseSpread = function(refDestructuringErrors) {
  2231. var node = this.startNode();
  2232. this.next();
  2233. node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  2234. return this.finishNode(node, "SpreadElement")
  2235. };
  2236. pp$2.parseRestBinding = function() {
  2237. var node = this.startNode();
  2238. this.next();
  2239. // RestElement inside of a function parameter must be an identifier
  2240. if (this.options.ecmaVersion === 6 && this.type !== types.name)
  2241. { this.unexpected(); }
  2242. node.argument = this.parseBindingAtom();
  2243. return this.finishNode(node, "RestElement")
  2244. };
  2245. // Parses lvalue (assignable) atom.
  2246. pp$2.parseBindingAtom = function() {
  2247. if (this.options.ecmaVersion >= 6) {
  2248. switch (this.type) {
  2249. case types.bracketL:
  2250. var node = this.startNode();
  2251. this.next();
  2252. node.elements = this.parseBindingList(types.bracketR, true, true);
  2253. return this.finishNode(node, "ArrayPattern")
  2254. case types.braceL:
  2255. return this.parseObj(true)
  2256. }
  2257. }
  2258. return this.parseIdent()
  2259. };
  2260. pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
  2261. var this$1 = this;
  2262. var elts = [], first = true;
  2263. while (!this.eat(close)) {
  2264. if (first) { first = false; }
  2265. else { this$1.expect(types.comma); }
  2266. if (allowEmpty && this$1.type === types.comma) {
  2267. elts.push(null);
  2268. } else if (allowTrailingComma && this$1.afterTrailingComma(close)) {
  2269. break
  2270. } else if (this$1.type === types.ellipsis) {
  2271. var rest = this$1.parseRestBinding();
  2272. this$1.parseBindingListItem(rest);
  2273. elts.push(rest);
  2274. if (this$1.type === types.comma) { this$1.raise(this$1.start, "Comma is not permitted after the rest element"); }
  2275. this$1.expect(close);
  2276. break
  2277. } else {
  2278. var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc);
  2279. this$1.parseBindingListItem(elem);
  2280. elts.push(elem);
  2281. }
  2282. }
  2283. return elts
  2284. };
  2285. pp$2.parseBindingListItem = function(param) {
  2286. return param
  2287. };
  2288. // Parses assignment pattern around given atom if possible.
  2289. pp$2.parseMaybeDefault = function(startPos, startLoc, left) {
  2290. left = left || this.parseBindingAtom();
  2291. if (this.options.ecmaVersion < 6 || !this.eat(types.eq)) { return left }
  2292. var node = this.startNodeAt(startPos, startLoc);
  2293. node.left = left;
  2294. node.right = this.parseMaybeAssign();
  2295. return this.finishNode(node, "AssignmentPattern")
  2296. };
  2297. // Verify that a node is an lval — something that can be assigned
  2298. // to.
  2299. // bindingType can be either:
  2300. // 'var' indicating that the lval creates a 'var' binding
  2301. // 'let' indicating that the lval creates a lexical ('let' or 'const') binding
  2302. // 'none' indicating that the binding should be checked for illegal identifiers, but not for duplicate references
  2303. pp$2.checkLVal = function(expr, bindingType, checkClashes) {
  2304. var this$1 = this;
  2305. switch (expr.type) {
  2306. case "Identifier":
  2307. if (this.strict && this.reservedWordsStrictBind.test(expr.name))
  2308. { this.raiseRecoverable(expr.start, (bindingType ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); }
  2309. if (checkClashes) {
  2310. if (has(checkClashes, expr.name))
  2311. { this.raiseRecoverable(expr.start, "Argument name clash"); }
  2312. checkClashes[expr.name] = true;
  2313. }
  2314. if (bindingType && bindingType !== "none") {
  2315. if (
  2316. bindingType === "var" && !this.canDeclareVarName(expr.name) ||
  2317. bindingType !== "var" && !this.canDeclareLexicalName(expr.name)
  2318. ) {
  2319. this.raiseRecoverable(expr.start, ("Identifier '" + (expr.name) + "' has already been declared"));
  2320. }
  2321. if (bindingType === "var") {
  2322. this.declareVarName(expr.name);
  2323. } else {
  2324. this.declareLexicalName(expr.name);
  2325. }
  2326. }
  2327. break
  2328. case "MemberExpression":
  2329. if (bindingType) { this.raiseRecoverable(expr.start, "Binding member expression"); }
  2330. break
  2331. case "ObjectPattern":
  2332. for (var i = 0, list = expr.properties; i < list.length; i += 1)
  2333. {
  2334. var prop = list[i];
  2335. this$1.checkLVal(prop, bindingType, checkClashes);
  2336. }
  2337. break
  2338. case "Property":
  2339. // AssignmentProperty has type === "Property"
  2340. this.checkLVal(expr.value, bindingType, checkClashes);
  2341. break
  2342. case "ArrayPattern":
  2343. for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
  2344. var elem = list$1[i$1];
  2345. if (elem) { this$1.checkLVal(elem, bindingType, checkClashes); }
  2346. }
  2347. break
  2348. case "AssignmentPattern":
  2349. this.checkLVal(expr.left, bindingType, checkClashes);
  2350. break
  2351. case "RestElement":
  2352. this.checkLVal(expr.argument, bindingType, checkClashes);
  2353. break
  2354. case "ParenthesizedExpression":
  2355. this.checkLVal(expr.expression, bindingType, checkClashes);
  2356. break
  2357. default:
  2358. this.raise(expr.start, (bindingType ? "Binding" : "Assigning to") + " rvalue");
  2359. }
  2360. };
  2361. // A recursive descent parser operates by defining functions for all
  2362. // syntactic elements, and recursively calling those, each function
  2363. // advancing the input stream and returning an AST node. Precedence
  2364. // of constructs (for example, the fact that `!x[1]` means `!(x[1])`
  2365. // instead of `(!x)[1]` is handled by the fact that the parser
  2366. // function that parses unary prefix operators is called first, and
  2367. // in turn calls the function that parses `[]` subscripts — that
  2368. // way, it'll receive the node for `x[1]` already parsed, and wraps
  2369. // *that* in the unary operator node.
  2370. //
  2371. // Acorn uses an [operator precedence parser][opp] to handle binary
  2372. // operator precedence, because it is much more compact than using
  2373. // the technique outlined above, which uses different, nesting
  2374. // functions to specify precedence, for all of the ten binary
  2375. // precedence levels that JavaScript defines.
  2376. //
  2377. // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
  2378. var pp$3 = Parser.prototype;
  2379. // Check if property name clashes with already added.
  2380. // Object/class getters and setters are not allowed to clash —
  2381. // either with each other or with an init property — and in
  2382. // strict mode, init properties are also not allowed to be repeated.
  2383. pp$3.checkPropClash = function(prop, propHash, refDestructuringErrors) {
  2384. if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement")
  2385. { return }
  2386. if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
  2387. { return }
  2388. var key = prop.key;
  2389. var name;
  2390. switch (key.type) {
  2391. case "Identifier": name = key.name; break
  2392. case "Literal": name = String(key.value); break
  2393. default: return
  2394. }
  2395. var kind = prop.kind;
  2396. if (this.options.ecmaVersion >= 6) {
  2397. if (name === "__proto__" && kind === "init") {
  2398. if (propHash.proto) {
  2399. if (refDestructuringErrors && refDestructuringErrors.doubleProto < 0) { refDestructuringErrors.doubleProto = key.start; }
  2400. // Backwards-compat kludge. Can be removed in version 6.0
  2401. else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); }
  2402. }
  2403. propHash.proto = true;
  2404. }
  2405. return
  2406. }
  2407. name = "$" + name;
  2408. var other = propHash[name];
  2409. if (other) {
  2410. var redefinition;
  2411. if (kind === "init") {
  2412. redefinition = this.strict && other.init || other.get || other.set;
  2413. } else {
  2414. redefinition = other.init || other[kind];
  2415. }
  2416. if (redefinition)
  2417. { this.raiseRecoverable(key.start, "Redefinition of property"); }
  2418. } else {
  2419. other = propHash[name] = {
  2420. init: false,
  2421. get: false,
  2422. set: false
  2423. };
  2424. }
  2425. other[kind] = true;
  2426. };
  2427. // ### Expression parsing
  2428. // These nest, from the most general expression type at the top to
  2429. // 'atomic', nondivisible expression types at the bottom. Most of
  2430. // the functions will simply let the function(s) below them parse,
  2431. // and, *if* the syntactic construct they handle is present, wrap
  2432. // the AST node that the inner parser gave them in another node.
  2433. // Parse a full expression. The optional arguments are used to
  2434. // forbid the `in` operator (in for loops initalization expressions)
  2435. // and provide reference for storing '=' operator inside shorthand
  2436. // property assignment in contexts where both object expression
  2437. // and object pattern might appear (so it's possible to raise
  2438. // delayed syntax error at correct position).
  2439. pp$3.parseExpression = function(noIn, refDestructuringErrors) {
  2440. var this$1 = this;
  2441. var startPos = this.start, startLoc = this.startLoc;
  2442. var expr = this.parseMaybeAssign(noIn, refDestructuringErrors);
  2443. if (this.type === types.comma) {
  2444. var node = this.startNodeAt(startPos, startLoc);
  2445. node.expressions = [expr];
  2446. while (this.eat(types.comma)) { node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors)); }
  2447. return this.finishNode(node, "SequenceExpression")
  2448. }
  2449. return expr
  2450. };
  2451. // Parse an assignment expression. This includes applications of
  2452. // operators like `+=`.
  2453. pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
  2454. if (this.inGenerator && this.isContextual("yield")) { return this.parseYield() }
  2455. var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1;
  2456. if (refDestructuringErrors) {
  2457. oldParenAssign = refDestructuringErrors.parenthesizedAssign;
  2458. oldTrailingComma = refDestructuringErrors.trailingComma;
  2459. refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
  2460. } else {
  2461. refDestructuringErrors = new DestructuringErrors;
  2462. ownDestructuringErrors = true;
  2463. }
  2464. var startPos = this.start, startLoc = this.startLoc;
  2465. if (this.type === types.parenL || this.type === types.name)
  2466. { this.potentialArrowAt = this.start; }
  2467. var left = this.parseMaybeConditional(noIn, refDestructuringErrors);
  2468. if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }
  2469. if (this.type.isAssign) {
  2470. var node = this.startNodeAt(startPos, startLoc);
  2471. node.operator = this.value;
  2472. node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left;
  2473. if (!ownDestructuringErrors) { DestructuringErrors.call(refDestructuringErrors); }
  2474. refDestructuringErrors.shorthandAssign = -1; // reset because shorthand default was used correctly
  2475. this.checkLVal(left);
  2476. this.next();
  2477. node.right = this.parseMaybeAssign(noIn);
  2478. return this.finishNode(node, "AssignmentExpression")
  2479. } else {
  2480. if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
  2481. }
  2482. if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
  2483. if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
  2484. return left
  2485. };
  2486. // Parse a ternary conditional (`?:`) operator.
  2487. pp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) {
  2488. var startPos = this.start, startLoc = this.startLoc;
  2489. var expr = this.parseExprOps(noIn, refDestructuringErrors);
  2490. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  2491. if (this.eat(types.question)) {
  2492. var node = this.startNodeAt(startPos, startLoc);
  2493. node.test = expr;
  2494. node.consequent = this.parseMaybeAssign();
  2495. this.expect(types.colon);
  2496. node.alternate = this.parseMaybeAssign(noIn);
  2497. return this.finishNode(node, "ConditionalExpression")
  2498. }
  2499. return expr
  2500. };
  2501. // Start the precedence parser.
  2502. pp$3.parseExprOps = function(noIn, refDestructuringErrors) {
  2503. var startPos = this.start, startLoc = this.startLoc;
  2504. var expr = this.parseMaybeUnary(refDestructuringErrors, false);
  2505. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  2506. return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn)
  2507. };
  2508. // Parse binary operators with the operator precedence parsing
  2509. // algorithm. `left` is the left-hand side of the operator.
  2510. // `minPrec` provides context that allows the function to stop and
  2511. // defer further parser to one of its callers when it encounters an
  2512. // operator that has a lower precedence than the set it is parsing.
  2513. pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
  2514. var prec = this.type.binop;
  2515. if (prec != null && (!noIn || this.type !== types._in)) {
  2516. if (prec > minPrec) {
  2517. var logical = this.type === types.logicalOR || this.type === types.logicalAND;
  2518. var op = this.value;
  2519. this.next();
  2520. var startPos = this.start, startLoc = this.startLoc;
  2521. var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn);
  2522. var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical);
  2523. return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)
  2524. }
  2525. }
  2526. return left
  2527. };
  2528. pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) {
  2529. var node = this.startNodeAt(startPos, startLoc);
  2530. node.left = left;
  2531. node.operator = op;
  2532. node.right = right;
  2533. return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
  2534. };
  2535. // Parse unary operators, both prefix and postfix.
  2536. pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
  2537. var this$1 = this;
  2538. var startPos = this.start, startLoc = this.startLoc, expr;
  2539. if (this.isContextual("await") && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction))) {
  2540. expr = this.parseAwait();
  2541. sawUnary = true;
  2542. } else if (this.type.prefix) {
  2543. var node = this.startNode(), update = this.type === types.incDec;
  2544. node.operator = this.value;
  2545. node.prefix = true;
  2546. this.next();
  2547. node.argument = this.parseMaybeUnary(null, true);
  2548. this.checkExpressionErrors(refDestructuringErrors, true);
  2549. if (update) { this.checkLVal(node.argument); }
  2550. else if (this.strict && node.operator === "delete" &&
  2551. node.argument.type === "Identifier")
  2552. { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
  2553. else { sawUnary = true; }
  2554. expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
  2555. } else {
  2556. expr = this.parseExprSubscripts(refDestructuringErrors);
  2557. if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
  2558. while (this.type.postfix && !this.canInsertSemicolon()) {
  2559. var node$1 = this$1.startNodeAt(startPos, startLoc);
  2560. node$1.operator = this$1.value;
  2561. node$1.prefix = false;
  2562. node$1.argument = expr;
  2563. this$1.checkLVal(expr);
  2564. this$1.next();
  2565. expr = this$1.finishNode(node$1, "UpdateExpression");
  2566. }
  2567. }
  2568. if (!sawUnary && this.eat(types.starstar))
  2569. { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) }
  2570. else
  2571. { return expr }
  2572. };
  2573. // Parse call, dot, and `[]`-subscript expressions.
  2574. pp$3.parseExprSubscripts = function(refDestructuringErrors) {
  2575. var startPos = this.start, startLoc = this.startLoc;
  2576. var expr = this.parseExprAtom(refDestructuringErrors);
  2577. var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")";
  2578. if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) { return expr }
  2579. var result = this.parseSubscripts(expr, startPos, startLoc);
  2580. if (refDestructuringErrors && result.type === "MemberExpression") {
  2581. if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
  2582. if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
  2583. }
  2584. return result
  2585. };
  2586. pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
  2587. var this$1 = this;
  2588. var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
  2589. this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async";
  2590. for (var computed = (void 0);;) {
  2591. if ((computed = this$1.eat(types.bracketL)) || this$1.eat(types.dot)) {
  2592. var node = this$1.startNodeAt(startPos, startLoc);
  2593. node.object = base;
  2594. node.property = computed ? this$1.parseExpression() : this$1.parseIdent(true);
  2595. node.computed = !!computed;
  2596. if (computed) { this$1.expect(types.bracketR); }
  2597. base = this$1.finishNode(node, "MemberExpression");
  2598. } else if (!noCalls && this$1.eat(types.parenL)) {
  2599. var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this$1.yieldPos, oldAwaitPos = this$1.awaitPos;
  2600. this$1.yieldPos = 0;
  2601. this$1.awaitPos = 0;
  2602. var exprList = this$1.parseExprList(types.parenR, this$1.options.ecmaVersion >= 8, false, refDestructuringErrors);
  2603. if (maybeAsyncArrow && !this$1.canInsertSemicolon() && this$1.eat(types.arrow)) {
  2604. this$1.checkPatternErrors(refDestructuringErrors, false);
  2605. this$1.checkYieldAwaitInDefaultParams();
  2606. this$1.yieldPos = oldYieldPos;
  2607. this$1.awaitPos = oldAwaitPos;
  2608. return this$1.parseArrowExpression(this$1.startNodeAt(startPos, startLoc), exprList, true)
  2609. }
  2610. this$1.checkExpressionErrors(refDestructuringErrors, true);
  2611. this$1.yieldPos = oldYieldPos || this$1.yieldPos;
  2612. this$1.awaitPos = oldAwaitPos || this$1.awaitPos;
  2613. var node$1 = this$1.startNodeAt(startPos, startLoc);
  2614. node$1.callee = base;
  2615. node$1.arguments = exprList;
  2616. base = this$1.finishNode(node$1, "CallExpression");
  2617. } else if (this$1.type === types.backQuote) {
  2618. var node$2 = this$1.startNodeAt(startPos, startLoc);
  2619. node$2.tag = base;
  2620. node$2.quasi = this$1.parseTemplate({isTagged: true});
  2621. base = this$1.finishNode(node$2, "TaggedTemplateExpression");
  2622. } else {
  2623. return base
  2624. }
  2625. }
  2626. };
  2627. // Parse an atomic expression — either a single token that is an
  2628. // expression, an expression started by a keyword like `function` or
  2629. // `new`, or an expression wrapped in punctuation like `()`, `[]`,
  2630. // or `{}`.
  2631. pp$3.parseExprAtom = function(refDestructuringErrors) {
  2632. var node, canBeArrow = this.potentialArrowAt === this.start;
  2633. switch (this.type) {
  2634. case types._super:
  2635. if (!this.inFunction)
  2636. { this.raise(this.start, "'super' outside of function or class"); }
  2637. node = this.startNode();
  2638. this.next();
  2639. // The `super` keyword can appear at below:
  2640. // SuperProperty:
  2641. // super [ Expression ]
  2642. // super . IdentifierName
  2643. // SuperCall:
  2644. // super Arguments
  2645. if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL)
  2646. { this.unexpected(); }
  2647. return this.finishNode(node, "Super")
  2648. case types._this:
  2649. node = this.startNode();
  2650. this.next();
  2651. return this.finishNode(node, "ThisExpression")
  2652. case types.name:
  2653. var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
  2654. var id = this.parseIdent(this.type !== types.name);
  2655. if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function))
  2656. { return this.parseFunction(this.startNodeAt(startPos, startLoc), false, false, true) }
  2657. if (canBeArrow && !this.canInsertSemicolon()) {
  2658. if (this.eat(types.arrow))
  2659. { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) }
  2660. if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc) {
  2661. id = this.parseIdent();
  2662. if (this.canInsertSemicolon() || !this.eat(types.arrow))
  2663. { this.unexpected(); }
  2664. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true)
  2665. }
  2666. }
  2667. return id
  2668. case types.regexp:
  2669. var value = this.value;
  2670. node = this.parseLiteral(value.value);
  2671. node.regex = {pattern: value.pattern, flags: value.flags};
  2672. return node
  2673. case types.num: case types.string:
  2674. return this.parseLiteral(this.value)
  2675. case types._null: case types._true: case types._false:
  2676. node = this.startNode();
  2677. node.value = this.type === types._null ? null : this.type === types._true;
  2678. node.raw = this.type.keyword;
  2679. this.next();
  2680. return this.finishNode(node, "Literal")
  2681. case types.parenL:
  2682. var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow);
  2683. if (refDestructuringErrors) {
  2684. if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
  2685. { refDestructuringErrors.parenthesizedAssign = start; }
  2686. if (refDestructuringErrors.parenthesizedBind < 0)
  2687. { refDestructuringErrors.parenthesizedBind = start; }
  2688. }
  2689. return expr
  2690. case types.bracketL:
  2691. node = this.startNode();
  2692. this.next();
  2693. node.elements = this.parseExprList(types.bracketR, true, true, refDestructuringErrors);
  2694. return this.finishNode(node, "ArrayExpression")
  2695. case types.braceL:
  2696. return this.parseObj(false, refDestructuringErrors)
  2697. case types._function:
  2698. node = this.startNode();
  2699. this.next();
  2700. return this.parseFunction(node, false)
  2701. case types._class:
  2702. return this.parseClass(this.startNode(), false)
  2703. case types._new:
  2704. return this.parseNew()
  2705. case types.backQuote:
  2706. return this.parseTemplate()
  2707. default:
  2708. this.unexpected();
  2709. }
  2710. };
  2711. pp$3.parseLiteral = function(value) {
  2712. var node = this.startNode();
  2713. node.value = value;
  2714. node.raw = this.input.slice(this.start, this.end);
  2715. this.next();
  2716. return this.finishNode(node, "Literal")
  2717. };
  2718. pp$3.parseParenExpression = function() {
  2719. this.expect(types.parenL);
  2720. var val = this.parseExpression();
  2721. this.expect(types.parenR);
  2722. return val
  2723. };
  2724. pp$3.parseParenAndDistinguishExpression = function(canBeArrow) {
  2725. var this$1 = this;
  2726. var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
  2727. if (this.options.ecmaVersion >= 6) {
  2728. this.next();
  2729. var innerStartPos = this.start, innerStartLoc = this.startLoc;
  2730. var exprList = [], first = true, lastIsComma = false;
  2731. var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
  2732. this.yieldPos = 0;
  2733. this.awaitPos = 0;
  2734. while (this.type !== types.parenR) {
  2735. first ? first = false : this$1.expect(types.comma);
  2736. if (allowTrailingComma && this$1.afterTrailingComma(types.parenR, true)) {
  2737. lastIsComma = true;
  2738. break
  2739. } else if (this$1.type === types.ellipsis) {
  2740. spreadStart = this$1.start;
  2741. exprList.push(this$1.parseParenItem(this$1.parseRestBinding()));
  2742. if (this$1.type === types.comma) { this$1.raise(this$1.start, "Comma is not permitted after the rest element"); }
  2743. break
  2744. } else {
  2745. exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem));
  2746. }
  2747. }
  2748. var innerEndPos = this.start, innerEndLoc = this.startLoc;
  2749. this.expect(types.parenR);
  2750. if (canBeArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
  2751. this.checkPatternErrors(refDestructuringErrors, false);
  2752. this.checkYieldAwaitInDefaultParams();
  2753. this.yieldPos = oldYieldPos;
  2754. this.awaitPos = oldAwaitPos;
  2755. return this.parseParenArrowList(startPos, startLoc, exprList)
  2756. }
  2757. if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }
  2758. if (spreadStart) { this.unexpected(spreadStart); }
  2759. this.checkExpressionErrors(refDestructuringErrors, true);
  2760. this.yieldPos = oldYieldPos || this.yieldPos;
  2761. this.awaitPos = oldAwaitPos || this.awaitPos;
  2762. if (exprList.length > 1) {
  2763. val = this.startNodeAt(innerStartPos, innerStartLoc);
  2764. val.expressions = exprList;
  2765. this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
  2766. } else {
  2767. val = exprList[0];
  2768. }
  2769. } else {
  2770. val = this.parseParenExpression();
  2771. }
  2772. if (this.options.preserveParens) {
  2773. var par = this.startNodeAt(startPos, startLoc);
  2774. par.expression = val;
  2775. return this.finishNode(par, "ParenthesizedExpression")
  2776. } else {
  2777. return val
  2778. }
  2779. };
  2780. pp$3.parseParenItem = function(item) {
  2781. return item
  2782. };
  2783. pp$3.parseParenArrowList = function(startPos, startLoc, exprList) {
  2784. return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList)
  2785. };
  2786. // New's precedence is slightly tricky. It must allow its argument to
  2787. // be a `[]` or dot subscript expression, but not a call — at least,
  2788. // not without wrapping it in parentheses. Thus, it uses the noCalls
  2789. // argument to parseSubscripts to prevent it from consuming the
  2790. // argument list.
  2791. var empty$1 = [];
  2792. pp$3.parseNew = function() {
  2793. var node = this.startNode();
  2794. var meta = this.parseIdent(true);
  2795. if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
  2796. node.meta = meta;
  2797. var containsEsc = this.containsEsc;
  2798. node.property = this.parseIdent(true);
  2799. if (node.property.name !== "target" || containsEsc)
  2800. { this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target"); }
  2801. if (!this.inFunction)
  2802. { this.raiseRecoverable(node.start, "new.target can only be used in functions"); }
  2803. return this.finishNode(node, "MetaProperty")
  2804. }
  2805. var startPos = this.start, startLoc = this.startLoc;
  2806. node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
  2807. if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false); }
  2808. else { node.arguments = empty$1; }
  2809. return this.finishNode(node, "NewExpression")
  2810. };
  2811. // Parse template expression.
  2812. pp$3.parseTemplateElement = function(ref) {
  2813. var isTagged = ref.isTagged;
  2814. var elem = this.startNode();
  2815. if (this.type === types.invalidTemplate) {
  2816. if (!isTagged) {
  2817. this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
  2818. }
  2819. elem.value = {
  2820. raw: this.value,
  2821. cooked: null
  2822. };
  2823. } else {
  2824. elem.value = {
  2825. raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
  2826. cooked: this.value
  2827. };
  2828. }
  2829. this.next();
  2830. elem.tail = this.type === types.backQuote;
  2831. return this.finishNode(elem, "TemplateElement")
  2832. };
  2833. pp$3.parseTemplate = function(ref) {
  2834. var this$1 = this;
  2835. if ( ref === void 0 ) ref = {};
  2836. var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;
  2837. var node = this.startNode();
  2838. this.next();
  2839. node.expressions = [];
  2840. var curElt = this.parseTemplateElement({isTagged: isTagged});
  2841. node.quasis = [curElt];
  2842. while (!curElt.tail) {
  2843. this$1.expect(types.dollarBraceL);
  2844. node.expressions.push(this$1.parseExpression());
  2845. this$1.expect(types.braceR);
  2846. node.quasis.push(curElt = this$1.parseTemplateElement({isTagged: isTagged}));
  2847. }
  2848. this.next();
  2849. return this.finishNode(node, "TemplateLiteral")
  2850. };
  2851. pp$3.isAsyncProp = function(prop) {
  2852. return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
  2853. (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types.star)) &&
  2854. !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
  2855. };
  2856. // Parse an object literal or binding pattern.
  2857. pp$3.parseObj = function(isPattern, refDestructuringErrors) {
  2858. var this$1 = this;
  2859. var node = this.startNode(), first = true, propHash = {};
  2860. node.properties = [];
  2861. this.next();
  2862. while (!this.eat(types.braceR)) {
  2863. if (!first) {
  2864. this$1.expect(types.comma);
  2865. if (this$1.afterTrailingComma(types.braceR)) { break }
  2866. } else { first = false; }
  2867. var prop = this$1.parseProperty(isPattern, refDestructuringErrors);
  2868. if (!isPattern) { this$1.checkPropClash(prop, propHash, refDestructuringErrors); }
  2869. node.properties.push(prop);
  2870. }
  2871. return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
  2872. };
  2873. pp$3.parseProperty = function(isPattern, refDestructuringErrors) {
  2874. var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
  2875. if (this.options.ecmaVersion >= 9 && this.eat(types.ellipsis)) {
  2876. if (isPattern) {
  2877. prop.argument = this.parseIdent(false);
  2878. if (this.type === types.comma) {
  2879. this.raise(this.start, "Comma is not permitted after the rest element");
  2880. }
  2881. return this.finishNode(prop, "RestElement")
  2882. }
  2883. // To disallow parenthesized identifier via `this.toAssignable()`.
  2884. if (this.type === types.parenL && refDestructuringErrors) {
  2885. if (refDestructuringErrors.parenthesizedAssign < 0) {
  2886. refDestructuringErrors.parenthesizedAssign = this.start;
  2887. }
  2888. if (refDestructuringErrors.parenthesizedBind < 0) {
  2889. refDestructuringErrors.parenthesizedBind = this.start;
  2890. }
  2891. }
  2892. // Parse argument.
  2893. prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
  2894. // To disallow trailing comma via `this.toAssignable()`.
  2895. if (this.type === types.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
  2896. refDestructuringErrors.trailingComma = this.start;
  2897. }
  2898. // Finish
  2899. return this.finishNode(prop, "SpreadElement")
  2900. }
  2901. if (this.options.ecmaVersion >= 6) {
  2902. prop.method = false;
  2903. prop.shorthand = false;
  2904. if (isPattern || refDestructuringErrors) {
  2905. startPos = this.start;
  2906. startLoc = this.startLoc;
  2907. }
  2908. if (!isPattern)
  2909. { isGenerator = this.eat(types.star); }
  2910. }
  2911. var containsEsc = this.containsEsc;
  2912. this.parsePropertyName(prop);
  2913. if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
  2914. isAsync = true;
  2915. isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
  2916. this.parsePropertyName(prop, refDestructuringErrors);
  2917. } else {
  2918. isAsync = false;
  2919. }
  2920. this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
  2921. return this.finishNode(prop, "Property")
  2922. };
  2923. pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
  2924. if ((isGenerator || isAsync) && this.type === types.colon)
  2925. { this.unexpected(); }
  2926. if (this.eat(types.colon)) {
  2927. prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
  2928. prop.kind = "init";
  2929. } else if (this.options.ecmaVersion >= 6 && this.type === types.parenL) {
  2930. if (isPattern) { this.unexpected(); }
  2931. prop.kind = "init";
  2932. prop.method = true;
  2933. prop.value = this.parseMethod(isGenerator, isAsync);
  2934. } else if (!isPattern && !containsEsc &&
  2935. this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
  2936. (prop.key.name === "get" || prop.key.name === "set") &&
  2937. (this.type !== types.comma && this.type !== types.braceR)) {
  2938. if (isGenerator || isAsync) { this.unexpected(); }
  2939. prop.kind = prop.key.name;
  2940. this.parsePropertyName(prop);
  2941. prop.value = this.parseMethod(false);
  2942. var paramCount = prop.kind === "get" ? 0 : 1;
  2943. if (prop.value.params.length !== paramCount) {
  2944. var start = prop.value.start;
  2945. if (prop.kind === "get")
  2946. { this.raiseRecoverable(start, "getter should have no params"); }
  2947. else
  2948. { this.raiseRecoverable(start, "setter should have exactly one param"); }
  2949. } else {
  2950. if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
  2951. { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
  2952. }
  2953. } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
  2954. this.checkUnreserved(prop.key);
  2955. prop.kind = "init";
  2956. if (isPattern) {
  2957. prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
  2958. } else if (this.type === types.eq && refDestructuringErrors) {
  2959. if (refDestructuringErrors.shorthandAssign < 0)
  2960. { refDestructuringErrors.shorthandAssign = this.start; }
  2961. prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
  2962. } else {
  2963. prop.value = prop.key;
  2964. }
  2965. prop.shorthand = true;
  2966. } else { this.unexpected(); }
  2967. };
  2968. pp$3.parsePropertyName = function(prop) {
  2969. if (this.options.ecmaVersion >= 6) {
  2970. if (this.eat(types.bracketL)) {
  2971. prop.computed = true;
  2972. prop.key = this.parseMaybeAssign();
  2973. this.expect(types.bracketR);
  2974. return prop.key
  2975. } else {
  2976. prop.computed = false;
  2977. }
  2978. }
  2979. return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(true)
  2980. };
  2981. // Initialize empty function node.
  2982. pp$3.initFunction = function(node) {
  2983. node.id = null;
  2984. if (this.options.ecmaVersion >= 6) {
  2985. node.generator = false;
  2986. node.expression = false;
  2987. }
  2988. if (this.options.ecmaVersion >= 8)
  2989. { node.async = false; }
  2990. };
  2991. // Parse object or class method.
  2992. pp$3.parseMethod = function(isGenerator, isAsync) {
  2993. var node = this.startNode(), oldInGen = this.inGenerator, oldInAsync = this.inAsync,
  2994. oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction;
  2995. this.initFunction(node);
  2996. if (this.options.ecmaVersion >= 6)
  2997. { node.generator = isGenerator; }
  2998. if (this.options.ecmaVersion >= 8)
  2999. { node.async = !!isAsync; }
  3000. this.inGenerator = node.generator;
  3001. this.inAsync = node.async;
  3002. this.yieldPos = 0;
  3003. this.awaitPos = 0;
  3004. this.inFunction = true;
  3005. this.enterFunctionScope();
  3006. this.expect(types.parenL);
  3007. node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
  3008. this.checkYieldAwaitInDefaultParams();
  3009. this.parseFunctionBody(node, false);
  3010. this.inGenerator = oldInGen;
  3011. this.inAsync = oldInAsync;
  3012. this.yieldPos = oldYieldPos;
  3013. this.awaitPos = oldAwaitPos;
  3014. this.inFunction = oldInFunc;
  3015. return this.finishNode(node, "FunctionExpression")
  3016. };
  3017. // Parse arrow function expression with given parameters.
  3018. pp$3.parseArrowExpression = function(node, params, isAsync) {
  3019. var oldInGen = this.inGenerator, oldInAsync = this.inAsync,
  3020. oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction;
  3021. this.enterFunctionScope();
  3022. this.initFunction(node);
  3023. if (this.options.ecmaVersion >= 8)
  3024. { node.async = !!isAsync; }
  3025. this.inGenerator = false;
  3026. this.inAsync = node.async;
  3027. this.yieldPos = 0;
  3028. this.awaitPos = 0;
  3029. this.inFunction = true;
  3030. node.params = this.toAssignableList(params, true);
  3031. this.parseFunctionBody(node, true);
  3032. this.inGenerator = oldInGen;
  3033. this.inAsync = oldInAsync;
  3034. this.yieldPos = oldYieldPos;
  3035. this.awaitPos = oldAwaitPos;
  3036. this.inFunction = oldInFunc;
  3037. return this.finishNode(node, "ArrowFunctionExpression")
  3038. };
  3039. // Parse function body and check parameters.
  3040. pp$3.parseFunctionBody = function(node, isArrowFunction) {
  3041. var isExpression = isArrowFunction && this.type !== types.braceL;
  3042. var oldStrict = this.strict, useStrict = false;
  3043. if (isExpression) {
  3044. node.body = this.parseMaybeAssign();
  3045. node.expression = true;
  3046. this.checkParams(node, false);
  3047. } else {
  3048. var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
  3049. if (!oldStrict || nonSimple) {
  3050. useStrict = this.strictDirective(this.end);
  3051. // If this is a strict mode function, verify that argument names
  3052. // are not repeated, and it does not try to bind the words `eval`
  3053. // or `arguments`.
  3054. if (useStrict && nonSimple)
  3055. { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); }
  3056. }
  3057. // Start a new scope with regard to labels and the `inFunction`
  3058. // flag (restore them to their old value afterwards).
  3059. var oldLabels = this.labels;
  3060. this.labels = [];
  3061. if (useStrict) { this.strict = true; }
  3062. // Add the params to varDeclaredNames to ensure that an error is thrown
  3063. // if a let/const declaration in the function clashes with one of the params.
  3064. this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && this.isSimpleParamList(node.params));
  3065. node.body = this.parseBlock(false);
  3066. node.expression = false;
  3067. this.adaptDirectivePrologue(node.body.body);
  3068. this.labels = oldLabels;
  3069. }
  3070. this.exitFunctionScope();
  3071. if (this.strict && node.id) {
  3072. // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
  3073. this.checkLVal(node.id, "none");
  3074. }
  3075. this.strict = oldStrict;
  3076. };
  3077. pp$3.isSimpleParamList = function(params) {
  3078. for (var i = 0, list = params; i < list.length; i += 1)
  3079. {
  3080. var param = list[i];
  3081. if (param.type !== "Identifier") { return false
  3082. } }
  3083. return true
  3084. };
  3085. // Checks function params for various disallowed patterns such as using "eval"
  3086. // or "arguments" and duplicate parameters.
  3087. pp$3.checkParams = function(node, allowDuplicates) {
  3088. var this$1 = this;
  3089. var nameHash = {};
  3090. for (var i = 0, list = node.params; i < list.length; i += 1)
  3091. {
  3092. var param = list[i];
  3093. this$1.checkLVal(param, "var", allowDuplicates ? null : nameHash);
  3094. }
  3095. };
  3096. // Parses a comma-separated list of expressions, and returns them as
  3097. // an array. `close` is the token type that ends the list, and
  3098. // `allowEmpty` can be turned on to allow subsequent commas with
  3099. // nothing in between them to be parsed as `null` (which is needed
  3100. // for array literals).
  3101. pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
  3102. var this$1 = this;
  3103. var elts = [], first = true;
  3104. while (!this.eat(close)) {
  3105. if (!first) {
  3106. this$1.expect(types.comma);
  3107. if (allowTrailingComma && this$1.afterTrailingComma(close)) { break }
  3108. } else { first = false; }
  3109. var elt = (void 0);
  3110. if (allowEmpty && this$1.type === types.comma)
  3111. { elt = null; }
  3112. else if (this$1.type === types.ellipsis) {
  3113. elt = this$1.parseSpread(refDestructuringErrors);
  3114. if (refDestructuringErrors && this$1.type === types.comma && refDestructuringErrors.trailingComma < 0)
  3115. { refDestructuringErrors.trailingComma = this$1.start; }
  3116. } else {
  3117. elt = this$1.parseMaybeAssign(false, refDestructuringErrors);
  3118. }
  3119. elts.push(elt);
  3120. }
  3121. return elts
  3122. };
  3123. pp$3.checkUnreserved = function(ref) {
  3124. var start = ref.start;
  3125. var end = ref.end;
  3126. var name = ref.name;
  3127. if (this.inGenerator && name === "yield")
  3128. { this.raiseRecoverable(start, "Can not use 'yield' as identifier inside a generator"); }
  3129. if (this.inAsync && name === "await")
  3130. { this.raiseRecoverable(start, "Can not use 'await' as identifier inside an async function"); }
  3131. if (this.isKeyword(name))
  3132. { this.raise(start, ("Unexpected keyword '" + name + "'")); }
  3133. if (this.options.ecmaVersion < 6 &&
  3134. this.input.slice(start, end).indexOf("\\") !== -1) { return }
  3135. var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
  3136. if (re.test(name)) {
  3137. if (!this.inAsync && name === "await")
  3138. { this.raiseRecoverable(start, "Can not use keyword 'await' outside an async function"); }
  3139. this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved"));
  3140. }
  3141. };
  3142. // Parse the next token as an identifier. If `liberal` is true (used
  3143. // when parsing properties), it will also convert keywords into
  3144. // identifiers.
  3145. pp$3.parseIdent = function(liberal, isBinding) {
  3146. var node = this.startNode();
  3147. if (liberal && this.options.allowReserved === "never") { liberal = false; }
  3148. if (this.type === types.name) {
  3149. node.name = this.value;
  3150. } else if (this.type.keyword) {
  3151. node.name = this.type.keyword;
  3152. // To fix https://github.com/acornjs/acorn/issues/575
  3153. // `class` and `function` keywords push new context into this.context.
  3154. // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
  3155. // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
  3156. if ((node.name === "class" || node.name === "function") &&
  3157. (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
  3158. this.context.pop();
  3159. }
  3160. } else {
  3161. this.unexpected();
  3162. }
  3163. this.next();
  3164. this.finishNode(node, "Identifier");
  3165. if (!liberal) { this.checkUnreserved(node); }
  3166. return node
  3167. };
  3168. // Parses yield expression inside generator.
  3169. pp$3.parseYield = function() {
  3170. if (!this.yieldPos) { this.yieldPos = this.start; }
  3171. var node = this.startNode();
  3172. this.next();
  3173. if (this.type === types.semi || this.canInsertSemicolon() || (this.type !== types.star && !this.type.startsExpr)) {
  3174. node.delegate = false;
  3175. node.argument = null;
  3176. } else {
  3177. node.delegate = this.eat(types.star);
  3178. node.argument = this.parseMaybeAssign();
  3179. }
  3180. return this.finishNode(node, "YieldExpression")
  3181. };
  3182. pp$3.parseAwait = function() {
  3183. if (!this.awaitPos) { this.awaitPos = this.start; }
  3184. var node = this.startNode();
  3185. this.next();
  3186. node.argument = this.parseMaybeUnary(null, true);
  3187. return this.finishNode(node, "AwaitExpression")
  3188. };
  3189. var pp$4 = Parser.prototype;
  3190. // This function is used to raise exceptions on parse errors. It
  3191. // takes an offset integer (into the current `input`) to indicate
  3192. // the location of the error, attaches the position to the end
  3193. // of the error message, and then raises a `SyntaxError` with that
  3194. // message.
  3195. pp$4.raise = function(pos, message) {
  3196. var loc = getLineInfo(this.input, pos);
  3197. message += " (" + loc.line + ":" + loc.column + ")";
  3198. var err = new SyntaxError(message);
  3199. err.pos = pos; err.loc = loc; err.raisedAt = this.pos;
  3200. throw err
  3201. };
  3202. pp$4.raiseRecoverable = pp$4.raise;
  3203. pp$4.curPosition = function() {
  3204. if (this.options.locations) {
  3205. return new Position(this.curLine, this.pos - this.lineStart)
  3206. }
  3207. };
  3208. var pp$5 = Parser.prototype;
  3209. // Object.assign polyfill
  3210. var assign = Object.assign || function(target) {
  3211. var sources = [], len = arguments.length - 1;
  3212. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  3213. for (var i = 0, list = sources; i < list.length; i += 1) {
  3214. var source = list[i];
  3215. for (var key in source) {
  3216. if (has(source, key)) {
  3217. target[key] = source[key];
  3218. }
  3219. }
  3220. }
  3221. return target
  3222. };
  3223. // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
  3224. pp$5.enterFunctionScope = function() {
  3225. // var: a hash of var-declared names in the current lexical scope
  3226. // lexical: a hash of lexically-declared names in the current lexical scope
  3227. // childVar: a hash of var-declared names in all child lexical scopes of the current lexical scope (within the current function scope)
  3228. // parentLexical: a hash of lexically-declared names in all parent lexical scopes of the current lexical scope (within the current function scope)
  3229. this.scopeStack.push({"var": {}, lexical: {}, childVar: {}, parentLexical: {}});
  3230. };
  3231. pp$5.exitFunctionScope = function() {
  3232. this.scopeStack.pop();
  3233. };
  3234. pp$5.enterLexicalScope = function() {
  3235. var parentScope = this.scopeStack[this.scopeStack.length - 1];
  3236. var childScope = {"var": {}, lexical: {}, childVar: {}, parentLexical: {}};
  3237. this.scopeStack.push(childScope);
  3238. assign(childScope.parentLexical, parentScope.lexical, parentScope.parentLexical);
  3239. };
  3240. pp$5.exitLexicalScope = function() {
  3241. var childScope = this.scopeStack.pop();
  3242. var parentScope = this.scopeStack[this.scopeStack.length - 1];
  3243. assign(parentScope.childVar, childScope["var"], childScope.childVar);
  3244. };
  3245. /**
  3246. * A name can be declared with `var` if there are no variables with the same name declared with `let`/`const`
  3247. * in the current lexical scope or any of the parent lexical scopes in this function.
  3248. */
  3249. pp$5.canDeclareVarName = function(name) {
  3250. var currentScope = this.scopeStack[this.scopeStack.length - 1];
  3251. return !has(currentScope.lexical, name) && !has(currentScope.parentLexical, name)
  3252. };
  3253. /**
  3254. * A name can be declared with `let`/`const` if there are no variables with the same name declared with `let`/`const`
  3255. * in the current scope, and there are no variables with the same name declared with `var` in the current scope or in
  3256. * any child lexical scopes in this function.
  3257. */
  3258. pp$5.canDeclareLexicalName = function(name) {
  3259. var currentScope = this.scopeStack[this.scopeStack.length - 1];
  3260. return !has(currentScope.lexical, name) && !has(currentScope["var"], name) && !has(currentScope.childVar, name)
  3261. };
  3262. pp$5.declareVarName = function(name) {
  3263. this.scopeStack[this.scopeStack.length - 1]["var"][name] = true;
  3264. };
  3265. pp$5.declareLexicalName = function(name) {
  3266. this.scopeStack[this.scopeStack.length - 1].lexical[name] = true;
  3267. };
  3268. var Node = function Node(parser, pos, loc) {
  3269. this.type = "";
  3270. this.start = pos;
  3271. this.end = 0;
  3272. if (parser.options.locations)
  3273. { this.loc = new SourceLocation(parser, loc); }
  3274. if (parser.options.directSourceFile)
  3275. { this.sourceFile = parser.options.directSourceFile; }
  3276. if (parser.options.ranges)
  3277. { this.range = [pos, 0]; }
  3278. };
  3279. // Start an AST node, attaching a start offset.
  3280. var pp$6 = Parser.prototype;
  3281. pp$6.startNode = function() {
  3282. return new Node(this, this.start, this.startLoc)
  3283. };
  3284. pp$6.startNodeAt = function(pos, loc) {
  3285. return new Node(this, pos, loc)
  3286. };
  3287. // Finish an AST node, adding `type` and `end` properties.
  3288. function finishNodeAt(node, type, pos, loc) {
  3289. node.type = type;
  3290. node.end = pos;
  3291. if (this.options.locations)
  3292. { node.loc.end = loc; }
  3293. if (this.options.ranges)
  3294. { node.range[1] = pos; }
  3295. return node
  3296. }
  3297. pp$6.finishNode = function(node, type) {
  3298. return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
  3299. };
  3300. // Finish node at given position
  3301. pp$6.finishNodeAt = function(node, type, pos, loc) {
  3302. return finishNodeAt.call(this, node, type, pos, loc)
  3303. };
  3304. // The algorithm used to determine whether a regexp can appear at a
  3305. // given point in the program is loosely based on sweet.js' approach.
  3306. // See https://github.com/mozilla/sweet.js/wiki/design
  3307. var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
  3308. this.token = token;
  3309. this.isExpr = !!isExpr;
  3310. this.preserveSpace = !!preserveSpace;
  3311. this.override = override;
  3312. this.generator = !!generator;
  3313. };
  3314. var types$1 = {
  3315. b_stat: new TokContext("{", false),
  3316. b_expr: new TokContext("{", true),
  3317. b_tmpl: new TokContext("${", false),
  3318. p_stat: new TokContext("(", false),
  3319. p_expr: new TokContext("(", true),
  3320. q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
  3321. f_stat: new TokContext("function", false),
  3322. f_expr: new TokContext("function", true),
  3323. f_expr_gen: new TokContext("function", true, false, null, true),
  3324. f_gen: new TokContext("function", false, false, null, true)
  3325. };
  3326. var pp$7 = Parser.prototype;
  3327. pp$7.initialContext = function() {
  3328. return [types$1.b_stat]
  3329. };
  3330. pp$7.braceIsBlock = function(prevType) {
  3331. var parent = this.curContext();
  3332. if (parent === types$1.f_expr || parent === types$1.f_stat)
  3333. { return true }
  3334. if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr))
  3335. { return !parent.isExpr }
  3336. // The check for `tt.name && exprAllowed` detects whether we are
  3337. // after a `yield` or `of` construct. See the `updateContext` for
  3338. // `tt.name`.
  3339. if (prevType === types._return || prevType === types.name && this.exprAllowed)
  3340. { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
  3341. if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow)
  3342. { return true }
  3343. if (prevType === types.braceL)
  3344. { return parent === types$1.b_stat }
  3345. if (prevType === types._var || prevType === types.name)
  3346. { return false }
  3347. return !this.exprAllowed
  3348. };
  3349. pp$7.inGeneratorContext = function() {
  3350. var this$1 = this;
  3351. for (var i = this.context.length - 1; i >= 1; i--) {
  3352. var context = this$1.context[i];
  3353. if (context.token === "function")
  3354. { return context.generator }
  3355. }
  3356. return false
  3357. };
  3358. pp$7.updateContext = function(prevType) {
  3359. var update, type = this.type;
  3360. if (type.keyword && prevType === types.dot)
  3361. { this.exprAllowed = false; }
  3362. else if (update = type.updateContext)
  3363. { update.call(this, prevType); }
  3364. else
  3365. { this.exprAllowed = type.beforeExpr; }
  3366. };
  3367. // Token-specific context update code
  3368. types.parenR.updateContext = types.braceR.updateContext = function() {
  3369. if (this.context.length === 1) {
  3370. this.exprAllowed = true;
  3371. return
  3372. }
  3373. var out = this.context.pop();
  3374. if (out === types$1.b_stat && this.curContext().token === "function") {
  3375. out = this.context.pop();
  3376. }
  3377. this.exprAllowed = !out.isExpr;
  3378. };
  3379. types.braceL.updateContext = function(prevType) {
  3380. this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr);
  3381. this.exprAllowed = true;
  3382. };
  3383. types.dollarBraceL.updateContext = function() {
  3384. this.context.push(types$1.b_tmpl);
  3385. this.exprAllowed = true;
  3386. };
  3387. types.parenL.updateContext = function(prevType) {
  3388. var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
  3389. this.context.push(statementParens ? types$1.p_stat : types$1.p_expr);
  3390. this.exprAllowed = true;
  3391. };
  3392. types.incDec.updateContext = function() {
  3393. // tokExprAllowed stays unchanged
  3394. };
  3395. types._function.updateContext = types._class.updateContext = function(prevType) {
  3396. if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else &&
  3397. !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat))
  3398. { this.context.push(types$1.f_expr); }
  3399. else
  3400. { this.context.push(types$1.f_stat); }
  3401. this.exprAllowed = false;
  3402. };
  3403. types.backQuote.updateContext = function() {
  3404. if (this.curContext() === types$1.q_tmpl)
  3405. { this.context.pop(); }
  3406. else
  3407. { this.context.push(types$1.q_tmpl); }
  3408. this.exprAllowed = false;
  3409. };
  3410. types.star.updateContext = function(prevType) {
  3411. if (prevType === types._function) {
  3412. var index = this.context.length - 1;
  3413. if (this.context[index] === types$1.f_expr)
  3414. { this.context[index] = types$1.f_expr_gen; }
  3415. else
  3416. { this.context[index] = types$1.f_gen; }
  3417. }
  3418. this.exprAllowed = true;
  3419. };
  3420. types.name.updateContext = function(prevType) {
  3421. var allowed = false;
  3422. if (this.options.ecmaVersion >= 6) {
  3423. if (this.value === "of" && !this.exprAllowed ||
  3424. this.value === "yield" && this.inGeneratorContext())
  3425. { allowed = true; }
  3426. }
  3427. this.exprAllowed = allowed;
  3428. };
  3429. var data = {
  3430. "$LONE": [
  3431. "ASCII",
  3432. "ASCII_Hex_Digit",
  3433. "AHex",
  3434. "Alphabetic",
  3435. "Alpha",
  3436. "Any",
  3437. "Assigned",
  3438. "Bidi_Control",
  3439. "Bidi_C",
  3440. "Bidi_Mirrored",
  3441. "Bidi_M",
  3442. "Case_Ignorable",
  3443. "CI",
  3444. "Cased",
  3445. "Changes_When_Casefolded",
  3446. "CWCF",
  3447. "Changes_When_Casemapped",
  3448. "CWCM",
  3449. "Changes_When_Lowercased",
  3450. "CWL",
  3451. "Changes_When_NFKC_Casefolded",
  3452. "CWKCF",
  3453. "Changes_When_Titlecased",
  3454. "CWT",
  3455. "Changes_When_Uppercased",
  3456. "CWU",
  3457. "Dash",
  3458. "Default_Ignorable_Code_Point",
  3459. "DI",
  3460. "Deprecated",
  3461. "Dep",
  3462. "Diacritic",
  3463. "Dia",
  3464. "Emoji",
  3465. "Emoji_Component",
  3466. "Emoji_Modifier",
  3467. "Emoji_Modifier_Base",
  3468. "Emoji_Presentation",
  3469. "Extender",
  3470. "Ext",
  3471. "Grapheme_Base",
  3472. "Gr_Base",
  3473. "Grapheme_Extend",
  3474. "Gr_Ext",
  3475. "Hex_Digit",
  3476. "Hex",
  3477. "IDS_Binary_Operator",
  3478. "IDSB",
  3479. "IDS_Trinary_Operator",
  3480. "IDST",
  3481. "ID_Continue",
  3482. "IDC",
  3483. "ID_Start",
  3484. "IDS",
  3485. "Ideographic",
  3486. "Ideo",
  3487. "Join_Control",
  3488. "Join_C",
  3489. "Logical_Order_Exception",
  3490. "LOE",
  3491. "Lowercase",
  3492. "Lower",
  3493. "Math",
  3494. "Noncharacter_Code_Point",
  3495. "NChar",
  3496. "Pattern_Syntax",
  3497. "Pat_Syn",
  3498. "Pattern_White_Space",
  3499. "Pat_WS",
  3500. "Quotation_Mark",
  3501. "QMark",
  3502. "Radical",
  3503. "Regional_Indicator",
  3504. "RI",
  3505. "Sentence_Terminal",
  3506. "STerm",
  3507. "Soft_Dotted",
  3508. "SD",
  3509. "Terminal_Punctuation",
  3510. "Term",
  3511. "Unified_Ideograph",
  3512. "UIdeo",
  3513. "Uppercase",
  3514. "Upper",
  3515. "Variation_Selector",
  3516. "VS",
  3517. "White_Space",
  3518. "space",
  3519. "XID_Continue",
  3520. "XIDC",
  3521. "XID_Start",
  3522. "XIDS"
  3523. ],
  3524. "General_Category": [
  3525. "Cased_Letter",
  3526. "LC",
  3527. "Close_Punctuation",
  3528. "Pe",
  3529. "Connector_Punctuation",
  3530. "Pc",
  3531. "Control",
  3532. "Cc",
  3533. "cntrl",
  3534. "Currency_Symbol",
  3535. "Sc",
  3536. "Dash_Punctuation",
  3537. "Pd",
  3538. "Decimal_Number",
  3539. "Nd",
  3540. "digit",
  3541. "Enclosing_Mark",
  3542. "Me",
  3543. "Final_Punctuation",
  3544. "Pf",
  3545. "Format",
  3546. "Cf",
  3547. "Initial_Punctuation",
  3548. "Pi",
  3549. "Letter",
  3550. "L",
  3551. "Letter_Number",
  3552. "Nl",
  3553. "Line_Separator",
  3554. "Zl",
  3555. "Lowercase_Letter",
  3556. "Ll",
  3557. "Mark",
  3558. "M",
  3559. "Combining_Mark",
  3560. "Math_Symbol",
  3561. "Sm",
  3562. "Modifier_Letter",
  3563. "Lm",
  3564. "Modifier_Symbol",
  3565. "Sk",
  3566. "Nonspacing_Mark",
  3567. "Mn",
  3568. "Number",
  3569. "N",
  3570. "Open_Punctuation",
  3571. "Ps",
  3572. "Other",
  3573. "C",
  3574. "Other_Letter",
  3575. "Lo",
  3576. "Other_Number",
  3577. "No",
  3578. "Other_Punctuation",
  3579. "Po",
  3580. "Other_Symbol",
  3581. "So",
  3582. "Paragraph_Separator",
  3583. "Zp",
  3584. "Private_Use",
  3585. "Co",
  3586. "Punctuation",
  3587. "P",
  3588. "punct",
  3589. "Separator",
  3590. "Z",
  3591. "Space_Separator",
  3592. "Zs",
  3593. "Spacing_Mark",
  3594. "Mc",
  3595. "Surrogate",
  3596. "Cs",
  3597. "Symbol",
  3598. "S",
  3599. "Titlecase_Letter",
  3600. "Lt",
  3601. "Unassigned",
  3602. "Cn",
  3603. "Uppercase_Letter",
  3604. "Lu"
  3605. ],
  3606. "Script": [
  3607. "Adlam",
  3608. "Adlm",
  3609. "Ahom",
  3610. "Anatolian_Hieroglyphs",
  3611. "Hluw",
  3612. "Arabic",
  3613. "Arab",
  3614. "Armenian",
  3615. "Armn",
  3616. "Avestan",
  3617. "Avst",
  3618. "Balinese",
  3619. "Bali",
  3620. "Bamum",
  3621. "Bamu",
  3622. "Bassa_Vah",
  3623. "Bass",
  3624. "Batak",
  3625. "Batk",
  3626. "Bengali",
  3627. "Beng",
  3628. "Bhaiksuki",
  3629. "Bhks",
  3630. "Bopomofo",
  3631. "Bopo",
  3632. "Brahmi",
  3633. "Brah",
  3634. "Braille",
  3635. "Brai",
  3636. "Buginese",
  3637. "Bugi",
  3638. "Buhid",
  3639. "Buhd",
  3640. "Canadian_Aboriginal",
  3641. "Cans",
  3642. "Carian",
  3643. "Cari",
  3644. "Caucasian_Albanian",
  3645. "Aghb",
  3646. "Chakma",
  3647. "Cakm",
  3648. "Cham",
  3649. "Cherokee",
  3650. "Cher",
  3651. "Common",
  3652. "Zyyy",
  3653. "Coptic",
  3654. "Copt",
  3655. "Qaac",
  3656. "Cuneiform",
  3657. "Xsux",
  3658. "Cypriot",
  3659. "Cprt",
  3660. "Cyrillic",
  3661. "Cyrl",
  3662. "Deseret",
  3663. "Dsrt",
  3664. "Devanagari",
  3665. "Deva",
  3666. "Duployan",
  3667. "Dupl",
  3668. "Egyptian_Hieroglyphs",
  3669. "Egyp",
  3670. "Elbasan",
  3671. "Elba",
  3672. "Ethiopic",
  3673. "Ethi",
  3674. "Georgian",
  3675. "Geor",
  3676. "Glagolitic",
  3677. "Glag",
  3678. "Gothic",
  3679. "Goth",
  3680. "Grantha",
  3681. "Gran",
  3682. "Greek",
  3683. "Grek",
  3684. "Gujarati",
  3685. "Gujr",
  3686. "Gurmukhi",
  3687. "Guru",
  3688. "Han",
  3689. "Hani",
  3690. "Hangul",
  3691. "Hang",
  3692. "Hanunoo",
  3693. "Hano",
  3694. "Hatran",
  3695. "Hatr",
  3696. "Hebrew",
  3697. "Hebr",
  3698. "Hiragana",
  3699. "Hira",
  3700. "Imperial_Aramaic",
  3701. "Armi",
  3702. "Inherited",
  3703. "Zinh",
  3704. "Qaai",
  3705. "Inscriptional_Pahlavi",
  3706. "Phli",
  3707. "Inscriptional_Parthian",
  3708. "Prti",
  3709. "Javanese",
  3710. "Java",
  3711. "Kaithi",
  3712. "Kthi",
  3713. "Kannada",
  3714. "Knda",
  3715. "Katakana",
  3716. "Kana",
  3717. "Kayah_Li",
  3718. "Kali",
  3719. "Kharoshthi",
  3720. "Khar",
  3721. "Khmer",
  3722. "Khmr",
  3723. "Khojki",
  3724. "Khoj",
  3725. "Khudawadi",
  3726. "Sind",
  3727. "Lao",
  3728. "Laoo",
  3729. "Latin",
  3730. "Latn",
  3731. "Lepcha",
  3732. "Lepc",
  3733. "Limbu",
  3734. "Limb",
  3735. "Linear_A",
  3736. "Lina",
  3737. "Linear_B",
  3738. "Linb",
  3739. "Lisu",
  3740. "Lycian",
  3741. "Lyci",
  3742. "Lydian",
  3743. "Lydi",
  3744. "Mahajani",
  3745. "Mahj",
  3746. "Malayalam",
  3747. "Mlym",
  3748. "Mandaic",
  3749. "Mand",
  3750. "Manichaean",
  3751. "Mani",
  3752. "Marchen",
  3753. "Marc",
  3754. "Masaram_Gondi",
  3755. "Gonm",
  3756. "Meetei_Mayek",
  3757. "Mtei",
  3758. "Mende_Kikakui",
  3759. "Mend",
  3760. "Meroitic_Cursive",
  3761. "Merc",
  3762. "Meroitic_Hieroglyphs",
  3763. "Mero",
  3764. "Miao",
  3765. "Plrd",
  3766. "Modi",
  3767. "Mongolian",
  3768. "Mong",
  3769. "Mro",
  3770. "Mroo",
  3771. "Multani",
  3772. "Mult",
  3773. "Myanmar",
  3774. "Mymr",
  3775. "Nabataean",
  3776. "Nbat",
  3777. "New_Tai_Lue",
  3778. "Talu",
  3779. "Newa",
  3780. "Nko",
  3781. "Nkoo",
  3782. "Nushu",
  3783. "Nshu",
  3784. "Ogham",
  3785. "Ogam",
  3786. "Ol_Chiki",
  3787. "Olck",
  3788. "Old_Hungarian",
  3789. "Hung",
  3790. "Old_Italic",
  3791. "Ital",
  3792. "Old_North_Arabian",
  3793. "Narb",
  3794. "Old_Permic",
  3795. "Perm",
  3796. "Old_Persian",
  3797. "Xpeo",
  3798. "Old_South_Arabian",
  3799. "Sarb",
  3800. "Old_Turkic",
  3801. "Orkh",
  3802. "Oriya",
  3803. "Orya",
  3804. "Osage",
  3805. "Osge",
  3806. "Osmanya",
  3807. "Osma",
  3808. "Pahawh_Hmong",
  3809. "Hmng",
  3810. "Palmyrene",
  3811. "Palm",
  3812. "Pau_Cin_Hau",
  3813. "Pauc",
  3814. "Phags_Pa",
  3815. "Phag",
  3816. "Phoenician",
  3817. "Phnx",
  3818. "Psalter_Pahlavi",
  3819. "Phlp",
  3820. "Rejang",
  3821. "Rjng",
  3822. "Runic",
  3823. "Runr",
  3824. "Samaritan",
  3825. "Samr",
  3826. "Saurashtra",
  3827. "Saur",
  3828. "Sharada",
  3829. "Shrd",
  3830. "Shavian",
  3831. "Shaw",
  3832. "Siddham",
  3833. "Sidd",
  3834. "SignWriting",
  3835. "Sgnw",
  3836. "Sinhala",
  3837. "Sinh",
  3838. "Sora_Sompeng",
  3839. "Sora",
  3840. "Soyombo",
  3841. "Soyo",
  3842. "Sundanese",
  3843. "Sund",
  3844. "Syloti_Nagri",
  3845. "Sylo",
  3846. "Syriac",
  3847. "Syrc",
  3848. "Tagalog",
  3849. "Tglg",
  3850. "Tagbanwa",
  3851. "Tagb",
  3852. "Tai_Le",
  3853. "Tale",
  3854. "Tai_Tham",
  3855. "Lana",
  3856. "Tai_Viet",
  3857. "Tavt",
  3858. "Takri",
  3859. "Takr",
  3860. "Tamil",
  3861. "Taml",
  3862. "Tangut",
  3863. "Tang",
  3864. "Telugu",
  3865. "Telu",
  3866. "Thaana",
  3867. "Thaa",
  3868. "Thai",
  3869. "Tibetan",
  3870. "Tibt",
  3871. "Tifinagh",
  3872. "Tfng",
  3873. "Tirhuta",
  3874. "Tirh",
  3875. "Ugaritic",
  3876. "Ugar",
  3877. "Vai",
  3878. "Vaii",
  3879. "Warang_Citi",
  3880. "Wara",
  3881. "Yi",
  3882. "Yiii",
  3883. "Zanabazar_Square",
  3884. "Zanb"
  3885. ]
  3886. };
  3887. Array.prototype.push.apply(data.$LONE, data.General_Category);
  3888. data.gc = data.General_Category;
  3889. data.sc = data.Script_Extensions = data.scx = data.Script;
  3890. var pp$9 = Parser.prototype;
  3891. var RegExpValidationState = function RegExpValidationState(parser) {
  3892. this.parser = parser;
  3893. this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "");
  3894. this.source = "";
  3895. this.flags = "";
  3896. this.start = 0;
  3897. this.switchU = false;
  3898. this.switchN = false;
  3899. this.pos = 0;
  3900. this.lastIntValue = 0;
  3901. this.lastStringValue = "";
  3902. this.lastAssertionIsQuantifiable = false;
  3903. this.numCapturingParens = 0;
  3904. this.maxBackReference = 0;
  3905. this.groupNames = [];
  3906. this.backReferenceNames = [];
  3907. };
  3908. RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
  3909. var unicode = flags.indexOf("u") !== -1;
  3910. this.start = start | 0;
  3911. this.source = pattern + "";
  3912. this.flags = flags;
  3913. this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
  3914. this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
  3915. };
  3916. RegExpValidationState.prototype.raise = function raise (message) {
  3917. this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message));
  3918. };
  3919. // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
  3920. // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
  3921. RegExpValidationState.prototype.at = function at (i) {
  3922. var s = this.source;
  3923. var l = s.length;
  3924. if (i >= l) {
  3925. return -1
  3926. }
  3927. var c = s.charCodeAt(i);
  3928. if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
  3929. return c
  3930. }
  3931. return (c << 10) + s.charCodeAt(i + 1) - 0x35FDC00
  3932. };
  3933. RegExpValidationState.prototype.nextIndex = function nextIndex (i) {
  3934. var s = this.source;
  3935. var l = s.length;
  3936. if (i >= l) {
  3937. return l
  3938. }
  3939. var c = s.charCodeAt(i);
  3940. if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
  3941. return i + 1
  3942. }
  3943. return i + 2
  3944. };
  3945. RegExpValidationState.prototype.current = function current () {
  3946. return this.at(this.pos)
  3947. };
  3948. RegExpValidationState.prototype.lookahead = function lookahead () {
  3949. return this.at(this.nextIndex(this.pos))
  3950. };
  3951. RegExpValidationState.prototype.advance = function advance () {
  3952. this.pos = this.nextIndex(this.pos);
  3953. };
  3954. RegExpValidationState.prototype.eat = function eat (ch) {
  3955. if (this.current() === ch) {
  3956. this.advance();
  3957. return true
  3958. }
  3959. return false
  3960. };
  3961. function codePointToString$1(ch) {
  3962. if (ch <= 0xFFFF) { return String.fromCharCode(ch) }
  3963. ch -= 0x10000;
  3964. return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00)
  3965. }
  3966. /**
  3967. * Validate the flags part of a given RegExpLiteral.
  3968. *
  3969. * @param {RegExpValidationState} state The state to validate RegExp.
  3970. * @returns {void}
  3971. */
  3972. pp$9.validateRegExpFlags = function(state) {
  3973. var this$1 = this;
  3974. var validFlags = state.validFlags;
  3975. var flags = state.flags;
  3976. for (var i = 0; i < flags.length; i++) {
  3977. var flag = flags.charAt(i);
  3978. if (validFlags.indexOf(flag) === -1) {
  3979. this$1.raise(state.start, "Invalid regular expression flag");
  3980. }
  3981. if (flags.indexOf(flag, i + 1) > -1) {
  3982. this$1.raise(state.start, "Duplicate regular expression flag");
  3983. }
  3984. }
  3985. };
  3986. /**
  3987. * Validate the pattern part of a given RegExpLiteral.
  3988. *
  3989. * @param {RegExpValidationState} state The state to validate RegExp.
  3990. * @returns {void}
  3991. */
  3992. pp$9.validateRegExpPattern = function(state) {
  3993. this.regexp_pattern(state);
  3994. // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
  3995. // parsing contains a |GroupName|, reparse with the goal symbol
  3996. // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
  3997. // exception if _P_ did not conform to the grammar, if any elements of _P_
  3998. // were not matched by the parse, or if any Early Error conditions exist.
  3999. if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
  4000. state.switchN = true;
  4001. this.regexp_pattern(state);
  4002. }
  4003. };
  4004. // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
  4005. pp$9.regexp_pattern = function(state) {
  4006. state.pos = 0;
  4007. state.lastIntValue = 0;
  4008. state.lastStringValue = "";
  4009. state.lastAssertionIsQuantifiable = false;
  4010. state.numCapturingParens = 0;
  4011. state.maxBackReference = 0;
  4012. state.groupNames.length = 0;
  4013. state.backReferenceNames.length = 0;
  4014. this.regexp_disjunction(state);
  4015. if (state.pos !== state.source.length) {
  4016. // Make the same messages as V8.
  4017. if (state.eat(0x29 /* ) */)) {
  4018. state.raise("Unmatched ')'");
  4019. }
  4020. if (state.eat(0x5D /* [ */) || state.eat(0x7D /* } */)) {
  4021. state.raise("Lone quantifier brackets");
  4022. }
  4023. }
  4024. if (state.maxBackReference > state.numCapturingParens) {
  4025. state.raise("Invalid escape");
  4026. }
  4027. for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
  4028. var name = list[i];
  4029. if (state.groupNames.indexOf(name) === -1) {
  4030. state.raise("Invalid named capture referenced");
  4031. }
  4032. }
  4033. };
  4034. // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
  4035. pp$9.regexp_disjunction = function(state) {
  4036. var this$1 = this;
  4037. this.regexp_alternative(state);
  4038. while (state.eat(0x7C /* | */)) {
  4039. this$1.regexp_alternative(state);
  4040. }
  4041. // Make the same message as V8.
  4042. if (this.regexp_eatQuantifier(state, true)) {
  4043. state.raise("Nothing to repeat");
  4044. }
  4045. if (state.eat(0x7B /* { */)) {
  4046. state.raise("Lone quantifier brackets");
  4047. }
  4048. };
  4049. // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
  4050. pp$9.regexp_alternative = function(state) {
  4051. while (state.pos < state.source.length && this.regexp_eatTerm(state))
  4052. { }
  4053. };
  4054. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
  4055. pp$9.regexp_eatTerm = function(state) {
  4056. if (this.regexp_eatAssertion(state)) {
  4057. // Handle `QuantifiableAssertion Quantifier` alternative.
  4058. // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
  4059. // is a QuantifiableAssertion.
  4060. if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
  4061. // Make the same message as V8.
  4062. if (state.switchU) {
  4063. state.raise("Invalid quantifier");
  4064. }
  4065. }
  4066. return true
  4067. }
  4068. if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
  4069. this.regexp_eatQuantifier(state);
  4070. return true
  4071. }
  4072. return false
  4073. };
  4074. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
  4075. pp$9.regexp_eatAssertion = function(state) {
  4076. var start = state.pos;
  4077. state.lastAssertionIsQuantifiable = false;
  4078. // ^, $
  4079. if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {
  4080. return true
  4081. }
  4082. // \b \B
  4083. if (state.eat(0x5C /* \ */)) {
  4084. if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {
  4085. return true
  4086. }
  4087. state.pos = start;
  4088. }
  4089. // Lookahead / Lookbehind
  4090. if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {
  4091. var lookbehind = false;
  4092. if (this.options.ecmaVersion >= 9) {
  4093. lookbehind = state.eat(0x3C /* < */);
  4094. }
  4095. if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {
  4096. this.regexp_disjunction(state);
  4097. if (!state.eat(0x29 /* ) */)) {
  4098. state.raise("Unterminated group");
  4099. }
  4100. state.lastAssertionIsQuantifiable = !lookbehind;
  4101. return true
  4102. }
  4103. }
  4104. state.pos = start;
  4105. return false
  4106. };
  4107. // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
  4108. pp$9.regexp_eatQuantifier = function(state, noError) {
  4109. if ( noError === void 0 ) noError = false;
  4110. if (this.regexp_eatQuantifierPrefix(state, noError)) {
  4111. state.eat(0x3F /* ? */);
  4112. return true
  4113. }
  4114. return false
  4115. };
  4116. // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
  4117. pp$9.regexp_eatQuantifierPrefix = function(state, noError) {
  4118. return (
  4119. state.eat(0x2A /* * */) ||
  4120. state.eat(0x2B /* + */) ||
  4121. state.eat(0x3F /* ? */) ||
  4122. this.regexp_eatBracedQuantifier(state, noError)
  4123. )
  4124. };
  4125. pp$9.regexp_eatBracedQuantifier = function(state, noError) {
  4126. var start = state.pos;
  4127. if (state.eat(0x7B /* { */)) {
  4128. var min = 0, max = -1;
  4129. if (this.regexp_eatDecimalDigits(state)) {
  4130. min = state.lastIntValue;
  4131. if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {
  4132. max = state.lastIntValue;
  4133. }
  4134. if (state.eat(0x7D /* } */)) {
  4135. // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
  4136. if (max !== -1 && max < min && !noError) {
  4137. state.raise("numbers out of order in {} quantifier");
  4138. }
  4139. return true
  4140. }
  4141. }
  4142. if (state.switchU && !noError) {
  4143. state.raise("Incomplete quantifier");
  4144. }
  4145. state.pos = start;
  4146. }
  4147. return false
  4148. };
  4149. // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
  4150. pp$9.regexp_eatAtom = function(state) {
  4151. return (
  4152. this.regexp_eatPatternCharacters(state) ||
  4153. state.eat(0x2E /* . */) ||
  4154. this.regexp_eatReverseSolidusAtomEscape(state) ||
  4155. this.regexp_eatCharacterClass(state) ||
  4156. this.regexp_eatUncapturingGroup(state) ||
  4157. this.regexp_eatCapturingGroup(state)
  4158. )
  4159. };
  4160. pp$9.regexp_eatReverseSolidusAtomEscape = function(state) {
  4161. var start = state.pos;
  4162. if (state.eat(0x5C /* \ */)) {
  4163. if (this.regexp_eatAtomEscape(state)) {
  4164. return true
  4165. }
  4166. state.pos = start;
  4167. }
  4168. return false
  4169. };
  4170. pp$9.regexp_eatUncapturingGroup = function(state) {
  4171. var start = state.pos;
  4172. if (state.eat(0x28 /* ( */)) {
  4173. if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
  4174. this.regexp_disjunction(state);
  4175. if (state.eat(0x29 /* ) */)) {
  4176. return true
  4177. }
  4178. state.raise("Unterminated group");
  4179. }
  4180. state.pos = start;
  4181. }
  4182. return false
  4183. };
  4184. pp$9.regexp_eatCapturingGroup = function(state) {
  4185. if (state.eat(0x28 /* ( */)) {
  4186. if (this.options.ecmaVersion >= 9) {
  4187. this.regexp_groupSpecifier(state);
  4188. } else if (state.current() === 0x3F /* ? */) {
  4189. state.raise("Invalid group");
  4190. }
  4191. this.regexp_disjunction(state);
  4192. if (state.eat(0x29 /* ) */)) {
  4193. state.numCapturingParens += 1;
  4194. return true
  4195. }
  4196. state.raise("Unterminated group");
  4197. }
  4198. return false
  4199. };
  4200. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
  4201. pp$9.regexp_eatExtendedAtom = function(state) {
  4202. return (
  4203. state.eat(0x2E /* . */) ||
  4204. this.regexp_eatReverseSolidusAtomEscape(state) ||
  4205. this.regexp_eatCharacterClass(state) ||
  4206. this.regexp_eatUncapturingGroup(state) ||
  4207. this.regexp_eatCapturingGroup(state) ||
  4208. this.regexp_eatInvalidBracedQuantifier(state) ||
  4209. this.regexp_eatExtendedPatternCharacter(state)
  4210. )
  4211. };
  4212. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
  4213. pp$9.regexp_eatInvalidBracedQuantifier = function(state) {
  4214. if (this.regexp_eatBracedQuantifier(state, true)) {
  4215. state.raise("Nothing to repeat");
  4216. }
  4217. return false
  4218. };
  4219. // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
  4220. pp$9.regexp_eatSyntaxCharacter = function(state) {
  4221. var ch = state.current();
  4222. if (isSyntaxCharacter(ch)) {
  4223. state.lastIntValue = ch;
  4224. state.advance();
  4225. return true
  4226. }
  4227. return false
  4228. };
  4229. function isSyntaxCharacter(ch) {
  4230. return (
  4231. ch === 0x24 /* $ */ ||
  4232. ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||
  4233. ch === 0x2E /* . */ ||
  4234. ch === 0x3F /* ? */ ||
  4235. ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||
  4236. ch >= 0x7B /* { */ && ch <= 0x7D /* } */
  4237. )
  4238. }
  4239. // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
  4240. // But eat eager.
  4241. pp$9.regexp_eatPatternCharacters = function(state) {
  4242. var start = state.pos;
  4243. var ch = 0;
  4244. while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
  4245. state.advance();
  4246. }
  4247. return state.pos !== start
  4248. };
  4249. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
  4250. pp$9.regexp_eatExtendedPatternCharacter = function(state) {
  4251. var ch = state.current();
  4252. if (
  4253. ch !== -1 &&
  4254. ch !== 0x24 /* $ */ &&
  4255. !((ch >= 0x28 /* ( */ && ch <= 0x2B) /* + */) &&
  4256. ch !== 0x2E /* . */ &&
  4257. ch !== 0x3F /* ? */ &&
  4258. ch !== 0x5B /* [ */ &&
  4259. ch !== 0x5E /* ^ */ &&
  4260. ch !== 0x7C /* | */
  4261. ) {
  4262. state.advance();
  4263. return true
  4264. }
  4265. return false
  4266. };
  4267. // GroupSpecifier[U] ::
  4268. // [empty]
  4269. // `?` GroupName[?U]
  4270. pp$9.regexp_groupSpecifier = function(state) {
  4271. if (state.eat(0x3F /* ? */)) {
  4272. if (this.regexp_eatGroupName(state)) {
  4273. if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
  4274. state.raise("Duplicate capture group name");
  4275. }
  4276. state.groupNames.push(state.lastStringValue);
  4277. return
  4278. }
  4279. state.raise("Invalid group");
  4280. }
  4281. };
  4282. // GroupName[U] ::
  4283. // `<` RegExpIdentifierName[?U] `>`
  4284. // Note: this updates `state.lastStringValue` property with the eaten name.
  4285. pp$9.regexp_eatGroupName = function(state) {
  4286. state.lastStringValue = "";
  4287. if (state.eat(0x3C /* < */)) {
  4288. if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
  4289. return true
  4290. }
  4291. state.raise("Invalid capture group name");
  4292. }
  4293. return false
  4294. };
  4295. // RegExpIdentifierName[U] ::
  4296. // RegExpIdentifierStart[?U]
  4297. // RegExpIdentifierName[?U] RegExpIdentifierPart[?U]
  4298. // Note: this updates `state.lastStringValue` property with the eaten name.
  4299. pp$9.regexp_eatRegExpIdentifierName = function(state) {
  4300. state.lastStringValue = "";
  4301. if (this.regexp_eatRegExpIdentifierStart(state)) {
  4302. state.lastStringValue += codePointToString$1(state.lastIntValue);
  4303. while (this.regexp_eatRegExpIdentifierPart(state)) {
  4304. state.lastStringValue += codePointToString$1(state.lastIntValue);
  4305. }
  4306. return true
  4307. }
  4308. return false
  4309. };
  4310. // RegExpIdentifierStart[U] ::
  4311. // UnicodeIDStart
  4312. // `$`
  4313. // `_`
  4314. // `\` RegExpUnicodeEscapeSequence[?U]
  4315. pp$9.regexp_eatRegExpIdentifierStart = function(state) {
  4316. var start = state.pos;
  4317. var ch = state.current();
  4318. state.advance();
  4319. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {
  4320. ch = state.lastIntValue;
  4321. }
  4322. if (isRegExpIdentifierStart(ch)) {
  4323. state.lastIntValue = ch;
  4324. return true
  4325. }
  4326. state.pos = start;
  4327. return false
  4328. };
  4329. function isRegExpIdentifierStart(ch) {
  4330. return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
  4331. }
  4332. // RegExpIdentifierPart[U] ::
  4333. // UnicodeIDContinue
  4334. // `$`
  4335. // `_`
  4336. // `\` RegExpUnicodeEscapeSequence[?U]
  4337. // <ZWNJ>
  4338. // <ZWJ>
  4339. pp$9.regexp_eatRegExpIdentifierPart = function(state) {
  4340. var start = state.pos;
  4341. var ch = state.current();
  4342. state.advance();
  4343. if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {
  4344. ch = state.lastIntValue;
  4345. }
  4346. if (isRegExpIdentifierPart(ch)) {
  4347. state.lastIntValue = ch;
  4348. return true
  4349. }
  4350. state.pos = start;
  4351. return false
  4352. };
  4353. function isRegExpIdentifierPart(ch) {
  4354. return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* <ZWNJ> */ || ch === 0x200D /* <ZWJ> */
  4355. }
  4356. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
  4357. pp$9.regexp_eatAtomEscape = function(state) {
  4358. if (
  4359. this.regexp_eatBackReference(state) ||
  4360. this.regexp_eatCharacterClassEscape(state) ||
  4361. this.regexp_eatCharacterEscape(state) ||
  4362. (state.switchN && this.regexp_eatKGroupName(state))
  4363. ) {
  4364. return true
  4365. }
  4366. if (state.switchU) {
  4367. // Make the same message as V8.
  4368. if (state.current() === 0x63 /* c */) {
  4369. state.raise("Invalid unicode escape");
  4370. }
  4371. state.raise("Invalid escape");
  4372. }
  4373. return false
  4374. };
  4375. pp$9.regexp_eatBackReference = function(state) {
  4376. var start = state.pos;
  4377. if (this.regexp_eatDecimalEscape(state)) {
  4378. var n = state.lastIntValue;
  4379. if (state.switchU) {
  4380. // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
  4381. if (n > state.maxBackReference) {
  4382. state.maxBackReference = n;
  4383. }
  4384. return true
  4385. }
  4386. if (n <= state.numCapturingParens) {
  4387. return true
  4388. }
  4389. state.pos = start;
  4390. }
  4391. return false
  4392. };
  4393. pp$9.regexp_eatKGroupName = function(state) {
  4394. if (state.eat(0x6B /* k */)) {
  4395. if (this.regexp_eatGroupName(state)) {
  4396. state.backReferenceNames.push(state.lastStringValue);
  4397. return true
  4398. }
  4399. state.raise("Invalid named reference");
  4400. }
  4401. return false
  4402. };
  4403. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
  4404. pp$9.regexp_eatCharacterEscape = function(state) {
  4405. return (
  4406. this.regexp_eatControlEscape(state) ||
  4407. this.regexp_eatCControlLetter(state) ||
  4408. this.regexp_eatZero(state) ||
  4409. this.regexp_eatHexEscapeSequence(state) ||
  4410. this.regexp_eatRegExpUnicodeEscapeSequence(state) ||
  4411. (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
  4412. this.regexp_eatIdentityEscape(state)
  4413. )
  4414. };
  4415. pp$9.regexp_eatCControlLetter = function(state) {
  4416. var start = state.pos;
  4417. if (state.eat(0x63 /* c */)) {
  4418. if (this.regexp_eatControlLetter(state)) {
  4419. return true
  4420. }
  4421. state.pos = start;
  4422. }
  4423. return false
  4424. };
  4425. pp$9.regexp_eatZero = function(state) {
  4426. if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
  4427. state.lastIntValue = 0;
  4428. state.advance();
  4429. return true
  4430. }
  4431. return false
  4432. };
  4433. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
  4434. pp$9.regexp_eatControlEscape = function(state) {
  4435. var ch = state.current();
  4436. if (ch === 0x74 /* t */) {
  4437. state.lastIntValue = 0x09; /* \t */
  4438. state.advance();
  4439. return true
  4440. }
  4441. if (ch === 0x6E /* n */) {
  4442. state.lastIntValue = 0x0A; /* \n */
  4443. state.advance();
  4444. return true
  4445. }
  4446. if (ch === 0x76 /* v */) {
  4447. state.lastIntValue = 0x0B; /* \v */
  4448. state.advance();
  4449. return true
  4450. }
  4451. if (ch === 0x66 /* f */) {
  4452. state.lastIntValue = 0x0C; /* \f */
  4453. state.advance();
  4454. return true
  4455. }
  4456. if (ch === 0x72 /* r */) {
  4457. state.lastIntValue = 0x0D; /* \r */
  4458. state.advance();
  4459. return true
  4460. }
  4461. return false
  4462. };
  4463. // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
  4464. pp$9.regexp_eatControlLetter = function(state) {
  4465. var ch = state.current();
  4466. if (isControlLetter(ch)) {
  4467. state.lastIntValue = ch % 0x20;
  4468. state.advance();
  4469. return true
  4470. }
  4471. return false
  4472. };
  4473. function isControlLetter(ch) {
  4474. return (
  4475. (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||
  4476. (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)
  4477. )
  4478. }
  4479. // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
  4480. pp$9.regexp_eatRegExpUnicodeEscapeSequence = function(state) {
  4481. var start = state.pos;
  4482. if (state.eat(0x75 /* u */)) {
  4483. if (this.regexp_eatFixedHexDigits(state, 4)) {
  4484. var lead = state.lastIntValue;
  4485. if (state.switchU && lead >= 0xD800 && lead <= 0xDBFF) {
  4486. var leadSurrogateEnd = state.pos;
  4487. if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
  4488. var trail = state.lastIntValue;
  4489. if (trail >= 0xDC00 && trail <= 0xDFFF) {
  4490. state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  4491. return true
  4492. }
  4493. }
  4494. state.pos = leadSurrogateEnd;
  4495. state.lastIntValue = lead;
  4496. }
  4497. return true
  4498. }
  4499. if (
  4500. state.switchU &&
  4501. state.eat(0x7B /* { */) &&
  4502. this.regexp_eatHexDigits(state) &&
  4503. state.eat(0x7D /* } */) &&
  4504. isValidUnicode(state.lastIntValue)
  4505. ) {
  4506. return true
  4507. }
  4508. if (state.switchU) {
  4509. state.raise("Invalid unicode escape");
  4510. }
  4511. state.pos = start;
  4512. }
  4513. return false
  4514. };
  4515. function isValidUnicode(ch) {
  4516. return ch >= 0 && ch <= 0x10FFFF
  4517. }
  4518. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
  4519. pp$9.regexp_eatIdentityEscape = function(state) {
  4520. if (state.switchU) {
  4521. if (this.regexp_eatSyntaxCharacter(state)) {
  4522. return true
  4523. }
  4524. if (state.eat(0x2F /* / */)) {
  4525. state.lastIntValue = 0x2F; /* / */
  4526. return true
  4527. }
  4528. return false
  4529. }
  4530. var ch = state.current();
  4531. if (ch !== 0x63 /* c */ && ((!state.switchN || ch !== 0x6B) /* k */)) {
  4532. state.lastIntValue = ch;
  4533. state.advance();
  4534. return true
  4535. }
  4536. return false
  4537. };
  4538. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
  4539. pp$9.regexp_eatDecimalEscape = function(state) {
  4540. state.lastIntValue = 0;
  4541. var ch = state.current();
  4542. if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
  4543. do {
  4544. state.lastIntValue = 10 * state.lastIntValue + ((ch - 0x30) /* 0 */);
  4545. state.advance();
  4546. } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)
  4547. return true
  4548. }
  4549. return false
  4550. };
  4551. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
  4552. pp$9.regexp_eatCharacterClassEscape = function(state) {
  4553. var ch = state.current();
  4554. if (isCharacterClassEscape(ch)) {
  4555. state.lastIntValue = -1;
  4556. state.advance();
  4557. return true
  4558. }
  4559. if (
  4560. state.switchU &&
  4561. this.options.ecmaVersion >= 9 &&
  4562. ((ch === 0x50 /* P */ || ch === 0x70) /* p */)
  4563. ) {
  4564. state.lastIntValue = -1;
  4565. state.advance();
  4566. if (
  4567. state.eat(0x7B /* { */) &&
  4568. this.regexp_eatUnicodePropertyValueExpression(state) &&
  4569. state.eat(0x7D /* } */)
  4570. ) {
  4571. return true
  4572. }
  4573. state.raise("Invalid property name");
  4574. }
  4575. return false
  4576. };
  4577. function isCharacterClassEscape(ch) {
  4578. return (
  4579. ch === 0x64 /* d */ ||
  4580. ch === 0x44 /* D */ ||
  4581. ch === 0x73 /* s */ ||
  4582. ch === 0x53 /* S */ ||
  4583. ch === 0x77 /* w */ ||
  4584. ch === 0x57 /* W */
  4585. )
  4586. }
  4587. // UnicodePropertyValueExpression ::
  4588. // UnicodePropertyName `=` UnicodePropertyValue
  4589. // LoneUnicodePropertyNameOrValue
  4590. pp$9.regexp_eatUnicodePropertyValueExpression = function(state) {
  4591. var start = state.pos;
  4592. // UnicodePropertyName `=` UnicodePropertyValue
  4593. if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {
  4594. var name = state.lastStringValue;
  4595. if (this.regexp_eatUnicodePropertyValue(state)) {
  4596. var value = state.lastStringValue;
  4597. this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
  4598. return true
  4599. }
  4600. }
  4601. state.pos = start;
  4602. // LoneUnicodePropertyNameOrValue
  4603. if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
  4604. var nameOrValue = state.lastStringValue;
  4605. this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
  4606. return true
  4607. }
  4608. return false
  4609. };
  4610. pp$9.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
  4611. if (!data.hasOwnProperty(name) || data[name].indexOf(value) === -1) {
  4612. state.raise("Invalid property name");
  4613. }
  4614. };
  4615. pp$9.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
  4616. if (data.$LONE.indexOf(nameOrValue) === -1) {
  4617. state.raise("Invalid property name");
  4618. }
  4619. };
  4620. // UnicodePropertyName ::
  4621. // UnicodePropertyNameCharacters
  4622. pp$9.regexp_eatUnicodePropertyName = function(state) {
  4623. var ch = 0;
  4624. state.lastStringValue = "";
  4625. while (isUnicodePropertyNameCharacter(ch = state.current())) {
  4626. state.lastStringValue += codePointToString$1(ch);
  4627. state.advance();
  4628. }
  4629. return state.lastStringValue !== ""
  4630. };
  4631. function isUnicodePropertyNameCharacter(ch) {
  4632. return isControlLetter(ch) || ch === 0x5F /* _ */
  4633. }
  4634. // UnicodePropertyValue ::
  4635. // UnicodePropertyValueCharacters
  4636. pp$9.regexp_eatUnicodePropertyValue = function(state) {
  4637. var ch = 0;
  4638. state.lastStringValue = "";
  4639. while (isUnicodePropertyValueCharacter(ch = state.current())) {
  4640. state.lastStringValue += codePointToString$1(ch);
  4641. state.advance();
  4642. }
  4643. return state.lastStringValue !== ""
  4644. };
  4645. function isUnicodePropertyValueCharacter(ch) {
  4646. return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)
  4647. }
  4648. // LoneUnicodePropertyNameOrValue ::
  4649. // UnicodePropertyValueCharacters
  4650. pp$9.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
  4651. return this.regexp_eatUnicodePropertyValue(state)
  4652. };
  4653. // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
  4654. pp$9.regexp_eatCharacterClass = function(state) {
  4655. if (state.eat(0x5B /* [ */)) {
  4656. state.eat(0x5E /* ^ */);
  4657. this.regexp_classRanges(state);
  4658. if (state.eat(0x5D /* [ */)) {
  4659. return true
  4660. }
  4661. // Unreachable since it threw "unterminated regular expression" error before.
  4662. state.raise("Unterminated character class");
  4663. }
  4664. return false
  4665. };
  4666. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
  4667. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
  4668. // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
  4669. pp$9.regexp_classRanges = function(state) {
  4670. var this$1 = this;
  4671. while (this.regexp_eatClassAtom(state)) {
  4672. var left = state.lastIntValue;
  4673. if (state.eat(0x2D /* - */) && this$1.regexp_eatClassAtom(state)) {
  4674. var right = state.lastIntValue;
  4675. if (state.switchU && (left === -1 || right === -1)) {
  4676. state.raise("Invalid character class");
  4677. }
  4678. if (left !== -1 && right !== -1 && left > right) {
  4679. state.raise("Range out of order in character class");
  4680. }
  4681. }
  4682. }
  4683. };
  4684. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
  4685. // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
  4686. pp$9.regexp_eatClassAtom = function(state) {
  4687. var start = state.pos;
  4688. if (state.eat(0x5C /* \ */)) {
  4689. if (this.regexp_eatClassEscape(state)) {
  4690. return true
  4691. }
  4692. if (state.switchU) {
  4693. // Make the same message as V8.
  4694. var ch$1 = state.current();
  4695. if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {
  4696. state.raise("Invalid class escape");
  4697. }
  4698. state.raise("Invalid escape");
  4699. }
  4700. state.pos = start;
  4701. }
  4702. var ch = state.current();
  4703. if (ch !== 0x5D /* [ */) {
  4704. state.lastIntValue = ch;
  4705. state.advance();
  4706. return true
  4707. }
  4708. return false
  4709. };
  4710. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
  4711. pp$9.regexp_eatClassEscape = function(state) {
  4712. var start = state.pos;
  4713. if (state.eat(0x62 /* b */)) {
  4714. state.lastIntValue = 0x08; /* <BS> */
  4715. return true
  4716. }
  4717. if (state.switchU && state.eat(0x2D /* - */)) {
  4718. state.lastIntValue = 0x2D; /* - */
  4719. return true
  4720. }
  4721. if (!state.switchU && state.eat(0x63 /* c */)) {
  4722. if (this.regexp_eatClassControlLetter(state)) {
  4723. return true
  4724. }
  4725. state.pos = start;
  4726. }
  4727. return (
  4728. this.regexp_eatCharacterClassEscape(state) ||
  4729. this.regexp_eatCharacterEscape(state)
  4730. )
  4731. };
  4732. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
  4733. pp$9.regexp_eatClassControlLetter = function(state) {
  4734. var ch = state.current();
  4735. if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
  4736. state.lastIntValue = ch % 0x20;
  4737. state.advance();
  4738. return true
  4739. }
  4740. return false
  4741. };
  4742. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  4743. pp$9.regexp_eatHexEscapeSequence = function(state) {
  4744. var start = state.pos;
  4745. if (state.eat(0x78 /* x */)) {
  4746. if (this.regexp_eatFixedHexDigits(state, 2)) {
  4747. return true
  4748. }
  4749. if (state.switchU) {
  4750. state.raise("Invalid escape");
  4751. }
  4752. state.pos = start;
  4753. }
  4754. return false
  4755. };
  4756. // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
  4757. pp$9.regexp_eatDecimalDigits = function(state) {
  4758. var start = state.pos;
  4759. var ch = 0;
  4760. state.lastIntValue = 0;
  4761. while (isDecimalDigit(ch = state.current())) {
  4762. state.lastIntValue = 10 * state.lastIntValue + ((ch - 0x30) /* 0 */);
  4763. state.advance();
  4764. }
  4765. return state.pos !== start
  4766. };
  4767. function isDecimalDigit(ch) {
  4768. return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */
  4769. }
  4770. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
  4771. pp$9.regexp_eatHexDigits = function(state) {
  4772. var start = state.pos;
  4773. var ch = 0;
  4774. state.lastIntValue = 0;
  4775. while (isHexDigit(ch = state.current())) {
  4776. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  4777. state.advance();
  4778. }
  4779. return state.pos !== start
  4780. };
  4781. function isHexDigit(ch) {
  4782. return (
  4783. (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||
  4784. (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||
  4785. (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)
  4786. )
  4787. }
  4788. function hexToInt(ch) {
  4789. if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {
  4790. return 10 + ((ch - 0x41) /* A */)
  4791. }
  4792. if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {
  4793. return 10 + ((ch - 0x61) /* a */)
  4794. }
  4795. return ch - 0x30 /* 0 */
  4796. }
  4797. // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
  4798. // Allows only 0-377(octal) i.e. 0-255(decimal).
  4799. pp$9.regexp_eatLegacyOctalEscapeSequence = function(state) {
  4800. if (this.regexp_eatOctalDigit(state)) {
  4801. var n1 = state.lastIntValue;
  4802. if (this.regexp_eatOctalDigit(state)) {
  4803. var n2 = state.lastIntValue;
  4804. if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
  4805. state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
  4806. } else {
  4807. state.lastIntValue = n1 * 8 + n2;
  4808. }
  4809. } else {
  4810. state.lastIntValue = n1;
  4811. }
  4812. return true
  4813. }
  4814. return false
  4815. };
  4816. // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
  4817. pp$9.regexp_eatOctalDigit = function(state) {
  4818. var ch = state.current();
  4819. if (isOctalDigit(ch)) {
  4820. state.lastIntValue = ch - 0x30; /* 0 */
  4821. state.advance();
  4822. return true
  4823. }
  4824. state.lastIntValue = 0;
  4825. return false
  4826. };
  4827. function isOctalDigit(ch) {
  4828. return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */
  4829. }
  4830. // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
  4831. // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
  4832. // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
  4833. pp$9.regexp_eatFixedHexDigits = function(state, length) {
  4834. var start = state.pos;
  4835. state.lastIntValue = 0;
  4836. for (var i = 0; i < length; ++i) {
  4837. var ch = state.current();
  4838. if (!isHexDigit(ch)) {
  4839. state.pos = start;
  4840. return false
  4841. }
  4842. state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
  4843. state.advance();
  4844. }
  4845. return true
  4846. };
  4847. // Object type used to represent tokens. Note that normally, tokens
  4848. // simply exist as properties on the parser object. This is only
  4849. // used for the onToken callback and the external tokenizer.
  4850. var Token = function Token(p) {
  4851. this.type = p.type;
  4852. this.value = p.value;
  4853. this.start = p.start;
  4854. this.end = p.end;
  4855. if (p.options.locations)
  4856. { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); }
  4857. if (p.options.ranges)
  4858. { this.range = [p.start, p.end]; }
  4859. };
  4860. // ## Tokenizer
  4861. var pp$8 = Parser.prototype;
  4862. // Move to the next token
  4863. pp$8.next = function() {
  4864. if (this.options.onToken)
  4865. { this.options.onToken(new Token(this)); }
  4866. this.lastTokEnd = this.end;
  4867. this.lastTokStart = this.start;
  4868. this.lastTokEndLoc = this.endLoc;
  4869. this.lastTokStartLoc = this.startLoc;
  4870. this.nextToken();
  4871. };
  4872. pp$8.getToken = function() {
  4873. this.next();
  4874. return new Token(this)
  4875. };
  4876. // If we're in an ES6 environment, make parsers iterable
  4877. if (typeof Symbol !== "undefined")
  4878. { pp$8[Symbol.iterator] = function() {
  4879. var this$1 = this;
  4880. return {
  4881. next: function () {
  4882. var token = this$1.getToken();
  4883. return {
  4884. done: token.type === types.eof,
  4885. value: token
  4886. }
  4887. }
  4888. }
  4889. }; }
  4890. // Toggle strict mode. Re-reads the next number or string to please
  4891. // pedantic tests (`"use strict"; 010;` should fail).
  4892. pp$8.curContext = function() {
  4893. return this.context[this.context.length - 1]
  4894. };
  4895. // Read a single token, updating the parser object's token-related
  4896. // properties.
  4897. pp$8.nextToken = function() {
  4898. var curContext = this.curContext();
  4899. if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }
  4900. this.start = this.pos;
  4901. if (this.options.locations) { this.startLoc = this.curPosition(); }
  4902. if (this.pos >= this.input.length) { return this.finishToken(types.eof) }
  4903. if (curContext.override) { return curContext.override(this) }
  4904. else { this.readToken(this.fullCharCodeAtPos()); }
  4905. };
  4906. pp$8.readToken = function(code) {
  4907. // Identifier or keyword. '\uXXXX' sequences are allowed in
  4908. // identifiers, so '\' also dispatches to that.
  4909. if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
  4910. { return this.readWord() }
  4911. return this.getTokenFromCode(code)
  4912. };
  4913. pp$8.fullCharCodeAtPos = function() {
  4914. var code = this.input.charCodeAt(this.pos);
  4915. if (code <= 0xd7ff || code >= 0xe000) { return code }
  4916. var next = this.input.charCodeAt(this.pos + 1);
  4917. return (code << 10) + next - 0x35fdc00
  4918. };
  4919. pp$8.skipBlockComment = function() {
  4920. var this$1 = this;
  4921. var startLoc = this.options.onComment && this.curPosition();
  4922. var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
  4923. if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); }
  4924. this.pos = end + 2;
  4925. if (this.options.locations) {
  4926. lineBreakG.lastIndex = start;
  4927. var match;
  4928. while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
  4929. ++this$1.curLine;
  4930. this$1.lineStart = match.index + match[0].length;
  4931. }
  4932. }
  4933. if (this.options.onComment)
  4934. { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
  4935. startLoc, this.curPosition()); }
  4936. };
  4937. pp$8.skipLineComment = function(startSkip) {
  4938. var this$1 = this;
  4939. var start = this.pos;
  4940. var startLoc = this.options.onComment && this.curPosition();
  4941. var ch = this.input.charCodeAt(this.pos += startSkip);
  4942. while (this.pos < this.input.length && !isNewLine(ch)) {
  4943. ch = this$1.input.charCodeAt(++this$1.pos);
  4944. }
  4945. if (this.options.onComment)
  4946. { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
  4947. startLoc, this.curPosition()); }
  4948. };
  4949. // Called at the start of the parse and after every token. Skips
  4950. // whitespace and comments, and.
  4951. pp$8.skipSpace = function() {
  4952. var this$1 = this;
  4953. loop: while (this.pos < this.input.length) {
  4954. var ch = this$1.input.charCodeAt(this$1.pos);
  4955. switch (ch) {
  4956. case 32: case 160: // ' '
  4957. ++this$1.pos;
  4958. break
  4959. case 13:
  4960. if (this$1.input.charCodeAt(this$1.pos + 1) === 10) {
  4961. ++this$1.pos;
  4962. }
  4963. case 10: case 8232: case 8233:
  4964. ++this$1.pos;
  4965. if (this$1.options.locations) {
  4966. ++this$1.curLine;
  4967. this$1.lineStart = this$1.pos;
  4968. }
  4969. break
  4970. case 47: // '/'
  4971. switch (this$1.input.charCodeAt(this$1.pos + 1)) {
  4972. case 42: // '*'
  4973. this$1.skipBlockComment();
  4974. break
  4975. case 47:
  4976. this$1.skipLineComment(2);
  4977. break
  4978. default:
  4979. break loop
  4980. }
  4981. break
  4982. default:
  4983. if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
  4984. ++this$1.pos;
  4985. } else {
  4986. break loop
  4987. }
  4988. }
  4989. }
  4990. };
  4991. // Called at the end of every token. Sets `end`, `val`, and
  4992. // maintains `context` and `exprAllowed`, and skips the space after
  4993. // the token, so that the next one's `start` will point at the
  4994. // right position.
  4995. pp$8.finishToken = function(type, val) {
  4996. this.end = this.pos;
  4997. if (this.options.locations) { this.endLoc = this.curPosition(); }
  4998. var prevType = this.type;
  4999. this.type = type;
  5000. this.value = val;
  5001. this.updateContext(prevType);
  5002. };
  5003. // ### Token reading
  5004. // This is the function that is called to fetch the next token. It
  5005. // is somewhat obscure, because it works in character codes rather
  5006. // than characters, and because operator parsing has been inlined
  5007. // into it.
  5008. //
  5009. // All in the name of speed.
  5010. //
  5011. pp$8.readToken_dot = function() {
  5012. var next = this.input.charCodeAt(this.pos + 1);
  5013. if (next >= 48 && next <= 57) { return this.readNumber(true) }
  5014. var next2 = this.input.charCodeAt(this.pos + 2);
  5015. if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
  5016. this.pos += 3;
  5017. return this.finishToken(types.ellipsis)
  5018. } else {
  5019. ++this.pos;
  5020. return this.finishToken(types.dot)
  5021. }
  5022. };
  5023. pp$8.readToken_slash = function() { // '/'
  5024. var next = this.input.charCodeAt(this.pos + 1);
  5025. if (this.exprAllowed) { ++this.pos; return this.readRegexp() }
  5026. if (next === 61) { return this.finishOp(types.assign, 2) }
  5027. return this.finishOp(types.slash, 1)
  5028. };
  5029. pp$8.readToken_mult_modulo_exp = function(code) { // '%*'
  5030. var next = this.input.charCodeAt(this.pos + 1);
  5031. var size = 1;
  5032. var tokentype = code === 42 ? types.star : types.modulo;
  5033. // exponentiation operator ** and **=
  5034. if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
  5035. ++size;
  5036. tokentype = types.starstar;
  5037. next = this.input.charCodeAt(this.pos + 2);
  5038. }
  5039. if (next === 61) { return this.finishOp(types.assign, size + 1) }
  5040. return this.finishOp(tokentype, size)
  5041. };
  5042. pp$8.readToken_pipe_amp = function(code) { // '|&'
  5043. var next = this.input.charCodeAt(this.pos + 1);
  5044. if (next === code) { return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2) }
  5045. if (next === 61) { return this.finishOp(types.assign, 2) }
  5046. return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1)
  5047. };
  5048. pp$8.readToken_caret = function() { // '^'
  5049. var next = this.input.charCodeAt(this.pos + 1);
  5050. if (next === 61) { return this.finishOp(types.assign, 2) }
  5051. return this.finishOp(types.bitwiseXOR, 1)
  5052. };
  5053. pp$8.readToken_plus_min = function(code) { // '+-'
  5054. var next = this.input.charCodeAt(this.pos + 1);
  5055. if (next === code) {
  5056. if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&
  5057. (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
  5058. // A `-->` line comment
  5059. this.skipLineComment(3);
  5060. this.skipSpace();
  5061. return this.nextToken()
  5062. }
  5063. return this.finishOp(types.incDec, 2)
  5064. }
  5065. if (next === 61) { return this.finishOp(types.assign, 2) }
  5066. return this.finishOp(types.plusMin, 1)
  5067. };
  5068. pp$8.readToken_lt_gt = function(code) { // '<>'
  5069. var next = this.input.charCodeAt(this.pos + 1);
  5070. var size = 1;
  5071. if (next === code) {
  5072. size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
  5073. if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) }
  5074. return this.finishOp(types.bitShift, size)
  5075. }
  5076. if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
  5077. this.input.charCodeAt(this.pos + 3) === 45) {
  5078. // `<!--`, an XML-style comment that should be interpreted as a line comment
  5079. this.skipLineComment(4);
  5080. this.skipSpace();
  5081. return this.nextToken()
  5082. }
  5083. if (next === 61) { size = 2; }
  5084. return this.finishOp(types.relational, size)
  5085. };
  5086. pp$8.readToken_eq_excl = function(code) { // '=!'
  5087. var next = this.input.charCodeAt(this.pos + 1);
  5088. if (next === 61) { return this.finishOp(types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) }
  5089. if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
  5090. this.pos += 2;
  5091. return this.finishToken(types.arrow)
  5092. }
  5093. return this.finishOp(code === 61 ? types.eq : types.prefix, 1)
  5094. };
  5095. pp$8.getTokenFromCode = function(code) {
  5096. switch (code) {
  5097. // The interpretation of a dot depends on whether it is followed
  5098. // by a digit or another two dots.
  5099. case 46: // '.'
  5100. return this.readToken_dot()
  5101. // Punctuation tokens.
  5102. case 40: ++this.pos; return this.finishToken(types.parenL)
  5103. case 41: ++this.pos; return this.finishToken(types.parenR)
  5104. case 59: ++this.pos; return this.finishToken(types.semi)
  5105. case 44: ++this.pos; return this.finishToken(types.comma)
  5106. case 91: ++this.pos; return this.finishToken(types.bracketL)
  5107. case 93: ++this.pos; return this.finishToken(types.bracketR)
  5108. case 123: ++this.pos; return this.finishToken(types.braceL)
  5109. case 125: ++this.pos; return this.finishToken(types.braceR)
  5110. case 58: ++this.pos; return this.finishToken(types.colon)
  5111. case 63: ++this.pos; return this.finishToken(types.question)
  5112. case 96: // '`'
  5113. if (this.options.ecmaVersion < 6) { break }
  5114. ++this.pos;
  5115. return this.finishToken(types.backQuote)
  5116. case 48: // '0'
  5117. var next = this.input.charCodeAt(this.pos + 1);
  5118. if (next === 120 || next === 88) { return this.readRadixNumber(16) } // '0x', '0X' - hex number
  5119. if (this.options.ecmaVersion >= 6) {
  5120. if (next === 111 || next === 79) { return this.readRadixNumber(8) } // '0o', '0O' - octal number
  5121. if (next === 98 || next === 66) { return this.readRadixNumber(2) } // '0b', '0B' - binary number
  5122. }
  5123. // Anything else beginning with a digit is an integer, octal
  5124. // number, or float.
  5125. case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9
  5126. return this.readNumber(false)
  5127. // Quotes produce strings.
  5128. case 34: case 39: // '"', "'"
  5129. return this.readString(code)
  5130. // Operators are parsed inline in tiny state machines. '=' (61) is
  5131. // often referred to. `finishOp` simply skips the amount of
  5132. // characters it is given as second argument, and returns a token
  5133. // of the type given by its first argument.
  5134. case 47: // '/'
  5135. return this.readToken_slash()
  5136. case 37: case 42: // '%*'
  5137. return this.readToken_mult_modulo_exp(code)
  5138. case 124: case 38: // '|&'
  5139. return this.readToken_pipe_amp(code)
  5140. case 94: // '^'
  5141. return this.readToken_caret()
  5142. case 43: case 45: // '+-'
  5143. return this.readToken_plus_min(code)
  5144. case 60: case 62: // '<>'
  5145. return this.readToken_lt_gt(code)
  5146. case 61: case 33: // '=!'
  5147. return this.readToken_eq_excl(code)
  5148. case 126: // '~'
  5149. return this.finishOp(types.prefix, 1)
  5150. }
  5151. this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
  5152. };
  5153. pp$8.finishOp = function(type, size) {
  5154. var str = this.input.slice(this.pos, this.pos + size);
  5155. this.pos += size;
  5156. return this.finishToken(type, str)
  5157. };
  5158. pp$8.readRegexp = function() {
  5159. var this$1 = this;
  5160. var escaped, inClass, start = this.pos;
  5161. for (;;) {
  5162. if (this$1.pos >= this$1.input.length) { this$1.raise(start, "Unterminated regular expression"); }
  5163. var ch = this$1.input.charAt(this$1.pos);
  5164. if (lineBreak.test(ch)) { this$1.raise(start, "Unterminated regular expression"); }
  5165. if (!escaped) {
  5166. if (ch === "[") { inClass = true; }
  5167. else if (ch === "]" && inClass) { inClass = false; }
  5168. else if (ch === "/" && !inClass) { break }
  5169. escaped = ch === "\\";
  5170. } else { escaped = false; }
  5171. ++this$1.pos;
  5172. }
  5173. var pattern = this.input.slice(start, this.pos);
  5174. ++this.pos;
  5175. var flagsStart = this.pos;
  5176. var flags = this.readWord1();
  5177. if (this.containsEsc) { this.unexpected(flagsStart); }
  5178. // Validate pattern
  5179. var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
  5180. state.reset(start, pattern, flags);
  5181. this.validateRegExpFlags(state);
  5182. this.validateRegExpPattern(state);
  5183. // Create Literal#value property value.
  5184. var value = null;
  5185. try {
  5186. value = new RegExp(pattern, flags);
  5187. } catch (e) {
  5188. // ESTree requires null if it failed to instantiate RegExp object.
  5189. // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
  5190. }
  5191. return this.finishToken(types.regexp, {pattern: pattern, flags: flags, value: value})
  5192. };
  5193. // Read an integer in the given radix. Return null if zero digits
  5194. // were read, the integer value otherwise. When `len` is given, this
  5195. // will return `null` unless the integer has exactly `len` digits.
  5196. pp$8.readInt = function(radix, len) {
  5197. var this$1 = this;
  5198. var start = this.pos, total = 0;
  5199. for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  5200. var code = this$1.input.charCodeAt(this$1.pos), val = (void 0);
  5201. if (code >= 97) { val = code - 97 + 10; } // a
  5202. else if (code >= 65) { val = code - 65 + 10; } // A
  5203. else if (code >= 48 && code <= 57) { val = code - 48; } // 0-9
  5204. else { val = Infinity; }
  5205. if (val >= radix) { break }
  5206. ++this$1.pos;
  5207. total = total * radix + val;
  5208. }
  5209. if (this.pos === start || len != null && this.pos - start !== len) { return null }
  5210. return total
  5211. };
  5212. pp$8.readRadixNumber = function(radix) {
  5213. this.pos += 2; // 0x
  5214. var val = this.readInt(radix);
  5215. if (val == null) { this.raise(this.start + 2, "Expected number in radix " + radix); }
  5216. if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  5217. return this.finishToken(types.num, val)
  5218. };
  5219. // Read an integer, octal integer, or floating-point number.
  5220. pp$8.readNumber = function(startsWithDot) {
  5221. var start = this.pos;
  5222. if (!startsWithDot && this.readInt(10) === null) { this.raise(start, "Invalid number"); }
  5223. var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  5224. if (octal && this.strict) { this.raise(start, "Invalid number"); }
  5225. if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
  5226. var next = this.input.charCodeAt(this.pos);
  5227. if (next === 46 && !octal) { // '.'
  5228. ++this.pos;
  5229. this.readInt(10);
  5230. next = this.input.charCodeAt(this.pos);
  5231. }
  5232. if ((next === 69 || next === 101) && !octal) { // 'eE'
  5233. next = this.input.charCodeAt(++this.pos);
  5234. if (next === 43 || next === 45) { ++this.pos; } // '+-'
  5235. if (this.readInt(10) === null) { this.raise(start, "Invalid number"); }
  5236. }
  5237. if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
  5238. var str = this.input.slice(start, this.pos);
  5239. var val = octal ? parseInt(str, 8) : parseFloat(str);
  5240. return this.finishToken(types.num, val)
  5241. };
  5242. // Read a string value, interpreting backslash-escapes.
  5243. pp$8.readCodePoint = function() {
  5244. var ch = this.input.charCodeAt(this.pos), code;
  5245. if (ch === 123) { // '{'
  5246. if (this.options.ecmaVersion < 6) { this.unexpected(); }
  5247. var codePos = ++this.pos;
  5248. code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
  5249. ++this.pos;
  5250. if (code > 0x10FFFF) { this.invalidStringToken(codePos, "Code point out of bounds"); }
  5251. } else {
  5252. code = this.readHexChar(4);
  5253. }
  5254. return code
  5255. };
  5256. function codePointToString(code) {
  5257. // UTF-16 Decoding
  5258. if (code <= 0xFFFF) { return String.fromCharCode(code) }
  5259. code -= 0x10000;
  5260. return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)
  5261. }
  5262. pp$8.readString = function(quote) {
  5263. var this$1 = this;
  5264. var out = "", chunkStart = ++this.pos;
  5265. for (;;) {
  5266. if (this$1.pos >= this$1.input.length) { this$1.raise(this$1.start, "Unterminated string constant"); }
  5267. var ch = this$1.input.charCodeAt(this$1.pos);
  5268. if (ch === quote) { break }
  5269. if (ch === 92) { // '\'
  5270. out += this$1.input.slice(chunkStart, this$1.pos);
  5271. out += this$1.readEscapedChar(false);
  5272. chunkStart = this$1.pos;
  5273. } else {
  5274. if (isNewLine(ch, this$1.options.ecmaVersion >= 10)) { this$1.raise(this$1.start, "Unterminated string constant"); }
  5275. ++this$1.pos;
  5276. }
  5277. }
  5278. out += this.input.slice(chunkStart, this.pos++);
  5279. return this.finishToken(types.string, out)
  5280. };
  5281. // Reads template string tokens.
  5282. var INVALID_TEMPLATE_ESCAPE_ERROR = {};
  5283. pp$8.tryReadTemplateToken = function() {
  5284. this.inTemplateElement = true;
  5285. try {
  5286. this.readTmplToken();
  5287. } catch (err) {
  5288. if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
  5289. this.readInvalidTemplateToken();
  5290. } else {
  5291. throw err
  5292. }
  5293. }
  5294. this.inTemplateElement = false;
  5295. };
  5296. pp$8.invalidStringToken = function(position, message) {
  5297. if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
  5298. throw INVALID_TEMPLATE_ESCAPE_ERROR
  5299. } else {
  5300. this.raise(position, message);
  5301. }
  5302. };
  5303. pp$8.readTmplToken = function() {
  5304. var this$1 = this;
  5305. var out = "", chunkStart = this.pos;
  5306. for (;;) {
  5307. if (this$1.pos >= this$1.input.length) { this$1.raise(this$1.start, "Unterminated template"); }
  5308. var ch = this$1.input.charCodeAt(this$1.pos);
  5309. if (ch === 96 || ch === 36 && this$1.input.charCodeAt(this$1.pos + 1) === 123) { // '`', '${'
  5310. if (this$1.pos === this$1.start && (this$1.type === types.template || this$1.type === types.invalidTemplate)) {
  5311. if (ch === 36) {
  5312. this$1.pos += 2;
  5313. return this$1.finishToken(types.dollarBraceL)
  5314. } else {
  5315. ++this$1.pos;
  5316. return this$1.finishToken(types.backQuote)
  5317. }
  5318. }
  5319. out += this$1.input.slice(chunkStart, this$1.pos);
  5320. return this$1.finishToken(types.template, out)
  5321. }
  5322. if (ch === 92) { // '\'
  5323. out += this$1.input.slice(chunkStart, this$1.pos);
  5324. out += this$1.readEscapedChar(true);
  5325. chunkStart = this$1.pos;
  5326. } else if (isNewLine(ch)) {
  5327. out += this$1.input.slice(chunkStart, this$1.pos);
  5328. ++this$1.pos;
  5329. switch (ch) {
  5330. case 13:
  5331. if (this$1.input.charCodeAt(this$1.pos) === 10) { ++this$1.pos; }
  5332. case 10:
  5333. out += "\n";
  5334. break
  5335. default:
  5336. out += String.fromCharCode(ch);
  5337. break
  5338. }
  5339. if (this$1.options.locations) {
  5340. ++this$1.curLine;
  5341. this$1.lineStart = this$1.pos;
  5342. }
  5343. chunkStart = this$1.pos;
  5344. } else {
  5345. ++this$1.pos;
  5346. }
  5347. }
  5348. };
  5349. // Reads a template token to search for the end, without validating any escape sequences
  5350. pp$8.readInvalidTemplateToken = function() {
  5351. var this$1 = this;
  5352. for (; this.pos < this.input.length; this.pos++) {
  5353. switch (this$1.input[this$1.pos]) {
  5354. case "\\":
  5355. ++this$1.pos;
  5356. break
  5357. case "$":
  5358. if (this$1.input[this$1.pos + 1] !== "{") {
  5359. break
  5360. }
  5361. // falls through
  5362. case "`":
  5363. return this$1.finishToken(types.invalidTemplate, this$1.input.slice(this$1.start, this$1.pos))
  5364. // no default
  5365. }
  5366. }
  5367. this.raise(this.start, "Unterminated template");
  5368. };
  5369. // Used to read escaped characters
  5370. pp$8.readEscapedChar = function(inTemplate) {
  5371. var ch = this.input.charCodeAt(++this.pos);
  5372. ++this.pos;
  5373. switch (ch) {
  5374. case 110: return "\n" // 'n' -> '\n'
  5375. case 114: return "\r" // 'r' -> '\r'
  5376. case 120: return String.fromCharCode(this.readHexChar(2)) // 'x'
  5377. case 117: return codePointToString(this.readCodePoint()) // 'u'
  5378. case 116: return "\t" // 't' -> '\t'
  5379. case 98: return "\b" // 'b' -> '\b'
  5380. case 118: return "\u000b" // 'v' -> '\u000b'
  5381. case 102: return "\f" // 'f' -> '\f'
  5382. case 13: if (this.input.charCodeAt(this.pos) === 10) { ++this.pos; } // '\r\n'
  5383. case 10: // ' \n'
  5384. if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
  5385. return ""
  5386. default:
  5387. if (ch >= 48 && ch <= 55) {
  5388. var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
  5389. var octal = parseInt(octalStr, 8);
  5390. if (octal > 255) {
  5391. octalStr = octalStr.slice(0, -1);
  5392. octal = parseInt(octalStr, 8);
  5393. }
  5394. this.pos += octalStr.length - 1;
  5395. ch = this.input.charCodeAt(this.pos);
  5396. if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
  5397. this.invalidStringToken(
  5398. this.pos - 1 - octalStr.length,
  5399. inTemplate
  5400. ? "Octal literal in template string"
  5401. : "Octal literal in strict mode"
  5402. );
  5403. }
  5404. return String.fromCharCode(octal)
  5405. }
  5406. return String.fromCharCode(ch)
  5407. }
  5408. };
  5409. // Used to read character escape sequences ('\x', '\u', '\U').
  5410. pp$8.readHexChar = function(len) {
  5411. var codePos = this.pos;
  5412. var n = this.readInt(16, len);
  5413. if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
  5414. return n
  5415. };
  5416. // Read an identifier, and return it as a string. Sets `this.containsEsc`
  5417. // to whether the word contained a '\u' escape.
  5418. //
  5419. // Incrementally adds only escaped chars, adding other chunks as-is
  5420. // as a micro-optimization.
  5421. pp$8.readWord1 = function() {
  5422. var this$1 = this;
  5423. this.containsEsc = false;
  5424. var word = "", first = true, chunkStart = this.pos;
  5425. var astral = this.options.ecmaVersion >= 6;
  5426. while (this.pos < this.input.length) {
  5427. var ch = this$1.fullCharCodeAtPos();
  5428. if (isIdentifierChar(ch, astral)) {
  5429. this$1.pos += ch <= 0xffff ? 1 : 2;
  5430. } else if (ch === 92) { // "\"
  5431. this$1.containsEsc = true;
  5432. word += this$1.input.slice(chunkStart, this$1.pos);
  5433. var escStart = this$1.pos;
  5434. if (this$1.input.charCodeAt(++this$1.pos) !== 117) // "u"
  5435. { this$1.invalidStringToken(this$1.pos, "Expecting Unicode escape sequence \\uXXXX"); }
  5436. ++this$1.pos;
  5437. var esc = this$1.readCodePoint();
  5438. if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
  5439. { this$1.invalidStringToken(escStart, "Invalid Unicode escape"); }
  5440. word += codePointToString(esc);
  5441. chunkStart = this$1.pos;
  5442. } else {
  5443. break
  5444. }
  5445. first = false;
  5446. }
  5447. return word + this.input.slice(chunkStart, this.pos)
  5448. };
  5449. // Read an identifier or keyword token. Will check for reserved
  5450. // words when necessary.
  5451. pp$8.readWord = function() {
  5452. var word = this.readWord1();
  5453. var type = types.name;
  5454. if (this.keywords.test(word)) {
  5455. if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword " + word); }
  5456. type = keywords$1[word];
  5457. }
  5458. return this.finishToken(type, word)
  5459. };
  5460. // Acorn is a tiny, fast JavaScript parser written in JavaScript.
  5461. //
  5462. // Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
  5463. // various contributors and released under an MIT license.
  5464. //
  5465. // Git repositories for Acorn are available at
  5466. //
  5467. // http://marijnhaverbeke.nl/git/acorn
  5468. // https://github.com/acornjs/acorn.git
  5469. //
  5470. // Please use the [github bug tracker][ghbt] to report issues.
  5471. //
  5472. // [ghbt]: https://github.com/acornjs/acorn/issues
  5473. //
  5474. // This file defines the main parser interface. The library also comes
  5475. // with a [error-tolerant parser][dammit] and an
  5476. // [abstract syntax tree walker][walk], defined in other files.
  5477. //
  5478. // [dammit]: acorn_loose.js
  5479. // [walk]: util/walk.js
  5480. var version = "5.7.2";
  5481. // The main exported interface (under `self.acorn` when in the
  5482. // browser) is a `parse` function that takes a code string and
  5483. // returns an abstract syntax tree as specified by [Mozilla parser
  5484. // API][api].
  5485. //
  5486. // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  5487. function parse(input, options) {
  5488. return new Parser(options, input).parse()
  5489. }
  5490. // This function tries to parse a single expression at a given
  5491. // offset in a string. Useful for parsing mixed-language formats
  5492. // that embed JavaScript expressions.
  5493. function parseExpressionAt(input, pos, options) {
  5494. var p = new Parser(options, input, pos);
  5495. p.nextToken();
  5496. return p.parseExpression()
  5497. }
  5498. // Acorn is organized as a tokenizer and a recursive-descent parser.
  5499. // The `tokenizer` export provides an interface to the tokenizer.
  5500. function tokenizer(input, options) {
  5501. return new Parser(options, input)
  5502. }
  5503. // This is a terrible kludge to support the existing, pre-ES6
  5504. // interface where the loose parser module retroactively adds exports
  5505. // to this module.
  5506. // eslint-disable-line camelcase
  5507. function addLooseExports(parse, Parser$$1, plugins$$1) {
  5508. exports.parse_dammit = parse; // eslint-disable-line camelcase
  5509. exports.LooseParser = Parser$$1;
  5510. exports.pluginsLoose = plugins$$1;
  5511. }
  5512. exports.version = version;
  5513. exports.parse = parse;
  5514. exports.parseExpressionAt = parseExpressionAt;
  5515. exports.tokenizer = tokenizer;
  5516. exports.addLooseExports = addLooseExports;
  5517. exports.Parser = Parser;
  5518. exports.plugins = plugins;
  5519. exports.defaultOptions = defaultOptions;
  5520. exports.Position = Position;
  5521. exports.SourceLocation = SourceLocation;
  5522. exports.getLineInfo = getLineInfo;
  5523. exports.Node = Node;
  5524. exports.TokenType = TokenType;
  5525. exports.tokTypes = types;
  5526. exports.keywordTypes = keywords$1;
  5527. exports.TokContext = TokContext;
  5528. exports.tokContexts = types$1;
  5529. exports.isIdentifierChar = isIdentifierChar;
  5530. exports.isIdentifierStart = isIdentifierStart;
  5531. exports.Token = Token;
  5532. exports.isNewLine = isNewLine;
  5533. exports.lineBreak = lineBreak;
  5534. exports.lineBreakG = lineBreakG;
  5535. exports.nonASCIIwhitespace = nonASCIIwhitespace;
  5536. Object.defineProperty(exports, '__esModule', { value: true });
  5537. })));
  5538. },{}],6:[function(_dereq_,module,exports){
  5539. /**
  5540. * Array#filter.
  5541. *
  5542. * @param {Array} arr
  5543. * @param {Function} fn
  5544. * @param {Object=} self
  5545. * @return {Array}
  5546. * @throw TypeError
  5547. */
  5548. module.exports = function (arr, fn, self) {
  5549. if (arr.filter) return arr.filter(fn, self);
  5550. if (void 0 === arr || null === arr) throw new TypeError;
  5551. if ('function' != typeof fn) throw new TypeError;
  5552. var ret = [];
  5553. for (var i = 0; i < arr.length; i++) {
  5554. if (!hasOwn.call(arr, i)) continue;
  5555. var val = arr[i];
  5556. if (fn.call(self, val, i, arr)) ret.push(val);
  5557. }
  5558. return ret;
  5559. };
  5560. var hasOwn = Object.prototype.hasOwnProperty;
  5561. },{}],7:[function(_dereq_,module,exports){
  5562. (function (global){
  5563. 'use strict';
  5564. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  5565. // original notice:
  5566. /*!
  5567. * The buffer module from node.js, for the browser.
  5568. *
  5569. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  5570. * @license MIT
  5571. */
  5572. function compare(a, b) {
  5573. if (a === b) {
  5574. return 0;
  5575. }
  5576. var x = a.length;
  5577. var y = b.length;
  5578. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5579. if (a[i] !== b[i]) {
  5580. x = a[i];
  5581. y = b[i];
  5582. break;
  5583. }
  5584. }
  5585. if (x < y) {
  5586. return -1;
  5587. }
  5588. if (y < x) {
  5589. return 1;
  5590. }
  5591. return 0;
  5592. }
  5593. function isBuffer(b) {
  5594. if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  5595. return global.Buffer.isBuffer(b);
  5596. }
  5597. return !!(b != null && b._isBuffer);
  5598. }
  5599. // based on node assert, original notice:
  5600. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  5601. //
  5602. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  5603. //
  5604. // Originally from narwhal.js (http://narwhaljs.org)
  5605. // Copyright (c) 2009 Thomas Robinson <280north.com>
  5606. //
  5607. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5608. // of this software and associated documentation files (the 'Software'), to
  5609. // deal in the Software without restriction, including without limitation the
  5610. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  5611. // sell copies of the Software, and to permit persons to whom the Software is
  5612. // furnished to do so, subject to the following conditions:
  5613. //
  5614. // The above copyright notice and this permission notice shall be included in
  5615. // all copies or substantial portions of the Software.
  5616. //
  5617. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5618. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5619. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5620. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  5621. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  5622. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  5623. var util = _dereq_('util/');
  5624. var hasOwn = Object.prototype.hasOwnProperty;
  5625. var pSlice = Array.prototype.slice;
  5626. var functionsHaveNames = (function () {
  5627. return function foo() {}.name === 'foo';
  5628. }());
  5629. function pToString (obj) {
  5630. return Object.prototype.toString.call(obj);
  5631. }
  5632. function isView(arrbuf) {
  5633. if (isBuffer(arrbuf)) {
  5634. return false;
  5635. }
  5636. if (typeof global.ArrayBuffer !== 'function') {
  5637. return false;
  5638. }
  5639. if (typeof ArrayBuffer.isView === 'function') {
  5640. return ArrayBuffer.isView(arrbuf);
  5641. }
  5642. if (!arrbuf) {
  5643. return false;
  5644. }
  5645. if (arrbuf instanceof DataView) {
  5646. return true;
  5647. }
  5648. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  5649. return true;
  5650. }
  5651. return false;
  5652. }
  5653. // 1. The assert module provides functions that throw
  5654. // AssertionError's when particular conditions are not met. The
  5655. // assert module must conform to the following interface.
  5656. var assert = module.exports = ok;
  5657. // 2. The AssertionError is defined in assert.
  5658. // new assert.AssertionError({ message: message,
  5659. // actual: actual,
  5660. // expected: expected })
  5661. var regex = /\s*function\s+([^\(\s]*)\s*/;
  5662. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  5663. function getName(func) {
  5664. if (!util.isFunction(func)) {
  5665. return;
  5666. }
  5667. if (functionsHaveNames) {
  5668. return func.name;
  5669. }
  5670. var str = func.toString();
  5671. var match = str.match(regex);
  5672. return match && match[1];
  5673. }
  5674. assert.AssertionError = function AssertionError(options) {
  5675. this.name = 'AssertionError';
  5676. this.actual = options.actual;
  5677. this.expected = options.expected;
  5678. this.operator = options.operator;
  5679. if (options.message) {
  5680. this.message = options.message;
  5681. this.generatedMessage = false;
  5682. } else {
  5683. this.message = getMessage(this);
  5684. this.generatedMessage = true;
  5685. }
  5686. var stackStartFunction = options.stackStartFunction || fail;
  5687. if (Error.captureStackTrace) {
  5688. Error.captureStackTrace(this, stackStartFunction);
  5689. } else {
  5690. // non v8 browsers so we can have a stacktrace
  5691. var err = new Error();
  5692. if (err.stack) {
  5693. var out = err.stack;
  5694. // try to strip useless frames
  5695. var fn_name = getName(stackStartFunction);
  5696. var idx = out.indexOf('\n' + fn_name);
  5697. if (idx >= 0) {
  5698. // once we have located the function frame
  5699. // we need to strip out everything before it (and its line)
  5700. var next_line = out.indexOf('\n', idx + 1);
  5701. out = out.substring(next_line + 1);
  5702. }
  5703. this.stack = out;
  5704. }
  5705. }
  5706. };
  5707. // assert.AssertionError instanceof Error
  5708. util.inherits(assert.AssertionError, Error);
  5709. function truncate(s, n) {
  5710. if (typeof s === 'string') {
  5711. return s.length < n ? s : s.slice(0, n);
  5712. } else {
  5713. return s;
  5714. }
  5715. }
  5716. function inspect(something) {
  5717. if (functionsHaveNames || !util.isFunction(something)) {
  5718. return util.inspect(something);
  5719. }
  5720. var rawname = getName(something);
  5721. var name = rawname ? ': ' + rawname : '';
  5722. return '[Function' + name + ']';
  5723. }
  5724. function getMessage(self) {
  5725. return truncate(inspect(self.actual), 128) + ' ' +
  5726. self.operator + ' ' +
  5727. truncate(inspect(self.expected), 128);
  5728. }
  5729. // At present only the three keys mentioned above are used and
  5730. // understood by the spec. Implementations or sub modules can pass
  5731. // other keys to the AssertionError's constructor - they will be
  5732. // ignored.
  5733. // 3. All of the following functions must throw an AssertionError
  5734. // when a corresponding condition is not met, with a message that
  5735. // may be undefined if not provided. All assertion methods provide
  5736. // both the actual and expected values to the assertion error for
  5737. // display purposes.
  5738. function fail(actual, expected, message, operator, stackStartFunction) {
  5739. throw new assert.AssertionError({
  5740. message: message,
  5741. actual: actual,
  5742. expected: expected,
  5743. operator: operator,
  5744. stackStartFunction: stackStartFunction
  5745. });
  5746. }
  5747. // EXTENSION! allows for well behaved errors defined elsewhere.
  5748. assert.fail = fail;
  5749. // 4. Pure assertion tests whether a value is truthy, as determined
  5750. // by !!guard.
  5751. // assert.ok(guard, message_opt);
  5752. // This statement is equivalent to assert.equal(true, !!guard,
  5753. // message_opt);. To test strictly for the value true, use
  5754. // assert.strictEqual(true, guard, message_opt);.
  5755. function ok(value, message) {
  5756. if (!value) fail(value, true, message, '==', assert.ok);
  5757. }
  5758. assert.ok = ok;
  5759. // 5. The equality assertion tests shallow, coercive equality with
  5760. // ==.
  5761. // assert.equal(actual, expected, message_opt);
  5762. assert.equal = function equal(actual, expected, message) {
  5763. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  5764. };
  5765. // 6. The non-equality assertion tests for whether two objects are not equal
  5766. // with != assert.notEqual(actual, expected, message_opt);
  5767. assert.notEqual = function notEqual(actual, expected, message) {
  5768. if (actual == expected) {
  5769. fail(actual, expected, message, '!=', assert.notEqual);
  5770. }
  5771. };
  5772. // 7. The equivalence assertion tests a deep equality relation.
  5773. // assert.deepEqual(actual, expected, message_opt);
  5774. assert.deepEqual = function deepEqual(actual, expected, message) {
  5775. if (!_deepEqual(actual, expected, false)) {
  5776. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  5777. }
  5778. };
  5779. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  5780. if (!_deepEqual(actual, expected, true)) {
  5781. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  5782. }
  5783. };
  5784. function _deepEqual(actual, expected, strict, memos) {
  5785. // 7.1. All identical values are equivalent, as determined by ===.
  5786. if (actual === expected) {
  5787. return true;
  5788. } else if (isBuffer(actual) && isBuffer(expected)) {
  5789. return compare(actual, expected) === 0;
  5790. // 7.2. If the expected value is a Date object, the actual value is
  5791. // equivalent if it is also a Date object that refers to the same time.
  5792. } else if (util.isDate(actual) && util.isDate(expected)) {
  5793. return actual.getTime() === expected.getTime();
  5794. // 7.3 If the expected value is a RegExp object, the actual value is
  5795. // equivalent if it is also a RegExp object with the same source and
  5796. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  5797. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  5798. return actual.source === expected.source &&
  5799. actual.global === expected.global &&
  5800. actual.multiline === expected.multiline &&
  5801. actual.lastIndex === expected.lastIndex &&
  5802. actual.ignoreCase === expected.ignoreCase;
  5803. // 7.4. Other pairs that do not both pass typeof value == 'object',
  5804. // equivalence is determined by ==.
  5805. } else if ((actual === null || typeof actual !== 'object') &&
  5806. (expected === null || typeof expected !== 'object')) {
  5807. return strict ? actual === expected : actual == expected;
  5808. // If both values are instances of typed arrays, wrap their underlying
  5809. // ArrayBuffers in a Buffer each to increase performance
  5810. // This optimization requires the arrays to have the same type as checked by
  5811. // Object.prototype.toString (aka pToString). Never perform binary
  5812. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  5813. // bit patterns are not identical.
  5814. } else if (isView(actual) && isView(expected) &&
  5815. pToString(actual) === pToString(expected) &&
  5816. !(actual instanceof Float32Array ||
  5817. actual instanceof Float64Array)) {
  5818. return compare(new Uint8Array(actual.buffer),
  5819. new Uint8Array(expected.buffer)) === 0;
  5820. // 7.5 For all other Object pairs, including Array objects, equivalence is
  5821. // determined by having the same number of owned properties (as verified
  5822. // with Object.prototype.hasOwnProperty.call), the same set of keys
  5823. // (although not necessarily the same order), equivalent values for every
  5824. // corresponding key, and an identical 'prototype' property. Note: this
  5825. // accounts for both named and indexed properties on Arrays.
  5826. } else if (isBuffer(actual) !== isBuffer(expected)) {
  5827. return false;
  5828. } else {
  5829. memos = memos || {actual: [], expected: []};
  5830. var actualIndex = memos.actual.indexOf(actual);
  5831. if (actualIndex !== -1) {
  5832. if (actualIndex === memos.expected.indexOf(expected)) {
  5833. return true;
  5834. }
  5835. }
  5836. memos.actual.push(actual);
  5837. memos.expected.push(expected);
  5838. return objEquiv(actual, expected, strict, memos);
  5839. }
  5840. }
  5841. function isArguments(object) {
  5842. return Object.prototype.toString.call(object) == '[object Arguments]';
  5843. }
  5844. function objEquiv(a, b, strict, actualVisitedObjects) {
  5845. if (a === null || a === undefined || b === null || b === undefined)
  5846. return false;
  5847. // if one is a primitive, the other must be same
  5848. if (util.isPrimitive(a) || util.isPrimitive(b))
  5849. return a === b;
  5850. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  5851. return false;
  5852. var aIsArgs = isArguments(a);
  5853. var bIsArgs = isArguments(b);
  5854. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  5855. return false;
  5856. if (aIsArgs) {
  5857. a = pSlice.call(a);
  5858. b = pSlice.call(b);
  5859. return _deepEqual(a, b, strict);
  5860. }
  5861. var ka = objectKeys(a);
  5862. var kb = objectKeys(b);
  5863. var key, i;
  5864. // having the same number of owned properties (keys incorporates
  5865. // hasOwnProperty)
  5866. if (ka.length !== kb.length)
  5867. return false;
  5868. //the same set of keys (although not necessarily the same order),
  5869. ka.sort();
  5870. kb.sort();
  5871. //~~~cheap key test
  5872. for (i = ka.length - 1; i >= 0; i--) {
  5873. if (ka[i] !== kb[i])
  5874. return false;
  5875. }
  5876. //equivalent values for every corresponding key, and
  5877. //~~~possibly expensive deep test
  5878. for (i = ka.length - 1; i >= 0; i--) {
  5879. key = ka[i];
  5880. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  5881. return false;
  5882. }
  5883. return true;
  5884. }
  5885. // 8. The non-equivalence assertion tests for any deep inequality.
  5886. // assert.notDeepEqual(actual, expected, message_opt);
  5887. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  5888. if (_deepEqual(actual, expected, false)) {
  5889. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  5890. }
  5891. };
  5892. assert.notDeepStrictEqual = notDeepStrictEqual;
  5893. function notDeepStrictEqual(actual, expected, message) {
  5894. if (_deepEqual(actual, expected, true)) {
  5895. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  5896. }
  5897. }
  5898. // 9. The strict equality assertion tests strict equality, as determined by ===.
  5899. // assert.strictEqual(actual, expected, message_opt);
  5900. assert.strictEqual = function strictEqual(actual, expected, message) {
  5901. if (actual !== expected) {
  5902. fail(actual, expected, message, '===', assert.strictEqual);
  5903. }
  5904. };
  5905. // 10. The strict non-equality assertion tests for strict inequality, as
  5906. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  5907. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  5908. if (actual === expected) {
  5909. fail(actual, expected, message, '!==', assert.notStrictEqual);
  5910. }
  5911. };
  5912. function expectedException(actual, expected) {
  5913. if (!actual || !expected) {
  5914. return false;
  5915. }
  5916. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  5917. return expected.test(actual);
  5918. }
  5919. try {
  5920. if (actual instanceof expected) {
  5921. return true;
  5922. }
  5923. } catch (e) {
  5924. // Ignore. The instanceof check doesn't work for arrow functions.
  5925. }
  5926. if (Error.isPrototypeOf(expected)) {
  5927. return false;
  5928. }
  5929. return expected.call({}, actual) === true;
  5930. }
  5931. function _tryBlock(block) {
  5932. var error;
  5933. try {
  5934. block();
  5935. } catch (e) {
  5936. error = e;
  5937. }
  5938. return error;
  5939. }
  5940. function _throws(shouldThrow, block, expected, message) {
  5941. var actual;
  5942. if (typeof block !== 'function') {
  5943. throw new TypeError('"block" argument must be a function');
  5944. }
  5945. if (typeof expected === 'string') {
  5946. message = expected;
  5947. expected = null;
  5948. }
  5949. actual = _tryBlock(block);
  5950. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  5951. (message ? ' ' + message : '.');
  5952. if (shouldThrow && !actual) {
  5953. fail(actual, expected, 'Missing expected exception' + message);
  5954. }
  5955. var userProvidedMessage = typeof message === 'string';
  5956. var isUnwantedException = !shouldThrow && util.isError(actual);
  5957. var isUnexpectedException = !shouldThrow && actual && !expected;
  5958. if ((isUnwantedException &&
  5959. userProvidedMessage &&
  5960. expectedException(actual, expected)) ||
  5961. isUnexpectedException) {
  5962. fail(actual, expected, 'Got unwanted exception' + message);
  5963. }
  5964. if ((shouldThrow && actual && expected &&
  5965. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  5966. throw actual;
  5967. }
  5968. }
  5969. // 11. Expected to throw an error:
  5970. // assert.throws(block, Error_opt, message_opt);
  5971. assert["throws"] = function(block, /*optional*/error, /*optional*/message) {
  5972. _throws(true, block, error, message);
  5973. };
  5974. // EXTENSION! This is annoying to write outside this module.
  5975. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  5976. _throws(false, block, error, message);
  5977. };
  5978. assert.ifError = function(err) { if (err) throw err; };
  5979. var objectKeys = Object.keys || function (obj) {
  5980. var keys = [];
  5981. for (var key in obj) {
  5982. if (hasOwn.call(obj, key)) keys.push(key);
  5983. }
  5984. return keys;
  5985. };
  5986. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  5987. },{"util/":10}],8:[function(_dereq_,module,exports){
  5988. if (typeof Object.create === 'function') {
  5989. // implementation from standard node.js 'util' module
  5990. module.exports = function inherits(ctor, superCtor) {
  5991. ctor.super_ = superCtor
  5992. ctor.prototype = Object.create(superCtor.prototype, {
  5993. constructor: {
  5994. value: ctor,
  5995. enumerable: false,
  5996. writable: true,
  5997. configurable: true
  5998. }
  5999. });
  6000. };
  6001. } else {
  6002. // old school shim for old browsers
  6003. module.exports = function inherits(ctor, superCtor) {
  6004. ctor.super_ = superCtor
  6005. var TempCtor = function () {}
  6006. TempCtor.prototype = superCtor.prototype
  6007. ctor.prototype = new TempCtor()
  6008. ctor.prototype.constructor = ctor
  6009. }
  6010. }
  6011. },{}],9:[function(_dereq_,module,exports){
  6012. module.exports = function isBuffer(arg) {
  6013. return arg && typeof arg === 'object'
  6014. && typeof arg.copy === 'function'
  6015. && typeof arg.fill === 'function'
  6016. && typeof arg.readUInt8 === 'function';
  6017. }
  6018. },{}],10:[function(_dereq_,module,exports){
  6019. (function (process,global){
  6020. // Copyright Joyent, Inc. and other Node contributors.
  6021. //
  6022. // Permission is hereby granted, free of charge, to any person obtaining a
  6023. // copy of this software and associated documentation files (the
  6024. // "Software"), to deal in the Software without restriction, including
  6025. // without limitation the rights to use, copy, modify, merge, publish,
  6026. // distribute, sublicense, and/or sell copies of the Software, and to permit
  6027. // persons to whom the Software is furnished to do so, subject to the
  6028. // following conditions:
  6029. //
  6030. // The above copyright notice and this permission notice shall be included
  6031. // in all copies or substantial portions of the Software.
  6032. //
  6033. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  6034. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  6035. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  6036. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  6037. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  6038. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  6039. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  6040. var formatRegExp = /%[sdj%]/g;
  6041. exports.format = function(f) {
  6042. if (!isString(f)) {
  6043. var objects = [];
  6044. for (var i = 0; i < arguments.length; i++) {
  6045. objects.push(inspect(arguments[i]));
  6046. }
  6047. return objects.join(' ');
  6048. }
  6049. var i = 1;
  6050. var args = arguments;
  6051. var len = args.length;
  6052. var str = String(f).replace(formatRegExp, function(x) {
  6053. if (x === '%%') return '%';
  6054. if (i >= len) return x;
  6055. switch (x) {
  6056. case '%s': return String(args[i++]);
  6057. case '%d': return Number(args[i++]);
  6058. case '%j':
  6059. try {
  6060. return JSON.stringify(args[i++]);
  6061. } catch (_) {
  6062. return '[Circular]';
  6063. }
  6064. default:
  6065. return x;
  6066. }
  6067. });
  6068. for (var x = args[i]; i < len; x = args[++i]) {
  6069. if (isNull(x) || !isObject(x)) {
  6070. str += ' ' + x;
  6071. } else {
  6072. str += ' ' + inspect(x);
  6073. }
  6074. }
  6075. return str;
  6076. };
  6077. // Mark that a method should not be used.
  6078. // Returns a modified function which warns once by default.
  6079. // If --no-deprecation is set, then it is a no-op.
  6080. exports.deprecate = function(fn, msg) {
  6081. // Allow for deprecating things in the process of starting up.
  6082. if (isUndefined(global.process)) {
  6083. return function() {
  6084. return exports.deprecate(fn, msg).apply(this, arguments);
  6085. };
  6086. }
  6087. if (process.noDeprecation === true) {
  6088. return fn;
  6089. }
  6090. var warned = false;
  6091. function deprecated() {
  6092. if (!warned) {
  6093. if (process.throwDeprecation) {
  6094. throw new Error(msg);
  6095. } else if (process.traceDeprecation) {
  6096. console.trace(msg);
  6097. } else {
  6098. console.error(msg);
  6099. }
  6100. warned = true;
  6101. }
  6102. return fn.apply(this, arguments);
  6103. }
  6104. return deprecated;
  6105. };
  6106. var debugs = {};
  6107. var debugEnviron;
  6108. exports.debuglog = function(set) {
  6109. if (isUndefined(debugEnviron))
  6110. debugEnviron = process.env.NODE_DEBUG || '';
  6111. set = set.toUpperCase();
  6112. if (!debugs[set]) {
  6113. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  6114. var pid = process.pid;
  6115. debugs[set] = function() {
  6116. var msg = exports.format.apply(exports, arguments);
  6117. console.error('%s %d: %s', set, pid, msg);
  6118. };
  6119. } else {
  6120. debugs[set] = function() {};
  6121. }
  6122. }
  6123. return debugs[set];
  6124. };
  6125. /**
  6126. * Echos the value of a value. Trys to print the value out
  6127. * in the best way possible given the different types.
  6128. *
  6129. * @param {Object} obj The object to print out.
  6130. * @param {Object} opts Optional options object that alters the output.
  6131. */
  6132. /* legacy: obj, showHidden, depth, colors*/
  6133. function inspect(obj, opts) {
  6134. // default options
  6135. var ctx = {
  6136. seen: [],
  6137. stylize: stylizeNoColor
  6138. };
  6139. // legacy...
  6140. if (arguments.length >= 3) ctx.depth = arguments[2];
  6141. if (arguments.length >= 4) ctx.colors = arguments[3];
  6142. if (isBoolean(opts)) {
  6143. // legacy...
  6144. ctx.showHidden = opts;
  6145. } else if (opts) {
  6146. // got an "options" object
  6147. exports._extend(ctx, opts);
  6148. }
  6149. // set default options
  6150. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  6151. if (isUndefined(ctx.depth)) ctx.depth = 2;
  6152. if (isUndefined(ctx.colors)) ctx.colors = false;
  6153. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  6154. if (ctx.colors) ctx.stylize = stylizeWithColor;
  6155. return formatValue(ctx, obj, ctx.depth);
  6156. }
  6157. exports.inspect = inspect;
  6158. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  6159. inspect.colors = {
  6160. 'bold' : [1, 22],
  6161. 'italic' : [3, 23],
  6162. 'underline' : [4, 24],
  6163. 'inverse' : [7, 27],
  6164. 'white' : [37, 39],
  6165. 'grey' : [90, 39],
  6166. 'black' : [30, 39],
  6167. 'blue' : [34, 39],
  6168. 'cyan' : [36, 39],
  6169. 'green' : [32, 39],
  6170. 'magenta' : [35, 39],
  6171. 'red' : [31, 39],
  6172. 'yellow' : [33, 39]
  6173. };
  6174. // Don't use 'blue' not visible on cmd.exe
  6175. inspect.styles = {
  6176. 'special': 'cyan',
  6177. 'number': 'yellow',
  6178. 'boolean': 'yellow',
  6179. 'undefined': 'grey',
  6180. 'null': 'bold',
  6181. 'string': 'green',
  6182. 'date': 'magenta',
  6183. // "name": intentionally not styling
  6184. 'regexp': 'red'
  6185. };
  6186. function stylizeWithColor(str, styleType) {
  6187. var style = inspect.styles[styleType];
  6188. if (style) {
  6189. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  6190. '\u001b[' + inspect.colors[style][1] + 'm';
  6191. } else {
  6192. return str;
  6193. }
  6194. }
  6195. function stylizeNoColor(str, styleType) {
  6196. return str;
  6197. }
  6198. function arrayToHash(array) {
  6199. var hash = {};
  6200. array.forEach(function(val, idx) {
  6201. hash[val] = true;
  6202. });
  6203. return hash;
  6204. }
  6205. function formatValue(ctx, value, recurseTimes) {
  6206. // Provide a hook for user-specified inspect functions.
  6207. // Check that value is an object with an inspect function on it
  6208. if (ctx.customInspect &&
  6209. value &&
  6210. isFunction(value.inspect) &&
  6211. // Filter out the util module, it's inspect function is special
  6212. value.inspect !== exports.inspect &&
  6213. // Also filter out any prototype objects using the circular check.
  6214. !(value.constructor && value.constructor.prototype === value)) {
  6215. var ret = value.inspect(recurseTimes, ctx);
  6216. if (!isString(ret)) {
  6217. ret = formatValue(ctx, ret, recurseTimes);
  6218. }
  6219. return ret;
  6220. }
  6221. // Primitive types cannot have properties
  6222. var primitive = formatPrimitive(ctx, value);
  6223. if (primitive) {
  6224. return primitive;
  6225. }
  6226. // Look up the keys of the object.
  6227. var keys = Object.keys(value);
  6228. var visibleKeys = arrayToHash(keys);
  6229. if (ctx.showHidden) {
  6230. keys = Object.getOwnPropertyNames(value);
  6231. }
  6232. // IE doesn't make error fields non-enumerable
  6233. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  6234. if (isError(value)
  6235. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  6236. return formatError(value);
  6237. }
  6238. // Some type of object without properties can be shortcutted.
  6239. if (keys.length === 0) {
  6240. if (isFunction(value)) {
  6241. var name = value.name ? ': ' + value.name : '';
  6242. return ctx.stylize('[Function' + name + ']', 'special');
  6243. }
  6244. if (isRegExp(value)) {
  6245. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  6246. }
  6247. if (isDate(value)) {
  6248. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  6249. }
  6250. if (isError(value)) {
  6251. return formatError(value);
  6252. }
  6253. }
  6254. var base = '', array = false, braces = ['{', '}'];
  6255. // Make Array say that they are Array
  6256. if (isArray(value)) {
  6257. array = true;
  6258. braces = ['[', ']'];
  6259. }
  6260. // Make functions say that they are functions
  6261. if (isFunction(value)) {
  6262. var n = value.name ? ': ' + value.name : '';
  6263. base = ' [Function' + n + ']';
  6264. }
  6265. // Make RegExps say that they are RegExps
  6266. if (isRegExp(value)) {
  6267. base = ' ' + RegExp.prototype.toString.call(value);
  6268. }
  6269. // Make dates with properties first say the date
  6270. if (isDate(value)) {
  6271. base = ' ' + Date.prototype.toUTCString.call(value);
  6272. }
  6273. // Make error with message first say the error
  6274. if (isError(value)) {
  6275. base = ' ' + formatError(value);
  6276. }
  6277. if (keys.length === 0 && (!array || value.length == 0)) {
  6278. return braces[0] + base + braces[1];
  6279. }
  6280. if (recurseTimes < 0) {
  6281. if (isRegExp(value)) {
  6282. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  6283. } else {
  6284. return ctx.stylize('[Object]', 'special');
  6285. }
  6286. }
  6287. ctx.seen.push(value);
  6288. var output;
  6289. if (array) {
  6290. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  6291. } else {
  6292. output = keys.map(function(key) {
  6293. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  6294. });
  6295. }
  6296. ctx.seen.pop();
  6297. return reduceToSingleString(output, base, braces);
  6298. }
  6299. function formatPrimitive(ctx, value) {
  6300. if (isUndefined(value))
  6301. return ctx.stylize('undefined', 'undefined');
  6302. if (isString(value)) {
  6303. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  6304. .replace(/'/g, "\\'")
  6305. .replace(/\\"/g, '"') + '\'';
  6306. return ctx.stylize(simple, 'string');
  6307. }
  6308. if (isNumber(value))
  6309. return ctx.stylize('' + value, 'number');
  6310. if (isBoolean(value))
  6311. return ctx.stylize('' + value, 'boolean');
  6312. // For some reason typeof null is "object", so special case here.
  6313. if (isNull(value))
  6314. return ctx.stylize('null', 'null');
  6315. }
  6316. function formatError(value) {
  6317. return '[' + Error.prototype.toString.call(value) + ']';
  6318. }
  6319. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  6320. var output = [];
  6321. for (var i = 0, l = value.length; i < l; ++i) {
  6322. if (hasOwnProperty(value, String(i))) {
  6323. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  6324. String(i), true));
  6325. } else {
  6326. output.push('');
  6327. }
  6328. }
  6329. keys.forEach(function(key) {
  6330. if (!key.match(/^\d+$/)) {
  6331. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  6332. key, true));
  6333. }
  6334. });
  6335. return output;
  6336. }
  6337. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  6338. var name, str, desc;
  6339. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  6340. if (desc.get) {
  6341. if (desc.set) {
  6342. str = ctx.stylize('[Getter/Setter]', 'special');
  6343. } else {
  6344. str = ctx.stylize('[Getter]', 'special');
  6345. }
  6346. } else {
  6347. if (desc.set) {
  6348. str = ctx.stylize('[Setter]', 'special');
  6349. }
  6350. }
  6351. if (!hasOwnProperty(visibleKeys, key)) {
  6352. name = '[' + key + ']';
  6353. }
  6354. if (!str) {
  6355. if (ctx.seen.indexOf(desc.value) < 0) {
  6356. if (isNull(recurseTimes)) {
  6357. str = formatValue(ctx, desc.value, null);
  6358. } else {
  6359. str = formatValue(ctx, desc.value, recurseTimes - 1);
  6360. }
  6361. if (str.indexOf('\n') > -1) {
  6362. if (array) {
  6363. str = str.split('\n').map(function(line) {
  6364. return ' ' + line;
  6365. }).join('\n').substr(2);
  6366. } else {
  6367. str = '\n' + str.split('\n').map(function(line) {
  6368. return ' ' + line;
  6369. }).join('\n');
  6370. }
  6371. }
  6372. } else {
  6373. str = ctx.stylize('[Circular]', 'special');
  6374. }
  6375. }
  6376. if (isUndefined(name)) {
  6377. if (array && key.match(/^\d+$/)) {
  6378. return str;
  6379. }
  6380. name = JSON.stringify('' + key);
  6381. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  6382. name = name.substr(1, name.length - 2);
  6383. name = ctx.stylize(name, 'name');
  6384. } else {
  6385. name = name.replace(/'/g, "\\'")
  6386. .replace(/\\"/g, '"')
  6387. .replace(/(^"|"$)/g, "'");
  6388. name = ctx.stylize(name, 'string');
  6389. }
  6390. }
  6391. return name + ': ' + str;
  6392. }
  6393. function reduceToSingleString(output, base, braces) {
  6394. var numLinesEst = 0;
  6395. var length = output.reduce(function(prev, cur) {
  6396. numLinesEst++;
  6397. if (cur.indexOf('\n') >= 0) numLinesEst++;
  6398. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  6399. }, 0);
  6400. if (length > 60) {
  6401. return braces[0] +
  6402. (base === '' ? '' : base + '\n ') +
  6403. ' ' +
  6404. output.join(',\n ') +
  6405. ' ' +
  6406. braces[1];
  6407. }
  6408. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  6409. }
  6410. // NOTE: These type checking functions intentionally don't use `instanceof`
  6411. // because it is fragile and can be easily faked with `Object.create()`.
  6412. function isArray(ar) {
  6413. return Array.isArray(ar);
  6414. }
  6415. exports.isArray = isArray;
  6416. function isBoolean(arg) {
  6417. return typeof arg === 'boolean';
  6418. }
  6419. exports.isBoolean = isBoolean;
  6420. function isNull(arg) {
  6421. return arg === null;
  6422. }
  6423. exports.isNull = isNull;
  6424. function isNullOrUndefined(arg) {
  6425. return arg == null;
  6426. }
  6427. exports.isNullOrUndefined = isNullOrUndefined;
  6428. function isNumber(arg) {
  6429. return typeof arg === 'number';
  6430. }
  6431. exports.isNumber = isNumber;
  6432. function isString(arg) {
  6433. return typeof arg === 'string';
  6434. }
  6435. exports.isString = isString;
  6436. function isSymbol(arg) {
  6437. return typeof arg === 'symbol';
  6438. }
  6439. exports.isSymbol = isSymbol;
  6440. function isUndefined(arg) {
  6441. return arg === void 0;
  6442. }
  6443. exports.isUndefined = isUndefined;
  6444. function isRegExp(re) {
  6445. return isObject(re) && objectToString(re) === '[object RegExp]';
  6446. }
  6447. exports.isRegExp = isRegExp;
  6448. function isObject(arg) {
  6449. return typeof arg === 'object' && arg !== null;
  6450. }
  6451. exports.isObject = isObject;
  6452. function isDate(d) {
  6453. return isObject(d) && objectToString(d) === '[object Date]';
  6454. }
  6455. exports.isDate = isDate;
  6456. function isError(e) {
  6457. return isObject(e) &&
  6458. (objectToString(e) === '[object Error]' || e instanceof Error);
  6459. }
  6460. exports.isError = isError;
  6461. function isFunction(arg) {
  6462. return typeof arg === 'function';
  6463. }
  6464. exports.isFunction = isFunction;
  6465. function isPrimitive(arg) {
  6466. return arg === null ||
  6467. typeof arg === 'boolean' ||
  6468. typeof arg === 'number' ||
  6469. typeof arg === 'string' ||
  6470. typeof arg === 'symbol' || // ES6 symbol
  6471. typeof arg === 'undefined';
  6472. }
  6473. exports.isPrimitive = isPrimitive;
  6474. exports.isBuffer = _dereq_('./support/isBuffer');
  6475. function objectToString(o) {
  6476. return Object.prototype.toString.call(o);
  6477. }
  6478. function pad(n) {
  6479. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  6480. }
  6481. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  6482. 'Oct', 'Nov', 'Dec'];
  6483. // 26 Feb 16:19:34
  6484. function timestamp() {
  6485. var d = new Date();
  6486. var time = [pad(d.getHours()),
  6487. pad(d.getMinutes()),
  6488. pad(d.getSeconds())].join(':');
  6489. return [d.getDate(), months[d.getMonth()], time].join(' ');
  6490. }
  6491. // log is just a thin wrapper to console.log that prepends a timestamp
  6492. exports.log = function() {
  6493. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  6494. };
  6495. /**
  6496. * Inherit the prototype methods from one constructor into another.
  6497. *
  6498. * The Function.prototype.inherits from lang.js rewritten as a standalone
  6499. * function (not on Function.prototype). NOTE: If this file is to be loaded
  6500. * during bootstrapping this function needs to be rewritten using some native
  6501. * functions as prototype setup using normal JavaScript does not work as
  6502. * expected during bootstrapping (see mirror.js in r114903).
  6503. *
  6504. * @param {function} ctor Constructor function which needs to inherit the
  6505. * prototype.
  6506. * @param {function} superCtor Constructor function to inherit prototype from.
  6507. */
  6508. exports.inherits = _dereq_('inherits');
  6509. exports._extend = function(origin, add) {
  6510. // Don't do anything if add isn't an object
  6511. if (!add || !isObject(add)) return origin;
  6512. var keys = Object.keys(add);
  6513. var i = keys.length;
  6514. while (i--) {
  6515. origin[keys[i]] = add[keys[i]];
  6516. }
  6517. return origin;
  6518. };
  6519. function hasOwnProperty(obj, prop) {
  6520. return Object.prototype.hasOwnProperty.call(obj, prop);
  6521. }
  6522. }).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  6523. },{"./support/isBuffer":9,"_process":169,"inherits":8}],11:[function(_dereq_,module,exports){
  6524. 'use strict'
  6525. exports.byteLength = byteLength
  6526. exports.toByteArray = toByteArray
  6527. exports.fromByteArray = fromByteArray
  6528. var lookup = []
  6529. var revLookup = []
  6530. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  6531. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  6532. for (var i = 0, len = code.length; i < len; ++i) {
  6533. lookup[i] = code[i]
  6534. revLookup[code.charCodeAt(i)] = i
  6535. }
  6536. // Support decoding URL-safe base64 strings, as Node.js does.
  6537. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  6538. revLookup['-'.charCodeAt(0)] = 62
  6539. revLookup['_'.charCodeAt(0)] = 63
  6540. function getLens (b64) {
  6541. var len = b64.length
  6542. if (len % 4 > 0) {
  6543. throw new Error('Invalid string. Length must be a multiple of 4')
  6544. }
  6545. // Trim off extra bytes after placeholder bytes are found
  6546. // See: https://github.com/beatgammit/base64-js/issues/42
  6547. var validLen = b64.indexOf('=')
  6548. if (validLen === -1) validLen = len
  6549. var placeHoldersLen = validLen === len
  6550. ? 0
  6551. : 4 - (validLen % 4)
  6552. return [validLen, placeHoldersLen]
  6553. }
  6554. // base64 is 4/3 + up to two characters of the original data
  6555. function byteLength (b64) {
  6556. var lens = getLens(b64)
  6557. var validLen = lens[0]
  6558. var placeHoldersLen = lens[1]
  6559. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  6560. }
  6561. function _byteLength (b64, validLen, placeHoldersLen) {
  6562. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  6563. }
  6564. function toByteArray (b64) {
  6565. var tmp
  6566. var lens = getLens(b64)
  6567. var validLen = lens[0]
  6568. var placeHoldersLen = lens[1]
  6569. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  6570. var curByte = 0
  6571. // if there are placeholders, only get up to the last complete 4 chars
  6572. var len = placeHoldersLen > 0
  6573. ? validLen - 4
  6574. : validLen
  6575. for (var i = 0; i < len; i += 4) {
  6576. tmp =
  6577. (revLookup[b64.charCodeAt(i)] << 18) |
  6578. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  6579. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  6580. revLookup[b64.charCodeAt(i + 3)]
  6581. arr[curByte++] = (tmp >> 16) & 0xFF
  6582. arr[curByte++] = (tmp >> 8) & 0xFF
  6583. arr[curByte++] = tmp & 0xFF
  6584. }
  6585. if (placeHoldersLen === 2) {
  6586. tmp =
  6587. (revLookup[b64.charCodeAt(i)] << 2) |
  6588. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  6589. arr[curByte++] = tmp & 0xFF
  6590. }
  6591. if (placeHoldersLen === 1) {
  6592. tmp =
  6593. (revLookup[b64.charCodeAt(i)] << 10) |
  6594. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  6595. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  6596. arr[curByte++] = (tmp >> 8) & 0xFF
  6597. arr[curByte++] = tmp & 0xFF
  6598. }
  6599. return arr
  6600. }
  6601. function tripletToBase64 (num) {
  6602. return lookup[num >> 18 & 0x3F] +
  6603. lookup[num >> 12 & 0x3F] +
  6604. lookup[num >> 6 & 0x3F] +
  6605. lookup[num & 0x3F]
  6606. }
  6607. function encodeChunk (uint8, start, end) {
  6608. var tmp
  6609. var output = []
  6610. for (var i = start; i < end; i += 3) {
  6611. tmp =
  6612. ((uint8[i] << 16) & 0xFF0000) +
  6613. ((uint8[i + 1] << 8) & 0xFF00) +
  6614. (uint8[i + 2] & 0xFF)
  6615. output.push(tripletToBase64(tmp))
  6616. }
  6617. return output.join('')
  6618. }
  6619. function fromByteArray (uint8) {
  6620. var tmp
  6621. var len = uint8.length
  6622. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  6623. var parts = []
  6624. var maxChunkLength = 16383 // must be multiple of 3
  6625. // go through the array every three bytes, we'll deal with trailing stuff later
  6626. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  6627. parts.push(encodeChunk(
  6628. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  6629. ))
  6630. }
  6631. // pad the end with zeros, but make sure to not forget the extra bytes
  6632. if (extraBytes === 1) {
  6633. tmp = uint8[len - 1]
  6634. parts.push(
  6635. lookup[tmp >> 2] +
  6636. lookup[(tmp << 4) & 0x3F] +
  6637. '=='
  6638. )
  6639. } else if (extraBytes === 2) {
  6640. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  6641. parts.push(
  6642. lookup[tmp >> 10] +
  6643. lookup[(tmp >> 4) & 0x3F] +
  6644. lookup[(tmp << 2) & 0x3F] +
  6645. '='
  6646. )
  6647. }
  6648. return parts.join('')
  6649. }
  6650. },{}],12:[function(_dereq_,module,exports){
  6651. (function (global){
  6652. /*!
  6653. * The buffer module from node.js, for the browser.
  6654. *
  6655. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  6656. * @license MIT
  6657. */
  6658. /* eslint-disable no-proto */
  6659. 'use strict'
  6660. var base64 = _dereq_('base64-js')
  6661. var ieee754 = _dereq_('ieee754')
  6662. var isArray = _dereq_('isarray')
  6663. exports.Buffer = Buffer
  6664. exports.SlowBuffer = SlowBuffer
  6665. exports.INSPECT_MAX_BYTES = 50
  6666. /**
  6667. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  6668. * === true Use Uint8Array implementation (fastest)
  6669. * === false Use Object implementation (most compatible, even IE6)
  6670. *
  6671. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  6672. * Opera 11.6+, iOS 4.2+.
  6673. *
  6674. * Due to various browser bugs, sometimes the Object implementation will be used even
  6675. * when the browser supports typed arrays.
  6676. *
  6677. * Note:
  6678. *
  6679. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  6680. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  6681. *
  6682. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  6683. *
  6684. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  6685. * incorrect length in some situations.
  6686. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  6687. * get the Object implementation, which is slower but behaves correctly.
  6688. */
  6689. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  6690. ? global.TYPED_ARRAY_SUPPORT
  6691. : typedArraySupport()
  6692. /*
  6693. * Export kMaxLength after typed array support is determined.
  6694. */
  6695. exports.kMaxLength = kMaxLength()
  6696. function typedArraySupport () {
  6697. try {
  6698. var arr = new Uint8Array(1)
  6699. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  6700. return arr.foo() === 42 && // typed array instances can be augmented
  6701. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  6702. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  6703. } catch (e) {
  6704. return false
  6705. }
  6706. }
  6707. function kMaxLength () {
  6708. return Buffer.TYPED_ARRAY_SUPPORT
  6709. ? 0x7fffffff
  6710. : 0x3fffffff
  6711. }
  6712. function createBuffer (that, length) {
  6713. if (kMaxLength() < length) {
  6714. throw new RangeError('Invalid typed array length')
  6715. }
  6716. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6717. // Return an augmented `Uint8Array` instance, for best performance
  6718. that = new Uint8Array(length)
  6719. that.__proto__ = Buffer.prototype
  6720. } else {
  6721. // Fallback: Return an object instance of the Buffer class
  6722. if (that === null) {
  6723. that = new Buffer(length)
  6724. }
  6725. that.length = length
  6726. }
  6727. return that
  6728. }
  6729. /**
  6730. * The Buffer constructor returns instances of `Uint8Array` that have their
  6731. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  6732. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  6733. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  6734. * returns a single octet.
  6735. *
  6736. * The `Uint8Array` prototype remains unmodified.
  6737. */
  6738. function Buffer (arg, encodingOrOffset, length) {
  6739. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  6740. return new Buffer(arg, encodingOrOffset, length)
  6741. }
  6742. // Common case.
  6743. if (typeof arg === 'number') {
  6744. if (typeof encodingOrOffset === 'string') {
  6745. throw new Error(
  6746. 'If encoding is specified then the first argument must be a string'
  6747. )
  6748. }
  6749. return allocUnsafe(this, arg)
  6750. }
  6751. return from(this, arg, encodingOrOffset, length)
  6752. }
  6753. Buffer.poolSize = 8192 // not used by this implementation
  6754. // TODO: Legacy, not needed anymore. Remove in next major version.
  6755. Buffer._augment = function (arr) {
  6756. arr.__proto__ = Buffer.prototype
  6757. return arr
  6758. }
  6759. function from (that, value, encodingOrOffset, length) {
  6760. if (typeof value === 'number') {
  6761. throw new TypeError('"value" argument must not be a number')
  6762. }
  6763. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  6764. return fromArrayBuffer(that, value, encodingOrOffset, length)
  6765. }
  6766. if (typeof value === 'string') {
  6767. return fromString(that, value, encodingOrOffset)
  6768. }
  6769. return fromObject(that, value)
  6770. }
  6771. /**
  6772. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  6773. * if value is a number.
  6774. * Buffer.from(str[, encoding])
  6775. * Buffer.from(array)
  6776. * Buffer.from(buffer)
  6777. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  6778. **/
  6779. Buffer.from = function (value, encodingOrOffset, length) {
  6780. return from(null, value, encodingOrOffset, length)
  6781. }
  6782. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6783. Buffer.prototype.__proto__ = Uint8Array.prototype
  6784. Buffer.__proto__ = Uint8Array
  6785. if (typeof Symbol !== 'undefined' && Symbol.species &&
  6786. Buffer[Symbol.species] === Buffer) {
  6787. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  6788. Object.defineProperty(Buffer, Symbol.species, {
  6789. value: null,
  6790. configurable: true
  6791. })
  6792. }
  6793. }
  6794. function assertSize (size) {
  6795. if (typeof size !== 'number') {
  6796. throw new TypeError('"size" argument must be a number')
  6797. } else if (size < 0) {
  6798. throw new RangeError('"size" argument must not be negative')
  6799. }
  6800. }
  6801. function alloc (that, size, fill, encoding) {
  6802. assertSize(size)
  6803. if (size <= 0) {
  6804. return createBuffer(that, size)
  6805. }
  6806. if (fill !== undefined) {
  6807. // Only pay attention to encoding if it's a string. This
  6808. // prevents accidentally sending in a number that would
  6809. // be interpretted as a start offset.
  6810. return typeof encoding === 'string'
  6811. ? createBuffer(that, size).fill(fill, encoding)
  6812. : createBuffer(that, size).fill(fill)
  6813. }
  6814. return createBuffer(that, size)
  6815. }
  6816. /**
  6817. * Creates a new filled Buffer instance.
  6818. * alloc(size[, fill[, encoding]])
  6819. **/
  6820. Buffer.alloc = function (size, fill, encoding) {
  6821. return alloc(null, size, fill, encoding)
  6822. }
  6823. function allocUnsafe (that, size) {
  6824. assertSize(size)
  6825. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  6826. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  6827. for (var i = 0; i < size; ++i) {
  6828. that[i] = 0
  6829. }
  6830. }
  6831. return that
  6832. }
  6833. /**
  6834. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  6835. * */
  6836. Buffer.allocUnsafe = function (size) {
  6837. return allocUnsafe(null, size)
  6838. }
  6839. /**
  6840. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  6841. */
  6842. Buffer.allocUnsafeSlow = function (size) {
  6843. return allocUnsafe(null, size)
  6844. }
  6845. function fromString (that, string, encoding) {
  6846. if (typeof encoding !== 'string' || encoding === '') {
  6847. encoding = 'utf8'
  6848. }
  6849. if (!Buffer.isEncoding(encoding)) {
  6850. throw new TypeError('"encoding" must be a valid string encoding')
  6851. }
  6852. var length = byteLength(string, encoding) | 0
  6853. that = createBuffer(that, length)
  6854. var actual = that.write(string, encoding)
  6855. if (actual !== length) {
  6856. // Writing a hex string, for example, that contains invalid characters will
  6857. // cause everything after the first invalid character to be ignored. (e.g.
  6858. // 'abxxcd' will be treated as 'ab')
  6859. that = that.slice(0, actual)
  6860. }
  6861. return that
  6862. }
  6863. function fromArrayLike (that, array) {
  6864. var length = array.length < 0 ? 0 : checked(array.length) | 0
  6865. that = createBuffer(that, length)
  6866. for (var i = 0; i < length; i += 1) {
  6867. that[i] = array[i] & 255
  6868. }
  6869. return that
  6870. }
  6871. function fromArrayBuffer (that, array, byteOffset, length) {
  6872. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  6873. if (byteOffset < 0 || array.byteLength < byteOffset) {
  6874. throw new RangeError('\'offset\' is out of bounds')
  6875. }
  6876. if (array.byteLength < byteOffset + (length || 0)) {
  6877. throw new RangeError('\'length\' is out of bounds')
  6878. }
  6879. if (byteOffset === undefined && length === undefined) {
  6880. array = new Uint8Array(array)
  6881. } else if (length === undefined) {
  6882. array = new Uint8Array(array, byteOffset)
  6883. } else {
  6884. array = new Uint8Array(array, byteOffset, length)
  6885. }
  6886. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6887. // Return an augmented `Uint8Array` instance, for best performance
  6888. that = array
  6889. that.__proto__ = Buffer.prototype
  6890. } else {
  6891. // Fallback: Return an object instance of the Buffer class
  6892. that = fromArrayLike(that, array)
  6893. }
  6894. return that
  6895. }
  6896. function fromObject (that, obj) {
  6897. if (Buffer.isBuffer(obj)) {
  6898. var len = checked(obj.length) | 0
  6899. that = createBuffer(that, len)
  6900. if (that.length === 0) {
  6901. return that
  6902. }
  6903. obj.copy(that, 0, 0, len)
  6904. return that
  6905. }
  6906. if (obj) {
  6907. if ((typeof ArrayBuffer !== 'undefined' &&
  6908. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  6909. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  6910. return createBuffer(that, 0)
  6911. }
  6912. return fromArrayLike(that, obj)
  6913. }
  6914. if (obj.type === 'Buffer' && isArray(obj.data)) {
  6915. return fromArrayLike(that, obj.data)
  6916. }
  6917. }
  6918. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  6919. }
  6920. function checked (length) {
  6921. // Note: cannot use `length < kMaxLength()` here because that fails when
  6922. // length is NaN (which is otherwise coerced to zero.)
  6923. if (length >= kMaxLength()) {
  6924. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  6925. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  6926. }
  6927. return length | 0
  6928. }
  6929. function SlowBuffer (length) {
  6930. if (+length != length) { // eslint-disable-line eqeqeq
  6931. length = 0
  6932. }
  6933. return Buffer.alloc(+length)
  6934. }
  6935. Buffer.isBuffer = function isBuffer (b) {
  6936. return !!(b != null && b._isBuffer)
  6937. }
  6938. Buffer.compare = function compare (a, b) {
  6939. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  6940. throw new TypeError('Arguments must be Buffers')
  6941. }
  6942. if (a === b) return 0
  6943. var x = a.length
  6944. var y = b.length
  6945. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  6946. if (a[i] !== b[i]) {
  6947. x = a[i]
  6948. y = b[i]
  6949. break
  6950. }
  6951. }
  6952. if (x < y) return -1
  6953. if (y < x) return 1
  6954. return 0
  6955. }
  6956. Buffer.isEncoding = function isEncoding (encoding) {
  6957. switch (String(encoding).toLowerCase()) {
  6958. case 'hex':
  6959. case 'utf8':
  6960. case 'utf-8':
  6961. case 'ascii':
  6962. case 'latin1':
  6963. case 'binary':
  6964. case 'base64':
  6965. case 'ucs2':
  6966. case 'ucs-2':
  6967. case 'utf16le':
  6968. case 'utf-16le':
  6969. return true
  6970. default:
  6971. return false
  6972. }
  6973. }
  6974. Buffer.concat = function concat (list, length) {
  6975. if (!isArray(list)) {
  6976. throw new TypeError('"list" argument must be an Array of Buffers')
  6977. }
  6978. if (list.length === 0) {
  6979. return Buffer.alloc(0)
  6980. }
  6981. var i
  6982. if (length === undefined) {
  6983. length = 0
  6984. for (i = 0; i < list.length; ++i) {
  6985. length += list[i].length
  6986. }
  6987. }
  6988. var buffer = Buffer.allocUnsafe(length)
  6989. var pos = 0
  6990. for (i = 0; i < list.length; ++i) {
  6991. var buf = list[i]
  6992. if (!Buffer.isBuffer(buf)) {
  6993. throw new TypeError('"list" argument must be an Array of Buffers')
  6994. }
  6995. buf.copy(buffer, pos)
  6996. pos += buf.length
  6997. }
  6998. return buffer
  6999. }
  7000. function byteLength (string, encoding) {
  7001. if (Buffer.isBuffer(string)) {
  7002. return string.length
  7003. }
  7004. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  7005. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  7006. return string.byteLength
  7007. }
  7008. if (typeof string !== 'string') {
  7009. string = '' + string
  7010. }
  7011. var len = string.length
  7012. if (len === 0) return 0
  7013. // Use a for loop to avoid recursion
  7014. var loweredCase = false
  7015. for (;;) {
  7016. switch (encoding) {
  7017. case 'ascii':
  7018. case 'latin1':
  7019. case 'binary':
  7020. return len
  7021. case 'utf8':
  7022. case 'utf-8':
  7023. case undefined:
  7024. return utf8ToBytes(string).length
  7025. case 'ucs2':
  7026. case 'ucs-2':
  7027. case 'utf16le':
  7028. case 'utf-16le':
  7029. return len * 2
  7030. case 'hex':
  7031. return len >>> 1
  7032. case 'base64':
  7033. return base64ToBytes(string).length
  7034. default:
  7035. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  7036. encoding = ('' + encoding).toLowerCase()
  7037. loweredCase = true
  7038. }
  7039. }
  7040. }
  7041. Buffer.byteLength = byteLength
  7042. function slowToString (encoding, start, end) {
  7043. var loweredCase = false
  7044. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  7045. // property of a typed array.
  7046. // This behaves neither like String nor Uint8Array in that we set start/end
  7047. // to their upper/lower bounds if the value passed is out of range.
  7048. // undefined is handled specially as per ECMA-262 6th Edition,
  7049. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  7050. if (start === undefined || start < 0) {
  7051. start = 0
  7052. }
  7053. // Return early if start > this.length. Done here to prevent potential uint32
  7054. // coercion fail below.
  7055. if (start > this.length) {
  7056. return ''
  7057. }
  7058. if (end === undefined || end > this.length) {
  7059. end = this.length
  7060. }
  7061. if (end <= 0) {
  7062. return ''
  7063. }
  7064. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  7065. end >>>= 0
  7066. start >>>= 0
  7067. if (end <= start) {
  7068. return ''
  7069. }
  7070. if (!encoding) encoding = 'utf8'
  7071. while (true) {
  7072. switch (encoding) {
  7073. case 'hex':
  7074. return hexSlice(this, start, end)
  7075. case 'utf8':
  7076. case 'utf-8':
  7077. return utf8Slice(this, start, end)
  7078. case 'ascii':
  7079. return asciiSlice(this, start, end)
  7080. case 'latin1':
  7081. case 'binary':
  7082. return latin1Slice(this, start, end)
  7083. case 'base64':
  7084. return base64Slice(this, start, end)
  7085. case 'ucs2':
  7086. case 'ucs-2':
  7087. case 'utf16le':
  7088. case 'utf-16le':
  7089. return utf16leSlice(this, start, end)
  7090. default:
  7091. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  7092. encoding = (encoding + '').toLowerCase()
  7093. loweredCase = true
  7094. }
  7095. }
  7096. }
  7097. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  7098. // Buffer instances.
  7099. Buffer.prototype._isBuffer = true
  7100. function swap (b, n, m) {
  7101. var i = b[n]
  7102. b[n] = b[m]
  7103. b[m] = i
  7104. }
  7105. Buffer.prototype.swap16 = function swap16 () {
  7106. var len = this.length
  7107. if (len % 2 !== 0) {
  7108. throw new RangeError('Buffer size must be a multiple of 16-bits')
  7109. }
  7110. for (var i = 0; i < len; i += 2) {
  7111. swap(this, i, i + 1)
  7112. }
  7113. return this
  7114. }
  7115. Buffer.prototype.swap32 = function swap32 () {
  7116. var len = this.length
  7117. if (len % 4 !== 0) {
  7118. throw new RangeError('Buffer size must be a multiple of 32-bits')
  7119. }
  7120. for (var i = 0; i < len; i += 4) {
  7121. swap(this, i, i + 3)
  7122. swap(this, i + 1, i + 2)
  7123. }
  7124. return this
  7125. }
  7126. Buffer.prototype.swap64 = function swap64 () {
  7127. var len = this.length
  7128. if (len % 8 !== 0) {
  7129. throw new RangeError('Buffer size must be a multiple of 64-bits')
  7130. }
  7131. for (var i = 0; i < len; i += 8) {
  7132. swap(this, i, i + 7)
  7133. swap(this, i + 1, i + 6)
  7134. swap(this, i + 2, i + 5)
  7135. swap(this, i + 3, i + 4)
  7136. }
  7137. return this
  7138. }
  7139. Buffer.prototype.toString = function toString () {
  7140. var length = this.length | 0
  7141. if (length === 0) return ''
  7142. if (arguments.length === 0) return utf8Slice(this, 0, length)
  7143. return slowToString.apply(this, arguments)
  7144. }
  7145. Buffer.prototype.equals = function equals (b) {
  7146. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  7147. if (this === b) return true
  7148. return Buffer.compare(this, b) === 0
  7149. }
  7150. Buffer.prototype.inspect = function inspect () {
  7151. var str = ''
  7152. var max = exports.INSPECT_MAX_BYTES
  7153. if (this.length > 0) {
  7154. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  7155. if (this.length > max) str += ' ... '
  7156. }
  7157. return '<Buffer ' + str + '>'
  7158. }
  7159. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  7160. if (!Buffer.isBuffer(target)) {
  7161. throw new TypeError('Argument must be a Buffer')
  7162. }
  7163. if (start === undefined) {
  7164. start = 0
  7165. }
  7166. if (end === undefined) {
  7167. end = target ? target.length : 0
  7168. }
  7169. if (thisStart === undefined) {
  7170. thisStart = 0
  7171. }
  7172. if (thisEnd === undefined) {
  7173. thisEnd = this.length
  7174. }
  7175. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  7176. throw new RangeError('out of range index')
  7177. }
  7178. if (thisStart >= thisEnd && start >= end) {
  7179. return 0
  7180. }
  7181. if (thisStart >= thisEnd) {
  7182. return -1
  7183. }
  7184. if (start >= end) {
  7185. return 1
  7186. }
  7187. start >>>= 0
  7188. end >>>= 0
  7189. thisStart >>>= 0
  7190. thisEnd >>>= 0
  7191. if (this === target) return 0
  7192. var x = thisEnd - thisStart
  7193. var y = end - start
  7194. var len = Math.min(x, y)
  7195. var thisCopy = this.slice(thisStart, thisEnd)
  7196. var targetCopy = target.slice(start, end)
  7197. for (var i = 0; i < len; ++i) {
  7198. if (thisCopy[i] !== targetCopy[i]) {
  7199. x = thisCopy[i]
  7200. y = targetCopy[i]
  7201. break
  7202. }
  7203. }
  7204. if (x < y) return -1
  7205. if (y < x) return 1
  7206. return 0
  7207. }
  7208. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  7209. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  7210. //
  7211. // Arguments:
  7212. // - buffer - a Buffer to search
  7213. // - val - a string, Buffer, or number
  7214. // - byteOffset - an index into `buffer`; will be clamped to an int32
  7215. // - encoding - an optional encoding, relevant is val is a string
  7216. // - dir - true for indexOf, false for lastIndexOf
  7217. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  7218. // Empty buffer means no match
  7219. if (buffer.length === 0) return -1
  7220. // Normalize byteOffset
  7221. if (typeof byteOffset === 'string') {
  7222. encoding = byteOffset
  7223. byteOffset = 0
  7224. } else if (byteOffset > 0x7fffffff) {
  7225. byteOffset = 0x7fffffff
  7226. } else if (byteOffset < -0x80000000) {
  7227. byteOffset = -0x80000000
  7228. }
  7229. byteOffset = +byteOffset // Coerce to Number.
  7230. if (isNaN(byteOffset)) {
  7231. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  7232. byteOffset = dir ? 0 : (buffer.length - 1)
  7233. }
  7234. // Normalize byteOffset: negative offsets start from the end of the buffer
  7235. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  7236. if (byteOffset >= buffer.length) {
  7237. if (dir) return -1
  7238. else byteOffset = buffer.length - 1
  7239. } else if (byteOffset < 0) {
  7240. if (dir) byteOffset = 0
  7241. else return -1
  7242. }
  7243. // Normalize val
  7244. if (typeof val === 'string') {
  7245. val = Buffer.from(val, encoding)
  7246. }
  7247. // Finally, search either indexOf (if dir is true) or lastIndexOf
  7248. if (Buffer.isBuffer(val)) {
  7249. // Special case: looking for empty string/buffer always fails
  7250. if (val.length === 0) {
  7251. return -1
  7252. }
  7253. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  7254. } else if (typeof val === 'number') {
  7255. val = val & 0xFF // Search for a byte value [0-255]
  7256. if (Buffer.TYPED_ARRAY_SUPPORT &&
  7257. typeof Uint8Array.prototype.indexOf === 'function') {
  7258. if (dir) {
  7259. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  7260. } else {
  7261. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  7262. }
  7263. }
  7264. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  7265. }
  7266. throw new TypeError('val must be string, number or Buffer')
  7267. }
  7268. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  7269. var indexSize = 1
  7270. var arrLength = arr.length
  7271. var valLength = val.length
  7272. if (encoding !== undefined) {
  7273. encoding = String(encoding).toLowerCase()
  7274. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  7275. encoding === 'utf16le' || encoding === 'utf-16le') {
  7276. if (arr.length < 2 || val.length < 2) {
  7277. return -1
  7278. }
  7279. indexSize = 2
  7280. arrLength /= 2
  7281. valLength /= 2
  7282. byteOffset /= 2
  7283. }
  7284. }
  7285. function read (buf, i) {
  7286. if (indexSize === 1) {
  7287. return buf[i]
  7288. } else {
  7289. return buf.readUInt16BE(i * indexSize)
  7290. }
  7291. }
  7292. var i
  7293. if (dir) {
  7294. var foundIndex = -1
  7295. for (i = byteOffset; i < arrLength; i++) {
  7296. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  7297. if (foundIndex === -1) foundIndex = i
  7298. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  7299. } else {
  7300. if (foundIndex !== -1) i -= i - foundIndex
  7301. foundIndex = -1
  7302. }
  7303. }
  7304. } else {
  7305. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  7306. for (i = byteOffset; i >= 0; i--) {
  7307. var found = true
  7308. for (var j = 0; j < valLength; j++) {
  7309. if (read(arr, i + j) !== read(val, j)) {
  7310. found = false
  7311. break
  7312. }
  7313. }
  7314. if (found) return i
  7315. }
  7316. }
  7317. return -1
  7318. }
  7319. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  7320. return this.indexOf(val, byteOffset, encoding) !== -1
  7321. }
  7322. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  7323. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  7324. }
  7325. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  7326. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  7327. }
  7328. function hexWrite (buf, string, offset, length) {
  7329. offset = Number(offset) || 0
  7330. var remaining = buf.length - offset
  7331. if (!length) {
  7332. length = remaining
  7333. } else {
  7334. length = Number(length)
  7335. if (length > remaining) {
  7336. length = remaining
  7337. }
  7338. }
  7339. // must be an even number of digits
  7340. var strLen = string.length
  7341. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  7342. if (length > strLen / 2) {
  7343. length = strLen / 2
  7344. }
  7345. for (var i = 0; i < length; ++i) {
  7346. var parsed = parseInt(string.substr(i * 2, 2), 16)
  7347. if (isNaN(parsed)) return i
  7348. buf[offset + i] = parsed
  7349. }
  7350. return i
  7351. }
  7352. function utf8Write (buf, string, offset, length) {
  7353. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  7354. }
  7355. function asciiWrite (buf, string, offset, length) {
  7356. return blitBuffer(asciiToBytes(string), buf, offset, length)
  7357. }
  7358. function latin1Write (buf, string, offset, length) {
  7359. return asciiWrite(buf, string, offset, length)
  7360. }
  7361. function base64Write (buf, string, offset, length) {
  7362. return blitBuffer(base64ToBytes(string), buf, offset, length)
  7363. }
  7364. function ucs2Write (buf, string, offset, length) {
  7365. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  7366. }
  7367. Buffer.prototype.write = function write (string, offset, length, encoding) {
  7368. // Buffer#write(string)
  7369. if (offset === undefined) {
  7370. encoding = 'utf8'
  7371. length = this.length
  7372. offset = 0
  7373. // Buffer#write(string, encoding)
  7374. } else if (length === undefined && typeof offset === 'string') {
  7375. encoding = offset
  7376. length = this.length
  7377. offset = 0
  7378. // Buffer#write(string, offset[, length][, encoding])
  7379. } else if (isFinite(offset)) {
  7380. offset = offset | 0
  7381. if (isFinite(length)) {
  7382. length = length | 0
  7383. if (encoding === undefined) encoding = 'utf8'
  7384. } else {
  7385. encoding = length
  7386. length = undefined
  7387. }
  7388. // legacy write(string, encoding, offset, length) - remove in v0.13
  7389. } else {
  7390. throw new Error(
  7391. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  7392. )
  7393. }
  7394. var remaining = this.length - offset
  7395. if (length === undefined || length > remaining) length = remaining
  7396. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  7397. throw new RangeError('Attempt to write outside buffer bounds')
  7398. }
  7399. if (!encoding) encoding = 'utf8'
  7400. var loweredCase = false
  7401. for (;;) {
  7402. switch (encoding) {
  7403. case 'hex':
  7404. return hexWrite(this, string, offset, length)
  7405. case 'utf8':
  7406. case 'utf-8':
  7407. return utf8Write(this, string, offset, length)
  7408. case 'ascii':
  7409. return asciiWrite(this, string, offset, length)
  7410. case 'latin1':
  7411. case 'binary':
  7412. return latin1Write(this, string, offset, length)
  7413. case 'base64':
  7414. // Warning: maxLength not taken into account in base64Write
  7415. return base64Write(this, string, offset, length)
  7416. case 'ucs2':
  7417. case 'ucs-2':
  7418. case 'utf16le':
  7419. case 'utf-16le':
  7420. return ucs2Write(this, string, offset, length)
  7421. default:
  7422. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  7423. encoding = ('' + encoding).toLowerCase()
  7424. loweredCase = true
  7425. }
  7426. }
  7427. }
  7428. Buffer.prototype.toJSON = function toJSON () {
  7429. return {
  7430. type: 'Buffer',
  7431. data: Array.prototype.slice.call(this._arr || this, 0)
  7432. }
  7433. }
  7434. function base64Slice (buf, start, end) {
  7435. if (start === 0 && end === buf.length) {
  7436. return base64.fromByteArray(buf)
  7437. } else {
  7438. return base64.fromByteArray(buf.slice(start, end))
  7439. }
  7440. }
  7441. function utf8Slice (buf, start, end) {
  7442. end = Math.min(buf.length, end)
  7443. var res = []
  7444. var i = start
  7445. while (i < end) {
  7446. var firstByte = buf[i]
  7447. var codePoint = null
  7448. var bytesPerSequence = (firstByte > 0xEF) ? 4
  7449. : (firstByte > 0xDF) ? 3
  7450. : (firstByte > 0xBF) ? 2
  7451. : 1
  7452. if (i + bytesPerSequence <= end) {
  7453. var secondByte, thirdByte, fourthByte, tempCodePoint
  7454. switch (bytesPerSequence) {
  7455. case 1:
  7456. if (firstByte < 0x80) {
  7457. codePoint = firstByte
  7458. }
  7459. break
  7460. case 2:
  7461. secondByte = buf[i + 1]
  7462. if ((secondByte & 0xC0) === 0x80) {
  7463. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  7464. if (tempCodePoint > 0x7F) {
  7465. codePoint = tempCodePoint
  7466. }
  7467. }
  7468. break
  7469. case 3:
  7470. secondByte = buf[i + 1]
  7471. thirdByte = buf[i + 2]
  7472. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  7473. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  7474. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  7475. codePoint = tempCodePoint
  7476. }
  7477. }
  7478. break
  7479. case 4:
  7480. secondByte = buf[i + 1]
  7481. thirdByte = buf[i + 2]
  7482. fourthByte = buf[i + 3]
  7483. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  7484. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  7485. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  7486. codePoint = tempCodePoint
  7487. }
  7488. }
  7489. }
  7490. }
  7491. if (codePoint === null) {
  7492. // we did not generate a valid codePoint so insert a
  7493. // replacement char (U+FFFD) and advance only 1 byte
  7494. codePoint = 0xFFFD
  7495. bytesPerSequence = 1
  7496. } else if (codePoint > 0xFFFF) {
  7497. // encode to utf16 (surrogate pair dance)
  7498. codePoint -= 0x10000
  7499. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  7500. codePoint = 0xDC00 | codePoint & 0x3FF
  7501. }
  7502. res.push(codePoint)
  7503. i += bytesPerSequence
  7504. }
  7505. return decodeCodePointsArray(res)
  7506. }
  7507. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  7508. // the lowest limit is Chrome, with 0x10000 args.
  7509. // We go 1 magnitude less, for safety
  7510. var MAX_ARGUMENTS_LENGTH = 0x1000
  7511. function decodeCodePointsArray (codePoints) {
  7512. var len = codePoints.length
  7513. if (len <= MAX_ARGUMENTS_LENGTH) {
  7514. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  7515. }
  7516. // Decode in chunks to avoid "call stack size exceeded".
  7517. var res = ''
  7518. var i = 0
  7519. while (i < len) {
  7520. res += String.fromCharCode.apply(
  7521. String,
  7522. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  7523. )
  7524. }
  7525. return res
  7526. }
  7527. function asciiSlice (buf, start, end) {
  7528. var ret = ''
  7529. end = Math.min(buf.length, end)
  7530. for (var i = start; i < end; ++i) {
  7531. ret += String.fromCharCode(buf[i] & 0x7F)
  7532. }
  7533. return ret
  7534. }
  7535. function latin1Slice (buf, start, end) {
  7536. var ret = ''
  7537. end = Math.min(buf.length, end)
  7538. for (var i = start; i < end; ++i) {
  7539. ret += String.fromCharCode(buf[i])
  7540. }
  7541. return ret
  7542. }
  7543. function hexSlice (buf, start, end) {
  7544. var len = buf.length
  7545. if (!start || start < 0) start = 0
  7546. if (!end || end < 0 || end > len) end = len
  7547. var out = ''
  7548. for (var i = start; i < end; ++i) {
  7549. out += toHex(buf[i])
  7550. }
  7551. return out
  7552. }
  7553. function utf16leSlice (buf, start, end) {
  7554. var bytes = buf.slice(start, end)
  7555. var res = ''
  7556. for (var i = 0; i < bytes.length; i += 2) {
  7557. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  7558. }
  7559. return res
  7560. }
  7561. Buffer.prototype.slice = function slice (start, end) {
  7562. var len = this.length
  7563. start = ~~start
  7564. end = end === undefined ? len : ~~end
  7565. if (start < 0) {
  7566. start += len
  7567. if (start < 0) start = 0
  7568. } else if (start > len) {
  7569. start = len
  7570. }
  7571. if (end < 0) {
  7572. end += len
  7573. if (end < 0) end = 0
  7574. } else if (end > len) {
  7575. end = len
  7576. }
  7577. if (end < start) end = start
  7578. var newBuf
  7579. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7580. newBuf = this.subarray(start, end)
  7581. newBuf.__proto__ = Buffer.prototype
  7582. } else {
  7583. var sliceLen = end - start
  7584. newBuf = new Buffer(sliceLen, undefined)
  7585. for (var i = 0; i < sliceLen; ++i) {
  7586. newBuf[i] = this[i + start]
  7587. }
  7588. }
  7589. return newBuf
  7590. }
  7591. /*
  7592. * Need to make sure that buffer isn't trying to write out of bounds.
  7593. */
  7594. function checkOffset (offset, ext, length) {
  7595. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  7596. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  7597. }
  7598. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  7599. offset = offset | 0
  7600. byteLength = byteLength | 0
  7601. if (!noAssert) checkOffset(offset, byteLength, this.length)
  7602. var val = this[offset]
  7603. var mul = 1
  7604. var i = 0
  7605. while (++i < byteLength && (mul *= 0x100)) {
  7606. val += this[offset + i] * mul
  7607. }
  7608. return val
  7609. }
  7610. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  7611. offset = offset | 0
  7612. byteLength = byteLength | 0
  7613. if (!noAssert) {
  7614. checkOffset(offset, byteLength, this.length)
  7615. }
  7616. var val = this[offset + --byteLength]
  7617. var mul = 1
  7618. while (byteLength > 0 && (mul *= 0x100)) {
  7619. val += this[offset + --byteLength] * mul
  7620. }
  7621. return val
  7622. }
  7623. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  7624. if (!noAssert) checkOffset(offset, 1, this.length)
  7625. return this[offset]
  7626. }
  7627. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  7628. if (!noAssert) checkOffset(offset, 2, this.length)
  7629. return this[offset] | (this[offset + 1] << 8)
  7630. }
  7631. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  7632. if (!noAssert) checkOffset(offset, 2, this.length)
  7633. return (this[offset] << 8) | this[offset + 1]
  7634. }
  7635. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  7636. if (!noAssert) checkOffset(offset, 4, this.length)
  7637. return ((this[offset]) |
  7638. (this[offset + 1] << 8) |
  7639. (this[offset + 2] << 16)) +
  7640. (this[offset + 3] * 0x1000000)
  7641. }
  7642. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  7643. if (!noAssert) checkOffset(offset, 4, this.length)
  7644. return (this[offset] * 0x1000000) +
  7645. ((this[offset + 1] << 16) |
  7646. (this[offset + 2] << 8) |
  7647. this[offset + 3])
  7648. }
  7649. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  7650. offset = offset | 0
  7651. byteLength = byteLength | 0
  7652. if (!noAssert) checkOffset(offset, byteLength, this.length)
  7653. var val = this[offset]
  7654. var mul = 1
  7655. var i = 0
  7656. while (++i < byteLength && (mul *= 0x100)) {
  7657. val += this[offset + i] * mul
  7658. }
  7659. mul *= 0x80
  7660. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  7661. return val
  7662. }
  7663. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  7664. offset = offset | 0
  7665. byteLength = byteLength | 0
  7666. if (!noAssert) checkOffset(offset, byteLength, this.length)
  7667. var i = byteLength
  7668. var mul = 1
  7669. var val = this[offset + --i]
  7670. while (i > 0 && (mul *= 0x100)) {
  7671. val += this[offset + --i] * mul
  7672. }
  7673. mul *= 0x80
  7674. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  7675. return val
  7676. }
  7677. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  7678. if (!noAssert) checkOffset(offset, 1, this.length)
  7679. if (!(this[offset] & 0x80)) return (this[offset])
  7680. return ((0xff - this[offset] + 1) * -1)
  7681. }
  7682. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  7683. if (!noAssert) checkOffset(offset, 2, this.length)
  7684. var val = this[offset] | (this[offset + 1] << 8)
  7685. return (val & 0x8000) ? val | 0xFFFF0000 : val
  7686. }
  7687. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  7688. if (!noAssert) checkOffset(offset, 2, this.length)
  7689. var val = this[offset + 1] | (this[offset] << 8)
  7690. return (val & 0x8000) ? val | 0xFFFF0000 : val
  7691. }
  7692. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  7693. if (!noAssert) checkOffset(offset, 4, this.length)
  7694. return (this[offset]) |
  7695. (this[offset + 1] << 8) |
  7696. (this[offset + 2] << 16) |
  7697. (this[offset + 3] << 24)
  7698. }
  7699. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  7700. if (!noAssert) checkOffset(offset, 4, this.length)
  7701. return (this[offset] << 24) |
  7702. (this[offset + 1] << 16) |
  7703. (this[offset + 2] << 8) |
  7704. (this[offset + 3])
  7705. }
  7706. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  7707. if (!noAssert) checkOffset(offset, 4, this.length)
  7708. return ieee754.read(this, offset, true, 23, 4)
  7709. }
  7710. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  7711. if (!noAssert) checkOffset(offset, 4, this.length)
  7712. return ieee754.read(this, offset, false, 23, 4)
  7713. }
  7714. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  7715. if (!noAssert) checkOffset(offset, 8, this.length)
  7716. return ieee754.read(this, offset, true, 52, 8)
  7717. }
  7718. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  7719. if (!noAssert) checkOffset(offset, 8, this.length)
  7720. return ieee754.read(this, offset, false, 52, 8)
  7721. }
  7722. function checkInt (buf, value, offset, ext, max, min) {
  7723. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  7724. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  7725. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  7726. }
  7727. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  7728. value = +value
  7729. offset = offset | 0
  7730. byteLength = byteLength | 0
  7731. if (!noAssert) {
  7732. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  7733. checkInt(this, value, offset, byteLength, maxBytes, 0)
  7734. }
  7735. var mul = 1
  7736. var i = 0
  7737. this[offset] = value & 0xFF
  7738. while (++i < byteLength && (mul *= 0x100)) {
  7739. this[offset + i] = (value / mul) & 0xFF
  7740. }
  7741. return offset + byteLength
  7742. }
  7743. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  7744. value = +value
  7745. offset = offset | 0
  7746. byteLength = byteLength | 0
  7747. if (!noAssert) {
  7748. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  7749. checkInt(this, value, offset, byteLength, maxBytes, 0)
  7750. }
  7751. var i = byteLength - 1
  7752. var mul = 1
  7753. this[offset + i] = value & 0xFF
  7754. while (--i >= 0 && (mul *= 0x100)) {
  7755. this[offset + i] = (value / mul) & 0xFF
  7756. }
  7757. return offset + byteLength
  7758. }
  7759. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  7760. value = +value
  7761. offset = offset | 0
  7762. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  7763. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  7764. this[offset] = (value & 0xff)
  7765. return offset + 1
  7766. }
  7767. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  7768. if (value < 0) value = 0xffff + value + 1
  7769. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  7770. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  7771. (littleEndian ? i : 1 - i) * 8
  7772. }
  7773. }
  7774. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  7775. value = +value
  7776. offset = offset | 0
  7777. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  7778. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7779. this[offset] = (value & 0xff)
  7780. this[offset + 1] = (value >>> 8)
  7781. } else {
  7782. objectWriteUInt16(this, value, offset, true)
  7783. }
  7784. return offset + 2
  7785. }
  7786. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  7787. value = +value
  7788. offset = offset | 0
  7789. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  7790. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7791. this[offset] = (value >>> 8)
  7792. this[offset + 1] = (value & 0xff)
  7793. } else {
  7794. objectWriteUInt16(this, value, offset, false)
  7795. }
  7796. return offset + 2
  7797. }
  7798. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  7799. if (value < 0) value = 0xffffffff + value + 1
  7800. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  7801. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  7802. }
  7803. }
  7804. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  7805. value = +value
  7806. offset = offset | 0
  7807. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  7808. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7809. this[offset + 3] = (value >>> 24)
  7810. this[offset + 2] = (value >>> 16)
  7811. this[offset + 1] = (value >>> 8)
  7812. this[offset] = (value & 0xff)
  7813. } else {
  7814. objectWriteUInt32(this, value, offset, true)
  7815. }
  7816. return offset + 4
  7817. }
  7818. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  7819. value = +value
  7820. offset = offset | 0
  7821. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  7822. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7823. this[offset] = (value >>> 24)
  7824. this[offset + 1] = (value >>> 16)
  7825. this[offset + 2] = (value >>> 8)
  7826. this[offset + 3] = (value & 0xff)
  7827. } else {
  7828. objectWriteUInt32(this, value, offset, false)
  7829. }
  7830. return offset + 4
  7831. }
  7832. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  7833. value = +value
  7834. offset = offset | 0
  7835. if (!noAssert) {
  7836. var limit = Math.pow(2, 8 * byteLength - 1)
  7837. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  7838. }
  7839. var i = 0
  7840. var mul = 1
  7841. var sub = 0
  7842. this[offset] = value & 0xFF
  7843. while (++i < byteLength && (mul *= 0x100)) {
  7844. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  7845. sub = 1
  7846. }
  7847. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  7848. }
  7849. return offset + byteLength
  7850. }
  7851. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  7852. value = +value
  7853. offset = offset | 0
  7854. if (!noAssert) {
  7855. var limit = Math.pow(2, 8 * byteLength - 1)
  7856. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  7857. }
  7858. var i = byteLength - 1
  7859. var mul = 1
  7860. var sub = 0
  7861. this[offset + i] = value & 0xFF
  7862. while (--i >= 0 && (mul *= 0x100)) {
  7863. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  7864. sub = 1
  7865. }
  7866. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  7867. }
  7868. return offset + byteLength
  7869. }
  7870. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  7871. value = +value
  7872. offset = offset | 0
  7873. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  7874. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  7875. if (value < 0) value = 0xff + value + 1
  7876. this[offset] = (value & 0xff)
  7877. return offset + 1
  7878. }
  7879. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  7880. value = +value
  7881. offset = offset | 0
  7882. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  7883. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7884. this[offset] = (value & 0xff)
  7885. this[offset + 1] = (value >>> 8)
  7886. } else {
  7887. objectWriteUInt16(this, value, offset, true)
  7888. }
  7889. return offset + 2
  7890. }
  7891. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  7892. value = +value
  7893. offset = offset | 0
  7894. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  7895. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7896. this[offset] = (value >>> 8)
  7897. this[offset + 1] = (value & 0xff)
  7898. } else {
  7899. objectWriteUInt16(this, value, offset, false)
  7900. }
  7901. return offset + 2
  7902. }
  7903. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  7904. value = +value
  7905. offset = offset | 0
  7906. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  7907. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7908. this[offset] = (value & 0xff)
  7909. this[offset + 1] = (value >>> 8)
  7910. this[offset + 2] = (value >>> 16)
  7911. this[offset + 3] = (value >>> 24)
  7912. } else {
  7913. objectWriteUInt32(this, value, offset, true)
  7914. }
  7915. return offset + 4
  7916. }
  7917. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  7918. value = +value
  7919. offset = offset | 0
  7920. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  7921. if (value < 0) value = 0xffffffff + value + 1
  7922. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7923. this[offset] = (value >>> 24)
  7924. this[offset + 1] = (value >>> 16)
  7925. this[offset + 2] = (value >>> 8)
  7926. this[offset + 3] = (value & 0xff)
  7927. } else {
  7928. objectWriteUInt32(this, value, offset, false)
  7929. }
  7930. return offset + 4
  7931. }
  7932. function checkIEEE754 (buf, value, offset, ext, max, min) {
  7933. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  7934. if (offset < 0) throw new RangeError('Index out of range')
  7935. }
  7936. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  7937. if (!noAssert) {
  7938. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  7939. }
  7940. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  7941. return offset + 4
  7942. }
  7943. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  7944. return writeFloat(this, value, offset, true, noAssert)
  7945. }
  7946. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  7947. return writeFloat(this, value, offset, false, noAssert)
  7948. }
  7949. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  7950. if (!noAssert) {
  7951. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  7952. }
  7953. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  7954. return offset + 8
  7955. }
  7956. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  7957. return writeDouble(this, value, offset, true, noAssert)
  7958. }
  7959. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  7960. return writeDouble(this, value, offset, false, noAssert)
  7961. }
  7962. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  7963. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  7964. if (!start) start = 0
  7965. if (!end && end !== 0) end = this.length
  7966. if (targetStart >= target.length) targetStart = target.length
  7967. if (!targetStart) targetStart = 0
  7968. if (end > 0 && end < start) end = start
  7969. // Copy 0 bytes; we're done
  7970. if (end === start) return 0
  7971. if (target.length === 0 || this.length === 0) return 0
  7972. // Fatal error conditions
  7973. if (targetStart < 0) {
  7974. throw new RangeError('targetStart out of bounds')
  7975. }
  7976. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  7977. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  7978. // Are we oob?
  7979. if (end > this.length) end = this.length
  7980. if (target.length - targetStart < end - start) {
  7981. end = target.length - targetStart + start
  7982. }
  7983. var len = end - start
  7984. var i
  7985. if (this === target && start < targetStart && targetStart < end) {
  7986. // descending copy from end
  7987. for (i = len - 1; i >= 0; --i) {
  7988. target[i + targetStart] = this[i + start]
  7989. }
  7990. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  7991. // ascending copy from start
  7992. for (i = 0; i < len; ++i) {
  7993. target[i + targetStart] = this[i + start]
  7994. }
  7995. } else {
  7996. Uint8Array.prototype.set.call(
  7997. target,
  7998. this.subarray(start, start + len),
  7999. targetStart
  8000. )
  8001. }
  8002. return len
  8003. }
  8004. // Usage:
  8005. // buffer.fill(number[, offset[, end]])
  8006. // buffer.fill(buffer[, offset[, end]])
  8007. // buffer.fill(string[, offset[, end]][, encoding])
  8008. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  8009. // Handle string cases:
  8010. if (typeof val === 'string') {
  8011. if (typeof start === 'string') {
  8012. encoding = start
  8013. start = 0
  8014. end = this.length
  8015. } else if (typeof end === 'string') {
  8016. encoding = end
  8017. end = this.length
  8018. }
  8019. if (val.length === 1) {
  8020. var code = val.charCodeAt(0)
  8021. if (code < 256) {
  8022. val = code
  8023. }
  8024. }
  8025. if (encoding !== undefined && typeof encoding !== 'string') {
  8026. throw new TypeError('encoding must be a string')
  8027. }
  8028. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  8029. throw new TypeError('Unknown encoding: ' + encoding)
  8030. }
  8031. } else if (typeof val === 'number') {
  8032. val = val & 255
  8033. }
  8034. // Invalid ranges are not set to a default, so can range check early.
  8035. if (start < 0 || this.length < start || this.length < end) {
  8036. throw new RangeError('Out of range index')
  8037. }
  8038. if (end <= start) {
  8039. return this
  8040. }
  8041. start = start >>> 0
  8042. end = end === undefined ? this.length : end >>> 0
  8043. if (!val) val = 0
  8044. var i
  8045. if (typeof val === 'number') {
  8046. for (i = start; i < end; ++i) {
  8047. this[i] = val
  8048. }
  8049. } else {
  8050. var bytes = Buffer.isBuffer(val)
  8051. ? val
  8052. : utf8ToBytes(new Buffer(val, encoding).toString())
  8053. var len = bytes.length
  8054. for (i = 0; i < end - start; ++i) {
  8055. this[i + start] = bytes[i % len]
  8056. }
  8057. }
  8058. return this
  8059. }
  8060. // HELPER FUNCTIONS
  8061. // ================
  8062. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  8063. function base64clean (str) {
  8064. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  8065. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  8066. // Node converts strings with length < 2 to ''
  8067. if (str.length < 2) return ''
  8068. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  8069. while (str.length % 4 !== 0) {
  8070. str = str + '='
  8071. }
  8072. return str
  8073. }
  8074. function stringtrim (str) {
  8075. if (str.trim) return str.trim()
  8076. return str.replace(/^\s+|\s+$/g, '')
  8077. }
  8078. function toHex (n) {
  8079. if (n < 16) return '0' + n.toString(16)
  8080. return n.toString(16)
  8081. }
  8082. function utf8ToBytes (string, units) {
  8083. units = units || Infinity
  8084. var codePoint
  8085. var length = string.length
  8086. var leadSurrogate = null
  8087. var bytes = []
  8088. for (var i = 0; i < length; ++i) {
  8089. codePoint = string.charCodeAt(i)
  8090. // is surrogate component
  8091. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  8092. // last char was a lead
  8093. if (!leadSurrogate) {
  8094. // no lead yet
  8095. if (codePoint > 0xDBFF) {
  8096. // unexpected trail
  8097. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  8098. continue
  8099. } else if (i + 1 === length) {
  8100. // unpaired lead
  8101. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  8102. continue
  8103. }
  8104. // valid lead
  8105. leadSurrogate = codePoint
  8106. continue
  8107. }
  8108. // 2 leads in a row
  8109. if (codePoint < 0xDC00) {
  8110. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  8111. leadSurrogate = codePoint
  8112. continue
  8113. }
  8114. // valid surrogate pair
  8115. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  8116. } else if (leadSurrogate) {
  8117. // valid bmp char, but last char was a lead
  8118. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  8119. }
  8120. leadSurrogate = null
  8121. // encode utf8
  8122. if (codePoint < 0x80) {
  8123. if ((units -= 1) < 0) break
  8124. bytes.push(codePoint)
  8125. } else if (codePoint < 0x800) {
  8126. if ((units -= 2) < 0) break
  8127. bytes.push(
  8128. codePoint >> 0x6 | 0xC0,
  8129. codePoint & 0x3F | 0x80
  8130. )
  8131. } else if (codePoint < 0x10000) {
  8132. if ((units -= 3) < 0) break
  8133. bytes.push(
  8134. codePoint >> 0xC | 0xE0,
  8135. codePoint >> 0x6 & 0x3F | 0x80,
  8136. codePoint & 0x3F | 0x80
  8137. )
  8138. } else if (codePoint < 0x110000) {
  8139. if ((units -= 4) < 0) break
  8140. bytes.push(
  8141. codePoint >> 0x12 | 0xF0,
  8142. codePoint >> 0xC & 0x3F | 0x80,
  8143. codePoint >> 0x6 & 0x3F | 0x80,
  8144. codePoint & 0x3F | 0x80
  8145. )
  8146. } else {
  8147. throw new Error('Invalid code point')
  8148. }
  8149. }
  8150. return bytes
  8151. }
  8152. function asciiToBytes (str) {
  8153. var byteArray = []
  8154. for (var i = 0; i < str.length; ++i) {
  8155. // Node's code seems to be doing this and not & 0x7F..
  8156. byteArray.push(str.charCodeAt(i) & 0xFF)
  8157. }
  8158. return byteArray
  8159. }
  8160. function utf16leToBytes (str, units) {
  8161. var c, hi, lo
  8162. var byteArray = []
  8163. for (var i = 0; i < str.length; ++i) {
  8164. if ((units -= 2) < 0) break
  8165. c = str.charCodeAt(i)
  8166. hi = c >> 8
  8167. lo = c % 256
  8168. byteArray.push(lo)
  8169. byteArray.push(hi)
  8170. }
  8171. return byteArray
  8172. }
  8173. function base64ToBytes (str) {
  8174. return base64.toByteArray(base64clean(str))
  8175. }
  8176. function blitBuffer (src, dst, offset, length) {
  8177. for (var i = 0; i < length; ++i) {
  8178. if ((i + offset >= dst.length) || (i >= src.length)) break
  8179. dst[i + offset] = src[i]
  8180. }
  8181. return i
  8182. }
  8183. function isnan (val) {
  8184. return val !== val // eslint-disable-line no-self-compare
  8185. }
  8186. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  8187. },{"base64-js":11,"ieee754":142,"isarray":145}],13:[function(_dereq_,module,exports){
  8188. 'use strict';
  8189. module.exports.parse = parse;
  8190. module.exports.generate = generate;
  8191. // TODO(jamestalmage): Allow full range of identifier characters instead of just ASCII
  8192. //
  8193. // This will likely require a build step
  8194. //
  8195. // SPEC: http://www.ecma-international.org/ecma-262/5.1/#sec-7.6
  8196. //
  8197. // TOOLING:
  8198. // https://github.com/mathiasbynens/regenerate
  8199. // https://www.npmjs.com/package/regjsgen
  8200. var regex = /^\s*(?:([A-Za-z$_][A-Za-z0-9$_]*)\s*\.)?\s*([A-Za-z$_][A-Za-z0-9$_]*)\s*\(\s*((?:[A-Za-z$_][A-Za-z0-9$_]*)|(?:\[\s*[A-Za-z$_][A-Za-z0-9$_]*\s*]))?((?:\s*,\s*(?:(?:[A-Za-z$_][A-Za-z0-9$_]*)|(?:\[\s*[A-Za-z$_][A-Za-z0-9$_]*\s*])))+)?\s*\)\s*$/;
  8201. function parse(str) {
  8202. var match = regex.exec(str);
  8203. if (!match) {
  8204. return null;
  8205. }
  8206. var callee;
  8207. if (match[1]) {
  8208. callee = {
  8209. type: 'MemberExpression',
  8210. object: match[1],
  8211. member: match[2]
  8212. };
  8213. } else {
  8214. callee = {
  8215. type: 'Identifier',
  8216. name: match[2]
  8217. };
  8218. }
  8219. var args = match[4] || '';
  8220. args = args.split(',');
  8221. if (match[3]) {
  8222. args[0] = match[3];
  8223. }
  8224. var trimmed = [];
  8225. args.forEach(function (str) {
  8226. var optional = false;
  8227. str = str.replace(/\s+/g, '');
  8228. if (!str.length) {
  8229. return;
  8230. }
  8231. if (str.charAt(0) === '[' && str.charAt(str.length - 1) === ']') {
  8232. optional = true;
  8233. str = str.substring(1, str.length - 1);
  8234. }
  8235. trimmed.push({
  8236. name: str,
  8237. optional: optional
  8238. });
  8239. });
  8240. return {
  8241. callee: callee,
  8242. args: trimmed
  8243. };
  8244. }
  8245. function generate(parsed) {
  8246. var callee;
  8247. if (parsed.callee.type === 'MemberExpression') {
  8248. callee = [
  8249. parsed.callee.object,
  8250. '.',
  8251. parsed.callee.member
  8252. ];
  8253. } else {
  8254. callee = [parsed.callee.name];
  8255. }
  8256. return callee.concat([
  8257. '(',
  8258. parsed.args.map(function (arg) {
  8259. return arg.optional ? '[' + arg.name + ']' : arg.name;
  8260. }).join(', '),
  8261. ')'
  8262. ]).join('');
  8263. }
  8264. },{}],14:[function(_dereq_,module,exports){
  8265. _dereq_('../../modules/es6.array.filter');
  8266. module.exports = _dereq_('../../modules/_core').Array.filter;
  8267. },{"../../modules/_core":43,"../../modules/es6.array.filter":102}],15:[function(_dereq_,module,exports){
  8268. _dereq_('../../modules/es6.array.for-each');
  8269. module.exports = _dereq_('../../modules/_core').Array.forEach;
  8270. },{"../../modules/_core":43,"../../modules/es6.array.for-each":103}],16:[function(_dereq_,module,exports){
  8271. _dereq_('../../modules/es6.array.index-of');
  8272. module.exports = _dereq_('../../modules/_core').Array.indexOf;
  8273. },{"../../modules/_core":43,"../../modules/es6.array.index-of":104}],17:[function(_dereq_,module,exports){
  8274. _dereq_('../../modules/es6.array.is-array');
  8275. module.exports = _dereq_('../../modules/_core').Array.isArray;
  8276. },{"../../modules/_core":43,"../../modules/es6.array.is-array":105}],18:[function(_dereq_,module,exports){
  8277. _dereq_('../../modules/es6.array.map');
  8278. module.exports = _dereq_('../../modules/_core').Array.map;
  8279. },{"../../modules/_core":43,"../../modules/es6.array.map":107}],19:[function(_dereq_,module,exports){
  8280. _dereq_('../../modules/es6.array.reduce-right');
  8281. module.exports = _dereq_('../../modules/_core').Array.reduceRight;
  8282. },{"../../modules/_core":43,"../../modules/es6.array.reduce-right":108}],20:[function(_dereq_,module,exports){
  8283. _dereq_('../../modules/es6.array.reduce');
  8284. module.exports = _dereq_('../../modules/_core').Array.reduce;
  8285. },{"../../modules/_core":43,"../../modules/es6.array.reduce":109}],21:[function(_dereq_,module,exports){
  8286. _dereq_('../../modules/es6.array.some');
  8287. module.exports = _dereq_('../../modules/_core').Array.some;
  8288. },{"../../modules/_core":43,"../../modules/es6.array.some":110}],22:[function(_dereq_,module,exports){
  8289. _dereq_('../modules/es6.object.to-string');
  8290. _dereq_('../modules/es6.string.iterator');
  8291. _dereq_('../modules/web.dom.iterable');
  8292. _dereq_('../modules/es6.map');
  8293. _dereq_('../modules/es7.map.to-json');
  8294. _dereq_('../modules/es7.map.of');
  8295. _dereq_('../modules/es7.map.from');
  8296. module.exports = _dereq_('../modules/_core').Map;
  8297. },{"../modules/_core":43,"../modules/es6.map":111,"../modules/es6.object.to-string":116,"../modules/es6.string.iterator":118,"../modules/es7.map.from":119,"../modules/es7.map.of":120,"../modules/es7.map.to-json":121,"../modules/web.dom.iterable":122}],23:[function(_dereq_,module,exports){
  8298. _dereq_('../../modules/es6.object.assign');
  8299. module.exports = _dereq_('../../modules/_core').Object.assign;
  8300. },{"../../modules/_core":43,"../../modules/es6.object.assign":112}],24:[function(_dereq_,module,exports){
  8301. _dereq_('../../modules/es6.object.create');
  8302. var $Object = _dereq_('../../modules/_core').Object;
  8303. module.exports = function create(P, D) {
  8304. return $Object.create(P, D);
  8305. };
  8306. },{"../../modules/_core":43,"../../modules/es6.object.create":113}],25:[function(_dereq_,module,exports){
  8307. _dereq_('../../modules/es6.object.define-property');
  8308. var $Object = _dereq_('../../modules/_core').Object;
  8309. module.exports = function defineProperty(it, key, desc) {
  8310. return $Object.defineProperty(it, key, desc);
  8311. };
  8312. },{"../../modules/_core":43,"../../modules/es6.object.define-property":114}],26:[function(_dereq_,module,exports){
  8313. _dereq_('../../modules/es6.object.keys');
  8314. module.exports = _dereq_('../../modules/_core').Object.keys;
  8315. },{"../../modules/_core":43,"../../modules/es6.object.keys":115}],27:[function(_dereq_,module,exports){
  8316. _dereq_('../../modules/es6.string.ends-with');
  8317. module.exports = _dereq_('../../modules/_core').String.endsWith;
  8318. },{"../../modules/_core":43,"../../modules/es6.string.ends-with":117}],28:[function(_dereq_,module,exports){
  8319. module.exports = function (it) {
  8320. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  8321. return it;
  8322. };
  8323. },{}],29:[function(_dereq_,module,exports){
  8324. module.exports = function () { /* empty */ };
  8325. },{}],30:[function(_dereq_,module,exports){
  8326. module.exports = function (it, Constructor, name, forbiddenField) {
  8327. if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
  8328. throw TypeError(name + ': incorrect invocation!');
  8329. } return it;
  8330. };
  8331. },{}],31:[function(_dereq_,module,exports){
  8332. var isObject = _dereq_('./_is-object');
  8333. module.exports = function (it) {
  8334. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  8335. return it;
  8336. };
  8337. },{"./_is-object":61}],32:[function(_dereq_,module,exports){
  8338. var forOf = _dereq_('./_for-of');
  8339. module.exports = function (iter, ITERATOR) {
  8340. var result = [];
  8341. forOf(iter, false, result.push, result, ITERATOR);
  8342. return result;
  8343. };
  8344. },{"./_for-of":52}],33:[function(_dereq_,module,exports){
  8345. // false -> Array#indexOf
  8346. // true -> Array#includes
  8347. var toIObject = _dereq_('./_to-iobject');
  8348. var toLength = _dereq_('./_to-length');
  8349. var toAbsoluteIndex = _dereq_('./_to-absolute-index');
  8350. module.exports = function (IS_INCLUDES) {
  8351. return function ($this, el, fromIndex) {
  8352. var O = toIObject($this);
  8353. var length = toLength(O.length);
  8354. var index = toAbsoluteIndex(fromIndex, length);
  8355. var value;
  8356. // Array#includes uses SameValueZero equality algorithm
  8357. // eslint-disable-next-line no-self-compare
  8358. if (IS_INCLUDES && el != el) while (length > index) {
  8359. value = O[index++];
  8360. // eslint-disable-next-line no-self-compare
  8361. if (value != value) return true;
  8362. // Array#indexOf ignores holes, Array#includes - not
  8363. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  8364. if (O[index] === el) return IS_INCLUDES || index || 0;
  8365. } return !IS_INCLUDES && -1;
  8366. };
  8367. };
  8368. },{"./_to-absolute-index":92,"./_to-iobject":94,"./_to-length":95}],34:[function(_dereq_,module,exports){
  8369. // 0 -> Array#forEach
  8370. // 1 -> Array#map
  8371. // 2 -> Array#filter
  8372. // 3 -> Array#some
  8373. // 4 -> Array#every
  8374. // 5 -> Array#find
  8375. // 6 -> Array#findIndex
  8376. var ctx = _dereq_('./_ctx');
  8377. var IObject = _dereq_('./_iobject');
  8378. var toObject = _dereq_('./_to-object');
  8379. var toLength = _dereq_('./_to-length');
  8380. var asc = _dereq_('./_array-species-create');
  8381. module.exports = function (TYPE, $create) {
  8382. var IS_MAP = TYPE == 1;
  8383. var IS_FILTER = TYPE == 2;
  8384. var IS_SOME = TYPE == 3;
  8385. var IS_EVERY = TYPE == 4;
  8386. var IS_FIND_INDEX = TYPE == 6;
  8387. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  8388. var create = $create || asc;
  8389. return function ($this, callbackfn, that) {
  8390. var O = toObject($this);
  8391. var self = IObject(O);
  8392. var f = ctx(callbackfn, that, 3);
  8393. var length = toLength(self.length);
  8394. var index = 0;
  8395. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  8396. var val, res;
  8397. for (;length > index; index++) if (NO_HOLES || index in self) {
  8398. val = self[index];
  8399. res = f(val, index, O);
  8400. if (TYPE) {
  8401. if (IS_MAP) result[index] = res; // map
  8402. else if (res) switch (TYPE) {
  8403. case 3: return true; // some
  8404. case 5: return val; // find
  8405. case 6: return index; // findIndex
  8406. case 2: result.push(val); // filter
  8407. } else if (IS_EVERY) return false; // every
  8408. }
  8409. }
  8410. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  8411. };
  8412. };
  8413. },{"./_array-species-create":37,"./_ctx":44,"./_iobject":58,"./_to-length":95,"./_to-object":96}],35:[function(_dereq_,module,exports){
  8414. var aFunction = _dereq_('./_a-function');
  8415. var toObject = _dereq_('./_to-object');
  8416. var IObject = _dereq_('./_iobject');
  8417. var toLength = _dereq_('./_to-length');
  8418. module.exports = function (that, callbackfn, aLen, memo, isRight) {
  8419. aFunction(callbackfn);
  8420. var O = toObject(that);
  8421. var self = IObject(O);
  8422. var length = toLength(O.length);
  8423. var index = isRight ? length - 1 : 0;
  8424. var i = isRight ? -1 : 1;
  8425. if (aLen < 2) for (;;) {
  8426. if (index in self) {
  8427. memo = self[index];
  8428. index += i;
  8429. break;
  8430. }
  8431. index += i;
  8432. if (isRight ? index < 0 : length <= index) {
  8433. throw TypeError('Reduce of empty array with no initial value');
  8434. }
  8435. }
  8436. for (;isRight ? index >= 0 : length > index; index += i) if (index in self) {
  8437. memo = callbackfn(memo, self[index], index, O);
  8438. }
  8439. return memo;
  8440. };
  8441. },{"./_a-function":28,"./_iobject":58,"./_to-length":95,"./_to-object":96}],36:[function(_dereq_,module,exports){
  8442. var isObject = _dereq_('./_is-object');
  8443. var isArray = _dereq_('./_is-array');
  8444. var SPECIES = _dereq_('./_wks')('species');
  8445. module.exports = function (original) {
  8446. var C;
  8447. if (isArray(original)) {
  8448. C = original.constructor;
  8449. // cross-realm fallback
  8450. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  8451. if (isObject(C)) {
  8452. C = C[SPECIES];
  8453. if (C === null) C = undefined;
  8454. }
  8455. } return C === undefined ? Array : C;
  8456. };
  8457. },{"./_is-array":60,"./_is-object":61,"./_wks":100}],37:[function(_dereq_,module,exports){
  8458. // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
  8459. var speciesConstructor = _dereq_('./_array-species-constructor');
  8460. module.exports = function (original, length) {
  8461. return new (speciesConstructor(original))(length);
  8462. };
  8463. },{"./_array-species-constructor":36}],38:[function(_dereq_,module,exports){
  8464. // getting tag from 19.1.3.6 Object.prototype.toString()
  8465. var cof = _dereq_('./_cof');
  8466. var TAG = _dereq_('./_wks')('toStringTag');
  8467. // ES3 wrong here
  8468. var ARG = cof(function () { return arguments; }()) == 'Arguments';
  8469. // fallback for IE11 Script Access Denied error
  8470. var tryGet = function (it, key) {
  8471. try {
  8472. return it[key];
  8473. } catch (e) { /* empty */ }
  8474. };
  8475. module.exports = function (it) {
  8476. var O, T, B;
  8477. return it === undefined ? 'Undefined' : it === null ? 'Null'
  8478. // @@toStringTag case
  8479. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  8480. // builtinTag case
  8481. : ARG ? cof(O)
  8482. // ES3 arguments fallback
  8483. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  8484. };
  8485. },{"./_cof":39,"./_wks":100}],39:[function(_dereq_,module,exports){
  8486. var toString = {}.toString;
  8487. module.exports = function (it) {
  8488. return toString.call(it).slice(8, -1);
  8489. };
  8490. },{}],40:[function(_dereq_,module,exports){
  8491. 'use strict';
  8492. var dP = _dereq_('./_object-dp').f;
  8493. var create = _dereq_('./_object-create');
  8494. var redefineAll = _dereq_('./_redefine-all');
  8495. var ctx = _dereq_('./_ctx');
  8496. var anInstance = _dereq_('./_an-instance');
  8497. var forOf = _dereq_('./_for-of');
  8498. var $iterDefine = _dereq_('./_iter-define');
  8499. var step = _dereq_('./_iter-step');
  8500. var setSpecies = _dereq_('./_set-species');
  8501. var DESCRIPTORS = _dereq_('./_descriptors');
  8502. var fastKey = _dereq_('./_meta').fastKey;
  8503. var validate = _dereq_('./_validate-collection');
  8504. var SIZE = DESCRIPTORS ? '_s' : 'size';
  8505. var getEntry = function (that, key) {
  8506. // fast case
  8507. var index = fastKey(key);
  8508. var entry;
  8509. if (index !== 'F') return that._i[index];
  8510. // frozen object case
  8511. for (entry = that._f; entry; entry = entry.n) {
  8512. if (entry.k == key) return entry;
  8513. }
  8514. };
  8515. module.exports = {
  8516. getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
  8517. var C = wrapper(function (that, iterable) {
  8518. anInstance(that, C, NAME, '_i');
  8519. that._t = NAME; // collection type
  8520. that._i = create(null); // index
  8521. that._f = undefined; // first entry
  8522. that._l = undefined; // last entry
  8523. that[SIZE] = 0; // size
  8524. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  8525. });
  8526. redefineAll(C.prototype, {
  8527. // 23.1.3.1 Map.prototype.clear()
  8528. // 23.2.3.2 Set.prototype.clear()
  8529. clear: function clear() {
  8530. for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
  8531. entry.r = true;
  8532. if (entry.p) entry.p = entry.p.n = undefined;
  8533. delete data[entry.i];
  8534. }
  8535. that._f = that._l = undefined;
  8536. that[SIZE] = 0;
  8537. },
  8538. // 23.1.3.3 Map.prototype.delete(key)
  8539. // 23.2.3.4 Set.prototype.delete(value)
  8540. 'delete': function (key) {
  8541. var that = validate(this, NAME);
  8542. var entry = getEntry(that, key);
  8543. if (entry) {
  8544. var next = entry.n;
  8545. var prev = entry.p;
  8546. delete that._i[entry.i];
  8547. entry.r = true;
  8548. if (prev) prev.n = next;
  8549. if (next) next.p = prev;
  8550. if (that._f == entry) that._f = next;
  8551. if (that._l == entry) that._l = prev;
  8552. that[SIZE]--;
  8553. } return !!entry;
  8554. },
  8555. // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
  8556. // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
  8557. forEach: function forEach(callbackfn /* , that = undefined */) {
  8558. validate(this, NAME);
  8559. var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
  8560. var entry;
  8561. while (entry = entry ? entry.n : this._f) {
  8562. f(entry.v, entry.k, this);
  8563. // revert to the last existing entry
  8564. while (entry && entry.r) entry = entry.p;
  8565. }
  8566. },
  8567. // 23.1.3.7 Map.prototype.has(key)
  8568. // 23.2.3.7 Set.prototype.has(value)
  8569. has: function has(key) {
  8570. return !!getEntry(validate(this, NAME), key);
  8571. }
  8572. });
  8573. if (DESCRIPTORS) dP(C.prototype, 'size', {
  8574. get: function () {
  8575. return validate(this, NAME)[SIZE];
  8576. }
  8577. });
  8578. return C;
  8579. },
  8580. def: function (that, key, value) {
  8581. var entry = getEntry(that, key);
  8582. var prev, index;
  8583. // change existing entry
  8584. if (entry) {
  8585. entry.v = value;
  8586. // create new entry
  8587. } else {
  8588. that._l = entry = {
  8589. i: index = fastKey(key, true), // <- index
  8590. k: key, // <- key
  8591. v: value, // <- value
  8592. p: prev = that._l, // <- previous entry
  8593. n: undefined, // <- next entry
  8594. r: false // <- removed
  8595. };
  8596. if (!that._f) that._f = entry;
  8597. if (prev) prev.n = entry;
  8598. that[SIZE]++;
  8599. // add to index
  8600. if (index !== 'F') that._i[index] = entry;
  8601. } return that;
  8602. },
  8603. getEntry: getEntry,
  8604. setStrong: function (C, NAME, IS_MAP) {
  8605. // add .keys, .values, .entries, [@@iterator]
  8606. // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
  8607. $iterDefine(C, NAME, function (iterated, kind) {
  8608. this._t = validate(iterated, NAME); // target
  8609. this._k = kind; // kind
  8610. this._l = undefined; // previous
  8611. }, function () {
  8612. var that = this;
  8613. var kind = that._k;
  8614. var entry = that._l;
  8615. // revert to the last existing entry
  8616. while (entry && entry.r) entry = entry.p;
  8617. // get next entry
  8618. if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
  8619. // or finish the iteration
  8620. that._t = undefined;
  8621. return step(1);
  8622. }
  8623. // return step by kind
  8624. if (kind == 'keys') return step(0, entry.k);
  8625. if (kind == 'values') return step(0, entry.v);
  8626. return step(0, [entry.k, entry.v]);
  8627. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  8628. // add [@@species], 23.1.2.2, 23.2.2.2
  8629. setSpecies(NAME);
  8630. }
  8631. };
  8632. },{"./_an-instance":30,"./_ctx":44,"./_descriptors":46,"./_for-of":52,"./_iter-define":65,"./_iter-step":66,"./_meta":69,"./_object-create":71,"./_object-dp":72,"./_redefine-all":81,"./_set-species":85,"./_validate-collection":99}],41:[function(_dereq_,module,exports){
  8633. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  8634. var classof = _dereq_('./_classof');
  8635. var from = _dereq_('./_array-from-iterable');
  8636. module.exports = function (NAME) {
  8637. return function toJSON() {
  8638. if (classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
  8639. return from(this);
  8640. };
  8641. };
  8642. },{"./_array-from-iterable":32,"./_classof":38}],42:[function(_dereq_,module,exports){
  8643. 'use strict';
  8644. var global = _dereq_('./_global');
  8645. var $export = _dereq_('./_export');
  8646. var meta = _dereq_('./_meta');
  8647. var fails = _dereq_('./_fails');
  8648. var hide = _dereq_('./_hide');
  8649. var redefineAll = _dereq_('./_redefine-all');
  8650. var forOf = _dereq_('./_for-of');
  8651. var anInstance = _dereq_('./_an-instance');
  8652. var isObject = _dereq_('./_is-object');
  8653. var setToStringTag = _dereq_('./_set-to-string-tag');
  8654. var dP = _dereq_('./_object-dp').f;
  8655. var each = _dereq_('./_array-methods')(0);
  8656. var DESCRIPTORS = _dereq_('./_descriptors');
  8657. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  8658. var Base = global[NAME];
  8659. var C = Base;
  8660. var ADDER = IS_MAP ? 'set' : 'add';
  8661. var proto = C && C.prototype;
  8662. var O = {};
  8663. if (!DESCRIPTORS || typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  8664. new C().entries().next();
  8665. }))) {
  8666. // create collection constructor
  8667. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  8668. redefineAll(C.prototype, methods);
  8669. meta.NEED = true;
  8670. } else {
  8671. C = wrapper(function (target, iterable) {
  8672. anInstance(target, C, NAME, '_c');
  8673. target._c = new Base();
  8674. if (iterable != undefined) forOf(iterable, IS_MAP, target[ADDER], target);
  8675. });
  8676. each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) {
  8677. var IS_ADDER = KEY == 'add' || KEY == 'set';
  8678. if (KEY in proto && !(IS_WEAK && KEY == 'clear')) hide(C.prototype, KEY, function (a, b) {
  8679. anInstance(this, C, KEY);
  8680. if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
  8681. var result = this._c[KEY](a === 0 ? 0 : a, b);
  8682. return IS_ADDER ? this : result;
  8683. });
  8684. });
  8685. IS_WEAK || dP(C.prototype, 'size', {
  8686. get: function () {
  8687. return this._c.size;
  8688. }
  8689. });
  8690. }
  8691. setToStringTag(C, NAME);
  8692. O[NAME] = C;
  8693. $export($export.G + $export.W + $export.F, O);
  8694. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  8695. return C;
  8696. };
  8697. },{"./_an-instance":30,"./_array-methods":34,"./_descriptors":46,"./_export":49,"./_fails":51,"./_for-of":52,"./_global":53,"./_hide":55,"./_is-object":61,"./_meta":69,"./_object-dp":72,"./_redefine-all":81,"./_set-to-string-tag":86}],43:[function(_dereq_,module,exports){
  8698. var core = module.exports = { version: '2.5.7' };
  8699. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  8700. },{}],44:[function(_dereq_,module,exports){
  8701. // optional / simple context binding
  8702. var aFunction = _dereq_('./_a-function');
  8703. module.exports = function (fn, that, length) {
  8704. aFunction(fn);
  8705. if (that === undefined) return fn;
  8706. switch (length) {
  8707. case 1: return function (a) {
  8708. return fn.call(that, a);
  8709. };
  8710. case 2: return function (a, b) {
  8711. return fn.call(that, a, b);
  8712. };
  8713. case 3: return function (a, b, c) {
  8714. return fn.call(that, a, b, c);
  8715. };
  8716. }
  8717. return function (/* ...args */) {
  8718. return fn.apply(that, arguments);
  8719. };
  8720. };
  8721. },{"./_a-function":28}],45:[function(_dereq_,module,exports){
  8722. // 7.2.1 RequireObjectCoercible(argument)
  8723. module.exports = function (it) {
  8724. if (it == undefined) throw TypeError("Can't call method on " + it);
  8725. return it;
  8726. };
  8727. },{}],46:[function(_dereq_,module,exports){
  8728. // Thank's IE8 for his funny defineProperty
  8729. module.exports = !_dereq_('./_fails')(function () {
  8730. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  8731. });
  8732. },{"./_fails":51}],47:[function(_dereq_,module,exports){
  8733. var isObject = _dereq_('./_is-object');
  8734. var document = _dereq_('./_global').document;
  8735. // typeof document.createElement is 'object' in old IE
  8736. var is = isObject(document) && isObject(document.createElement);
  8737. module.exports = function (it) {
  8738. return is ? document.createElement(it) : {};
  8739. };
  8740. },{"./_global":53,"./_is-object":61}],48:[function(_dereq_,module,exports){
  8741. // IE 8- don't enum bug keys
  8742. module.exports = (
  8743. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  8744. ).split(',');
  8745. },{}],49:[function(_dereq_,module,exports){
  8746. var global = _dereq_('./_global');
  8747. var core = _dereq_('./_core');
  8748. var ctx = _dereq_('./_ctx');
  8749. var hide = _dereq_('./_hide');
  8750. var has = _dereq_('./_has');
  8751. var PROTOTYPE = 'prototype';
  8752. var $export = function (type, name, source) {
  8753. var IS_FORCED = type & $export.F;
  8754. var IS_GLOBAL = type & $export.G;
  8755. var IS_STATIC = type & $export.S;
  8756. var IS_PROTO = type & $export.P;
  8757. var IS_BIND = type & $export.B;
  8758. var IS_WRAP = type & $export.W;
  8759. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  8760. var expProto = exports[PROTOTYPE];
  8761. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
  8762. var key, own, out;
  8763. if (IS_GLOBAL) source = name;
  8764. for (key in source) {
  8765. // contains in native
  8766. own = !IS_FORCED && target && target[key] !== undefined;
  8767. if (own && has(exports, key)) continue;
  8768. // export native or passed
  8769. out = own ? target[key] : source[key];
  8770. // prevent global pollution for namespaces
  8771. exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
  8772. // bind timers to global for call from export context
  8773. : IS_BIND && own ? ctx(out, global)
  8774. // wrap global constructors for prevent change them in library
  8775. : IS_WRAP && target[key] == out ? (function (C) {
  8776. var F = function (a, b, c) {
  8777. if (this instanceof C) {
  8778. switch (arguments.length) {
  8779. case 0: return new C();
  8780. case 1: return new C(a);
  8781. case 2: return new C(a, b);
  8782. } return new C(a, b, c);
  8783. } return C.apply(this, arguments);
  8784. };
  8785. F[PROTOTYPE] = C[PROTOTYPE];
  8786. return F;
  8787. // make static versions for prototype methods
  8788. })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  8789. // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
  8790. if (IS_PROTO) {
  8791. (exports.virtual || (exports.virtual = {}))[key] = out;
  8792. // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
  8793. if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
  8794. }
  8795. }
  8796. };
  8797. // type bitmap
  8798. $export.F = 1; // forced
  8799. $export.G = 2; // global
  8800. $export.S = 4; // static
  8801. $export.P = 8; // proto
  8802. $export.B = 16; // bind
  8803. $export.W = 32; // wrap
  8804. $export.U = 64; // safe
  8805. $export.R = 128; // real proto method for `library`
  8806. module.exports = $export;
  8807. },{"./_core":43,"./_ctx":44,"./_global":53,"./_has":54,"./_hide":55}],50:[function(_dereq_,module,exports){
  8808. var MATCH = _dereq_('./_wks')('match');
  8809. module.exports = function (KEY) {
  8810. var re = /./;
  8811. try {
  8812. '/./'[KEY](re);
  8813. } catch (e) {
  8814. try {
  8815. re[MATCH] = false;
  8816. return !'/./'[KEY](re);
  8817. } catch (f) { /* empty */ }
  8818. } return true;
  8819. };
  8820. },{"./_wks":100}],51:[function(_dereq_,module,exports){
  8821. module.exports = function (exec) {
  8822. try {
  8823. return !!exec();
  8824. } catch (e) {
  8825. return true;
  8826. }
  8827. };
  8828. },{}],52:[function(_dereq_,module,exports){
  8829. var ctx = _dereq_('./_ctx');
  8830. var call = _dereq_('./_iter-call');
  8831. var isArrayIter = _dereq_('./_is-array-iter');
  8832. var anObject = _dereq_('./_an-object');
  8833. var toLength = _dereq_('./_to-length');
  8834. var getIterFn = _dereq_('./core.get-iterator-method');
  8835. var BREAK = {};
  8836. var RETURN = {};
  8837. var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  8838. var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
  8839. var f = ctx(fn, that, entries ? 2 : 1);
  8840. var index = 0;
  8841. var length, step, iterator, result;
  8842. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  8843. // fast case for arrays with default iterator
  8844. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  8845. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  8846. if (result === BREAK || result === RETURN) return result;
  8847. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  8848. result = call(iterator, f, step.value, entries);
  8849. if (result === BREAK || result === RETURN) return result;
  8850. }
  8851. };
  8852. exports.BREAK = BREAK;
  8853. exports.RETURN = RETURN;
  8854. },{"./_an-object":31,"./_ctx":44,"./_is-array-iter":59,"./_iter-call":63,"./_to-length":95,"./core.get-iterator-method":101}],53:[function(_dereq_,module,exports){
  8855. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  8856. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  8857. ? window : typeof self != 'undefined' && self.Math == Math ? self
  8858. // eslint-disable-next-line no-new-func
  8859. : Function('return this')();
  8860. if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
  8861. },{}],54:[function(_dereq_,module,exports){
  8862. var hasOwnProperty = {}.hasOwnProperty;
  8863. module.exports = function (it, key) {
  8864. return hasOwnProperty.call(it, key);
  8865. };
  8866. },{}],55:[function(_dereq_,module,exports){
  8867. var dP = _dereq_('./_object-dp');
  8868. var createDesc = _dereq_('./_property-desc');
  8869. module.exports = _dereq_('./_descriptors') ? function (object, key, value) {
  8870. return dP.f(object, key, createDesc(1, value));
  8871. } : function (object, key, value) {
  8872. object[key] = value;
  8873. return object;
  8874. };
  8875. },{"./_descriptors":46,"./_object-dp":72,"./_property-desc":80}],56:[function(_dereq_,module,exports){
  8876. var document = _dereq_('./_global').document;
  8877. module.exports = document && document.documentElement;
  8878. },{"./_global":53}],57:[function(_dereq_,module,exports){
  8879. module.exports = !_dereq_('./_descriptors') && !_dereq_('./_fails')(function () {
  8880. return Object.defineProperty(_dereq_('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
  8881. });
  8882. },{"./_descriptors":46,"./_dom-create":47,"./_fails":51}],58:[function(_dereq_,module,exports){
  8883. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  8884. var cof = _dereq_('./_cof');
  8885. // eslint-disable-next-line no-prototype-builtins
  8886. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  8887. return cof(it) == 'String' ? it.split('') : Object(it);
  8888. };
  8889. },{"./_cof":39}],59:[function(_dereq_,module,exports){
  8890. // check on default Array iterator
  8891. var Iterators = _dereq_('./_iterators');
  8892. var ITERATOR = _dereq_('./_wks')('iterator');
  8893. var ArrayProto = Array.prototype;
  8894. module.exports = function (it) {
  8895. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  8896. };
  8897. },{"./_iterators":67,"./_wks":100}],60:[function(_dereq_,module,exports){
  8898. // 7.2.2 IsArray(argument)
  8899. var cof = _dereq_('./_cof');
  8900. module.exports = Array.isArray || function isArray(arg) {
  8901. return cof(arg) == 'Array';
  8902. };
  8903. },{"./_cof":39}],61:[function(_dereq_,module,exports){
  8904. module.exports = function (it) {
  8905. return typeof it === 'object' ? it !== null : typeof it === 'function';
  8906. };
  8907. },{}],62:[function(_dereq_,module,exports){
  8908. // 7.2.8 IsRegExp(argument)
  8909. var isObject = _dereq_('./_is-object');
  8910. var cof = _dereq_('./_cof');
  8911. var MATCH = _dereq_('./_wks')('match');
  8912. module.exports = function (it) {
  8913. var isRegExp;
  8914. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  8915. };
  8916. },{"./_cof":39,"./_is-object":61,"./_wks":100}],63:[function(_dereq_,module,exports){
  8917. // call something on iterator step with safe closing on error
  8918. var anObject = _dereq_('./_an-object');
  8919. module.exports = function (iterator, fn, value, entries) {
  8920. try {
  8921. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  8922. // 7.4.6 IteratorClose(iterator, completion)
  8923. } catch (e) {
  8924. var ret = iterator['return'];
  8925. if (ret !== undefined) anObject(ret.call(iterator));
  8926. throw e;
  8927. }
  8928. };
  8929. },{"./_an-object":31}],64:[function(_dereq_,module,exports){
  8930. 'use strict';
  8931. var create = _dereq_('./_object-create');
  8932. var descriptor = _dereq_('./_property-desc');
  8933. var setToStringTag = _dereq_('./_set-to-string-tag');
  8934. var IteratorPrototype = {};
  8935. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  8936. _dereq_('./_hide')(IteratorPrototype, _dereq_('./_wks')('iterator'), function () { return this; });
  8937. module.exports = function (Constructor, NAME, next) {
  8938. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  8939. setToStringTag(Constructor, NAME + ' Iterator');
  8940. };
  8941. },{"./_hide":55,"./_object-create":71,"./_property-desc":80,"./_set-to-string-tag":86,"./_wks":100}],65:[function(_dereq_,module,exports){
  8942. 'use strict';
  8943. var LIBRARY = _dereq_('./_library');
  8944. var $export = _dereq_('./_export');
  8945. var redefine = _dereq_('./_redefine');
  8946. var hide = _dereq_('./_hide');
  8947. var Iterators = _dereq_('./_iterators');
  8948. var $iterCreate = _dereq_('./_iter-create');
  8949. var setToStringTag = _dereq_('./_set-to-string-tag');
  8950. var getPrototypeOf = _dereq_('./_object-gpo');
  8951. var ITERATOR = _dereq_('./_wks')('iterator');
  8952. var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
  8953. var FF_ITERATOR = '@@iterator';
  8954. var KEYS = 'keys';
  8955. var VALUES = 'values';
  8956. var returnThis = function () { return this; };
  8957. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  8958. $iterCreate(Constructor, NAME, next);
  8959. var getMethod = function (kind) {
  8960. if (!BUGGY && kind in proto) return proto[kind];
  8961. switch (kind) {
  8962. case KEYS: return function keys() { return new Constructor(this, kind); };
  8963. case VALUES: return function values() { return new Constructor(this, kind); };
  8964. } return function entries() { return new Constructor(this, kind); };
  8965. };
  8966. var TAG = NAME + ' Iterator';
  8967. var DEF_VALUES = DEFAULT == VALUES;
  8968. var VALUES_BUG = false;
  8969. var proto = Base.prototype;
  8970. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  8971. var $default = $native || getMethod(DEFAULT);
  8972. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  8973. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  8974. var methods, key, IteratorPrototype;
  8975. // Fix native
  8976. if ($anyNative) {
  8977. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  8978. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  8979. // Set @@toStringTag to native iterators
  8980. setToStringTag(IteratorPrototype, TAG, true);
  8981. // fix for some old engines
  8982. if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
  8983. }
  8984. }
  8985. // fix Array#{values, @@iterator}.name in V8 / FF
  8986. if (DEF_VALUES && $native && $native.name !== VALUES) {
  8987. VALUES_BUG = true;
  8988. $default = function values() { return $native.call(this); };
  8989. }
  8990. // Define iterator
  8991. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  8992. hide(proto, ITERATOR, $default);
  8993. }
  8994. // Plug for library
  8995. Iterators[NAME] = $default;
  8996. Iterators[TAG] = returnThis;
  8997. if (DEFAULT) {
  8998. methods = {
  8999. values: DEF_VALUES ? $default : getMethod(VALUES),
  9000. keys: IS_SET ? $default : getMethod(KEYS),
  9001. entries: $entries
  9002. };
  9003. if (FORCED) for (key in methods) {
  9004. if (!(key in proto)) redefine(proto, key, methods[key]);
  9005. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  9006. }
  9007. return methods;
  9008. };
  9009. },{"./_export":49,"./_hide":55,"./_iter-create":64,"./_iterators":67,"./_library":68,"./_object-gpo":75,"./_redefine":82,"./_set-to-string-tag":86,"./_wks":100}],66:[function(_dereq_,module,exports){
  9010. module.exports = function (done, value) {
  9011. return { value: value, done: !!done };
  9012. };
  9013. },{}],67:[function(_dereq_,module,exports){
  9014. module.exports = {};
  9015. },{}],68:[function(_dereq_,module,exports){
  9016. module.exports = true;
  9017. },{}],69:[function(_dereq_,module,exports){
  9018. var META = _dereq_('./_uid')('meta');
  9019. var isObject = _dereq_('./_is-object');
  9020. var has = _dereq_('./_has');
  9021. var setDesc = _dereq_('./_object-dp').f;
  9022. var id = 0;
  9023. var isExtensible = Object.isExtensible || function () {
  9024. return true;
  9025. };
  9026. var FREEZE = !_dereq_('./_fails')(function () {
  9027. return isExtensible(Object.preventExtensions({}));
  9028. });
  9029. var setMeta = function (it) {
  9030. setDesc(it, META, { value: {
  9031. i: 'O' + ++id, // object ID
  9032. w: {} // weak collections IDs
  9033. } });
  9034. };
  9035. var fastKey = function (it, create) {
  9036. // return primitive with prefix
  9037. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  9038. if (!has(it, META)) {
  9039. // can't set metadata to uncaught frozen object
  9040. if (!isExtensible(it)) return 'F';
  9041. // not necessary to add metadata
  9042. if (!create) return 'E';
  9043. // add missing metadata
  9044. setMeta(it);
  9045. // return object ID
  9046. } return it[META].i;
  9047. };
  9048. var getWeak = function (it, create) {
  9049. if (!has(it, META)) {
  9050. // can't set metadata to uncaught frozen object
  9051. if (!isExtensible(it)) return true;
  9052. // not necessary to add metadata
  9053. if (!create) return false;
  9054. // add missing metadata
  9055. setMeta(it);
  9056. // return hash weak collections IDs
  9057. } return it[META].w;
  9058. };
  9059. // add metadata on freeze-family methods calling
  9060. var onFreeze = function (it) {
  9061. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  9062. return it;
  9063. };
  9064. var meta = module.exports = {
  9065. KEY: META,
  9066. NEED: false,
  9067. fastKey: fastKey,
  9068. getWeak: getWeak,
  9069. onFreeze: onFreeze
  9070. };
  9071. },{"./_fails":51,"./_has":54,"./_is-object":61,"./_object-dp":72,"./_uid":98}],70:[function(_dereq_,module,exports){
  9072. 'use strict';
  9073. // 19.1.2.1 Object.assign(target, source, ...)
  9074. var getKeys = _dereq_('./_object-keys');
  9075. var gOPS = _dereq_('./_object-gops');
  9076. var pIE = _dereq_('./_object-pie');
  9077. var toObject = _dereq_('./_to-object');
  9078. var IObject = _dereq_('./_iobject');
  9079. var $assign = Object.assign;
  9080. // should work with symbols and should have deterministic property order (V8 bug)
  9081. module.exports = !$assign || _dereq_('./_fails')(function () {
  9082. var A = {};
  9083. var B = {};
  9084. // eslint-disable-next-line no-undef
  9085. var S = Symbol();
  9086. var K = 'abcdefghijklmnopqrst';
  9087. A[S] = 7;
  9088. K.split('').forEach(function (k) { B[k] = k; });
  9089. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  9090. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  9091. var T = toObject(target);
  9092. var aLen = arguments.length;
  9093. var index = 1;
  9094. var getSymbols = gOPS.f;
  9095. var isEnum = pIE.f;
  9096. while (aLen > index) {
  9097. var S = IObject(arguments[index++]);
  9098. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  9099. var length = keys.length;
  9100. var j = 0;
  9101. var key;
  9102. while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  9103. } return T;
  9104. } : $assign;
  9105. },{"./_fails":51,"./_iobject":58,"./_object-gops":74,"./_object-keys":77,"./_object-pie":78,"./_to-object":96}],71:[function(_dereq_,module,exports){
  9106. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  9107. var anObject = _dereq_('./_an-object');
  9108. var dPs = _dereq_('./_object-dps');
  9109. var enumBugKeys = _dereq_('./_enum-bug-keys');
  9110. var IE_PROTO = _dereq_('./_shared-key')('IE_PROTO');
  9111. var Empty = function () { /* empty */ };
  9112. var PROTOTYPE = 'prototype';
  9113. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  9114. var createDict = function () {
  9115. // Thrash, waste and sodomy: IE GC bug
  9116. var iframe = _dereq_('./_dom-create')('iframe');
  9117. var i = enumBugKeys.length;
  9118. var lt = '<';
  9119. var gt = '>';
  9120. var iframeDocument;
  9121. iframe.style.display = 'none';
  9122. _dereq_('./_html').appendChild(iframe);
  9123. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  9124. // createDict = iframe.contentWindow.Object;
  9125. // html.removeChild(iframe);
  9126. iframeDocument = iframe.contentWindow.document;
  9127. iframeDocument.open();
  9128. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  9129. iframeDocument.close();
  9130. createDict = iframeDocument.F;
  9131. while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
  9132. return createDict();
  9133. };
  9134. module.exports = Object.create || function create(O, Properties) {
  9135. var result;
  9136. if (O !== null) {
  9137. Empty[PROTOTYPE] = anObject(O);
  9138. result = new Empty();
  9139. Empty[PROTOTYPE] = null;
  9140. // add "__proto__" for Object.getPrototypeOf polyfill
  9141. result[IE_PROTO] = O;
  9142. } else result = createDict();
  9143. return Properties === undefined ? result : dPs(result, Properties);
  9144. };
  9145. },{"./_an-object":31,"./_dom-create":47,"./_enum-bug-keys":48,"./_html":56,"./_object-dps":73,"./_shared-key":87}],72:[function(_dereq_,module,exports){
  9146. var anObject = _dereq_('./_an-object');
  9147. var IE8_DOM_DEFINE = _dereq_('./_ie8-dom-define');
  9148. var toPrimitive = _dereq_('./_to-primitive');
  9149. var dP = Object.defineProperty;
  9150. exports.f = _dereq_('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  9151. anObject(O);
  9152. P = toPrimitive(P, true);
  9153. anObject(Attributes);
  9154. if (IE8_DOM_DEFINE) try {
  9155. return dP(O, P, Attributes);
  9156. } catch (e) { /* empty */ }
  9157. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  9158. if ('value' in Attributes) O[P] = Attributes.value;
  9159. return O;
  9160. };
  9161. },{"./_an-object":31,"./_descriptors":46,"./_ie8-dom-define":57,"./_to-primitive":97}],73:[function(_dereq_,module,exports){
  9162. var dP = _dereq_('./_object-dp');
  9163. var anObject = _dereq_('./_an-object');
  9164. var getKeys = _dereq_('./_object-keys');
  9165. module.exports = _dereq_('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
  9166. anObject(O);
  9167. var keys = getKeys(Properties);
  9168. var length = keys.length;
  9169. var i = 0;
  9170. var P;
  9171. while (length > i) dP.f(O, P = keys[i++], Properties[P]);
  9172. return O;
  9173. };
  9174. },{"./_an-object":31,"./_descriptors":46,"./_object-dp":72,"./_object-keys":77}],74:[function(_dereq_,module,exports){
  9175. exports.f = Object.getOwnPropertySymbols;
  9176. },{}],75:[function(_dereq_,module,exports){
  9177. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  9178. var has = _dereq_('./_has');
  9179. var toObject = _dereq_('./_to-object');
  9180. var IE_PROTO = _dereq_('./_shared-key')('IE_PROTO');
  9181. var ObjectProto = Object.prototype;
  9182. module.exports = Object.getPrototypeOf || function (O) {
  9183. O = toObject(O);
  9184. if (has(O, IE_PROTO)) return O[IE_PROTO];
  9185. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  9186. return O.constructor.prototype;
  9187. } return O instanceof Object ? ObjectProto : null;
  9188. };
  9189. },{"./_has":54,"./_shared-key":87,"./_to-object":96}],76:[function(_dereq_,module,exports){
  9190. var has = _dereq_('./_has');
  9191. var toIObject = _dereq_('./_to-iobject');
  9192. var arrayIndexOf = _dereq_('./_array-includes')(false);
  9193. var IE_PROTO = _dereq_('./_shared-key')('IE_PROTO');
  9194. module.exports = function (object, names) {
  9195. var O = toIObject(object);
  9196. var i = 0;
  9197. var result = [];
  9198. var key;
  9199. for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
  9200. // Don't enum bug & hidden keys
  9201. while (names.length > i) if (has(O, key = names[i++])) {
  9202. ~arrayIndexOf(result, key) || result.push(key);
  9203. }
  9204. return result;
  9205. };
  9206. },{"./_array-includes":33,"./_has":54,"./_shared-key":87,"./_to-iobject":94}],77:[function(_dereq_,module,exports){
  9207. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  9208. var $keys = _dereq_('./_object-keys-internal');
  9209. var enumBugKeys = _dereq_('./_enum-bug-keys');
  9210. module.exports = Object.keys || function keys(O) {
  9211. return $keys(O, enumBugKeys);
  9212. };
  9213. },{"./_enum-bug-keys":48,"./_object-keys-internal":76}],78:[function(_dereq_,module,exports){
  9214. exports.f = {}.propertyIsEnumerable;
  9215. },{}],79:[function(_dereq_,module,exports){
  9216. // most Object methods by ES6 should accept primitives
  9217. var $export = _dereq_('./_export');
  9218. var core = _dereq_('./_core');
  9219. var fails = _dereq_('./_fails');
  9220. module.exports = function (KEY, exec) {
  9221. var fn = (core.Object || {})[KEY] || Object[KEY];
  9222. var exp = {};
  9223. exp[KEY] = exec(fn);
  9224. $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
  9225. };
  9226. },{"./_core":43,"./_export":49,"./_fails":51}],80:[function(_dereq_,module,exports){
  9227. module.exports = function (bitmap, value) {
  9228. return {
  9229. enumerable: !(bitmap & 1),
  9230. configurable: !(bitmap & 2),
  9231. writable: !(bitmap & 4),
  9232. value: value
  9233. };
  9234. };
  9235. },{}],81:[function(_dereq_,module,exports){
  9236. var hide = _dereq_('./_hide');
  9237. module.exports = function (target, src, safe) {
  9238. for (var key in src) {
  9239. if (safe && target[key]) target[key] = src[key];
  9240. else hide(target, key, src[key]);
  9241. } return target;
  9242. };
  9243. },{"./_hide":55}],82:[function(_dereq_,module,exports){
  9244. module.exports = _dereq_('./_hide');
  9245. },{"./_hide":55}],83:[function(_dereq_,module,exports){
  9246. 'use strict';
  9247. // https://tc39.github.io/proposal-setmap-offrom/
  9248. var $export = _dereq_('./_export');
  9249. var aFunction = _dereq_('./_a-function');
  9250. var ctx = _dereq_('./_ctx');
  9251. var forOf = _dereq_('./_for-of');
  9252. module.exports = function (COLLECTION) {
  9253. $export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
  9254. var mapFn = arguments[1];
  9255. var mapping, A, n, cb;
  9256. aFunction(this);
  9257. mapping = mapFn !== undefined;
  9258. if (mapping) aFunction(mapFn);
  9259. if (source == undefined) return new this();
  9260. A = [];
  9261. if (mapping) {
  9262. n = 0;
  9263. cb = ctx(mapFn, arguments[2], 2);
  9264. forOf(source, false, function (nextItem) {
  9265. A.push(cb(nextItem, n++));
  9266. });
  9267. } else {
  9268. forOf(source, false, A.push, A);
  9269. }
  9270. return new this(A);
  9271. } });
  9272. };
  9273. },{"./_a-function":28,"./_ctx":44,"./_export":49,"./_for-of":52}],84:[function(_dereq_,module,exports){
  9274. 'use strict';
  9275. // https://tc39.github.io/proposal-setmap-offrom/
  9276. var $export = _dereq_('./_export');
  9277. module.exports = function (COLLECTION) {
  9278. $export($export.S, COLLECTION, { of: function of() {
  9279. var length = arguments.length;
  9280. var A = new Array(length);
  9281. while (length--) A[length] = arguments[length];
  9282. return new this(A);
  9283. } });
  9284. };
  9285. },{"./_export":49}],85:[function(_dereq_,module,exports){
  9286. 'use strict';
  9287. var global = _dereq_('./_global');
  9288. var core = _dereq_('./_core');
  9289. var dP = _dereq_('./_object-dp');
  9290. var DESCRIPTORS = _dereq_('./_descriptors');
  9291. var SPECIES = _dereq_('./_wks')('species');
  9292. module.exports = function (KEY) {
  9293. var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
  9294. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  9295. configurable: true,
  9296. get: function () { return this; }
  9297. });
  9298. };
  9299. },{"./_core":43,"./_descriptors":46,"./_global":53,"./_object-dp":72,"./_wks":100}],86:[function(_dereq_,module,exports){
  9300. var def = _dereq_('./_object-dp').f;
  9301. var has = _dereq_('./_has');
  9302. var TAG = _dereq_('./_wks')('toStringTag');
  9303. module.exports = function (it, tag, stat) {
  9304. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
  9305. };
  9306. },{"./_has":54,"./_object-dp":72,"./_wks":100}],87:[function(_dereq_,module,exports){
  9307. var shared = _dereq_('./_shared')('keys');
  9308. var uid = _dereq_('./_uid');
  9309. module.exports = function (key) {
  9310. return shared[key] || (shared[key] = uid(key));
  9311. };
  9312. },{"./_shared":88,"./_uid":98}],88:[function(_dereq_,module,exports){
  9313. var core = _dereq_('./_core');
  9314. var global = _dereq_('./_global');
  9315. var SHARED = '__core-js_shared__';
  9316. var store = global[SHARED] || (global[SHARED] = {});
  9317. (module.exports = function (key, value) {
  9318. return store[key] || (store[key] = value !== undefined ? value : {});
  9319. })('versions', []).push({
  9320. version: core.version,
  9321. mode: _dereq_('./_library') ? 'pure' : 'global',
  9322. copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
  9323. });
  9324. },{"./_core":43,"./_global":53,"./_library":68}],89:[function(_dereq_,module,exports){
  9325. 'use strict';
  9326. var fails = _dereq_('./_fails');
  9327. module.exports = function (method, arg) {
  9328. return !!method && fails(function () {
  9329. // eslint-disable-next-line no-useless-call
  9330. arg ? method.call(null, function () { /* empty */ }, 1) : method.call(null);
  9331. });
  9332. };
  9333. },{"./_fails":51}],90:[function(_dereq_,module,exports){
  9334. var toInteger = _dereq_('./_to-integer');
  9335. var defined = _dereq_('./_defined');
  9336. // true -> String#at
  9337. // false -> String#codePointAt
  9338. module.exports = function (TO_STRING) {
  9339. return function (that, pos) {
  9340. var s = String(defined(that));
  9341. var i = toInteger(pos);
  9342. var l = s.length;
  9343. var a, b;
  9344. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  9345. a = s.charCodeAt(i);
  9346. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  9347. ? TO_STRING ? s.charAt(i) : a
  9348. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  9349. };
  9350. };
  9351. },{"./_defined":45,"./_to-integer":93}],91:[function(_dereq_,module,exports){
  9352. // helper for String#{startsWith, endsWith, includes}
  9353. var isRegExp = _dereq_('./_is-regexp');
  9354. var defined = _dereq_('./_defined');
  9355. module.exports = function (that, searchString, NAME) {
  9356. if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
  9357. return String(defined(that));
  9358. };
  9359. },{"./_defined":45,"./_is-regexp":62}],92:[function(_dereq_,module,exports){
  9360. var toInteger = _dereq_('./_to-integer');
  9361. var max = Math.max;
  9362. var min = Math.min;
  9363. module.exports = function (index, length) {
  9364. index = toInteger(index);
  9365. return index < 0 ? max(index + length, 0) : min(index, length);
  9366. };
  9367. },{"./_to-integer":93}],93:[function(_dereq_,module,exports){
  9368. // 7.1.4 ToInteger
  9369. var ceil = Math.ceil;
  9370. var floor = Math.floor;
  9371. module.exports = function (it) {
  9372. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  9373. };
  9374. },{}],94:[function(_dereq_,module,exports){
  9375. // to indexed object, toObject with fallback for non-array-like ES3 strings
  9376. var IObject = _dereq_('./_iobject');
  9377. var defined = _dereq_('./_defined');
  9378. module.exports = function (it) {
  9379. return IObject(defined(it));
  9380. };
  9381. },{"./_defined":45,"./_iobject":58}],95:[function(_dereq_,module,exports){
  9382. // 7.1.15 ToLength
  9383. var toInteger = _dereq_('./_to-integer');
  9384. var min = Math.min;
  9385. module.exports = function (it) {
  9386. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  9387. };
  9388. },{"./_to-integer":93}],96:[function(_dereq_,module,exports){
  9389. // 7.1.13 ToObject(argument)
  9390. var defined = _dereq_('./_defined');
  9391. module.exports = function (it) {
  9392. return Object(defined(it));
  9393. };
  9394. },{"./_defined":45}],97:[function(_dereq_,module,exports){
  9395. // 7.1.1 ToPrimitive(input [, PreferredType])
  9396. var isObject = _dereq_('./_is-object');
  9397. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  9398. // and the second argument - flag - preferred type is a string
  9399. module.exports = function (it, S) {
  9400. if (!isObject(it)) return it;
  9401. var fn, val;
  9402. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  9403. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  9404. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  9405. throw TypeError("Can't convert object to primitive value");
  9406. };
  9407. },{"./_is-object":61}],98:[function(_dereq_,module,exports){
  9408. var id = 0;
  9409. var px = Math.random();
  9410. module.exports = function (key) {
  9411. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  9412. };
  9413. },{}],99:[function(_dereq_,module,exports){
  9414. var isObject = _dereq_('./_is-object');
  9415. module.exports = function (it, TYPE) {
  9416. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  9417. return it;
  9418. };
  9419. },{"./_is-object":61}],100:[function(_dereq_,module,exports){
  9420. var store = _dereq_('./_shared')('wks');
  9421. var uid = _dereq_('./_uid');
  9422. var Symbol = _dereq_('./_global').Symbol;
  9423. var USE_SYMBOL = typeof Symbol == 'function';
  9424. var $exports = module.exports = function (name) {
  9425. return store[name] || (store[name] =
  9426. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  9427. };
  9428. $exports.store = store;
  9429. },{"./_global":53,"./_shared":88,"./_uid":98}],101:[function(_dereq_,module,exports){
  9430. var classof = _dereq_('./_classof');
  9431. var ITERATOR = _dereq_('./_wks')('iterator');
  9432. var Iterators = _dereq_('./_iterators');
  9433. module.exports = _dereq_('./_core').getIteratorMethod = function (it) {
  9434. if (it != undefined) return it[ITERATOR]
  9435. || it['@@iterator']
  9436. || Iterators[classof(it)];
  9437. };
  9438. },{"./_classof":38,"./_core":43,"./_iterators":67,"./_wks":100}],102:[function(_dereq_,module,exports){
  9439. 'use strict';
  9440. var $export = _dereq_('./_export');
  9441. var $filter = _dereq_('./_array-methods')(2);
  9442. $export($export.P + $export.F * !_dereq_('./_strict-method')([].filter, true), 'Array', {
  9443. // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
  9444. filter: function filter(callbackfn /* , thisArg */) {
  9445. return $filter(this, callbackfn, arguments[1]);
  9446. }
  9447. });
  9448. },{"./_array-methods":34,"./_export":49,"./_strict-method":89}],103:[function(_dereq_,module,exports){
  9449. 'use strict';
  9450. var $export = _dereq_('./_export');
  9451. var $forEach = _dereq_('./_array-methods')(0);
  9452. var STRICT = _dereq_('./_strict-method')([].forEach, true);
  9453. $export($export.P + $export.F * !STRICT, 'Array', {
  9454. // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
  9455. forEach: function forEach(callbackfn /* , thisArg */) {
  9456. return $forEach(this, callbackfn, arguments[1]);
  9457. }
  9458. });
  9459. },{"./_array-methods":34,"./_export":49,"./_strict-method":89}],104:[function(_dereq_,module,exports){
  9460. 'use strict';
  9461. var $export = _dereq_('./_export');
  9462. var $indexOf = _dereq_('./_array-includes')(false);
  9463. var $native = [].indexOf;
  9464. var NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0;
  9465. $export($export.P + $export.F * (NEGATIVE_ZERO || !_dereq_('./_strict-method')($native)), 'Array', {
  9466. // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
  9467. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  9468. return NEGATIVE_ZERO
  9469. // convert -0 to +0
  9470. ? $native.apply(this, arguments) || 0
  9471. : $indexOf(this, searchElement, arguments[1]);
  9472. }
  9473. });
  9474. },{"./_array-includes":33,"./_export":49,"./_strict-method":89}],105:[function(_dereq_,module,exports){
  9475. // 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
  9476. var $export = _dereq_('./_export');
  9477. $export($export.S, 'Array', { isArray: _dereq_('./_is-array') });
  9478. },{"./_export":49,"./_is-array":60}],106:[function(_dereq_,module,exports){
  9479. 'use strict';
  9480. var addToUnscopables = _dereq_('./_add-to-unscopables');
  9481. var step = _dereq_('./_iter-step');
  9482. var Iterators = _dereq_('./_iterators');
  9483. var toIObject = _dereq_('./_to-iobject');
  9484. // 22.1.3.4 Array.prototype.entries()
  9485. // 22.1.3.13 Array.prototype.keys()
  9486. // 22.1.3.29 Array.prototype.values()
  9487. // 22.1.3.30 Array.prototype[@@iterator]()
  9488. module.exports = _dereq_('./_iter-define')(Array, 'Array', function (iterated, kind) {
  9489. this._t = toIObject(iterated); // target
  9490. this._i = 0; // next index
  9491. this._k = kind; // kind
  9492. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  9493. }, function () {
  9494. var O = this._t;
  9495. var kind = this._k;
  9496. var index = this._i++;
  9497. if (!O || index >= O.length) {
  9498. this._t = undefined;
  9499. return step(1);
  9500. }
  9501. if (kind == 'keys') return step(0, index);
  9502. if (kind == 'values') return step(0, O[index]);
  9503. return step(0, [index, O[index]]);
  9504. }, 'values');
  9505. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  9506. Iterators.Arguments = Iterators.Array;
  9507. addToUnscopables('keys');
  9508. addToUnscopables('values');
  9509. addToUnscopables('entries');
  9510. },{"./_add-to-unscopables":29,"./_iter-define":65,"./_iter-step":66,"./_iterators":67,"./_to-iobject":94}],107:[function(_dereq_,module,exports){
  9511. 'use strict';
  9512. var $export = _dereq_('./_export');
  9513. var $map = _dereq_('./_array-methods')(1);
  9514. $export($export.P + $export.F * !_dereq_('./_strict-method')([].map, true), 'Array', {
  9515. // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
  9516. map: function map(callbackfn /* , thisArg */) {
  9517. return $map(this, callbackfn, arguments[1]);
  9518. }
  9519. });
  9520. },{"./_array-methods":34,"./_export":49,"./_strict-method":89}],108:[function(_dereq_,module,exports){
  9521. 'use strict';
  9522. var $export = _dereq_('./_export');
  9523. var $reduce = _dereq_('./_array-reduce');
  9524. $export($export.P + $export.F * !_dereq_('./_strict-method')([].reduceRight, true), 'Array', {
  9525. // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
  9526. reduceRight: function reduceRight(callbackfn /* , initialValue */) {
  9527. return $reduce(this, callbackfn, arguments.length, arguments[1], true);
  9528. }
  9529. });
  9530. },{"./_array-reduce":35,"./_export":49,"./_strict-method":89}],109:[function(_dereq_,module,exports){
  9531. 'use strict';
  9532. var $export = _dereq_('./_export');
  9533. var $reduce = _dereq_('./_array-reduce');
  9534. $export($export.P + $export.F * !_dereq_('./_strict-method')([].reduce, true), 'Array', {
  9535. // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
  9536. reduce: function reduce(callbackfn /* , initialValue */) {
  9537. return $reduce(this, callbackfn, arguments.length, arguments[1], false);
  9538. }
  9539. });
  9540. },{"./_array-reduce":35,"./_export":49,"./_strict-method":89}],110:[function(_dereq_,module,exports){
  9541. 'use strict';
  9542. var $export = _dereq_('./_export');
  9543. var $some = _dereq_('./_array-methods')(3);
  9544. $export($export.P + $export.F * !_dereq_('./_strict-method')([].some, true), 'Array', {
  9545. // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
  9546. some: function some(callbackfn /* , thisArg */) {
  9547. return $some(this, callbackfn, arguments[1]);
  9548. }
  9549. });
  9550. },{"./_array-methods":34,"./_export":49,"./_strict-method":89}],111:[function(_dereq_,module,exports){
  9551. 'use strict';
  9552. var strong = _dereq_('./_collection-strong');
  9553. var validate = _dereq_('./_validate-collection');
  9554. var MAP = 'Map';
  9555. // 23.1 Map Objects
  9556. module.exports = _dereq_('./_collection')(MAP, function (get) {
  9557. return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  9558. }, {
  9559. // 23.1.3.6 Map.prototype.get(key)
  9560. get: function get(key) {
  9561. var entry = strong.getEntry(validate(this, MAP), key);
  9562. return entry && entry.v;
  9563. },
  9564. // 23.1.3.9 Map.prototype.set(key, value)
  9565. set: function set(key, value) {
  9566. return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);
  9567. }
  9568. }, strong, true);
  9569. },{"./_collection":42,"./_collection-strong":40,"./_validate-collection":99}],112:[function(_dereq_,module,exports){
  9570. // 19.1.3.1 Object.assign(target, source)
  9571. var $export = _dereq_('./_export');
  9572. $export($export.S + $export.F, 'Object', { assign: _dereq_('./_object-assign') });
  9573. },{"./_export":49,"./_object-assign":70}],113:[function(_dereq_,module,exports){
  9574. var $export = _dereq_('./_export');
  9575. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  9576. $export($export.S, 'Object', { create: _dereq_('./_object-create') });
  9577. },{"./_export":49,"./_object-create":71}],114:[function(_dereq_,module,exports){
  9578. var $export = _dereq_('./_export');
  9579. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  9580. $export($export.S + $export.F * !_dereq_('./_descriptors'), 'Object', { defineProperty: _dereq_('./_object-dp').f });
  9581. },{"./_descriptors":46,"./_export":49,"./_object-dp":72}],115:[function(_dereq_,module,exports){
  9582. // 19.1.2.14 Object.keys(O)
  9583. var toObject = _dereq_('./_to-object');
  9584. var $keys = _dereq_('./_object-keys');
  9585. _dereq_('./_object-sap')('keys', function () {
  9586. return function keys(it) {
  9587. return $keys(toObject(it));
  9588. };
  9589. });
  9590. },{"./_object-keys":77,"./_object-sap":79,"./_to-object":96}],116:[function(_dereq_,module,exports){
  9591. },{}],117:[function(_dereq_,module,exports){
  9592. // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
  9593. 'use strict';
  9594. var $export = _dereq_('./_export');
  9595. var toLength = _dereq_('./_to-length');
  9596. var context = _dereq_('./_string-context');
  9597. var ENDS_WITH = 'endsWith';
  9598. var $endsWith = ''[ENDS_WITH];
  9599. $export($export.P + $export.F * _dereq_('./_fails-is-regexp')(ENDS_WITH), 'String', {
  9600. endsWith: function endsWith(searchString /* , endPosition = @length */) {
  9601. var that = context(this, searchString, ENDS_WITH);
  9602. var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  9603. var len = toLength(that.length);
  9604. var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
  9605. var search = String(searchString);
  9606. return $endsWith
  9607. ? $endsWith.call(that, search, end)
  9608. : that.slice(end - search.length, end) === search;
  9609. }
  9610. });
  9611. },{"./_export":49,"./_fails-is-regexp":50,"./_string-context":91,"./_to-length":95}],118:[function(_dereq_,module,exports){
  9612. 'use strict';
  9613. var $at = _dereq_('./_string-at')(true);
  9614. // 21.1.3.27 String.prototype[@@iterator]()
  9615. _dereq_('./_iter-define')(String, 'String', function (iterated) {
  9616. this._t = String(iterated); // target
  9617. this._i = 0; // next index
  9618. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  9619. }, function () {
  9620. var O = this._t;
  9621. var index = this._i;
  9622. var point;
  9623. if (index >= O.length) return { value: undefined, done: true };
  9624. point = $at(O, index);
  9625. this._i += point.length;
  9626. return { value: point, done: false };
  9627. });
  9628. },{"./_iter-define":65,"./_string-at":90}],119:[function(_dereq_,module,exports){
  9629. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
  9630. _dereq_('./_set-collection-from')('Map');
  9631. },{"./_set-collection-from":83}],120:[function(_dereq_,module,exports){
  9632. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
  9633. _dereq_('./_set-collection-of')('Map');
  9634. },{"./_set-collection-of":84}],121:[function(_dereq_,module,exports){
  9635. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  9636. var $export = _dereq_('./_export');
  9637. $export($export.P + $export.R, 'Map', { toJSON: _dereq_('./_collection-to-json')('Map') });
  9638. },{"./_collection-to-json":41,"./_export":49}],122:[function(_dereq_,module,exports){
  9639. _dereq_('./es6.array.iterator');
  9640. var global = _dereq_('./_global');
  9641. var hide = _dereq_('./_hide');
  9642. var Iterators = _dereq_('./_iterators');
  9643. var TO_STRING_TAG = _dereq_('./_wks')('toStringTag');
  9644. var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
  9645. 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
  9646. 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
  9647. 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
  9648. 'TextTrackList,TouchList').split(',');
  9649. for (var i = 0; i < DOMIterables.length; i++) {
  9650. var NAME = DOMIterables[i];
  9651. var Collection = global[NAME];
  9652. var proto = Collection && Collection.prototype;
  9653. if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  9654. Iterators[NAME] = Iterators.Array;
  9655. }
  9656. },{"./_global":53,"./_hide":55,"./_iterators":67,"./_wks":100,"./es6.array.iterator":106}],123:[function(_dereq_,module,exports){
  9657. 'use strict';
  9658. var keys = _dereq_('object-keys');
  9659. var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
  9660. var toStr = Object.prototype.toString;
  9661. var concat = Array.prototype.concat;
  9662. var origDefineProperty = Object.defineProperty;
  9663. var isFunction = function (fn) {
  9664. return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
  9665. };
  9666. var arePropertyDescriptorsSupported = function () {
  9667. var obj = {};
  9668. try {
  9669. origDefineProperty(obj, 'x', { enumerable: false, value: obj });
  9670. // eslint-disable-next-line no-unused-vars, no-restricted-syntax
  9671. for (var _ in obj) { // jscs:ignore disallowUnusedVariables
  9672. return false;
  9673. }
  9674. return obj.x === obj;
  9675. } catch (e) { /* this is IE 8. */
  9676. return false;
  9677. }
  9678. };
  9679. var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
  9680. var defineProperty = function (object, name, value, predicate) {
  9681. if (name in object && (!isFunction(predicate) || !predicate())) {
  9682. return;
  9683. }
  9684. if (supportsDescriptors) {
  9685. origDefineProperty(object, name, {
  9686. configurable: true,
  9687. enumerable: false,
  9688. value: value,
  9689. writable: true
  9690. });
  9691. } else {
  9692. object[name] = value;
  9693. }
  9694. };
  9695. var defineProperties = function (object, map) {
  9696. var predicates = arguments.length > 2 ? arguments[2] : {};
  9697. var props = keys(map);
  9698. if (hasSymbols) {
  9699. props = concat.call(props, Object.getOwnPropertySymbols(map));
  9700. }
  9701. for (var i = 0; i < props.length; i += 1) {
  9702. defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
  9703. }
  9704. };
  9705. defineProperties.supportsDescriptors = !!supportsDescriptors;
  9706. module.exports = defineProperties;
  9707. },{"object-keys":146}],124:[function(_dereq_,module,exports){
  9708. /**
  9709. * Diff Match and Patch
  9710. * Copyright 2018 The diff-match-patch Authors.
  9711. * https://github.com/google/diff-match-patch
  9712. *
  9713. * Licensed under the Apache License, Version 2.0 (the "License");
  9714. * you may not use this file except in compliance with the License.
  9715. * You may obtain a copy of the License at
  9716. *
  9717. * http://www.apache.org/licenses/LICENSE-2.0
  9718. *
  9719. * Unless required by applicable law or agreed to in writing, software
  9720. * distributed under the License is distributed on an "AS IS" BASIS,
  9721. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9722. * See the License for the specific language governing permissions and
  9723. * limitations under the License.
  9724. */
  9725. /**
  9726. * @fileoverview Computes the difference between two texts to create a patch.
  9727. * Applies the patch onto another text, allowing for errors.
  9728. * @author fraser@google.com (Neil Fraser)
  9729. */
  9730. /**
  9731. * Class containing the diff, match and patch methods.
  9732. * @constructor
  9733. */
  9734. function diff_match_patch() {
  9735. // Defaults.
  9736. // Redefine these in your program to override the defaults.
  9737. // Number of seconds to map a diff before giving up (0 for infinity).
  9738. this.Diff_Timeout = 1.0;
  9739. // Cost of an empty edit operation in terms of edit characters.
  9740. this.Diff_EditCost = 4;
  9741. // At what point is no match declared (0.0 = perfection, 1.0 = very loose).
  9742. this.Match_Threshold = 0.5;
  9743. // How far to search for a match (0 = exact location, 1000+ = broad match).
  9744. // A match this many characters away from the expected location will add
  9745. // 1.0 to the score (0.0 is a perfect match).
  9746. this.Match_Distance = 1000;
  9747. // When deleting a large block of text (over ~64 characters), how close do
  9748. // the contents have to be to match the expected contents. (0.0 = perfection,
  9749. // 1.0 = very loose). Note that Match_Threshold controls how closely the
  9750. // end points of a delete need to match.
  9751. this.Patch_DeleteThreshold = 0.5;
  9752. // Chunk size for context length.
  9753. this.Patch_Margin = 4;
  9754. // The number of bits in an int.
  9755. this.Match_MaxBits = 32;
  9756. }
  9757. // DIFF FUNCTIONS
  9758. /**
  9759. * The data structure representing a diff is an array of tuples:
  9760. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  9761. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  9762. */
  9763. var DIFF_DELETE = -1;
  9764. var DIFF_INSERT = 1;
  9765. var DIFF_EQUAL = 0;
  9766. /** @typedef {{0: number, 1: string}} */
  9767. diff_match_patch.Diff;
  9768. /**
  9769. * Find the differences between two texts. Simplifies the problem by stripping
  9770. * any common prefix or suffix off the texts before diffing.
  9771. * @param {string} text1 Old string to be diffed.
  9772. * @param {string} text2 New string to be diffed.
  9773. * @param {boolean=} opt_checklines Optional speedup flag. If present and false,
  9774. * then don't run a line-level diff first to identify the changed areas.
  9775. * Defaults to true, which does a faster, slightly less optimal diff.
  9776. * @param {number} opt_deadline Optional time when the diff should be complete
  9777. * by. Used internally for recursive calls. Users should set DiffTimeout
  9778. * instead.
  9779. * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
  9780. */
  9781. diff_match_patch.prototype.diff_main = function(text1, text2, opt_checklines,
  9782. opt_deadline) {
  9783. // Set a deadline by which time the diff must be complete.
  9784. if (typeof opt_deadline == 'undefined') {
  9785. if (this.Diff_Timeout <= 0) {
  9786. opt_deadline = Number.MAX_VALUE;
  9787. } else {
  9788. opt_deadline = (new Date).getTime() + this.Diff_Timeout * 1000;
  9789. }
  9790. }
  9791. var deadline = opt_deadline;
  9792. // Check for null inputs.
  9793. if (text1 == null || text2 == null) {
  9794. throw new Error('Null input. (diff_main)');
  9795. }
  9796. // Check for equality (speedup).
  9797. if (text1 == text2) {
  9798. if (text1) {
  9799. return [[DIFF_EQUAL, text1]];
  9800. }
  9801. return [];
  9802. }
  9803. if (typeof opt_checklines == 'undefined') {
  9804. opt_checklines = true;
  9805. }
  9806. var checklines = opt_checklines;
  9807. // Trim off common prefix (speedup).
  9808. var commonlength = this.diff_commonPrefix(text1, text2);
  9809. var commonprefix = text1.substring(0, commonlength);
  9810. text1 = text1.substring(commonlength);
  9811. text2 = text2.substring(commonlength);
  9812. // Trim off common suffix (speedup).
  9813. commonlength = this.diff_commonSuffix(text1, text2);
  9814. var commonsuffix = text1.substring(text1.length - commonlength);
  9815. text1 = text1.substring(0, text1.length - commonlength);
  9816. text2 = text2.substring(0, text2.length - commonlength);
  9817. // Compute the diff on the middle block.
  9818. var diffs = this.diff_compute_(text1, text2, checklines, deadline);
  9819. // Restore the prefix and suffix.
  9820. if (commonprefix) {
  9821. diffs.unshift([DIFF_EQUAL, commonprefix]);
  9822. }
  9823. if (commonsuffix) {
  9824. diffs.push([DIFF_EQUAL, commonsuffix]);
  9825. }
  9826. this.diff_cleanupMerge(diffs);
  9827. return diffs;
  9828. };
  9829. /**
  9830. * Find the differences between two texts. Assumes that the texts do not
  9831. * have any common prefix or suffix.
  9832. * @param {string} text1 Old string to be diffed.
  9833. * @param {string} text2 New string to be diffed.
  9834. * @param {boolean} checklines Speedup flag. If false, then don't run a
  9835. * line-level diff first to identify the changed areas.
  9836. * If true, then run a faster, slightly less optimal diff.
  9837. * @param {number} deadline Time when the diff should be complete by.
  9838. * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
  9839. * @private
  9840. */
  9841. diff_match_patch.prototype.diff_compute_ = function(text1, text2, checklines,
  9842. deadline) {
  9843. var diffs;
  9844. if (!text1) {
  9845. // Just add some text (speedup).
  9846. return [[DIFF_INSERT, text2]];
  9847. }
  9848. if (!text2) {
  9849. // Just delete some text (speedup).
  9850. return [[DIFF_DELETE, text1]];
  9851. }
  9852. var longtext = text1.length > text2.length ? text1 : text2;
  9853. var shorttext = text1.length > text2.length ? text2 : text1;
  9854. var i = longtext.indexOf(shorttext);
  9855. if (i != -1) {
  9856. // Shorter text is inside the longer text (speedup).
  9857. diffs = [[DIFF_INSERT, longtext.substring(0, i)],
  9858. [DIFF_EQUAL, shorttext],
  9859. [DIFF_INSERT, longtext.substring(i + shorttext.length)]];
  9860. // Swap insertions for deletions if diff is reversed.
  9861. if (text1.length > text2.length) {
  9862. diffs[0][0] = diffs[2][0] = DIFF_DELETE;
  9863. }
  9864. return diffs;
  9865. }
  9866. if (shorttext.length == 1) {
  9867. // Single character string.
  9868. // After the previous speedup, the character can't be an equality.
  9869. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  9870. }
  9871. // Check to see if the problem can be split in two.
  9872. var hm = this.diff_halfMatch_(text1, text2);
  9873. if (hm) {
  9874. // A half-match was found, sort out the return data.
  9875. var text1_a = hm[0];
  9876. var text1_b = hm[1];
  9877. var text2_a = hm[2];
  9878. var text2_b = hm[3];
  9879. var mid_common = hm[4];
  9880. // Send both pairs off for separate processing.
  9881. var diffs_a = this.diff_main(text1_a, text2_a, checklines, deadline);
  9882. var diffs_b = this.diff_main(text1_b, text2_b, checklines, deadline);
  9883. // Merge the results.
  9884. return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
  9885. }
  9886. if (checklines && text1.length > 100 && text2.length > 100) {
  9887. return this.diff_lineMode_(text1, text2, deadline);
  9888. }
  9889. return this.diff_bisect_(text1, text2, deadline);
  9890. };
  9891. /**
  9892. * Do a quick line-level diff on both strings, then rediff the parts for
  9893. * greater accuracy.
  9894. * This speedup can produce non-minimal diffs.
  9895. * @param {string} text1 Old string to be diffed.
  9896. * @param {string} text2 New string to be diffed.
  9897. * @param {number} deadline Time when the diff should be complete by.
  9898. * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
  9899. * @private
  9900. */
  9901. diff_match_patch.prototype.diff_lineMode_ = function(text1, text2, deadline) {
  9902. // Scan the text on a line-by-line basis first.
  9903. var a = this.diff_linesToChars_(text1, text2);
  9904. text1 = a.chars1;
  9905. text2 = a.chars2;
  9906. var linearray = a.lineArray;
  9907. var diffs = this.diff_main(text1, text2, false, deadline);
  9908. // Convert the diff back to original text.
  9909. this.diff_charsToLines_(diffs, linearray);
  9910. // Eliminate freak matches (e.g. blank lines)
  9911. this.diff_cleanupSemantic(diffs);
  9912. // Rediff any replacement blocks, this time character-by-character.
  9913. // Add a dummy entry at the end.
  9914. diffs.push([DIFF_EQUAL, '']);
  9915. var pointer = 0;
  9916. var count_delete = 0;
  9917. var count_insert = 0;
  9918. var text_delete = '';
  9919. var text_insert = '';
  9920. while (pointer < diffs.length) {
  9921. switch (diffs[pointer][0]) {
  9922. case DIFF_INSERT:
  9923. count_insert++;
  9924. text_insert += diffs[pointer][1];
  9925. break;
  9926. case DIFF_DELETE:
  9927. count_delete++;
  9928. text_delete += diffs[pointer][1];
  9929. break;
  9930. case DIFF_EQUAL:
  9931. // Upon reaching an equality, check for prior redundancies.
  9932. if (count_delete >= 1 && count_insert >= 1) {
  9933. // Delete the offending records and add the merged ones.
  9934. diffs.splice(pointer - count_delete - count_insert,
  9935. count_delete + count_insert);
  9936. pointer = pointer - count_delete - count_insert;
  9937. var a = this.diff_main(text_delete, text_insert, false, deadline);
  9938. for (var j = a.length - 1; j >= 0; j--) {
  9939. diffs.splice(pointer, 0, a[j]);
  9940. }
  9941. pointer = pointer + a.length;
  9942. }
  9943. count_insert = 0;
  9944. count_delete = 0;
  9945. text_delete = '';
  9946. text_insert = '';
  9947. break;
  9948. }
  9949. pointer++;
  9950. }
  9951. diffs.pop(); // Remove the dummy entry at the end.
  9952. return diffs;
  9953. };
  9954. /**
  9955. * Find the 'middle snake' of a diff, split the problem in two
  9956. * and return the recursively constructed diff.
  9957. * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
  9958. * @param {string} text1 Old string to be diffed.
  9959. * @param {string} text2 New string to be diffed.
  9960. * @param {number} deadline Time at which to bail if not yet complete.
  9961. * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
  9962. * @private
  9963. */
  9964. diff_match_patch.prototype.diff_bisect_ = function(text1, text2, deadline) {
  9965. // Cache the text lengths to prevent multiple calls.
  9966. var text1_length = text1.length;
  9967. var text2_length = text2.length;
  9968. var max_d = Math.ceil((text1_length + text2_length) / 2);
  9969. var v_offset = max_d;
  9970. var v_length = 2 * max_d;
  9971. var v1 = new Array(v_length);
  9972. var v2 = new Array(v_length);
  9973. // Setting all elements to -1 is faster in Chrome & Firefox than mixing
  9974. // integers and undefined.
  9975. for (var x = 0; x < v_length; x++) {
  9976. v1[x] = -1;
  9977. v2[x] = -1;
  9978. }
  9979. v1[v_offset + 1] = 0;
  9980. v2[v_offset + 1] = 0;
  9981. var delta = text1_length - text2_length;
  9982. // If the total number of characters is odd, then the front path will collide
  9983. // with the reverse path.
  9984. var front = (delta % 2 != 0);
  9985. // Offsets for start and end of k loop.
  9986. // Prevents mapping of space beyond the grid.
  9987. var k1start = 0;
  9988. var k1end = 0;
  9989. var k2start = 0;
  9990. var k2end = 0;
  9991. for (var d = 0; d < max_d; d++) {
  9992. // Bail out if deadline is reached.
  9993. if ((new Date()).getTime() > deadline) {
  9994. break;
  9995. }
  9996. // Walk the front path one step.
  9997. for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
  9998. var k1_offset = v_offset + k1;
  9999. var x1;
  10000. if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
  10001. x1 = v1[k1_offset + 1];
  10002. } else {
  10003. x1 = v1[k1_offset - 1] + 1;
  10004. }
  10005. var y1 = x1 - k1;
  10006. while (x1 < text1_length && y1 < text2_length &&
  10007. text1.charAt(x1) == text2.charAt(y1)) {
  10008. x1++;
  10009. y1++;
  10010. }
  10011. v1[k1_offset] = x1;
  10012. if (x1 > text1_length) {
  10013. // Ran off the right of the graph.
  10014. k1end += 2;
  10015. } else if (y1 > text2_length) {
  10016. // Ran off the bottom of the graph.
  10017. k1start += 2;
  10018. } else if (front) {
  10019. var k2_offset = v_offset + delta - k1;
  10020. if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
  10021. // Mirror x2 onto top-left coordinate system.
  10022. var x2 = text1_length - v2[k2_offset];
  10023. if (x1 >= x2) {
  10024. // Overlap detected.
  10025. return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
  10026. }
  10027. }
  10028. }
  10029. }
  10030. // Walk the reverse path one step.
  10031. for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
  10032. var k2_offset = v_offset + k2;
  10033. var x2;
  10034. if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
  10035. x2 = v2[k2_offset + 1];
  10036. } else {
  10037. x2 = v2[k2_offset - 1] + 1;
  10038. }
  10039. var y2 = x2 - k2;
  10040. while (x2 < text1_length && y2 < text2_length &&
  10041. text1.charAt(text1_length - x2 - 1) ==
  10042. text2.charAt(text2_length - y2 - 1)) {
  10043. x2++;
  10044. y2++;
  10045. }
  10046. v2[k2_offset] = x2;
  10047. if (x2 > text1_length) {
  10048. // Ran off the left of the graph.
  10049. k2end += 2;
  10050. } else if (y2 > text2_length) {
  10051. // Ran off the top of the graph.
  10052. k2start += 2;
  10053. } else if (!front) {
  10054. var k1_offset = v_offset + delta - k2;
  10055. if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
  10056. var x1 = v1[k1_offset];
  10057. var y1 = v_offset + x1 - k1_offset;
  10058. // Mirror x2 onto top-left coordinate system.
  10059. x2 = text1_length - x2;
  10060. if (x1 >= x2) {
  10061. // Overlap detected.
  10062. return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
  10063. }
  10064. }
  10065. }
  10066. }
  10067. }
  10068. // Diff took too long and hit the deadline or
  10069. // number of diffs equals number of characters, no commonality at all.
  10070. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  10071. };
  10072. /**
  10073. * Given the location of the 'middle snake', split the diff in two parts
  10074. * and recurse.
  10075. * @param {string} text1 Old string to be diffed.
  10076. * @param {string} text2 New string to be diffed.
  10077. * @param {number} x Index of split point in text1.
  10078. * @param {number} y Index of split point in text2.
  10079. * @param {number} deadline Time at which to bail if not yet complete.
  10080. * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
  10081. * @private
  10082. */
  10083. diff_match_patch.prototype.diff_bisectSplit_ = function(text1, text2, x, y,
  10084. deadline) {
  10085. var text1a = text1.substring(0, x);
  10086. var text2a = text2.substring(0, y);
  10087. var text1b = text1.substring(x);
  10088. var text2b = text2.substring(y);
  10089. // Compute both diffs serially.
  10090. var diffs = this.diff_main(text1a, text2a, false, deadline);
  10091. var diffsb = this.diff_main(text1b, text2b, false, deadline);
  10092. return diffs.concat(diffsb);
  10093. };
  10094. /**
  10095. * Split two texts into an array of strings. Reduce the texts to a string of
  10096. * hashes where each Unicode character represents one line.
  10097. * @param {string} text1 First string.
  10098. * @param {string} text2 Second string.
  10099. * @return {{chars1: string, chars2: string, lineArray: !Array.<string>}}
  10100. * An object containing the encoded text1, the encoded text2 and
  10101. * the array of unique strings.
  10102. * The zeroth element of the array of unique strings is intentionally blank.
  10103. * @private
  10104. */
  10105. diff_match_patch.prototype.diff_linesToChars_ = function(text1, text2) {
  10106. var lineArray = []; // e.g. lineArray[4] == 'Hello\n'
  10107. var lineHash = {}; // e.g. lineHash['Hello\n'] == 4
  10108. // '\x00' is a valid character, but various debuggers don't like it.
  10109. // So we'll insert a junk entry to avoid generating a null character.
  10110. lineArray[0] = '';
  10111. /**
  10112. * Split a text into an array of strings. Reduce the texts to a string of
  10113. * hashes where each Unicode character represents one line.
  10114. * Modifies linearray and linehash through being a closure.
  10115. * @param {string} text String to encode.
  10116. * @return {string} Encoded string.
  10117. * @private
  10118. */
  10119. function diff_linesToCharsMunge_(text) {
  10120. var chars = '';
  10121. // Walk the text, pulling out a substring for each line.
  10122. // text.split('\n') would would temporarily double our memory footprint.
  10123. // Modifying text would create many large strings to garbage collect.
  10124. var lineStart = 0;
  10125. var lineEnd = -1;
  10126. // Keeping our own length variable is faster than looking it up.
  10127. var lineArrayLength = lineArray.length;
  10128. while (lineEnd < text.length - 1) {
  10129. lineEnd = text.indexOf('\n', lineStart);
  10130. if (lineEnd == -1) {
  10131. lineEnd = text.length - 1;
  10132. }
  10133. var line = text.substring(lineStart, lineEnd + 1);
  10134. lineStart = lineEnd + 1;
  10135. if (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) :
  10136. (lineHash[line] !== undefined)) {
  10137. chars += String.fromCharCode(lineHash[line]);
  10138. } else {
  10139. chars += String.fromCharCode(lineArrayLength);
  10140. lineHash[line] = lineArrayLength;
  10141. lineArray[lineArrayLength++] = line;
  10142. }
  10143. }
  10144. return chars;
  10145. }
  10146. var chars1 = diff_linesToCharsMunge_(text1);
  10147. var chars2 = diff_linesToCharsMunge_(text2);
  10148. return {chars1: chars1, chars2: chars2, lineArray: lineArray};
  10149. };
  10150. /**
  10151. * Rehydrate the text in a diff from a string of line hashes to real lines of
  10152. * text.
  10153. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10154. * @param {!Array.<string>} lineArray Array of unique strings.
  10155. * @private
  10156. */
  10157. diff_match_patch.prototype.diff_charsToLines_ = function(diffs, lineArray) {
  10158. for (var x = 0; x < diffs.length; x++) {
  10159. var chars = diffs[x][1];
  10160. var text = [];
  10161. for (var y = 0; y < chars.length; y++) {
  10162. text[y] = lineArray[chars.charCodeAt(y)];
  10163. }
  10164. diffs[x][1] = text.join('');
  10165. }
  10166. };
  10167. /**
  10168. * Determine the common prefix of two strings.
  10169. * @param {string} text1 First string.
  10170. * @param {string} text2 Second string.
  10171. * @return {number} The number of characters common to the start of each
  10172. * string.
  10173. */
  10174. diff_match_patch.prototype.diff_commonPrefix = function(text1, text2) {
  10175. // Quick check for common null cases.
  10176. if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
  10177. return 0;
  10178. }
  10179. // Binary search.
  10180. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  10181. var pointermin = 0;
  10182. var pointermax = Math.min(text1.length, text2.length);
  10183. var pointermid = pointermax;
  10184. var pointerstart = 0;
  10185. while (pointermin < pointermid) {
  10186. if (text1.substring(pointerstart, pointermid) ==
  10187. text2.substring(pointerstart, pointermid)) {
  10188. pointermin = pointermid;
  10189. pointerstart = pointermin;
  10190. } else {
  10191. pointermax = pointermid;
  10192. }
  10193. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  10194. }
  10195. return pointermid;
  10196. };
  10197. /**
  10198. * Determine the common suffix of two strings.
  10199. * @param {string} text1 First string.
  10200. * @param {string} text2 Second string.
  10201. * @return {number} The number of characters common to the end of each string.
  10202. */
  10203. diff_match_patch.prototype.diff_commonSuffix = function(text1, text2) {
  10204. // Quick check for common null cases.
  10205. if (!text1 || !text2 ||
  10206. text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
  10207. return 0;
  10208. }
  10209. // Binary search.
  10210. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  10211. var pointermin = 0;
  10212. var pointermax = Math.min(text1.length, text2.length);
  10213. var pointermid = pointermax;
  10214. var pointerend = 0;
  10215. while (pointermin < pointermid) {
  10216. if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
  10217. text2.substring(text2.length - pointermid, text2.length - pointerend)) {
  10218. pointermin = pointermid;
  10219. pointerend = pointermin;
  10220. } else {
  10221. pointermax = pointermid;
  10222. }
  10223. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  10224. }
  10225. return pointermid;
  10226. };
  10227. /**
  10228. * Determine if the suffix of one string is the prefix of another.
  10229. * @param {string} text1 First string.
  10230. * @param {string} text2 Second string.
  10231. * @return {number} The number of characters common to the end of the first
  10232. * string and the start of the second string.
  10233. * @private
  10234. */
  10235. diff_match_patch.prototype.diff_commonOverlap_ = function(text1, text2) {
  10236. // Cache the text lengths to prevent multiple calls.
  10237. var text1_length = text1.length;
  10238. var text2_length = text2.length;
  10239. // Eliminate the null case.
  10240. if (text1_length == 0 || text2_length == 0) {
  10241. return 0;
  10242. }
  10243. // Truncate the longer string.
  10244. if (text1_length > text2_length) {
  10245. text1 = text1.substring(text1_length - text2_length);
  10246. } else if (text1_length < text2_length) {
  10247. text2 = text2.substring(0, text1_length);
  10248. }
  10249. var text_length = Math.min(text1_length, text2_length);
  10250. // Quick check for the worst case.
  10251. if (text1 == text2) {
  10252. return text_length;
  10253. }
  10254. // Start by looking for a single character match
  10255. // and increase length until no match is found.
  10256. // Performance analysis: http://neil.fraser.name/news/2010/11/04/
  10257. var best = 0;
  10258. var length = 1;
  10259. while (true) {
  10260. var pattern = text1.substring(text_length - length);
  10261. var found = text2.indexOf(pattern);
  10262. if (found == -1) {
  10263. return best;
  10264. }
  10265. length += found;
  10266. if (found == 0 || text1.substring(text_length - length) ==
  10267. text2.substring(0, length)) {
  10268. best = length;
  10269. length++;
  10270. }
  10271. }
  10272. };
  10273. /**
  10274. * Do the two texts share a substring which is at least half the length of the
  10275. * longer text?
  10276. * This speedup can produce non-minimal diffs.
  10277. * @param {string} text1 First string.
  10278. * @param {string} text2 Second string.
  10279. * @return {Array.<string>} Five element Array, containing the prefix of
  10280. * text1, the suffix of text1, the prefix of text2, the suffix of
  10281. * text2 and the common middle. Or null if there was no match.
  10282. * @private
  10283. */
  10284. diff_match_patch.prototype.diff_halfMatch_ = function(text1, text2) {
  10285. if (this.Diff_Timeout <= 0) {
  10286. // Don't risk returning a non-optimal diff if we have unlimited time.
  10287. return null;
  10288. }
  10289. var longtext = text1.length > text2.length ? text1 : text2;
  10290. var shorttext = text1.length > text2.length ? text2 : text1;
  10291. if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
  10292. return null; // Pointless.
  10293. }
  10294. var dmp = this; // 'this' becomes 'window' in a closure.
  10295. /**
  10296. * Does a substring of shorttext exist within longtext such that the substring
  10297. * is at least half the length of longtext?
  10298. * Closure, but does not reference any external variables.
  10299. * @param {string} longtext Longer string.
  10300. * @param {string} shorttext Shorter string.
  10301. * @param {number} i Start index of quarter length substring within longtext.
  10302. * @return {Array.<string>} Five element Array, containing the prefix of
  10303. * longtext, the suffix of longtext, the prefix of shorttext, the suffix
  10304. * of shorttext and the common middle. Or null if there was no match.
  10305. * @private
  10306. */
  10307. function diff_halfMatchI_(longtext, shorttext, i) {
  10308. // Start with a 1/4 length substring at position i as a seed.
  10309. var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
  10310. var j = -1;
  10311. var best_common = '';
  10312. var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
  10313. while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
  10314. var prefixLength = dmp.diff_commonPrefix(longtext.substring(i),
  10315. shorttext.substring(j));
  10316. var suffixLength = dmp.diff_commonSuffix(longtext.substring(0, i),
  10317. shorttext.substring(0, j));
  10318. if (best_common.length < suffixLength + prefixLength) {
  10319. best_common = shorttext.substring(j - suffixLength, j) +
  10320. shorttext.substring(j, j + prefixLength);
  10321. best_longtext_a = longtext.substring(0, i - suffixLength);
  10322. best_longtext_b = longtext.substring(i + prefixLength);
  10323. best_shorttext_a = shorttext.substring(0, j - suffixLength);
  10324. best_shorttext_b = shorttext.substring(j + prefixLength);
  10325. }
  10326. }
  10327. if (best_common.length * 2 >= longtext.length) {
  10328. return [best_longtext_a, best_longtext_b,
  10329. best_shorttext_a, best_shorttext_b, best_common];
  10330. } else {
  10331. return null;
  10332. }
  10333. }
  10334. // First check if the second quarter is the seed for a half-match.
  10335. var hm1 = diff_halfMatchI_(longtext, shorttext,
  10336. Math.ceil(longtext.length / 4));
  10337. // Check again based on the third quarter.
  10338. var hm2 = diff_halfMatchI_(longtext, shorttext,
  10339. Math.ceil(longtext.length / 2));
  10340. var hm;
  10341. if (!hm1 && !hm2) {
  10342. return null;
  10343. } else if (!hm2) {
  10344. hm = hm1;
  10345. } else if (!hm1) {
  10346. hm = hm2;
  10347. } else {
  10348. // Both matched. Select the longest.
  10349. hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
  10350. }
  10351. // A half-match was found, sort out the return data.
  10352. var text1_a, text1_b, text2_a, text2_b;
  10353. if (text1.length > text2.length) {
  10354. text1_a = hm[0];
  10355. text1_b = hm[1];
  10356. text2_a = hm[2];
  10357. text2_b = hm[3];
  10358. } else {
  10359. text2_a = hm[0];
  10360. text2_b = hm[1];
  10361. text1_a = hm[2];
  10362. text1_b = hm[3];
  10363. }
  10364. var mid_common = hm[4];
  10365. return [text1_a, text1_b, text2_a, text2_b, mid_common];
  10366. };
  10367. /**
  10368. * Reduce the number of edits by eliminating semantically trivial equalities.
  10369. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10370. */
  10371. diff_match_patch.prototype.diff_cleanupSemantic = function(diffs) {
  10372. var changes = false;
  10373. var equalities = []; // Stack of indices where equalities are found.
  10374. var equalitiesLength = 0; // Keeping our own length var is faster in JS.
  10375. /** @type {?string} */
  10376. var lastequality = null;
  10377. // Always equal to diffs[equalities[equalitiesLength - 1]][1]
  10378. var pointer = 0; // Index of current position.
  10379. // Number of characters that changed prior to the equality.
  10380. var length_insertions1 = 0;
  10381. var length_deletions1 = 0;
  10382. // Number of characters that changed after the equality.
  10383. var length_insertions2 = 0;
  10384. var length_deletions2 = 0;
  10385. while (pointer < diffs.length) {
  10386. if (diffs[pointer][0] == DIFF_EQUAL) { // Equality found.
  10387. equalities[equalitiesLength++] = pointer;
  10388. length_insertions1 = length_insertions2;
  10389. length_deletions1 = length_deletions2;
  10390. length_insertions2 = 0;
  10391. length_deletions2 = 0;
  10392. lastequality = diffs[pointer][1];
  10393. } else { // An insertion or deletion.
  10394. if (diffs[pointer][0] == DIFF_INSERT) {
  10395. length_insertions2 += diffs[pointer][1].length;
  10396. } else {
  10397. length_deletions2 += diffs[pointer][1].length;
  10398. }
  10399. // Eliminate an equality that is smaller or equal to the edits on both
  10400. // sides of it.
  10401. if (lastequality && (lastequality.length <=
  10402. Math.max(length_insertions1, length_deletions1)) &&
  10403. (lastequality.length <= Math.max(length_insertions2,
  10404. length_deletions2))) {
  10405. // Duplicate record.
  10406. diffs.splice(equalities[equalitiesLength - 1], 0,
  10407. [DIFF_DELETE, lastequality]);
  10408. // Change second copy to insert.
  10409. diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
  10410. // Throw away the equality we just deleted.
  10411. equalitiesLength--;
  10412. // Throw away the previous equality (it needs to be reevaluated).
  10413. equalitiesLength--;
  10414. pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
  10415. length_insertions1 = 0; // Reset the counters.
  10416. length_deletions1 = 0;
  10417. length_insertions2 = 0;
  10418. length_deletions2 = 0;
  10419. lastequality = null;
  10420. changes = true;
  10421. }
  10422. }
  10423. pointer++;
  10424. }
  10425. // Normalize the diff.
  10426. if (changes) {
  10427. this.diff_cleanupMerge(diffs);
  10428. }
  10429. this.diff_cleanupSemanticLossless(diffs);
  10430. // Find any overlaps between deletions and insertions.
  10431. // e.g: <del>abcxxx</del><ins>xxxdef</ins>
  10432. // -> <del>abc</del>xxx<ins>def</ins>
  10433. // e.g: <del>xxxabc</del><ins>defxxx</ins>
  10434. // -> <ins>def</ins>xxx<del>abc</del>
  10435. // Only extract an overlap if it is as big as the edit ahead or behind it.
  10436. pointer = 1;
  10437. while (pointer < diffs.length) {
  10438. if (diffs[pointer - 1][0] == DIFF_DELETE &&
  10439. diffs[pointer][0] == DIFF_INSERT) {
  10440. var deletion = diffs[pointer - 1][1];
  10441. var insertion = diffs[pointer][1];
  10442. var overlap_length1 = this.diff_commonOverlap_(deletion, insertion);
  10443. var overlap_length2 = this.diff_commonOverlap_(insertion, deletion);
  10444. if (overlap_length1 >= overlap_length2) {
  10445. if (overlap_length1 >= deletion.length / 2 ||
  10446. overlap_length1 >= insertion.length / 2) {
  10447. // Overlap found. Insert an equality and trim the surrounding edits.
  10448. diffs.splice(pointer, 0,
  10449. [DIFF_EQUAL, insertion.substring(0, overlap_length1)]);
  10450. diffs[pointer - 1][1] =
  10451. deletion.substring(0, deletion.length - overlap_length1);
  10452. diffs[pointer + 1][1] = insertion.substring(overlap_length1);
  10453. pointer++;
  10454. }
  10455. } else {
  10456. if (overlap_length2 >= deletion.length / 2 ||
  10457. overlap_length2 >= insertion.length / 2) {
  10458. // Reverse overlap found.
  10459. // Insert an equality and swap and trim the surrounding edits.
  10460. diffs.splice(pointer, 0,
  10461. [DIFF_EQUAL, deletion.substring(0, overlap_length2)]);
  10462. diffs[pointer - 1][0] = DIFF_INSERT;
  10463. diffs[pointer - 1][1] =
  10464. insertion.substring(0, insertion.length - overlap_length2);
  10465. diffs[pointer + 1][0] = DIFF_DELETE;
  10466. diffs[pointer + 1][1] =
  10467. deletion.substring(overlap_length2);
  10468. pointer++;
  10469. }
  10470. }
  10471. pointer++;
  10472. }
  10473. pointer++;
  10474. }
  10475. };
  10476. /**
  10477. * Look for single edits surrounded on both sides by equalities
  10478. * which can be shifted sideways to align the edit to a word boundary.
  10479. * e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.
  10480. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10481. */
  10482. diff_match_patch.prototype.diff_cleanupSemanticLossless = function(diffs) {
  10483. /**
  10484. * Given two strings, compute a score representing whether the internal
  10485. * boundary falls on logical boundaries.
  10486. * Scores range from 6 (best) to 0 (worst).
  10487. * Closure, but does not reference any external variables.
  10488. * @param {string} one First string.
  10489. * @param {string} two Second string.
  10490. * @return {number} The score.
  10491. * @private
  10492. */
  10493. function diff_cleanupSemanticScore_(one, two) {
  10494. if (!one || !two) {
  10495. // Edges are the best.
  10496. return 6;
  10497. }
  10498. // Each port of this function behaves slightly differently due to
  10499. // subtle differences in each language's definition of things like
  10500. // 'whitespace'. Since this function's purpose is largely cosmetic,
  10501. // the choice has been made to use each language's native features
  10502. // rather than force total conformity.
  10503. var char1 = one.charAt(one.length - 1);
  10504. var char2 = two.charAt(0);
  10505. var nonAlphaNumeric1 = char1.match(diff_match_patch.nonAlphaNumericRegex_);
  10506. var nonAlphaNumeric2 = char2.match(diff_match_patch.nonAlphaNumericRegex_);
  10507. var whitespace1 = nonAlphaNumeric1 &&
  10508. char1.match(diff_match_patch.whitespaceRegex_);
  10509. var whitespace2 = nonAlphaNumeric2 &&
  10510. char2.match(diff_match_patch.whitespaceRegex_);
  10511. var lineBreak1 = whitespace1 &&
  10512. char1.match(diff_match_patch.linebreakRegex_);
  10513. var lineBreak2 = whitespace2 &&
  10514. char2.match(diff_match_patch.linebreakRegex_);
  10515. var blankLine1 = lineBreak1 &&
  10516. one.match(diff_match_patch.blanklineEndRegex_);
  10517. var blankLine2 = lineBreak2 &&
  10518. two.match(diff_match_patch.blanklineStartRegex_);
  10519. if (blankLine1 || blankLine2) {
  10520. // Five points for blank lines.
  10521. return 5;
  10522. } else if (lineBreak1 || lineBreak2) {
  10523. // Four points for line breaks.
  10524. return 4;
  10525. } else if (nonAlphaNumeric1 && !whitespace1 && whitespace2) {
  10526. // Three points for end of sentences.
  10527. return 3;
  10528. } else if (whitespace1 || whitespace2) {
  10529. // Two points for whitespace.
  10530. return 2;
  10531. } else if (nonAlphaNumeric1 || nonAlphaNumeric2) {
  10532. // One point for non-alphanumeric.
  10533. return 1;
  10534. }
  10535. return 0;
  10536. }
  10537. var pointer = 1;
  10538. // Intentionally ignore the first and last element (don't need checking).
  10539. while (pointer < diffs.length - 1) {
  10540. if (diffs[pointer - 1][0] == DIFF_EQUAL &&
  10541. diffs[pointer + 1][0] == DIFF_EQUAL) {
  10542. // This is a single edit surrounded by equalities.
  10543. var equality1 = diffs[pointer - 1][1];
  10544. var edit = diffs[pointer][1];
  10545. var equality2 = diffs[pointer + 1][1];
  10546. // First, shift the edit as far left as possible.
  10547. var commonOffset = this.diff_commonSuffix(equality1, edit);
  10548. if (commonOffset) {
  10549. var commonString = edit.substring(edit.length - commonOffset);
  10550. equality1 = equality1.substring(0, equality1.length - commonOffset);
  10551. edit = commonString + edit.substring(0, edit.length - commonOffset);
  10552. equality2 = commonString + equality2;
  10553. }
  10554. // Second, step character by character right, looking for the best fit.
  10555. var bestEquality1 = equality1;
  10556. var bestEdit = edit;
  10557. var bestEquality2 = equality2;
  10558. var bestScore = diff_cleanupSemanticScore_(equality1, edit) +
  10559. diff_cleanupSemanticScore_(edit, equality2);
  10560. while (edit.charAt(0) === equality2.charAt(0)) {
  10561. equality1 += edit.charAt(0);
  10562. edit = edit.substring(1) + equality2.charAt(0);
  10563. equality2 = equality2.substring(1);
  10564. var score = diff_cleanupSemanticScore_(equality1, edit) +
  10565. diff_cleanupSemanticScore_(edit, equality2);
  10566. // The >= encourages trailing rather than leading whitespace on edits.
  10567. if (score >= bestScore) {
  10568. bestScore = score;
  10569. bestEquality1 = equality1;
  10570. bestEdit = edit;
  10571. bestEquality2 = equality2;
  10572. }
  10573. }
  10574. if (diffs[pointer - 1][1] != bestEquality1) {
  10575. // We have an improvement, save it back to the diff.
  10576. if (bestEquality1) {
  10577. diffs[pointer - 1][1] = bestEquality1;
  10578. } else {
  10579. diffs.splice(pointer - 1, 1);
  10580. pointer--;
  10581. }
  10582. diffs[pointer][1] = bestEdit;
  10583. if (bestEquality2) {
  10584. diffs[pointer + 1][1] = bestEquality2;
  10585. } else {
  10586. diffs.splice(pointer + 1, 1);
  10587. pointer--;
  10588. }
  10589. }
  10590. }
  10591. pointer++;
  10592. }
  10593. };
  10594. // Define some regex patterns for matching boundaries.
  10595. diff_match_patch.nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/;
  10596. diff_match_patch.whitespaceRegex_ = /\s/;
  10597. diff_match_patch.linebreakRegex_ = /[\r\n]/;
  10598. diff_match_patch.blanklineEndRegex_ = /\n\r?\n$/;
  10599. diff_match_patch.blanklineStartRegex_ = /^\r?\n\r?\n/;
  10600. /**
  10601. * Reduce the number of edits by eliminating operationally trivial equalities.
  10602. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10603. */
  10604. diff_match_patch.prototype.diff_cleanupEfficiency = function(diffs) {
  10605. var changes = false;
  10606. var equalities = []; // Stack of indices where equalities are found.
  10607. var equalitiesLength = 0; // Keeping our own length var is faster in JS.
  10608. /** @type {?string} */
  10609. var lastequality = null;
  10610. // Always equal to diffs[equalities[equalitiesLength - 1]][1]
  10611. var pointer = 0; // Index of current position.
  10612. // Is there an insertion operation before the last equality.
  10613. var pre_ins = false;
  10614. // Is there a deletion operation before the last equality.
  10615. var pre_del = false;
  10616. // Is there an insertion operation after the last equality.
  10617. var post_ins = false;
  10618. // Is there a deletion operation after the last equality.
  10619. var post_del = false;
  10620. while (pointer < diffs.length) {
  10621. if (diffs[pointer][0] == DIFF_EQUAL) { // Equality found.
  10622. if (diffs[pointer][1].length < this.Diff_EditCost &&
  10623. (post_ins || post_del)) {
  10624. // Candidate found.
  10625. equalities[equalitiesLength++] = pointer;
  10626. pre_ins = post_ins;
  10627. pre_del = post_del;
  10628. lastequality = diffs[pointer][1];
  10629. } else {
  10630. // Not a candidate, and can never become one.
  10631. equalitiesLength = 0;
  10632. lastequality = null;
  10633. }
  10634. post_ins = post_del = false;
  10635. } else { // An insertion or deletion.
  10636. if (diffs[pointer][0] == DIFF_DELETE) {
  10637. post_del = true;
  10638. } else {
  10639. post_ins = true;
  10640. }
  10641. /*
  10642. * Five types to be split:
  10643. * <ins>A</ins><del>B</del>XY<ins>C</ins><del>D</del>
  10644. * <ins>A</ins>X<ins>C</ins><del>D</del>
  10645. * <ins>A</ins><del>B</del>X<ins>C</ins>
  10646. * <ins>A</del>X<ins>C</ins><del>D</del>
  10647. * <ins>A</ins><del>B</del>X<del>C</del>
  10648. */
  10649. if (lastequality && ((pre_ins && pre_del && post_ins && post_del) ||
  10650. ((lastequality.length < this.Diff_EditCost / 2) &&
  10651. (pre_ins + pre_del + post_ins + post_del) == 3))) {
  10652. // Duplicate record.
  10653. diffs.splice(equalities[equalitiesLength - 1], 0,
  10654. [DIFF_DELETE, lastequality]);
  10655. // Change second copy to insert.
  10656. diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
  10657. equalitiesLength--; // Throw away the equality we just deleted;
  10658. lastequality = null;
  10659. if (pre_ins && pre_del) {
  10660. // No changes made which could affect previous entry, keep going.
  10661. post_ins = post_del = true;
  10662. equalitiesLength = 0;
  10663. } else {
  10664. equalitiesLength--; // Throw away the previous equality.
  10665. pointer = equalitiesLength > 0 ?
  10666. equalities[equalitiesLength - 1] : -1;
  10667. post_ins = post_del = false;
  10668. }
  10669. changes = true;
  10670. }
  10671. }
  10672. pointer++;
  10673. }
  10674. if (changes) {
  10675. this.diff_cleanupMerge(diffs);
  10676. }
  10677. };
  10678. /**
  10679. * Reorder and merge like edit sections. Merge equalities.
  10680. * Any edit section can move as long as it doesn't cross an equality.
  10681. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10682. */
  10683. diff_match_patch.prototype.diff_cleanupMerge = function(diffs) {
  10684. diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
  10685. var pointer = 0;
  10686. var count_delete = 0;
  10687. var count_insert = 0;
  10688. var text_delete = '';
  10689. var text_insert = '';
  10690. var commonlength;
  10691. while (pointer < diffs.length) {
  10692. switch (diffs[pointer][0]) {
  10693. case DIFF_INSERT:
  10694. count_insert++;
  10695. text_insert += diffs[pointer][1];
  10696. pointer++;
  10697. break;
  10698. case DIFF_DELETE:
  10699. count_delete++;
  10700. text_delete += diffs[pointer][1];
  10701. pointer++;
  10702. break;
  10703. case DIFF_EQUAL:
  10704. // Upon reaching an equality, check for prior redundancies.
  10705. if (count_delete + count_insert > 1) {
  10706. if (count_delete !== 0 && count_insert !== 0) {
  10707. // Factor out any common prefixies.
  10708. commonlength = this.diff_commonPrefix(text_insert, text_delete);
  10709. if (commonlength !== 0) {
  10710. if ((pointer - count_delete - count_insert) > 0 &&
  10711. diffs[pointer - count_delete - count_insert - 1][0] ==
  10712. DIFF_EQUAL) {
  10713. diffs[pointer - count_delete - count_insert - 1][1] +=
  10714. text_insert.substring(0, commonlength);
  10715. } else {
  10716. diffs.splice(0, 0, [DIFF_EQUAL,
  10717. text_insert.substring(0, commonlength)]);
  10718. pointer++;
  10719. }
  10720. text_insert = text_insert.substring(commonlength);
  10721. text_delete = text_delete.substring(commonlength);
  10722. }
  10723. // Factor out any common suffixies.
  10724. commonlength = this.diff_commonSuffix(text_insert, text_delete);
  10725. if (commonlength !== 0) {
  10726. diffs[pointer][1] = text_insert.substring(text_insert.length -
  10727. commonlength) + diffs[pointer][1];
  10728. text_insert = text_insert.substring(0, text_insert.length -
  10729. commonlength);
  10730. text_delete = text_delete.substring(0, text_delete.length -
  10731. commonlength);
  10732. }
  10733. }
  10734. // Delete the offending records and add the merged ones.
  10735. if (count_delete === 0) {
  10736. diffs.splice(pointer - count_insert,
  10737. count_delete + count_insert, [DIFF_INSERT, text_insert]);
  10738. } else if (count_insert === 0) {
  10739. diffs.splice(pointer - count_delete,
  10740. count_delete + count_insert, [DIFF_DELETE, text_delete]);
  10741. } else {
  10742. diffs.splice(pointer - count_delete - count_insert,
  10743. count_delete + count_insert, [DIFF_DELETE, text_delete],
  10744. [DIFF_INSERT, text_insert]);
  10745. }
  10746. pointer = pointer - count_delete - count_insert +
  10747. (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
  10748. } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
  10749. // Merge this equality with the previous one.
  10750. diffs[pointer - 1][1] += diffs[pointer][1];
  10751. diffs.splice(pointer, 1);
  10752. } else {
  10753. pointer++;
  10754. }
  10755. count_insert = 0;
  10756. count_delete = 0;
  10757. text_delete = '';
  10758. text_insert = '';
  10759. break;
  10760. }
  10761. }
  10762. if (diffs[diffs.length - 1][1] === '') {
  10763. diffs.pop(); // Remove the dummy entry at the end.
  10764. }
  10765. // Second pass: look for single edits surrounded on both sides by equalities
  10766. // which can be shifted sideways to eliminate an equality.
  10767. // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
  10768. var changes = false;
  10769. pointer = 1;
  10770. // Intentionally ignore the first and last element (don't need checking).
  10771. while (pointer < diffs.length - 1) {
  10772. if (diffs[pointer - 1][0] == DIFF_EQUAL &&
  10773. diffs[pointer + 1][0] == DIFF_EQUAL) {
  10774. // This is a single edit surrounded by equalities.
  10775. if (diffs[pointer][1].substring(diffs[pointer][1].length -
  10776. diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
  10777. // Shift the edit over the previous equality.
  10778. diffs[pointer][1] = diffs[pointer - 1][1] +
  10779. diffs[pointer][1].substring(0, diffs[pointer][1].length -
  10780. diffs[pointer - 1][1].length);
  10781. diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
  10782. diffs.splice(pointer - 1, 1);
  10783. changes = true;
  10784. } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
  10785. diffs[pointer + 1][1]) {
  10786. // Shift the edit over the next equality.
  10787. diffs[pointer - 1][1] += diffs[pointer + 1][1];
  10788. diffs[pointer][1] =
  10789. diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
  10790. diffs[pointer + 1][1];
  10791. diffs.splice(pointer + 1, 1);
  10792. changes = true;
  10793. }
  10794. }
  10795. pointer++;
  10796. }
  10797. // If shifts were made, the diff needs reordering and another shift sweep.
  10798. if (changes) {
  10799. this.diff_cleanupMerge(diffs);
  10800. }
  10801. };
  10802. /**
  10803. * loc is a location in text1, compute and return the equivalent location in
  10804. * text2.
  10805. * e.g. 'The cat' vs 'The big cat', 1->1, 5->8
  10806. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10807. * @param {number} loc Location within text1.
  10808. * @return {number} Location within text2.
  10809. */
  10810. diff_match_patch.prototype.diff_xIndex = function(diffs, loc) {
  10811. var chars1 = 0;
  10812. var chars2 = 0;
  10813. var last_chars1 = 0;
  10814. var last_chars2 = 0;
  10815. var x;
  10816. for (x = 0; x < diffs.length; x++) {
  10817. if (diffs[x][0] !== DIFF_INSERT) { // Equality or deletion.
  10818. chars1 += diffs[x][1].length;
  10819. }
  10820. if (diffs[x][0] !== DIFF_DELETE) { // Equality or insertion.
  10821. chars2 += diffs[x][1].length;
  10822. }
  10823. if (chars1 > loc) { // Overshot the location.
  10824. break;
  10825. }
  10826. last_chars1 = chars1;
  10827. last_chars2 = chars2;
  10828. }
  10829. // Was the location was deleted?
  10830. if (diffs.length != x && diffs[x][0] === DIFF_DELETE) {
  10831. return last_chars2;
  10832. }
  10833. // Add the remaining character length.
  10834. return last_chars2 + (loc - last_chars1);
  10835. };
  10836. /**
  10837. * Convert a diff array into a pretty HTML report.
  10838. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10839. * @return {string} HTML representation.
  10840. */
  10841. diff_match_patch.prototype.diff_prettyHtml = function(diffs) {
  10842. var html = [];
  10843. var pattern_amp = /&/g;
  10844. var pattern_lt = /</g;
  10845. var pattern_gt = />/g;
  10846. var pattern_para = /\n/g;
  10847. for (var x = 0; x < diffs.length; x++) {
  10848. var op = diffs[x][0]; // Operation (insert, delete, equal)
  10849. var data = diffs[x][1]; // Text of change.
  10850. var text = data.replace(pattern_amp, '&amp;').replace(pattern_lt, '&lt;')
  10851. .replace(pattern_gt, '&gt;').replace(pattern_para, '&para;<br>');
  10852. switch (op) {
  10853. case DIFF_INSERT:
  10854. html[x] = '<ins style="background:#e6ffe6;">' + text + '</ins>';
  10855. break;
  10856. case DIFF_DELETE:
  10857. html[x] = '<del style="background:#ffe6e6;">' + text + '</del>';
  10858. break;
  10859. case DIFF_EQUAL:
  10860. html[x] = '<span>' + text + '</span>';
  10861. break;
  10862. }
  10863. }
  10864. return html.join('');
  10865. };
  10866. /**
  10867. * Compute and return the source text (all equalities and deletions).
  10868. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10869. * @return {string} Source text.
  10870. */
  10871. diff_match_patch.prototype.diff_text1 = function(diffs) {
  10872. var text = [];
  10873. for (var x = 0; x < diffs.length; x++) {
  10874. if (diffs[x][0] !== DIFF_INSERT) {
  10875. text[x] = diffs[x][1];
  10876. }
  10877. }
  10878. return text.join('');
  10879. };
  10880. /**
  10881. * Compute and return the destination text (all equalities and insertions).
  10882. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10883. * @return {string} Destination text.
  10884. */
  10885. diff_match_patch.prototype.diff_text2 = function(diffs) {
  10886. var text = [];
  10887. for (var x = 0; x < diffs.length; x++) {
  10888. if (diffs[x][0] !== DIFF_DELETE) {
  10889. text[x] = diffs[x][1];
  10890. }
  10891. }
  10892. return text.join('');
  10893. };
  10894. /**
  10895. * Compute the Levenshtein distance; the number of inserted, deleted or
  10896. * substituted characters.
  10897. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10898. * @return {number} Number of changes.
  10899. */
  10900. diff_match_patch.prototype.diff_levenshtein = function(diffs) {
  10901. var levenshtein = 0;
  10902. var insertions = 0;
  10903. var deletions = 0;
  10904. for (var x = 0; x < diffs.length; x++) {
  10905. var op = diffs[x][0];
  10906. var data = diffs[x][1];
  10907. switch (op) {
  10908. case DIFF_INSERT:
  10909. insertions += data.length;
  10910. break;
  10911. case DIFF_DELETE:
  10912. deletions += data.length;
  10913. break;
  10914. case DIFF_EQUAL:
  10915. // A deletion and an insertion is one substitution.
  10916. levenshtein += Math.max(insertions, deletions);
  10917. insertions = 0;
  10918. deletions = 0;
  10919. break;
  10920. }
  10921. }
  10922. levenshtein += Math.max(insertions, deletions);
  10923. return levenshtein;
  10924. };
  10925. /**
  10926. * Crush the diff into an encoded string which describes the operations
  10927. * required to transform text1 into text2.
  10928. * E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'.
  10929. * Operations are tab-separated. Inserted text is escaped using %xx notation.
  10930. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  10931. * @return {string} Delta text.
  10932. */
  10933. diff_match_patch.prototype.diff_toDelta = function(diffs) {
  10934. var text = [];
  10935. for (var x = 0; x < diffs.length; x++) {
  10936. switch (diffs[x][0]) {
  10937. case DIFF_INSERT:
  10938. text[x] = '+' + encodeURI(diffs[x][1]);
  10939. break;
  10940. case DIFF_DELETE:
  10941. text[x] = '-' + diffs[x][1].length;
  10942. break;
  10943. case DIFF_EQUAL:
  10944. text[x] = '=' + diffs[x][1].length;
  10945. break;
  10946. }
  10947. }
  10948. return text.join('\t').replace(/%20/g, ' ');
  10949. };
  10950. /**
  10951. * Given the original text1, and an encoded string which describes the
  10952. * operations required to transform text1 into text2, compute the full diff.
  10953. * @param {string} text1 Source string for the diff.
  10954. * @param {string} delta Delta text.
  10955. * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
  10956. * @throws {!Error} If invalid input.
  10957. */
  10958. diff_match_patch.prototype.diff_fromDelta = function(text1, delta) {
  10959. var diffs = [];
  10960. var diffsLength = 0; // Keeping our own length var is faster in JS.
  10961. var pointer = 0; // Cursor in text1
  10962. var tokens = delta.split(/\t/g);
  10963. for (var x = 0; x < tokens.length; x++) {
  10964. // Each token begins with a one character parameter which specifies the
  10965. // operation of this token (delete, insert, equality).
  10966. var param = tokens[x].substring(1);
  10967. switch (tokens[x].charAt(0)) {
  10968. case '+':
  10969. try {
  10970. diffs[diffsLength++] = [DIFF_INSERT, decodeURI(param)];
  10971. } catch (ex) {
  10972. // Malformed URI sequence.
  10973. throw new Error('Illegal escape in diff_fromDelta: ' + param);
  10974. }
  10975. break;
  10976. case '-':
  10977. // Fall through.
  10978. case '=':
  10979. var n = parseInt(param, 10);
  10980. if (isNaN(n) || n < 0) {
  10981. throw new Error('Invalid number in diff_fromDelta: ' + param);
  10982. }
  10983. var text = text1.substring(pointer, pointer += n);
  10984. if (tokens[x].charAt(0) == '=') {
  10985. diffs[diffsLength++] = [DIFF_EQUAL, text];
  10986. } else {
  10987. diffs[diffsLength++] = [DIFF_DELETE, text];
  10988. }
  10989. break;
  10990. default:
  10991. // Blank tokens are ok (from a trailing \t).
  10992. // Anything else is an error.
  10993. if (tokens[x]) {
  10994. throw new Error('Invalid diff operation in diff_fromDelta: ' +
  10995. tokens[x]);
  10996. }
  10997. }
  10998. }
  10999. if (pointer != text1.length) {
  11000. throw new Error('Delta length (' + pointer +
  11001. ') does not equal source text length (' + text1.length + ').');
  11002. }
  11003. return diffs;
  11004. };
  11005. // MATCH FUNCTIONS
  11006. /**
  11007. * Locate the best instance of 'pattern' in 'text' near 'loc'.
  11008. * @param {string} text The text to search.
  11009. * @param {string} pattern The pattern to search for.
  11010. * @param {number} loc The location to search around.
  11011. * @return {number} Best match index or -1.
  11012. */
  11013. diff_match_patch.prototype.match_main = function(text, pattern, loc) {
  11014. // Check for null inputs.
  11015. if (text == null || pattern == null || loc == null) {
  11016. throw new Error('Null input. (match_main)');
  11017. }
  11018. loc = Math.max(0, Math.min(loc, text.length));
  11019. if (text == pattern) {
  11020. // Shortcut (potentially not guaranteed by the algorithm)
  11021. return 0;
  11022. } else if (!text.length) {
  11023. // Nothing to match.
  11024. return -1;
  11025. } else if (text.substring(loc, loc + pattern.length) == pattern) {
  11026. // Perfect match at the perfect spot! (Includes case of null pattern)
  11027. return loc;
  11028. } else {
  11029. // Do a fuzzy compare.
  11030. return this.match_bitap_(text, pattern, loc);
  11031. }
  11032. };
  11033. /**
  11034. * Locate the best instance of 'pattern' in 'text' near 'loc' using the
  11035. * Bitap algorithm.
  11036. * @param {string} text The text to search.
  11037. * @param {string} pattern The pattern to search for.
  11038. * @param {number} loc The location to search around.
  11039. * @return {number} Best match index or -1.
  11040. * @private
  11041. */
  11042. diff_match_patch.prototype.match_bitap_ = function(text, pattern, loc) {
  11043. if (pattern.length > this.Match_MaxBits) {
  11044. throw new Error('Pattern too long for this browser.');
  11045. }
  11046. // Initialise the alphabet.
  11047. var s = this.match_alphabet_(pattern);
  11048. var dmp = this; // 'this' becomes 'window' in a closure.
  11049. /**
  11050. * Compute and return the score for a match with e errors and x location.
  11051. * Accesses loc and pattern through being a closure.
  11052. * @param {number} e Number of errors in match.
  11053. * @param {number} x Location of match.
  11054. * @return {number} Overall score for match (0.0 = good, 1.0 = bad).
  11055. * @private
  11056. */
  11057. function match_bitapScore_(e, x) {
  11058. var accuracy = e / pattern.length;
  11059. var proximity = Math.abs(loc - x);
  11060. if (!dmp.Match_Distance) {
  11061. // Dodge divide by zero error.
  11062. return proximity ? 1.0 : accuracy;
  11063. }
  11064. return accuracy + (proximity / dmp.Match_Distance);
  11065. }
  11066. // Highest score beyond which we give up.
  11067. var score_threshold = this.Match_Threshold;
  11068. // Is there a nearby exact match? (speedup)
  11069. var best_loc = text.indexOf(pattern, loc);
  11070. if (best_loc != -1) {
  11071. score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold);
  11072. // What about in the other direction? (speedup)
  11073. best_loc = text.lastIndexOf(pattern, loc + pattern.length);
  11074. if (best_loc != -1) {
  11075. score_threshold =
  11076. Math.min(match_bitapScore_(0, best_loc), score_threshold);
  11077. }
  11078. }
  11079. // Initialise the bit arrays.
  11080. var matchmask = 1 << (pattern.length - 1);
  11081. best_loc = -1;
  11082. var bin_min, bin_mid;
  11083. var bin_max = pattern.length + text.length;
  11084. var last_rd;
  11085. for (var d = 0; d < pattern.length; d++) {
  11086. // Scan for the best match; each iteration allows for one more error.
  11087. // Run a binary search to determine how far from 'loc' we can stray at this
  11088. // error level.
  11089. bin_min = 0;
  11090. bin_mid = bin_max;
  11091. while (bin_min < bin_mid) {
  11092. if (match_bitapScore_(d, loc + bin_mid) <= score_threshold) {
  11093. bin_min = bin_mid;
  11094. } else {
  11095. bin_max = bin_mid;
  11096. }
  11097. bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min);
  11098. }
  11099. // Use the result from this iteration as the maximum for the next.
  11100. bin_max = bin_mid;
  11101. var start = Math.max(1, loc - bin_mid + 1);
  11102. var finish = Math.min(loc + bin_mid, text.length) + pattern.length;
  11103. var rd = Array(finish + 2);
  11104. rd[finish + 1] = (1 << d) - 1;
  11105. for (var j = finish; j >= start; j--) {
  11106. // The alphabet (s) is a sparse hash, so the following line generates
  11107. // warnings.
  11108. var charMatch = s[text.charAt(j - 1)];
  11109. if (d === 0) { // First pass: exact match.
  11110. rd[j] = ((rd[j + 1] << 1) | 1) & charMatch;
  11111. } else { // Subsequent passes: fuzzy match.
  11112. rd[j] = (((rd[j + 1] << 1) | 1) & charMatch) |
  11113. (((last_rd[j + 1] | last_rd[j]) << 1) | 1) |
  11114. last_rd[j + 1];
  11115. }
  11116. if (rd[j] & matchmask) {
  11117. var score = match_bitapScore_(d, j - 1);
  11118. // This match will almost certainly be better than any existing match.
  11119. // But check anyway.
  11120. if (score <= score_threshold) {
  11121. // Told you so.
  11122. score_threshold = score;
  11123. best_loc = j - 1;
  11124. if (best_loc > loc) {
  11125. // When passing loc, don't exceed our current distance from loc.
  11126. start = Math.max(1, 2 * loc - best_loc);
  11127. } else {
  11128. // Already passed loc, downhill from here on in.
  11129. break;
  11130. }
  11131. }
  11132. }
  11133. }
  11134. // No hope for a (better) match at greater error levels.
  11135. if (match_bitapScore_(d + 1, loc) > score_threshold) {
  11136. break;
  11137. }
  11138. last_rd = rd;
  11139. }
  11140. return best_loc;
  11141. };
  11142. /**
  11143. * Initialise the alphabet for the Bitap algorithm.
  11144. * @param {string} pattern The text to encode.
  11145. * @return {!Object} Hash of character locations.
  11146. * @private
  11147. */
  11148. diff_match_patch.prototype.match_alphabet_ = function(pattern) {
  11149. var s = {};
  11150. for (var i = 0; i < pattern.length; i++) {
  11151. s[pattern.charAt(i)] = 0;
  11152. }
  11153. for (var i = 0; i < pattern.length; i++) {
  11154. s[pattern.charAt(i)] |= 1 << (pattern.length - i - 1);
  11155. }
  11156. return s;
  11157. };
  11158. // PATCH FUNCTIONS
  11159. /**
  11160. * Increase the context until it is unique,
  11161. * but don't let the pattern expand beyond Match_MaxBits.
  11162. * @param {!diff_match_patch.patch_obj} patch The patch to grow.
  11163. * @param {string} text Source text.
  11164. * @private
  11165. */
  11166. diff_match_patch.prototype.patch_addContext_ = function(patch, text) {
  11167. if (text.length == 0) {
  11168. return;
  11169. }
  11170. var pattern = text.substring(patch.start2, patch.start2 + patch.length1);
  11171. var padding = 0;
  11172. // Look for the first and last matches of pattern in text. If two different
  11173. // matches are found, increase the pattern length.
  11174. while (text.indexOf(pattern) != text.lastIndexOf(pattern) &&
  11175. pattern.length < this.Match_MaxBits - this.Patch_Margin -
  11176. this.Patch_Margin) {
  11177. padding += this.Patch_Margin;
  11178. pattern = text.substring(patch.start2 - padding,
  11179. patch.start2 + patch.length1 + padding);
  11180. }
  11181. // Add one chunk for good luck.
  11182. padding += this.Patch_Margin;
  11183. // Add the prefix.
  11184. var prefix = text.substring(patch.start2 - padding, patch.start2);
  11185. if (prefix) {
  11186. patch.diffs.unshift([DIFF_EQUAL, prefix]);
  11187. }
  11188. // Add the suffix.
  11189. var suffix = text.substring(patch.start2 + patch.length1,
  11190. patch.start2 + patch.length1 + padding);
  11191. if (suffix) {
  11192. patch.diffs.push([DIFF_EQUAL, suffix]);
  11193. }
  11194. // Roll back the start points.
  11195. patch.start1 -= prefix.length;
  11196. patch.start2 -= prefix.length;
  11197. // Extend the lengths.
  11198. patch.length1 += prefix.length + suffix.length;
  11199. patch.length2 += prefix.length + suffix.length;
  11200. };
  11201. /**
  11202. * Compute a list of patches to turn text1 into text2.
  11203. * Use diffs if provided, otherwise compute it ourselves.
  11204. * There are four ways to call this function, depending on what data is
  11205. * available to the caller:
  11206. * Method 1:
  11207. * a = text1, b = text2
  11208. * Method 2:
  11209. * a = diffs
  11210. * Method 3 (optimal):
  11211. * a = text1, b = diffs
  11212. * Method 4 (deprecated, use method 3):
  11213. * a = text1, b = text2, c = diffs
  11214. *
  11215. * @param {string|!Array.<!diff_match_patch.Diff>} a text1 (methods 1,3,4) or
  11216. * Array of diff tuples for text1 to text2 (method 2).
  11217. * @param {string|!Array.<!diff_match_patch.Diff>} opt_b text2 (methods 1,4) or
  11218. * Array of diff tuples for text1 to text2 (method 3) or undefined (method 2).
  11219. * @param {string|!Array.<!diff_match_patch.Diff>} opt_c Array of diff tuples
  11220. * for text1 to text2 (method 4) or undefined (methods 1,2,3).
  11221. * @return {!Array.<!diff_match_patch.patch_obj>} Array of Patch objects.
  11222. */
  11223. diff_match_patch.prototype.patch_make = function(a, opt_b, opt_c) {
  11224. var text1, diffs;
  11225. if (typeof a == 'string' && typeof opt_b == 'string' &&
  11226. typeof opt_c == 'undefined') {
  11227. // Method 1: text1, text2
  11228. // Compute diffs from text1 and text2.
  11229. text1 = /** @type {string} */(a);
  11230. diffs = this.diff_main(text1, /** @type {string} */(opt_b), true);
  11231. if (diffs.length > 2) {
  11232. this.diff_cleanupSemantic(diffs);
  11233. this.diff_cleanupEfficiency(diffs);
  11234. }
  11235. } else if (a && typeof a == 'object' && typeof opt_b == 'undefined' &&
  11236. typeof opt_c == 'undefined') {
  11237. // Method 2: diffs
  11238. // Compute text1 from diffs.
  11239. diffs = /** @type {!Array.<!diff_match_patch.Diff>} */(a);
  11240. text1 = this.diff_text1(diffs);
  11241. } else if (typeof a == 'string' && opt_b && typeof opt_b == 'object' &&
  11242. typeof opt_c == 'undefined') {
  11243. // Method 3: text1, diffs
  11244. text1 = /** @type {string} */(a);
  11245. diffs = /** @type {!Array.<!diff_match_patch.Diff>} */(opt_b);
  11246. } else if (typeof a == 'string' && typeof opt_b == 'string' &&
  11247. opt_c && typeof opt_c == 'object') {
  11248. // Method 4: text1, text2, diffs
  11249. // text2 is not used.
  11250. text1 = /** @type {string} */(a);
  11251. diffs = /** @type {!Array.<!diff_match_patch.Diff>} */(opt_c);
  11252. } else {
  11253. throw new Error('Unknown call format to patch_make.');
  11254. }
  11255. if (diffs.length === 0) {
  11256. return []; // Get rid of the null case.
  11257. }
  11258. var patches = [];
  11259. var patch = new diff_match_patch.patch_obj();
  11260. var patchDiffLength = 0; // Keeping our own length var is faster in JS.
  11261. var char_count1 = 0; // Number of characters into the text1 string.
  11262. var char_count2 = 0; // Number of characters into the text2 string.
  11263. // Start with text1 (prepatch_text) and apply the diffs until we arrive at
  11264. // text2 (postpatch_text). We recreate the patches one by one to determine
  11265. // context info.
  11266. var prepatch_text = text1;
  11267. var postpatch_text = text1;
  11268. for (var x = 0; x < diffs.length; x++) {
  11269. var diff_type = diffs[x][0];
  11270. var diff_text = diffs[x][1];
  11271. if (!patchDiffLength && diff_type !== DIFF_EQUAL) {
  11272. // A new patch starts here.
  11273. patch.start1 = char_count1;
  11274. patch.start2 = char_count2;
  11275. }
  11276. switch (diff_type) {
  11277. case DIFF_INSERT:
  11278. patch.diffs[patchDiffLength++] = diffs[x];
  11279. patch.length2 += diff_text.length;
  11280. postpatch_text = postpatch_text.substring(0, char_count2) + diff_text +
  11281. postpatch_text.substring(char_count2);
  11282. break;
  11283. case DIFF_DELETE:
  11284. patch.length1 += diff_text.length;
  11285. patch.diffs[patchDiffLength++] = diffs[x];
  11286. postpatch_text = postpatch_text.substring(0, char_count2) +
  11287. postpatch_text.substring(char_count2 +
  11288. diff_text.length);
  11289. break;
  11290. case DIFF_EQUAL:
  11291. if (diff_text.length <= 2 * this.Patch_Margin &&
  11292. patchDiffLength && diffs.length != x + 1) {
  11293. // Small equality inside a patch.
  11294. patch.diffs[patchDiffLength++] = diffs[x];
  11295. patch.length1 += diff_text.length;
  11296. patch.length2 += diff_text.length;
  11297. } else if (diff_text.length >= 2 * this.Patch_Margin) {
  11298. // Time for a new patch.
  11299. if (patchDiffLength) {
  11300. this.patch_addContext_(patch, prepatch_text);
  11301. patches.push(patch);
  11302. patch = new diff_match_patch.patch_obj();
  11303. patchDiffLength = 0;
  11304. // Unlike Unidiff, our patch lists have a rolling context.
  11305. // http://code.google.com/p/google-diff-match-patch/wiki/Unidiff
  11306. // Update prepatch text & pos to reflect the application of the
  11307. // just completed patch.
  11308. prepatch_text = postpatch_text;
  11309. char_count1 = char_count2;
  11310. }
  11311. }
  11312. break;
  11313. }
  11314. // Update the current character count.
  11315. if (diff_type !== DIFF_INSERT) {
  11316. char_count1 += diff_text.length;
  11317. }
  11318. if (diff_type !== DIFF_DELETE) {
  11319. char_count2 += diff_text.length;
  11320. }
  11321. }
  11322. // Pick up the leftover patch if not empty.
  11323. if (patchDiffLength) {
  11324. this.patch_addContext_(patch, prepatch_text);
  11325. patches.push(patch);
  11326. }
  11327. return patches;
  11328. };
  11329. /**
  11330. * Given an array of patches, return another array that is identical.
  11331. * @param {!Array.<!diff_match_patch.patch_obj>} patches Array of Patch objects.
  11332. * @return {!Array.<!diff_match_patch.patch_obj>} Array of Patch objects.
  11333. */
  11334. diff_match_patch.prototype.patch_deepCopy = function(patches) {
  11335. // Making deep copies is hard in JavaScript.
  11336. var patchesCopy = [];
  11337. for (var x = 0; x < patches.length; x++) {
  11338. var patch = patches[x];
  11339. var patchCopy = new diff_match_patch.patch_obj();
  11340. patchCopy.diffs = [];
  11341. for (var y = 0; y < patch.diffs.length; y++) {
  11342. patchCopy.diffs[y] = patch.diffs[y].slice();
  11343. }
  11344. patchCopy.start1 = patch.start1;
  11345. patchCopy.start2 = patch.start2;
  11346. patchCopy.length1 = patch.length1;
  11347. patchCopy.length2 = patch.length2;
  11348. patchesCopy[x] = patchCopy;
  11349. }
  11350. return patchesCopy;
  11351. };
  11352. /**
  11353. * Merge a set of patches onto the text. Return a patched text, as well
  11354. * as a list of true/false values indicating which patches were applied.
  11355. * @param {!Array.<!diff_match_patch.patch_obj>} patches Array of Patch objects.
  11356. * @param {string} text Old text.
  11357. * @return {!Array.<string|!Array.<boolean>>} Two element Array, containing the
  11358. * new text and an array of boolean values.
  11359. */
  11360. diff_match_patch.prototype.patch_apply = function(patches, text) {
  11361. if (patches.length == 0) {
  11362. return [text, []];
  11363. }
  11364. // Deep copy the patches so that no changes are made to originals.
  11365. patches = this.patch_deepCopy(patches);
  11366. var nullPadding = this.patch_addPadding(patches);
  11367. text = nullPadding + text + nullPadding;
  11368. this.patch_splitMax(patches);
  11369. // delta keeps track of the offset between the expected and actual location
  11370. // of the previous patch. If there are patches expected at positions 10 and
  11371. // 20, but the first patch was found at 12, delta is 2 and the second patch
  11372. // has an effective expected position of 22.
  11373. var delta = 0;
  11374. var results = [];
  11375. for (var x = 0; x < patches.length; x++) {
  11376. var expected_loc = patches[x].start2 + delta;
  11377. var text1 = this.diff_text1(patches[x].diffs);
  11378. var start_loc;
  11379. var end_loc = -1;
  11380. if (text1.length > this.Match_MaxBits) {
  11381. // patch_splitMax will only provide an oversized pattern in the case of
  11382. // a monster delete.
  11383. start_loc = this.match_main(text, text1.substring(0, this.Match_MaxBits),
  11384. expected_loc);
  11385. if (start_loc != -1) {
  11386. end_loc = this.match_main(text,
  11387. text1.substring(text1.length - this.Match_MaxBits),
  11388. expected_loc + text1.length - this.Match_MaxBits);
  11389. if (end_loc == -1 || start_loc >= end_loc) {
  11390. // Can't find valid trailing context. Drop this patch.
  11391. start_loc = -1;
  11392. }
  11393. }
  11394. } else {
  11395. start_loc = this.match_main(text, text1, expected_loc);
  11396. }
  11397. if (start_loc == -1) {
  11398. // No match found. :(
  11399. results[x] = false;
  11400. // Subtract the delta for this failed patch from subsequent patches.
  11401. delta -= patches[x].length2 - patches[x].length1;
  11402. } else {
  11403. // Found a match. :)
  11404. results[x] = true;
  11405. delta = start_loc - expected_loc;
  11406. var text2;
  11407. if (end_loc == -1) {
  11408. text2 = text.substring(start_loc, start_loc + text1.length);
  11409. } else {
  11410. text2 = text.substring(start_loc, end_loc + this.Match_MaxBits);
  11411. }
  11412. if (text1 == text2) {
  11413. // Perfect match, just shove the replacement text in.
  11414. text = text.substring(0, start_loc) +
  11415. this.diff_text2(patches[x].diffs) +
  11416. text.substring(start_loc + text1.length);
  11417. } else {
  11418. // Imperfect match. Run a diff to get a framework of equivalent
  11419. // indices.
  11420. var diffs = this.diff_main(text1, text2, false);
  11421. if (text1.length > this.Match_MaxBits &&
  11422. this.diff_levenshtein(diffs) / text1.length >
  11423. this.Patch_DeleteThreshold) {
  11424. // The end points match, but the content is unacceptably bad.
  11425. results[x] = false;
  11426. } else {
  11427. this.diff_cleanupSemanticLossless(diffs);
  11428. var index1 = 0;
  11429. var index2;
  11430. for (var y = 0; y < patches[x].diffs.length; y++) {
  11431. var mod = patches[x].diffs[y];
  11432. if (mod[0] !== DIFF_EQUAL) {
  11433. index2 = this.diff_xIndex(diffs, index1);
  11434. }
  11435. if (mod[0] === DIFF_INSERT) { // Insertion
  11436. text = text.substring(0, start_loc + index2) + mod[1] +
  11437. text.substring(start_loc + index2);
  11438. } else if (mod[0] === DIFF_DELETE) { // Deletion
  11439. text = text.substring(0, start_loc + index2) +
  11440. text.substring(start_loc + this.diff_xIndex(diffs,
  11441. index1 + mod[1].length));
  11442. }
  11443. if (mod[0] !== DIFF_DELETE) {
  11444. index1 += mod[1].length;
  11445. }
  11446. }
  11447. }
  11448. }
  11449. }
  11450. }
  11451. // Strip the padding off.
  11452. text = text.substring(nullPadding.length, text.length - nullPadding.length);
  11453. return [text, results];
  11454. };
  11455. /**
  11456. * Add some padding on text start and end so that edges can match something.
  11457. * Intended to be called only from within patch_apply.
  11458. * @param {!Array.<!diff_match_patch.patch_obj>} patches Array of Patch objects.
  11459. * @return {string} The padding string added to each side.
  11460. */
  11461. diff_match_patch.prototype.patch_addPadding = function(patches) {
  11462. var paddingLength = this.Patch_Margin;
  11463. var nullPadding = '';
  11464. for (var x = 1; x <= paddingLength; x++) {
  11465. nullPadding += String.fromCharCode(x);
  11466. }
  11467. // Bump all the patches forward.
  11468. for (var x = 0; x < patches.length; x++) {
  11469. patches[x].start1 += paddingLength;
  11470. patches[x].start2 += paddingLength;
  11471. }
  11472. // Add some padding on start of first diff.
  11473. var patch = patches[0];
  11474. var diffs = patch.diffs;
  11475. if (diffs.length == 0 || diffs[0][0] != DIFF_EQUAL) {
  11476. // Add nullPadding equality.
  11477. diffs.unshift([DIFF_EQUAL, nullPadding]);
  11478. patch.start1 -= paddingLength; // Should be 0.
  11479. patch.start2 -= paddingLength; // Should be 0.
  11480. patch.length1 += paddingLength;
  11481. patch.length2 += paddingLength;
  11482. } else if (paddingLength > diffs[0][1].length) {
  11483. // Grow first equality.
  11484. var extraLength = paddingLength - diffs[0][1].length;
  11485. diffs[0][1] = nullPadding.substring(diffs[0][1].length) + diffs[0][1];
  11486. patch.start1 -= extraLength;
  11487. patch.start2 -= extraLength;
  11488. patch.length1 += extraLength;
  11489. patch.length2 += extraLength;
  11490. }
  11491. // Add some padding on end of last diff.
  11492. patch = patches[patches.length - 1];
  11493. diffs = patch.diffs;
  11494. if (diffs.length == 0 || diffs[diffs.length - 1][0] != DIFF_EQUAL) {
  11495. // Add nullPadding equality.
  11496. diffs.push([DIFF_EQUAL, nullPadding]);
  11497. patch.length1 += paddingLength;
  11498. patch.length2 += paddingLength;
  11499. } else if (paddingLength > diffs[diffs.length - 1][1].length) {
  11500. // Grow last equality.
  11501. var extraLength = paddingLength - diffs[diffs.length - 1][1].length;
  11502. diffs[diffs.length - 1][1] += nullPadding.substring(0, extraLength);
  11503. patch.length1 += extraLength;
  11504. patch.length2 += extraLength;
  11505. }
  11506. return nullPadding;
  11507. };
  11508. /**
  11509. * Look through the patches and break up any which are longer than the maximum
  11510. * limit of the match algorithm.
  11511. * Intended to be called only from within patch_apply.
  11512. * @param {!Array.<!diff_match_patch.patch_obj>} patches Array of Patch objects.
  11513. */
  11514. diff_match_patch.prototype.patch_splitMax = function(patches) {
  11515. var patch_size = this.Match_MaxBits;
  11516. for (var x = 0; x < patches.length; x++) {
  11517. if (patches[x].length1 <= patch_size) {
  11518. continue;
  11519. }
  11520. var bigpatch = patches[x];
  11521. // Remove the big old patch.
  11522. patches.splice(x--, 1);
  11523. var start1 = bigpatch.start1;
  11524. var start2 = bigpatch.start2;
  11525. var precontext = '';
  11526. while (bigpatch.diffs.length !== 0) {
  11527. // Create one of several smaller patches.
  11528. var patch = new diff_match_patch.patch_obj();
  11529. var empty = true;
  11530. patch.start1 = start1 - precontext.length;
  11531. patch.start2 = start2 - precontext.length;
  11532. if (precontext !== '') {
  11533. patch.length1 = patch.length2 = precontext.length;
  11534. patch.diffs.push([DIFF_EQUAL, precontext]);
  11535. }
  11536. while (bigpatch.diffs.length !== 0 &&
  11537. patch.length1 < patch_size - this.Patch_Margin) {
  11538. var diff_type = bigpatch.diffs[0][0];
  11539. var diff_text = bigpatch.diffs[0][1];
  11540. if (diff_type === DIFF_INSERT) {
  11541. // Insertions are harmless.
  11542. patch.length2 += diff_text.length;
  11543. start2 += diff_text.length;
  11544. patch.diffs.push(bigpatch.diffs.shift());
  11545. empty = false;
  11546. } else if (diff_type === DIFF_DELETE && patch.diffs.length == 1 &&
  11547. patch.diffs[0][0] == DIFF_EQUAL &&
  11548. diff_text.length > 2 * patch_size) {
  11549. // This is a large deletion. Let it pass in one chunk.
  11550. patch.length1 += diff_text.length;
  11551. start1 += diff_text.length;
  11552. empty = false;
  11553. patch.diffs.push([diff_type, diff_text]);
  11554. bigpatch.diffs.shift();
  11555. } else {
  11556. // Deletion or equality. Only take as much as we can stomach.
  11557. diff_text = diff_text.substring(0,
  11558. patch_size - patch.length1 - this.Patch_Margin);
  11559. patch.length1 += diff_text.length;
  11560. start1 += diff_text.length;
  11561. if (diff_type === DIFF_EQUAL) {
  11562. patch.length2 += diff_text.length;
  11563. start2 += diff_text.length;
  11564. } else {
  11565. empty = false;
  11566. }
  11567. patch.diffs.push([diff_type, diff_text]);
  11568. if (diff_text == bigpatch.diffs[0][1]) {
  11569. bigpatch.diffs.shift();
  11570. } else {
  11571. bigpatch.diffs[0][1] =
  11572. bigpatch.diffs[0][1].substring(diff_text.length);
  11573. }
  11574. }
  11575. }
  11576. // Compute the head context for the next patch.
  11577. precontext = this.diff_text2(patch.diffs);
  11578. precontext =
  11579. precontext.substring(precontext.length - this.Patch_Margin);
  11580. // Append the end context for this patch.
  11581. var postcontext = this.diff_text1(bigpatch.diffs)
  11582. .substring(0, this.Patch_Margin);
  11583. if (postcontext !== '') {
  11584. patch.length1 += postcontext.length;
  11585. patch.length2 += postcontext.length;
  11586. if (patch.diffs.length !== 0 &&
  11587. patch.diffs[patch.diffs.length - 1][0] === DIFF_EQUAL) {
  11588. patch.diffs[patch.diffs.length - 1][1] += postcontext;
  11589. } else {
  11590. patch.diffs.push([DIFF_EQUAL, postcontext]);
  11591. }
  11592. }
  11593. if (!empty) {
  11594. patches.splice(++x, 0, patch);
  11595. }
  11596. }
  11597. }
  11598. };
  11599. /**
  11600. * Take a list of patches and return a textual representation.
  11601. * @param {!Array.<!diff_match_patch.patch_obj>} patches Array of Patch objects.
  11602. * @return {string} Text representation of patches.
  11603. */
  11604. diff_match_patch.prototype.patch_toText = function(patches) {
  11605. var text = [];
  11606. for (var x = 0; x < patches.length; x++) {
  11607. text[x] = patches[x];
  11608. }
  11609. return text.join('');
  11610. };
  11611. /**
  11612. * Parse a textual representation of patches and return a list of Patch objects.
  11613. * @param {string} textline Text representation of patches.
  11614. * @return {!Array.<!diff_match_patch.patch_obj>} Array of Patch objects.
  11615. * @throws {!Error} If invalid input.
  11616. */
  11617. diff_match_patch.prototype.patch_fromText = function(textline) {
  11618. var patches = [];
  11619. if (!textline) {
  11620. return patches;
  11621. }
  11622. var text = textline.split('\n');
  11623. var textPointer = 0;
  11624. var patchHeader = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;
  11625. while (textPointer < text.length) {
  11626. var m = text[textPointer].match(patchHeader);
  11627. if (!m) {
  11628. throw new Error('Invalid patch string: ' + text[textPointer]);
  11629. }
  11630. var patch = new diff_match_patch.patch_obj();
  11631. patches.push(patch);
  11632. patch.start1 = parseInt(m[1], 10);
  11633. if (m[2] === '') {
  11634. patch.start1--;
  11635. patch.length1 = 1;
  11636. } else if (m[2] == '0') {
  11637. patch.length1 = 0;
  11638. } else {
  11639. patch.start1--;
  11640. patch.length1 = parseInt(m[2], 10);
  11641. }
  11642. patch.start2 = parseInt(m[3], 10);
  11643. if (m[4] === '') {
  11644. patch.start2--;
  11645. patch.length2 = 1;
  11646. } else if (m[4] == '0') {
  11647. patch.length2 = 0;
  11648. } else {
  11649. patch.start2--;
  11650. patch.length2 = parseInt(m[4], 10);
  11651. }
  11652. textPointer++;
  11653. while (textPointer < text.length) {
  11654. var sign = text[textPointer].charAt(0);
  11655. try {
  11656. var line = decodeURI(text[textPointer].substring(1));
  11657. } catch (ex) {
  11658. // Malformed URI sequence.
  11659. throw new Error('Illegal escape in patch_fromText: ' + line);
  11660. }
  11661. if (sign == '-') {
  11662. // Deletion.
  11663. patch.diffs.push([DIFF_DELETE, line]);
  11664. } else if (sign == '+') {
  11665. // Insertion.
  11666. patch.diffs.push([DIFF_INSERT, line]);
  11667. } else if (sign == ' ') {
  11668. // Minor equality.
  11669. patch.diffs.push([DIFF_EQUAL, line]);
  11670. } else if (sign == '@') {
  11671. // Start of next patch.
  11672. break;
  11673. } else if (sign === '') {
  11674. // Blank line? Whatever.
  11675. } else {
  11676. // WTF?
  11677. throw new Error('Invalid patch mode "' + sign + '" in: ' + line);
  11678. }
  11679. textPointer++;
  11680. }
  11681. }
  11682. return patches;
  11683. };
  11684. /**
  11685. * Class representing one patch operation.
  11686. * @constructor
  11687. */
  11688. diff_match_patch.patch_obj = function() {
  11689. /** @type {!Array.<!diff_match_patch.Diff>} */
  11690. this.diffs = [];
  11691. /** @type {?number} */
  11692. this.start1 = null;
  11693. /** @type {?number} */
  11694. this.start2 = null;
  11695. /** @type {number} */
  11696. this.length1 = 0;
  11697. /** @type {number} */
  11698. this.length2 = 0;
  11699. };
  11700. /**
  11701. * Emmulate GNU diff's format.
  11702. * Header: @@ -382,8 +481,9 @@
  11703. * Indicies are printed as 1-based, not 0-based.
  11704. * @return {string} The GNU diff string.
  11705. */
  11706. diff_match_patch.patch_obj.prototype.toString = function() {
  11707. var coords1, coords2;
  11708. if (this.length1 === 0) {
  11709. coords1 = this.start1 + ',0';
  11710. } else if (this.length1 == 1) {
  11711. coords1 = this.start1 + 1;
  11712. } else {
  11713. coords1 = (this.start1 + 1) + ',' + this.length1;
  11714. }
  11715. if (this.length2 === 0) {
  11716. coords2 = this.start2 + ',0';
  11717. } else if (this.length2 == 1) {
  11718. coords2 = this.start2 + 1;
  11719. } else {
  11720. coords2 = (this.start2 + 1) + ',' + this.length2;
  11721. }
  11722. var text = ['@@ -' + coords1 + ' +' + coords2 + ' @@\n'];
  11723. var op;
  11724. // Escape the body of the patch with %xx notation.
  11725. for (var x = 0; x < this.diffs.length; x++) {
  11726. switch (this.diffs[x][0]) {
  11727. case DIFF_INSERT:
  11728. op = '+';
  11729. break;
  11730. case DIFF_DELETE:
  11731. op = '-';
  11732. break;
  11733. case DIFF_EQUAL:
  11734. op = ' ';
  11735. break;
  11736. }
  11737. text[x + 1] = op + encodeURI(this.diffs[x][1]) + '\n';
  11738. }
  11739. return text.join('').replace(/%20/g, ' ');
  11740. };
  11741. // The following export code was added by @ForbesLindesay
  11742. module.exports = diff_match_patch;
  11743. module.exports['diff_match_patch'] = diff_match_patch;
  11744. module.exports['DIFF_DELETE'] = DIFF_DELETE;
  11745. module.exports['DIFF_INSERT'] = DIFF_INSERT;
  11746. module.exports['DIFF_EQUAL'] = DIFF_EQUAL;
  11747. },{}],125:[function(_dereq_,module,exports){
  11748. var eaw = {};
  11749. if ('undefined' == typeof module) {
  11750. window.eastasianwidth = eaw;
  11751. } else {
  11752. module.exports = eaw;
  11753. }
  11754. eaw.eastAsianWidth = function(character) {
  11755. var x = character.charCodeAt(0);
  11756. var y = (character.length == 2) ? character.charCodeAt(1) : 0;
  11757. var codePoint = x;
  11758. if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) {
  11759. x &= 0x3FF;
  11760. y &= 0x3FF;
  11761. codePoint = (x << 10) | y;
  11762. codePoint += 0x10000;
  11763. }
  11764. if ((0x3000 == codePoint) ||
  11765. (0xFF01 <= codePoint && codePoint <= 0xFF60) ||
  11766. (0xFFE0 <= codePoint && codePoint <= 0xFFE6)) {
  11767. return 'F';
  11768. }
  11769. if ((0x20A9 == codePoint) ||
  11770. (0xFF61 <= codePoint && codePoint <= 0xFFBE) ||
  11771. (0xFFC2 <= codePoint && codePoint <= 0xFFC7) ||
  11772. (0xFFCA <= codePoint && codePoint <= 0xFFCF) ||
  11773. (0xFFD2 <= codePoint && codePoint <= 0xFFD7) ||
  11774. (0xFFDA <= codePoint && codePoint <= 0xFFDC) ||
  11775. (0xFFE8 <= codePoint && codePoint <= 0xFFEE)) {
  11776. return 'H';
  11777. }
  11778. if ((0x1100 <= codePoint && codePoint <= 0x115F) ||
  11779. (0x11A3 <= codePoint && codePoint <= 0x11A7) ||
  11780. (0x11FA <= codePoint && codePoint <= 0x11FF) ||
  11781. (0x2329 <= codePoint && codePoint <= 0x232A) ||
  11782. (0x2E80 <= codePoint && codePoint <= 0x2E99) ||
  11783. (0x2E9B <= codePoint && codePoint <= 0x2EF3) ||
  11784. (0x2F00 <= codePoint && codePoint <= 0x2FD5) ||
  11785. (0x2FF0 <= codePoint && codePoint <= 0x2FFB) ||
  11786. (0x3001 <= codePoint && codePoint <= 0x303E) ||
  11787. (0x3041 <= codePoint && codePoint <= 0x3096) ||
  11788. (0x3099 <= codePoint && codePoint <= 0x30FF) ||
  11789. (0x3105 <= codePoint && codePoint <= 0x312D) ||
  11790. (0x3131 <= codePoint && codePoint <= 0x318E) ||
  11791. (0x3190 <= codePoint && codePoint <= 0x31BA) ||
  11792. (0x31C0 <= codePoint && codePoint <= 0x31E3) ||
  11793. (0x31F0 <= codePoint && codePoint <= 0x321E) ||
  11794. (0x3220 <= codePoint && codePoint <= 0x3247) ||
  11795. (0x3250 <= codePoint && codePoint <= 0x32FE) ||
  11796. (0x3300 <= codePoint && codePoint <= 0x4DBF) ||
  11797. (0x4E00 <= codePoint && codePoint <= 0xA48C) ||
  11798. (0xA490 <= codePoint && codePoint <= 0xA4C6) ||
  11799. (0xA960 <= codePoint && codePoint <= 0xA97C) ||
  11800. (0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
  11801. (0xD7B0 <= codePoint && codePoint <= 0xD7C6) ||
  11802. (0xD7CB <= codePoint && codePoint <= 0xD7FB) ||
  11803. (0xF900 <= codePoint && codePoint <= 0xFAFF) ||
  11804. (0xFE10 <= codePoint && codePoint <= 0xFE19) ||
  11805. (0xFE30 <= codePoint && codePoint <= 0xFE52) ||
  11806. (0xFE54 <= codePoint && codePoint <= 0xFE66) ||
  11807. (0xFE68 <= codePoint && codePoint <= 0xFE6B) ||
  11808. (0x1B000 <= codePoint && codePoint <= 0x1B001) ||
  11809. (0x1F200 <= codePoint && codePoint <= 0x1F202) ||
  11810. (0x1F210 <= codePoint && codePoint <= 0x1F23A) ||
  11811. (0x1F240 <= codePoint && codePoint <= 0x1F248) ||
  11812. (0x1F250 <= codePoint && codePoint <= 0x1F251) ||
  11813. (0x20000 <= codePoint && codePoint <= 0x2F73F) ||
  11814. (0x2B740 <= codePoint && codePoint <= 0x2FFFD) ||
  11815. (0x30000 <= codePoint && codePoint <= 0x3FFFD)) {
  11816. return 'W';
  11817. }
  11818. if ((0x0020 <= codePoint && codePoint <= 0x007E) ||
  11819. (0x00A2 <= codePoint && codePoint <= 0x00A3) ||
  11820. (0x00A5 <= codePoint && codePoint <= 0x00A6) ||
  11821. (0x00AC == codePoint) ||
  11822. (0x00AF == codePoint) ||
  11823. (0x27E6 <= codePoint && codePoint <= 0x27ED) ||
  11824. (0x2985 <= codePoint && codePoint <= 0x2986)) {
  11825. return 'Na';
  11826. }
  11827. if ((0x00A1 == codePoint) ||
  11828. (0x00A4 == codePoint) ||
  11829. (0x00A7 <= codePoint && codePoint <= 0x00A8) ||
  11830. (0x00AA == codePoint) ||
  11831. (0x00AD <= codePoint && codePoint <= 0x00AE) ||
  11832. (0x00B0 <= codePoint && codePoint <= 0x00B4) ||
  11833. (0x00B6 <= codePoint && codePoint <= 0x00BA) ||
  11834. (0x00BC <= codePoint && codePoint <= 0x00BF) ||
  11835. (0x00C6 == codePoint) ||
  11836. (0x00D0 == codePoint) ||
  11837. (0x00D7 <= codePoint && codePoint <= 0x00D8) ||
  11838. (0x00DE <= codePoint && codePoint <= 0x00E1) ||
  11839. (0x00E6 == codePoint) ||
  11840. (0x00E8 <= codePoint && codePoint <= 0x00EA) ||
  11841. (0x00EC <= codePoint && codePoint <= 0x00ED) ||
  11842. (0x00F0 == codePoint) ||
  11843. (0x00F2 <= codePoint && codePoint <= 0x00F3) ||
  11844. (0x00F7 <= codePoint && codePoint <= 0x00FA) ||
  11845. (0x00FC == codePoint) ||
  11846. (0x00FE == codePoint) ||
  11847. (0x0101 == codePoint) ||
  11848. (0x0111 == codePoint) ||
  11849. (0x0113 == codePoint) ||
  11850. (0x011B == codePoint) ||
  11851. (0x0126 <= codePoint && codePoint <= 0x0127) ||
  11852. (0x012B == codePoint) ||
  11853. (0x0131 <= codePoint && codePoint <= 0x0133) ||
  11854. (0x0138 == codePoint) ||
  11855. (0x013F <= codePoint && codePoint <= 0x0142) ||
  11856. (0x0144 == codePoint) ||
  11857. (0x0148 <= codePoint && codePoint <= 0x014B) ||
  11858. (0x014D == codePoint) ||
  11859. (0x0152 <= codePoint && codePoint <= 0x0153) ||
  11860. (0x0166 <= codePoint && codePoint <= 0x0167) ||
  11861. (0x016B == codePoint) ||
  11862. (0x01CE == codePoint) ||
  11863. (0x01D0 == codePoint) ||
  11864. (0x01D2 == codePoint) ||
  11865. (0x01D4 == codePoint) ||
  11866. (0x01D6 == codePoint) ||
  11867. (0x01D8 == codePoint) ||
  11868. (0x01DA == codePoint) ||
  11869. (0x01DC == codePoint) ||
  11870. (0x0251 == codePoint) ||
  11871. (0x0261 == codePoint) ||
  11872. (0x02C4 == codePoint) ||
  11873. (0x02C7 == codePoint) ||
  11874. (0x02C9 <= codePoint && codePoint <= 0x02CB) ||
  11875. (0x02CD == codePoint) ||
  11876. (0x02D0 == codePoint) ||
  11877. (0x02D8 <= codePoint && codePoint <= 0x02DB) ||
  11878. (0x02DD == codePoint) ||
  11879. (0x02DF == codePoint) ||
  11880. (0x0300 <= codePoint && codePoint <= 0x036F) ||
  11881. (0x0391 <= codePoint && codePoint <= 0x03A1) ||
  11882. (0x03A3 <= codePoint && codePoint <= 0x03A9) ||
  11883. (0x03B1 <= codePoint && codePoint <= 0x03C1) ||
  11884. (0x03C3 <= codePoint && codePoint <= 0x03C9) ||
  11885. (0x0401 == codePoint) ||
  11886. (0x0410 <= codePoint && codePoint <= 0x044F) ||
  11887. (0x0451 == codePoint) ||
  11888. (0x2010 == codePoint) ||
  11889. (0x2013 <= codePoint && codePoint <= 0x2016) ||
  11890. (0x2018 <= codePoint && codePoint <= 0x2019) ||
  11891. (0x201C <= codePoint && codePoint <= 0x201D) ||
  11892. (0x2020 <= codePoint && codePoint <= 0x2022) ||
  11893. (0x2024 <= codePoint && codePoint <= 0x2027) ||
  11894. (0x2030 == codePoint) ||
  11895. (0x2032 <= codePoint && codePoint <= 0x2033) ||
  11896. (0x2035 == codePoint) ||
  11897. (0x203B == codePoint) ||
  11898. (0x203E == codePoint) ||
  11899. (0x2074 == codePoint) ||
  11900. (0x207F == codePoint) ||
  11901. (0x2081 <= codePoint && codePoint <= 0x2084) ||
  11902. (0x20AC == codePoint) ||
  11903. (0x2103 == codePoint) ||
  11904. (0x2105 == codePoint) ||
  11905. (0x2109 == codePoint) ||
  11906. (0x2113 == codePoint) ||
  11907. (0x2116 == codePoint) ||
  11908. (0x2121 <= codePoint && codePoint <= 0x2122) ||
  11909. (0x2126 == codePoint) ||
  11910. (0x212B == codePoint) ||
  11911. (0x2153 <= codePoint && codePoint <= 0x2154) ||
  11912. (0x215B <= codePoint && codePoint <= 0x215E) ||
  11913. (0x2160 <= codePoint && codePoint <= 0x216B) ||
  11914. (0x2170 <= codePoint && codePoint <= 0x2179) ||
  11915. (0x2189 == codePoint) ||
  11916. (0x2190 <= codePoint && codePoint <= 0x2199) ||
  11917. (0x21B8 <= codePoint && codePoint <= 0x21B9) ||
  11918. (0x21D2 == codePoint) ||
  11919. (0x21D4 == codePoint) ||
  11920. (0x21E7 == codePoint) ||
  11921. (0x2200 == codePoint) ||
  11922. (0x2202 <= codePoint && codePoint <= 0x2203) ||
  11923. (0x2207 <= codePoint && codePoint <= 0x2208) ||
  11924. (0x220B == codePoint) ||
  11925. (0x220F == codePoint) ||
  11926. (0x2211 == codePoint) ||
  11927. (0x2215 == codePoint) ||
  11928. (0x221A == codePoint) ||
  11929. (0x221D <= codePoint && codePoint <= 0x2220) ||
  11930. (0x2223 == codePoint) ||
  11931. (0x2225 == codePoint) ||
  11932. (0x2227 <= codePoint && codePoint <= 0x222C) ||
  11933. (0x222E == codePoint) ||
  11934. (0x2234 <= codePoint && codePoint <= 0x2237) ||
  11935. (0x223C <= codePoint && codePoint <= 0x223D) ||
  11936. (0x2248 == codePoint) ||
  11937. (0x224C == codePoint) ||
  11938. (0x2252 == codePoint) ||
  11939. (0x2260 <= codePoint && codePoint <= 0x2261) ||
  11940. (0x2264 <= codePoint && codePoint <= 0x2267) ||
  11941. (0x226A <= codePoint && codePoint <= 0x226B) ||
  11942. (0x226E <= codePoint && codePoint <= 0x226F) ||
  11943. (0x2282 <= codePoint && codePoint <= 0x2283) ||
  11944. (0x2286 <= codePoint && codePoint <= 0x2287) ||
  11945. (0x2295 == codePoint) ||
  11946. (0x2299 == codePoint) ||
  11947. (0x22A5 == codePoint) ||
  11948. (0x22BF == codePoint) ||
  11949. (0x2312 == codePoint) ||
  11950. (0x2460 <= codePoint && codePoint <= 0x24E9) ||
  11951. (0x24EB <= codePoint && codePoint <= 0x254B) ||
  11952. (0x2550 <= codePoint && codePoint <= 0x2573) ||
  11953. (0x2580 <= codePoint && codePoint <= 0x258F) ||
  11954. (0x2592 <= codePoint && codePoint <= 0x2595) ||
  11955. (0x25A0 <= codePoint && codePoint <= 0x25A1) ||
  11956. (0x25A3 <= codePoint && codePoint <= 0x25A9) ||
  11957. (0x25B2 <= codePoint && codePoint <= 0x25B3) ||
  11958. (0x25B6 <= codePoint && codePoint <= 0x25B7) ||
  11959. (0x25BC <= codePoint && codePoint <= 0x25BD) ||
  11960. (0x25C0 <= codePoint && codePoint <= 0x25C1) ||
  11961. (0x25C6 <= codePoint && codePoint <= 0x25C8) ||
  11962. (0x25CB == codePoint) ||
  11963. (0x25CE <= codePoint && codePoint <= 0x25D1) ||
  11964. (0x25E2 <= codePoint && codePoint <= 0x25E5) ||
  11965. (0x25EF == codePoint) ||
  11966. (0x2605 <= codePoint && codePoint <= 0x2606) ||
  11967. (0x2609 == codePoint) ||
  11968. (0x260E <= codePoint && codePoint <= 0x260F) ||
  11969. (0x2614 <= codePoint && codePoint <= 0x2615) ||
  11970. (0x261C == codePoint) ||
  11971. (0x261E == codePoint) ||
  11972. (0x2640 == codePoint) ||
  11973. (0x2642 == codePoint) ||
  11974. (0x2660 <= codePoint && codePoint <= 0x2661) ||
  11975. (0x2663 <= codePoint && codePoint <= 0x2665) ||
  11976. (0x2667 <= codePoint && codePoint <= 0x266A) ||
  11977. (0x266C <= codePoint && codePoint <= 0x266D) ||
  11978. (0x266F == codePoint) ||
  11979. (0x269E <= codePoint && codePoint <= 0x269F) ||
  11980. (0x26BE <= codePoint && codePoint <= 0x26BF) ||
  11981. (0x26C4 <= codePoint && codePoint <= 0x26CD) ||
  11982. (0x26CF <= codePoint && codePoint <= 0x26E1) ||
  11983. (0x26E3 == codePoint) ||
  11984. (0x26E8 <= codePoint && codePoint <= 0x26FF) ||
  11985. (0x273D == codePoint) ||
  11986. (0x2757 == codePoint) ||
  11987. (0x2776 <= codePoint && codePoint <= 0x277F) ||
  11988. (0x2B55 <= codePoint && codePoint <= 0x2B59) ||
  11989. (0x3248 <= codePoint && codePoint <= 0x324F) ||
  11990. (0xE000 <= codePoint && codePoint <= 0xF8FF) ||
  11991. (0xFE00 <= codePoint && codePoint <= 0xFE0F) ||
  11992. (0xFFFD == codePoint) ||
  11993. (0x1F100 <= codePoint && codePoint <= 0x1F10A) ||
  11994. (0x1F110 <= codePoint && codePoint <= 0x1F12D) ||
  11995. (0x1F130 <= codePoint && codePoint <= 0x1F169) ||
  11996. (0x1F170 <= codePoint && codePoint <= 0x1F19A) ||
  11997. (0xE0100 <= codePoint && codePoint <= 0xE01EF) ||
  11998. (0xF0000 <= codePoint && codePoint <= 0xFFFFD) ||
  11999. (0x100000 <= codePoint && codePoint <= 0x10FFFD)) {
  12000. return 'A';
  12001. }
  12002. return 'N';
  12003. };
  12004. eaw.characterLength = function(character) {
  12005. var code = this.eastAsianWidth(character);
  12006. if (code == 'F' || code == 'W' || code == 'A') {
  12007. return 2;
  12008. } else {
  12009. return 1;
  12010. }
  12011. };
  12012. // Split a string considering surrogate-pairs.
  12013. function stringToArray(string) {
  12014. return string.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
  12015. }
  12016. eaw.length = function(string) {
  12017. var characters = stringToArray(string);
  12018. var len = 0;
  12019. for (var i = 0; i < characters.length; i++) {
  12020. len = len + this.characterLength(characters[i]);
  12021. }
  12022. return len;
  12023. };
  12024. eaw.slice = function(text, start, end) {
  12025. textLen = eaw.length(text)
  12026. start = start ? start : 0;
  12027. end = end ? end : 1;
  12028. if (start < 0) {
  12029. start = textLen + start;
  12030. }
  12031. if (end < 0) {
  12032. end = textLen + end;
  12033. }
  12034. var result = '';
  12035. var eawLen = 0;
  12036. var chars = stringToArray(text);
  12037. for (var i = 0; i < chars.length; i++) {
  12038. var char = chars[i];
  12039. var charLen = eaw.length(char);
  12040. if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
  12041. if (eawLen + charLen <= end) {
  12042. result += char;
  12043. } else {
  12044. break;
  12045. }
  12046. }
  12047. eawLen += charLen;
  12048. }
  12049. return result;
  12050. };
  12051. },{}],126:[function(_dereq_,module,exports){
  12052. /**
  12053. * empower-core - Power Assert feature enhancer for assert function/object.
  12054. *
  12055. * https://github.com/twada/power-assert-runtime/packages/empower-core
  12056. *
  12057. * Copyright (c) 2013-2018 Takuto Wada
  12058. * Licensed under the MIT license.
  12059. * https://github.com/twada/power-assert-runtime/blob/master/LICENSE
  12060. */
  12061. var create = _dereq_('core-js/library/fn/object/create');
  12062. var assign = _dereq_('core-js/library/fn/object/assign');
  12063. var defaultOptions = _dereq_('./lib/default-options');
  12064. var Decorator = _dereq_('./lib/decorator');
  12065. var define = _dereq_('./lib/define-properties');
  12066. var slice = Array.prototype.slice;
  12067. /**
  12068. * Enhance Power Assert feature to assert function/object.
  12069. * @param assert target assert function or object to enhance
  12070. * @param options enhancement options
  12071. * @return enhanced assert function/object
  12072. */
  12073. function empowerCore (assert, options) {
  12074. var typeOfAssert = (typeof assert);
  12075. var enhancedAssert;
  12076. if ((typeOfAssert !== 'object' && typeOfAssert !== 'function') || assert === null) {
  12077. throw new TypeError('empower-core argument should be a function or object.');
  12078. }
  12079. if (isEmpowered(assert)) {
  12080. return assert;
  12081. }
  12082. switch (typeOfAssert) {
  12083. case 'function':
  12084. enhancedAssert = empowerAssertFunction(assert, options);
  12085. break;
  12086. case 'object':
  12087. enhancedAssert = empowerAssertObject(assert, options);
  12088. break;
  12089. default:
  12090. throw new Error('Cannot be here');
  12091. }
  12092. define(enhancedAssert, { _empowered: true });
  12093. return enhancedAssert;
  12094. }
  12095. function empowerAssertObject (assertObject, options) {
  12096. var config = assign(defaultOptions(), options);
  12097. var target = config.destructive ? assertObject : create(assertObject);
  12098. var decorator = new Decorator(target, config);
  12099. return assign(target, decorator.enhancement());
  12100. }
  12101. function empowerAssertFunction (assertFunction, options) {
  12102. var config = assign(defaultOptions(), options);
  12103. if (config.destructive) {
  12104. throw new Error('cannot use destructive:true to function.');
  12105. }
  12106. var decorator = new Decorator(assertFunction, config);
  12107. var enhancement = decorator.enhancement();
  12108. var powerAssert;
  12109. if (typeof enhancement === 'function') {
  12110. powerAssert = function powerAssert () {
  12111. return enhancement.apply(null, slice.apply(arguments));
  12112. };
  12113. } else {
  12114. powerAssert = function powerAssert () {
  12115. return assertFunction.apply(null, slice.apply(arguments));
  12116. };
  12117. }
  12118. assign(powerAssert, assertFunction);
  12119. return assign(powerAssert, enhancement);
  12120. }
  12121. function isEmpowered (assertObjectOrFunction) {
  12122. return assertObjectOrFunction._empowered;
  12123. }
  12124. empowerCore.defaultOptions = defaultOptions;
  12125. module.exports = empowerCore;
  12126. },{"./lib/decorator":128,"./lib/default-options":129,"./lib/define-properties":130,"core-js/library/fn/object/assign":23,"core-js/library/fn/object/create":24}],127:[function(_dereq_,module,exports){
  12127. 'use strict';
  12128. var some = _dereq_('core-js/library/fn/array/some');
  12129. var map = _dereq_('core-js/library/fn/array/map');
  12130. function decorate (callSpec, decorator) {
  12131. var numArgsToCapture = callSpec.numArgsToCapture;
  12132. return function decoratedAssert () {
  12133. var context, message, hasMessage = false;
  12134. // see: https://github.com/twada/empower-core/pull/8#issue-127859465
  12135. // see: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
  12136. var args = new Array(arguments.length);
  12137. for(var i = 0; i < args.length; ++i) {
  12138. args[i] = arguments[i];
  12139. }
  12140. if (numArgsToCapture === (args.length - 1)) {
  12141. message = args.pop();
  12142. hasMessage = true;
  12143. }
  12144. var invocation = {
  12145. thisObj: this,
  12146. values: args,
  12147. message: message,
  12148. hasMessage: hasMessage
  12149. };
  12150. if (some(args, isCaptured)) {
  12151. invocation.values = map(args.slice(0, numArgsToCapture), function (arg) {
  12152. if (isNotCaptured(arg)) {
  12153. return arg;
  12154. }
  12155. if (!context) {
  12156. context = {
  12157. source: arg.source,
  12158. args: []
  12159. };
  12160. }
  12161. context.args.push({
  12162. value: arg.powerAssertContext.value,
  12163. events: arg.powerAssertContext.events
  12164. });
  12165. return arg.powerAssertContext.value;
  12166. });
  12167. return decorator.concreteAssert(callSpec, invocation, context);
  12168. } else {
  12169. return decorator.concreteAssert(callSpec, invocation);
  12170. }
  12171. };
  12172. }
  12173. function isNotCaptured (value) {
  12174. return !isCaptured(value);
  12175. }
  12176. function isCaptured (value) {
  12177. return (typeof value === 'object') &&
  12178. (value !== null) &&
  12179. (typeof value.powerAssertContext !== 'undefined');
  12180. }
  12181. module.exports = decorate;
  12182. },{"core-js/library/fn/array/map":18,"core-js/library/fn/array/some":21}],128:[function(_dereq_,module,exports){
  12183. 'use strict';
  12184. var forEach = _dereq_('core-js/library/fn/array/for-each');
  12185. var filter = _dereq_('core-js/library/fn/array/filter');
  12186. var map = _dereq_('core-js/library/fn/array/map');
  12187. var signature = _dereq_('call-signature');
  12188. var decorate = _dereq_('./decorate');
  12189. var keys = _dereq_('core-js/library/fn/object/keys');
  12190. function Decorator (receiver, config) {
  12191. this.receiver = receiver;
  12192. this.config = config;
  12193. this.onError = config.onError;
  12194. this.onSuccess = config.onSuccess;
  12195. this.signatures = map(config.patterns, parse);
  12196. this.wrapOnlySignatures = map(config.wrapOnlyPatterns, parse);
  12197. }
  12198. Decorator.prototype.enhancement = function () {
  12199. var that = this;
  12200. var container = this.container();
  12201. var wrappedMethods = [];
  12202. function attach(matcherSpec, enhanced) {
  12203. var matcher = matcherSpec.parsed;
  12204. var methodName = detectMethodName(matcher.callee);
  12205. if (typeof that.receiver[methodName] !== 'function' || wrappedMethods.indexOf(methodName) !== -1) {
  12206. return;
  12207. }
  12208. var callSpec = {
  12209. thisObj: that.receiver,
  12210. func: that.receiver[methodName],
  12211. numArgsToCapture: numberOfArgumentsToCapture(matcherSpec),
  12212. matcherSpec: matcherSpec,
  12213. enhanced: enhanced
  12214. };
  12215. container[methodName] = callSpec.enhancedFunc = decorate(callSpec, that);
  12216. wrappedMethods.push(methodName);
  12217. }
  12218. forEach(filter(this.signatures, methodCall), function (matcher) {
  12219. attach(matcher, true);
  12220. });
  12221. forEach(filter(this.wrapOnlySignatures, methodCall), function (matcher) {
  12222. attach(matcher, false);
  12223. });
  12224. return container;
  12225. };
  12226. Decorator.prototype.container = function () {
  12227. var basement = {};
  12228. if (typeof this.receiver === 'function') {
  12229. var candidates = filter(this.signatures, functionCall);
  12230. var enhanced = true;
  12231. if (candidates.length === 0) {
  12232. enhanced = false;
  12233. candidates = filter(this.wrapOnlySignatures, functionCall);
  12234. }
  12235. if (candidates.length === 1) {
  12236. var callSpec = {
  12237. thisObj: null,
  12238. func: this.receiver,
  12239. numArgsToCapture: numberOfArgumentsToCapture(candidates[0]),
  12240. matcherSpec: candidates[0],
  12241. enhanced: enhanced
  12242. };
  12243. basement = callSpec.enhancedFunc = decorate(callSpec, this);
  12244. }
  12245. }
  12246. return basement;
  12247. };
  12248. Decorator.prototype.concreteAssert = function (callSpec, invocation, context) {
  12249. var func = callSpec.func;
  12250. var thisObj = this.config.bindReceiver ? callSpec.thisObj : invocation.thisObj;
  12251. var enhanced = callSpec.enhanced;
  12252. var args = invocation.values;
  12253. var message = invocation.message;
  12254. var matcherSpec = callSpec.matcherSpec;
  12255. if (context && typeof this.config.modifyMessageBeforeAssert === 'function') {
  12256. message = this.config.modifyMessageBeforeAssert({originalMessage: message, powerAssertContext: context});
  12257. }
  12258. args = args.concat(message);
  12259. var data = {
  12260. thisObj: invocation.thisObj,
  12261. assertionFunction: callSpec.enhancedFunc,
  12262. originalMessage: message,
  12263. defaultMessage: matcherSpec.defaultMessage,
  12264. matcherSpec: matcherSpec,
  12265. enhanced: enhanced,
  12266. args: args
  12267. };
  12268. if (context) {
  12269. data.powerAssertContext = context;
  12270. }
  12271. return this._callFunc(func, thisObj, args, data);
  12272. };
  12273. // see: https://github.com/twada/empower-core/pull/8#issuecomment-173480982
  12274. Decorator.prototype._callFunc = function (func, thisObj, args, data) {
  12275. var ret;
  12276. try {
  12277. ret = func.apply(thisObj, args);
  12278. } catch (e) {
  12279. data.assertionThrew = true;
  12280. data.error = e;
  12281. return this.onError.call(thisObj, data);
  12282. }
  12283. data.assertionThrew = false;
  12284. data.returnValue = ret;
  12285. return this.onSuccess.call(thisObj, data);
  12286. };
  12287. function numberOfArgumentsToCapture (matcherSpec) {
  12288. var matcher = matcherSpec.parsed;
  12289. var len = matcher.args.length;
  12290. var lastArg;
  12291. if (0 < len) {
  12292. lastArg = matcher.args[len - 1];
  12293. if (lastArg.name === 'message' && lastArg.optional) {
  12294. len -= 1;
  12295. }
  12296. }
  12297. return len;
  12298. }
  12299. function detectMethodName (callee) {
  12300. if (callee.type === 'MemberExpression') {
  12301. return callee.member;
  12302. }
  12303. return null;
  12304. }
  12305. function functionCall (matcherSpec) {
  12306. return matcherSpec.parsed.callee.type === 'Identifier';
  12307. }
  12308. function methodCall (matcherSpec) {
  12309. return matcherSpec.parsed.callee.type === 'MemberExpression';
  12310. }
  12311. function parse(matcherSpec) {
  12312. if (typeof matcherSpec === 'string') {
  12313. matcherSpec = {pattern: matcherSpec};
  12314. }
  12315. var ret = {};
  12316. forEach(keys(matcherSpec), function (key) {
  12317. ret[key] = matcherSpec[key];
  12318. });
  12319. ret.parsed = signature.parse(matcherSpec.pattern);
  12320. return ret;
  12321. }
  12322. module.exports = Decorator;
  12323. },{"./decorate":127,"call-signature":13,"core-js/library/fn/array/filter":14,"core-js/library/fn/array/for-each":15,"core-js/library/fn/array/map":18,"core-js/library/fn/object/keys":26}],129:[function(_dereq_,module,exports){
  12324. 'use strict';
  12325. module.exports = function defaultOptions () {
  12326. return {
  12327. destructive: false,
  12328. bindReceiver: true,
  12329. onError: onError,
  12330. onSuccess: onSuccess,
  12331. patterns: [
  12332. 'assert(value, [message])',
  12333. 'assert.ok(value, [message])',
  12334. 'assert.equal(actual, expected, [message])',
  12335. 'assert.notEqual(actual, expected, [message])',
  12336. 'assert.strictEqual(actual, expected, [message])',
  12337. 'assert.notStrictEqual(actual, expected, [message])',
  12338. 'assert.deepEqual(actual, expected, [message])',
  12339. 'assert.notDeepEqual(actual, expected, [message])',
  12340. 'assert.deepStrictEqual(actual, expected, [message])',
  12341. 'assert.notDeepStrictEqual(actual, expected, [message])'
  12342. ],
  12343. wrapOnlyPatterns: []
  12344. };
  12345. };
  12346. function onError (errorEvent) {
  12347. var e = errorEvent.error;
  12348. if (errorEvent.powerAssertContext && /^AssertionError/.test(e.name)) {
  12349. e.powerAssertContext = errorEvent.powerAssertContext;
  12350. }
  12351. throw e;
  12352. }
  12353. function onSuccess(successEvent) {
  12354. return successEvent.returnValue;
  12355. }
  12356. },{}],130:[function(_dereq_,module,exports){
  12357. 'use strict';
  12358. var defineProperty = _dereq_('core-js/library/fn/object/define-property');
  12359. var forEach = _dereq_('core-js/library/fn/array/for-each');
  12360. var keys = _dereq_('core-js/library/fn/object/keys');
  12361. module.exports = function defineProperties (obj, map) {
  12362. forEach(keys(map), function (name) {
  12363. defineProperty(obj, name, {
  12364. configurable: true,
  12365. enumerable: false,
  12366. value: map[name],
  12367. writable: true
  12368. });
  12369. });
  12370. };
  12371. },{"core-js/library/fn/array/for-each":15,"core-js/library/fn/object/define-property":25,"core-js/library/fn/object/keys":26}],131:[function(_dereq_,module,exports){
  12372. /**
  12373. * empower - Power Assert feature enhancer for assert function/object.
  12374. *
  12375. * https://github.com/power-assert-js/empower
  12376. *
  12377. * Copyright (c) 2013-2018 Takuto Wada
  12378. * Licensed under the MIT license.
  12379. * https://github.com/power-assert-js/empower/blob/master/MIT-LICENSE.txt
  12380. */
  12381. var empowerCore = _dereq_('empower-core');
  12382. var defaultOptions = _dereq_('./lib/default-options');
  12383. var capturable = _dereq_('./lib/capturable');
  12384. var assign = _dereq_('core-js/library/fn/object/assign');
  12385. var define = _dereq_('./lib/define-properties');
  12386. /**
  12387. * Enhance Power Assert feature to assert function/object.
  12388. * @param assert target assert function or object to enhance
  12389. * @param formatter power assert format function
  12390. * @param options enhancement options
  12391. * @return enhanced assert function/object
  12392. */
  12393. function empower (assert, formatter, options) {
  12394. var config = assign(defaultOptions(), options);
  12395. var eagerEvaluation = !(config.modifyMessageOnRethrow || config.saveContextOnRethrow);
  12396. // see: https://github.com/power-assert-js/empower/pull/26
  12397. var shouldRecreateAssertionError = (function isStackUnchanged () {
  12398. if (typeof assert !== 'function') {
  12399. return false;
  12400. }
  12401. if (typeof assert.AssertionError !== 'function') {
  12402. return false;
  12403. }
  12404. var ae = new assert.AssertionError({
  12405. actual: 123,
  12406. expected: 456,
  12407. operator: '==='
  12408. });
  12409. ae.message = '[REPLACED MESSAGE]';
  12410. return !(/REPLACED MESSAGE/.test(ae.stack)) && /123 === 456/.test(ae.stack);
  12411. })();
  12412. var empowerCoreConfig = assign(config, {
  12413. modifyMessageBeforeAssert: function (beforeAssertEvent) {
  12414. var message = beforeAssertEvent.originalMessage;
  12415. if (!eagerEvaluation) {
  12416. return message;
  12417. }
  12418. return buildPowerAssertText(formatter, message, beforeAssertEvent.powerAssertContext);
  12419. },
  12420. onError: function onError (errorEvent) {
  12421. var e = errorEvent.error;
  12422. if (!/^AssertionError/.test(e.name)) {
  12423. throw e;
  12424. }
  12425. if (!errorEvent.powerAssertContext) {
  12426. throw e;
  12427. }
  12428. var poweredMessage;
  12429. if (config.modifyMessageOnRethrow || config.saveContextOnRethrow) {
  12430. poweredMessage = buildPowerAssertText(formatter, errorEvent.originalMessage, errorEvent.powerAssertContext);
  12431. if (shouldRecreateAssertionError) {
  12432. e = new assert.AssertionError({
  12433. message: poweredMessage,
  12434. actual: e.actual,
  12435. expected: e.expected,
  12436. operator: e.operator,
  12437. stackStartFunction: e.stackStartFunction || onError
  12438. });
  12439. e.generatedMessage = false;
  12440. }
  12441. }
  12442. if (config.modifyMessageOnRethrow && !shouldRecreateAssertionError) {
  12443. e.message = poweredMessage;
  12444. e.generatedMessage = false;
  12445. }
  12446. if (config.saveContextOnRethrow) {
  12447. e.powerAssertContext = errorEvent.powerAssertContext;
  12448. }
  12449. throw e;
  12450. }
  12451. });
  12452. var enhancedAssert = empowerCore(assert, empowerCoreConfig);
  12453. define(enhancedAssert, capturable());
  12454. return enhancedAssert;
  12455. }
  12456. function buildPowerAssertText (formatter, message, context) {
  12457. // console.log(message);
  12458. var powerAssertText = formatter(context);
  12459. return message ? message + ' ' + powerAssertText : powerAssertText;
  12460. };
  12461. empower.defaultOptions = defaultOptions;
  12462. module.exports = empower;
  12463. },{"./lib/capturable":132,"./lib/default-options":133,"./lib/define-properties":134,"core-js/library/fn/object/assign":23,"empower-core":126}],132:[function(_dereq_,module,exports){
  12464. 'use strict';
  12465. module.exports = function capturable () {
  12466. var events = [];
  12467. function _capt (value, espath) {
  12468. events.push({value: value, espath: espath});
  12469. return value;
  12470. }
  12471. function _expr (value, args) {
  12472. var captured = events;
  12473. events = [];
  12474. var source = {
  12475. content: args.content,
  12476. filepath: args.filepath,
  12477. line: args.line
  12478. };
  12479. if (args.generator) {
  12480. source.generator = true;
  12481. }
  12482. if (args.async) {
  12483. source.async = true;
  12484. }
  12485. return {
  12486. powerAssertContext: {
  12487. value: value,
  12488. events: captured
  12489. },
  12490. source: source
  12491. };
  12492. }
  12493. return {
  12494. _capt: _capt,
  12495. _expr: _expr
  12496. };
  12497. };
  12498. },{}],133:[function(_dereq_,module,exports){
  12499. 'use strict';
  12500. var empowerCore = _dereq_('empower-core');
  12501. var assign = _dereq_('core-js/library/fn/object/assign');
  12502. module.exports = function defaultOptions () {
  12503. return assign(empowerCore.defaultOptions(), {
  12504. modifyMessageOnRethrow: false,
  12505. saveContextOnRethrow: false
  12506. });
  12507. };
  12508. },{"core-js/library/fn/object/assign":23,"empower-core":126}],134:[function(_dereq_,module,exports){
  12509. arguments[4][130][0].apply(exports,arguments)
  12510. },{"core-js/library/fn/array/for-each":15,"core-js/library/fn/object/define-property":25,"core-js/library/fn/object/keys":26,"dup":130}],135:[function(_dereq_,module,exports){
  12511. /**
  12512. * espurify - Clone new AST without extra properties
  12513. *
  12514. * https://github.com/estools/espurify
  12515. *
  12516. * Copyright (c) 2014-2018 Takuto Wada
  12517. * Licensed under the MIT license.
  12518. * https://github.com/estools/espurify/blob/master/MIT-LICENSE.txt
  12519. */
  12520. 'use strict';
  12521. var createWhitelist = _dereq_('./lib/create-whitelist');
  12522. var cloneWithWhitelist = _dereq_('./lib/clone-ast');
  12523. function createCloneFunction (options) {
  12524. return cloneWithWhitelist(createWhitelist(options));
  12525. }
  12526. var espurify = createCloneFunction();
  12527. espurify.customize = createCloneFunction;
  12528. espurify.cloneWithWhitelist = cloneWithWhitelist;
  12529. module.exports = espurify;
  12530. },{"./lib/clone-ast":137,"./lib/create-whitelist":138}],136:[function(_dereq_,module,exports){
  12531. module.exports = {
  12532. ArrayExpression: ['type', 'elements'],
  12533. ArrayPattern: ['type', 'elements'],
  12534. ArrowFunctionExpression: ['type', 'id', 'params', 'body', 'generator', 'expression', 'async'],
  12535. AssignmentExpression: ['type', 'operator', 'left', 'right'],
  12536. AssignmentPattern: ['type', 'left', 'right'],
  12537. AwaitExpression: ['type', 'argument'],
  12538. BinaryExpression: ['type', 'operator', 'left', 'right'],
  12539. BlockStatement: ['type', 'body'],
  12540. BreakStatement: ['type', 'label'],
  12541. CallExpression: ['type', 'callee', 'arguments'],
  12542. CatchClause: ['type', 'param', 'guard', 'body'],
  12543. ClassBody: ['type', 'body'],
  12544. ClassDeclaration: ['type', 'id', 'superClass', 'body'],
  12545. ClassExpression: ['type', 'id', 'superClass', 'body'],
  12546. ConditionalExpression: ['type', 'test', 'consequent', 'alternate'],
  12547. ContinueStatement: ['type', 'label'],
  12548. DebuggerStatement: ['type'],
  12549. DoWhileStatement: ['type', 'body', 'test'],
  12550. EmptyStatement: ['type'],
  12551. ExportAllDeclaration: ['type', 'source'],
  12552. ExportDefaultDeclaration: ['type', 'declaration'],
  12553. ExportNamedDeclaration: ['type', 'declaration', 'specifiers', 'source'],
  12554. ExportSpecifier: ['type', 'exported', 'local'],
  12555. ExpressionStatement: ['type', 'expression'],
  12556. ForInStatement: ['type', 'left', 'right', 'body'],
  12557. ForOfStatement: ['type', 'left', 'right', 'body', 'await'],
  12558. ForStatement: ['type', 'init', 'test', 'update', 'body'],
  12559. FunctionDeclaration: ['type', 'id', 'params', 'body', 'generator', 'async'],
  12560. FunctionExpression: ['type', 'id', 'params', 'body', 'generator', 'async'],
  12561. Identifier: ['type', 'name'],
  12562. IfStatement: ['type', 'test', 'consequent', 'alternate'],
  12563. ImportDeclaration: ['type', 'specifiers', 'source'],
  12564. ImportDefaultSpecifier: ['type', 'local'],
  12565. ImportNamespaceSpecifier: ['type', 'local'],
  12566. ImportSpecifier: ['type', 'imported', 'local'],
  12567. LabeledStatement: ['type', 'label', 'body'],
  12568. Literal: ['type', 'value', 'regex'],
  12569. LogicalExpression: ['type', 'operator', 'left', 'right'],
  12570. MemberExpression: ['type', 'object', 'property', 'computed'],
  12571. MetaProperty: ['type', 'meta', 'property'],
  12572. MethodDefinition: ['type', 'key', 'value', 'kind', 'computed', 'static'],
  12573. NewExpression: ['type', 'callee', 'arguments'],
  12574. ObjectExpression: ['type', 'properties'],
  12575. ObjectPattern: ['type', 'properties'],
  12576. Program: ['type', 'body', 'sourceType'],
  12577. Property: ['type', 'key', 'value', 'kind', 'method', 'shorthand', 'computed'],
  12578. RestElement: ['type', 'argument'],
  12579. ReturnStatement: ['type', 'argument'],
  12580. SequenceExpression: ['type', 'expressions'],
  12581. SpreadElement: ['type', 'argument'],
  12582. Super: ['type'],
  12583. SwitchCase: ['type', 'test', 'consequent'],
  12584. SwitchStatement: ['type', 'discriminant', 'cases', 'lexical'],
  12585. TaggedTemplateExpression: ['type', 'tag', 'quasi'],
  12586. TemplateElement: ['type', 'tail', 'value'],
  12587. TemplateLiteral: ['type', 'quasis', 'expressions'],
  12588. ThisExpression: ['type'],
  12589. ThrowStatement: ['type', 'argument'],
  12590. TryStatement: ['type', 'block', 'handler', 'finalizer'],
  12591. UnaryExpression: ['type', 'operator', 'prefix', 'argument'],
  12592. UpdateExpression: ['type', 'operator', 'argument', 'prefix'],
  12593. VariableDeclaration: ['type', 'declarations', 'kind'],
  12594. VariableDeclarator: ['type', 'id', 'init'],
  12595. WhileStatement: ['type', 'test', 'body'],
  12596. WithStatement: ['type', 'object', 'body'],
  12597. YieldExpression: ['type', 'argument', 'delegate']
  12598. };
  12599. },{}],137:[function(_dereq_,module,exports){
  12600. 'use strict';
  12601. var isArray = _dereq_('core-js/library/fn/array/is-array');
  12602. var objectKeys = _dereq_('core-js/library/fn/object/keys');
  12603. var indexOf = _dereq_('core-js/library/fn/array/index-of');
  12604. var Map = _dereq_('core-js/library/fn/map');
  12605. var reduce = _dereq_('core-js/library/fn/array/reduce');
  12606. module.exports = function cloneWithWhitelist (astWhiteList) {
  12607. var whitelist = reduce(objectKeys(astWhiteList), function (props, key) {
  12608. var propNames = astWhiteList[key];
  12609. var prepend = (indexOf(propNames, 'type') === -1) ? ['type'] : [];
  12610. props[key] = prepend.concat(propNames || []);
  12611. return props;
  12612. }, {});
  12613. function cloneNodeOrObject (obj, seen) {
  12614. var props = obj.type ? whitelist[obj.type] : null;
  12615. if (props) {
  12616. return cloneNode(obj, props, seen);
  12617. } else {
  12618. return cloneObject(obj, seen);
  12619. }
  12620. }
  12621. function cloneArray (ary, seen) {
  12622. var i = ary.length;
  12623. var clone = [];
  12624. while (i--) {
  12625. clone[i] = cloneOf(ary[i], seen);
  12626. }
  12627. return clone;
  12628. }
  12629. function cloneNode (node, props, seen) {
  12630. var i, len, key;
  12631. var clone = {};
  12632. for (i = 0, len = props.length; i < len; i += 1) {
  12633. key = props[i];
  12634. if (node.hasOwnProperty(key)) {
  12635. clone[key] = cloneOf(node[key], seen);
  12636. }
  12637. }
  12638. return clone;
  12639. }
  12640. function cloneObject (obj, seen) {
  12641. var props = objectKeys(obj);
  12642. var i, len, key, value;
  12643. var clone = {};
  12644. for (i = 0, len = props.length; i < len; i += 1) {
  12645. key = props[i];
  12646. value = obj[key];
  12647. if (seen.has(value)) {
  12648. continue;
  12649. }
  12650. clone[key] = cloneOf(value, seen);
  12651. }
  12652. return clone;
  12653. }
  12654. function cloneOf (val, seen) {
  12655. if (typeof val === 'object' && val !== null) {
  12656. seen.set(val, true);
  12657. if (val instanceof RegExp) {
  12658. return new RegExp(val);
  12659. } else if (isArray(val)) {
  12660. return cloneArray(val, seen);
  12661. } else {
  12662. return cloneNodeOrObject(val, seen);
  12663. }
  12664. } else {
  12665. return val;
  12666. }
  12667. }
  12668. function cloneRoot (obj) {
  12669. var seen = new Map();
  12670. seen.set(obj, true);
  12671. return cloneNodeOrObject(obj, seen);
  12672. }
  12673. return cloneRoot;
  12674. };
  12675. },{"core-js/library/fn/array/index-of":16,"core-js/library/fn/array/is-array":17,"core-js/library/fn/array/reduce":20,"core-js/library/fn/map":22,"core-js/library/fn/object/keys":26}],138:[function(_dereq_,module,exports){
  12676. 'use strict';
  12677. var defaultProps = _dereq_('./ast-properties');
  12678. var objectKeys = _dereq_('core-js/library/fn/object/keys');
  12679. var assign = _dereq_('core-js/library/fn/object/assign');
  12680. module.exports = function createWhitelist (options) {
  12681. var opts = assign({}, options);
  12682. var typeName, i, len;
  12683. var keys = objectKeys(defaultProps);
  12684. var result = {};
  12685. for (i = 0, len = keys.length; i < len; i += 1) {
  12686. typeName = keys[i];
  12687. result[typeName] = defaultProps[typeName].concat(opts.extra || []);
  12688. }
  12689. return result;
  12690. };
  12691. },{"./ast-properties":136,"core-js/library/fn/object/assign":23,"core-js/library/fn/object/keys":26}],139:[function(_dereq_,module,exports){
  12692. /*
  12693. Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
  12694. Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
  12695. Redistribution and use in source and binary forms, with or without
  12696. modification, are permitted provided that the following conditions are met:
  12697. * Redistributions of source code must retain the above copyright
  12698. notice, this list of conditions and the following disclaimer.
  12699. * Redistributions in binary form must reproduce the above copyright
  12700. notice, this list of conditions and the following disclaimer in the
  12701. documentation and/or other materials provided with the distribution.
  12702. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  12703. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12704. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  12705. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  12706. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12707. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12708. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12709. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12710. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  12711. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12712. */
  12713. /*jslint vars:false, bitwise:true*/
  12714. /*jshint indent:4*/
  12715. /*global exports:true*/
  12716. (function clone(exports) {
  12717. 'use strict';
  12718. var Syntax,
  12719. isArray,
  12720. VisitorOption,
  12721. VisitorKeys,
  12722. objectCreate,
  12723. objectKeys,
  12724. BREAK,
  12725. SKIP,
  12726. REMOVE;
  12727. function ignoreJSHintError() { }
  12728. isArray = Array.isArray;
  12729. if (!isArray) {
  12730. isArray = function isArray(array) {
  12731. return Object.prototype.toString.call(array) === '[object Array]';
  12732. };
  12733. }
  12734. function deepCopy(obj) {
  12735. var ret = {}, key, val;
  12736. for (key in obj) {
  12737. if (obj.hasOwnProperty(key)) {
  12738. val = obj[key];
  12739. if (typeof val === 'object' && val !== null) {
  12740. ret[key] = deepCopy(val);
  12741. } else {
  12742. ret[key] = val;
  12743. }
  12744. }
  12745. }
  12746. return ret;
  12747. }
  12748. function shallowCopy(obj) {
  12749. var ret = {}, key;
  12750. for (key in obj) {
  12751. if (obj.hasOwnProperty(key)) {
  12752. ret[key] = obj[key];
  12753. }
  12754. }
  12755. return ret;
  12756. }
  12757. ignoreJSHintError(shallowCopy);
  12758. // based on LLVM libc++ upper_bound / lower_bound
  12759. // MIT License
  12760. function upperBound(array, func) {
  12761. var diff, len, i, current;
  12762. len = array.length;
  12763. i = 0;
  12764. while (len) {
  12765. diff = len >>> 1;
  12766. current = i + diff;
  12767. if (func(array[current])) {
  12768. len = diff;
  12769. } else {
  12770. i = current + 1;
  12771. len -= diff + 1;
  12772. }
  12773. }
  12774. return i;
  12775. }
  12776. function lowerBound(array, func) {
  12777. var diff, len, i, current;
  12778. len = array.length;
  12779. i = 0;
  12780. while (len) {
  12781. diff = len >>> 1;
  12782. current = i + diff;
  12783. if (func(array[current])) {
  12784. i = current + 1;
  12785. len -= diff + 1;
  12786. } else {
  12787. len = diff;
  12788. }
  12789. }
  12790. return i;
  12791. }
  12792. ignoreJSHintError(lowerBound);
  12793. objectCreate = Object.create || (function () {
  12794. function F() { }
  12795. return function (o) {
  12796. F.prototype = o;
  12797. return new F();
  12798. };
  12799. })();
  12800. objectKeys = Object.keys || function (o) {
  12801. var keys = [], key;
  12802. for (key in o) {
  12803. keys.push(key);
  12804. }
  12805. return keys;
  12806. };
  12807. function extend(to, from) {
  12808. var keys = objectKeys(from), key, i, len;
  12809. for (i = 0, len = keys.length; i < len; i += 1) {
  12810. key = keys[i];
  12811. to[key] = from[key];
  12812. }
  12813. return to;
  12814. }
  12815. Syntax = {
  12816. AssignmentExpression: 'AssignmentExpression',
  12817. AssignmentPattern: 'AssignmentPattern',
  12818. ArrayExpression: 'ArrayExpression',
  12819. ArrayPattern: 'ArrayPattern',
  12820. ArrowFunctionExpression: 'ArrowFunctionExpression',
  12821. AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
  12822. BlockStatement: 'BlockStatement',
  12823. BinaryExpression: 'BinaryExpression',
  12824. BreakStatement: 'BreakStatement',
  12825. CallExpression: 'CallExpression',
  12826. CatchClause: 'CatchClause',
  12827. ClassBody: 'ClassBody',
  12828. ClassDeclaration: 'ClassDeclaration',
  12829. ClassExpression: 'ClassExpression',
  12830. ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
  12831. ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
  12832. ConditionalExpression: 'ConditionalExpression',
  12833. ContinueStatement: 'ContinueStatement',
  12834. DebuggerStatement: 'DebuggerStatement',
  12835. DirectiveStatement: 'DirectiveStatement',
  12836. DoWhileStatement: 'DoWhileStatement',
  12837. EmptyStatement: 'EmptyStatement',
  12838. ExportAllDeclaration: 'ExportAllDeclaration',
  12839. ExportDefaultDeclaration: 'ExportDefaultDeclaration',
  12840. ExportNamedDeclaration: 'ExportNamedDeclaration',
  12841. ExportSpecifier: 'ExportSpecifier',
  12842. ExpressionStatement: 'ExpressionStatement',
  12843. ForStatement: 'ForStatement',
  12844. ForInStatement: 'ForInStatement',
  12845. ForOfStatement: 'ForOfStatement',
  12846. FunctionDeclaration: 'FunctionDeclaration',
  12847. FunctionExpression: 'FunctionExpression',
  12848. GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
  12849. Identifier: 'Identifier',
  12850. IfStatement: 'IfStatement',
  12851. ImportDeclaration: 'ImportDeclaration',
  12852. ImportDefaultSpecifier: 'ImportDefaultSpecifier',
  12853. ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
  12854. ImportSpecifier: 'ImportSpecifier',
  12855. Literal: 'Literal',
  12856. LabeledStatement: 'LabeledStatement',
  12857. LogicalExpression: 'LogicalExpression',
  12858. MemberExpression: 'MemberExpression',
  12859. MetaProperty: 'MetaProperty',
  12860. MethodDefinition: 'MethodDefinition',
  12861. ModuleSpecifier: 'ModuleSpecifier',
  12862. NewExpression: 'NewExpression',
  12863. ObjectExpression: 'ObjectExpression',
  12864. ObjectPattern: 'ObjectPattern',
  12865. Program: 'Program',
  12866. Property: 'Property',
  12867. RestElement: 'RestElement',
  12868. ReturnStatement: 'ReturnStatement',
  12869. SequenceExpression: 'SequenceExpression',
  12870. SpreadElement: 'SpreadElement',
  12871. Super: 'Super',
  12872. SwitchStatement: 'SwitchStatement',
  12873. SwitchCase: 'SwitchCase',
  12874. TaggedTemplateExpression: 'TaggedTemplateExpression',
  12875. TemplateElement: 'TemplateElement',
  12876. TemplateLiteral: 'TemplateLiteral',
  12877. ThisExpression: 'ThisExpression',
  12878. ThrowStatement: 'ThrowStatement',
  12879. TryStatement: 'TryStatement',
  12880. UnaryExpression: 'UnaryExpression',
  12881. UpdateExpression: 'UpdateExpression',
  12882. VariableDeclaration: 'VariableDeclaration',
  12883. VariableDeclarator: 'VariableDeclarator',
  12884. WhileStatement: 'WhileStatement',
  12885. WithStatement: 'WithStatement',
  12886. YieldExpression: 'YieldExpression'
  12887. };
  12888. VisitorKeys = {
  12889. AssignmentExpression: ['left', 'right'],
  12890. AssignmentPattern: ['left', 'right'],
  12891. ArrayExpression: ['elements'],
  12892. ArrayPattern: ['elements'],
  12893. ArrowFunctionExpression: ['params', 'body'],
  12894. AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
  12895. BlockStatement: ['body'],
  12896. BinaryExpression: ['left', 'right'],
  12897. BreakStatement: ['label'],
  12898. CallExpression: ['callee', 'arguments'],
  12899. CatchClause: ['param', 'body'],
  12900. ClassBody: ['body'],
  12901. ClassDeclaration: ['id', 'superClass', 'body'],
  12902. ClassExpression: ['id', 'superClass', 'body'],
  12903. ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
  12904. ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
  12905. ConditionalExpression: ['test', 'consequent', 'alternate'],
  12906. ContinueStatement: ['label'],
  12907. DebuggerStatement: [],
  12908. DirectiveStatement: [],
  12909. DoWhileStatement: ['body', 'test'],
  12910. EmptyStatement: [],
  12911. ExportAllDeclaration: ['source'],
  12912. ExportDefaultDeclaration: ['declaration'],
  12913. ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
  12914. ExportSpecifier: ['exported', 'local'],
  12915. ExpressionStatement: ['expression'],
  12916. ForStatement: ['init', 'test', 'update', 'body'],
  12917. ForInStatement: ['left', 'right', 'body'],
  12918. ForOfStatement: ['left', 'right', 'body'],
  12919. FunctionDeclaration: ['id', 'params', 'body'],
  12920. FunctionExpression: ['id', 'params', 'body'],
  12921. GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
  12922. Identifier: [],
  12923. IfStatement: ['test', 'consequent', 'alternate'],
  12924. ImportDeclaration: ['specifiers', 'source'],
  12925. ImportDefaultSpecifier: ['local'],
  12926. ImportNamespaceSpecifier: ['local'],
  12927. ImportSpecifier: ['imported', 'local'],
  12928. Literal: [],
  12929. LabeledStatement: ['label', 'body'],
  12930. LogicalExpression: ['left', 'right'],
  12931. MemberExpression: ['object', 'property'],
  12932. MetaProperty: ['meta', 'property'],
  12933. MethodDefinition: ['key', 'value'],
  12934. ModuleSpecifier: [],
  12935. NewExpression: ['callee', 'arguments'],
  12936. ObjectExpression: ['properties'],
  12937. ObjectPattern: ['properties'],
  12938. Program: ['body'],
  12939. Property: ['key', 'value'],
  12940. RestElement: [ 'argument' ],
  12941. ReturnStatement: ['argument'],
  12942. SequenceExpression: ['expressions'],
  12943. SpreadElement: ['argument'],
  12944. Super: [],
  12945. SwitchStatement: ['discriminant', 'cases'],
  12946. SwitchCase: ['test', 'consequent'],
  12947. TaggedTemplateExpression: ['tag', 'quasi'],
  12948. TemplateElement: [],
  12949. TemplateLiteral: ['quasis', 'expressions'],
  12950. ThisExpression: [],
  12951. ThrowStatement: ['argument'],
  12952. TryStatement: ['block', 'handler', 'finalizer'],
  12953. UnaryExpression: ['argument'],
  12954. UpdateExpression: ['argument'],
  12955. VariableDeclaration: ['declarations'],
  12956. VariableDeclarator: ['id', 'init'],
  12957. WhileStatement: ['test', 'body'],
  12958. WithStatement: ['object', 'body'],
  12959. YieldExpression: ['argument']
  12960. };
  12961. // unique id
  12962. BREAK = {};
  12963. SKIP = {};
  12964. REMOVE = {};
  12965. VisitorOption = {
  12966. Break: BREAK,
  12967. Skip: SKIP,
  12968. Remove: REMOVE
  12969. };
  12970. function Reference(parent, key) {
  12971. this.parent = parent;
  12972. this.key = key;
  12973. }
  12974. Reference.prototype.replace = function replace(node) {
  12975. this.parent[this.key] = node;
  12976. };
  12977. Reference.prototype.remove = function remove() {
  12978. if (isArray(this.parent)) {
  12979. this.parent.splice(this.key, 1);
  12980. return true;
  12981. } else {
  12982. this.replace(null);
  12983. return false;
  12984. }
  12985. };
  12986. function Element(node, path, wrap, ref) {
  12987. this.node = node;
  12988. this.path = path;
  12989. this.wrap = wrap;
  12990. this.ref = ref;
  12991. }
  12992. function Controller() { }
  12993. // API:
  12994. // return property path array from root to current node
  12995. Controller.prototype.path = function path() {
  12996. var i, iz, j, jz, result, element;
  12997. function addToPath(result, path) {
  12998. if (isArray(path)) {
  12999. for (j = 0, jz = path.length; j < jz; ++j) {
  13000. result.push(path[j]);
  13001. }
  13002. } else {
  13003. result.push(path);
  13004. }
  13005. }
  13006. // root node
  13007. if (!this.__current.path) {
  13008. return null;
  13009. }
  13010. // first node is sentinel, second node is root element
  13011. result = [];
  13012. for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
  13013. element = this.__leavelist[i];
  13014. addToPath(result, element.path);
  13015. }
  13016. addToPath(result, this.__current.path);
  13017. return result;
  13018. };
  13019. // API:
  13020. // return type of current node
  13021. Controller.prototype.type = function () {
  13022. var node = this.current();
  13023. return node.type || this.__current.wrap;
  13024. };
  13025. // API:
  13026. // return array of parent elements
  13027. Controller.prototype.parents = function parents() {
  13028. var i, iz, result;
  13029. // first node is sentinel
  13030. result = [];
  13031. for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
  13032. result.push(this.__leavelist[i].node);
  13033. }
  13034. return result;
  13035. };
  13036. // API:
  13037. // return current node
  13038. Controller.prototype.current = function current() {
  13039. return this.__current.node;
  13040. };
  13041. Controller.prototype.__execute = function __execute(callback, element) {
  13042. var previous, result;
  13043. result = undefined;
  13044. previous = this.__current;
  13045. this.__current = element;
  13046. this.__state = null;
  13047. if (callback) {
  13048. result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
  13049. }
  13050. this.__current = previous;
  13051. return result;
  13052. };
  13053. // API:
  13054. // notify control skip / break
  13055. Controller.prototype.notify = function notify(flag) {
  13056. this.__state = flag;
  13057. };
  13058. // API:
  13059. // skip child nodes of current node
  13060. Controller.prototype.skip = function () {
  13061. this.notify(SKIP);
  13062. };
  13063. // API:
  13064. // break traversals
  13065. Controller.prototype['break'] = function () {
  13066. this.notify(BREAK);
  13067. };
  13068. // API:
  13069. // remove node
  13070. Controller.prototype.remove = function () {
  13071. this.notify(REMOVE);
  13072. };
  13073. Controller.prototype.__initialize = function(root, visitor) {
  13074. this.visitor = visitor;
  13075. this.root = root;
  13076. this.__worklist = [];
  13077. this.__leavelist = [];
  13078. this.__current = null;
  13079. this.__state = null;
  13080. this.__fallback = null;
  13081. if (visitor.fallback === 'iteration') {
  13082. this.__fallback = objectKeys;
  13083. } else if (typeof visitor.fallback === 'function') {
  13084. this.__fallback = visitor.fallback;
  13085. }
  13086. this.__keys = VisitorKeys;
  13087. if (visitor.keys) {
  13088. this.__keys = extend(objectCreate(this.__keys), visitor.keys);
  13089. }
  13090. };
  13091. function isNode(node) {
  13092. if (node == null) {
  13093. return false;
  13094. }
  13095. return typeof node === 'object' && typeof node.type === 'string';
  13096. }
  13097. function isProperty(nodeType, key) {
  13098. return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
  13099. }
  13100. Controller.prototype.traverse = function traverse(root, visitor) {
  13101. var worklist,
  13102. leavelist,
  13103. element,
  13104. node,
  13105. nodeType,
  13106. ret,
  13107. key,
  13108. current,
  13109. current2,
  13110. candidates,
  13111. candidate,
  13112. sentinel;
  13113. this.__initialize(root, visitor);
  13114. sentinel = {};
  13115. // reference
  13116. worklist = this.__worklist;
  13117. leavelist = this.__leavelist;
  13118. // initialize
  13119. worklist.push(new Element(root, null, null, null));
  13120. leavelist.push(new Element(null, null, null, null));
  13121. while (worklist.length) {
  13122. element = worklist.pop();
  13123. if (element === sentinel) {
  13124. element = leavelist.pop();
  13125. ret = this.__execute(visitor.leave, element);
  13126. if (this.__state === BREAK || ret === BREAK) {
  13127. return;
  13128. }
  13129. continue;
  13130. }
  13131. if (element.node) {
  13132. ret = this.__execute(visitor.enter, element);
  13133. if (this.__state === BREAK || ret === BREAK) {
  13134. return;
  13135. }
  13136. worklist.push(sentinel);
  13137. leavelist.push(element);
  13138. if (this.__state === SKIP || ret === SKIP) {
  13139. continue;
  13140. }
  13141. node = element.node;
  13142. nodeType = node.type || element.wrap;
  13143. candidates = this.__keys[nodeType];
  13144. if (!candidates) {
  13145. if (this.__fallback) {
  13146. candidates = this.__fallback(node);
  13147. } else {
  13148. throw new Error('Unknown node type ' + nodeType + '.');
  13149. }
  13150. }
  13151. current = candidates.length;
  13152. while ((current -= 1) >= 0) {
  13153. key = candidates[current];
  13154. candidate = node[key];
  13155. if (!candidate) {
  13156. continue;
  13157. }
  13158. if (isArray(candidate)) {
  13159. current2 = candidate.length;
  13160. while ((current2 -= 1) >= 0) {
  13161. if (!candidate[current2]) {
  13162. continue;
  13163. }
  13164. if (isProperty(nodeType, candidates[current])) {
  13165. element = new Element(candidate[current2], [key, current2], 'Property', null);
  13166. } else if (isNode(candidate[current2])) {
  13167. element = new Element(candidate[current2], [key, current2], null, null);
  13168. } else {
  13169. continue;
  13170. }
  13171. worklist.push(element);
  13172. }
  13173. } else if (isNode(candidate)) {
  13174. worklist.push(new Element(candidate, key, null, null));
  13175. }
  13176. }
  13177. }
  13178. }
  13179. };
  13180. Controller.prototype.replace = function replace(root, visitor) {
  13181. var worklist,
  13182. leavelist,
  13183. node,
  13184. nodeType,
  13185. target,
  13186. element,
  13187. current,
  13188. current2,
  13189. candidates,
  13190. candidate,
  13191. sentinel,
  13192. outer,
  13193. key;
  13194. function removeElem(element) {
  13195. var i,
  13196. key,
  13197. nextElem,
  13198. parent;
  13199. if (element.ref.remove()) {
  13200. // When the reference is an element of an array.
  13201. key = element.ref.key;
  13202. parent = element.ref.parent;
  13203. // If removed from array, then decrease following items' keys.
  13204. i = worklist.length;
  13205. while (i--) {
  13206. nextElem = worklist[i];
  13207. if (nextElem.ref && nextElem.ref.parent === parent) {
  13208. if (nextElem.ref.key < key) {
  13209. break;
  13210. }
  13211. --nextElem.ref.key;
  13212. }
  13213. }
  13214. }
  13215. }
  13216. this.__initialize(root, visitor);
  13217. sentinel = {};
  13218. // reference
  13219. worklist = this.__worklist;
  13220. leavelist = this.__leavelist;
  13221. // initialize
  13222. outer = {
  13223. root: root
  13224. };
  13225. element = new Element(root, null, null, new Reference(outer, 'root'));
  13226. worklist.push(element);
  13227. leavelist.push(element);
  13228. while (worklist.length) {
  13229. element = worklist.pop();
  13230. if (element === sentinel) {
  13231. element = leavelist.pop();
  13232. target = this.__execute(visitor.leave, element);
  13233. // node may be replaced with null,
  13234. // so distinguish between undefined and null in this place
  13235. if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
  13236. // replace
  13237. element.ref.replace(target);
  13238. }
  13239. if (this.__state === REMOVE || target === REMOVE) {
  13240. removeElem(element);
  13241. }
  13242. if (this.__state === BREAK || target === BREAK) {
  13243. return outer.root;
  13244. }
  13245. continue;
  13246. }
  13247. target = this.__execute(visitor.enter, element);
  13248. // node may be replaced with null,
  13249. // so distinguish between undefined and null in this place
  13250. if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
  13251. // replace
  13252. element.ref.replace(target);
  13253. element.node = target;
  13254. }
  13255. if (this.__state === REMOVE || target === REMOVE) {
  13256. removeElem(element);
  13257. element.node = null;
  13258. }
  13259. if (this.__state === BREAK || target === BREAK) {
  13260. return outer.root;
  13261. }
  13262. // node may be null
  13263. node = element.node;
  13264. if (!node) {
  13265. continue;
  13266. }
  13267. worklist.push(sentinel);
  13268. leavelist.push(element);
  13269. if (this.__state === SKIP || target === SKIP) {
  13270. continue;
  13271. }
  13272. nodeType = node.type || element.wrap;
  13273. candidates = this.__keys[nodeType];
  13274. if (!candidates) {
  13275. if (this.__fallback) {
  13276. candidates = this.__fallback(node);
  13277. } else {
  13278. throw new Error('Unknown node type ' + nodeType + '.');
  13279. }
  13280. }
  13281. current = candidates.length;
  13282. while ((current -= 1) >= 0) {
  13283. key = candidates[current];
  13284. candidate = node[key];
  13285. if (!candidate) {
  13286. continue;
  13287. }
  13288. if (isArray(candidate)) {
  13289. current2 = candidate.length;
  13290. while ((current2 -= 1) >= 0) {
  13291. if (!candidate[current2]) {
  13292. continue;
  13293. }
  13294. if (isProperty(nodeType, candidates[current])) {
  13295. element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
  13296. } else if (isNode(candidate[current2])) {
  13297. element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
  13298. } else {
  13299. continue;
  13300. }
  13301. worklist.push(element);
  13302. }
  13303. } else if (isNode(candidate)) {
  13304. worklist.push(new Element(candidate, key, null, new Reference(node, key)));
  13305. }
  13306. }
  13307. }
  13308. return outer.root;
  13309. };
  13310. function traverse(root, visitor) {
  13311. var controller = new Controller();
  13312. return controller.traverse(root, visitor);
  13313. }
  13314. function replace(root, visitor) {
  13315. var controller = new Controller();
  13316. return controller.replace(root, visitor);
  13317. }
  13318. function extendCommentRange(comment, tokens) {
  13319. var target;
  13320. target = upperBound(tokens, function search(token) {
  13321. return token.range[0] > comment.range[0];
  13322. });
  13323. comment.extendedRange = [comment.range[0], comment.range[1]];
  13324. if (target !== tokens.length) {
  13325. comment.extendedRange[1] = tokens[target].range[0];
  13326. }
  13327. target -= 1;
  13328. if (target >= 0) {
  13329. comment.extendedRange[0] = tokens[target].range[1];
  13330. }
  13331. return comment;
  13332. }
  13333. function attachComments(tree, providedComments, tokens) {
  13334. // At first, we should calculate extended comment ranges.
  13335. var comments = [], comment, len, i, cursor;
  13336. if (!tree.range) {
  13337. throw new Error('attachComments needs range information');
  13338. }
  13339. // tokens array is empty, we attach comments to tree as 'leadingComments'
  13340. if (!tokens.length) {
  13341. if (providedComments.length) {
  13342. for (i = 0, len = providedComments.length; i < len; i += 1) {
  13343. comment = deepCopy(providedComments[i]);
  13344. comment.extendedRange = [0, tree.range[0]];
  13345. comments.push(comment);
  13346. }
  13347. tree.leadingComments = comments;
  13348. }
  13349. return tree;
  13350. }
  13351. for (i = 0, len = providedComments.length; i < len; i += 1) {
  13352. comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
  13353. }
  13354. // This is based on John Freeman's implementation.
  13355. cursor = 0;
  13356. traverse(tree, {
  13357. enter: function (node) {
  13358. var comment;
  13359. while (cursor < comments.length) {
  13360. comment = comments[cursor];
  13361. if (comment.extendedRange[1] > node.range[0]) {
  13362. break;
  13363. }
  13364. if (comment.extendedRange[1] === node.range[0]) {
  13365. if (!node.leadingComments) {
  13366. node.leadingComments = [];
  13367. }
  13368. node.leadingComments.push(comment);
  13369. comments.splice(cursor, 1);
  13370. } else {
  13371. cursor += 1;
  13372. }
  13373. }
  13374. // already out of owned node
  13375. if (cursor === comments.length) {
  13376. return VisitorOption.Break;
  13377. }
  13378. if (comments[cursor].extendedRange[0] > node.range[1]) {
  13379. return VisitorOption.Skip;
  13380. }
  13381. }
  13382. });
  13383. cursor = 0;
  13384. traverse(tree, {
  13385. leave: function (node) {
  13386. var comment;
  13387. while (cursor < comments.length) {
  13388. comment = comments[cursor];
  13389. if (node.range[1] < comment.extendedRange[0]) {
  13390. break;
  13391. }
  13392. if (node.range[1] === comment.extendedRange[0]) {
  13393. if (!node.trailingComments) {
  13394. node.trailingComments = [];
  13395. }
  13396. node.trailingComments.push(comment);
  13397. comments.splice(cursor, 1);
  13398. } else {
  13399. cursor += 1;
  13400. }
  13401. }
  13402. // already out of owned node
  13403. if (cursor === comments.length) {
  13404. return VisitorOption.Break;
  13405. }
  13406. if (comments[cursor].extendedRange[0] > node.range[1]) {
  13407. return VisitorOption.Skip;
  13408. }
  13409. }
  13410. });
  13411. return tree;
  13412. }
  13413. exports.version = _dereq_('./package.json').version;
  13414. exports.Syntax = Syntax;
  13415. exports.traverse = traverse;
  13416. exports.replace = replace;
  13417. exports.attachComments = attachComments;
  13418. exports.VisitorKeys = VisitorKeys;
  13419. exports.VisitorOption = VisitorOption;
  13420. exports.Controller = Controller;
  13421. exports.cloneEnvironment = function () { return clone({}); };
  13422. return exports;
  13423. }(exports));
  13424. /* vim: set sw=4 ts=4 et tw=80 : */
  13425. },{"./package.json":140}],140:[function(_dereq_,module,exports){
  13426. module.exports={"name":"estraverse","version":"4.2.0"}
  13427. },{}],141:[function(_dereq_,module,exports){
  13428. // Copyright Joyent, Inc. and other Node contributors.
  13429. //
  13430. // Permission is hereby granted, free of charge, to any person obtaining a
  13431. // copy of this software and associated documentation files (the
  13432. // "Software"), to deal in the Software without restriction, including
  13433. // without limitation the rights to use, copy, modify, merge, publish,
  13434. // distribute, sublicense, and/or sell copies of the Software, and to permit
  13435. // persons to whom the Software is furnished to do so, subject to the
  13436. // following conditions:
  13437. //
  13438. // The above copyright notice and this permission notice shall be included
  13439. // in all copies or substantial portions of the Software.
  13440. //
  13441. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13442. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13443. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  13444. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  13445. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  13446. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  13447. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  13448. function EventEmitter() {
  13449. this._events = this._events || {};
  13450. this._maxListeners = this._maxListeners || undefined;
  13451. }
  13452. module.exports = EventEmitter;
  13453. // Backwards-compat with node 0.10.x
  13454. EventEmitter.EventEmitter = EventEmitter;
  13455. EventEmitter.prototype._events = undefined;
  13456. EventEmitter.prototype._maxListeners = undefined;
  13457. // By default EventEmitters will print a warning if more than 10 listeners are
  13458. // added to it. This is a useful default which helps finding memory leaks.
  13459. EventEmitter.defaultMaxListeners = 10;
  13460. // Obviously not all Emitters should be limited to 10. This function allows
  13461. // that to be increased. Set to zero for unlimited.
  13462. EventEmitter.prototype.setMaxListeners = function(n) {
  13463. if (!isNumber(n) || n < 0 || isNaN(n))
  13464. throw TypeError('n must be a positive number');
  13465. this._maxListeners = n;
  13466. return this;
  13467. };
  13468. EventEmitter.prototype.emit = function(type) {
  13469. var er, handler, len, args, i, listeners;
  13470. if (!this._events)
  13471. this._events = {};
  13472. // If there is no 'error' event listener then throw.
  13473. if (type === 'error') {
  13474. if (!this._events.error ||
  13475. (isObject(this._events.error) && !this._events.error.length)) {
  13476. er = arguments[1];
  13477. if (er instanceof Error) {
  13478. throw er; // Unhandled 'error' event
  13479. } else {
  13480. // At least give some kind of context to the user
  13481. var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
  13482. err.context = er;
  13483. throw err;
  13484. }
  13485. }
  13486. }
  13487. handler = this._events[type];
  13488. if (isUndefined(handler))
  13489. return false;
  13490. if (isFunction(handler)) {
  13491. switch (arguments.length) {
  13492. // fast cases
  13493. case 1:
  13494. handler.call(this);
  13495. break;
  13496. case 2:
  13497. handler.call(this, arguments[1]);
  13498. break;
  13499. case 3:
  13500. handler.call(this, arguments[1], arguments[2]);
  13501. break;
  13502. // slower
  13503. default:
  13504. args = Array.prototype.slice.call(arguments, 1);
  13505. handler.apply(this, args);
  13506. }
  13507. } else if (isObject(handler)) {
  13508. args = Array.prototype.slice.call(arguments, 1);
  13509. listeners = handler.slice();
  13510. len = listeners.length;
  13511. for (i = 0; i < len; i++)
  13512. listeners[i].apply(this, args);
  13513. }
  13514. return true;
  13515. };
  13516. EventEmitter.prototype.addListener = function(type, listener) {
  13517. var m;
  13518. if (!isFunction(listener))
  13519. throw TypeError('listener must be a function');
  13520. if (!this._events)
  13521. this._events = {};
  13522. // To avoid recursion in the case that type === "newListener"! Before
  13523. // adding it to the listeners, first emit "newListener".
  13524. if (this._events.newListener)
  13525. this.emit('newListener', type,
  13526. isFunction(listener.listener) ?
  13527. listener.listener : listener);
  13528. if (!this._events[type])
  13529. // Optimize the case of one listener. Don't need the extra array object.
  13530. this._events[type] = listener;
  13531. else if (isObject(this._events[type]))
  13532. // If we've already got an array, just append.
  13533. this._events[type].push(listener);
  13534. else
  13535. // Adding the second element, need to change to array.
  13536. this._events[type] = [this._events[type], listener];
  13537. // Check for listener leak
  13538. if (isObject(this._events[type]) && !this._events[type].warned) {
  13539. if (!isUndefined(this._maxListeners)) {
  13540. m = this._maxListeners;
  13541. } else {
  13542. m = EventEmitter.defaultMaxListeners;
  13543. }
  13544. if (m && m > 0 && this._events[type].length > m) {
  13545. this._events[type].warned = true;
  13546. console.error('(node) warning: possible EventEmitter memory ' +
  13547. 'leak detected. %d listeners added. ' +
  13548. 'Use emitter.setMaxListeners() to increase limit.',
  13549. this._events[type].length);
  13550. if (typeof console.trace === 'function') {
  13551. // not supported in IE 10
  13552. console.trace();
  13553. }
  13554. }
  13555. }
  13556. return this;
  13557. };
  13558. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  13559. EventEmitter.prototype.once = function(type, listener) {
  13560. if (!isFunction(listener))
  13561. throw TypeError('listener must be a function');
  13562. var fired = false;
  13563. function g() {
  13564. this.removeListener(type, g);
  13565. if (!fired) {
  13566. fired = true;
  13567. listener.apply(this, arguments);
  13568. }
  13569. }
  13570. g.listener = listener;
  13571. this.on(type, g);
  13572. return this;
  13573. };
  13574. // emits a 'removeListener' event iff the listener was removed
  13575. EventEmitter.prototype.removeListener = function(type, listener) {
  13576. var list, position, length, i;
  13577. if (!isFunction(listener))
  13578. throw TypeError('listener must be a function');
  13579. if (!this._events || !this._events[type])
  13580. return this;
  13581. list = this._events[type];
  13582. length = list.length;
  13583. position = -1;
  13584. if (list === listener ||
  13585. (isFunction(list.listener) && list.listener === listener)) {
  13586. delete this._events[type];
  13587. if (this._events.removeListener)
  13588. this.emit('removeListener', type, listener);
  13589. } else if (isObject(list)) {
  13590. for (i = length; i-- > 0;) {
  13591. if (list[i] === listener ||
  13592. (list[i].listener && list[i].listener === listener)) {
  13593. position = i;
  13594. break;
  13595. }
  13596. }
  13597. if (position < 0)
  13598. return this;
  13599. if (list.length === 1) {
  13600. list.length = 0;
  13601. delete this._events[type];
  13602. } else {
  13603. list.splice(position, 1);
  13604. }
  13605. if (this._events.removeListener)
  13606. this.emit('removeListener', type, listener);
  13607. }
  13608. return this;
  13609. };
  13610. EventEmitter.prototype.removeAllListeners = function(type) {
  13611. var key, listeners;
  13612. if (!this._events)
  13613. return this;
  13614. // not listening for removeListener, no need to emit
  13615. if (!this._events.removeListener) {
  13616. if (arguments.length === 0)
  13617. this._events = {};
  13618. else if (this._events[type])
  13619. delete this._events[type];
  13620. return this;
  13621. }
  13622. // emit removeListener for all listeners on all events
  13623. if (arguments.length === 0) {
  13624. for (key in this._events) {
  13625. if (key === 'removeListener') continue;
  13626. this.removeAllListeners(key);
  13627. }
  13628. this.removeAllListeners('removeListener');
  13629. this._events = {};
  13630. return this;
  13631. }
  13632. listeners = this._events[type];
  13633. if (isFunction(listeners)) {
  13634. this.removeListener(type, listeners);
  13635. } else if (listeners) {
  13636. // LIFO order
  13637. while (listeners.length)
  13638. this.removeListener(type, listeners[listeners.length - 1]);
  13639. }
  13640. delete this._events[type];
  13641. return this;
  13642. };
  13643. EventEmitter.prototype.listeners = function(type) {
  13644. var ret;
  13645. if (!this._events || !this._events[type])
  13646. ret = [];
  13647. else if (isFunction(this._events[type]))
  13648. ret = [this._events[type]];
  13649. else
  13650. ret = this._events[type].slice();
  13651. return ret;
  13652. };
  13653. EventEmitter.prototype.listenerCount = function(type) {
  13654. if (this._events) {
  13655. var evlistener = this._events[type];
  13656. if (isFunction(evlistener))
  13657. return 1;
  13658. else if (evlistener)
  13659. return evlistener.length;
  13660. }
  13661. return 0;
  13662. };
  13663. EventEmitter.listenerCount = function(emitter, type) {
  13664. return emitter.listenerCount(type);
  13665. };
  13666. function isFunction(arg) {
  13667. return typeof arg === 'function';
  13668. }
  13669. function isNumber(arg) {
  13670. return typeof arg === 'number';
  13671. }
  13672. function isObject(arg) {
  13673. return typeof arg === 'object' && arg !== null;
  13674. }
  13675. function isUndefined(arg) {
  13676. return arg === void 0;
  13677. }
  13678. },{}],142:[function(_dereq_,module,exports){
  13679. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  13680. var e, m
  13681. var eLen = (nBytes * 8) - mLen - 1
  13682. var eMax = (1 << eLen) - 1
  13683. var eBias = eMax >> 1
  13684. var nBits = -7
  13685. var i = isLE ? (nBytes - 1) : 0
  13686. var d = isLE ? -1 : 1
  13687. var s = buffer[offset + i]
  13688. i += d
  13689. e = s & ((1 << (-nBits)) - 1)
  13690. s >>= (-nBits)
  13691. nBits += eLen
  13692. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  13693. m = e & ((1 << (-nBits)) - 1)
  13694. e >>= (-nBits)
  13695. nBits += mLen
  13696. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  13697. if (e === 0) {
  13698. e = 1 - eBias
  13699. } else if (e === eMax) {
  13700. return m ? NaN : ((s ? -1 : 1) * Infinity)
  13701. } else {
  13702. m = m + Math.pow(2, mLen)
  13703. e = e - eBias
  13704. }
  13705. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  13706. }
  13707. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  13708. var e, m, c
  13709. var eLen = (nBytes * 8) - mLen - 1
  13710. var eMax = (1 << eLen) - 1
  13711. var eBias = eMax >> 1
  13712. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  13713. var i = isLE ? 0 : (nBytes - 1)
  13714. var d = isLE ? 1 : -1
  13715. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  13716. value = Math.abs(value)
  13717. if (isNaN(value) || value === Infinity) {
  13718. m = isNaN(value) ? 1 : 0
  13719. e = eMax
  13720. } else {
  13721. e = Math.floor(Math.log(value) / Math.LN2)
  13722. if (value * (c = Math.pow(2, -e)) < 1) {
  13723. e--
  13724. c *= 2
  13725. }
  13726. if (e + eBias >= 1) {
  13727. value += rt / c
  13728. } else {
  13729. value += rt * Math.pow(2, 1 - eBias)
  13730. }
  13731. if (value * c >= 2) {
  13732. e++
  13733. c /= 2
  13734. }
  13735. if (e + eBias >= eMax) {
  13736. m = 0
  13737. e = eMax
  13738. } else if (e + eBias >= 1) {
  13739. m = ((value * c) - 1) * Math.pow(2, mLen)
  13740. e = e + eBias
  13741. } else {
  13742. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  13743. e = 0
  13744. }
  13745. }
  13746. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  13747. e = (e << mLen) | m
  13748. eLen += mLen
  13749. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  13750. buffer[offset + i - d] |= s * 128
  13751. }
  13752. },{}],143:[function(_dereq_,module,exports){
  13753. var indexOf = [].indexOf;
  13754. module.exports = function(arr, obj){
  13755. if (indexOf) return arr.indexOf(obj);
  13756. for (var i = 0; i < arr.length; ++i) {
  13757. if (arr[i] === obj) return i;
  13758. }
  13759. return -1;
  13760. };
  13761. },{}],144:[function(_dereq_,module,exports){
  13762. arguments[4][8][0].apply(exports,arguments)
  13763. },{"dup":8}],145:[function(_dereq_,module,exports){
  13764. var toString = {}.toString;
  13765. module.exports = Array.isArray || function (arr) {
  13766. return toString.call(arr) == '[object Array]';
  13767. };
  13768. },{}],146:[function(_dereq_,module,exports){
  13769. 'use strict';
  13770. // modified from https://github.com/es-shims/es5-shim
  13771. var has = Object.prototype.hasOwnProperty;
  13772. var toStr = Object.prototype.toString;
  13773. var slice = Array.prototype.slice;
  13774. var isArgs = _dereq_('./isArguments');
  13775. var isEnumerable = Object.prototype.propertyIsEnumerable;
  13776. var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
  13777. var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
  13778. var dontEnums = [
  13779. 'toString',
  13780. 'toLocaleString',
  13781. 'valueOf',
  13782. 'hasOwnProperty',
  13783. 'isPrototypeOf',
  13784. 'propertyIsEnumerable',
  13785. 'constructor'
  13786. ];
  13787. var equalsConstructorPrototype = function (o) {
  13788. var ctor = o.constructor;
  13789. return ctor && ctor.prototype === o;
  13790. };
  13791. var excludedKeys = {
  13792. $applicationCache: true,
  13793. $console: true,
  13794. $external: true,
  13795. $frame: true,
  13796. $frameElement: true,
  13797. $frames: true,
  13798. $innerHeight: true,
  13799. $innerWidth: true,
  13800. $outerHeight: true,
  13801. $outerWidth: true,
  13802. $pageXOffset: true,
  13803. $pageYOffset: true,
  13804. $parent: true,
  13805. $scrollLeft: true,
  13806. $scrollTop: true,
  13807. $scrollX: true,
  13808. $scrollY: true,
  13809. $self: true,
  13810. $webkitIndexedDB: true,
  13811. $webkitStorageInfo: true,
  13812. $window: true
  13813. };
  13814. var hasAutomationEqualityBug = (function () {
  13815. /* global window */
  13816. if (typeof window === 'undefined') { return false; }
  13817. for (var k in window) {
  13818. try {
  13819. if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  13820. try {
  13821. equalsConstructorPrototype(window[k]);
  13822. } catch (e) {
  13823. return true;
  13824. }
  13825. }
  13826. } catch (e) {
  13827. return true;
  13828. }
  13829. }
  13830. return false;
  13831. }());
  13832. var equalsConstructorPrototypeIfNotBuggy = function (o) {
  13833. /* global window */
  13834. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  13835. return equalsConstructorPrototype(o);
  13836. }
  13837. try {
  13838. return equalsConstructorPrototype(o);
  13839. } catch (e) {
  13840. return false;
  13841. }
  13842. };
  13843. var keysShim = function keys(object) {
  13844. var isObject = object !== null && typeof object === 'object';
  13845. var isFunction = toStr.call(object) === '[object Function]';
  13846. var isArguments = isArgs(object);
  13847. var isString = isObject && toStr.call(object) === '[object String]';
  13848. var theKeys = [];
  13849. if (!isObject && !isFunction && !isArguments) {
  13850. throw new TypeError('Object.keys called on a non-object');
  13851. }
  13852. var skipProto = hasProtoEnumBug && isFunction;
  13853. if (isString && object.length > 0 && !has.call(object, 0)) {
  13854. for (var i = 0; i < object.length; ++i) {
  13855. theKeys.push(String(i));
  13856. }
  13857. }
  13858. if (isArguments && object.length > 0) {
  13859. for (var j = 0; j < object.length; ++j) {
  13860. theKeys.push(String(j));
  13861. }
  13862. } else {
  13863. for (var name in object) {
  13864. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  13865. theKeys.push(String(name));
  13866. }
  13867. }
  13868. }
  13869. if (hasDontEnumBug) {
  13870. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  13871. for (var k = 0; k < dontEnums.length; ++k) {
  13872. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  13873. theKeys.push(dontEnums[k]);
  13874. }
  13875. }
  13876. }
  13877. return theKeys;
  13878. };
  13879. keysShim.shim = function shimObjectKeys() {
  13880. if (Object.keys) {
  13881. var keysWorksWithArguments = (function () {
  13882. // Safari 5.0 bug
  13883. return (Object.keys(arguments) || '').length === 2;
  13884. }(1, 2));
  13885. if (!keysWorksWithArguments) {
  13886. var originalKeys = Object.keys;
  13887. Object.keys = function keys(object) { // eslint-disable-line func-name-matching
  13888. if (isArgs(object)) {
  13889. return originalKeys(slice.call(object));
  13890. } else {
  13891. return originalKeys(object);
  13892. }
  13893. };
  13894. }
  13895. } else {
  13896. Object.keys = keysShim;
  13897. }
  13898. return Object.keys || keysShim;
  13899. };
  13900. module.exports = keysShim;
  13901. },{"./isArguments":147}],147:[function(_dereq_,module,exports){
  13902. 'use strict';
  13903. var toStr = Object.prototype.toString;
  13904. module.exports = function isArguments(value) {
  13905. var str = toStr.call(value);
  13906. var isArgs = str === '[object Arguments]';
  13907. if (!isArgs) {
  13908. isArgs = str !== '[object Array]' &&
  13909. value !== null &&
  13910. typeof value === 'object' &&
  13911. typeof value.length === 'number' &&
  13912. value.length >= 0 &&
  13913. toStr.call(value.callee) === '[object Function]';
  13914. }
  13915. return isArgs;
  13916. };
  13917. },{}],148:[function(_dereq_,module,exports){
  13918. module.exports = _dereq_('./lib/create-formatter');
  13919. },{"./lib/create-formatter":149}],149:[function(_dereq_,module,exports){
  13920. 'use strict';
  13921. var assign = _dereq_('core-js/library/fn/object/assign');
  13922. var ContextTraversal = _dereq_('power-assert-context-traversal');
  13923. var LegacyContextTraversal = _dereq_('./legacy-context-traversal');
  13924. var StringWriter = _dereq_('./string-writer');
  13925. var defaultOptions = _dereq_('./default-options');
  13926. var reduce = _dereq_('core-js/library/fn/array/reduce');
  13927. /**
  13928. * options.reducers [array]
  13929. * options.renderers [array]
  13930. * options.outputOffset [number]
  13931. * options.lineSeparator [string]
  13932. * options.legacy [boolean]
  13933. */
  13934. function createFormatter (options) {
  13935. var formatterConfig = assign({}, defaultOptions(), options);
  13936. var reducers = formatterConfig.reducers || [];
  13937. var rendererConfigs = formatterConfig.renderers;
  13938. var len = rendererConfigs.length;
  13939. return function (powerAssertContext) {
  13940. var context = reduce(reducers, function (prevContext, reducer) {
  13941. return reducer(prevContext);
  13942. }, powerAssertContext);
  13943. var writer = new StringWriter(formatterConfig);
  13944. var traversal;
  13945. if (formatterConfig.legacy) {
  13946. traversal = new LegacyContextTraversal(context);
  13947. traversal.setWritable(writer);
  13948. } else {
  13949. traversal = new ContextTraversal(context);
  13950. }
  13951. for (var i = 0; i < len; i += 1) {
  13952. var RendererClass;
  13953. var renderer;
  13954. var config = rendererConfigs[i];
  13955. if (typeof config === 'object') {
  13956. RendererClass = config.ctor;
  13957. renderer = new RendererClass(config.options);
  13958. } else if (typeof config === 'function') {
  13959. RendererClass = config;
  13960. renderer = new RendererClass();
  13961. }
  13962. renderer.init(traversal);
  13963. if (typeof renderer.setWritable === 'function') {
  13964. renderer.setWritable(writer);
  13965. }
  13966. }
  13967. traversal.traverse();
  13968. writer.write('');
  13969. return writer.toString();
  13970. };
  13971. }
  13972. createFormatter.StringWriter = StringWriter;
  13973. module.exports = createFormatter;
  13974. },{"./default-options":150,"./legacy-context-traversal":151,"./string-writer":152,"core-js/library/fn/array/reduce":20,"core-js/library/fn/object/assign":23,"power-assert-context-traversal":154}],150:[function(_dereq_,module,exports){
  13975. 'use strict';
  13976. module.exports = function defaultOptions () {
  13977. return {
  13978. reducers: [
  13979. ],
  13980. legacy: false,
  13981. outputOffset: 2,
  13982. lineSeparator: '\n'
  13983. };
  13984. };
  13985. },{}],151:[function(_dereq_,module,exports){
  13986. 'use strict';
  13987. var ContextTraversal = _dereq_('power-assert-context-traversal');
  13988. var inherits = _dereq_('util').inherits;
  13989. var slice = Array.prototype.slice;
  13990. function LegacyContextTraversal (powerAssertContext) {
  13991. ContextTraversal.call(this, powerAssertContext);
  13992. }
  13993. inherits(LegacyContextTraversal, ContextTraversal);
  13994. LegacyContextTraversal.prototype.setWritable = function (writer) {
  13995. this.writer = writer;
  13996. };
  13997. LegacyContextTraversal.prototype.on = function () {
  13998. var args = slice.apply(arguments);
  13999. if (args[0] === 'render') {
  14000. args[0] = 'end';
  14001. }
  14002. ContextTraversal.prototype.on.apply(this, args);
  14003. };
  14004. LegacyContextTraversal.prototype.emit = function () {
  14005. var args = slice.apply(arguments);
  14006. if (args[0] === 'end') {
  14007. args[1] = this.writer;
  14008. }
  14009. ContextTraversal.prototype.emit.apply(this, args);
  14010. };
  14011. module.exports = LegacyContextTraversal;
  14012. },{"power-assert-context-traversal":154,"util":176}],152:[function(_dereq_,module,exports){
  14013. 'use strict';
  14014. function spacerStr (len) {
  14015. var str = '';
  14016. for(var i = 0; i < len; i += 1) {
  14017. str += ' ';
  14018. }
  14019. return str;
  14020. }
  14021. function StringWriter (config) {
  14022. this.lines = [];
  14023. this.lineSeparator = config.lineSeparator;
  14024. this.regex = new RegExp(this.lineSeparator, 'g');
  14025. this.spacer = spacerStr(config.outputOffset);
  14026. }
  14027. StringWriter.prototype.write = function (str) {
  14028. this.lines.push(this.spacer + str.replace(this.regex, this.lineSeparator + this.spacer));
  14029. };
  14030. StringWriter.prototype.toString = function () {
  14031. var str = this.lines.join(this.lineSeparator);
  14032. this.lines.length = 0;
  14033. return str;
  14034. };
  14035. module.exports = StringWriter;
  14036. },{}],153:[function(_dereq_,module,exports){
  14037. 'use strict';
  14038. var parser = _dereq_('acorn');
  14039. _dereq_('acorn-es7-plugin')(parser);
  14040. var estraverse = _dereq_('estraverse');
  14041. var purifyAst = _dereq_('espurify').customize({extra: ['range']});
  14042. var assign = _dereq_('core-js/library/fn/object/assign');
  14043. module.exports = function (powerAssertContext) {
  14044. var source = powerAssertContext.source;
  14045. if (source.ast && source.tokens && source.visitorKeys) {
  14046. return powerAssertContext;
  14047. }
  14048. var astAndTokens;
  14049. try {
  14050. astAndTokens = parse(source);
  14051. } catch (e) {
  14052. return assign({}, powerAssertContext, { source: assign({}, source, { error: e }) });
  14053. }
  14054. var newSource = assign({}, source, {
  14055. ast: purifyAst(astAndTokens.expression),
  14056. tokens: astAndTokens.tokens,
  14057. visitorKeys: estraverse.VisitorKeys
  14058. });
  14059. return assign({}, powerAssertContext, { source: newSource });
  14060. };
  14061. function parserOptions(tokens) {
  14062. return {
  14063. sourceType: 'module',
  14064. ecmaVersion: 2018,
  14065. locations: true,
  14066. ranges: false,
  14067. onToken: tokens,
  14068. plugins: {asyncawait: true}
  14069. };
  14070. }
  14071. function parse (source) {
  14072. var code = source.content;
  14073. var ast, tokens;
  14074. function doParse(wrapper) {
  14075. var content = wrapper ? wrapper(code) : code;
  14076. var tokenBag = [];
  14077. ast = parser.parse(content, parserOptions(tokenBag));
  14078. if (wrapper) {
  14079. ast = ast.body[0].body;
  14080. tokens = tokenBag.slice(6, -2);
  14081. } else {
  14082. tokens = tokenBag.slice(0, -1);
  14083. }
  14084. }
  14085. if (source.async) {
  14086. doParse(wrappedInAsync);
  14087. } else if (source.generator) {
  14088. doParse(wrappedInGenerator);
  14089. } else {
  14090. doParse();
  14091. }
  14092. var exp = ast.body[0].expression;
  14093. var columnOffset = exp.loc.start.column;
  14094. var offsetTree = estraverse.replace(exp, {
  14095. keys: estraverse.VisitorKeys,
  14096. enter: function (eachNode) {
  14097. if (!eachNode.loc && eachNode.range) {
  14098. // skip already visited node
  14099. return eachNode;
  14100. }
  14101. eachNode.range = [
  14102. eachNode.loc.start.column - columnOffset,
  14103. eachNode.loc.end.column - columnOffset
  14104. ];
  14105. delete eachNode.loc;
  14106. return eachNode;
  14107. }
  14108. });
  14109. return {
  14110. tokens: offsetAndSlimDownTokens(tokens),
  14111. expression: offsetTree
  14112. };
  14113. }
  14114. function wrappedInGenerator (jsCode) {
  14115. return 'function *wrapper() { ' + jsCode + ' }';
  14116. }
  14117. function wrappedInAsync (jsCode) {
  14118. return 'async function wrapper() { ' + jsCode + ' }';
  14119. }
  14120. function offsetAndSlimDownTokens (tokens) {
  14121. var i, token, newToken, result = [];
  14122. var columnOffset;
  14123. for(i = 0; i < tokens.length; i += 1) {
  14124. token = tokens[i];
  14125. if (i === 0) {
  14126. columnOffset = token.loc.start.column;
  14127. }
  14128. newToken = {
  14129. type: {
  14130. label: token.type.label
  14131. }
  14132. };
  14133. if (typeof token.value !== 'undefined') {
  14134. newToken.value = token.value;
  14135. }
  14136. newToken.range = [
  14137. token.loc.start.column - columnOffset,
  14138. token.loc.end.column - columnOffset
  14139. ];
  14140. result.push(newToken);
  14141. }
  14142. return result;
  14143. }
  14144. },{"acorn":5,"acorn-es7-plugin":2,"core-js/library/fn/object/assign":23,"espurify":135,"estraverse":139}],154:[function(_dereq_,module,exports){
  14145. module.exports = _dereq_('./lib/context-traversal');
  14146. },{"./lib/context-traversal":155}],155:[function(_dereq_,module,exports){
  14147. 'use strict';
  14148. var EventEmitter = _dereq_('events').EventEmitter;
  14149. var inherits = _dereq_('util').inherits;
  14150. var estraverse = _dereq_('estraverse');
  14151. var forEach = _dereq_('core-js/library/fn/array/for-each');
  14152. var reduce = _dereq_('core-js/library/fn/array/reduce');
  14153. var locationOf = _dereq_('./location');
  14154. var literalPattern = /^(?:String|Numeric|Null|Boolean|RegExp)?Literal$/;
  14155. var assign = _dereq_('core-js/library/fn/object/assign');
  14156. function ContextTraversal (powerAssertContext) {
  14157. this.powerAssertContext = powerAssertContext;
  14158. EventEmitter.call(this);
  14159. }
  14160. inherits(ContextTraversal, EventEmitter);
  14161. ContextTraversal.prototype.traverse = function () {
  14162. var _this = this;
  14163. var source = _this.powerAssertContext.source;
  14164. parseIfJson(source, 'ast');
  14165. parseIfJson(source, 'tokens');
  14166. parseIfJson(source, 'visitorKeys');
  14167. _this.emit('start', this.powerAssertContext);
  14168. forEach(this.powerAssertContext.args, function (capturedArgument) {
  14169. onEachEsNode(capturedArgument, source, function (esNode) {
  14170. _this.emit('data', esNode);
  14171. });
  14172. });
  14173. _this.emit('end');
  14174. };
  14175. function parseIfJson (source, propName) {
  14176. if (typeof source[propName] === 'string') {
  14177. source[propName] = JSON.parse(source[propName]);
  14178. }
  14179. }
  14180. function onEachEsNode(capturedArgument, source, callback) {
  14181. var espathToValue = reduce(capturedArgument.events, function (accum, ev) {
  14182. accum[ev.espath] = ev.value;
  14183. return accum;
  14184. }, {});
  14185. var nodeStack = [];
  14186. estraverse.traverse(source.ast, {
  14187. keys: source.visitorKeys,
  14188. enter: function (currentNode, parentNode) {
  14189. var parentEsNode = (0 < nodeStack.length) ? nodeStack[nodeStack.length - 1] : null;
  14190. var esNode = createEsNode(this.path(), currentNode, espathToValue, source.content, source.tokens, parentEsNode);
  14191. nodeStack.push(esNode);
  14192. callback(esNode);
  14193. },
  14194. leave: function (currentNode, parentNode) {
  14195. nodeStack.pop();
  14196. }
  14197. });
  14198. }
  14199. function isLiteral (node) {
  14200. return literalPattern.test(node.type);
  14201. }
  14202. function createEsNode (path, currentNode, espathToValue, jsCode, tokens, parent) {
  14203. var espath = path ? path.join('/') : '';
  14204. return {
  14205. espath: espath,
  14206. parent: parent,
  14207. key: path ? path[path.length - 1] : null,
  14208. node: currentNode,
  14209. code: jsCode.slice(currentNode.range[0], currentNode.range[1]),
  14210. value: isLiteral(currentNode) ? currentNode.value : espathToValue[espath],
  14211. isCaptured: espathToValue.hasOwnProperty(espath),
  14212. range: locationOf(currentNode, tokens)
  14213. };
  14214. }
  14215. module.exports = ContextTraversal;
  14216. },{"./location":156,"core-js/library/fn/array/for-each":15,"core-js/library/fn/array/reduce":20,"core-js/library/fn/object/assign":23,"estraverse":139,"events":141,"util":176}],156:[function(_dereq_,module,exports){
  14217. 'use strict';
  14218. var syntax = _dereq_('estraverse').Syntax;
  14219. function locationOf(currentNode, tokens) {
  14220. switch(currentNode.type) {
  14221. case syntax.MemberExpression:
  14222. return propertyLocationOf(currentNode, tokens);
  14223. case syntax.CallExpression:
  14224. if (currentNode.callee.type === syntax.MemberExpression) {
  14225. return propertyLocationOf(currentNode.callee, tokens);
  14226. }
  14227. break;
  14228. case syntax.BinaryExpression:
  14229. case syntax.LogicalExpression:
  14230. case syntax.AssignmentExpression:
  14231. return infixOperatorLocationOf(currentNode, tokens);
  14232. default:
  14233. break;
  14234. }
  14235. return currentNode.range;
  14236. }
  14237. function propertyLocationOf(memberExpression, tokens) {
  14238. var prop = memberExpression.property;
  14239. var token;
  14240. if (!memberExpression.computed) {
  14241. return prop.range;
  14242. }
  14243. token = findLeftBracketTokenOf(memberExpression, tokens);
  14244. return token ? token.range : prop.range;
  14245. }
  14246. // calculate location of infix operator for BinaryExpression, AssignmentExpression and LogicalExpression.
  14247. function infixOperatorLocationOf (expression, tokens) {
  14248. var token = findOperatorTokenOf(expression, tokens);
  14249. return token ? token.range : expression.left.range;
  14250. }
  14251. function findLeftBracketTokenOf(expression, tokens) {
  14252. var fromColumn = expression.property.range[0];
  14253. return searchToken(tokens, function (token, index) {
  14254. var prevToken;
  14255. if (token.range[0] === fromColumn) {
  14256. prevToken = tokens[index - 1];
  14257. // if (prevToken.type === 'Punctuator' && prevToken.value === '[') { // esprima
  14258. if (prevToken.type.label === '[') { // acorn
  14259. return prevToken;
  14260. }
  14261. }
  14262. return undefined;
  14263. });
  14264. }
  14265. function findOperatorTokenOf(expression, tokens) {
  14266. var fromColumn = expression.left.range[1];
  14267. var toColumn = expression.right.range[0];
  14268. return searchToken(tokens, function (token, index) {
  14269. if (fromColumn < token.range[0] &&
  14270. token.range[1] < toColumn &&
  14271. token.value === expression.operator) {
  14272. return token;
  14273. }
  14274. return undefined;
  14275. });
  14276. }
  14277. function searchToken(tokens, predicate) {
  14278. var i, token, found;
  14279. for(i = 0; i < tokens.length; i += 1) {
  14280. token = tokens[i];
  14281. found = predicate(token, i);
  14282. if (found) {
  14283. return found;
  14284. }
  14285. }
  14286. return undefined;
  14287. }
  14288. module.exports = locationOf;
  14289. },{"estraverse":139}],157:[function(_dereq_,module,exports){
  14290. /**
  14291. * power-assert-formatter.js - Power Assert output formatter
  14292. *
  14293. * https://github.com/power-assert-js/power-assert-formatter
  14294. *
  14295. * Copyright (c) 2013-2016 Takuto Wada
  14296. * Licensed under the MIT license.
  14297. * https://github.com/power-assert-js/power-assert-formatter/blob/master/MIT-LICENSE.txt
  14298. */
  14299. 'use strict';
  14300. module.exports = _dereq_('./lib/create');
  14301. },{"./lib/create":158}],158:[function(_dereq_,module,exports){
  14302. 'use strict';
  14303. var createFormatter = _dereq_('power-assert-context-formatter');
  14304. var appendAst = _dereq_('power-assert-context-reducer-ast');
  14305. var FileRenderer = _dereq_('power-assert-renderer-file');
  14306. var AssertionRenderer = _dereq_('power-assert-renderer-assertion');
  14307. var DiagramRenderer = _dereq_('power-assert-renderer-diagram');
  14308. var ComparisonRenderer = _dereq_('power-assert-renderer-comparison');
  14309. var defaultOptions = _dereq_('./default-options');
  14310. var assign = _dereq_('core-js/library/fn/object/assign');
  14311. var map = _dereq_('core-js/library/fn/array/map');
  14312. // "Browserify can only analyze static requires. It is not in the scope of browserify to handle dynamic requires."
  14313. // https://github.com/substack/node-browserify/issues/377
  14314. var defaultRendererClasses = {
  14315. './built-in/file': FileRenderer,
  14316. './built-in/assertion': AssertionRenderer,
  14317. './built-in/diagram': DiagramRenderer,
  14318. './built-in/binary-expression': ComparisonRenderer
  14319. };
  14320. function toRendererClass (rendererName) {
  14321. var RendererClass;
  14322. if (typeof rendererName === 'function') {
  14323. RendererClass = rendererName;
  14324. } else if (typeof rendererName === 'string') {
  14325. if (defaultRendererClasses[rendererName]) {
  14326. RendererClass = defaultRendererClasses[rendererName];
  14327. } else {
  14328. RendererClass = _dereq_(rendererName);
  14329. }
  14330. }
  14331. return RendererClass;
  14332. }
  14333. function create (options) {
  14334. var config = assign(defaultOptions(), options);
  14335. var rendererClasses = map(config.renderers, toRendererClass);
  14336. var renderers = map(rendererClasses, function (clazz) {
  14337. return { ctor: clazz, options: config };
  14338. });
  14339. return createFormatter(assign({}, config, {
  14340. reducers: [
  14341. appendAst
  14342. ],
  14343. renderers: renderers,
  14344. legacy: true
  14345. }));
  14346. }
  14347. create.renderers = {
  14348. AssertionRenderer: AssertionRenderer,
  14349. FileRenderer: FileRenderer,
  14350. DiagramRenderer: DiagramRenderer,
  14351. BinaryExpressionRenderer: ComparisonRenderer
  14352. };
  14353. create.defaultOptions = defaultOptions;
  14354. module.exports = create;
  14355. },{"./default-options":159,"core-js/library/fn/array/map":18,"core-js/library/fn/object/assign":23,"power-assert-context-formatter":148,"power-assert-context-reducer-ast":153,"power-assert-renderer-assertion":160,"power-assert-renderer-comparison":162,"power-assert-renderer-diagram":165,"power-assert-renderer-file":167}],159:[function(_dereq_,module,exports){
  14356. 'use strict';
  14357. module.exports = function defaultOptions () {
  14358. return {
  14359. lineDiffThreshold: 5,
  14360. maxDepth: 1,
  14361. outputOffset: 2,
  14362. anonymous: 'Object',
  14363. circular: '#@Circular#',
  14364. lineSeparator: '\n',
  14365. ambiguousEastAsianCharWidth: 2,
  14366. renderers: [
  14367. './built-in/file',
  14368. './built-in/assertion',
  14369. './built-in/diagram',
  14370. './built-in/binary-expression'
  14371. ]
  14372. };
  14373. };
  14374. },{}],160:[function(_dereq_,module,exports){
  14375. 'use strict';
  14376. var BaseRenderer = _dereq_('power-assert-renderer-base');
  14377. var stringWidth = _dereq_('power-assert-util-string-width');
  14378. var inherits = _dereq_('util').inherits;
  14379. function AssertionRenderer () {
  14380. BaseRenderer.call(this);
  14381. }
  14382. inherits(AssertionRenderer, BaseRenderer);
  14383. AssertionRenderer.prototype.onStart = function (context) {
  14384. this.context = context;
  14385. this.assertionLine = context.source.content;
  14386. };
  14387. AssertionRenderer.prototype.onEnd = function () {
  14388. this.write('');
  14389. this.write(this.assertionLine);
  14390. var e = this.context.source.error;
  14391. if (e && e instanceof SyntaxError) {
  14392. var re = /Unexpected token \(1\:(\d+)\)/;
  14393. var matchResult = re.exec(e.message);
  14394. if (matchResult) {
  14395. var syntaxErrorIndex = Number(matchResult[1]);
  14396. this.renderValueAt(syntaxErrorIndex, '?');
  14397. this.renderValueAt(syntaxErrorIndex, '?');
  14398. this.renderValueAt(syntaxErrorIndex, e.toString());
  14399. this.renderValueAt(0, '');
  14400. this.renderValueAt(0, 'If you are using `babel-plugin-espower` and want to use experimental syntax in your assert(), you should set `embedAst` option to true.');
  14401. this.renderValueAt(0, 'see: https://github.com/power-assert-js/babel-plugin-espower#optionsembedast');
  14402. }
  14403. }
  14404. };
  14405. AssertionRenderer.prototype.renderValueAt = function (idx, str) {
  14406. var row = createRow(stringWidth(this.assertionLine), ' ');
  14407. replaceColumn(idx, row, str);
  14408. this.write(row.join(''));
  14409. };
  14410. function replaceColumn (columnIndex, row, str) {
  14411. var i, width = stringWidth(str);
  14412. for (i = 0; i < width; i += 1) {
  14413. row.splice(columnIndex + i, 1, str.charAt(i));
  14414. }
  14415. }
  14416. function createRow (numCols, initial) {
  14417. var row = [], i;
  14418. for(i = 0; i < numCols; i += 1) {
  14419. row[i] = initial;
  14420. }
  14421. return row;
  14422. }
  14423. module.exports = AssertionRenderer;
  14424. },{"power-assert-renderer-base":161,"power-assert-util-string-width":168,"util":176}],161:[function(_dereq_,module,exports){
  14425. 'use strict';
  14426. function BaseRenderer () {
  14427. }
  14428. BaseRenderer.prototype.init = function (traversal) {
  14429. var _this = this;
  14430. traversal.on('start', function (context) {
  14431. _this.onStart(context);
  14432. });
  14433. traversal.on('data', function (esNode) {
  14434. _this.onData(esNode);
  14435. });
  14436. traversal.on('end', function () {
  14437. _this.onEnd();
  14438. });
  14439. };
  14440. BaseRenderer.prototype.setWritable = function (writable) {
  14441. this.writable = writable;
  14442. };
  14443. // API
  14444. BaseRenderer.prototype.onStart = function (context) {
  14445. };
  14446. // API
  14447. BaseRenderer.prototype.onData = function (esNode) {
  14448. };
  14449. // API
  14450. BaseRenderer.prototype.onEnd = function () {
  14451. };
  14452. // API
  14453. BaseRenderer.prototype.write = function (str) {
  14454. this.writable.write(str);
  14455. };
  14456. module.exports = BaseRenderer;
  14457. },{}],162:[function(_dereq_,module,exports){
  14458. 'use strict';
  14459. var BaseRenderer = _dereq_('power-assert-renderer-base');
  14460. var inherits = _dereq_('util').inherits;
  14461. var typeName = _dereq_('type-name');
  14462. var keys = _dereq_('core-js/library/fn/object/keys');
  14463. var forEach = _dereq_('core-js/library/fn/array/for-each');
  14464. var udiff = _dereq_('./lib/udiff');
  14465. var stringifier = _dereq_('stringifier');
  14466. var assign = _dereq_('core-js/library/fn/object/assign');
  14467. var defaultOptions = _dereq_('./lib/default-options');
  14468. var literalPattern = /^(?:String|Numeric|Null|Boolean|RegExp)?Literal$/;
  14469. function isLiteral (node) {
  14470. return literalPattern.test(node.type);
  14471. }
  14472. /**
  14473. * options.stringify [function]
  14474. * options.maxDepth [number]
  14475. * options.lineSeparator [string]
  14476. * options.anonymous [string]
  14477. * options.circular [string]
  14478. *
  14479. * options.diff [function]
  14480. * options.lineDiffThreshold [number]
  14481. */
  14482. function ComparisonRenderer (config) {
  14483. BaseRenderer.call(this);
  14484. this.config = assign({}, defaultOptions(), config);
  14485. if (typeof this.config.stringify === 'function') {
  14486. this.stringify = this.config.stringify;
  14487. } else {
  14488. this.stringify = stringifier(this.config);
  14489. }
  14490. if (typeof this.config.diff === 'function') {
  14491. this.diff = this.config.diff;
  14492. } else {
  14493. this.diff = udiff(this.config);
  14494. }
  14495. this.espathToPair = {};
  14496. }
  14497. inherits(ComparisonRenderer, BaseRenderer);
  14498. ComparisonRenderer.prototype.onData = function (esNode) {
  14499. var pair;
  14500. if (!esNode.isCaptured) {
  14501. if (isTargetBinaryExpression(esNode.parent) && isLiteral(esNode.node)) {
  14502. this.espathToPair[esNode.parent.espath][esNode.key] = {code: esNode.code, value: esNode.value};
  14503. }
  14504. return;
  14505. }
  14506. if (isTargetBinaryExpression(esNode.parent)) {
  14507. this.espathToPair[esNode.parent.espath][esNode.key] = {code: esNode.code, value: esNode.value};
  14508. }
  14509. if (isTargetBinaryExpression(esNode)) {
  14510. pair = {
  14511. operator: esNode.node.operator,
  14512. value: esNode.value
  14513. };
  14514. this.espathToPair[esNode.espath] = pair;
  14515. }
  14516. };
  14517. ComparisonRenderer.prototype.onEnd = function () {
  14518. var _this = this;
  14519. var pairs = [];
  14520. forEach(keys(this.espathToPair), function (espath) {
  14521. var pair = _this.espathToPair[espath];
  14522. if (pair.left && pair.right) {
  14523. pairs.push(pair);
  14524. }
  14525. });
  14526. forEach(pairs, function (pair) {
  14527. _this.compare(pair);
  14528. });
  14529. };
  14530. ComparisonRenderer.prototype.compare = function (pair) {
  14531. if (isStringDiffTarget(pair)) {
  14532. this.showStringDiff(pair);
  14533. } else {
  14534. this.showExpectedAndActual(pair);
  14535. }
  14536. };
  14537. ComparisonRenderer.prototype.showExpectedAndActual = function (pair) {
  14538. this.write('');
  14539. this.write('[' + typeName(pair.right.value) + '] ' + pair.right.code);
  14540. this.write('=> ' + this.stringify(pair.right.value));
  14541. this.write('[' + typeName(pair.left.value) + '] ' + pair.left.code);
  14542. this.write('=> ' + this.stringify(pair.left.value));
  14543. };
  14544. ComparisonRenderer.prototype.showStringDiff = function (pair) {
  14545. this.write('');
  14546. this.write('--- [string] ' + pair.right.code);
  14547. this.write('+++ [string] ' + pair.left.code);
  14548. this.write(this.diff(pair.right.value, pair.left.value, this.config));
  14549. };
  14550. function isTargetBinaryExpression (esNode) {
  14551. return esNode &&
  14552. esNode.node.type === 'BinaryExpression' &&
  14553. (esNode.node.operator === '===' || esNode.node.operator === '==') &&
  14554. esNode.isCaptured &&
  14555. !(esNode.value);
  14556. }
  14557. function isStringDiffTarget(pair) {
  14558. return typeof pair.left.value === 'string' && typeof pair.right.value === 'string';
  14559. }
  14560. ComparisonRenderer.udiff = udiff;
  14561. module.exports = ComparisonRenderer;
  14562. },{"./lib/default-options":163,"./lib/udiff":164,"core-js/library/fn/array/for-each":15,"core-js/library/fn/object/assign":23,"core-js/library/fn/object/keys":26,"power-assert-renderer-base":161,"stringifier":170,"type-name":173,"util":176}],163:[function(_dereq_,module,exports){
  14563. 'use strict';
  14564. module.exports = function defaultOptions () {
  14565. return {
  14566. lineDiffThreshold: 5,
  14567. maxDepth: 2,
  14568. indent: null,
  14569. outputOffset: 2,
  14570. anonymous: 'Object',
  14571. circular: '#@Circular#',
  14572. lineSeparator: '\n'
  14573. };
  14574. };
  14575. },{}],164:[function(_dereq_,module,exports){
  14576. 'use strict';
  14577. var DiffMatchPatch = _dereq_('diff-match-patch');
  14578. var dmp = new DiffMatchPatch();
  14579. function udiff (config) {
  14580. return function diff (text1, text2) {
  14581. var patch;
  14582. if (config && shouldUseLineLevelDiff(text1, config)) {
  14583. patch = udiffLines(text1, text2);
  14584. } else {
  14585. patch = udiffChars(text1, text2);
  14586. }
  14587. return decodeURIComponent(patch);
  14588. };
  14589. }
  14590. function shouldUseLineLevelDiff (text, config) {
  14591. return config.lineDiffThreshold < text.split(/\r\n|\r|\n/).length;
  14592. }
  14593. function udiffLines(text1, text2) {
  14594. /*jshint camelcase: false */
  14595. var a = dmp.diff_linesToChars_(text1, text2);
  14596. var diffs = dmp.diff_main(a.chars1, a.chars2, false);
  14597. dmp.diff_charsToLines_(diffs, a.lineArray);
  14598. dmp.diff_cleanupSemantic(diffs);
  14599. return dmp.patch_toText(dmp.patch_make(text1, diffs));
  14600. }
  14601. function udiffChars (text1, text2) {
  14602. /*jshint camelcase: false */
  14603. var diffs = dmp.diff_main(text1, text2, false);
  14604. dmp.diff_cleanupSemantic(diffs);
  14605. return dmp.patch_toText(dmp.patch_make(text1, diffs));
  14606. }
  14607. module.exports = udiff;
  14608. },{"diff-match-patch":124}],165:[function(_dereq_,module,exports){
  14609. 'use strict';
  14610. var BaseRenderer = _dereq_('power-assert-renderer-base');
  14611. var inherits = _dereq_('util').inherits;
  14612. var forEach = _dereq_('core-js/library/fn/array/for-each');
  14613. var stringifier = _dereq_('stringifier');
  14614. var stringWidth = _dereq_('power-assert-util-string-width');
  14615. var assign = _dereq_('core-js/library/fn/object/assign');
  14616. var defaultOptions = _dereq_('./lib/default-options');
  14617. /**
  14618. * options.stringify [function]
  14619. * options.maxDepth [number]
  14620. * options.lineSeparator [string]
  14621. * options.anonymous [string]
  14622. * options.circular [string]
  14623. *
  14624. * options.widthOf [function]
  14625. * options.ambiguousEastAsianCharWidth [number]
  14626. */
  14627. function DiagramRenderer (config) {
  14628. BaseRenderer.call(this);
  14629. this.config = assign({}, defaultOptions(), config);
  14630. this.events = [];
  14631. if (typeof this.config.stringify === 'function') {
  14632. this.stringify = this.config.stringify;
  14633. } else {
  14634. this.stringify = stringifier(this.config);
  14635. }
  14636. if (typeof this.config.widthOf === 'function') {
  14637. this.widthOf = this.config.widthOf;
  14638. } else {
  14639. this.widthOf = (this.config.ambiguousEastAsianCharWidth === 1) ? stringWidth.narrow : stringWidth;
  14640. }
  14641. this.initialVertivalBarLength = 1;
  14642. }
  14643. inherits(DiagramRenderer, BaseRenderer);
  14644. DiagramRenderer.prototype.onStart = function (context) {
  14645. this.assertionLine = context.source.content;
  14646. this.initializeRows();
  14647. };
  14648. DiagramRenderer.prototype.onData = function (esNode) {
  14649. if (!esNode.isCaptured) {
  14650. return;
  14651. }
  14652. this.events.push({value: esNode.value, leftIndex: esNode.range[0]});
  14653. };
  14654. DiagramRenderer.prototype.onEnd = function () {
  14655. this.events.sort(rightToLeft);
  14656. this.constructRows(this.events);
  14657. var _this = this;
  14658. forEach(this.rows, function (columns) {
  14659. _this.write(columns.join(''));
  14660. });
  14661. };
  14662. DiagramRenderer.prototype.initializeRows = function () {
  14663. this.rows = [];
  14664. for (var i = 0; i <= this.initialVertivalBarLength; i += 1) {
  14665. this.addOneMoreRow();
  14666. }
  14667. };
  14668. DiagramRenderer.prototype.newRowFor = function (assertionLine) {
  14669. return createRow(this.widthOf(assertionLine), ' ');
  14670. };
  14671. DiagramRenderer.prototype.addOneMoreRow = function () {
  14672. this.rows.push(this.newRowFor(this.assertionLine));
  14673. };
  14674. DiagramRenderer.prototype.lastRow = function () {
  14675. return this.rows[this.rows.length - 1];
  14676. };
  14677. DiagramRenderer.prototype.renderVerticalBarAt = function (columnIndex) {
  14678. var i, lastRowIndex = this.rows.length - 1;
  14679. for (i = 0; i < lastRowIndex; i += 1) {
  14680. this.rows[i].splice(columnIndex, 1, '|');
  14681. }
  14682. };
  14683. DiagramRenderer.prototype.renderValueAt = function (columnIndex, dumpedValue) {
  14684. var i, width = this.widthOf(dumpedValue);
  14685. for (i = 0; i < width; i += 1) {
  14686. this.lastRow().splice(columnIndex + i, 1, dumpedValue.charAt(i));
  14687. }
  14688. };
  14689. DiagramRenderer.prototype.isOverlapped = function (prevCapturing, nextCaputuring, dumpedValue) {
  14690. return (typeof prevCapturing !== 'undefined') && this.startColumnFor(prevCapturing) <= (this.startColumnFor(nextCaputuring) + this.widthOf(dumpedValue));
  14691. };
  14692. DiagramRenderer.prototype.constructRows = function (capturedEvents) {
  14693. var that = this;
  14694. var prevCaptured;
  14695. forEach(capturedEvents, function (captured) {
  14696. var dumpedValue = that.stringify(captured.value);
  14697. if (that.isOverlapped(prevCaptured, captured, dumpedValue)) {
  14698. that.addOneMoreRow();
  14699. }
  14700. that.renderVerticalBarAt(that.startColumnFor(captured));
  14701. that.renderValueAt(that.startColumnFor(captured), dumpedValue);
  14702. prevCaptured = captured;
  14703. });
  14704. };
  14705. DiagramRenderer.prototype.startColumnFor = function (captured) {
  14706. return this.widthOf(this.assertionLine.slice(0, captured.leftIndex));
  14707. };
  14708. function createRow (numCols, initial) {
  14709. var row = [], i;
  14710. for(i = 0; i < numCols; i += 1) {
  14711. row[i] = initial;
  14712. }
  14713. return row;
  14714. }
  14715. function rightToLeft (a, b) {
  14716. return b.leftIndex - a.leftIndex;
  14717. }
  14718. module.exports = DiagramRenderer;
  14719. },{"./lib/default-options":166,"core-js/library/fn/array/for-each":15,"core-js/library/fn/object/assign":23,"power-assert-renderer-base":161,"power-assert-util-string-width":168,"stringifier":170,"util":176}],166:[function(_dereq_,module,exports){
  14720. 'use strict';
  14721. module.exports = function defaultOptions () {
  14722. return {
  14723. ambiguousEastAsianCharWidth: 2,
  14724. maxDepth: 2,
  14725. indent: null,
  14726. outputOffset: 2,
  14727. anonymous: 'Object',
  14728. circular: '#@Circular#',
  14729. lineSeparator: '\n'
  14730. };
  14731. };
  14732. },{}],167:[function(_dereq_,module,exports){
  14733. 'use strict';
  14734. var BaseRenderer = _dereq_('power-assert-renderer-base');
  14735. var inherits = _dereq_('util').inherits;
  14736. function FileRenderer () {
  14737. BaseRenderer.call(this);
  14738. }
  14739. inherits(FileRenderer, BaseRenderer);
  14740. FileRenderer.prototype.onStart = function (context) {
  14741. this.filepath = context.source.filepath;
  14742. this.lineNumber = context.source.line;
  14743. };
  14744. FileRenderer.prototype.onEnd = function () {
  14745. if (this.filepath) {
  14746. this.write('# ' + [this.filepath, this.lineNumber].join(':'));
  14747. } else {
  14748. this.write('# at line: ' + this.lineNumber);
  14749. }
  14750. };
  14751. module.exports = FileRenderer;
  14752. },{"power-assert-renderer-base":161,"util":176}],168:[function(_dereq_,module,exports){
  14753. 'use strict';
  14754. var eaw = _dereq_('eastasianwidth');
  14755. function stringWidth (ambiguousCharWidth) {
  14756. return function widthOf (str) {
  14757. var i, code, width = 0;
  14758. for(i = 0; i < str.length; i+=1) {
  14759. code = eaw.eastAsianWidth(str.charAt(i));
  14760. switch(code) {
  14761. case 'F':
  14762. case 'W':
  14763. width += 2;
  14764. break;
  14765. case 'H':
  14766. case 'Na':
  14767. case 'N':
  14768. width += 1;
  14769. break;
  14770. case 'A':
  14771. width += ambiguousCharWidth;
  14772. break;
  14773. }
  14774. }
  14775. return width;
  14776. };
  14777. }
  14778. module.exports = stringWidth(2);
  14779. module.exports.narrow = stringWidth(1);
  14780. },{"eastasianwidth":125}],169:[function(_dereq_,module,exports){
  14781. // shim for using process in browser
  14782. var process = module.exports = {};
  14783. // cached from whatever global is present so that test runners that stub it
  14784. // don't break things. But we need to wrap it in a try catch in case it is
  14785. // wrapped in strict mode code which doesn't define any globals. It's inside a
  14786. // function because try/catches deoptimize in certain engines.
  14787. var cachedSetTimeout;
  14788. var cachedClearTimeout;
  14789. function defaultSetTimout() {
  14790. throw new Error('setTimeout has not been defined');
  14791. }
  14792. function defaultClearTimeout () {
  14793. throw new Error('clearTimeout has not been defined');
  14794. }
  14795. (function () {
  14796. try {
  14797. if (typeof setTimeout === 'function') {
  14798. cachedSetTimeout = setTimeout;
  14799. } else {
  14800. cachedSetTimeout = defaultSetTimout;
  14801. }
  14802. } catch (e) {
  14803. cachedSetTimeout = defaultSetTimout;
  14804. }
  14805. try {
  14806. if (typeof clearTimeout === 'function') {
  14807. cachedClearTimeout = clearTimeout;
  14808. } else {
  14809. cachedClearTimeout = defaultClearTimeout;
  14810. }
  14811. } catch (e) {
  14812. cachedClearTimeout = defaultClearTimeout;
  14813. }
  14814. } ())
  14815. function runTimeout(fun) {
  14816. if (cachedSetTimeout === setTimeout) {
  14817. //normal enviroments in sane situations
  14818. return setTimeout(fun, 0);
  14819. }
  14820. // if setTimeout wasn't available but was latter defined
  14821. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  14822. cachedSetTimeout = setTimeout;
  14823. return setTimeout(fun, 0);
  14824. }
  14825. try {
  14826. // when when somebody has screwed with setTimeout but no I.E. maddness
  14827. return cachedSetTimeout(fun, 0);
  14828. } catch(e){
  14829. try {
  14830. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  14831. return cachedSetTimeout.call(null, fun, 0);
  14832. } catch(e){
  14833. // 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
  14834. return cachedSetTimeout.call(this, fun, 0);
  14835. }
  14836. }
  14837. }
  14838. function runClearTimeout(marker) {
  14839. if (cachedClearTimeout === clearTimeout) {
  14840. //normal enviroments in sane situations
  14841. return clearTimeout(marker);
  14842. }
  14843. // if clearTimeout wasn't available but was latter defined
  14844. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  14845. cachedClearTimeout = clearTimeout;
  14846. return clearTimeout(marker);
  14847. }
  14848. try {
  14849. // when when somebody has screwed with setTimeout but no I.E. maddness
  14850. return cachedClearTimeout(marker);
  14851. } catch (e){
  14852. try {
  14853. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  14854. return cachedClearTimeout.call(null, marker);
  14855. } catch (e){
  14856. // 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.
  14857. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  14858. return cachedClearTimeout.call(this, marker);
  14859. }
  14860. }
  14861. }
  14862. var queue = [];
  14863. var draining = false;
  14864. var currentQueue;
  14865. var queueIndex = -1;
  14866. function cleanUpNextTick() {
  14867. if (!draining || !currentQueue) {
  14868. return;
  14869. }
  14870. draining = false;
  14871. if (currentQueue.length) {
  14872. queue = currentQueue.concat(queue);
  14873. } else {
  14874. queueIndex = -1;
  14875. }
  14876. if (queue.length) {
  14877. drainQueue();
  14878. }
  14879. }
  14880. function drainQueue() {
  14881. if (draining) {
  14882. return;
  14883. }
  14884. var timeout = runTimeout(cleanUpNextTick);
  14885. draining = true;
  14886. var len = queue.length;
  14887. while(len) {
  14888. currentQueue = queue;
  14889. queue = [];
  14890. while (++queueIndex < len) {
  14891. if (currentQueue) {
  14892. currentQueue[queueIndex].run();
  14893. }
  14894. }
  14895. queueIndex = -1;
  14896. len = queue.length;
  14897. }
  14898. currentQueue = null;
  14899. draining = false;
  14900. runClearTimeout(timeout);
  14901. }
  14902. process.nextTick = function (fun) {
  14903. var args = new Array(arguments.length - 1);
  14904. if (arguments.length > 1) {
  14905. for (var i = 1; i < arguments.length; i++) {
  14906. args[i - 1] = arguments[i];
  14907. }
  14908. }
  14909. queue.push(new Item(fun, args));
  14910. if (queue.length === 1 && !draining) {
  14911. runTimeout(drainQueue);
  14912. }
  14913. };
  14914. // v8 likes predictible objects
  14915. function Item(fun, array) {
  14916. this.fun = fun;
  14917. this.array = array;
  14918. }
  14919. Item.prototype.run = function () {
  14920. this.fun.apply(null, this.array);
  14921. };
  14922. process.title = 'browser';
  14923. process.browser = true;
  14924. process.env = {};
  14925. process.argv = [];
  14926. process.version = ''; // empty string to avoid regexp issues
  14927. process.versions = {};
  14928. function noop() {}
  14929. process.on = noop;
  14930. process.addListener = noop;
  14931. process.once = noop;
  14932. process.off = noop;
  14933. process.removeListener = noop;
  14934. process.removeAllListeners = noop;
  14935. process.emit = noop;
  14936. process.prependListener = noop;
  14937. process.prependOnceListener = noop;
  14938. process.listeners = function (name) { return [] }
  14939. process.binding = function (name) {
  14940. throw new Error('process.binding is not supported');
  14941. };
  14942. process.cwd = function () { return '/' };
  14943. process.chdir = function (dir) {
  14944. throw new Error('process.chdir is not supported');
  14945. };
  14946. process.umask = function() { return 0; };
  14947. },{}],170:[function(_dereq_,module,exports){
  14948. /**
  14949. * stringifier
  14950. *
  14951. * https://github.com/twada/stringifier
  14952. *
  14953. * Copyright (c) 2014-2018 Takuto Wada
  14954. * Licensed under the MIT license.
  14955. * https://twada.mit-license.org/2014-2018
  14956. */
  14957. 'use strict';
  14958. var traverse = _dereq_('traverse');
  14959. var typeName = _dereq_('type-name');
  14960. var assign = _dereq_('core-js/library/fn/object/assign');
  14961. var endsWith = _dereq_('core-js/library/fn/string/ends-with');
  14962. var s = _dereq_('./strategies');
  14963. function defaultHandlers () {
  14964. return {
  14965. 'null': s.always('null'),
  14966. 'undefined': s.always('undefined'),
  14967. 'function': s.prune(),
  14968. 'string': s.json(),
  14969. 'boolean': s.json(),
  14970. 'number': s.number(),
  14971. 'symbol': s.toStr(),
  14972. 'RegExp': s.toStr(),
  14973. 'String': s.newLike(),
  14974. 'Boolean': s.newLike(),
  14975. 'Number': s.newLike(),
  14976. 'Date': s.newLike(),
  14977. 'Array': s.array(),
  14978. 'Object': s.object(),
  14979. 'Error': s.object(null, ['message', 'code']),
  14980. '@default': s.object()
  14981. };
  14982. }
  14983. function defaultOptions () {
  14984. return {
  14985. maxDepth: null,
  14986. indent: null,
  14987. anonymous: '@Anonymous',
  14988. circular: '#@Circular#',
  14989. snip: '..(snip)',
  14990. lineSeparator: '\n',
  14991. typeFun: typeName
  14992. };
  14993. }
  14994. function createStringifier (customOptions) {
  14995. var options = assign({}, defaultOptions(), customOptions);
  14996. var handlers = assign({}, defaultHandlers(), options.handlers);
  14997. return function stringifyAny (push, x) {
  14998. var context = this;
  14999. var handler = handlerFor(context.node, options, handlers);
  15000. var currentPath = '/' + context.path.join('/');
  15001. var customization = handlers[currentPath];
  15002. var acc = {
  15003. context: context,
  15004. options: options,
  15005. handlers: handlers,
  15006. push: push
  15007. };
  15008. if (typeName(customization) === 'function') {
  15009. handler = customization;
  15010. } else if (typeName(customization) === 'number') {
  15011. handler = s.flow.compose(s.filters.truncate(customization),handler);
  15012. } else if (context.parent && typeName(context.parent.node) === 'Array' && !(context.key in context.parent.node)) {
  15013. // sparse arrays
  15014. handler = s.always('');
  15015. }
  15016. handler(acc, x);
  15017. return push;
  15018. };
  15019. }
  15020. function handlerFor (val, options, handlers) {
  15021. var tname = options.typeFun(val);
  15022. if (typeName(handlers[tname]) === 'function') {
  15023. return handlers[tname];
  15024. }
  15025. if (endsWith(tname, 'Error')) {
  15026. return handlers['Error'];
  15027. }
  15028. return handlers['@default'];
  15029. }
  15030. function walk (val, reducer) {
  15031. var buffer = [];
  15032. var push = function (str) {
  15033. buffer.push(str);
  15034. };
  15035. traverse(val).reduce(reducer, push);
  15036. return buffer.join('');
  15037. }
  15038. function stringify (val, options) {
  15039. return walk(val, createStringifier(options));
  15040. }
  15041. function stringifier (options) {
  15042. return function (val) {
  15043. return walk(val, createStringifier(options));
  15044. };
  15045. }
  15046. stringifier.stringify = stringify;
  15047. stringifier.strategies = s;
  15048. stringifier.defaultOptions = defaultOptions;
  15049. stringifier.defaultHandlers = defaultHandlers;
  15050. module.exports = stringifier;
  15051. },{"./strategies":171,"core-js/library/fn/object/assign":23,"core-js/library/fn/string/ends-with":27,"traverse":172,"type-name":173}],171:[function(_dereq_,module,exports){
  15052. 'use strict';
  15053. var typeName = _dereq_('type-name');
  15054. var forEach = _dereq_('core-js/library/fn/array/for-each');
  15055. var arrayFilter = _dereq_('core-js/library/fn/array/filter');
  15056. var reduceRight = _dereq_('core-js/library/fn/array/reduce-right');
  15057. var indexOf = _dereq_('core-js/library/fn/array/index-of');
  15058. var slice = Array.prototype.slice;
  15059. var END = {};
  15060. var ITERATE = {};
  15061. // arguments should end with end or iterate
  15062. function compose () {
  15063. var filters = slice.apply(arguments);
  15064. return reduceRight(filters, function(right, left) {
  15065. return left(right);
  15066. });
  15067. }
  15068. // skip children
  15069. function end () {
  15070. return function (acc, x) {
  15071. acc.context.keys = [];
  15072. return END;
  15073. };
  15074. }
  15075. // iterate children
  15076. function iterate () {
  15077. return function (acc, x) {
  15078. return ITERATE;
  15079. };
  15080. }
  15081. function filter (predicate) {
  15082. return function (next) {
  15083. return function (acc, x) {
  15084. var toBeIterated;
  15085. var isIteratingArray = (typeName(x) === 'Array');
  15086. if (typeName(predicate) === 'function') {
  15087. toBeIterated = [];
  15088. forEach(acc.context.keys, function (key) {
  15089. var indexOrKey = isIteratingArray ? parseInt(key, 10) : key;
  15090. var kvp = {
  15091. key: indexOrKey,
  15092. value: x[key]
  15093. };
  15094. var decision = predicate(kvp);
  15095. if (decision) {
  15096. toBeIterated.push(key);
  15097. }
  15098. if (typeName(decision) === 'number') {
  15099. truncateByKey(decision, key, acc);
  15100. }
  15101. if (typeName(decision) === 'function') {
  15102. customizeStrategyForKey(decision, key, acc);
  15103. }
  15104. });
  15105. acc.context.keys = toBeIterated;
  15106. }
  15107. return next(acc, x);
  15108. };
  15109. };
  15110. }
  15111. function customizeStrategyForKey (strategy, key, acc) {
  15112. acc.handlers[currentPath(key, acc)] = strategy;
  15113. }
  15114. function truncateByKey (size, key, acc) {
  15115. acc.handlers[currentPath(key, acc)] = size;
  15116. }
  15117. function currentPath (key, acc) {
  15118. var pathToCurrentNode = [''].concat(acc.context.path);
  15119. if (typeName(key) !== 'undefined') {
  15120. pathToCurrentNode.push(key);
  15121. }
  15122. return pathToCurrentNode.join('/');
  15123. }
  15124. function allowedKeys (orderedWhiteList) {
  15125. return function (next) {
  15126. return function (acc, x) {
  15127. var isIteratingArray = (typeName(x) === 'Array');
  15128. if (!isIteratingArray && typeName(orderedWhiteList) === 'Array') {
  15129. acc.context.keys = arrayFilter(orderedWhiteList, function (propKey) {
  15130. return x.hasOwnProperty(propKey);
  15131. });
  15132. }
  15133. return next(acc, x);
  15134. };
  15135. };
  15136. }
  15137. function safeKeys () {
  15138. return function (next) {
  15139. return function (acc, x) {
  15140. if (typeName(x) !== 'Array') {
  15141. acc.context.keys = arrayFilter(acc.context.keys, function (propKey) {
  15142. // Error handling for unsafe property access.
  15143. // For example, on PhantomJS,
  15144. // accessing HTMLInputElement.selectionEnd causes TypeError
  15145. try {
  15146. var val = x[propKey];
  15147. return true;
  15148. } catch (e) {
  15149. // skip unsafe key
  15150. return false;
  15151. }
  15152. });
  15153. }
  15154. return next(acc, x);
  15155. };
  15156. };
  15157. }
  15158. function arrayIndicesToKeys () {
  15159. return function (next) {
  15160. return function (acc, x) {
  15161. if (typeName(x) === 'Array' && 0 < x.length) {
  15162. var indices = Array(x.length);
  15163. for(var i = 0; i < x.length; i += 1) {
  15164. indices[i] = String(i); // traverse uses strings as keys
  15165. }
  15166. acc.context.keys = indices;
  15167. }
  15168. return next(acc, x);
  15169. };
  15170. };
  15171. }
  15172. function when (guard, then) {
  15173. return function (next) {
  15174. return function (acc, x) {
  15175. var kvp = {
  15176. key: acc.context.key,
  15177. value: x
  15178. };
  15179. if (guard(kvp, acc)) {
  15180. return then(acc, x);
  15181. }
  15182. return next(acc, x);
  15183. };
  15184. };
  15185. }
  15186. function truncate (size) {
  15187. return function (next) {
  15188. return function (acc, x) {
  15189. var orig = acc.push;
  15190. var ret;
  15191. acc.push = function (str) {
  15192. var savings = str.length - size;
  15193. var truncated;
  15194. if (savings <= size) {
  15195. orig.call(acc, str);
  15196. } else {
  15197. truncated = str.substring(0, size);
  15198. orig.call(acc, truncated + acc.options.snip);
  15199. }
  15200. };
  15201. ret = next(acc, x);
  15202. acc.push = orig;
  15203. return ret;
  15204. };
  15205. };
  15206. }
  15207. function constructorName () {
  15208. return function (next) {
  15209. return function (acc, x) {
  15210. var name = acc.options.typeFun(x);
  15211. if (name === '') {
  15212. name = acc.options.anonymous;
  15213. }
  15214. acc.push(name);
  15215. return next(acc, x);
  15216. };
  15217. };
  15218. }
  15219. function always (str) {
  15220. return function (next) {
  15221. return function (acc, x) {
  15222. acc.push(str);
  15223. return next(acc, x);
  15224. };
  15225. };
  15226. }
  15227. function optionValue (key) {
  15228. return function (next) {
  15229. return function (acc, x) {
  15230. acc.push(acc.options[key]);
  15231. return next(acc, x);
  15232. };
  15233. };
  15234. }
  15235. function json (replacer) {
  15236. return function (next) {
  15237. return function (acc, x) {
  15238. acc.push(JSON.stringify(x, replacer));
  15239. return next(acc, x);
  15240. };
  15241. };
  15242. }
  15243. function toStr () {
  15244. return function (next) {
  15245. return function (acc, x) {
  15246. acc.push(x.toString());
  15247. return next(acc, x);
  15248. };
  15249. };
  15250. }
  15251. function decorateArray () {
  15252. return function (next) {
  15253. return function (acc, x) {
  15254. acc.context.before(function (node) {
  15255. acc.push('[');
  15256. });
  15257. acc.context.after(function (node) {
  15258. afterAllChildren(this, acc.push, acc.options);
  15259. acc.push(']');
  15260. });
  15261. acc.context.pre(function (val, key) {
  15262. beforeEachChild(this, acc.push, acc.options);
  15263. });
  15264. acc.context.post(function (childContext) {
  15265. afterEachChild(childContext, acc.push);
  15266. });
  15267. return next(acc, x);
  15268. };
  15269. };
  15270. }
  15271. function decorateObject () {
  15272. return function (next) {
  15273. return function (acc, x) {
  15274. acc.context.before(function (node) {
  15275. acc.push('{');
  15276. });
  15277. acc.context.after(function (node) {
  15278. afterAllChildren(this, acc.push, acc.options);
  15279. acc.push('}');
  15280. });
  15281. acc.context.pre(function (val, key) {
  15282. beforeEachChild(this, acc.push, acc.options);
  15283. acc.push(sanitizeKey(key) + (acc.options.indent ? ': ' : ':'));
  15284. });
  15285. acc.context.post(function (childContext) {
  15286. afterEachChild(childContext, acc.push);
  15287. });
  15288. return next(acc, x);
  15289. };
  15290. };
  15291. }
  15292. function sanitizeKey (key) {
  15293. return /^[A-Za-z_]+$/.test(key) ? key : JSON.stringify(key);
  15294. }
  15295. function afterAllChildren (context, push, options) {
  15296. if (options.indent && 0 < context.keys.length) {
  15297. push(options.lineSeparator);
  15298. for(var i = 0; i < context.level; i += 1) { // indent level - 1
  15299. push(options.indent);
  15300. }
  15301. }
  15302. }
  15303. function beforeEachChild (context, push, options) {
  15304. if (options.indent) {
  15305. push(options.lineSeparator);
  15306. for(var i = 0; i <= context.level; i += 1) {
  15307. push(options.indent);
  15308. }
  15309. }
  15310. }
  15311. function afterEachChild (childContext, push) {
  15312. if (!childContext.isLast) {
  15313. push(',');
  15314. }
  15315. }
  15316. function nan (kvp, acc) {
  15317. return kvp.value !== kvp.value;
  15318. }
  15319. function positiveInfinity (kvp, acc) {
  15320. return !isFinite(kvp.value) && kvp.value === Infinity;
  15321. }
  15322. function negativeInfinity (kvp, acc) {
  15323. return !isFinite(kvp.value) && kvp.value !== Infinity;
  15324. }
  15325. function circular (kvp, acc) {
  15326. return acc.context.circular;
  15327. }
  15328. function maxDepth (kvp, acc) {
  15329. return (acc.options.maxDepth && acc.options.maxDepth <= acc.context.level);
  15330. }
  15331. var prune = compose(
  15332. always('#'),
  15333. constructorName(),
  15334. always('#'),
  15335. end()
  15336. );
  15337. var omitNaN = when(nan, compose(
  15338. always('NaN'),
  15339. end()
  15340. ));
  15341. var omitPositiveInfinity = when(positiveInfinity, compose(
  15342. always('Infinity'),
  15343. end()
  15344. ));
  15345. var omitNegativeInfinity = when(negativeInfinity, compose(
  15346. always('-Infinity'),
  15347. end()
  15348. ));
  15349. var omitCircular = when(circular, compose(
  15350. optionValue('circular'),
  15351. end()
  15352. ));
  15353. var omitMaxDepth = when(maxDepth, prune);
  15354. module.exports = {
  15355. filters: {
  15356. always: always,
  15357. optionValue: optionValue,
  15358. constructorName: constructorName,
  15359. json: json,
  15360. toStr: toStr,
  15361. prune: prune,
  15362. truncate: truncate,
  15363. decorateArray: decorateArray,
  15364. decorateObject: decorateObject
  15365. },
  15366. flow: {
  15367. compose: compose,
  15368. when: when,
  15369. allowedKeys: allowedKeys,
  15370. safeKeys: safeKeys,
  15371. arrayIndicesToKeys: arrayIndicesToKeys,
  15372. filter: filter,
  15373. iterate: iterate,
  15374. end: end
  15375. },
  15376. symbols: {
  15377. END: END,
  15378. ITERATE: ITERATE
  15379. },
  15380. always: function (str) {
  15381. return compose(always(str), end());
  15382. },
  15383. json: function () {
  15384. return compose(json(), end());
  15385. },
  15386. toStr: function () {
  15387. return compose(toStr(), end());
  15388. },
  15389. prune: function () {
  15390. return prune;
  15391. },
  15392. number: function () {
  15393. return compose(
  15394. omitNaN,
  15395. omitPositiveInfinity,
  15396. omitNegativeInfinity,
  15397. json(),
  15398. end()
  15399. );
  15400. },
  15401. newLike: function () {
  15402. return compose(
  15403. always('new '),
  15404. constructorName(),
  15405. always('('),
  15406. json(),
  15407. always(')'),
  15408. end()
  15409. );
  15410. },
  15411. array: function (predicate) {
  15412. return compose(
  15413. omitCircular,
  15414. omitMaxDepth,
  15415. decorateArray(),
  15416. arrayIndicesToKeys(),
  15417. filter(predicate),
  15418. iterate()
  15419. );
  15420. },
  15421. object: function (predicate, orderedWhiteList) {
  15422. return compose(
  15423. omitCircular,
  15424. omitMaxDepth,
  15425. constructorName(),
  15426. decorateObject(),
  15427. allowedKeys(orderedWhiteList),
  15428. safeKeys(),
  15429. filter(predicate),
  15430. iterate()
  15431. );
  15432. }
  15433. };
  15434. },{"core-js/library/fn/array/filter":14,"core-js/library/fn/array/for-each":15,"core-js/library/fn/array/index-of":16,"core-js/library/fn/array/reduce-right":19,"type-name":173}],172:[function(_dereq_,module,exports){
  15435. var traverse = module.exports = function (obj) {
  15436. return new Traverse(obj);
  15437. };
  15438. function Traverse (obj) {
  15439. this.value = obj;
  15440. }
  15441. Traverse.prototype.get = function (ps) {
  15442. var node = this.value;
  15443. for (var i = 0; i < ps.length; i ++) {
  15444. var key = ps[i];
  15445. if (!node || !hasOwnProperty.call(node, key)) {
  15446. node = undefined;
  15447. break;
  15448. }
  15449. node = node[key];
  15450. }
  15451. return node;
  15452. };
  15453. Traverse.prototype.has = function (ps) {
  15454. var node = this.value;
  15455. for (var i = 0; i < ps.length; i ++) {
  15456. var key = ps[i];
  15457. if (!node || !hasOwnProperty.call(node, key)) {
  15458. return false;
  15459. }
  15460. node = node[key];
  15461. }
  15462. return true;
  15463. };
  15464. Traverse.prototype.set = function (ps, value) {
  15465. var node = this.value;
  15466. for (var i = 0; i < ps.length - 1; i ++) {
  15467. var key = ps[i];
  15468. if (!hasOwnProperty.call(node, key)) node[key] = {};
  15469. node = node[key];
  15470. }
  15471. node[ps[i]] = value;
  15472. return value;
  15473. };
  15474. Traverse.prototype.map = function (cb) {
  15475. return walk(this.value, cb, true);
  15476. };
  15477. Traverse.prototype.forEach = function (cb) {
  15478. this.value = walk(this.value, cb, false);
  15479. return this.value;
  15480. };
  15481. Traverse.prototype.reduce = function (cb, init) {
  15482. var skip = arguments.length === 1;
  15483. var acc = skip ? this.value : init;
  15484. this.forEach(function (x) {
  15485. if (!this.isRoot || !skip) {
  15486. acc = cb.call(this, acc, x);
  15487. }
  15488. });
  15489. return acc;
  15490. };
  15491. Traverse.prototype.paths = function () {
  15492. var acc = [];
  15493. this.forEach(function (x) {
  15494. acc.push(this.path);
  15495. });
  15496. return acc;
  15497. };
  15498. Traverse.prototype.nodes = function () {
  15499. var acc = [];
  15500. this.forEach(function (x) {
  15501. acc.push(this.node);
  15502. });
  15503. return acc;
  15504. };
  15505. Traverse.prototype.clone = function () {
  15506. var parents = [], nodes = [];
  15507. return (function clone (src) {
  15508. for (var i = 0; i < parents.length; i++) {
  15509. if (parents[i] === src) {
  15510. return nodes[i];
  15511. }
  15512. }
  15513. if (typeof src === 'object' && src !== null) {
  15514. var dst = copy(src);
  15515. parents.push(src);
  15516. nodes.push(dst);
  15517. forEach(objectKeys(src), function (key) {
  15518. dst[key] = clone(src[key]);
  15519. });
  15520. parents.pop();
  15521. nodes.pop();
  15522. return dst;
  15523. }
  15524. else {
  15525. return src;
  15526. }
  15527. })(this.value);
  15528. };
  15529. function walk (root, cb, immutable) {
  15530. var path = [];
  15531. var parents = [];
  15532. var alive = true;
  15533. return (function walker (node_) {
  15534. var node = immutable ? copy(node_) : node_;
  15535. var modifiers = {};
  15536. var keepGoing = true;
  15537. var state = {
  15538. node : node,
  15539. node_ : node_,
  15540. path : [].concat(path),
  15541. parent : parents[parents.length - 1],
  15542. parents : parents,
  15543. key : path.slice(-1)[0],
  15544. isRoot : path.length === 0,
  15545. level : path.length,
  15546. circular : null,
  15547. update : function (x, stopHere) {
  15548. if (!state.isRoot) {
  15549. state.parent.node[state.key] = x;
  15550. }
  15551. state.node = x;
  15552. if (stopHere) keepGoing = false;
  15553. },
  15554. 'delete' : function (stopHere) {
  15555. delete state.parent.node[state.key];
  15556. if (stopHere) keepGoing = false;
  15557. },
  15558. remove : function (stopHere) {
  15559. if (isArray(state.parent.node)) {
  15560. state.parent.node.splice(state.key, 1);
  15561. }
  15562. else {
  15563. delete state.parent.node[state.key];
  15564. }
  15565. if (stopHere) keepGoing = false;
  15566. },
  15567. keys : null,
  15568. before : function (f) { modifiers.before = f },
  15569. after : function (f) { modifiers.after = f },
  15570. pre : function (f) { modifiers.pre = f },
  15571. post : function (f) { modifiers.post = f },
  15572. stop : function () { alive = false },
  15573. block : function () { keepGoing = false }
  15574. };
  15575. if (!alive) return state;
  15576. function updateState() {
  15577. if (typeof state.node === 'object' && state.node !== null) {
  15578. if (!state.keys || state.node_ !== state.node) {
  15579. state.keys = objectKeys(state.node)
  15580. }
  15581. state.isLeaf = state.keys.length == 0;
  15582. for (var i = 0; i < parents.length; i++) {
  15583. if (parents[i].node_ === node_) {
  15584. state.circular = parents[i];
  15585. break;
  15586. }
  15587. }
  15588. }
  15589. else {
  15590. state.isLeaf = true;
  15591. state.keys = null;
  15592. }
  15593. state.notLeaf = !state.isLeaf;
  15594. state.notRoot = !state.isRoot;
  15595. }
  15596. updateState();
  15597. // use return values to update if defined
  15598. var ret = cb.call(state, state.node);
  15599. if (ret !== undefined && state.update) state.update(ret);
  15600. if (modifiers.before) modifiers.before.call(state, state.node);
  15601. if (!keepGoing) return state;
  15602. if (typeof state.node == 'object'
  15603. && state.node !== null && !state.circular) {
  15604. parents.push(state);
  15605. updateState();
  15606. forEach(state.keys, function (key, i) {
  15607. path.push(key);
  15608. if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);
  15609. var child = walker(state.node[key]);
  15610. if (immutable && hasOwnProperty.call(state.node, key)) {
  15611. state.node[key] = child.node;
  15612. }
  15613. child.isLast = i == state.keys.length - 1;
  15614. child.isFirst = i == 0;
  15615. if (modifiers.post) modifiers.post.call(state, child);
  15616. path.pop();
  15617. });
  15618. parents.pop();
  15619. }
  15620. if (modifiers.after) modifiers.after.call(state, state.node);
  15621. return state;
  15622. })(root).node;
  15623. }
  15624. function copy (src) {
  15625. if (typeof src === 'object' && src !== null) {
  15626. var dst;
  15627. if (isArray(src)) {
  15628. dst = [];
  15629. }
  15630. else if (isDate(src)) {
  15631. dst = new Date(src.getTime ? src.getTime() : src);
  15632. }
  15633. else if (isRegExp(src)) {
  15634. dst = new RegExp(src);
  15635. }
  15636. else if (isError(src)) {
  15637. dst = { message: src.message };
  15638. }
  15639. else if (isBoolean(src)) {
  15640. dst = new Boolean(src);
  15641. }
  15642. else if (isNumber(src)) {
  15643. dst = new Number(src);
  15644. }
  15645. else if (isString(src)) {
  15646. dst = new String(src);
  15647. }
  15648. else if (Object.create && Object.getPrototypeOf) {
  15649. dst = Object.create(Object.getPrototypeOf(src));
  15650. }
  15651. else if (src.constructor === Object) {
  15652. dst = {};
  15653. }
  15654. else {
  15655. var proto =
  15656. (src.constructor && src.constructor.prototype)
  15657. || src.__proto__
  15658. || {}
  15659. ;
  15660. var T = function () {};
  15661. T.prototype = proto;
  15662. dst = new T;
  15663. }
  15664. forEach(objectKeys(src), function (key) {
  15665. dst[key] = src[key];
  15666. });
  15667. return dst;
  15668. }
  15669. else return src;
  15670. }
  15671. var objectKeys = Object.keys || function keys (obj) {
  15672. var res = [];
  15673. for (var key in obj) res.push(key)
  15674. return res;
  15675. };
  15676. function toS (obj) { return Object.prototype.toString.call(obj) }
  15677. function isDate (obj) { return toS(obj) === '[object Date]' }
  15678. function isRegExp (obj) { return toS(obj) === '[object RegExp]' }
  15679. function isError (obj) { return toS(obj) === '[object Error]' }
  15680. function isBoolean (obj) { return toS(obj) === '[object Boolean]' }
  15681. function isNumber (obj) { return toS(obj) === '[object Number]' }
  15682. function isString (obj) { return toS(obj) === '[object String]' }
  15683. var isArray = Array.isArray || function isArray (xs) {
  15684. return Object.prototype.toString.call(xs) === '[object Array]';
  15685. };
  15686. var forEach = function (xs, fn) {
  15687. if (xs.forEach) return xs.forEach(fn)
  15688. else for (var i = 0; i < xs.length; i++) {
  15689. fn(xs[i], i, xs);
  15690. }
  15691. };
  15692. forEach(objectKeys(Traverse.prototype), function (key) {
  15693. traverse[key] = function (obj) {
  15694. var args = [].slice.call(arguments, 1);
  15695. var t = new Traverse(obj);
  15696. return t[key].apply(t, args);
  15697. };
  15698. });
  15699. var hasOwnProperty = Object.hasOwnProperty || function (obj, key) {
  15700. return key in obj;
  15701. };
  15702. },{}],173:[function(_dereq_,module,exports){
  15703. /**
  15704. * type-name - Just a reasonable typeof
  15705. *
  15706. * https://github.com/twada/type-name
  15707. *
  15708. * Copyright (c) 2014-2016 Takuto Wada
  15709. * Licensed under the MIT license.
  15710. * https://github.com/twada/type-name/blob/master/LICENSE
  15711. */
  15712. 'use strict';
  15713. var toStr = Object.prototype.toString;
  15714. function funcName (f) {
  15715. if (f.name) {
  15716. return f.name;
  15717. }
  15718. var match = /^\s*function\s*([^\(]*)/im.exec(f.toString());
  15719. return match ? match[1] : '';
  15720. }
  15721. function ctorName (obj) {
  15722. var strName = toStr.call(obj).slice(8, -1);
  15723. if ((strName === 'Object' || strName === 'Error') && obj.constructor) {
  15724. return funcName(obj.constructor);
  15725. }
  15726. return strName;
  15727. }
  15728. function typeName (val) {
  15729. var type;
  15730. if (val === null) {
  15731. return 'null';
  15732. }
  15733. type = typeof val;
  15734. if (type === 'object') {
  15735. return ctorName(val);
  15736. }
  15737. return type;
  15738. }
  15739. module.exports = typeName;
  15740. },{}],174:[function(_dereq_,module,exports){
  15741. // port of https://github.com/nodejs/node/blob/v6.3.0/lib/assert.js#L145-L248
  15742. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  15743. //
  15744. // Originally from narwhal.js (http://narwhaljs.org)
  15745. // Copyright (c) 2009 Thomas Robinson <280north.com>
  15746. //
  15747. // Permission is hereby granted, free of charge, to any person obtaining a copy
  15748. // of this software and associated documentation files (the 'Software'), to
  15749. // deal in the Software without restriction, including without limitation the
  15750. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  15751. // sell copies of the Software, and to permit persons to whom the Software is
  15752. // furnished to do so, subject to the following conditions:
  15753. //
  15754. // The above copyright notice and this permission notice shall be included in
  15755. // all copies or substantial portions of the Software.
  15756. //
  15757. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15758. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15759. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15760. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  15761. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  15762. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  15763. 'use strict';
  15764. var Buffer = _dereq_('buffer').Buffer;
  15765. var compare = Buffer.compare;
  15766. var indexOf = _dereq_('indexof');
  15767. var filter = _dereq_('array-filter');
  15768. var getPrototypeOf = Object.getPrototypeOf || function(obj) {
  15769. return obj.__proto__ || (
  15770. ((obj.constructor ? obj.constructor.prototype : Object.prototype))
  15771. );
  15772. };
  15773. function isEnumerable(obj, key) {
  15774. return Object.prototype.propertyIsEnumerable.call(obj, key);
  15775. };
  15776. function pToString(obj) {
  15777. return Object.prototype.toString.call(obj);
  15778. };
  15779. function isPrimitive(arg) {
  15780. return arg === null ||
  15781. typeof arg === 'boolean' ||
  15782. typeof arg === 'number' ||
  15783. typeof arg === 'string' ||
  15784. typeof arg === 'symbol' || // ES6 symbol
  15785. typeof arg === 'undefined';
  15786. }
  15787. function isObject(arg) {
  15788. return typeof arg === 'object' && arg !== null;
  15789. }
  15790. function isDate(d) {
  15791. return isObject(d) && pToString(d) === '[object Date]';
  15792. }
  15793. function isRegExp(re) {
  15794. return isObject(re) && pToString(re) === '[object RegExp]';
  15795. }
  15796. var isArguments = (function () {
  15797. function isArg(obj) {
  15798. return isObject(obj) && pToString(obj) == '[object Arguments]';
  15799. }
  15800. // dealing with old IEs (There's no Arguments type)
  15801. if (!isArg(arguments)) {
  15802. return function(obj) {
  15803. return isObject(obj) &&
  15804. typeof obj.length === 'number' &&
  15805. obj.length >= 0 &&
  15806. pToString(obj) !== '[object Array]' &&
  15807. pToString(obj.callee) === '[object Function]';
  15808. };
  15809. } else {
  15810. return isArg;
  15811. }
  15812. })();
  15813. function fromBufferSupport() {
  15814. try {
  15815. return typeof Buffer.from === 'function' && !!Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
  15816. } catch (e) {
  15817. // Buffer.from under Node 4.x causes `TypeError: this is not a typed array.`
  15818. return false;
  15819. }
  15820. }
  15821. var toBuffer = (function () {
  15822. // check whether Buffer constructor accepts ArrayBuffer or not
  15823. function isBufferConstructorAcceptsArrayBuffer() {
  15824. try {
  15825. return typeof Uint8Array === 'function' && (new Buffer(new Uint8Array([1]).buffer)[0] === 1);
  15826. } catch (e) {
  15827. return false;
  15828. }
  15829. }
  15830. if (isBufferConstructorAcceptsArrayBuffer()) {
  15831. // Node 4.x
  15832. return function (ab) {
  15833. return new Buffer(ab);
  15834. };
  15835. } else {
  15836. // Node 0.10.x and 0.12.x
  15837. return function (ab) {
  15838. var buffer = new Buffer(ab.byteLength);
  15839. var view = new Uint8Array(ab);
  15840. for (var i = 0; i < buffer.length; ++i) {
  15841. buffer[i] = view[i];
  15842. }
  15843. return buffer;
  15844. };
  15845. }
  15846. })();
  15847. var bufferFrom = fromBufferSupport() ? Buffer.from : toBuffer;
  15848. var objectKeys = (function () {
  15849. var OLD_V8_ARRAY_BUFFER_ENUM = ['BYTES_PER_ELEMENT','get','set','slice','subarray','buffer','length','byteOffset','byteLength'];
  15850. var keys = Object.keys || _dereq_('object-keys');
  15851. return function objectKeys(obj) {
  15852. // avoid iterating enumerable properties of ArrayBuffer under old V8
  15853. if (isEnumerable(obj, 'buffer') &&
  15854. isEnumerable(obj, 'byteOffset') &&
  15855. isEnumerable(obj, 'byteLength')) {
  15856. return filter(keys(obj), function (k) {
  15857. return indexOf(OLD_V8_ARRAY_BUFFER_ENUM, k) === -1;
  15858. });
  15859. } else {
  15860. return keys(obj);
  15861. }
  15862. };
  15863. })();
  15864. function _deepEqual(actual, expected, strict, memos) {
  15865. // 7.1. All identical values are equivalent, as determined by ===.
  15866. if (actual === expected) {
  15867. return true;
  15868. } else if (actual instanceof Buffer && expected instanceof Buffer) {
  15869. return compare(actual, expected) === 0;
  15870. // 7.2. If the expected value is a Date object, the actual value is
  15871. // equivalent if it is also a Date object that refers to the same time.
  15872. } else if (isDate(actual) && isDate(expected)) {
  15873. return actual.getTime() === expected.getTime();
  15874. // 7.3 If the expected value is a RegExp object, the actual value is
  15875. // equivalent if it is also a RegExp object with the same source and
  15876. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  15877. } else if (isRegExp(actual) && isRegExp(expected)) {
  15878. return actual.source === expected.source &&
  15879. actual.global === expected.global &&
  15880. actual.multiline === expected.multiline &&
  15881. actual.lastIndex === expected.lastIndex &&
  15882. actual.ignoreCase === expected.ignoreCase;
  15883. // 7.4. Other pairs that do not both pass typeof value == 'object',
  15884. // equivalence is determined by ==.
  15885. } else if ((actual === null || typeof actual !== 'object') &&
  15886. (expected === null || typeof expected !== 'object')) {
  15887. return strict ? actual === expected : actual == expected;
  15888. // If both values are instances of typed arrays, wrap their underlying
  15889. // ArrayBuffers in a Buffer each to increase performance
  15890. // This optimization requires the arrays to have the same type as checked by
  15891. // Object.prototype.toString (aka pToString). Never perform binary
  15892. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  15893. // bit patterns are not identical.
  15894. } else if (typeof ArrayBuffer === 'function' && typeof ArrayBuffer.isView === 'function' &&
  15895. ArrayBuffer.isView(actual) && ArrayBuffer.isView(expected) &&
  15896. pToString(actual) === pToString(expected) &&
  15897. !(actual instanceof Float32Array ||
  15898. actual instanceof Float64Array)) {
  15899. return compare(bufferFrom(actual.buffer),
  15900. bufferFrom(expected.buffer)) === 0;
  15901. // 7.5 For all other Object pairs, including Array objects, equivalence is
  15902. // determined by having the same number of owned properties (as verified
  15903. // with Object.prototype.hasOwnProperty.call), the same set of keys
  15904. // (although not necessarily the same order), equivalent values for every
  15905. // corresponding key, and an identical 'prototype' property. Note: this
  15906. // accounts for both named and indexed properties on Arrays.
  15907. } else {
  15908. memos = memos || {actual: [], expected: []};
  15909. var actualIndex = indexOf(memos.actual, actual);
  15910. if (actualIndex !== -1) {
  15911. if (actualIndex === indexOf(memos.expected, expected)) {
  15912. return true;
  15913. }
  15914. }
  15915. memos.actual.push(actual);
  15916. memos.expected.push(expected);
  15917. return objEquiv(actual, expected, strict, memos);
  15918. }
  15919. }
  15920. function objEquiv(a, b, strict, actualVisitedObjects) {
  15921. if (a === null || a === undefined || b === null || b === undefined)
  15922. return false;
  15923. // if one is a primitive, the other must be same
  15924. if (isPrimitive(a) || isPrimitive(b))
  15925. return a === b;
  15926. if (strict && getPrototypeOf(a) !== getPrototypeOf(b))
  15927. return false;
  15928. var aIsArgs = isArguments(a),
  15929. bIsArgs = isArguments(b);
  15930. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  15931. return false;
  15932. var ka = objectKeys(a),
  15933. kb = objectKeys(b),
  15934. key, i;
  15935. // having the same number of owned properties (keys incorporates
  15936. // hasOwnProperty)
  15937. if (ka.length != kb.length)
  15938. return false;
  15939. //the same set of keys (although not necessarily the same order),
  15940. ka.sort();
  15941. kb.sort();
  15942. //~~~cheap key test
  15943. for (i = ka.length - 1; i >= 0; i--) {
  15944. if (ka[i] != kb[i])
  15945. return false;
  15946. }
  15947. //equivalent values for every corresponding key, and
  15948. //~~~possibly expensive deep test
  15949. for (i = ka.length - 1; i >= 0; i--) {
  15950. key = ka[i];
  15951. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  15952. return false;
  15953. }
  15954. return true;
  15955. }
  15956. module.exports = _deepEqual;
  15957. },{"array-filter":6,"buffer":12,"indexof":143,"object-keys":146}],175:[function(_dereq_,module,exports){
  15958. arguments[4][9][0].apply(exports,arguments)
  15959. },{"dup":9}],176:[function(_dereq_,module,exports){
  15960. arguments[4][10][0].apply(exports,arguments)
  15961. },{"./support/isBuffer":175,"_process":169,"dup":10,"inherits":144}],177:[function(_dereq_,module,exports){
  15962. module.exports = extend
  15963. var hasOwnProperty = Object.prototype.hasOwnProperty;
  15964. function extend(target) {
  15965. for (var i = 1; i < arguments.length; i++) {
  15966. var source = arguments[i]
  15967. for (var key in source) {
  15968. if (hasOwnProperty.call(source, key)) {
  15969. target[key] = source[key]
  15970. }
  15971. }
  15972. }
  15973. return target
  15974. }
  15975. },{}]},{},[1])(1)
  15976. });