worker-javascript.js 337 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531
  1. "no use strict";
  2. !(function(window) {
  3. if (typeof window.window != "undefined" && window.document)
  4. return;
  5. if (window.require && window.define)
  6. return;
  7. if (!window.console) {
  8. window.console = function() {
  9. var msgs = Array.prototype.slice.call(arguments, 0);
  10. postMessage({type: "log", data: msgs});
  11. };
  12. window.console.error =
  13. window.console.warn =
  14. window.console.log =
  15. window.console.trace = window.console;
  16. }
  17. window.window = window;
  18. window.ace = window;
  19. window.onerror = function(message, file, line, col, err) {
  20. postMessage({type: "error", data: {
  21. message: message,
  22. data: err.data,
  23. file: file,
  24. line: line,
  25. col: col,
  26. stack: err.stack
  27. }});
  28. };
  29. window.normalizeModule = function(parentId, moduleName) {
  30. // normalize plugin requires
  31. if (moduleName.indexOf("!") !== -1) {
  32. var chunks = moduleName.split("!");
  33. return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
  34. }
  35. // normalize relative requires
  36. if (moduleName.charAt(0) == ".") {
  37. var base = parentId.split("/").slice(0, -1).join("/");
  38. moduleName = (base ? base + "/" : "") + moduleName;
  39. while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
  40. var previous = moduleName;
  41. moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  42. }
  43. }
  44. return moduleName;
  45. };
  46. window.require = function require(parentId, id) {
  47. if (!id) {
  48. id = parentId;
  49. parentId = null;
  50. }
  51. if (!id.charAt)
  52. throw new Error("worker.js require() accepts only (parentId, id) as arguments");
  53. id = window.normalizeModule(parentId, id);
  54. var module = window.require.modules[id];
  55. if (module) {
  56. if (!module.initialized) {
  57. module.initialized = true;
  58. module.exports = module.factory().exports;
  59. }
  60. return module.exports;
  61. }
  62. if (!window.require.tlns)
  63. return console.log("unable to load " + id);
  64. var path = resolveModuleId(id, window.require.tlns);
  65. if (path.slice(-3) != ".js") path += ".js";
  66. window.require.id = id;
  67. window.require.modules[id] = {}; // prevent infinite loop on broken modules
  68. importScripts(path);
  69. return window.require(parentId, id);
  70. };
  71. function resolveModuleId(id, paths) {
  72. var testPath = id, tail = "";
  73. while (testPath) {
  74. var alias = paths[testPath];
  75. if (typeof alias == "string") {
  76. return alias + tail;
  77. } else if (alias) {
  78. return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
  79. } else if (alias === false) {
  80. return "";
  81. }
  82. var i = testPath.lastIndexOf("/");
  83. if (i === -1) break;
  84. tail = testPath.substr(i) + tail;
  85. testPath = testPath.slice(0, i);
  86. }
  87. return id;
  88. }
  89. window.require.modules = {};
  90. window.require.tlns = {};
  91. window.define = function(id, deps, factory) {
  92. if (arguments.length == 2) {
  93. factory = deps;
  94. if (typeof id != "string") {
  95. deps = id;
  96. id = window.require.id;
  97. }
  98. } else if (arguments.length == 1) {
  99. factory = id;
  100. deps = [];
  101. id = window.require.id;
  102. }
  103. if (typeof factory != "function") {
  104. window.require.modules[id] = {
  105. exports: factory,
  106. initialized: true
  107. };
  108. return;
  109. }
  110. if (!deps.length)
  111. // If there is no dependencies, we inject "require", "exports" and
  112. // "module" as dependencies, to provide CommonJS compatibility.
  113. deps = ["require", "exports", "module"];
  114. var req = function(childId) {
  115. return window.require(id, childId);
  116. };
  117. window.require.modules[id] = {
  118. exports: {},
  119. factory: function() {
  120. var module = this;
  121. var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
  122. switch (dep) {
  123. // Because "require", "exports" and "module" aren't actual
  124. // dependencies, we must handle them seperately.
  125. case "require": return req;
  126. case "exports": return module.exports;
  127. case "module": return module;
  128. // But for all other dependencies, we can just go ahead and
  129. // require them.
  130. default: return req(dep);
  131. }
  132. }));
  133. if (returnExports)
  134. module.exports = returnExports;
  135. return module;
  136. }
  137. };
  138. };
  139. window.define.amd = {};
  140. require.tlns = {};
  141. window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
  142. for (var i in topLevelNamespaces)
  143. require.tlns[i] = topLevelNamespaces[i];
  144. };
  145. window.initSender = function initSender() {
  146. var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
  147. var oop = window.require("ace/lib/oop");
  148. var Sender = function() {};
  149. (function() {
  150. oop.implement(this, EventEmitter);
  151. this.callback = function(data, callbackId) {
  152. postMessage({
  153. type: "call",
  154. id: callbackId,
  155. data: data
  156. });
  157. };
  158. this.emit = function(name, data) {
  159. postMessage({
  160. type: "event",
  161. name: name,
  162. data: data
  163. });
  164. };
  165. }).call(Sender.prototype);
  166. return new Sender();
  167. };
  168. var main = window.main = null;
  169. var sender = window.sender = null;
  170. window.onmessage = function(e) {
  171. var msg = e.data;
  172. if (msg.event && sender) {
  173. sender._signal(msg.event, msg.data);
  174. }
  175. else if (msg.command) {
  176. if (main[msg.command])
  177. main[msg.command].apply(main, msg.args);
  178. else if (window[msg.command])
  179. window[msg.command].apply(window, msg.args);
  180. else
  181. throw new Error("Unknown command:" + msg.command);
  182. }
  183. else if (msg.init) {
  184. window.initBaseUrls(msg.tlns);
  185. require("ace/lib/es5-shim");
  186. sender = window.sender = window.initSender();
  187. var clazz = require(msg.module)[msg.classname];
  188. main = window.main = new clazz(sender);
  189. }
  190. };
  191. })(this);
  192. ace.define("ace/lib/oop",[], function(require, exports, module) {
  193. "use strict";
  194. exports.inherits = function(ctor, superCtor) {
  195. ctor.super_ = superCtor;
  196. ctor.prototype = Object.create(superCtor.prototype, {
  197. constructor: {
  198. value: ctor,
  199. enumerable: false,
  200. writable: true,
  201. configurable: true
  202. }
  203. });
  204. };
  205. exports.mixin = function(obj, mixin) {
  206. for (var key in mixin) {
  207. obj[key] = mixin[key];
  208. }
  209. return obj;
  210. };
  211. exports.implement = function(proto, mixin) {
  212. exports.mixin(proto, mixin);
  213. };
  214. });
  215. ace.define("ace/range",[], function(require, exports, module) {
  216. "use strict";
  217. var comparePoints = function(p1, p2) {
  218. return p1.row - p2.row || p1.column - p2.column;
  219. };
  220. var Range = function(startRow, startColumn, endRow, endColumn) {
  221. this.start = {
  222. row: startRow,
  223. column: startColumn
  224. };
  225. this.end = {
  226. row: endRow,
  227. column: endColumn
  228. };
  229. };
  230. (function() {
  231. this.isEqual = function(range) {
  232. return this.start.row === range.start.row &&
  233. this.end.row === range.end.row &&
  234. this.start.column === range.start.column &&
  235. this.end.column === range.end.column;
  236. };
  237. this.toString = function() {
  238. return ("Range: [" + this.start.row + "/" + this.start.column +
  239. "] -> [" + this.end.row + "/" + this.end.column + "]");
  240. };
  241. this.contains = function(row, column) {
  242. return this.compare(row, column) == 0;
  243. };
  244. this.compareRange = function(range) {
  245. var cmp,
  246. end = range.end,
  247. start = range.start;
  248. cmp = this.compare(end.row, end.column);
  249. if (cmp == 1) {
  250. cmp = this.compare(start.row, start.column);
  251. if (cmp == 1) {
  252. return 2;
  253. } else if (cmp == 0) {
  254. return 1;
  255. } else {
  256. return 0;
  257. }
  258. } else if (cmp == -1) {
  259. return -2;
  260. } else {
  261. cmp = this.compare(start.row, start.column);
  262. if (cmp == -1) {
  263. return -1;
  264. } else if (cmp == 1) {
  265. return 42;
  266. } else {
  267. return 0;
  268. }
  269. }
  270. };
  271. this.comparePoint = function(p) {
  272. return this.compare(p.row, p.column);
  273. };
  274. this.containsRange = function(range) {
  275. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  276. };
  277. this.intersects = function(range) {
  278. var cmp = this.compareRange(range);
  279. return (cmp == -1 || cmp == 0 || cmp == 1);
  280. };
  281. this.isEnd = function(row, column) {
  282. return this.end.row == row && this.end.column == column;
  283. };
  284. this.isStart = function(row, column) {
  285. return this.start.row == row && this.start.column == column;
  286. };
  287. this.setStart = function(row, column) {
  288. if (typeof row == "object") {
  289. this.start.column = row.column;
  290. this.start.row = row.row;
  291. } else {
  292. this.start.row = row;
  293. this.start.column = column;
  294. }
  295. };
  296. this.setEnd = function(row, column) {
  297. if (typeof row == "object") {
  298. this.end.column = row.column;
  299. this.end.row = row.row;
  300. } else {
  301. this.end.row = row;
  302. this.end.column = column;
  303. }
  304. };
  305. this.inside = function(row, column) {
  306. if (this.compare(row, column) == 0) {
  307. if (this.isEnd(row, column) || this.isStart(row, column)) {
  308. return false;
  309. } else {
  310. return true;
  311. }
  312. }
  313. return false;
  314. };
  315. this.insideStart = function(row, column) {
  316. if (this.compare(row, column) == 0) {
  317. if (this.isEnd(row, column)) {
  318. return false;
  319. } else {
  320. return true;
  321. }
  322. }
  323. return false;
  324. };
  325. this.insideEnd = function(row, column) {
  326. if (this.compare(row, column) == 0) {
  327. if (this.isStart(row, column)) {
  328. return false;
  329. } else {
  330. return true;
  331. }
  332. }
  333. return false;
  334. };
  335. this.compare = function(row, column) {
  336. if (!this.isMultiLine()) {
  337. if (row === this.start.row) {
  338. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  339. }
  340. }
  341. if (row < this.start.row)
  342. return -1;
  343. if (row > this.end.row)
  344. return 1;
  345. if (this.start.row === row)
  346. return column >= this.start.column ? 0 : -1;
  347. if (this.end.row === row)
  348. return column <= this.end.column ? 0 : 1;
  349. return 0;
  350. };
  351. this.compareStart = function(row, column) {
  352. if (this.start.row == row && this.start.column == column) {
  353. return -1;
  354. } else {
  355. return this.compare(row, column);
  356. }
  357. };
  358. this.compareEnd = function(row, column) {
  359. if (this.end.row == row && this.end.column == column) {
  360. return 1;
  361. } else {
  362. return this.compare(row, column);
  363. }
  364. };
  365. this.compareInside = function(row, column) {
  366. if (this.end.row == row && this.end.column == column) {
  367. return 1;
  368. } else if (this.start.row == row && this.start.column == column) {
  369. return -1;
  370. } else {
  371. return this.compare(row, column);
  372. }
  373. };
  374. this.clipRows = function(firstRow, lastRow) {
  375. if (this.end.row > lastRow)
  376. var end = {row: lastRow + 1, column: 0};
  377. else if (this.end.row < firstRow)
  378. var end = {row: firstRow, column: 0};
  379. if (this.start.row > lastRow)
  380. var start = {row: lastRow + 1, column: 0};
  381. else if (this.start.row < firstRow)
  382. var start = {row: firstRow, column: 0};
  383. return Range.fromPoints(start || this.start, end || this.end);
  384. };
  385. this.extend = function(row, column) {
  386. var cmp = this.compare(row, column);
  387. if (cmp == 0)
  388. return this;
  389. else if (cmp == -1)
  390. var start = {row: row, column: column};
  391. else
  392. var end = {row: row, column: column};
  393. return Range.fromPoints(start || this.start, end || this.end);
  394. };
  395. this.isEmpty = function() {
  396. return (this.start.row === this.end.row && this.start.column === this.end.column);
  397. };
  398. this.isMultiLine = function() {
  399. return (this.start.row !== this.end.row);
  400. };
  401. this.clone = function() {
  402. return Range.fromPoints(this.start, this.end);
  403. };
  404. this.collapseRows = function() {
  405. if (this.end.column == 0)
  406. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
  407. else
  408. return new Range(this.start.row, 0, this.end.row, 0);
  409. };
  410. this.toScreenRange = function(session) {
  411. var screenPosStart = session.documentToScreenPosition(this.start);
  412. var screenPosEnd = session.documentToScreenPosition(this.end);
  413. return new Range(
  414. screenPosStart.row, screenPosStart.column,
  415. screenPosEnd.row, screenPosEnd.column
  416. );
  417. };
  418. this.moveBy = function(row, column) {
  419. this.start.row += row;
  420. this.start.column += column;
  421. this.end.row += row;
  422. this.end.column += column;
  423. };
  424. }).call(Range.prototype);
  425. Range.fromPoints = function(start, end) {
  426. return new Range(start.row, start.column, end.row, end.column);
  427. };
  428. Range.comparePoints = comparePoints;
  429. Range.comparePoints = function(p1, p2) {
  430. return p1.row - p2.row || p1.column - p2.column;
  431. };
  432. exports.Range = Range;
  433. });
  434. ace.define("ace/apply_delta",[], function(require, exports, module) {
  435. "use strict";
  436. function throwDeltaError(delta, errorText){
  437. console.log("Invalid Delta:", delta);
  438. throw "Invalid Delta: " + errorText;
  439. }
  440. function positionInDocument(docLines, position) {
  441. return position.row >= 0 && position.row < docLines.length &&
  442. position.column >= 0 && position.column <= docLines[position.row].length;
  443. }
  444. function validateDelta(docLines, delta) {
  445. if (delta.action != "insert" && delta.action != "remove")
  446. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  447. if (!(delta.lines instanceof Array))
  448. throwDeltaError(delta, "delta.lines must be an Array");
  449. if (!delta.start || !delta.end)
  450. throwDeltaError(delta, "delta.start/end must be an present");
  451. var start = delta.start;
  452. if (!positionInDocument(docLines, delta.start))
  453. throwDeltaError(delta, "delta.start must be contained in document");
  454. var end = delta.end;
  455. if (delta.action == "remove" && !positionInDocument(docLines, end))
  456. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  457. var numRangeRows = end.row - start.row;
  458. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  459. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  460. throwDeltaError(delta, "delta.range must match delta lines");
  461. }
  462. exports.applyDelta = function(docLines, delta, doNotValidate) {
  463. var row = delta.start.row;
  464. var startColumn = delta.start.column;
  465. var line = docLines[row] || "";
  466. switch (delta.action) {
  467. case "insert":
  468. var lines = delta.lines;
  469. if (lines.length === 1) {
  470. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  471. } else {
  472. var args = [row, 1].concat(delta.lines);
  473. docLines.splice.apply(docLines, args);
  474. docLines[row] = line.substring(0, startColumn) + docLines[row];
  475. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  476. }
  477. break;
  478. case "remove":
  479. var endColumn = delta.end.column;
  480. var endRow = delta.end.row;
  481. if (row === endRow) {
  482. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  483. } else {
  484. docLines.splice(
  485. row, endRow - row + 1,
  486. line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
  487. );
  488. }
  489. break;
  490. }
  491. };
  492. });
  493. ace.define("ace/lib/event_emitter",[], function(require, exports, module) {
  494. "use strict";
  495. var EventEmitter = {};
  496. var stopPropagation = function() { this.propagationStopped = true; };
  497. var preventDefault = function() { this.defaultPrevented = true; };
  498. EventEmitter._emit =
  499. EventEmitter._dispatchEvent = function(eventName, e) {
  500. this._eventRegistry || (this._eventRegistry = {});
  501. this._defaultHandlers || (this._defaultHandlers = {});
  502. var listeners = this._eventRegistry[eventName] || [];
  503. var defaultHandler = this._defaultHandlers[eventName];
  504. if (!listeners.length && !defaultHandler)
  505. return;
  506. if (typeof e != "object" || !e)
  507. e = {};
  508. if (!e.type)
  509. e.type = eventName;
  510. if (!e.stopPropagation)
  511. e.stopPropagation = stopPropagation;
  512. if (!e.preventDefault)
  513. e.preventDefault = preventDefault;
  514. listeners = listeners.slice();
  515. for (var i=0; i<listeners.length; i++) {
  516. listeners[i](e, this);
  517. if (e.propagationStopped)
  518. break;
  519. }
  520. if (defaultHandler && !e.defaultPrevented)
  521. return defaultHandler(e, this);
  522. };
  523. EventEmitter._signal = function(eventName, e) {
  524. var listeners = (this._eventRegistry || {})[eventName];
  525. if (!listeners)
  526. return;
  527. listeners = listeners.slice();
  528. for (var i=0; i<listeners.length; i++)
  529. listeners[i](e, this);
  530. };
  531. EventEmitter.once = function(eventName, callback) {
  532. var _self = this;
  533. this.addEventListener(eventName, function newCallback() {
  534. _self.removeEventListener(eventName, newCallback);
  535. callback.apply(null, arguments);
  536. });
  537. if (!callback) {
  538. return new Promise(function(resolve) {
  539. callback = resolve;
  540. });
  541. }
  542. };
  543. EventEmitter.setDefaultHandler = function(eventName, callback) {
  544. var handlers = this._defaultHandlers;
  545. if (!handlers)
  546. handlers = this._defaultHandlers = {_disabled_: {}};
  547. if (handlers[eventName]) {
  548. var old = handlers[eventName];
  549. var disabled = handlers._disabled_[eventName];
  550. if (!disabled)
  551. handlers._disabled_[eventName] = disabled = [];
  552. disabled.push(old);
  553. var i = disabled.indexOf(callback);
  554. if (i != -1)
  555. disabled.splice(i, 1);
  556. }
  557. handlers[eventName] = callback;
  558. };
  559. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  560. var handlers = this._defaultHandlers;
  561. if (!handlers)
  562. return;
  563. var disabled = handlers._disabled_[eventName];
  564. if (handlers[eventName] == callback) {
  565. if (disabled)
  566. this.setDefaultHandler(eventName, disabled.pop());
  567. } else if (disabled) {
  568. var i = disabled.indexOf(callback);
  569. if (i != -1)
  570. disabled.splice(i, 1);
  571. }
  572. };
  573. EventEmitter.on =
  574. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  575. this._eventRegistry = this._eventRegistry || {};
  576. var listeners = this._eventRegistry[eventName];
  577. if (!listeners)
  578. listeners = this._eventRegistry[eventName] = [];
  579. if (listeners.indexOf(callback) == -1)
  580. listeners[capturing ? "unshift" : "push"](callback);
  581. return callback;
  582. };
  583. EventEmitter.off =
  584. EventEmitter.removeListener =
  585. EventEmitter.removeEventListener = function(eventName, callback) {
  586. this._eventRegistry = this._eventRegistry || {};
  587. var listeners = this._eventRegistry[eventName];
  588. if (!listeners)
  589. return;
  590. var index = listeners.indexOf(callback);
  591. if (index !== -1)
  592. listeners.splice(index, 1);
  593. };
  594. EventEmitter.removeAllListeners = function(eventName) {
  595. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  596. };
  597. exports.EventEmitter = EventEmitter;
  598. });
  599. ace.define("ace/anchor",[], function(require, exports, module) {
  600. "use strict";
  601. var oop = require("./lib/oop");
  602. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  603. var Anchor = exports.Anchor = function(doc, row, column) {
  604. this.$onChange = this.onChange.bind(this);
  605. this.attach(doc);
  606. if (typeof column == "undefined")
  607. this.setPosition(row.row, row.column);
  608. else
  609. this.setPosition(row, column);
  610. };
  611. (function() {
  612. oop.implement(this, EventEmitter);
  613. this.getPosition = function() {
  614. return this.$clipPositionToDocument(this.row, this.column);
  615. };
  616. this.getDocument = function() {
  617. return this.document;
  618. };
  619. this.$insertRight = false;
  620. this.onChange = function(delta) {
  621. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  622. return;
  623. if (delta.start.row > this.row)
  624. return;
  625. var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
  626. this.setPosition(point.row, point.column, true);
  627. };
  628. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  629. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  630. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  631. }
  632. function $getTransformedPoint(delta, point, moveIfEqual) {
  633. var deltaIsInsert = delta.action == "insert";
  634. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  635. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  636. var deltaStart = delta.start;
  637. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  638. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  639. return {
  640. row: point.row,
  641. column: point.column
  642. };
  643. }
  644. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  645. return {
  646. row: point.row + deltaRowShift,
  647. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  648. };
  649. }
  650. return {
  651. row: deltaStart.row,
  652. column: deltaStart.column
  653. };
  654. }
  655. this.setPosition = function(row, column, noClip) {
  656. var pos;
  657. if (noClip) {
  658. pos = {
  659. row: row,
  660. column: column
  661. };
  662. } else {
  663. pos = this.$clipPositionToDocument(row, column);
  664. }
  665. if (this.row == pos.row && this.column == pos.column)
  666. return;
  667. var old = {
  668. row: this.row,
  669. column: this.column
  670. };
  671. this.row = pos.row;
  672. this.column = pos.column;
  673. this._signal("change", {
  674. old: old,
  675. value: pos
  676. });
  677. };
  678. this.detach = function() {
  679. this.document.removeEventListener("change", this.$onChange);
  680. };
  681. this.attach = function(doc) {
  682. this.document = doc || this.document;
  683. this.document.on("change", this.$onChange);
  684. };
  685. this.$clipPositionToDocument = function(row, column) {
  686. var pos = {};
  687. if (row >= this.document.getLength()) {
  688. pos.row = Math.max(0, this.document.getLength() - 1);
  689. pos.column = this.document.getLine(pos.row).length;
  690. }
  691. else if (row < 0) {
  692. pos.row = 0;
  693. pos.column = 0;
  694. }
  695. else {
  696. pos.row = row;
  697. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  698. }
  699. if (column < 0)
  700. pos.column = 0;
  701. return pos;
  702. };
  703. }).call(Anchor.prototype);
  704. });
  705. ace.define("ace/document",[], function(require, exports, module) {
  706. "use strict";
  707. var oop = require("./lib/oop");
  708. var applyDelta = require("./apply_delta").applyDelta;
  709. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  710. var Range = require("./range").Range;
  711. var Anchor = require("./anchor").Anchor;
  712. var Document = function(textOrLines) {
  713. this.$lines = [""];
  714. if (textOrLines.length === 0) {
  715. this.$lines = [""];
  716. } else if (Array.isArray(textOrLines)) {
  717. this.insertMergedLines({row: 0, column: 0}, textOrLines);
  718. } else {
  719. this.insert({row: 0, column:0}, textOrLines);
  720. }
  721. };
  722. (function() {
  723. oop.implement(this, EventEmitter);
  724. this.setValue = function(text) {
  725. var len = this.getLength() - 1;
  726. this.remove(new Range(0, 0, len, this.getLine(len).length));
  727. this.insert({row: 0, column: 0}, text);
  728. };
  729. this.getValue = function() {
  730. return this.getAllLines().join(this.getNewLineCharacter());
  731. };
  732. this.createAnchor = function(row, column) {
  733. return new Anchor(this, row, column);
  734. };
  735. if ("aaa".split(/a/).length === 0) {
  736. this.$split = function(text) {
  737. return text.replace(/\r\n|\r/g, "\n").split("\n");
  738. };
  739. } else {
  740. this.$split = function(text) {
  741. return text.split(/\r\n|\r|\n/);
  742. };
  743. }
  744. this.$detectNewLine = function(text) {
  745. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  746. this.$autoNewLine = match ? match[1] : "\n";
  747. this._signal("changeNewLineMode");
  748. };
  749. this.getNewLineCharacter = function() {
  750. switch (this.$newLineMode) {
  751. case "windows":
  752. return "\r\n";
  753. case "unix":
  754. return "\n";
  755. default:
  756. return this.$autoNewLine || "\n";
  757. }
  758. };
  759. this.$autoNewLine = "";
  760. this.$newLineMode = "auto";
  761. this.setNewLineMode = function(newLineMode) {
  762. if (this.$newLineMode === newLineMode)
  763. return;
  764. this.$newLineMode = newLineMode;
  765. this._signal("changeNewLineMode");
  766. };
  767. this.getNewLineMode = function() {
  768. return this.$newLineMode;
  769. };
  770. this.isNewLine = function(text) {
  771. return (text == "\r\n" || text == "\r" || text == "\n");
  772. };
  773. this.getLine = function(row) {
  774. return this.$lines[row] || "";
  775. };
  776. this.getLines = function(firstRow, lastRow) {
  777. return this.$lines.slice(firstRow, lastRow + 1);
  778. };
  779. this.getAllLines = function() {
  780. return this.getLines(0, this.getLength());
  781. };
  782. this.getLength = function() {
  783. return this.$lines.length;
  784. };
  785. this.getTextRange = function(range) {
  786. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  787. };
  788. this.getLinesForRange = function(range) {
  789. var lines;
  790. if (range.start.row === range.end.row) {
  791. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  792. } else {
  793. lines = this.getLines(range.start.row, range.end.row);
  794. lines[0] = (lines[0] || "").substring(range.start.column);
  795. var l = lines.length - 1;
  796. if (range.end.row - range.start.row == l)
  797. lines[l] = lines[l].substring(0, range.end.column);
  798. }
  799. return lines;
  800. };
  801. this.insertLines = function(row, lines) {
  802. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  803. return this.insertFullLines(row, lines);
  804. };
  805. this.removeLines = function(firstRow, lastRow) {
  806. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  807. return this.removeFullLines(firstRow, lastRow);
  808. };
  809. this.insertNewLine = function(position) {
  810. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
  811. return this.insertMergedLines(position, ["", ""]);
  812. };
  813. this.insert = function(position, text) {
  814. if (this.getLength() <= 1)
  815. this.$detectNewLine(text);
  816. return this.insertMergedLines(position, this.$split(text));
  817. };
  818. this.insertInLine = function(position, text) {
  819. var start = this.clippedPos(position.row, position.column);
  820. var end = this.pos(position.row, position.column + text.length);
  821. this.applyDelta({
  822. start: start,
  823. end: end,
  824. action: "insert",
  825. lines: [text]
  826. }, true);
  827. return this.clonePos(end);
  828. };
  829. this.clippedPos = function(row, column) {
  830. var length = this.getLength();
  831. if (row === undefined) {
  832. row = length;
  833. } else if (row < 0) {
  834. row = 0;
  835. } else if (row >= length) {
  836. row = length - 1;
  837. column = undefined;
  838. }
  839. var line = this.getLine(row);
  840. if (column == undefined)
  841. column = line.length;
  842. column = Math.min(Math.max(column, 0), line.length);
  843. return {row: row, column: column};
  844. };
  845. this.clonePos = function(pos) {
  846. return {row: pos.row, column: pos.column};
  847. };
  848. this.pos = function(row, column) {
  849. return {row: row, column: column};
  850. };
  851. this.$clipPosition = function(position) {
  852. var length = this.getLength();
  853. if (position.row >= length) {
  854. position.row = Math.max(0, length - 1);
  855. position.column = this.getLine(length - 1).length;
  856. } else {
  857. position.row = Math.max(0, position.row);
  858. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  859. }
  860. return position;
  861. };
  862. this.insertFullLines = function(row, lines) {
  863. row = Math.min(Math.max(row, 0), this.getLength());
  864. var column = 0;
  865. if (row < this.getLength()) {
  866. lines = lines.concat([""]);
  867. column = 0;
  868. } else {
  869. lines = [""].concat(lines);
  870. row--;
  871. column = this.$lines[row].length;
  872. }
  873. this.insertMergedLines({row: row, column: column}, lines);
  874. };
  875. this.insertMergedLines = function(position, lines) {
  876. var start = this.clippedPos(position.row, position.column);
  877. var end = {
  878. row: start.row + lines.length - 1,
  879. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  880. };
  881. this.applyDelta({
  882. start: start,
  883. end: end,
  884. action: "insert",
  885. lines: lines
  886. });
  887. return this.clonePos(end);
  888. };
  889. this.remove = function(range) {
  890. var start = this.clippedPos(range.start.row, range.start.column);
  891. var end = this.clippedPos(range.end.row, range.end.column);
  892. this.applyDelta({
  893. start: start,
  894. end: end,
  895. action: "remove",
  896. lines: this.getLinesForRange({start: start, end: end})
  897. });
  898. return this.clonePos(start);
  899. };
  900. this.removeInLine = function(row, startColumn, endColumn) {
  901. var start = this.clippedPos(row, startColumn);
  902. var end = this.clippedPos(row, endColumn);
  903. this.applyDelta({
  904. start: start,
  905. end: end,
  906. action: "remove",
  907. lines: this.getLinesForRange({start: start, end: end})
  908. }, true);
  909. return this.clonePos(start);
  910. };
  911. this.removeFullLines = function(firstRow, lastRow) {
  912. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  913. lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
  914. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  915. var deleteLastNewLine = lastRow < this.getLength() - 1;
  916. var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
  917. var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
  918. var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
  919. var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
  920. var range = new Range(startRow, startCol, endRow, endCol);
  921. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  922. this.applyDelta({
  923. start: range.start,
  924. end: range.end,
  925. action: "remove",
  926. lines: this.getLinesForRange(range)
  927. });
  928. return deletedLines;
  929. };
  930. this.removeNewLine = function(row) {
  931. if (row < this.getLength() - 1 && row >= 0) {
  932. this.applyDelta({
  933. start: this.pos(row, this.getLine(row).length),
  934. end: this.pos(row + 1, 0),
  935. action: "remove",
  936. lines: ["", ""]
  937. });
  938. }
  939. };
  940. this.replace = function(range, text) {
  941. if (!(range instanceof Range))
  942. range = Range.fromPoints(range.start, range.end);
  943. if (text.length === 0 && range.isEmpty())
  944. return range.start;
  945. if (text == this.getTextRange(range))
  946. return range.end;
  947. this.remove(range);
  948. var end;
  949. if (text) {
  950. end = this.insert(range.start, text);
  951. }
  952. else {
  953. end = range.start;
  954. }
  955. return end;
  956. };
  957. this.applyDeltas = function(deltas) {
  958. for (var i=0; i<deltas.length; i++) {
  959. this.applyDelta(deltas[i]);
  960. }
  961. };
  962. this.revertDeltas = function(deltas) {
  963. for (var i=deltas.length-1; i>=0; i--) {
  964. this.revertDelta(deltas[i]);
  965. }
  966. };
  967. this.applyDelta = function(delta, doNotValidate) {
  968. var isInsert = delta.action == "insert";
  969. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  970. : !Range.comparePoints(delta.start, delta.end)) {
  971. return;
  972. }
  973. if (isInsert && delta.lines.length > 20000) {
  974. this.$splitAndapplyLargeDelta(delta, 20000);
  975. }
  976. else {
  977. applyDelta(this.$lines, delta, doNotValidate);
  978. this._signal("change", delta);
  979. }
  980. };
  981. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  982. var lines = delta.lines;
  983. var l = lines.length - MAX + 1;
  984. var row = delta.start.row;
  985. var column = delta.start.column;
  986. for (var from = 0, to = 0; from < l; from = to) {
  987. to += MAX - 1;
  988. var chunk = lines.slice(from, to);
  989. chunk.push("");
  990. this.applyDelta({
  991. start: this.pos(row + from, column),
  992. end: this.pos(row + to, column = 0),
  993. action: delta.action,
  994. lines: chunk
  995. }, true);
  996. }
  997. delta.lines = lines.slice(from);
  998. delta.start.row = row + from;
  999. delta.start.column = column;
  1000. this.applyDelta(delta, true);
  1001. };
  1002. this.revertDelta = function(delta) {
  1003. this.applyDelta({
  1004. start: this.clonePos(delta.start),
  1005. end: this.clonePos(delta.end),
  1006. action: (delta.action == "insert" ? "remove" : "insert"),
  1007. lines: delta.lines.slice()
  1008. });
  1009. };
  1010. this.indexToPosition = function(index, startRow) {
  1011. var lines = this.$lines || this.getAllLines();
  1012. var newlineLength = this.getNewLineCharacter().length;
  1013. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1014. index -= lines[i].length + newlineLength;
  1015. if (index < 0)
  1016. return {row: i, column: index + lines[i].length + newlineLength};
  1017. }
  1018. return {row: l-1, column: index + lines[l-1].length + newlineLength};
  1019. };
  1020. this.positionToIndex = function(pos, startRow) {
  1021. var lines = this.$lines || this.getAllLines();
  1022. var newlineLength = this.getNewLineCharacter().length;
  1023. var index = 0;
  1024. var row = Math.min(pos.row, lines.length);
  1025. for (var i = startRow || 0; i < row; ++i)
  1026. index += lines[i].length + newlineLength;
  1027. return index + pos.column;
  1028. };
  1029. }).call(Document.prototype);
  1030. exports.Document = Document;
  1031. });
  1032. ace.define("ace/lib/lang",[], function(require, exports, module) {
  1033. "use strict";
  1034. exports.last = function(a) {
  1035. return a[a.length - 1];
  1036. };
  1037. exports.stringReverse = function(string) {
  1038. return string.split("").reverse().join("");
  1039. };
  1040. exports.stringRepeat = function (string, count) {
  1041. var result = '';
  1042. while (count > 0) {
  1043. if (count & 1)
  1044. result += string;
  1045. if (count >>= 1)
  1046. string += string;
  1047. }
  1048. return result;
  1049. };
  1050. var trimBeginRegexp = /^\s\s*/;
  1051. var trimEndRegexp = /\s\s*$/;
  1052. exports.stringTrimLeft = function (string) {
  1053. return string.replace(trimBeginRegexp, '');
  1054. };
  1055. exports.stringTrimRight = function (string) {
  1056. return string.replace(trimEndRegexp, '');
  1057. };
  1058. exports.copyObject = function(obj) {
  1059. var copy = {};
  1060. for (var key in obj) {
  1061. copy[key] = obj[key];
  1062. }
  1063. return copy;
  1064. };
  1065. exports.copyArray = function(array){
  1066. var copy = [];
  1067. for (var i=0, l=array.length; i<l; i++) {
  1068. if (array[i] && typeof array[i] == "object")
  1069. copy[i] = this.copyObject(array[i]);
  1070. else
  1071. copy[i] = array[i];
  1072. }
  1073. return copy;
  1074. };
  1075. exports.deepCopy = function deepCopy(obj) {
  1076. if (typeof obj !== "object" || !obj)
  1077. return obj;
  1078. var copy;
  1079. if (Array.isArray(obj)) {
  1080. copy = [];
  1081. for (var key = 0; key < obj.length; key++) {
  1082. copy[key] = deepCopy(obj[key]);
  1083. }
  1084. return copy;
  1085. }
  1086. if (Object.prototype.toString.call(obj) !== "[object Object]")
  1087. return obj;
  1088. copy = {};
  1089. for (var key in obj)
  1090. copy[key] = deepCopy(obj[key]);
  1091. return copy;
  1092. };
  1093. exports.arrayToMap = function(arr) {
  1094. var map = {};
  1095. for (var i=0; i<arr.length; i++) {
  1096. map[arr[i]] = 1;
  1097. }
  1098. return map;
  1099. };
  1100. exports.createMap = function(props) {
  1101. var map = Object.create(null);
  1102. for (var i in props) {
  1103. map[i] = props[i];
  1104. }
  1105. return map;
  1106. };
  1107. exports.arrayRemove = function(array, value) {
  1108. for (var i = 0; i <= array.length; i++) {
  1109. if (value === array[i]) {
  1110. array.splice(i, 1);
  1111. }
  1112. }
  1113. };
  1114. exports.escapeRegExp = function(str) {
  1115. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1116. };
  1117. exports.escapeHTML = function(str) {
  1118. return ("" + str).replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1119. };
  1120. exports.getMatchOffsets = function(string, regExp) {
  1121. var matches = [];
  1122. string.replace(regExp, function(str) {
  1123. matches.push({
  1124. offset: arguments[arguments.length-2],
  1125. length: str.length
  1126. });
  1127. });
  1128. return matches;
  1129. };
  1130. exports.deferredCall = function(fcn) {
  1131. var timer = null;
  1132. var callback = function() {
  1133. timer = null;
  1134. fcn();
  1135. };
  1136. var deferred = function(timeout) {
  1137. deferred.cancel();
  1138. timer = setTimeout(callback, timeout || 0);
  1139. return deferred;
  1140. };
  1141. deferred.schedule = deferred;
  1142. deferred.call = function() {
  1143. this.cancel();
  1144. fcn();
  1145. return deferred;
  1146. };
  1147. deferred.cancel = function() {
  1148. clearTimeout(timer);
  1149. timer = null;
  1150. return deferred;
  1151. };
  1152. deferred.isPending = function() {
  1153. return timer;
  1154. };
  1155. return deferred;
  1156. };
  1157. exports.delayedCall = function(fcn, defaultTimeout) {
  1158. var timer = null;
  1159. var callback = function() {
  1160. timer = null;
  1161. fcn();
  1162. };
  1163. var _self = function(timeout) {
  1164. if (timer == null)
  1165. timer = setTimeout(callback, timeout || defaultTimeout);
  1166. };
  1167. _self.delay = function(timeout) {
  1168. timer && clearTimeout(timer);
  1169. timer = setTimeout(callback, timeout || defaultTimeout);
  1170. };
  1171. _self.schedule = _self;
  1172. _self.call = function() {
  1173. this.cancel();
  1174. fcn();
  1175. };
  1176. _self.cancel = function() {
  1177. timer && clearTimeout(timer);
  1178. timer = null;
  1179. };
  1180. _self.isPending = function() {
  1181. return timer;
  1182. };
  1183. return _self;
  1184. };
  1185. });
  1186. ace.define("ace/worker/mirror",[], function(require, exports, module) {
  1187. "use strict";
  1188. var Range = require("../range").Range;
  1189. var Document = require("../document").Document;
  1190. var lang = require("../lib/lang");
  1191. var Mirror = exports.Mirror = function(sender) {
  1192. this.sender = sender;
  1193. var doc = this.doc = new Document("");
  1194. var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  1195. var _self = this;
  1196. sender.on("change", function(e) {
  1197. var data = e.data;
  1198. if (data[0].start) {
  1199. doc.applyDeltas(data);
  1200. } else {
  1201. for (var i = 0; i < data.length; i += 2) {
  1202. if (Array.isArray(data[i+1])) {
  1203. var d = {action: "insert", start: data[i], lines: data[i+1]};
  1204. } else {
  1205. var d = {action: "remove", start: data[i], end: data[i+1]};
  1206. }
  1207. doc.applyDelta(d, true);
  1208. }
  1209. }
  1210. if (_self.$timeout)
  1211. return deferredUpdate.schedule(_self.$timeout);
  1212. _self.onUpdate();
  1213. });
  1214. };
  1215. (function() {
  1216. this.$timeout = 500;
  1217. this.setTimeout = function(timeout) {
  1218. this.$timeout = timeout;
  1219. };
  1220. this.setValue = function(value) {
  1221. this.doc.setValue(value);
  1222. this.deferredUpdate.schedule(this.$timeout);
  1223. };
  1224. this.getValue = function(callbackId) {
  1225. this.sender.callback(this.doc.getValue(), callbackId);
  1226. };
  1227. this.onUpdate = function() {
  1228. };
  1229. this.isPending = function() {
  1230. return this.deferredUpdate.isPending();
  1231. };
  1232. }).call(Mirror.prototype);
  1233. });
  1234. ace.define("ace/mode/javascript/jshint",[], function(require, exports, module) {
  1235. module.exports = (function outer (modules, cache, entry) {
  1236. var previousRequire = typeof require == "function" && require;
  1237. function newRequire(name, jumped){
  1238. if(!cache[name]) {
  1239. if(!modules[name]) {
  1240. var currentRequire = typeof require == "function" && require;
  1241. if (!jumped && currentRequire) return currentRequire(name, true);
  1242. if (previousRequire) return previousRequire(name, true);
  1243. var err = new Error('Cannot find module \'' + name + '\'');
  1244. err.code = 'MODULE_NOT_FOUND';
  1245. throw err;
  1246. }
  1247. var m = cache[name] = {exports:{}};
  1248. modules[name][0].call(m.exports, function(x){
  1249. var id = modules[name][1][x];
  1250. return newRequire(id ? id : x);
  1251. },m,m.exports,outer,modules,cache,entry);
  1252. }
  1253. return cache[name].exports;
  1254. }
  1255. for(var i=0;i<entry.length;i++) newRequire(entry[i]);
  1256. return newRequire(entry[0]);
  1257. })
  1258. ({"/node_modules/browserify/node_modules/events/events.js":[function(_dereq_,module,exports){
  1259. function EventEmitter() {
  1260. this._events = this._events || {};
  1261. this._maxListeners = this._maxListeners || undefined;
  1262. }
  1263. module.exports = EventEmitter;
  1264. EventEmitter.EventEmitter = EventEmitter;
  1265. EventEmitter.prototype._events = undefined;
  1266. EventEmitter.prototype._maxListeners = undefined;
  1267. EventEmitter.defaultMaxListeners = 10;
  1268. EventEmitter.prototype.setMaxListeners = function(n) {
  1269. if (!isNumber(n) || n < 0 || isNaN(n))
  1270. throw TypeError('n must be a positive number');
  1271. this._maxListeners = n;
  1272. return this;
  1273. };
  1274. EventEmitter.prototype.emit = function(type) {
  1275. var er, handler, len, args, i, listeners;
  1276. if (!this._events)
  1277. this._events = {};
  1278. if (type === 'error') {
  1279. if (!this._events.error ||
  1280. (isObject(this._events.error) && !this._events.error.length)) {
  1281. er = arguments[1];
  1282. if (er instanceof Error) {
  1283. throw er; // Unhandled 'error' event
  1284. }
  1285. throw TypeError('Uncaught, unspecified "error" event.');
  1286. }
  1287. }
  1288. handler = this._events[type];
  1289. if (isUndefined(handler))
  1290. return false;
  1291. if (isFunction(handler)) {
  1292. switch (arguments.length) {
  1293. case 1:
  1294. handler.call(this);
  1295. break;
  1296. case 2:
  1297. handler.call(this, arguments[1]);
  1298. break;
  1299. case 3:
  1300. handler.call(this, arguments[1], arguments[2]);
  1301. break;
  1302. default:
  1303. len = arguments.length;
  1304. args = new Array(len - 1);
  1305. for (i = 1; i < len; i++)
  1306. args[i - 1] = arguments[i];
  1307. handler.apply(this, args);
  1308. }
  1309. } else if (isObject(handler)) {
  1310. len = arguments.length;
  1311. args = new Array(len - 1);
  1312. for (i = 1; i < len; i++)
  1313. args[i - 1] = arguments[i];
  1314. listeners = handler.slice();
  1315. len = listeners.length;
  1316. for (i = 0; i < len; i++)
  1317. listeners[i].apply(this, args);
  1318. }
  1319. return true;
  1320. };
  1321. EventEmitter.prototype.addListener = function(type, listener) {
  1322. var m;
  1323. if (!isFunction(listener))
  1324. throw TypeError('listener must be a function');
  1325. if (!this._events)
  1326. this._events = {};
  1327. if (this._events.newListener)
  1328. this.emit('newListener', type,
  1329. isFunction(listener.listener) ?
  1330. listener.listener : listener);
  1331. if (!this._events[type])
  1332. this._events[type] = listener;
  1333. else if (isObject(this._events[type]))
  1334. this._events[type].push(listener);
  1335. else
  1336. this._events[type] = [this._events[type], listener];
  1337. if (isObject(this._events[type]) && !this._events[type].warned) {
  1338. var m;
  1339. if (!isUndefined(this._maxListeners)) {
  1340. m = this._maxListeners;
  1341. } else {
  1342. m = EventEmitter.defaultMaxListeners;
  1343. }
  1344. if (m && m > 0 && this._events[type].length > m) {
  1345. this._events[type].warned = true;
  1346. console.error('(node) warning: possible EventEmitter memory ' +
  1347. 'leak detected. %d listeners added. ' +
  1348. 'Use emitter.setMaxListeners() to increase limit.',
  1349. this._events[type].length);
  1350. if (typeof console.trace === 'function') {
  1351. console.trace();
  1352. }
  1353. }
  1354. }
  1355. return this;
  1356. };
  1357. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  1358. EventEmitter.prototype.once = function(type, listener) {
  1359. if (!isFunction(listener))
  1360. throw TypeError('listener must be a function');
  1361. var fired = false;
  1362. function g() {
  1363. this.removeListener(type, g);
  1364. if (!fired) {
  1365. fired = true;
  1366. listener.apply(this, arguments);
  1367. }
  1368. }
  1369. g.listener = listener;
  1370. this.on(type, g);
  1371. return this;
  1372. };
  1373. EventEmitter.prototype.removeListener = function(type, listener) {
  1374. var list, position, length, i;
  1375. if (!isFunction(listener))
  1376. throw TypeError('listener must be a function');
  1377. if (!this._events || !this._events[type])
  1378. return this;
  1379. list = this._events[type];
  1380. length = list.length;
  1381. position = -1;
  1382. if (list === listener ||
  1383. (isFunction(list.listener) && list.listener === listener)) {
  1384. delete this._events[type];
  1385. if (this._events.removeListener)
  1386. this.emit('removeListener', type, listener);
  1387. } else if (isObject(list)) {
  1388. for (i = length; i-- > 0;) {
  1389. if (list[i] === listener ||
  1390. (list[i].listener && list[i].listener === listener)) {
  1391. position = i;
  1392. break;
  1393. }
  1394. }
  1395. if (position < 0)
  1396. return this;
  1397. if (list.length === 1) {
  1398. list.length = 0;
  1399. delete this._events[type];
  1400. } else {
  1401. list.splice(position, 1);
  1402. }
  1403. if (this._events.removeListener)
  1404. this.emit('removeListener', type, listener);
  1405. }
  1406. return this;
  1407. };
  1408. EventEmitter.prototype.removeAllListeners = function(type) {
  1409. var key, listeners;
  1410. if (!this._events)
  1411. return this;
  1412. if (!this._events.removeListener) {
  1413. if (arguments.length === 0)
  1414. this._events = {};
  1415. else if (this._events[type])
  1416. delete this._events[type];
  1417. return this;
  1418. }
  1419. if (arguments.length === 0) {
  1420. for (key in this._events) {
  1421. if (key === 'removeListener') continue;
  1422. this.removeAllListeners(key);
  1423. }
  1424. this.removeAllListeners('removeListener');
  1425. this._events = {};
  1426. return this;
  1427. }
  1428. listeners = this._events[type];
  1429. if (isFunction(listeners)) {
  1430. this.removeListener(type, listeners);
  1431. } else {
  1432. while (listeners.length)
  1433. this.removeListener(type, listeners[listeners.length - 1]);
  1434. }
  1435. delete this._events[type];
  1436. return this;
  1437. };
  1438. EventEmitter.prototype.listeners = function(type) {
  1439. var ret;
  1440. if (!this._events || !this._events[type])
  1441. ret = [];
  1442. else if (isFunction(this._events[type]))
  1443. ret = [this._events[type]];
  1444. else
  1445. ret = this._events[type].slice();
  1446. return ret;
  1447. };
  1448. EventEmitter.listenerCount = function(emitter, type) {
  1449. var ret;
  1450. if (!emitter._events || !emitter._events[type])
  1451. ret = 0;
  1452. else if (isFunction(emitter._events[type]))
  1453. ret = 1;
  1454. else
  1455. ret = emitter._events[type].length;
  1456. return ret;
  1457. };
  1458. function isFunction(arg) {
  1459. return typeof arg === 'function';
  1460. }
  1461. function isNumber(arg) {
  1462. return typeof arg === 'number';
  1463. }
  1464. function isObject(arg) {
  1465. return typeof arg === 'object' && arg !== null;
  1466. }
  1467. function isUndefined(arg) {
  1468. return arg === void 0;
  1469. }
  1470. },{}],"/node_modules/jshint/data/ascii-identifier-data.js":[function(_dereq_,module,exports){
  1471. var identifierStartTable = [];
  1472. for (var i = 0; i < 128; i++) {
  1473. identifierStartTable[i] =
  1474. i === 36 || // $
  1475. i >= 65 && i <= 90 || // A-Z
  1476. i === 95 || // _
  1477. i >= 97 && i <= 122; // a-z
  1478. }
  1479. var identifierPartTable = [];
  1480. for (var i = 0; i < 128; i++) {
  1481. identifierPartTable[i] =
  1482. identifierStartTable[i] || // $, _, A-Z, a-z
  1483. i >= 48 && i <= 57; // 0-9
  1484. }
  1485. module.exports = {
  1486. asciiIdentifierStartTable: identifierStartTable,
  1487. asciiIdentifierPartTable: identifierPartTable
  1488. };
  1489. },{}],"/node_modules/jshint/lodash.js":[function(_dereq_,module,exports){
  1490. (function (global){
  1491. ;(function() {
  1492. var undefined;
  1493. var VERSION = '3.7.0';
  1494. var FUNC_ERROR_TEXT = 'Expected a function';
  1495. var argsTag = '[object Arguments]',
  1496. arrayTag = '[object Array]',
  1497. boolTag = '[object Boolean]',
  1498. dateTag = '[object Date]',
  1499. errorTag = '[object Error]',
  1500. funcTag = '[object Function]',
  1501. mapTag = '[object Map]',
  1502. numberTag = '[object Number]',
  1503. objectTag = '[object Object]',
  1504. regexpTag = '[object RegExp]',
  1505. setTag = '[object Set]',
  1506. stringTag = '[object String]',
  1507. weakMapTag = '[object WeakMap]';
  1508. var arrayBufferTag = '[object ArrayBuffer]',
  1509. float32Tag = '[object Float32Array]',
  1510. float64Tag = '[object Float64Array]',
  1511. int8Tag = '[object Int8Array]',
  1512. int16Tag = '[object Int16Array]',
  1513. int32Tag = '[object Int32Array]',
  1514. uint8Tag = '[object Uint8Array]',
  1515. uint8ClampedTag = '[object Uint8ClampedArray]',
  1516. uint16Tag = '[object Uint16Array]',
  1517. uint32Tag = '[object Uint32Array]';
  1518. var reIsDeepProp = /\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,
  1519. reIsPlainProp = /^\w*$/,
  1520. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  1521. var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
  1522. reHasRegExpChars = RegExp(reRegExpChars.source);
  1523. var reEscapeChar = /\\(\\)?/g;
  1524. var reFlags = /\w*$/;
  1525. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1526. var typedArrayTags = {};
  1527. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1528. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1529. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1530. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1531. typedArrayTags[uint32Tag] = true;
  1532. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1533. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1534. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  1535. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  1536. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  1537. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  1538. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  1539. var cloneableTags = {};
  1540. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  1541. cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
  1542. cloneableTags[dateTag] = cloneableTags[float32Tag] =
  1543. cloneableTags[float64Tag] = cloneableTags[int8Tag] =
  1544. cloneableTags[int16Tag] = cloneableTags[int32Tag] =
  1545. cloneableTags[numberTag] = cloneableTags[objectTag] =
  1546. cloneableTags[regexpTag] = cloneableTags[stringTag] =
  1547. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  1548. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  1549. cloneableTags[errorTag] = cloneableTags[funcTag] =
  1550. cloneableTags[mapTag] = cloneableTags[setTag] =
  1551. cloneableTags[weakMapTag] = false;
  1552. var objectTypes = {
  1553. 'function': true,
  1554. 'object': true
  1555. };
  1556. var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
  1557. var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
  1558. var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;
  1559. var freeSelf = objectTypes[typeof self] && self && self.Object && self;
  1560. var freeWindow = objectTypes[typeof window] && window && window.Object && window;
  1561. var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
  1562. var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
  1563. function baseFindIndex(array, predicate, fromRight) {
  1564. var length = array.length,
  1565. index = fromRight ? length : -1;
  1566. while ((fromRight ? index-- : ++index < length)) {
  1567. if (predicate(array[index], index, array)) {
  1568. return index;
  1569. }
  1570. }
  1571. return -1;
  1572. }
  1573. function baseIndexOf(array, value, fromIndex) {
  1574. if (value !== value) {
  1575. return indexOfNaN(array, fromIndex);
  1576. }
  1577. var index = fromIndex - 1,
  1578. length = array.length;
  1579. while (++index < length) {
  1580. if (array[index] === value) {
  1581. return index;
  1582. }
  1583. }
  1584. return -1;
  1585. }
  1586. function baseIsFunction(value) {
  1587. return typeof value == 'function' || false;
  1588. }
  1589. function baseToString(value) {
  1590. if (typeof value == 'string') {
  1591. return value;
  1592. }
  1593. return value == null ? '' : (value + '');
  1594. }
  1595. function indexOfNaN(array, fromIndex, fromRight) {
  1596. var length = array.length,
  1597. index = fromIndex + (fromRight ? 0 : -1);
  1598. while ((fromRight ? index-- : ++index < length)) {
  1599. var other = array[index];
  1600. if (other !== other) {
  1601. return index;
  1602. }
  1603. }
  1604. return -1;
  1605. }
  1606. function isObjectLike(value) {
  1607. return !!value && typeof value == 'object';
  1608. }
  1609. var arrayProto = Array.prototype,
  1610. objectProto = Object.prototype;
  1611. var fnToString = Function.prototype.toString;
  1612. var hasOwnProperty = objectProto.hasOwnProperty;
  1613. var objToString = objectProto.toString;
  1614. var reIsNative = RegExp('^' +
  1615. escapeRegExp(objToString)
  1616. .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1617. );
  1618. var ArrayBuffer = isNative(ArrayBuffer = root.ArrayBuffer) && ArrayBuffer,
  1619. bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
  1620. floor = Math.floor,
  1621. getOwnPropertySymbols = isNative(getOwnPropertySymbols = Object.getOwnPropertySymbols) && getOwnPropertySymbols,
  1622. getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
  1623. push = arrayProto.push,
  1624. preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions,
  1625. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  1626. Uint8Array = isNative(Uint8Array = root.Uint8Array) && Uint8Array;
  1627. var Float64Array = (function() {
  1628. try {
  1629. var func = isNative(func = root.Float64Array) && func,
  1630. result = new func(new ArrayBuffer(10), 0, 1) && func;
  1631. } catch(e) {}
  1632. return result;
  1633. }());
  1634. var nativeAssign = (function() {
  1635. var object = { '1': 0 },
  1636. func = preventExtensions && isNative(func = Object.assign) && func;
  1637. try { func(preventExtensions(object), 'xo'); } catch(e) {}
  1638. return !object[1] && func;
  1639. }());
  1640. var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray,
  1641. nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys,
  1642. nativeMax = Math.max,
  1643. nativeMin = Math.min;
  1644. var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;
  1645. var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
  1646. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  1647. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  1648. var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
  1649. var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
  1650. function lodash() {
  1651. }
  1652. var support = lodash.support = {};
  1653. (function(x) {
  1654. var Ctor = function() { this.x = x; },
  1655. object = { '0': x, 'length': x },
  1656. props = [];
  1657. Ctor.prototype = { 'valueOf': x, 'y': x };
  1658. for (var key in new Ctor) { props.push(key); }
  1659. support.funcDecomp = /\bthis\b/.test(function() { return this; });
  1660. support.funcNames = typeof Function.name == 'string';
  1661. try {
  1662. support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
  1663. } catch(e) {
  1664. support.nonEnumArgs = true;
  1665. }
  1666. }(1, 0));
  1667. function arrayCopy(source, array) {
  1668. var index = -1,
  1669. length = source.length;
  1670. array || (array = Array(length));
  1671. while (++index < length) {
  1672. array[index] = source[index];
  1673. }
  1674. return array;
  1675. }
  1676. function arrayEach(array, iteratee) {
  1677. var index = -1,
  1678. length = array.length;
  1679. while (++index < length) {
  1680. if (iteratee(array[index], index, array) === false) {
  1681. break;
  1682. }
  1683. }
  1684. return array;
  1685. }
  1686. function arrayFilter(array, predicate) {
  1687. var index = -1,
  1688. length = array.length,
  1689. resIndex = -1,
  1690. result = [];
  1691. while (++index < length) {
  1692. var value = array[index];
  1693. if (predicate(value, index, array)) {
  1694. result[++resIndex] = value;
  1695. }
  1696. }
  1697. return result;
  1698. }
  1699. function arrayMap(array, iteratee) {
  1700. var index = -1,
  1701. length = array.length,
  1702. result = Array(length);
  1703. while (++index < length) {
  1704. result[index] = iteratee(array[index], index, array);
  1705. }
  1706. return result;
  1707. }
  1708. function arrayMax(array) {
  1709. var index = -1,
  1710. length = array.length,
  1711. result = NEGATIVE_INFINITY;
  1712. while (++index < length) {
  1713. var value = array[index];
  1714. if (value > result) {
  1715. result = value;
  1716. }
  1717. }
  1718. return result;
  1719. }
  1720. function arraySome(array, predicate) {
  1721. var index = -1,
  1722. length = array.length;
  1723. while (++index < length) {
  1724. if (predicate(array[index], index, array)) {
  1725. return true;
  1726. }
  1727. }
  1728. return false;
  1729. }
  1730. function assignWith(object, source, customizer) {
  1731. var props = keys(source);
  1732. push.apply(props, getSymbols(source));
  1733. var index = -1,
  1734. length = props.length;
  1735. while (++index < length) {
  1736. var key = props[index],
  1737. value = object[key],
  1738. result = customizer(value, source[key], key, object, source);
  1739. if ((result === result ? (result !== value) : (value === value)) ||
  1740. (value === undefined && !(key in object))) {
  1741. object[key] = result;
  1742. }
  1743. }
  1744. return object;
  1745. }
  1746. var baseAssign = nativeAssign || function(object, source) {
  1747. return source == null
  1748. ? object
  1749. : baseCopy(source, getSymbols(source), baseCopy(source, keys(source), object));
  1750. };
  1751. function baseCopy(source, props, object) {
  1752. object || (object = {});
  1753. var index = -1,
  1754. length = props.length;
  1755. while (++index < length) {
  1756. var key = props[index];
  1757. object[key] = source[key];
  1758. }
  1759. return object;
  1760. }
  1761. function baseCallback(func, thisArg, argCount) {
  1762. var type = typeof func;
  1763. if (type == 'function') {
  1764. return thisArg === undefined
  1765. ? func
  1766. : bindCallback(func, thisArg, argCount);
  1767. }
  1768. if (func == null) {
  1769. return identity;
  1770. }
  1771. if (type == 'object') {
  1772. return baseMatches(func);
  1773. }
  1774. return thisArg === undefined
  1775. ? property(func)
  1776. : baseMatchesProperty(func, thisArg);
  1777. }
  1778. function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
  1779. var result;
  1780. if (customizer) {
  1781. result = object ? customizer(value, key, object) : customizer(value);
  1782. }
  1783. if (result !== undefined) {
  1784. return result;
  1785. }
  1786. if (!isObject(value)) {
  1787. return value;
  1788. }
  1789. var isArr = isArray(value);
  1790. if (isArr) {
  1791. result = initCloneArray(value);
  1792. if (!isDeep) {
  1793. return arrayCopy(value, result);
  1794. }
  1795. } else {
  1796. var tag = objToString.call(value),
  1797. isFunc = tag == funcTag;
  1798. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  1799. result = initCloneObject(isFunc ? {} : value);
  1800. if (!isDeep) {
  1801. return baseAssign(result, value);
  1802. }
  1803. } else {
  1804. return cloneableTags[tag]
  1805. ? initCloneByTag(value, tag, isDeep)
  1806. : (object ? value : {});
  1807. }
  1808. }
  1809. stackA || (stackA = []);
  1810. stackB || (stackB = []);
  1811. var length = stackA.length;
  1812. while (length--) {
  1813. if (stackA[length] == value) {
  1814. return stackB[length];
  1815. }
  1816. }
  1817. stackA.push(value);
  1818. stackB.push(result);
  1819. (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
  1820. result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
  1821. });
  1822. return result;
  1823. }
  1824. var baseEach = createBaseEach(baseForOwn);
  1825. function baseFilter(collection, predicate) {
  1826. var result = [];
  1827. baseEach(collection, function(value, index, collection) {
  1828. if (predicate(value, index, collection)) {
  1829. result.push(value);
  1830. }
  1831. });
  1832. return result;
  1833. }
  1834. var baseFor = createBaseFor();
  1835. function baseForIn(object, iteratee) {
  1836. return baseFor(object, iteratee, keysIn);
  1837. }
  1838. function baseForOwn(object, iteratee) {
  1839. return baseFor(object, iteratee, keys);
  1840. }
  1841. function baseGet(object, path, pathKey) {
  1842. if (object == null) {
  1843. return;
  1844. }
  1845. if (pathKey !== undefined && pathKey in toObject(object)) {
  1846. path = [pathKey];
  1847. }
  1848. var index = -1,
  1849. length = path.length;
  1850. while (object != null && ++index < length) {
  1851. var result = object = object[path[index]];
  1852. }
  1853. return result;
  1854. }
  1855. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  1856. if (value === other) {
  1857. return value !== 0 || (1 / value == 1 / other);
  1858. }
  1859. var valType = typeof value,
  1860. othType = typeof other;
  1861. if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
  1862. value == null || other == null) {
  1863. return value !== value && other !== other;
  1864. }
  1865. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  1866. }
  1867. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  1868. var objIsArr = isArray(object),
  1869. othIsArr = isArray(other),
  1870. objTag = arrayTag,
  1871. othTag = arrayTag;
  1872. if (!objIsArr) {
  1873. objTag = objToString.call(object);
  1874. if (objTag == argsTag) {
  1875. objTag = objectTag;
  1876. } else if (objTag != objectTag) {
  1877. objIsArr = isTypedArray(object);
  1878. }
  1879. }
  1880. if (!othIsArr) {
  1881. othTag = objToString.call(other);
  1882. if (othTag == argsTag) {
  1883. othTag = objectTag;
  1884. } else if (othTag != objectTag) {
  1885. othIsArr = isTypedArray(other);
  1886. }
  1887. }
  1888. var objIsObj = objTag == objectTag,
  1889. othIsObj = othTag == objectTag,
  1890. isSameTag = objTag == othTag;
  1891. if (isSameTag && !(objIsArr || objIsObj)) {
  1892. return equalByTag(object, other, objTag);
  1893. }
  1894. if (!isLoose) {
  1895. var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  1896. othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  1897. if (valWrapped || othWrapped) {
  1898. return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  1899. }
  1900. }
  1901. if (!isSameTag) {
  1902. return false;
  1903. }
  1904. stackA || (stackA = []);
  1905. stackB || (stackB = []);
  1906. var length = stackA.length;
  1907. while (length--) {
  1908. if (stackA[length] == object) {
  1909. return stackB[length] == other;
  1910. }
  1911. }
  1912. stackA.push(object);
  1913. stackB.push(other);
  1914. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  1915. stackA.pop();
  1916. stackB.pop();
  1917. return result;
  1918. }
  1919. function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
  1920. var index = -1,
  1921. length = props.length,
  1922. noCustomizer = !customizer;
  1923. while (++index < length) {
  1924. if ((noCustomizer && strictCompareFlags[index])
  1925. ? values[index] !== object[props[index]]
  1926. : !(props[index] in object)
  1927. ) {
  1928. return false;
  1929. }
  1930. }
  1931. index = -1;
  1932. while (++index < length) {
  1933. var key = props[index],
  1934. objValue = object[key],
  1935. srcValue = values[index];
  1936. if (noCustomizer && strictCompareFlags[index]) {
  1937. var result = objValue !== undefined || (key in object);
  1938. } else {
  1939. result = customizer ? customizer(objValue, srcValue, key) : undefined;
  1940. if (result === undefined) {
  1941. result = baseIsEqual(srcValue, objValue, customizer, true);
  1942. }
  1943. }
  1944. if (!result) {
  1945. return false;
  1946. }
  1947. }
  1948. return true;
  1949. }
  1950. function baseMatches(source) {
  1951. var props = keys(source),
  1952. length = props.length;
  1953. if (!length) {
  1954. return constant(true);
  1955. }
  1956. if (length == 1) {
  1957. var key = props[0],
  1958. value = source[key];
  1959. if (isStrictComparable(value)) {
  1960. return function(object) {
  1961. if (object == null) {
  1962. return false;
  1963. }
  1964. return object[key] === value && (value !== undefined || (key in toObject(object)));
  1965. };
  1966. }
  1967. }
  1968. var values = Array(length),
  1969. strictCompareFlags = Array(length);
  1970. while (length--) {
  1971. value = source[props[length]];
  1972. values[length] = value;
  1973. strictCompareFlags[length] = isStrictComparable(value);
  1974. }
  1975. return function(object) {
  1976. return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
  1977. };
  1978. }
  1979. function baseMatchesProperty(path, value) {
  1980. var isArr = isArray(path),
  1981. isCommon = isKey(path) && isStrictComparable(value),
  1982. pathKey = (path + '');
  1983. path = toPath(path);
  1984. return function(object) {
  1985. if (object == null) {
  1986. return false;
  1987. }
  1988. var key = pathKey;
  1989. object = toObject(object);
  1990. if ((isArr || !isCommon) && !(key in object)) {
  1991. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  1992. if (object == null) {
  1993. return false;
  1994. }
  1995. key = last(path);
  1996. object = toObject(object);
  1997. }
  1998. return object[key] === value
  1999. ? (value !== undefined || (key in object))
  2000. : baseIsEqual(value, object[key], null, true);
  2001. };
  2002. }
  2003. function baseMerge(object, source, customizer, stackA, stackB) {
  2004. if (!isObject(object)) {
  2005. return object;
  2006. }
  2007. var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
  2008. if (!isSrcArr) {
  2009. var props = keys(source);
  2010. push.apply(props, getSymbols(source));
  2011. }
  2012. arrayEach(props || source, function(srcValue, key) {
  2013. if (props) {
  2014. key = srcValue;
  2015. srcValue = source[key];
  2016. }
  2017. if (isObjectLike(srcValue)) {
  2018. stackA || (stackA = []);
  2019. stackB || (stackB = []);
  2020. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  2021. }
  2022. else {
  2023. var value = object[key],
  2024. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  2025. isCommon = result === undefined;
  2026. if (isCommon) {
  2027. result = srcValue;
  2028. }
  2029. if ((isSrcArr || result !== undefined) &&
  2030. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  2031. object[key] = result;
  2032. }
  2033. }
  2034. });
  2035. return object;
  2036. }
  2037. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  2038. var length = stackA.length,
  2039. srcValue = source[key];
  2040. while (length--) {
  2041. if (stackA[length] == srcValue) {
  2042. object[key] = stackB[length];
  2043. return;
  2044. }
  2045. }
  2046. var value = object[key],
  2047. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  2048. isCommon = result === undefined;
  2049. if (isCommon) {
  2050. result = srcValue;
  2051. if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
  2052. result = isArray(value)
  2053. ? value
  2054. : (getLength(value) ? arrayCopy(value) : []);
  2055. }
  2056. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  2057. result = isArguments(value)
  2058. ? toPlainObject(value)
  2059. : (isPlainObject(value) ? value : {});
  2060. }
  2061. else {
  2062. isCommon = false;
  2063. }
  2064. }
  2065. stackA.push(srcValue);
  2066. stackB.push(result);
  2067. if (isCommon) {
  2068. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  2069. } else if (result === result ? (result !== value) : (value === value)) {
  2070. object[key] = result;
  2071. }
  2072. }
  2073. function baseProperty(key) {
  2074. return function(object) {
  2075. return object == null ? undefined : object[key];
  2076. };
  2077. }
  2078. function basePropertyDeep(path) {
  2079. var pathKey = (path + '');
  2080. path = toPath(path);
  2081. return function(object) {
  2082. return baseGet(object, path, pathKey);
  2083. };
  2084. }
  2085. function baseSlice(array, start, end) {
  2086. var index = -1,
  2087. length = array.length;
  2088. start = start == null ? 0 : (+start || 0);
  2089. if (start < 0) {
  2090. start = -start > length ? 0 : (length + start);
  2091. }
  2092. end = (end === undefined || end > length) ? length : (+end || 0);
  2093. if (end < 0) {
  2094. end += length;
  2095. }
  2096. length = start > end ? 0 : ((end - start) >>> 0);
  2097. start >>>= 0;
  2098. var result = Array(length);
  2099. while (++index < length) {
  2100. result[index] = array[index + start];
  2101. }
  2102. return result;
  2103. }
  2104. function baseSome(collection, predicate) {
  2105. var result;
  2106. baseEach(collection, function(value, index, collection) {
  2107. result = predicate(value, index, collection);
  2108. return !result;
  2109. });
  2110. return !!result;
  2111. }
  2112. function baseValues(object, props) {
  2113. var index = -1,
  2114. length = props.length,
  2115. result = Array(length);
  2116. while (++index < length) {
  2117. result[index] = object[props[index]];
  2118. }
  2119. return result;
  2120. }
  2121. function binaryIndex(array, value, retHighest) {
  2122. var low = 0,
  2123. high = array ? array.length : low;
  2124. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  2125. while (low < high) {
  2126. var mid = (low + high) >>> 1,
  2127. computed = array[mid];
  2128. if (retHighest ? (computed <= value) : (computed < value)) {
  2129. low = mid + 1;
  2130. } else {
  2131. high = mid;
  2132. }
  2133. }
  2134. return high;
  2135. }
  2136. return binaryIndexBy(array, value, identity, retHighest);
  2137. }
  2138. function binaryIndexBy(array, value, iteratee, retHighest) {
  2139. value = iteratee(value);
  2140. var low = 0,
  2141. high = array ? array.length : 0,
  2142. valIsNaN = value !== value,
  2143. valIsUndef = value === undefined;
  2144. while (low < high) {
  2145. var mid = floor((low + high) / 2),
  2146. computed = iteratee(array[mid]),
  2147. isReflexive = computed === computed;
  2148. if (valIsNaN) {
  2149. var setLow = isReflexive || retHighest;
  2150. } else if (valIsUndef) {
  2151. setLow = isReflexive && (retHighest || computed !== undefined);
  2152. } else {
  2153. setLow = retHighest ? (computed <= value) : (computed < value);
  2154. }
  2155. if (setLow) {
  2156. low = mid + 1;
  2157. } else {
  2158. high = mid;
  2159. }
  2160. }
  2161. return nativeMin(high, MAX_ARRAY_INDEX);
  2162. }
  2163. function bindCallback(func, thisArg, argCount) {
  2164. if (typeof func != 'function') {
  2165. return identity;
  2166. }
  2167. if (thisArg === undefined) {
  2168. return func;
  2169. }
  2170. switch (argCount) {
  2171. case 1: return function(value) {
  2172. return func.call(thisArg, value);
  2173. };
  2174. case 3: return function(value, index, collection) {
  2175. return func.call(thisArg, value, index, collection);
  2176. };
  2177. case 4: return function(accumulator, value, index, collection) {
  2178. return func.call(thisArg, accumulator, value, index, collection);
  2179. };
  2180. case 5: return function(value, other, key, object, source) {
  2181. return func.call(thisArg, value, other, key, object, source);
  2182. };
  2183. }
  2184. return function() {
  2185. return func.apply(thisArg, arguments);
  2186. };
  2187. }
  2188. function bufferClone(buffer) {
  2189. return bufferSlice.call(buffer, 0);
  2190. }
  2191. if (!bufferSlice) {
  2192. bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
  2193. var byteLength = buffer.byteLength,
  2194. floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
  2195. offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
  2196. result = new ArrayBuffer(byteLength);
  2197. if (floatLength) {
  2198. var view = new Float64Array(result, 0, floatLength);
  2199. view.set(new Float64Array(buffer, 0, floatLength));
  2200. }
  2201. if (byteLength != offset) {
  2202. view = new Uint8Array(result, offset);
  2203. view.set(new Uint8Array(buffer, offset));
  2204. }
  2205. return result;
  2206. };
  2207. }
  2208. function createAssigner(assigner) {
  2209. return restParam(function(object, sources) {
  2210. var index = -1,
  2211. length = object == null ? 0 : sources.length,
  2212. customizer = length > 2 && sources[length - 2],
  2213. guard = length > 2 && sources[2],
  2214. thisArg = length > 1 && sources[length - 1];
  2215. if (typeof customizer == 'function') {
  2216. customizer = bindCallback(customizer, thisArg, 5);
  2217. length -= 2;
  2218. } else {
  2219. customizer = typeof thisArg == 'function' ? thisArg : null;
  2220. length -= (customizer ? 1 : 0);
  2221. }
  2222. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  2223. customizer = length < 3 ? null : customizer;
  2224. length = 1;
  2225. }
  2226. while (++index < length) {
  2227. var source = sources[index];
  2228. if (source) {
  2229. assigner(object, source, customizer);
  2230. }
  2231. }
  2232. return object;
  2233. });
  2234. }
  2235. function createBaseEach(eachFunc, fromRight) {
  2236. return function(collection, iteratee) {
  2237. var length = collection ? getLength(collection) : 0;
  2238. if (!isLength(length)) {
  2239. return eachFunc(collection, iteratee);
  2240. }
  2241. var index = fromRight ? length : -1,
  2242. iterable = toObject(collection);
  2243. while ((fromRight ? index-- : ++index < length)) {
  2244. if (iteratee(iterable[index], index, iterable) === false) {
  2245. break;
  2246. }
  2247. }
  2248. return collection;
  2249. };
  2250. }
  2251. function createBaseFor(fromRight) {
  2252. return function(object, iteratee, keysFunc) {
  2253. var iterable = toObject(object),
  2254. props = keysFunc(object),
  2255. length = props.length,
  2256. index = fromRight ? length : -1;
  2257. while ((fromRight ? index-- : ++index < length)) {
  2258. var key = props[index];
  2259. if (iteratee(iterable[key], key, iterable) === false) {
  2260. break;
  2261. }
  2262. }
  2263. return object;
  2264. };
  2265. }
  2266. function createFindIndex(fromRight) {
  2267. return function(array, predicate, thisArg) {
  2268. if (!(array && array.length)) {
  2269. return -1;
  2270. }
  2271. predicate = getCallback(predicate, thisArg, 3);
  2272. return baseFindIndex(array, predicate, fromRight);
  2273. };
  2274. }
  2275. function createForEach(arrayFunc, eachFunc) {
  2276. return function(collection, iteratee, thisArg) {
  2277. return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
  2278. ? arrayFunc(collection, iteratee)
  2279. : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
  2280. };
  2281. }
  2282. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  2283. var index = -1,
  2284. arrLength = array.length,
  2285. othLength = other.length,
  2286. result = true;
  2287. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  2288. return false;
  2289. }
  2290. while (result && ++index < arrLength) {
  2291. var arrValue = array[index],
  2292. othValue = other[index];
  2293. result = undefined;
  2294. if (customizer) {
  2295. result = isLoose
  2296. ? customizer(othValue, arrValue, index)
  2297. : customizer(arrValue, othValue, index);
  2298. }
  2299. if (result === undefined) {
  2300. if (isLoose) {
  2301. var othIndex = othLength;
  2302. while (othIndex--) {
  2303. othValue = other[othIndex];
  2304. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  2305. if (result) {
  2306. break;
  2307. }
  2308. }
  2309. } else {
  2310. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  2311. }
  2312. }
  2313. }
  2314. return !!result;
  2315. }
  2316. function equalByTag(object, other, tag) {
  2317. switch (tag) {
  2318. case boolTag:
  2319. case dateTag:
  2320. return +object == +other;
  2321. case errorTag:
  2322. return object.name == other.name && object.message == other.message;
  2323. case numberTag:
  2324. return (object != +object)
  2325. ? other != +other
  2326. : (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
  2327. case regexpTag:
  2328. case stringTag:
  2329. return object == (other + '');
  2330. }
  2331. return false;
  2332. }
  2333. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  2334. var objProps = keys(object),
  2335. objLength = objProps.length,
  2336. othProps = keys(other),
  2337. othLength = othProps.length;
  2338. if (objLength != othLength && !isLoose) {
  2339. return false;
  2340. }
  2341. var skipCtor = isLoose,
  2342. index = -1;
  2343. while (++index < objLength) {
  2344. var key = objProps[index],
  2345. result = isLoose ? key in other : hasOwnProperty.call(other, key);
  2346. if (result) {
  2347. var objValue = object[key],
  2348. othValue = other[key];
  2349. result = undefined;
  2350. if (customizer) {
  2351. result = isLoose
  2352. ? customizer(othValue, objValue, key)
  2353. : customizer(objValue, othValue, key);
  2354. }
  2355. if (result === undefined) {
  2356. result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
  2357. }
  2358. }
  2359. if (!result) {
  2360. return false;
  2361. }
  2362. skipCtor || (skipCtor = key == 'constructor');
  2363. }
  2364. if (!skipCtor) {
  2365. var objCtor = object.constructor,
  2366. othCtor = other.constructor;
  2367. if (objCtor != othCtor &&
  2368. ('constructor' in object && 'constructor' in other) &&
  2369. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  2370. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  2371. return false;
  2372. }
  2373. }
  2374. return true;
  2375. }
  2376. function getCallback(func, thisArg, argCount) {
  2377. var result = lodash.callback || callback;
  2378. result = result === callback ? baseCallback : result;
  2379. return argCount ? result(func, thisArg, argCount) : result;
  2380. }
  2381. function getIndexOf(collection, target, fromIndex) {
  2382. var result = lodash.indexOf || indexOf;
  2383. result = result === indexOf ? baseIndexOf : result;
  2384. return collection ? result(collection, target, fromIndex) : result;
  2385. }
  2386. var getLength = baseProperty('length');
  2387. var getSymbols = !getOwnPropertySymbols ? constant([]) : function(object) {
  2388. return getOwnPropertySymbols(toObject(object));
  2389. };
  2390. function initCloneArray(array) {
  2391. var length = array.length,
  2392. result = new array.constructor(length);
  2393. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  2394. result.index = array.index;
  2395. result.input = array.input;
  2396. }
  2397. return result;
  2398. }
  2399. function initCloneObject(object) {
  2400. var Ctor = object.constructor;
  2401. if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
  2402. Ctor = Object;
  2403. }
  2404. return new Ctor;
  2405. }
  2406. function initCloneByTag(object, tag, isDeep) {
  2407. var Ctor = object.constructor;
  2408. switch (tag) {
  2409. case arrayBufferTag:
  2410. return bufferClone(object);
  2411. case boolTag:
  2412. case dateTag:
  2413. return new Ctor(+object);
  2414. case float32Tag: case float64Tag:
  2415. case int8Tag: case int16Tag: case int32Tag:
  2416. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  2417. var buffer = object.buffer;
  2418. return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
  2419. case numberTag:
  2420. case stringTag:
  2421. return new Ctor(object);
  2422. case regexpTag:
  2423. var result = new Ctor(object.source, reFlags.exec(object));
  2424. result.lastIndex = object.lastIndex;
  2425. }
  2426. return result;
  2427. }
  2428. function isIndex(value, length) {
  2429. value = +value;
  2430. length = length == null ? MAX_SAFE_INTEGER : length;
  2431. return value > -1 && value % 1 == 0 && value < length;
  2432. }
  2433. function isIterateeCall(value, index, object) {
  2434. if (!isObject(object)) {
  2435. return false;
  2436. }
  2437. var type = typeof index;
  2438. if (type == 'number') {
  2439. var length = getLength(object),
  2440. prereq = isLength(length) && isIndex(index, length);
  2441. } else {
  2442. prereq = type == 'string' && index in object;
  2443. }
  2444. if (prereq) {
  2445. var other = object[index];
  2446. return value === value ? (value === other) : (other !== other);
  2447. }
  2448. return false;
  2449. }
  2450. function isKey(value, object) {
  2451. var type = typeof value;
  2452. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  2453. return true;
  2454. }
  2455. if (isArray(value)) {
  2456. return false;
  2457. }
  2458. var result = !reIsDeepProp.test(value);
  2459. return result || (object != null && value in toObject(object));
  2460. }
  2461. function isLength(value) {
  2462. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  2463. }
  2464. function isStrictComparable(value) {
  2465. return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
  2466. }
  2467. function shimIsPlainObject(value) {
  2468. var Ctor,
  2469. support = lodash.support;
  2470. if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||
  2471. (!hasOwnProperty.call(value, 'constructor') &&
  2472. (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  2473. return false;
  2474. }
  2475. var result;
  2476. baseForIn(value, function(subValue, key) {
  2477. result = key;
  2478. });
  2479. return result === undefined || hasOwnProperty.call(value, result);
  2480. }
  2481. function shimKeys(object) {
  2482. var props = keysIn(object),
  2483. propsLength = props.length,
  2484. length = propsLength && object.length,
  2485. support = lodash.support;
  2486. var allowIndexes = length && isLength(length) &&
  2487. (isArray(object) || (support.nonEnumArgs && isArguments(object)));
  2488. var index = -1,
  2489. result = [];
  2490. while (++index < propsLength) {
  2491. var key = props[index];
  2492. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  2493. result.push(key);
  2494. }
  2495. }
  2496. return result;
  2497. }
  2498. function toObject(value) {
  2499. return isObject(value) ? value : Object(value);
  2500. }
  2501. function toPath(value) {
  2502. if (isArray(value)) {
  2503. return value;
  2504. }
  2505. var result = [];
  2506. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  2507. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  2508. });
  2509. return result;
  2510. }
  2511. var findLastIndex = createFindIndex(true);
  2512. function indexOf(array, value, fromIndex) {
  2513. var length = array ? array.length : 0;
  2514. if (!length) {
  2515. return -1;
  2516. }
  2517. if (typeof fromIndex == 'number') {
  2518. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
  2519. } else if (fromIndex) {
  2520. var index = binaryIndex(array, value),
  2521. other = array[index];
  2522. if (value === value ? (value === other) : (other !== other)) {
  2523. return index;
  2524. }
  2525. return -1;
  2526. }
  2527. return baseIndexOf(array, value, fromIndex || 0);
  2528. }
  2529. function last(array) {
  2530. var length = array ? array.length : 0;
  2531. return length ? array[length - 1] : undefined;
  2532. }
  2533. function slice(array, start, end) {
  2534. var length = array ? array.length : 0;
  2535. if (!length) {
  2536. return [];
  2537. }
  2538. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  2539. start = 0;
  2540. end = length;
  2541. }
  2542. return baseSlice(array, start, end);
  2543. }
  2544. function unzip(array) {
  2545. var index = -1,
  2546. length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0,
  2547. result = Array(length);
  2548. while (++index < length) {
  2549. result[index] = arrayMap(array, baseProperty(index));
  2550. }
  2551. return result;
  2552. }
  2553. var zip = restParam(unzip);
  2554. var forEach = createForEach(arrayEach, baseEach);
  2555. function includes(collection, target, fromIndex, guard) {
  2556. var length = collection ? getLength(collection) : 0;
  2557. if (!isLength(length)) {
  2558. collection = values(collection);
  2559. length = collection.length;
  2560. }
  2561. if (!length) {
  2562. return false;
  2563. }
  2564. if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
  2565. fromIndex = 0;
  2566. } else {
  2567. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
  2568. }
  2569. return (typeof collection == 'string' || !isArray(collection) && isString(collection))
  2570. ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
  2571. : (getIndexOf(collection, target, fromIndex) > -1);
  2572. }
  2573. function reject(collection, predicate, thisArg) {
  2574. var func = isArray(collection) ? arrayFilter : baseFilter;
  2575. predicate = getCallback(predicate, thisArg, 3);
  2576. return func(collection, function(value, index, collection) {
  2577. return !predicate(value, index, collection);
  2578. });
  2579. }
  2580. function some(collection, predicate, thisArg) {
  2581. var func = isArray(collection) ? arraySome : baseSome;
  2582. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  2583. predicate = null;
  2584. }
  2585. if (typeof predicate != 'function' || thisArg !== undefined) {
  2586. predicate = getCallback(predicate, thisArg, 3);
  2587. }
  2588. return func(collection, predicate);
  2589. }
  2590. function restParam(func, start) {
  2591. if (typeof func != 'function') {
  2592. throw new TypeError(FUNC_ERROR_TEXT);
  2593. }
  2594. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  2595. return function() {
  2596. var args = arguments,
  2597. index = -1,
  2598. length = nativeMax(args.length - start, 0),
  2599. rest = Array(length);
  2600. while (++index < length) {
  2601. rest[index] = args[start + index];
  2602. }
  2603. switch (start) {
  2604. case 0: return func.call(this, rest);
  2605. case 1: return func.call(this, args[0], rest);
  2606. case 2: return func.call(this, args[0], args[1], rest);
  2607. }
  2608. var otherArgs = Array(start + 1);
  2609. index = -1;
  2610. while (++index < start) {
  2611. otherArgs[index] = args[index];
  2612. }
  2613. otherArgs[start] = rest;
  2614. return func.apply(this, otherArgs);
  2615. };
  2616. }
  2617. function clone(value, isDeep, customizer, thisArg) {
  2618. if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
  2619. isDeep = false;
  2620. }
  2621. else if (typeof isDeep == 'function') {
  2622. thisArg = customizer;
  2623. customizer = isDeep;
  2624. isDeep = false;
  2625. }
  2626. customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
  2627. return baseClone(value, isDeep, customizer);
  2628. }
  2629. function isArguments(value) {
  2630. var length = isObjectLike(value) ? value.length : undefined;
  2631. return isLength(length) && objToString.call(value) == argsTag;
  2632. }
  2633. var isArray = nativeIsArray || function(value) {
  2634. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  2635. };
  2636. function isEmpty(value) {
  2637. if (value == null) {
  2638. return true;
  2639. }
  2640. var length = getLength(value);
  2641. if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
  2642. (isObjectLike(value) && isFunction(value.splice)))) {
  2643. return !length;
  2644. }
  2645. return !keys(value).length;
  2646. }
  2647. var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
  2648. return objToString.call(value) == funcTag;
  2649. };
  2650. function isObject(value) {
  2651. var type = typeof value;
  2652. return type == 'function' || (!!value && type == 'object');
  2653. }
  2654. function isNative(value) {
  2655. if (value == null) {
  2656. return false;
  2657. }
  2658. if (objToString.call(value) == funcTag) {
  2659. return reIsNative.test(fnToString.call(value));
  2660. }
  2661. return isObjectLike(value) && reIsHostCtor.test(value);
  2662. }
  2663. function isNumber(value) {
  2664. return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
  2665. }
  2666. var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
  2667. if (!(value && objToString.call(value) == objectTag)) {
  2668. return false;
  2669. }
  2670. var valueOf = value.valueOf,
  2671. objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
  2672. return objProto
  2673. ? (value == objProto || getPrototypeOf(value) == objProto)
  2674. : shimIsPlainObject(value);
  2675. };
  2676. function isString(value) {
  2677. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  2678. }
  2679. function isTypedArray(value) {
  2680. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  2681. }
  2682. function toPlainObject(value) {
  2683. return baseCopy(value, keysIn(value));
  2684. }
  2685. var assign = createAssigner(function(object, source, customizer) {
  2686. return customizer
  2687. ? assignWith(object, source, customizer)
  2688. : baseAssign(object, source);
  2689. });
  2690. function has(object, path) {
  2691. if (object == null) {
  2692. return false;
  2693. }
  2694. var result = hasOwnProperty.call(object, path);
  2695. if (!result && !isKey(path)) {
  2696. path = toPath(path);
  2697. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  2698. path = last(path);
  2699. result = object != null && hasOwnProperty.call(object, path);
  2700. }
  2701. return result;
  2702. }
  2703. var keys = !nativeKeys ? shimKeys : function(object) {
  2704. if (object) {
  2705. var Ctor = object.constructor,
  2706. length = object.length;
  2707. }
  2708. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  2709. (typeof object != 'function' && isLength(length))) {
  2710. return shimKeys(object);
  2711. }
  2712. return isObject(object) ? nativeKeys(object) : [];
  2713. };
  2714. function keysIn(object) {
  2715. if (object == null) {
  2716. return [];
  2717. }
  2718. if (!isObject(object)) {
  2719. object = Object(object);
  2720. }
  2721. var length = object.length;
  2722. length = (length && isLength(length) &&
  2723. (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
  2724. var Ctor = object.constructor,
  2725. index = -1,
  2726. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  2727. result = Array(length),
  2728. skipIndexes = length > 0;
  2729. while (++index < length) {
  2730. result[index] = (index + '');
  2731. }
  2732. for (var key in object) {
  2733. if (!(skipIndexes && isIndex(key, length)) &&
  2734. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  2735. result.push(key);
  2736. }
  2737. }
  2738. return result;
  2739. }
  2740. var merge = createAssigner(baseMerge);
  2741. function values(object) {
  2742. return baseValues(object, keys(object));
  2743. }
  2744. function escapeRegExp(string) {
  2745. string = baseToString(string);
  2746. return (string && reHasRegExpChars.test(string))
  2747. ? string.replace(reRegExpChars, '\\$&')
  2748. : string;
  2749. }
  2750. function callback(func, thisArg, guard) {
  2751. if (guard && isIterateeCall(func, thisArg, guard)) {
  2752. thisArg = null;
  2753. }
  2754. return baseCallback(func, thisArg);
  2755. }
  2756. function constant(value) {
  2757. return function() {
  2758. return value;
  2759. };
  2760. }
  2761. function identity(value) {
  2762. return value;
  2763. }
  2764. function property(path) {
  2765. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  2766. }
  2767. lodash.assign = assign;
  2768. lodash.callback = callback;
  2769. lodash.constant = constant;
  2770. lodash.forEach = forEach;
  2771. lodash.keys = keys;
  2772. lodash.keysIn = keysIn;
  2773. lodash.merge = merge;
  2774. lodash.property = property;
  2775. lodash.reject = reject;
  2776. lodash.restParam = restParam;
  2777. lodash.slice = slice;
  2778. lodash.toPlainObject = toPlainObject;
  2779. lodash.unzip = unzip;
  2780. lodash.values = values;
  2781. lodash.zip = zip;
  2782. lodash.each = forEach;
  2783. lodash.extend = assign;
  2784. lodash.iteratee = callback;
  2785. lodash.clone = clone;
  2786. lodash.escapeRegExp = escapeRegExp;
  2787. lodash.findLastIndex = findLastIndex;
  2788. lodash.has = has;
  2789. lodash.identity = identity;
  2790. lodash.includes = includes;
  2791. lodash.indexOf = indexOf;
  2792. lodash.isArguments = isArguments;
  2793. lodash.isArray = isArray;
  2794. lodash.isEmpty = isEmpty;
  2795. lodash.isFunction = isFunction;
  2796. lodash.isNative = isNative;
  2797. lodash.isNumber = isNumber;
  2798. lodash.isObject = isObject;
  2799. lodash.isPlainObject = isPlainObject;
  2800. lodash.isString = isString;
  2801. lodash.isTypedArray = isTypedArray;
  2802. lodash.last = last;
  2803. lodash.some = some;
  2804. lodash.any = some;
  2805. lodash.contains = includes;
  2806. lodash.include = includes;
  2807. lodash.VERSION = VERSION;
  2808. if (freeExports && freeModule) {
  2809. if (moduleExports) {
  2810. (freeModule.exports = lodash)._ = lodash;
  2811. }
  2812. else {
  2813. freeExports._ = lodash;
  2814. }
  2815. }
  2816. else {
  2817. root._ = lodash;
  2818. }
  2819. }.call(this));
  2820. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2821. },{}],"/node_modules/jshint/src/jshint.js":[function(_dereq_,module,exports){
  2822. var _ = _dereq_("../lodash");
  2823. var events = _dereq_("events");
  2824. var vars = _dereq_("./vars.js");
  2825. var messages = _dereq_("./messages.js");
  2826. var Lexer = _dereq_("./lex.js").Lexer;
  2827. var reg = _dereq_("./reg.js");
  2828. var state = _dereq_("./state.js").state;
  2829. var style = _dereq_("./style.js");
  2830. var options = _dereq_("./options.js");
  2831. var scopeManager = _dereq_("./scope-manager.js");
  2832. var JSHINT = (function() {
  2833. "use strict";
  2834. var api, // Extension API
  2835. bang = {
  2836. "<" : true,
  2837. "<=" : true,
  2838. "==" : true,
  2839. "===": true,
  2840. "!==": true,
  2841. "!=" : true,
  2842. ">" : true,
  2843. ">=" : true,
  2844. "+" : true,
  2845. "-" : true,
  2846. "*" : true,
  2847. "/" : true,
  2848. "%" : true
  2849. },
  2850. declared, // Globals that were declared using /*global ... */ syntax.
  2851. functionicity = [
  2852. "closure", "exception", "global", "label",
  2853. "outer", "unused", "var"
  2854. ],
  2855. functions, // All of the functions
  2856. inblock,
  2857. indent,
  2858. lookahead,
  2859. lex,
  2860. member,
  2861. membersOnly,
  2862. predefined, // Global variables defined by option
  2863. stack,
  2864. urls,
  2865. extraModules = [],
  2866. emitter = new events.EventEmitter();
  2867. function checkOption(name, t) {
  2868. name = name.trim();
  2869. if (/^[+-]W\d{3}$/g.test(name)) {
  2870. return true;
  2871. }
  2872. if (options.validNames.indexOf(name) === -1) {
  2873. if (t.type !== "jslint" && !_.has(options.removed, name)) {
  2874. error("E001", t, name);
  2875. return false;
  2876. }
  2877. }
  2878. return true;
  2879. }
  2880. function isString(obj) {
  2881. return Object.prototype.toString.call(obj) === "[object String]";
  2882. }
  2883. function isIdentifier(tkn, value) {
  2884. if (!tkn)
  2885. return false;
  2886. if (!tkn.identifier || tkn.value !== value)
  2887. return false;
  2888. return true;
  2889. }
  2890. function isReserved(token) {
  2891. if (!token.reserved) {
  2892. return false;
  2893. }
  2894. var meta = token.meta;
  2895. if (meta && meta.isFutureReservedWord && state.inES5()) {
  2896. if (!meta.es5) {
  2897. return false;
  2898. }
  2899. if (meta.strictOnly) {
  2900. if (!state.option.strict && !state.isStrict()) {
  2901. return false;
  2902. }
  2903. }
  2904. if (token.isProperty) {
  2905. return false;
  2906. }
  2907. }
  2908. return true;
  2909. }
  2910. function supplant(str, data) {
  2911. return str.replace(/\{([^{}]*)\}/g, function(a, b) {
  2912. var r = data[b];
  2913. return typeof r === "string" || typeof r === "number" ? r : a;
  2914. });
  2915. }
  2916. function combine(dest, src) {
  2917. Object.keys(src).forEach(function(name) {
  2918. if (_.has(JSHINT.blacklist, name)) return;
  2919. dest[name] = src[name];
  2920. });
  2921. }
  2922. function processenforceall() {
  2923. if (state.option.enforceall) {
  2924. for (var enforceopt in options.bool.enforcing) {
  2925. if (state.option[enforceopt] === undefined &&
  2926. !options.noenforceall[enforceopt]) {
  2927. state.option[enforceopt] = true;
  2928. }
  2929. }
  2930. for (var relaxopt in options.bool.relaxing) {
  2931. if (state.option[relaxopt] === undefined) {
  2932. state.option[relaxopt] = false;
  2933. }
  2934. }
  2935. }
  2936. }
  2937. function assume() {
  2938. processenforceall();
  2939. if (!state.option.esversion && !state.option.moz) {
  2940. if (state.option.es3) {
  2941. state.option.esversion = 3;
  2942. } else if (state.option.esnext) {
  2943. state.option.esversion = 6;
  2944. } else {
  2945. state.option.esversion = 5;
  2946. }
  2947. }
  2948. if (state.inES5()) {
  2949. combine(predefined, vars.ecmaIdentifiers[5]);
  2950. }
  2951. if (state.inES6()) {
  2952. combine(predefined, vars.ecmaIdentifiers[6]);
  2953. }
  2954. if (state.option.module) {
  2955. if (state.option.strict === true) {
  2956. state.option.strict = "global";
  2957. }
  2958. if (!state.inES6()) {
  2959. warning("W134", state.tokens.next, "module", 6);
  2960. }
  2961. }
  2962. if (state.option.couch) {
  2963. combine(predefined, vars.couch);
  2964. }
  2965. if (state.option.qunit) {
  2966. combine(predefined, vars.qunit);
  2967. }
  2968. if (state.option.rhino) {
  2969. combine(predefined, vars.rhino);
  2970. }
  2971. if (state.option.shelljs) {
  2972. combine(predefined, vars.shelljs);
  2973. combine(predefined, vars.node);
  2974. }
  2975. if (state.option.typed) {
  2976. combine(predefined, vars.typed);
  2977. }
  2978. if (state.option.phantom) {
  2979. combine(predefined, vars.phantom);
  2980. if (state.option.strict === true) {
  2981. state.option.strict = "global";
  2982. }
  2983. }
  2984. if (state.option.prototypejs) {
  2985. combine(predefined, vars.prototypejs);
  2986. }
  2987. if (state.option.node) {
  2988. combine(predefined, vars.node);
  2989. combine(predefined, vars.typed);
  2990. if (state.option.strict === true) {
  2991. state.option.strict = "global";
  2992. }
  2993. }
  2994. if (state.option.devel) {
  2995. combine(predefined, vars.devel);
  2996. }
  2997. if (state.option.dojo) {
  2998. combine(predefined, vars.dojo);
  2999. }
  3000. if (state.option.browser) {
  3001. combine(predefined, vars.browser);
  3002. combine(predefined, vars.typed);
  3003. }
  3004. if (state.option.browserify) {
  3005. combine(predefined, vars.browser);
  3006. combine(predefined, vars.typed);
  3007. combine(predefined, vars.browserify);
  3008. if (state.option.strict === true) {
  3009. state.option.strict = "global";
  3010. }
  3011. }
  3012. if (state.option.nonstandard) {
  3013. combine(predefined, vars.nonstandard);
  3014. }
  3015. if (state.option.jasmine) {
  3016. combine(predefined, vars.jasmine);
  3017. }
  3018. if (state.option.jquery) {
  3019. combine(predefined, vars.jquery);
  3020. }
  3021. if (state.option.mootools) {
  3022. combine(predefined, vars.mootools);
  3023. }
  3024. if (state.option.worker) {
  3025. combine(predefined, vars.worker);
  3026. }
  3027. if (state.option.wsh) {
  3028. combine(predefined, vars.wsh);
  3029. }
  3030. if (state.option.globalstrict && state.option.strict !== false) {
  3031. state.option.strict = "global";
  3032. }
  3033. if (state.option.yui) {
  3034. combine(predefined, vars.yui);
  3035. }
  3036. if (state.option.mocha) {
  3037. combine(predefined, vars.mocha);
  3038. }
  3039. }
  3040. function quit(code, line, chr) {
  3041. var percentage = Math.floor((line / state.lines.length) * 100);
  3042. var message = messages.errors[code].desc;
  3043. throw {
  3044. name: "JSHintError",
  3045. line: line,
  3046. character: chr,
  3047. message: message + " (" + percentage + "% scanned).",
  3048. raw: message,
  3049. code: code
  3050. };
  3051. }
  3052. function removeIgnoredMessages() {
  3053. var ignored = state.ignoredLines;
  3054. if (_.isEmpty(ignored)) return;
  3055. JSHINT.errors = _.reject(JSHINT.errors, function(err) { return ignored[err.line] });
  3056. }
  3057. function warning(code, t, a, b, c, d) {
  3058. var ch, l, w, msg;
  3059. if (/^W\d{3}$/.test(code)) {
  3060. if (state.ignored[code])
  3061. return;
  3062. msg = messages.warnings[code];
  3063. } else if (/E\d{3}/.test(code)) {
  3064. msg = messages.errors[code];
  3065. } else if (/I\d{3}/.test(code)) {
  3066. msg = messages.info[code];
  3067. }
  3068. t = t || state.tokens.next || {};
  3069. if (t.id === "(end)") { // `~
  3070. t = state.tokens.curr;
  3071. }
  3072. l = t.line || 0;
  3073. ch = t.from || 0;
  3074. w = {
  3075. id: "(error)",
  3076. raw: msg.desc,
  3077. code: msg.code,
  3078. evidence: state.lines[l - 1] || "",
  3079. line: l,
  3080. character: ch,
  3081. scope: JSHINT.scope,
  3082. a: a,
  3083. b: b,
  3084. c: c,
  3085. d: d
  3086. };
  3087. w.reason = supplant(msg.desc, w);
  3088. JSHINT.errors.push(w);
  3089. removeIgnoredMessages();
  3090. if (JSHINT.errors.length >= state.option.maxerr)
  3091. quit("E043", l, ch);
  3092. return w;
  3093. }
  3094. function warningAt(m, l, ch, a, b, c, d) {
  3095. return warning(m, {
  3096. line: l,
  3097. from: ch
  3098. }, a, b, c, d);
  3099. }
  3100. function error(m, t, a, b, c, d) {
  3101. warning(m, t, a, b, c, d);
  3102. }
  3103. function errorAt(m, l, ch, a, b, c, d) {
  3104. return error(m, {
  3105. line: l,
  3106. from: ch
  3107. }, a, b, c, d);
  3108. }
  3109. function addInternalSrc(elem, src) {
  3110. var i;
  3111. i = {
  3112. id: "(internal)",
  3113. elem: elem,
  3114. value: src
  3115. };
  3116. JSHINT.internals.push(i);
  3117. return i;
  3118. }
  3119. function doOption() {
  3120. var nt = state.tokens.next;
  3121. var body = nt.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g) || [];
  3122. var predef = {};
  3123. if (nt.type === "globals") {
  3124. body.forEach(function(g, idx) {
  3125. g = g.split(":");
  3126. var key = (g[0] || "").trim();
  3127. var val = (g[1] || "").trim();
  3128. if (key === "-" || !key.length) {
  3129. if (idx > 0 && idx === body.length - 1) {
  3130. return;
  3131. }
  3132. error("E002", nt);
  3133. return;
  3134. }
  3135. if (key.charAt(0) === "-") {
  3136. key = key.slice(1);
  3137. val = false;
  3138. JSHINT.blacklist[key] = key;
  3139. delete predefined[key];
  3140. } else {
  3141. predef[key] = (val === "true");
  3142. }
  3143. });
  3144. combine(predefined, predef);
  3145. for (var key in predef) {
  3146. if (_.has(predef, key)) {
  3147. declared[key] = nt;
  3148. }
  3149. }
  3150. }
  3151. if (nt.type === "exported") {
  3152. body.forEach(function(e, idx) {
  3153. if (!e.length) {
  3154. if (idx > 0 && idx === body.length - 1) {
  3155. return;
  3156. }
  3157. error("E002", nt);
  3158. return;
  3159. }
  3160. state.funct["(scope)"].addExported(e);
  3161. });
  3162. }
  3163. if (nt.type === "members") {
  3164. membersOnly = membersOnly || {};
  3165. body.forEach(function(m) {
  3166. var ch1 = m.charAt(0);
  3167. var ch2 = m.charAt(m.length - 1);
  3168. if (ch1 === ch2 && (ch1 === "\"" || ch1 === "'")) {
  3169. m = m
  3170. .substr(1, m.length - 2)
  3171. .replace("\\\"", "\"");
  3172. }
  3173. membersOnly[m] = false;
  3174. });
  3175. }
  3176. var numvals = [
  3177. "maxstatements",
  3178. "maxparams",
  3179. "maxdepth",
  3180. "maxcomplexity",
  3181. "maxerr",
  3182. "maxlen",
  3183. "indent"
  3184. ];
  3185. if (nt.type === "jshint" || nt.type === "jslint") {
  3186. body.forEach(function(g) {
  3187. g = g.split(":");
  3188. var key = (g[0] || "").trim();
  3189. var val = (g[1] || "").trim();
  3190. if (!checkOption(key, nt)) {
  3191. return;
  3192. }
  3193. if (numvals.indexOf(key) >= 0) {
  3194. if (val !== "false") {
  3195. val = +val;
  3196. if (typeof val !== "number" || !isFinite(val) || val <= 0 || Math.floor(val) !== val) {
  3197. error("E032", nt, g[1].trim());
  3198. return;
  3199. }
  3200. state.option[key] = val;
  3201. } else {
  3202. state.option[key] = key === "indent" ? 4 : false;
  3203. }
  3204. return;
  3205. }
  3206. if (key === "validthis") {
  3207. if (state.funct["(global)"])
  3208. return void error("E009");
  3209. if (val !== "true" && val !== "false")
  3210. return void error("E002", nt);
  3211. state.option.validthis = (val === "true");
  3212. return;
  3213. }
  3214. if (key === "quotmark") {
  3215. switch (val) {
  3216. case "true":
  3217. case "false":
  3218. state.option.quotmark = (val === "true");
  3219. break;
  3220. case "double":
  3221. case "single":
  3222. state.option.quotmark = val;
  3223. break;
  3224. default:
  3225. error("E002", nt);
  3226. }
  3227. return;
  3228. }
  3229. if (key === "shadow") {
  3230. switch (val) {
  3231. case "true":
  3232. state.option.shadow = true;
  3233. break;
  3234. case "outer":
  3235. state.option.shadow = "outer";
  3236. break;
  3237. case "false":
  3238. case "inner":
  3239. state.option.shadow = "inner";
  3240. break;
  3241. default:
  3242. error("E002", nt);
  3243. }
  3244. return;
  3245. }
  3246. if (key === "unused") {
  3247. switch (val) {
  3248. case "true":
  3249. state.option.unused = true;
  3250. break;
  3251. case "false":
  3252. state.option.unused = false;
  3253. break;
  3254. case "vars":
  3255. case "strict":
  3256. state.option.unused = val;
  3257. break;
  3258. default:
  3259. error("E002", nt);
  3260. }
  3261. return;
  3262. }
  3263. if (key === "latedef") {
  3264. switch (val) {
  3265. case "true":
  3266. state.option.latedef = true;
  3267. break;
  3268. case "false":
  3269. state.option.latedef = false;
  3270. break;
  3271. case "nofunc":
  3272. state.option.latedef = "nofunc";
  3273. break;
  3274. default:
  3275. error("E002", nt);
  3276. }
  3277. return;
  3278. }
  3279. if (key === "ignore") {
  3280. switch (val) {
  3281. case "line":
  3282. state.ignoredLines[nt.line] = true;
  3283. removeIgnoredMessages();
  3284. break;
  3285. default:
  3286. error("E002", nt);
  3287. }
  3288. return;
  3289. }
  3290. if (key === "strict") {
  3291. switch (val) {
  3292. case "true":
  3293. state.option.strict = true;
  3294. break;
  3295. case "false":
  3296. state.option.strict = false;
  3297. break;
  3298. case "func":
  3299. case "global":
  3300. case "implied":
  3301. state.option.strict = val;
  3302. break;
  3303. default:
  3304. error("E002", nt);
  3305. }
  3306. return;
  3307. }
  3308. if (key === "module") {
  3309. if (!hasParsedCode(state.funct)) {
  3310. error("E055", state.tokens.next, "module");
  3311. }
  3312. }
  3313. var esversions = {
  3314. es3 : 3,
  3315. es5 : 5,
  3316. esnext: 6
  3317. };
  3318. if (_.has(esversions, key)) {
  3319. switch (val) {
  3320. case "true":
  3321. state.option.moz = false;
  3322. state.option.esversion = esversions[key];
  3323. break;
  3324. case "false":
  3325. if (!state.option.moz) {
  3326. state.option.esversion = 5;
  3327. }
  3328. break;
  3329. default:
  3330. error("E002", nt);
  3331. }
  3332. return;
  3333. }
  3334. if (key === "esversion") {
  3335. switch (val) {
  3336. case "5":
  3337. if (state.inES5(true)) {
  3338. warning("I003");
  3339. }
  3340. case "3":
  3341. case "6":
  3342. state.option.moz = false;
  3343. state.option.esversion = +val;
  3344. break;
  3345. case "2015":
  3346. state.option.moz = false;
  3347. state.option.esversion = 6;
  3348. break;
  3349. default:
  3350. error("E002", nt);
  3351. }
  3352. if (!hasParsedCode(state.funct)) {
  3353. error("E055", state.tokens.next, "esversion");
  3354. }
  3355. return;
  3356. }
  3357. var match = /^([+-])(W\d{3})$/g.exec(key);
  3358. if (match) {
  3359. state.ignored[match[2]] = (match[1] === "-");
  3360. return;
  3361. }
  3362. var tn;
  3363. if (val === "true" || val === "false") {
  3364. if (nt.type === "jslint") {
  3365. tn = options.renamed[key] || key;
  3366. state.option[tn] = (val === "true");
  3367. if (options.inverted[tn] !== undefined) {
  3368. state.option[tn] = !state.option[tn];
  3369. }
  3370. } else {
  3371. state.option[key] = (val === "true");
  3372. }
  3373. if (key === "newcap") {
  3374. state.option["(explicitNewcap)"] = true;
  3375. }
  3376. return;
  3377. }
  3378. error("E002", nt);
  3379. });
  3380. assume();
  3381. }
  3382. }
  3383. function peek(p) {
  3384. var i = p || 0, j = lookahead.length, t;
  3385. if (i < j) {
  3386. return lookahead[i];
  3387. }
  3388. while (j <= i) {
  3389. t = lookahead[j];
  3390. if (!t) {
  3391. t = lookahead[j] = lex.token();
  3392. }
  3393. j += 1;
  3394. }
  3395. if (!t && state.tokens.next.id === "(end)") {
  3396. return state.tokens.next;
  3397. }
  3398. return t;
  3399. }
  3400. function peekIgnoreEOL() {
  3401. var i = 0;
  3402. var t;
  3403. do {
  3404. t = peek(i++);
  3405. } while (t.id === "(endline)");
  3406. return t;
  3407. }
  3408. function advance(id, t) {
  3409. switch (state.tokens.curr.id) {
  3410. case "(number)":
  3411. if (state.tokens.next.id === ".") {
  3412. warning("W005", state.tokens.curr);
  3413. }
  3414. break;
  3415. case "-":
  3416. if (state.tokens.next.id === "-" || state.tokens.next.id === "--") {
  3417. warning("W006");
  3418. }
  3419. break;
  3420. case "+":
  3421. if (state.tokens.next.id === "+" || state.tokens.next.id === "++") {
  3422. warning("W007");
  3423. }
  3424. break;
  3425. }
  3426. if (id && state.tokens.next.id !== id) {
  3427. if (t) {
  3428. if (state.tokens.next.id === "(end)") {
  3429. error("E019", t, t.id);
  3430. } else {
  3431. error("E020", state.tokens.next, id, t.id, t.line, state.tokens.next.value);
  3432. }
  3433. } else if (state.tokens.next.type !== "(identifier)" || state.tokens.next.value !== id) {
  3434. warning("W116", state.tokens.next, id, state.tokens.next.value);
  3435. }
  3436. }
  3437. state.tokens.prev = state.tokens.curr;
  3438. state.tokens.curr = state.tokens.next;
  3439. for (;;) {
  3440. state.tokens.next = lookahead.shift() || lex.token();
  3441. if (!state.tokens.next) { // No more tokens left, give up
  3442. quit("E041", state.tokens.curr.line);
  3443. }
  3444. if (state.tokens.next.id === "(end)" || state.tokens.next.id === "(error)") {
  3445. return;
  3446. }
  3447. if (state.tokens.next.check) {
  3448. state.tokens.next.check();
  3449. }
  3450. if (state.tokens.next.isSpecial) {
  3451. if (state.tokens.next.type === "falls through") {
  3452. state.tokens.curr.caseFallsThrough = true;
  3453. } else {
  3454. doOption();
  3455. }
  3456. } else {
  3457. if (state.tokens.next.id !== "(endline)") {
  3458. break;
  3459. }
  3460. }
  3461. }
  3462. }
  3463. function isInfix(token) {
  3464. return token.infix || (!token.identifier && !token.template && !!token.led);
  3465. }
  3466. function isEndOfExpr() {
  3467. var curr = state.tokens.curr;
  3468. var next = state.tokens.next;
  3469. if (next.id === ";" || next.id === "}" || next.id === ":") {
  3470. return true;
  3471. }
  3472. if (isInfix(next) === isInfix(curr) || (curr.id === "yield" && state.inMoz())) {
  3473. return curr.line !== startLine(next);
  3474. }
  3475. return false;
  3476. }
  3477. function isBeginOfExpr(prev) {
  3478. return !prev.left && prev.arity !== "unary";
  3479. }
  3480. function expression(rbp, initial) {
  3481. var left, isArray = false, isObject = false, isLetExpr = false;
  3482. state.nameStack.push();
  3483. if (!initial && state.tokens.next.value === "let" && peek(0).value === "(") {
  3484. if (!state.inMoz()) {
  3485. warning("W118", state.tokens.next, "let expressions");
  3486. }
  3487. isLetExpr = true;
  3488. state.funct["(scope)"].stack();
  3489. advance("let");
  3490. advance("(");
  3491. state.tokens.prev.fud();
  3492. advance(")");
  3493. }
  3494. if (state.tokens.next.id === "(end)")
  3495. error("E006", state.tokens.curr);
  3496. var isDangerous =
  3497. state.option.asi &&
  3498. state.tokens.prev.line !== startLine(state.tokens.curr) &&
  3499. _.contains(["]", ")"], state.tokens.prev.id) &&
  3500. _.contains(["[", "("], state.tokens.curr.id);
  3501. if (isDangerous)
  3502. warning("W014", state.tokens.curr, state.tokens.curr.id);
  3503. advance();
  3504. if (initial) {
  3505. state.funct["(verb)"] = state.tokens.curr.value;
  3506. state.tokens.curr.beginsStmt = true;
  3507. }
  3508. if (initial === true && state.tokens.curr.fud) {
  3509. left = state.tokens.curr.fud();
  3510. } else {
  3511. if (state.tokens.curr.nud) {
  3512. left = state.tokens.curr.nud();
  3513. } else {
  3514. error("E030", state.tokens.curr, state.tokens.curr.id);
  3515. }
  3516. while ((rbp < state.tokens.next.lbp || state.tokens.next.type === "(template)") &&
  3517. !isEndOfExpr()) {
  3518. isArray = state.tokens.curr.value === "Array";
  3519. isObject = state.tokens.curr.value === "Object";
  3520. if (left && (left.value || (left.first && left.first.value))) {
  3521. if (left.value !== "new" ||
  3522. (left.first && left.first.value && left.first.value === ".")) {
  3523. isArray = false;
  3524. if (left.value !== state.tokens.curr.value) {
  3525. isObject = false;
  3526. }
  3527. }
  3528. }
  3529. advance();
  3530. if (isArray && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
  3531. warning("W009", state.tokens.curr);
  3532. }
  3533. if (isObject && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
  3534. warning("W010", state.tokens.curr);
  3535. }
  3536. if (left && state.tokens.curr.led) {
  3537. left = state.tokens.curr.led(left);
  3538. } else {
  3539. error("E033", state.tokens.curr, state.tokens.curr.id);
  3540. }
  3541. }
  3542. }
  3543. if (isLetExpr) {
  3544. state.funct["(scope)"].unstack();
  3545. }
  3546. state.nameStack.pop();
  3547. return left;
  3548. }
  3549. function startLine(token) {
  3550. return token.startLine || token.line;
  3551. }
  3552. function nobreaknonadjacent(left, right) {
  3553. left = left || state.tokens.curr;
  3554. right = right || state.tokens.next;
  3555. if (!state.option.laxbreak && left.line !== startLine(right)) {
  3556. warning("W014", right, right.value);
  3557. }
  3558. }
  3559. function nolinebreak(t) {
  3560. t = t || state.tokens.curr;
  3561. if (t.line !== startLine(state.tokens.next)) {
  3562. warning("E022", t, t.value);
  3563. }
  3564. }
  3565. function nobreakcomma(left, right) {
  3566. if (left.line !== startLine(right)) {
  3567. if (!state.option.laxcomma) {
  3568. if (comma.first) {
  3569. warning("I001");
  3570. comma.first = false;
  3571. }
  3572. warning("W014", left, right.value);
  3573. }
  3574. }
  3575. }
  3576. function comma(opts) {
  3577. opts = opts || {};
  3578. if (!opts.peek) {
  3579. nobreakcomma(state.tokens.curr, state.tokens.next);
  3580. advance(",");
  3581. } else {
  3582. nobreakcomma(state.tokens.prev, state.tokens.curr);
  3583. }
  3584. if (state.tokens.next.identifier && !(opts.property && state.inES5())) {
  3585. switch (state.tokens.next.value) {
  3586. case "break":
  3587. case "case":
  3588. case "catch":
  3589. case "continue":
  3590. case "default":
  3591. case "do":
  3592. case "else":
  3593. case "finally":
  3594. case "for":
  3595. case "if":
  3596. case "in":
  3597. case "instanceof":
  3598. case "return":
  3599. case "switch":
  3600. case "throw":
  3601. case "try":
  3602. case "var":
  3603. case "let":
  3604. case "while":
  3605. case "with":
  3606. error("E024", state.tokens.next, state.tokens.next.value);
  3607. return false;
  3608. }
  3609. }
  3610. if (state.tokens.next.type === "(punctuator)") {
  3611. switch (state.tokens.next.value) {
  3612. case "}":
  3613. case "]":
  3614. case ",":
  3615. if (opts.allowTrailing) {
  3616. return true;
  3617. }
  3618. case ")":
  3619. error("E024", state.tokens.next, state.tokens.next.value);
  3620. return false;
  3621. }
  3622. }
  3623. return true;
  3624. }
  3625. function symbol(s, p) {
  3626. var x = state.syntax[s];
  3627. if (!x || typeof x !== "object") {
  3628. state.syntax[s] = x = {
  3629. id: s,
  3630. lbp: p,
  3631. value: s
  3632. };
  3633. }
  3634. return x;
  3635. }
  3636. function delim(s) {
  3637. var x = symbol(s, 0);
  3638. x.delim = true;
  3639. return x;
  3640. }
  3641. function stmt(s, f) {
  3642. var x = delim(s);
  3643. x.identifier = x.reserved = true;
  3644. x.fud = f;
  3645. return x;
  3646. }
  3647. function blockstmt(s, f) {
  3648. var x = stmt(s, f);
  3649. x.block = true;
  3650. return x;
  3651. }
  3652. function reserveName(x) {
  3653. var c = x.id.charAt(0);
  3654. if ((c >= "a" && c <= "z") || (c >= "A" && c <= "Z")) {
  3655. x.identifier = x.reserved = true;
  3656. }
  3657. return x;
  3658. }
  3659. function prefix(s, f) {
  3660. var x = symbol(s, 150);
  3661. reserveName(x);
  3662. x.nud = (typeof f === "function") ? f : function() {
  3663. this.arity = "unary";
  3664. this.right = expression(150);
  3665. if (this.id === "++" || this.id === "--") {
  3666. if (state.option.plusplus) {
  3667. warning("W016", this, this.id);
  3668. } else if (this.right && (!this.right.identifier || isReserved(this.right)) &&
  3669. this.right.id !== "." && this.right.id !== "[") {
  3670. warning("W017", this);
  3671. }
  3672. if (this.right && this.right.isMetaProperty) {
  3673. error("E031", this);
  3674. } else if (this.right && this.right.identifier) {
  3675. state.funct["(scope)"].block.modify(this.right.value, this);
  3676. }
  3677. }
  3678. return this;
  3679. };
  3680. return x;
  3681. }
  3682. function type(s, f) {
  3683. var x = delim(s);
  3684. x.type = s;
  3685. x.nud = f;
  3686. return x;
  3687. }
  3688. function reserve(name, func) {
  3689. var x = type(name, func);
  3690. x.identifier = true;
  3691. x.reserved = true;
  3692. return x;
  3693. }
  3694. function FutureReservedWord(name, meta) {
  3695. var x = type(name, (meta && meta.nud) || function() {
  3696. return this;
  3697. });
  3698. meta = meta || {};
  3699. meta.isFutureReservedWord = true;
  3700. x.value = name;
  3701. x.identifier = true;
  3702. x.reserved = true;
  3703. x.meta = meta;
  3704. return x;
  3705. }
  3706. function reservevar(s, v) {
  3707. return reserve(s, function() {
  3708. if (typeof v === "function") {
  3709. v(this);
  3710. }
  3711. return this;
  3712. });
  3713. }
  3714. function infix(s, f, p, w) {
  3715. var x = symbol(s, p);
  3716. reserveName(x);
  3717. x.infix = true;
  3718. x.led = function(left) {
  3719. if (!w) {
  3720. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  3721. }
  3722. if ((s === "in" || s === "instanceof") && left.id === "!") {
  3723. warning("W018", left, "!");
  3724. }
  3725. if (typeof f === "function") {
  3726. return f(left, this);
  3727. } else {
  3728. this.left = left;
  3729. this.right = expression(p);
  3730. return this;
  3731. }
  3732. };
  3733. return x;
  3734. }
  3735. function application(s) {
  3736. var x = symbol(s, 42);
  3737. x.led = function(left) {
  3738. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  3739. this.left = left;
  3740. this.right = doFunction({ type: "arrow", loneArg: left });
  3741. return this;
  3742. };
  3743. return x;
  3744. }
  3745. function relation(s, f) {
  3746. var x = symbol(s, 100);
  3747. x.led = function(left) {
  3748. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  3749. this.left = left;
  3750. var right = this.right = expression(100);
  3751. if (isIdentifier(left, "NaN") || isIdentifier(right, "NaN")) {
  3752. warning("W019", this);
  3753. } else if (f) {
  3754. f.apply(this, [left, right]);
  3755. }
  3756. if (!left || !right) {
  3757. quit("E041", state.tokens.curr.line);
  3758. }
  3759. if (left.id === "!") {
  3760. warning("W018", left, "!");
  3761. }
  3762. if (right.id === "!") {
  3763. warning("W018", right, "!");
  3764. }
  3765. return this;
  3766. };
  3767. return x;
  3768. }
  3769. function isPoorRelation(node) {
  3770. return node &&
  3771. ((node.type === "(number)" && +node.value === 0) ||
  3772. (node.type === "(string)" && node.value === "") ||
  3773. (node.type === "null" && !state.option.eqnull) ||
  3774. node.type === "true" ||
  3775. node.type === "false" ||
  3776. node.type === "undefined");
  3777. }
  3778. var typeofValues = {};
  3779. typeofValues.legacy = [
  3780. "xml",
  3781. "unknown"
  3782. ];
  3783. typeofValues.es3 = [
  3784. "undefined", "boolean", "number", "string", "function", "object",
  3785. ];
  3786. typeofValues.es3 = typeofValues.es3.concat(typeofValues.legacy);
  3787. typeofValues.es6 = typeofValues.es3.concat("symbol");
  3788. function isTypoTypeof(left, right, state) {
  3789. var values;
  3790. if (state.option.notypeof)
  3791. return false;
  3792. if (!left || !right)
  3793. return false;
  3794. values = state.inES6() ? typeofValues.es6 : typeofValues.es3;
  3795. if (right.type === "(identifier)" && right.value === "typeof" && left.type === "(string)")
  3796. return !_.contains(values, left.value);
  3797. return false;
  3798. }
  3799. function isGlobalEval(left, state) {
  3800. var isGlobal = false;
  3801. if (left.type === "this" && state.funct["(context)"] === null) {
  3802. isGlobal = true;
  3803. }
  3804. else if (left.type === "(identifier)") {
  3805. if (state.option.node && left.value === "global") {
  3806. isGlobal = true;
  3807. }
  3808. else if (state.option.browser && (left.value === "window" || left.value === "document")) {
  3809. isGlobal = true;
  3810. }
  3811. }
  3812. return isGlobal;
  3813. }
  3814. function findNativePrototype(left) {
  3815. var natives = [
  3816. "Array", "ArrayBuffer", "Boolean", "Collator", "DataView", "Date",
  3817. "DateTimeFormat", "Error", "EvalError", "Float32Array", "Float64Array",
  3818. "Function", "Infinity", "Intl", "Int16Array", "Int32Array", "Int8Array",
  3819. "Iterator", "Number", "NumberFormat", "Object", "RangeError",
  3820. "ReferenceError", "RegExp", "StopIteration", "String", "SyntaxError",
  3821. "TypeError", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray",
  3822. "URIError"
  3823. ];
  3824. function walkPrototype(obj) {
  3825. if (typeof obj !== "object") return;
  3826. return obj.right === "prototype" ? obj : walkPrototype(obj.left);
  3827. }
  3828. function walkNative(obj) {
  3829. while (!obj.identifier && typeof obj.left === "object")
  3830. obj = obj.left;
  3831. if (obj.identifier && natives.indexOf(obj.value) >= 0)
  3832. return obj.value;
  3833. }
  3834. var prototype = walkPrototype(left);
  3835. if (prototype) return walkNative(prototype);
  3836. }
  3837. function checkLeftSideAssign(left, assignToken, options) {
  3838. var allowDestructuring = options && options.allowDestructuring;
  3839. assignToken = assignToken || left;
  3840. if (state.option.freeze) {
  3841. var nativeObject = findNativePrototype(left);
  3842. if (nativeObject)
  3843. warning("W121", left, nativeObject);
  3844. }
  3845. if (left.identifier && !left.isMetaProperty) {
  3846. state.funct["(scope)"].block.reassign(left.value, left);
  3847. }
  3848. if (left.id === ".") {
  3849. if (!left.left || left.left.value === "arguments" && !state.isStrict()) {
  3850. warning("E031", assignToken);
  3851. }
  3852. state.nameStack.set(state.tokens.prev);
  3853. return true;
  3854. } else if (left.id === "{" || left.id === "[") {
  3855. if (allowDestructuring && state.tokens.curr.left.destructAssign) {
  3856. state.tokens.curr.left.destructAssign.forEach(function(t) {
  3857. if (t.id) {
  3858. state.funct["(scope)"].block.modify(t.id, t.token);
  3859. }
  3860. });
  3861. } else {
  3862. if (left.id === "{" || !left.left) {
  3863. warning("E031", assignToken);
  3864. } else if (left.left.value === "arguments" && !state.isStrict()) {
  3865. warning("E031", assignToken);
  3866. }
  3867. }
  3868. if (left.id === "[") {
  3869. state.nameStack.set(left.right);
  3870. }
  3871. return true;
  3872. } else if (left.isMetaProperty) {
  3873. error("E031", assignToken);
  3874. return true;
  3875. } else if (left.identifier && !isReserved(left)) {
  3876. if (state.funct["(scope)"].labeltype(left.value) === "exception") {
  3877. warning("W022", left);
  3878. }
  3879. state.nameStack.set(left);
  3880. return true;
  3881. }
  3882. if (left === state.syntax["function"]) {
  3883. warning("W023", state.tokens.curr);
  3884. }
  3885. return false;
  3886. }
  3887. function assignop(s, f, p) {
  3888. var x = infix(s, typeof f === "function" ? f : function(left, that) {
  3889. that.left = left;
  3890. if (left && checkLeftSideAssign(left, that, { allowDestructuring: true })) {
  3891. that.right = expression(10);
  3892. return that;
  3893. }
  3894. error("E031", that);
  3895. }, p);
  3896. x.exps = true;
  3897. x.assign = true;
  3898. return x;
  3899. }
  3900. function bitwise(s, f, p) {
  3901. var x = symbol(s, p);
  3902. reserveName(x);
  3903. x.led = (typeof f === "function") ? f : function(left) {
  3904. if (state.option.bitwise) {
  3905. warning("W016", this, this.id);
  3906. }
  3907. this.left = left;
  3908. this.right = expression(p);
  3909. return this;
  3910. };
  3911. return x;
  3912. }
  3913. function bitwiseassignop(s) {
  3914. return assignop(s, function(left, that) {
  3915. if (state.option.bitwise) {
  3916. warning("W016", that, that.id);
  3917. }
  3918. if (left && checkLeftSideAssign(left, that)) {
  3919. that.right = expression(10);
  3920. return that;
  3921. }
  3922. error("E031", that);
  3923. }, 20);
  3924. }
  3925. function suffix(s) {
  3926. var x = symbol(s, 150);
  3927. x.led = function(left) {
  3928. if (state.option.plusplus) {
  3929. warning("W016", this, this.id);
  3930. } else if ((!left.identifier || isReserved(left)) && left.id !== "." && left.id !== "[") {
  3931. warning("W017", this);
  3932. }
  3933. if (left.isMetaProperty) {
  3934. error("E031", this);
  3935. } else if (left && left.identifier) {
  3936. state.funct["(scope)"].block.modify(left.value, left);
  3937. }
  3938. this.left = left;
  3939. return this;
  3940. };
  3941. return x;
  3942. }
  3943. function optionalidentifier(fnparam, prop, preserve) {
  3944. if (!state.tokens.next.identifier) {
  3945. return;
  3946. }
  3947. if (!preserve) {
  3948. advance();
  3949. }
  3950. var curr = state.tokens.curr;
  3951. var val = state.tokens.curr.value;
  3952. if (!isReserved(curr)) {
  3953. return val;
  3954. }
  3955. if (prop) {
  3956. if (state.inES5()) {
  3957. return val;
  3958. }
  3959. }
  3960. if (fnparam && val === "undefined") {
  3961. return val;
  3962. }
  3963. warning("W024", state.tokens.curr, state.tokens.curr.id);
  3964. return val;
  3965. }
  3966. function identifier(fnparam, prop) {
  3967. var i = optionalidentifier(fnparam, prop, false);
  3968. if (i) {
  3969. return i;
  3970. }
  3971. if (state.tokens.next.value === "...") {
  3972. if (!state.inES6(true)) {
  3973. warning("W119", state.tokens.next, "spread/rest operator", "6");
  3974. }
  3975. advance();
  3976. if (checkPunctuator(state.tokens.next, "...")) {
  3977. warning("E024", state.tokens.next, "...");
  3978. while (checkPunctuator(state.tokens.next, "...")) {
  3979. advance();
  3980. }
  3981. }
  3982. if (!state.tokens.next.identifier) {
  3983. warning("E024", state.tokens.curr, "...");
  3984. return;
  3985. }
  3986. return identifier(fnparam, prop);
  3987. } else {
  3988. error("E030", state.tokens.next, state.tokens.next.value);
  3989. if (state.tokens.next.id !== ";") {
  3990. advance();
  3991. }
  3992. }
  3993. }
  3994. function reachable(controlToken) {
  3995. var i = 0, t;
  3996. if (state.tokens.next.id !== ";" || controlToken.inBracelessBlock) {
  3997. return;
  3998. }
  3999. for (;;) {
  4000. do {
  4001. t = peek(i);
  4002. i += 1;
  4003. } while (t.id !== "(end)" && t.id === "(comment)");
  4004. if (t.reach) {
  4005. return;
  4006. }
  4007. if (t.id !== "(endline)") {
  4008. if (t.id === "function") {
  4009. if (state.option.latedef === true) {
  4010. warning("W026", t);
  4011. }
  4012. break;
  4013. }
  4014. warning("W027", t, t.value, controlToken.value);
  4015. break;
  4016. }
  4017. }
  4018. }
  4019. function parseFinalSemicolon() {
  4020. if (state.tokens.next.id !== ";") {
  4021. if (state.tokens.next.isUnclosed) return advance();
  4022. var sameLine = startLine(state.tokens.next) === state.tokens.curr.line &&
  4023. state.tokens.next.id !== "(end)";
  4024. var blockEnd = checkPunctuator(state.tokens.next, "}");
  4025. if (sameLine && !blockEnd) {
  4026. errorAt("E058", state.tokens.curr.line, state.tokens.curr.character);
  4027. } else if (!state.option.asi) {
  4028. if ((blockEnd && !state.option.lastsemic) || !sameLine) {
  4029. warningAt("W033", state.tokens.curr.line, state.tokens.curr.character);
  4030. }
  4031. }
  4032. } else {
  4033. advance(";");
  4034. }
  4035. }
  4036. function statement() {
  4037. var i = indent, r, t = state.tokens.next, hasOwnScope = false;
  4038. if (t.id === ";") {
  4039. advance(";");
  4040. return;
  4041. }
  4042. var res = isReserved(t);
  4043. if (res && t.meta && t.meta.isFutureReservedWord && peek().id === ":") {
  4044. warning("W024", t, t.id);
  4045. res = false;
  4046. }
  4047. if (t.identifier && !res && peek().id === ":") {
  4048. advance();
  4049. advance(":");
  4050. hasOwnScope = true;
  4051. state.funct["(scope)"].stack();
  4052. state.funct["(scope)"].block.addBreakLabel(t.value, { token: state.tokens.curr });
  4053. if (!state.tokens.next.labelled && state.tokens.next.value !== "{") {
  4054. warning("W028", state.tokens.next, t.value, state.tokens.next.value);
  4055. }
  4056. state.tokens.next.label = t.value;
  4057. t = state.tokens.next;
  4058. }
  4059. if (t.id === "{") {
  4060. var iscase = (state.funct["(verb)"] === "case" && state.tokens.curr.value === ":");
  4061. block(true, true, false, false, iscase);
  4062. return;
  4063. }
  4064. r = expression(0, true);
  4065. if (r && !(r.identifier && r.value === "function") &&
  4066. !(r.type === "(punctuator)" && r.left &&
  4067. r.left.identifier && r.left.value === "function")) {
  4068. if (!state.isStrict() &&
  4069. state.option.strict === "global") {
  4070. warning("E007");
  4071. }
  4072. }
  4073. if (!t.block) {
  4074. if (!state.option.expr && (!r || !r.exps)) {
  4075. warning("W030", state.tokens.curr);
  4076. } else if (state.option.nonew && r && r.left && r.id === "(" && r.left.id === "new") {
  4077. warning("W031", t);
  4078. }
  4079. parseFinalSemicolon();
  4080. }
  4081. indent = i;
  4082. if (hasOwnScope) {
  4083. state.funct["(scope)"].unstack();
  4084. }
  4085. return r;
  4086. }
  4087. function statements() {
  4088. var a = [], p;
  4089. while (!state.tokens.next.reach && state.tokens.next.id !== "(end)") {
  4090. if (state.tokens.next.id === ";") {
  4091. p = peek();
  4092. if (!p || (p.id !== "(" && p.id !== "[")) {
  4093. warning("W032");
  4094. }
  4095. advance(";");
  4096. } else {
  4097. a.push(statement());
  4098. }
  4099. }
  4100. return a;
  4101. }
  4102. function directives() {
  4103. var i, p, pn;
  4104. while (state.tokens.next.id === "(string)") {
  4105. p = peek(0);
  4106. if (p.id === "(endline)") {
  4107. i = 1;
  4108. do {
  4109. pn = peek(i++);
  4110. } while (pn.id === "(endline)");
  4111. if (pn.id === ";") {
  4112. p = pn;
  4113. } else if (pn.value === "[" || pn.value === ".") {
  4114. break;
  4115. } else if (!state.option.asi || pn.value === "(") {
  4116. warning("W033", state.tokens.next);
  4117. }
  4118. } else if (p.id === "." || p.id === "[") {
  4119. break;
  4120. } else if (p.id !== ";") {
  4121. warning("W033", p);
  4122. }
  4123. advance();
  4124. var directive = state.tokens.curr.value;
  4125. if (state.directive[directive] ||
  4126. (directive === "use strict" && state.option.strict === "implied")) {
  4127. warning("W034", state.tokens.curr, directive);
  4128. }
  4129. state.directive[directive] = true;
  4130. if (p.id === ";") {
  4131. advance(";");
  4132. }
  4133. }
  4134. if (state.isStrict()) {
  4135. if (!state.option["(explicitNewcap)"]) {
  4136. state.option.newcap = true;
  4137. }
  4138. state.option.undef = true;
  4139. }
  4140. }
  4141. function block(ordinary, stmt, isfunc, isfatarrow, iscase) {
  4142. var a,
  4143. b = inblock,
  4144. old_indent = indent,
  4145. m,
  4146. t,
  4147. line,
  4148. d;
  4149. inblock = ordinary;
  4150. t = state.tokens.next;
  4151. var metrics = state.funct["(metrics)"];
  4152. metrics.nestedBlockDepth += 1;
  4153. metrics.verifyMaxNestedBlockDepthPerFunction();
  4154. if (state.tokens.next.id === "{") {
  4155. advance("{");
  4156. state.funct["(scope)"].stack();
  4157. line = state.tokens.curr.line;
  4158. if (state.tokens.next.id !== "}") {
  4159. indent += state.option.indent;
  4160. while (!ordinary && state.tokens.next.from > indent) {
  4161. indent += state.option.indent;
  4162. }
  4163. if (isfunc) {
  4164. m = {};
  4165. for (d in state.directive) {
  4166. if (_.has(state.directive, d)) {
  4167. m[d] = state.directive[d];
  4168. }
  4169. }
  4170. directives();
  4171. if (state.option.strict && state.funct["(context)"]["(global)"]) {
  4172. if (!m["use strict"] && !state.isStrict()) {
  4173. warning("E007");
  4174. }
  4175. }
  4176. }
  4177. a = statements();
  4178. metrics.statementCount += a.length;
  4179. indent -= state.option.indent;
  4180. }
  4181. advance("}", t);
  4182. if (isfunc) {
  4183. state.funct["(scope)"].validateParams();
  4184. if (m) {
  4185. state.directive = m;
  4186. }
  4187. }
  4188. state.funct["(scope)"].unstack();
  4189. indent = old_indent;
  4190. } else if (!ordinary) {
  4191. if (isfunc) {
  4192. state.funct["(scope)"].stack();
  4193. m = {};
  4194. if (stmt && !isfatarrow && !state.inMoz()) {
  4195. error("W118", state.tokens.curr, "function closure expressions");
  4196. }
  4197. if (!stmt) {
  4198. for (d in state.directive) {
  4199. if (_.has(state.directive, d)) {
  4200. m[d] = state.directive[d];
  4201. }
  4202. }
  4203. }
  4204. expression(10);
  4205. if (state.option.strict && state.funct["(context)"]["(global)"]) {
  4206. if (!m["use strict"] && !state.isStrict()) {
  4207. warning("E007");
  4208. }
  4209. }
  4210. state.funct["(scope)"].unstack();
  4211. } else {
  4212. error("E021", state.tokens.next, "{", state.tokens.next.value);
  4213. }
  4214. } else {
  4215. state.funct["(noblockscopedvar)"] = state.tokens.next.id !== "for";
  4216. state.funct["(scope)"].stack();
  4217. if (!stmt || state.option.curly) {
  4218. warning("W116", state.tokens.next, "{", state.tokens.next.value);
  4219. }
  4220. state.tokens.next.inBracelessBlock = true;
  4221. indent += state.option.indent;
  4222. a = [statement()];
  4223. indent -= state.option.indent;
  4224. state.funct["(scope)"].unstack();
  4225. delete state.funct["(noblockscopedvar)"];
  4226. }
  4227. switch (state.funct["(verb)"]) {
  4228. case "break":
  4229. case "continue":
  4230. case "return":
  4231. case "throw":
  4232. if (iscase) {
  4233. break;
  4234. }
  4235. default:
  4236. state.funct["(verb)"] = null;
  4237. }
  4238. inblock = b;
  4239. if (ordinary && state.option.noempty && (!a || a.length === 0)) {
  4240. warning("W035", state.tokens.prev);
  4241. }
  4242. metrics.nestedBlockDepth -= 1;
  4243. return a;
  4244. }
  4245. function countMember(m) {
  4246. if (membersOnly && typeof membersOnly[m] !== "boolean") {
  4247. warning("W036", state.tokens.curr, m);
  4248. }
  4249. if (typeof member[m] === "number") {
  4250. member[m] += 1;
  4251. } else {
  4252. member[m] = 1;
  4253. }
  4254. }
  4255. type("(number)", function() {
  4256. return this;
  4257. });
  4258. type("(string)", function() {
  4259. return this;
  4260. });
  4261. state.syntax["(identifier)"] = {
  4262. type: "(identifier)",
  4263. lbp: 0,
  4264. identifier: true,
  4265. nud: function() {
  4266. var v = this.value;
  4267. if (state.tokens.next.id === "=>") {
  4268. return this;
  4269. }
  4270. if (!state.funct["(comparray)"].check(v)) {
  4271. state.funct["(scope)"].block.use(v, state.tokens.curr);
  4272. }
  4273. return this;
  4274. },
  4275. led: function() {
  4276. error("E033", state.tokens.next, state.tokens.next.value);
  4277. }
  4278. };
  4279. var baseTemplateSyntax = {
  4280. lbp: 0,
  4281. identifier: false,
  4282. template: true,
  4283. };
  4284. state.syntax["(template)"] = _.extend({
  4285. type: "(template)",
  4286. nud: doTemplateLiteral,
  4287. led: doTemplateLiteral,
  4288. noSubst: false
  4289. }, baseTemplateSyntax);
  4290. state.syntax["(template middle)"] = _.extend({
  4291. type: "(template middle)",
  4292. middle: true,
  4293. noSubst: false
  4294. }, baseTemplateSyntax);
  4295. state.syntax["(template tail)"] = _.extend({
  4296. type: "(template tail)",
  4297. tail: true,
  4298. noSubst: false
  4299. }, baseTemplateSyntax);
  4300. state.syntax["(no subst template)"] = _.extend({
  4301. type: "(template)",
  4302. nud: doTemplateLiteral,
  4303. led: doTemplateLiteral,
  4304. noSubst: true,
  4305. tail: true // mark as tail, since it's always the last component
  4306. }, baseTemplateSyntax);
  4307. type("(regexp)", function() {
  4308. return this;
  4309. });
  4310. delim("(endline)");
  4311. delim("(begin)");
  4312. delim("(end)").reach = true;
  4313. delim("(error)").reach = true;
  4314. delim("}").reach = true;
  4315. delim(")");
  4316. delim("]");
  4317. delim("\"").reach = true;
  4318. delim("'").reach = true;
  4319. delim(";");
  4320. delim(":").reach = true;
  4321. delim("#");
  4322. reserve("else");
  4323. reserve("case").reach = true;
  4324. reserve("catch");
  4325. reserve("default").reach = true;
  4326. reserve("finally");
  4327. reservevar("arguments", function(x) {
  4328. if (state.isStrict() && state.funct["(global)"]) {
  4329. warning("E008", x);
  4330. }
  4331. });
  4332. reservevar("eval");
  4333. reservevar("false");
  4334. reservevar("Infinity");
  4335. reservevar("null");
  4336. reservevar("this", function(x) {
  4337. if (state.isStrict() && !isMethod() &&
  4338. !state.option.validthis && ((state.funct["(statement)"] &&
  4339. state.funct["(name)"].charAt(0) > "Z") || state.funct["(global)"])) {
  4340. warning("W040", x);
  4341. }
  4342. });
  4343. reservevar("true");
  4344. reservevar("undefined");
  4345. assignop("=", "assign", 20);
  4346. assignop("+=", "assignadd", 20);
  4347. assignop("-=", "assignsub", 20);
  4348. assignop("*=", "assignmult", 20);
  4349. assignop("/=", "assigndiv", 20).nud = function() {
  4350. error("E014");
  4351. };
  4352. assignop("%=", "assignmod", 20);
  4353. bitwiseassignop("&=");
  4354. bitwiseassignop("|=");
  4355. bitwiseassignop("^=");
  4356. bitwiseassignop("<<=");
  4357. bitwiseassignop(">>=");
  4358. bitwiseassignop(">>>=");
  4359. infix(",", function(left, that) {
  4360. var expr;
  4361. that.exprs = [left];
  4362. if (state.option.nocomma) {
  4363. warning("W127");
  4364. }
  4365. if (!comma({ peek: true })) {
  4366. return that;
  4367. }
  4368. while (true) {
  4369. if (!(expr = expression(10))) {
  4370. break;
  4371. }
  4372. that.exprs.push(expr);
  4373. if (state.tokens.next.value !== "," || !comma()) {
  4374. break;
  4375. }
  4376. }
  4377. return that;
  4378. }, 10, true);
  4379. infix("?", function(left, that) {
  4380. increaseComplexityCount();
  4381. that.left = left;
  4382. that.right = expression(10);
  4383. advance(":");
  4384. that["else"] = expression(10);
  4385. return that;
  4386. }, 30);
  4387. var orPrecendence = 40;
  4388. infix("||", function(left, that) {
  4389. increaseComplexityCount();
  4390. that.left = left;
  4391. that.right = expression(orPrecendence);
  4392. return that;
  4393. }, orPrecendence);
  4394. infix("&&", "and", 50);
  4395. bitwise("|", "bitor", 70);
  4396. bitwise("^", "bitxor", 80);
  4397. bitwise("&", "bitand", 90);
  4398. relation("==", function(left, right) {
  4399. var eqnull = state.option.eqnull &&
  4400. ((left && left.value) === "null" || (right && right.value) === "null");
  4401. switch (true) {
  4402. case !eqnull && state.option.eqeqeq:
  4403. this.from = this.character;
  4404. warning("W116", this, "===", "==");
  4405. break;
  4406. case isPoorRelation(left):
  4407. warning("W041", this, "===", left.value);
  4408. break;
  4409. case isPoorRelation(right):
  4410. warning("W041", this, "===", right.value);
  4411. break;
  4412. case isTypoTypeof(right, left, state):
  4413. warning("W122", this, right.value);
  4414. break;
  4415. case isTypoTypeof(left, right, state):
  4416. warning("W122", this, left.value);
  4417. break;
  4418. }
  4419. return this;
  4420. });
  4421. relation("===", function(left, right) {
  4422. if (isTypoTypeof(right, left, state)) {
  4423. warning("W122", this, right.value);
  4424. } else if (isTypoTypeof(left, right, state)) {
  4425. warning("W122", this, left.value);
  4426. }
  4427. return this;
  4428. });
  4429. relation("!=", function(left, right) {
  4430. var eqnull = state.option.eqnull &&
  4431. ((left && left.value) === "null" || (right && right.value) === "null");
  4432. if (!eqnull && state.option.eqeqeq) {
  4433. this.from = this.character;
  4434. warning("W116", this, "!==", "!=");
  4435. } else if (isPoorRelation(left)) {
  4436. warning("W041", this, "!==", left.value);
  4437. } else if (isPoorRelation(right)) {
  4438. warning("W041", this, "!==", right.value);
  4439. } else if (isTypoTypeof(right, left, state)) {
  4440. warning("W122", this, right.value);
  4441. } else if (isTypoTypeof(left, right, state)) {
  4442. warning("W122", this, left.value);
  4443. }
  4444. return this;
  4445. });
  4446. relation("!==", function(left, right) {
  4447. if (isTypoTypeof(right, left, state)) {
  4448. warning("W122", this, right.value);
  4449. } else if (isTypoTypeof(left, right, state)) {
  4450. warning("W122", this, left.value);
  4451. }
  4452. return this;
  4453. });
  4454. relation("<");
  4455. relation(">");
  4456. relation("<=");
  4457. relation(">=");
  4458. bitwise("<<", "shiftleft", 120);
  4459. bitwise(">>", "shiftright", 120);
  4460. bitwise(">>>", "shiftrightunsigned", 120);
  4461. infix("in", "in", 120);
  4462. infix("instanceof", "instanceof", 120);
  4463. infix("+", function(left, that) {
  4464. var right;
  4465. that.left = left;
  4466. that.right = right = expression(130);
  4467. if (left && right && left.id === "(string)" && right.id === "(string)") {
  4468. left.value += right.value;
  4469. left.character = right.character;
  4470. if (!state.option.scripturl && reg.javascriptURL.test(left.value)) {
  4471. warning("W050", left);
  4472. }
  4473. return left;
  4474. }
  4475. return that;
  4476. }, 130);
  4477. prefix("+", "num");
  4478. prefix("+++", function() {
  4479. warning("W007");
  4480. this.arity = "unary";
  4481. this.right = expression(150);
  4482. return this;
  4483. });
  4484. infix("+++", function(left) {
  4485. warning("W007");
  4486. this.left = left;
  4487. this.right = expression(130);
  4488. return this;
  4489. }, 130);
  4490. infix("-", "sub", 130);
  4491. prefix("-", "neg");
  4492. prefix("---", function() {
  4493. warning("W006");
  4494. this.arity = "unary";
  4495. this.right = expression(150);
  4496. return this;
  4497. });
  4498. infix("---", function(left) {
  4499. warning("W006");
  4500. this.left = left;
  4501. this.right = expression(130);
  4502. return this;
  4503. }, 130);
  4504. infix("*", "mult", 140);
  4505. infix("/", "div", 140);
  4506. infix("%", "mod", 140);
  4507. suffix("++");
  4508. prefix("++", "preinc");
  4509. state.syntax["++"].exps = true;
  4510. suffix("--");
  4511. prefix("--", "predec");
  4512. state.syntax["--"].exps = true;
  4513. prefix("delete", function() {
  4514. var p = expression(10);
  4515. if (!p) {
  4516. return this;
  4517. }
  4518. if (p.id !== "." && p.id !== "[") {
  4519. warning("W051");
  4520. }
  4521. this.first = p;
  4522. if (p.identifier && !state.isStrict()) {
  4523. p.forgiveUndef = true;
  4524. }
  4525. return this;
  4526. }).exps = true;
  4527. prefix("~", function() {
  4528. if (state.option.bitwise) {
  4529. warning("W016", this, "~");
  4530. }
  4531. this.arity = "unary";
  4532. this.right = expression(150);
  4533. return this;
  4534. });
  4535. prefix("...", function() {
  4536. if (!state.inES6(true)) {
  4537. warning("W119", this, "spread/rest operator", "6");
  4538. }
  4539. if (!state.tokens.next.identifier &&
  4540. state.tokens.next.type !== "(string)" &&
  4541. !checkPunctuators(state.tokens.next, ["[", "("])) {
  4542. error("E030", state.tokens.next, state.tokens.next.value);
  4543. }
  4544. expression(150);
  4545. return this;
  4546. });
  4547. prefix("!", function() {
  4548. this.arity = "unary";
  4549. this.right = expression(150);
  4550. if (!this.right) { // '!' followed by nothing? Give up.
  4551. quit("E041", this.line || 0);
  4552. }
  4553. if (bang[this.right.id] === true) {
  4554. warning("W018", this, "!");
  4555. }
  4556. return this;
  4557. });
  4558. prefix("typeof", (function() {
  4559. var p = expression(150);
  4560. this.first = this.right = p;
  4561. if (!p) { // 'typeof' followed by nothing? Give up.
  4562. quit("E041", this.line || 0, this.character || 0);
  4563. }
  4564. if (p.identifier) {
  4565. p.forgiveUndef = true;
  4566. }
  4567. return this;
  4568. }));
  4569. prefix("new", function() {
  4570. var mp = metaProperty("target", function() {
  4571. if (!state.inES6(true)) {
  4572. warning("W119", state.tokens.prev, "new.target", "6");
  4573. }
  4574. var inFunction, c = state.funct;
  4575. while (c) {
  4576. inFunction = !c["(global)"];
  4577. if (!c["(arrow)"]) { break; }
  4578. c = c["(context)"];
  4579. }
  4580. if (!inFunction) {
  4581. warning("W136", state.tokens.prev, "new.target");
  4582. }
  4583. });
  4584. if (mp) { return mp; }
  4585. var c = expression(155), i;
  4586. if (c && c.id !== "function") {
  4587. if (c.identifier) {
  4588. c["new"] = true;
  4589. switch (c.value) {
  4590. case "Number":
  4591. case "String":
  4592. case "Boolean":
  4593. case "Math":
  4594. case "JSON":
  4595. warning("W053", state.tokens.prev, c.value);
  4596. break;
  4597. case "Symbol":
  4598. if (state.inES6()) {
  4599. warning("W053", state.tokens.prev, c.value);
  4600. }
  4601. break;
  4602. case "Function":
  4603. if (!state.option.evil) {
  4604. warning("W054");
  4605. }
  4606. break;
  4607. case "Date":
  4608. case "RegExp":
  4609. case "this":
  4610. break;
  4611. default:
  4612. if (c.id !== "function") {
  4613. i = c.value.substr(0, 1);
  4614. if (state.option.newcap && (i < "A" || i > "Z") &&
  4615. !state.funct["(scope)"].isPredefined(c.value)) {
  4616. warning("W055", state.tokens.curr);
  4617. }
  4618. }
  4619. }
  4620. } else {
  4621. if (c.id !== "." && c.id !== "[" && c.id !== "(") {
  4622. warning("W056", state.tokens.curr);
  4623. }
  4624. }
  4625. } else {
  4626. if (!state.option.supernew)
  4627. warning("W057", this);
  4628. }
  4629. if (state.tokens.next.id !== "(" && !state.option.supernew) {
  4630. warning("W058", state.tokens.curr, state.tokens.curr.value);
  4631. }
  4632. this.first = this.right = c;
  4633. return this;
  4634. });
  4635. state.syntax["new"].exps = true;
  4636. prefix("void").exps = true;
  4637. infix(".", function(left, that) {
  4638. var m = identifier(false, true);
  4639. if (typeof m === "string") {
  4640. countMember(m);
  4641. }
  4642. that.left = left;
  4643. that.right = m;
  4644. if (m && m === "hasOwnProperty" && state.tokens.next.value === "=") {
  4645. warning("W001");
  4646. }
  4647. if (left && left.value === "arguments" && (m === "callee" || m === "caller")) {
  4648. if (state.option.noarg)
  4649. warning("W059", left, m);
  4650. else if (state.isStrict())
  4651. error("E008");
  4652. } else if (!state.option.evil && left && left.value === "document" &&
  4653. (m === "write" || m === "writeln")) {
  4654. warning("W060", left);
  4655. }
  4656. if (!state.option.evil && (m === "eval" || m === "execScript")) {
  4657. if (isGlobalEval(left, state)) {
  4658. warning("W061");
  4659. }
  4660. }
  4661. return that;
  4662. }, 160, true);
  4663. infix("(", function(left, that) {
  4664. if (state.option.immed && left && !left.immed && left.id === "function") {
  4665. warning("W062");
  4666. }
  4667. var n = 0;
  4668. var p = [];
  4669. if (left) {
  4670. if (left.type === "(identifier)") {
  4671. if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
  4672. if ("Array Number String Boolean Date Object Error Symbol".indexOf(left.value) === -1) {
  4673. if (left.value === "Math") {
  4674. warning("W063", left);
  4675. } else if (state.option.newcap) {
  4676. warning("W064", left);
  4677. }
  4678. }
  4679. }
  4680. }
  4681. }
  4682. if (state.tokens.next.id !== ")") {
  4683. for (;;) {
  4684. p[p.length] = expression(10);
  4685. n += 1;
  4686. if (state.tokens.next.id !== ",") {
  4687. break;
  4688. }
  4689. comma();
  4690. }
  4691. }
  4692. advance(")");
  4693. if (typeof left === "object") {
  4694. if (!state.inES5() && left.value === "parseInt" && n === 1) {
  4695. warning("W065", state.tokens.curr);
  4696. }
  4697. if (!state.option.evil) {
  4698. if (left.value === "eval" || left.value === "Function" ||
  4699. left.value === "execScript") {
  4700. warning("W061", left);
  4701. if (p[0] && [0].id === "(string)") {
  4702. addInternalSrc(left, p[0].value);
  4703. }
  4704. } else if (p[0] && p[0].id === "(string)" &&
  4705. (left.value === "setTimeout" ||
  4706. left.value === "setInterval")) {
  4707. warning("W066", left);
  4708. addInternalSrc(left, p[0].value);
  4709. } else if (p[0] && p[0].id === "(string)" &&
  4710. left.value === "." &&
  4711. left.left.value === "window" &&
  4712. (left.right === "setTimeout" ||
  4713. left.right === "setInterval")) {
  4714. warning("W066", left);
  4715. addInternalSrc(left, p[0].value);
  4716. }
  4717. }
  4718. if (!left.identifier && left.id !== "." && left.id !== "[" && left.id !== "=>" &&
  4719. left.id !== "(" && left.id !== "&&" && left.id !== "||" && left.id !== "?" &&
  4720. !(state.inES6() && left["(name)"])) {
  4721. warning("W067", that);
  4722. }
  4723. }
  4724. that.left = left;
  4725. return that;
  4726. }, 155, true).exps = true;
  4727. prefix("(", function() {
  4728. var pn = state.tokens.next, pn1, i = -1;
  4729. var ret, triggerFnExpr, first, last;
  4730. var parens = 1;
  4731. var opening = state.tokens.curr;
  4732. var preceeding = state.tokens.prev;
  4733. var isNecessary = !state.option.singleGroups;
  4734. do {
  4735. if (pn.value === "(") {
  4736. parens += 1;
  4737. } else if (pn.value === ")") {
  4738. parens -= 1;
  4739. }
  4740. i += 1;
  4741. pn1 = pn;
  4742. pn = peek(i);
  4743. } while (!(parens === 0 && pn1.value === ")") && pn.value !== ";" && pn.type !== "(end)");
  4744. if (state.tokens.next.id === "function") {
  4745. triggerFnExpr = state.tokens.next.immed = true;
  4746. }
  4747. if (pn.value === "=>") {
  4748. return doFunction({ type: "arrow", parsedOpening: true });
  4749. }
  4750. var exprs = [];
  4751. if (state.tokens.next.id !== ")") {
  4752. for (;;) {
  4753. exprs.push(expression(10));
  4754. if (state.tokens.next.id !== ",") {
  4755. break;
  4756. }
  4757. if (state.option.nocomma) {
  4758. warning("W127");
  4759. }
  4760. comma();
  4761. }
  4762. }
  4763. advance(")", this);
  4764. if (state.option.immed && exprs[0] && exprs[0].id === "function") {
  4765. if (state.tokens.next.id !== "(" &&
  4766. state.tokens.next.id !== "." && state.tokens.next.id !== "[") {
  4767. warning("W068", this);
  4768. }
  4769. }
  4770. if (!exprs.length) {
  4771. return;
  4772. }
  4773. if (exprs.length > 1) {
  4774. ret = Object.create(state.syntax[","]);
  4775. ret.exprs = exprs;
  4776. first = exprs[0];
  4777. last = exprs[exprs.length - 1];
  4778. if (!isNecessary) {
  4779. isNecessary = preceeding.assign || preceeding.delim;
  4780. }
  4781. } else {
  4782. ret = first = last = exprs[0];
  4783. if (!isNecessary) {
  4784. isNecessary =
  4785. (opening.beginsStmt && (ret.id === "{" || triggerFnExpr || isFunctor(ret))) ||
  4786. (triggerFnExpr &&
  4787. (!isEndOfExpr() || state.tokens.prev.id !== "}")) ||
  4788. (isFunctor(ret) && !isEndOfExpr()) ||
  4789. (ret.id === "{" && preceeding.id === "=>") ||
  4790. (ret.type === "(number)" &&
  4791. checkPunctuator(pn, ".") && /^\d+$/.test(ret.value));
  4792. }
  4793. }
  4794. if (ret) {
  4795. if (!isNecessary && (first.left || first.right || ret.exprs)) {
  4796. isNecessary =
  4797. (!isBeginOfExpr(preceeding) && first.lbp <= preceeding.lbp) ||
  4798. (!isEndOfExpr() && last.lbp < state.tokens.next.lbp);
  4799. }
  4800. if (!isNecessary) {
  4801. warning("W126", opening);
  4802. }
  4803. ret.paren = true;
  4804. }
  4805. return ret;
  4806. });
  4807. application("=>");
  4808. infix("[", function(left, that) {
  4809. var e = expression(10), s;
  4810. if (e && e.type === "(string)") {
  4811. if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) {
  4812. if (isGlobalEval(left, state)) {
  4813. warning("W061");
  4814. }
  4815. }
  4816. countMember(e.value);
  4817. if (!state.option.sub && reg.identifier.test(e.value)) {
  4818. s = state.syntax[e.value];
  4819. if (!s || !isReserved(s)) {
  4820. warning("W069", state.tokens.prev, e.value);
  4821. }
  4822. }
  4823. }
  4824. advance("]", that);
  4825. if (e && e.value === "hasOwnProperty" && state.tokens.next.value === "=") {
  4826. warning("W001");
  4827. }
  4828. that.left = left;
  4829. that.right = e;
  4830. return that;
  4831. }, 160, true);
  4832. function comprehensiveArrayExpression() {
  4833. var res = {};
  4834. res.exps = true;
  4835. state.funct["(comparray)"].stack();
  4836. var reversed = false;
  4837. if (state.tokens.next.value !== "for") {
  4838. reversed = true;
  4839. if (!state.inMoz()) {
  4840. warning("W116", state.tokens.next, "for", state.tokens.next.value);
  4841. }
  4842. state.funct["(comparray)"].setState("use");
  4843. res.right = expression(10);
  4844. }
  4845. advance("for");
  4846. if (state.tokens.next.value === "each") {
  4847. advance("each");
  4848. if (!state.inMoz()) {
  4849. warning("W118", state.tokens.curr, "for each");
  4850. }
  4851. }
  4852. advance("(");
  4853. state.funct["(comparray)"].setState("define");
  4854. res.left = expression(130);
  4855. if (_.contains(["in", "of"], state.tokens.next.value)) {
  4856. advance();
  4857. } else {
  4858. error("E045", state.tokens.curr);
  4859. }
  4860. state.funct["(comparray)"].setState("generate");
  4861. expression(10);
  4862. advance(")");
  4863. if (state.tokens.next.value === "if") {
  4864. advance("if");
  4865. advance("(");
  4866. state.funct["(comparray)"].setState("filter");
  4867. res.filter = expression(10);
  4868. advance(")");
  4869. }
  4870. if (!reversed) {
  4871. state.funct["(comparray)"].setState("use");
  4872. res.right = expression(10);
  4873. }
  4874. advance("]");
  4875. state.funct["(comparray)"].unstack();
  4876. return res;
  4877. }
  4878. prefix("[", function() {
  4879. var blocktype = lookupBlockType();
  4880. if (blocktype.isCompArray) {
  4881. if (!state.option.esnext && !state.inMoz()) {
  4882. warning("W118", state.tokens.curr, "array comprehension");
  4883. }
  4884. return comprehensiveArrayExpression();
  4885. } else if (blocktype.isDestAssign) {
  4886. this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
  4887. return this;
  4888. }
  4889. var b = state.tokens.curr.line !== startLine(state.tokens.next);
  4890. this.first = [];
  4891. if (b) {
  4892. indent += state.option.indent;
  4893. if (state.tokens.next.from === indent + state.option.indent) {
  4894. indent += state.option.indent;
  4895. }
  4896. }
  4897. while (state.tokens.next.id !== "(end)") {
  4898. while (state.tokens.next.id === ",") {
  4899. if (!state.option.elision) {
  4900. if (!state.inES5()) {
  4901. warning("W070");
  4902. } else {
  4903. warning("W128");
  4904. do {
  4905. advance(",");
  4906. } while (state.tokens.next.id === ",");
  4907. continue;
  4908. }
  4909. }
  4910. advance(",");
  4911. }
  4912. if (state.tokens.next.id === "]") {
  4913. break;
  4914. }
  4915. this.first.push(expression(10));
  4916. if (state.tokens.next.id === ",") {
  4917. comma({ allowTrailing: true });
  4918. if (state.tokens.next.id === "]" && !state.inES5()) {
  4919. warning("W070", state.tokens.curr);
  4920. break;
  4921. }
  4922. } else {
  4923. break;
  4924. }
  4925. }
  4926. if (b) {
  4927. indent -= state.option.indent;
  4928. }
  4929. advance("]", this);
  4930. return this;
  4931. });
  4932. function isMethod() {
  4933. return state.funct["(statement)"] && state.funct["(statement)"].type === "class" ||
  4934. state.funct["(context)"] && state.funct["(context)"]["(verb)"] === "class";
  4935. }
  4936. function isPropertyName(token) {
  4937. return token.identifier || token.id === "(string)" || token.id === "(number)";
  4938. }
  4939. function propertyName(preserveOrToken) {
  4940. var id;
  4941. var preserve = true;
  4942. if (typeof preserveOrToken === "object") {
  4943. id = preserveOrToken;
  4944. } else {
  4945. preserve = preserveOrToken;
  4946. id = optionalidentifier(false, true, preserve);
  4947. }
  4948. if (!id) {
  4949. if (state.tokens.next.id === "(string)") {
  4950. id = state.tokens.next.value;
  4951. if (!preserve) {
  4952. advance();
  4953. }
  4954. } else if (state.tokens.next.id === "(number)") {
  4955. id = state.tokens.next.value.toString();
  4956. if (!preserve) {
  4957. advance();
  4958. }
  4959. }
  4960. } else if (typeof id === "object") {
  4961. if (id.id === "(string)" || id.id === "(identifier)") id = id.value;
  4962. else if (id.id === "(number)") id = id.value.toString();
  4963. }
  4964. if (id === "hasOwnProperty") {
  4965. warning("W001");
  4966. }
  4967. return id;
  4968. }
  4969. function functionparams(options) {
  4970. var next;
  4971. var paramsIds = [];
  4972. var ident;
  4973. var tokens = [];
  4974. var t;
  4975. var pastDefault = false;
  4976. var pastRest = false;
  4977. var arity = 0;
  4978. var loneArg = options && options.loneArg;
  4979. if (loneArg && loneArg.identifier === true) {
  4980. state.funct["(scope)"].addParam(loneArg.value, loneArg);
  4981. return { arity: 1, params: [ loneArg.value ] };
  4982. }
  4983. next = state.tokens.next;
  4984. if (!options || !options.parsedOpening) {
  4985. advance("(");
  4986. }
  4987. if (state.tokens.next.id === ")") {
  4988. advance(")");
  4989. return;
  4990. }
  4991. function addParam(addParamArgs) {
  4992. state.funct["(scope)"].addParam.apply(state.funct["(scope)"], addParamArgs);
  4993. }
  4994. for (;;) {
  4995. arity++;
  4996. var currentParams = [];
  4997. if (_.contains(["{", "["], state.tokens.next.id)) {
  4998. tokens = destructuringPattern();
  4999. for (t in tokens) {
  5000. t = tokens[t];
  5001. if (t.id) {
  5002. paramsIds.push(t.id);
  5003. currentParams.push([t.id, t.token]);
  5004. }
  5005. }
  5006. } else {
  5007. if (checkPunctuator(state.tokens.next, "...")) pastRest = true;
  5008. ident = identifier(true);
  5009. if (ident) {
  5010. paramsIds.push(ident);
  5011. currentParams.push([ident, state.tokens.curr]);
  5012. } else {
  5013. while (!checkPunctuators(state.tokens.next, [",", ")"])) advance();
  5014. }
  5015. }
  5016. if (pastDefault) {
  5017. if (state.tokens.next.id !== "=") {
  5018. error("W138", state.tokens.current);
  5019. }
  5020. }
  5021. if (state.tokens.next.id === "=") {
  5022. if (!state.inES6()) {
  5023. warning("W119", state.tokens.next, "default parameters", "6");
  5024. }
  5025. advance("=");
  5026. pastDefault = true;
  5027. expression(10);
  5028. }
  5029. currentParams.forEach(addParam);
  5030. if (state.tokens.next.id === ",") {
  5031. if (pastRest) {
  5032. warning("W131", state.tokens.next);
  5033. }
  5034. comma();
  5035. } else {
  5036. advance(")", next);
  5037. return { arity: arity, params: paramsIds };
  5038. }
  5039. }
  5040. }
  5041. function functor(name, token, overwrites) {
  5042. var funct = {
  5043. "(name)" : name,
  5044. "(breakage)" : 0,
  5045. "(loopage)" : 0,
  5046. "(tokens)" : {},
  5047. "(properties)": {},
  5048. "(catch)" : false,
  5049. "(global)" : false,
  5050. "(line)" : null,
  5051. "(character)" : null,
  5052. "(metrics)" : null,
  5053. "(statement)" : null,
  5054. "(context)" : null,
  5055. "(scope)" : null,
  5056. "(comparray)" : null,
  5057. "(generator)" : null,
  5058. "(arrow)" : null,
  5059. "(params)" : null
  5060. };
  5061. if (token) {
  5062. _.extend(funct, {
  5063. "(line)" : token.line,
  5064. "(character)": token.character,
  5065. "(metrics)" : createMetrics(token)
  5066. });
  5067. }
  5068. _.extend(funct, overwrites);
  5069. if (funct["(context)"]) {
  5070. funct["(scope)"] = funct["(context)"]["(scope)"];
  5071. funct["(comparray)"] = funct["(context)"]["(comparray)"];
  5072. }
  5073. return funct;
  5074. }
  5075. function isFunctor(token) {
  5076. return "(scope)" in token;
  5077. }
  5078. function hasParsedCode(funct) {
  5079. return funct["(global)"] && !funct["(verb)"];
  5080. }
  5081. function doTemplateLiteral(left) {
  5082. var ctx = this.context;
  5083. var noSubst = this.noSubst;
  5084. var depth = this.depth;
  5085. if (!noSubst) {
  5086. while (!end()) {
  5087. if (!state.tokens.next.template || state.tokens.next.depth > depth) {
  5088. expression(0); // should probably have different rbp?
  5089. } else {
  5090. advance();
  5091. }
  5092. }
  5093. }
  5094. return {
  5095. id: "(template)",
  5096. type: "(template)",
  5097. tag: left
  5098. };
  5099. function end() {
  5100. if (state.tokens.curr.template && state.tokens.curr.tail &&
  5101. state.tokens.curr.context === ctx) return true;
  5102. var complete = (state.tokens.next.template && state.tokens.next.tail &&
  5103. state.tokens.next.context === ctx);
  5104. if (complete) advance();
  5105. return complete || state.tokens.next.isUnclosed;
  5106. }
  5107. }
  5108. function doFunction(options) {
  5109. var f, token, name, statement, classExprBinding, isGenerator, isArrow, ignoreLoopFunc;
  5110. var oldOption = state.option;
  5111. var oldIgnored = state.ignored;
  5112. if (options) {
  5113. name = options.name;
  5114. statement = options.statement;
  5115. classExprBinding = options.classExprBinding;
  5116. isGenerator = options.type === "generator";
  5117. isArrow = options.type === "arrow";
  5118. ignoreLoopFunc = options.ignoreLoopFunc;
  5119. }
  5120. state.option = Object.create(state.option);
  5121. state.ignored = Object.create(state.ignored);
  5122. state.funct = functor(name || state.nameStack.infer(), state.tokens.next, {
  5123. "(statement)": statement,
  5124. "(context)": state.funct,
  5125. "(arrow)": isArrow,
  5126. "(generator)": isGenerator
  5127. });
  5128. f = state.funct;
  5129. token = state.tokens.curr;
  5130. token.funct = state.funct;
  5131. functions.push(state.funct);
  5132. state.funct["(scope)"].stack("functionouter");
  5133. var internallyAccessibleName = name || classExprBinding;
  5134. if (internallyAccessibleName) {
  5135. state.funct["(scope)"].block.add(internallyAccessibleName,
  5136. classExprBinding ? "class" : "function", state.tokens.curr, false);
  5137. }
  5138. state.funct["(scope)"].stack("functionparams");
  5139. var paramsInfo = functionparams(options);
  5140. if (paramsInfo) {
  5141. state.funct["(params)"] = paramsInfo.params;
  5142. state.funct["(metrics)"].arity = paramsInfo.arity;
  5143. state.funct["(metrics)"].verifyMaxParametersPerFunction();
  5144. } else {
  5145. state.funct["(metrics)"].arity = 0;
  5146. }
  5147. if (isArrow) {
  5148. if (!state.inES6(true)) {
  5149. warning("W119", state.tokens.curr, "arrow function syntax (=>)", "6");
  5150. }
  5151. if (!options.loneArg) {
  5152. advance("=>");
  5153. }
  5154. }
  5155. block(false, true, true, isArrow);
  5156. if (!state.option.noyield && isGenerator &&
  5157. state.funct["(generator)"] !== "yielded") {
  5158. warning("W124", state.tokens.curr);
  5159. }
  5160. state.funct["(metrics)"].verifyMaxStatementsPerFunction();
  5161. state.funct["(metrics)"].verifyMaxComplexityPerFunction();
  5162. state.funct["(unusedOption)"] = state.option.unused;
  5163. state.option = oldOption;
  5164. state.ignored = oldIgnored;
  5165. state.funct["(last)"] = state.tokens.curr.line;
  5166. state.funct["(lastcharacter)"] = state.tokens.curr.character;
  5167. state.funct["(scope)"].unstack(); // also does usage and label checks
  5168. state.funct["(scope)"].unstack();
  5169. state.funct = state.funct["(context)"];
  5170. if (!ignoreLoopFunc && !state.option.loopfunc && state.funct["(loopage)"]) {
  5171. if (f["(isCapturing)"]) {
  5172. warning("W083", token);
  5173. }
  5174. }
  5175. return f;
  5176. }
  5177. function createMetrics(functionStartToken) {
  5178. return {
  5179. statementCount: 0,
  5180. nestedBlockDepth: -1,
  5181. ComplexityCount: 1,
  5182. arity: 0,
  5183. verifyMaxStatementsPerFunction: function() {
  5184. if (state.option.maxstatements &&
  5185. this.statementCount > state.option.maxstatements) {
  5186. warning("W071", functionStartToken, this.statementCount);
  5187. }
  5188. },
  5189. verifyMaxParametersPerFunction: function() {
  5190. if (_.isNumber(state.option.maxparams) &&
  5191. this.arity > state.option.maxparams) {
  5192. warning("W072", functionStartToken, this.arity);
  5193. }
  5194. },
  5195. verifyMaxNestedBlockDepthPerFunction: function() {
  5196. if (state.option.maxdepth &&
  5197. this.nestedBlockDepth > 0 &&
  5198. this.nestedBlockDepth === state.option.maxdepth + 1) {
  5199. warning("W073", null, this.nestedBlockDepth);
  5200. }
  5201. },
  5202. verifyMaxComplexityPerFunction: function() {
  5203. var max = state.option.maxcomplexity;
  5204. var cc = this.ComplexityCount;
  5205. if (max && cc > max) {
  5206. warning("W074", functionStartToken, cc);
  5207. }
  5208. }
  5209. };
  5210. }
  5211. function increaseComplexityCount() {
  5212. state.funct["(metrics)"].ComplexityCount += 1;
  5213. }
  5214. function checkCondAssignment(expr) {
  5215. var id, paren;
  5216. if (expr) {
  5217. id = expr.id;
  5218. paren = expr.paren;
  5219. if (id === "," && (expr = expr.exprs[expr.exprs.length - 1])) {
  5220. id = expr.id;
  5221. paren = paren || expr.paren;
  5222. }
  5223. }
  5224. switch (id) {
  5225. case "=":
  5226. case "+=":
  5227. case "-=":
  5228. case "*=":
  5229. case "%=":
  5230. case "&=":
  5231. case "|=":
  5232. case "^=":
  5233. case "/=":
  5234. if (!paren && !state.option.boss) {
  5235. warning("W084");
  5236. }
  5237. }
  5238. }
  5239. function checkProperties(props) {
  5240. if (state.inES5()) {
  5241. for (var name in props) {
  5242. if (props[name] && props[name].setterToken && !props[name].getterToken) {
  5243. warning("W078", props[name].setterToken);
  5244. }
  5245. }
  5246. }
  5247. }
  5248. function metaProperty(name, c) {
  5249. if (checkPunctuator(state.tokens.next, ".")) {
  5250. var left = state.tokens.curr.id;
  5251. advance(".");
  5252. var id = identifier();
  5253. state.tokens.curr.isMetaProperty = true;
  5254. if (name !== id) {
  5255. error("E057", state.tokens.prev, left, id);
  5256. } else {
  5257. c();
  5258. }
  5259. return state.tokens.curr;
  5260. }
  5261. }
  5262. (function(x) {
  5263. x.nud = function() {
  5264. var b, f, i, p, t, isGeneratorMethod = false, nextVal;
  5265. var props = Object.create(null); // All properties, including accessors
  5266. b = state.tokens.curr.line !== startLine(state.tokens.next);
  5267. if (b) {
  5268. indent += state.option.indent;
  5269. if (state.tokens.next.from === indent + state.option.indent) {
  5270. indent += state.option.indent;
  5271. }
  5272. }
  5273. var blocktype = lookupBlockType();
  5274. if (blocktype.isDestAssign) {
  5275. this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
  5276. return this;
  5277. }
  5278. for (;;) {
  5279. if (state.tokens.next.id === "}") {
  5280. break;
  5281. }
  5282. nextVal = state.tokens.next.value;
  5283. if (state.tokens.next.identifier &&
  5284. (peekIgnoreEOL().id === "," || peekIgnoreEOL().id === "}")) {
  5285. if (!state.inES6()) {
  5286. warning("W104", state.tokens.next, "object short notation", "6");
  5287. }
  5288. i = propertyName(true);
  5289. saveProperty(props, i, state.tokens.next);
  5290. expression(10);
  5291. } else if (peek().id !== ":" && (nextVal === "get" || nextVal === "set")) {
  5292. advance(nextVal);
  5293. if (!state.inES5()) {
  5294. error("E034");
  5295. }
  5296. i = propertyName();
  5297. if (!i && !state.inES6()) {
  5298. error("E035");
  5299. }
  5300. if (i) {
  5301. saveAccessor(nextVal, props, i, state.tokens.curr);
  5302. }
  5303. t = state.tokens.next;
  5304. f = doFunction();
  5305. p = f["(params)"];
  5306. if (nextVal === "get" && i && p) {
  5307. warning("W076", t, p[0], i);
  5308. } else if (nextVal === "set" && i && (!p || p.length !== 1)) {
  5309. warning("W077", t, i);
  5310. }
  5311. } else {
  5312. if (state.tokens.next.value === "*" && state.tokens.next.type === "(punctuator)") {
  5313. if (!state.inES6()) {
  5314. warning("W104", state.tokens.next, "generator functions", "6");
  5315. }
  5316. advance("*");
  5317. isGeneratorMethod = true;
  5318. } else {
  5319. isGeneratorMethod = false;
  5320. }
  5321. if (state.tokens.next.id === "[") {
  5322. i = computedPropertyName();
  5323. state.nameStack.set(i);
  5324. } else {
  5325. state.nameStack.set(state.tokens.next);
  5326. i = propertyName();
  5327. saveProperty(props, i, state.tokens.next);
  5328. if (typeof i !== "string") {
  5329. break;
  5330. }
  5331. }
  5332. if (state.tokens.next.value === "(") {
  5333. if (!state.inES6()) {
  5334. warning("W104", state.tokens.curr, "concise methods", "6");
  5335. }
  5336. doFunction({ type: isGeneratorMethod ? "generator" : null });
  5337. } else {
  5338. advance(":");
  5339. expression(10);
  5340. }
  5341. }
  5342. countMember(i);
  5343. if (state.tokens.next.id === ",") {
  5344. comma({ allowTrailing: true, property: true });
  5345. if (state.tokens.next.id === ",") {
  5346. warning("W070", state.tokens.curr);
  5347. } else if (state.tokens.next.id === "}" && !state.inES5()) {
  5348. warning("W070", state.tokens.curr);
  5349. }
  5350. } else {
  5351. break;
  5352. }
  5353. }
  5354. if (b) {
  5355. indent -= state.option.indent;
  5356. }
  5357. advance("}", this);
  5358. checkProperties(props);
  5359. return this;
  5360. };
  5361. x.fud = function() {
  5362. error("E036", state.tokens.curr);
  5363. };
  5364. }(delim("{")));
  5365. function destructuringPattern(options) {
  5366. var isAssignment = options && options.assignment;
  5367. if (!state.inES6()) {
  5368. warning("W104", state.tokens.curr,
  5369. isAssignment ? "destructuring assignment" : "destructuring binding", "6");
  5370. }
  5371. return destructuringPatternRecursive(options);
  5372. }
  5373. function destructuringPatternRecursive(options) {
  5374. var ids;
  5375. var identifiers = [];
  5376. var openingParsed = options && options.openingParsed;
  5377. var isAssignment = options && options.assignment;
  5378. var recursiveOptions = isAssignment ? { assignment: isAssignment } : null;
  5379. var firstToken = openingParsed ? state.tokens.curr : state.tokens.next;
  5380. var nextInnerDE = function() {
  5381. var ident;
  5382. if (checkPunctuators(state.tokens.next, ["[", "{"])) {
  5383. ids = destructuringPatternRecursive(recursiveOptions);
  5384. for (var id in ids) {
  5385. id = ids[id];
  5386. identifiers.push({ id: id.id, token: id.token });
  5387. }
  5388. } else if (checkPunctuator(state.tokens.next, ",")) {
  5389. identifiers.push({ id: null, token: state.tokens.curr });
  5390. } else if (checkPunctuator(state.tokens.next, "(")) {
  5391. advance("(");
  5392. nextInnerDE();
  5393. advance(")");
  5394. } else {
  5395. var is_rest = checkPunctuator(state.tokens.next, "...");
  5396. if (isAssignment) {
  5397. var identifierToken = is_rest ? peek(0) : state.tokens.next;
  5398. if (!identifierToken.identifier) {
  5399. warning("E030", identifierToken, identifierToken.value);
  5400. }
  5401. var assignTarget = expression(155);
  5402. if (assignTarget) {
  5403. checkLeftSideAssign(assignTarget);
  5404. if (assignTarget.identifier) {
  5405. ident = assignTarget.value;
  5406. }
  5407. }
  5408. } else {
  5409. ident = identifier();
  5410. }
  5411. if (ident) {
  5412. identifiers.push({ id: ident, token: state.tokens.curr });
  5413. }
  5414. return is_rest;
  5415. }
  5416. return false;
  5417. };
  5418. var assignmentProperty = function() {
  5419. var id;
  5420. if (checkPunctuator(state.tokens.next, "[")) {
  5421. advance("[");
  5422. expression(10);
  5423. advance("]");
  5424. advance(":");
  5425. nextInnerDE();
  5426. } else if (state.tokens.next.id === "(string)" ||
  5427. state.tokens.next.id === "(number)") {
  5428. advance();
  5429. advance(":");
  5430. nextInnerDE();
  5431. } else {
  5432. id = identifier();
  5433. if (checkPunctuator(state.tokens.next, ":")) {
  5434. advance(":");
  5435. nextInnerDE();
  5436. } else if (id) {
  5437. if (isAssignment) {
  5438. checkLeftSideAssign(state.tokens.curr);
  5439. }
  5440. identifiers.push({ id: id, token: state.tokens.curr });
  5441. }
  5442. }
  5443. };
  5444. if (checkPunctuator(firstToken, "[")) {
  5445. if (!openingParsed) {
  5446. advance("[");
  5447. }
  5448. if (checkPunctuator(state.tokens.next, "]")) {
  5449. warning("W137", state.tokens.curr);
  5450. }
  5451. var element_after_rest = false;
  5452. while (!checkPunctuator(state.tokens.next, "]")) {
  5453. if (nextInnerDE() && !element_after_rest &&
  5454. checkPunctuator(state.tokens.next, ",")) {
  5455. warning("W130", state.tokens.next);
  5456. element_after_rest = true;
  5457. }
  5458. if (checkPunctuator(state.tokens.next, "=")) {
  5459. if (checkPunctuator(state.tokens.prev, "...")) {
  5460. advance("]");
  5461. } else {
  5462. advance("=");
  5463. }
  5464. if (state.tokens.next.id === "undefined") {
  5465. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5466. }
  5467. expression(10);
  5468. }
  5469. if (!checkPunctuator(state.tokens.next, "]")) {
  5470. advance(",");
  5471. }
  5472. }
  5473. advance("]");
  5474. } else if (checkPunctuator(firstToken, "{")) {
  5475. if (!openingParsed) {
  5476. advance("{");
  5477. }
  5478. if (checkPunctuator(state.tokens.next, "}")) {
  5479. warning("W137", state.tokens.curr);
  5480. }
  5481. while (!checkPunctuator(state.tokens.next, "}")) {
  5482. assignmentProperty();
  5483. if (checkPunctuator(state.tokens.next, "=")) {
  5484. advance("=");
  5485. if (state.tokens.next.id === "undefined") {
  5486. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5487. }
  5488. expression(10);
  5489. }
  5490. if (!checkPunctuator(state.tokens.next, "}")) {
  5491. advance(",");
  5492. if (checkPunctuator(state.tokens.next, "}")) {
  5493. break;
  5494. }
  5495. }
  5496. }
  5497. advance("}");
  5498. }
  5499. return identifiers;
  5500. }
  5501. function destructuringPatternMatch(tokens, value) {
  5502. var first = value.first;
  5503. if (!first)
  5504. return;
  5505. _.zip(tokens, Array.isArray(first) ? first : [ first ]).forEach(function(val) {
  5506. var token = val[0];
  5507. var value = val[1];
  5508. if (token && value)
  5509. token.first = value;
  5510. else if (token && token.first && !value)
  5511. warning("W080", token.first, token.first.value);
  5512. });
  5513. }
  5514. function blockVariableStatement(type, statement, context) {
  5515. var prefix = context && context.prefix;
  5516. var inexport = context && context.inexport;
  5517. var isLet = type === "let";
  5518. var isConst = type === "const";
  5519. var tokens, lone, value, letblock;
  5520. if (!state.inES6()) {
  5521. warning("W104", state.tokens.curr, type, "6");
  5522. }
  5523. if (isLet && state.tokens.next.value === "(") {
  5524. if (!state.inMoz()) {
  5525. warning("W118", state.tokens.next, "let block");
  5526. }
  5527. advance("(");
  5528. state.funct["(scope)"].stack();
  5529. letblock = true;
  5530. } else if (state.funct["(noblockscopedvar)"]) {
  5531. error("E048", state.tokens.curr, isConst ? "Const" : "Let");
  5532. }
  5533. statement.first = [];
  5534. for (;;) {
  5535. var names = [];
  5536. if (_.contains(["{", "["], state.tokens.next.value)) {
  5537. tokens = destructuringPattern();
  5538. lone = false;
  5539. } else {
  5540. tokens = [ { id: identifier(), token: state.tokens.curr } ];
  5541. lone = true;
  5542. }
  5543. if (!prefix && isConst && state.tokens.next.id !== "=") {
  5544. warning("E012", state.tokens.curr, state.tokens.curr.value);
  5545. }
  5546. for (var t in tokens) {
  5547. if (tokens.hasOwnProperty(t)) {
  5548. t = tokens[t];
  5549. if (state.funct["(scope)"].block.isGlobal()) {
  5550. if (predefined[t.id] === false) {
  5551. warning("W079", t.token, t.id);
  5552. }
  5553. }
  5554. if (t.id && !state.funct["(noblockscopedvar)"]) {
  5555. state.funct["(scope)"].addlabel(t.id, {
  5556. type: type,
  5557. token: t.token });
  5558. names.push(t.token);
  5559. if (lone && inexport) {
  5560. state.funct["(scope)"].setExported(t.token.value, t.token);
  5561. }
  5562. }
  5563. }
  5564. }
  5565. if (state.tokens.next.id === "=") {
  5566. advance("=");
  5567. if (!prefix && state.tokens.next.id === "undefined") {
  5568. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5569. }
  5570. if (!prefix && peek(0).id === "=" && state.tokens.next.identifier) {
  5571. warning("W120", state.tokens.next, state.tokens.next.value);
  5572. }
  5573. value = expression(prefix ? 120 : 10);
  5574. if (lone) {
  5575. tokens[0].first = value;
  5576. } else {
  5577. destructuringPatternMatch(names, value);
  5578. }
  5579. }
  5580. statement.first = statement.first.concat(names);
  5581. if (state.tokens.next.id !== ",") {
  5582. break;
  5583. }
  5584. comma();
  5585. }
  5586. if (letblock) {
  5587. advance(")");
  5588. block(true, true);
  5589. statement.block = true;
  5590. state.funct["(scope)"].unstack();
  5591. }
  5592. return statement;
  5593. }
  5594. var conststatement = stmt("const", function(context) {
  5595. return blockVariableStatement("const", this, context);
  5596. });
  5597. conststatement.exps = true;
  5598. var letstatement = stmt("let", function(context) {
  5599. return blockVariableStatement("let", this, context);
  5600. });
  5601. letstatement.exps = true;
  5602. var varstatement = stmt("var", function(context) {
  5603. var prefix = context && context.prefix;
  5604. var inexport = context && context.inexport;
  5605. var tokens, lone, value;
  5606. var implied = context && context.implied;
  5607. var report = !(context && context.ignore);
  5608. this.first = [];
  5609. for (;;) {
  5610. var names = [];
  5611. if (_.contains(["{", "["], state.tokens.next.value)) {
  5612. tokens = destructuringPattern();
  5613. lone = false;
  5614. } else {
  5615. tokens = [ { id: identifier(), token: state.tokens.curr } ];
  5616. lone = true;
  5617. }
  5618. if (!(prefix && implied) && report && state.option.varstmt) {
  5619. warning("W132", this);
  5620. }
  5621. this.first = this.first.concat(names);
  5622. for (var t in tokens) {
  5623. if (tokens.hasOwnProperty(t)) {
  5624. t = tokens[t];
  5625. if (!implied && state.funct["(global)"]) {
  5626. if (predefined[t.id] === false) {
  5627. warning("W079", t.token, t.id);
  5628. } else if (state.option.futurehostile === false) {
  5629. if ((!state.inES5() && vars.ecmaIdentifiers[5][t.id] === false) ||
  5630. (!state.inES6() && vars.ecmaIdentifiers[6][t.id] === false)) {
  5631. warning("W129", t.token, t.id);
  5632. }
  5633. }
  5634. }
  5635. if (t.id) {
  5636. if (implied === "for") {
  5637. if (!state.funct["(scope)"].has(t.id)) {
  5638. if (report) warning("W088", t.token, t.id);
  5639. }
  5640. state.funct["(scope)"].block.use(t.id, t.token);
  5641. } else {
  5642. state.funct["(scope)"].addlabel(t.id, {
  5643. type: "var",
  5644. token: t.token });
  5645. if (lone && inexport) {
  5646. state.funct["(scope)"].setExported(t.id, t.token);
  5647. }
  5648. }
  5649. names.push(t.token);
  5650. }
  5651. }
  5652. }
  5653. if (state.tokens.next.id === "=") {
  5654. state.nameStack.set(state.tokens.curr);
  5655. advance("=");
  5656. if (!prefix && report && !state.funct["(loopage)"] &&
  5657. state.tokens.next.id === "undefined") {
  5658. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5659. }
  5660. if (peek(0).id === "=" && state.tokens.next.identifier) {
  5661. if (!prefix && report &&
  5662. !state.funct["(params)"] ||
  5663. state.funct["(params)"].indexOf(state.tokens.next.value) === -1) {
  5664. warning("W120", state.tokens.next, state.tokens.next.value);
  5665. }
  5666. }
  5667. value = expression(prefix ? 120 : 10);
  5668. if (lone) {
  5669. tokens[0].first = value;
  5670. } else {
  5671. destructuringPatternMatch(names, value);
  5672. }
  5673. }
  5674. if (state.tokens.next.id !== ",") {
  5675. break;
  5676. }
  5677. comma();
  5678. }
  5679. return this;
  5680. });
  5681. varstatement.exps = true;
  5682. blockstmt("class", function() {
  5683. return classdef.call(this, true);
  5684. });
  5685. function classdef(isStatement) {
  5686. if (!state.inES6()) {
  5687. warning("W104", state.tokens.curr, "class", "6");
  5688. }
  5689. if (isStatement) {
  5690. this.name = identifier();
  5691. state.funct["(scope)"].addlabel(this.name, {
  5692. type: "class",
  5693. token: state.tokens.curr });
  5694. } else if (state.tokens.next.identifier && state.tokens.next.value !== "extends") {
  5695. this.name = identifier();
  5696. this.namedExpr = true;
  5697. } else {
  5698. this.name = state.nameStack.infer();
  5699. }
  5700. classtail(this);
  5701. return this;
  5702. }
  5703. function classtail(c) {
  5704. var wasInClassBody = state.inClassBody;
  5705. if (state.tokens.next.value === "extends") {
  5706. advance("extends");
  5707. c.heritage = expression(10);
  5708. }
  5709. state.inClassBody = true;
  5710. advance("{");
  5711. c.body = classbody(c);
  5712. advance("}");
  5713. state.inClassBody = wasInClassBody;
  5714. }
  5715. function classbody(c) {
  5716. var name;
  5717. var isStatic;
  5718. var isGenerator;
  5719. var getset;
  5720. var props = Object.create(null);
  5721. var staticProps = Object.create(null);
  5722. var computed;
  5723. for (var i = 0; state.tokens.next.id !== "}"; ++i) {
  5724. name = state.tokens.next;
  5725. isStatic = false;
  5726. isGenerator = false;
  5727. getset = null;
  5728. if (name.id === ";") {
  5729. warning("W032");
  5730. advance(";");
  5731. continue;
  5732. }
  5733. if (name.id === "*") {
  5734. isGenerator = true;
  5735. advance("*");
  5736. name = state.tokens.next;
  5737. }
  5738. if (name.id === "[") {
  5739. name = computedPropertyName();
  5740. computed = true;
  5741. } else if (isPropertyName(name)) {
  5742. advance();
  5743. computed = false;
  5744. if (name.identifier && name.value === "static") {
  5745. if (checkPunctuator(state.tokens.next, "*")) {
  5746. isGenerator = true;
  5747. advance("*");
  5748. }
  5749. if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
  5750. computed = state.tokens.next.id === "[";
  5751. isStatic = true;
  5752. name = state.tokens.next;
  5753. if (state.tokens.next.id === "[") {
  5754. name = computedPropertyName();
  5755. } else advance();
  5756. }
  5757. }
  5758. if (name.identifier && (name.value === "get" || name.value === "set")) {
  5759. if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
  5760. computed = state.tokens.next.id === "[";
  5761. getset = name;
  5762. name = state.tokens.next;
  5763. if (state.tokens.next.id === "[") {
  5764. name = computedPropertyName();
  5765. } else advance();
  5766. }
  5767. }
  5768. } else {
  5769. warning("W052", state.tokens.next, state.tokens.next.value || state.tokens.next.type);
  5770. advance();
  5771. continue;
  5772. }
  5773. if (!checkPunctuator(state.tokens.next, "(")) {
  5774. error("E054", state.tokens.next, state.tokens.next.value);
  5775. while (state.tokens.next.id !== "}" &&
  5776. !checkPunctuator(state.tokens.next, "(")) {
  5777. advance();
  5778. }
  5779. if (state.tokens.next.value !== "(") {
  5780. doFunction({ statement: c });
  5781. }
  5782. }
  5783. if (!computed) {
  5784. if (getset) {
  5785. saveAccessor(
  5786. getset.value, isStatic ? staticProps : props, name.value, name, true, isStatic);
  5787. } else {
  5788. if (name.value === "constructor") {
  5789. state.nameStack.set(c);
  5790. } else {
  5791. state.nameStack.set(name);
  5792. }
  5793. saveProperty(isStatic ? staticProps : props, name.value, name, true, isStatic);
  5794. }
  5795. }
  5796. if (getset && name.value === "constructor") {
  5797. var propDesc = getset.value === "get" ? "class getter method" : "class setter method";
  5798. error("E049", name, propDesc, "constructor");
  5799. } else if (name.value === "prototype") {
  5800. error("E049", name, "class method", "prototype");
  5801. }
  5802. propertyName(name);
  5803. doFunction({
  5804. statement: c,
  5805. type: isGenerator ? "generator" : null,
  5806. classExprBinding: c.namedExpr ? c.name : null
  5807. });
  5808. }
  5809. checkProperties(props);
  5810. }
  5811. blockstmt("function", function(context) {
  5812. var inexport = context && context.inexport;
  5813. var generator = false;
  5814. if (state.tokens.next.value === "*") {
  5815. advance("*");
  5816. if (state.inES6({ strict: true })) {
  5817. generator = true;
  5818. } else {
  5819. warning("W119", state.tokens.curr, "function*", "6");
  5820. }
  5821. }
  5822. if (inblock) {
  5823. warning("W082", state.tokens.curr);
  5824. }
  5825. var i = optionalidentifier();
  5826. state.funct["(scope)"].addlabel(i, {
  5827. type: "function",
  5828. token: state.tokens.curr });
  5829. if (i === undefined) {
  5830. warning("W025");
  5831. } else if (inexport) {
  5832. state.funct["(scope)"].setExported(i, state.tokens.prev);
  5833. }
  5834. doFunction({
  5835. name: i,
  5836. statement: this,
  5837. type: generator ? "generator" : null,
  5838. ignoreLoopFunc: inblock // a declaration may already have warned
  5839. });
  5840. if (state.tokens.next.id === "(" && state.tokens.next.line === state.tokens.curr.line) {
  5841. error("E039");
  5842. }
  5843. return this;
  5844. });
  5845. prefix("function", function() {
  5846. var generator = false;
  5847. if (state.tokens.next.value === "*") {
  5848. if (!state.inES6()) {
  5849. warning("W119", state.tokens.curr, "function*", "6");
  5850. }
  5851. advance("*");
  5852. generator = true;
  5853. }
  5854. var i = optionalidentifier();
  5855. doFunction({ name: i, type: generator ? "generator" : null });
  5856. return this;
  5857. });
  5858. blockstmt("if", function() {
  5859. var t = state.tokens.next;
  5860. increaseComplexityCount();
  5861. state.condition = true;
  5862. advance("(");
  5863. var expr = expression(0);
  5864. checkCondAssignment(expr);
  5865. var forinifcheck = null;
  5866. if (state.option.forin && state.forinifcheckneeded) {
  5867. state.forinifcheckneeded = false; // We only need to analyze the first if inside the loop
  5868. forinifcheck = state.forinifchecks[state.forinifchecks.length - 1];
  5869. if (expr.type === "(punctuator)" && expr.value === "!") {
  5870. forinifcheck.type = "(negative)";
  5871. } else {
  5872. forinifcheck.type = "(positive)";
  5873. }
  5874. }
  5875. advance(")", t);
  5876. state.condition = false;
  5877. var s = block(true, true);
  5878. if (forinifcheck && forinifcheck.type === "(negative)") {
  5879. if (s && s[0] && s[0].type === "(identifier)" && s[0].value === "continue") {
  5880. forinifcheck.type = "(negative-with-continue)";
  5881. }
  5882. }
  5883. if (state.tokens.next.id === "else") {
  5884. advance("else");
  5885. if (state.tokens.next.id === "if" || state.tokens.next.id === "switch") {
  5886. statement();
  5887. } else {
  5888. block(true, true);
  5889. }
  5890. }
  5891. return this;
  5892. });
  5893. blockstmt("try", function() {
  5894. var b;
  5895. function doCatch() {
  5896. advance("catch");
  5897. advance("(");
  5898. state.funct["(scope)"].stack("catchparams");
  5899. if (checkPunctuators(state.tokens.next, ["[", "{"])) {
  5900. var tokens = destructuringPattern();
  5901. _.each(tokens, function(token) {
  5902. if (token.id) {
  5903. state.funct["(scope)"].addParam(token.id, token, "exception");
  5904. }
  5905. });
  5906. } else if (state.tokens.next.type !== "(identifier)") {
  5907. warning("E030", state.tokens.next, state.tokens.next.value);
  5908. } else {
  5909. state.funct["(scope)"].addParam(identifier(), state.tokens.curr, "exception");
  5910. }
  5911. if (state.tokens.next.value === "if") {
  5912. if (!state.inMoz()) {
  5913. warning("W118", state.tokens.curr, "catch filter");
  5914. }
  5915. advance("if");
  5916. expression(0);
  5917. }
  5918. advance(")");
  5919. block(false);
  5920. state.funct["(scope)"].unstack();
  5921. }
  5922. block(true);
  5923. while (state.tokens.next.id === "catch") {
  5924. increaseComplexityCount();
  5925. if (b && (!state.inMoz())) {
  5926. warning("W118", state.tokens.next, "multiple catch blocks");
  5927. }
  5928. doCatch();
  5929. b = true;
  5930. }
  5931. if (state.tokens.next.id === "finally") {
  5932. advance("finally");
  5933. block(true);
  5934. return;
  5935. }
  5936. if (!b) {
  5937. error("E021", state.tokens.next, "catch", state.tokens.next.value);
  5938. }
  5939. return this;
  5940. });
  5941. blockstmt("while", function() {
  5942. var t = state.tokens.next;
  5943. state.funct["(breakage)"] += 1;
  5944. state.funct["(loopage)"] += 1;
  5945. increaseComplexityCount();
  5946. advance("(");
  5947. checkCondAssignment(expression(0));
  5948. advance(")", t);
  5949. block(true, true);
  5950. state.funct["(breakage)"] -= 1;
  5951. state.funct["(loopage)"] -= 1;
  5952. return this;
  5953. }).labelled = true;
  5954. blockstmt("with", function() {
  5955. var t = state.tokens.next;
  5956. if (state.isStrict()) {
  5957. error("E010", state.tokens.curr);
  5958. } else if (!state.option.withstmt) {
  5959. warning("W085", state.tokens.curr);
  5960. }
  5961. advance("(");
  5962. expression(0);
  5963. advance(")", t);
  5964. block(true, true);
  5965. return this;
  5966. });
  5967. blockstmt("switch", function() {
  5968. var t = state.tokens.next;
  5969. var g = false;
  5970. var noindent = false;
  5971. state.funct["(breakage)"] += 1;
  5972. advance("(");
  5973. checkCondAssignment(expression(0));
  5974. advance(")", t);
  5975. t = state.tokens.next;
  5976. advance("{");
  5977. if (state.tokens.next.from === indent)
  5978. noindent = true;
  5979. if (!noindent)
  5980. indent += state.option.indent;
  5981. this.cases = [];
  5982. for (;;) {
  5983. switch (state.tokens.next.id) {
  5984. case "case":
  5985. switch (state.funct["(verb)"]) {
  5986. case "yield":
  5987. case "break":
  5988. case "case":
  5989. case "continue":
  5990. case "return":
  5991. case "switch":
  5992. case "throw":
  5993. break;
  5994. default:
  5995. if (!state.tokens.curr.caseFallsThrough) {
  5996. warning("W086", state.tokens.curr, "case");
  5997. }
  5998. }
  5999. advance("case");
  6000. this.cases.push(expression(0));
  6001. increaseComplexityCount();
  6002. g = true;
  6003. advance(":");
  6004. state.funct["(verb)"] = "case";
  6005. break;
  6006. case "default":
  6007. switch (state.funct["(verb)"]) {
  6008. case "yield":
  6009. case "break":
  6010. case "continue":
  6011. case "return":
  6012. case "throw":
  6013. break;
  6014. default:
  6015. if (this.cases.length) {
  6016. if (!state.tokens.curr.caseFallsThrough) {
  6017. warning("W086", state.tokens.curr, "default");
  6018. }
  6019. }
  6020. }
  6021. advance("default");
  6022. g = true;
  6023. advance(":");
  6024. break;
  6025. case "}":
  6026. if (!noindent)
  6027. indent -= state.option.indent;
  6028. advance("}", t);
  6029. state.funct["(breakage)"] -= 1;
  6030. state.funct["(verb)"] = undefined;
  6031. return;
  6032. case "(end)":
  6033. error("E023", state.tokens.next, "}");
  6034. return;
  6035. default:
  6036. indent += state.option.indent;
  6037. if (g) {
  6038. switch (state.tokens.curr.id) {
  6039. case ",":
  6040. error("E040");
  6041. return;
  6042. case ":":
  6043. g = false;
  6044. statements();
  6045. break;
  6046. default:
  6047. error("E025", state.tokens.curr);
  6048. return;
  6049. }
  6050. } else {
  6051. if (state.tokens.curr.id === ":") {
  6052. advance(":");
  6053. error("E024", state.tokens.curr, ":");
  6054. statements();
  6055. } else {
  6056. error("E021", state.tokens.next, "case", state.tokens.next.value);
  6057. return;
  6058. }
  6059. }
  6060. indent -= state.option.indent;
  6061. }
  6062. }
  6063. return this;
  6064. }).labelled = true;
  6065. stmt("debugger", function() {
  6066. if (!state.option.debug) {
  6067. warning("W087", this);
  6068. }
  6069. return this;
  6070. }).exps = true;
  6071. (function() {
  6072. var x = stmt("do", function() {
  6073. state.funct["(breakage)"] += 1;
  6074. state.funct["(loopage)"] += 1;
  6075. increaseComplexityCount();
  6076. this.first = block(true, true);
  6077. advance("while");
  6078. var t = state.tokens.next;
  6079. advance("(");
  6080. checkCondAssignment(expression(0));
  6081. advance(")", t);
  6082. state.funct["(breakage)"] -= 1;
  6083. state.funct["(loopage)"] -= 1;
  6084. return this;
  6085. });
  6086. x.labelled = true;
  6087. x.exps = true;
  6088. }());
  6089. blockstmt("for", function() {
  6090. var s, t = state.tokens.next;
  6091. var letscope = false;
  6092. var foreachtok = null;
  6093. if (t.value === "each") {
  6094. foreachtok = t;
  6095. advance("each");
  6096. if (!state.inMoz()) {
  6097. warning("W118", state.tokens.curr, "for each");
  6098. }
  6099. }
  6100. increaseComplexityCount();
  6101. advance("(");
  6102. var nextop; // contains the token of the "in" or "of" operator
  6103. var i = 0;
  6104. var inof = ["in", "of"];
  6105. var level = 0; // BindingPattern "level" --- level 0 === no BindingPattern
  6106. var comma; // First comma punctuator at level 0
  6107. var initializer; // First initializer at level 0
  6108. if (checkPunctuators(state.tokens.next, ["{", "["])) ++level;
  6109. do {
  6110. nextop = peek(i);
  6111. ++i;
  6112. if (checkPunctuators(nextop, ["{", "["])) ++level;
  6113. else if (checkPunctuators(nextop, ["}", "]"])) --level;
  6114. if (level < 0) break;
  6115. if (level === 0) {
  6116. if (!comma && checkPunctuator(nextop, ",")) comma = nextop;
  6117. else if (!initializer && checkPunctuator(nextop, "=")) initializer = nextop;
  6118. }
  6119. } while (level > 0 || !_.contains(inof, nextop.value) && nextop.value !== ";" &&
  6120. nextop.type !== "(end)"); // Is this a JSCS bug? This looks really weird.
  6121. if (_.contains(inof, nextop.value)) {
  6122. if (!state.inES6() && nextop.value === "of") {
  6123. warning("W104", nextop, "for of", "6");
  6124. }
  6125. var ok = !(initializer || comma);
  6126. if (initializer) {
  6127. error("W133", comma, nextop.value, "initializer is forbidden");
  6128. }
  6129. if (comma) {
  6130. error("W133", comma, nextop.value, "more than one ForBinding");
  6131. }
  6132. if (state.tokens.next.id === "var") {
  6133. advance("var");
  6134. state.tokens.curr.fud({ prefix: true });
  6135. } else if (state.tokens.next.id === "let" || state.tokens.next.id === "const") {
  6136. advance(state.tokens.next.id);
  6137. letscope = true;
  6138. state.funct["(scope)"].stack();
  6139. state.tokens.curr.fud({ prefix: true });
  6140. } else {
  6141. Object.create(varstatement).fud({ prefix: true, implied: "for", ignore: !ok });
  6142. }
  6143. advance(nextop.value);
  6144. expression(20);
  6145. advance(")", t);
  6146. if (nextop.value === "in" && state.option.forin) {
  6147. state.forinifcheckneeded = true;
  6148. if (state.forinifchecks === undefined) {
  6149. state.forinifchecks = [];
  6150. }
  6151. state.forinifchecks.push({
  6152. type: "(none)"
  6153. });
  6154. }
  6155. state.funct["(breakage)"] += 1;
  6156. state.funct["(loopage)"] += 1;
  6157. s = block(true, true);
  6158. if (nextop.value === "in" && state.option.forin) {
  6159. if (state.forinifchecks && state.forinifchecks.length > 0) {
  6160. var check = state.forinifchecks.pop();
  6161. if (// No if statement or not the first statement in loop body
  6162. s && s.length > 0 && (typeof s[0] !== "object" || s[0].value !== "if") ||
  6163. check.type === "(positive)" && s.length > 1 ||
  6164. check.type === "(negative)") {
  6165. warning("W089", this);
  6166. }
  6167. }
  6168. state.forinifcheckneeded = false;
  6169. }
  6170. state.funct["(breakage)"] -= 1;
  6171. state.funct["(loopage)"] -= 1;
  6172. } else {
  6173. if (foreachtok) {
  6174. error("E045", foreachtok);
  6175. }
  6176. if (state.tokens.next.id !== ";") {
  6177. if (state.tokens.next.id === "var") {
  6178. advance("var");
  6179. state.tokens.curr.fud();
  6180. } else if (state.tokens.next.id === "let") {
  6181. advance("let");
  6182. letscope = true;
  6183. state.funct["(scope)"].stack();
  6184. state.tokens.curr.fud();
  6185. } else {
  6186. for (;;) {
  6187. expression(0, "for");
  6188. if (state.tokens.next.id !== ",") {
  6189. break;
  6190. }
  6191. comma();
  6192. }
  6193. }
  6194. }
  6195. nolinebreak(state.tokens.curr);
  6196. advance(";");
  6197. state.funct["(loopage)"] += 1;
  6198. if (state.tokens.next.id !== ";") {
  6199. checkCondAssignment(expression(0));
  6200. }
  6201. nolinebreak(state.tokens.curr);
  6202. advance(";");
  6203. if (state.tokens.next.id === ";") {
  6204. error("E021", state.tokens.next, ")", ";");
  6205. }
  6206. if (state.tokens.next.id !== ")") {
  6207. for (;;) {
  6208. expression(0, "for");
  6209. if (state.tokens.next.id !== ",") {
  6210. break;
  6211. }
  6212. comma();
  6213. }
  6214. }
  6215. advance(")", t);
  6216. state.funct["(breakage)"] += 1;
  6217. block(true, true);
  6218. state.funct["(breakage)"] -= 1;
  6219. state.funct["(loopage)"] -= 1;
  6220. }
  6221. if (letscope) {
  6222. state.funct["(scope)"].unstack();
  6223. }
  6224. return this;
  6225. }).labelled = true;
  6226. stmt("break", function() {
  6227. var v = state.tokens.next.value;
  6228. if (!state.option.asi)
  6229. nolinebreak(this);
  6230. if (state.tokens.next.id !== ";" && !state.tokens.next.reach &&
  6231. state.tokens.curr.line === startLine(state.tokens.next)) {
  6232. if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
  6233. warning("W090", state.tokens.next, v);
  6234. }
  6235. this.first = state.tokens.next;
  6236. advance();
  6237. } else {
  6238. if (state.funct["(breakage)"] === 0)
  6239. warning("W052", state.tokens.next, this.value);
  6240. }
  6241. reachable(this);
  6242. return this;
  6243. }).exps = true;
  6244. stmt("continue", function() {
  6245. var v = state.tokens.next.value;
  6246. if (state.funct["(breakage)"] === 0)
  6247. warning("W052", state.tokens.next, this.value);
  6248. if (!state.funct["(loopage)"])
  6249. warning("W052", state.tokens.next, this.value);
  6250. if (!state.option.asi)
  6251. nolinebreak(this);
  6252. if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
  6253. if (state.tokens.curr.line === startLine(state.tokens.next)) {
  6254. if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
  6255. warning("W090", state.tokens.next, v);
  6256. }
  6257. this.first = state.tokens.next;
  6258. advance();
  6259. }
  6260. }
  6261. reachable(this);
  6262. return this;
  6263. }).exps = true;
  6264. stmt("return", function() {
  6265. if (this.line === startLine(state.tokens.next)) {
  6266. if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
  6267. this.first = expression(0);
  6268. if (this.first &&
  6269. this.first.type === "(punctuator)" && this.first.value === "=" &&
  6270. !this.first.paren && !state.option.boss) {
  6271. warningAt("W093", this.first.line, this.first.character);
  6272. }
  6273. }
  6274. } else {
  6275. if (state.tokens.next.type === "(punctuator)" &&
  6276. ["[", "{", "+", "-"].indexOf(state.tokens.next.value) > -1) {
  6277. nolinebreak(this); // always warn (Line breaking error)
  6278. }
  6279. }
  6280. reachable(this);
  6281. return this;
  6282. }).exps = true;
  6283. (function(x) {
  6284. x.exps = true;
  6285. x.lbp = 25;
  6286. }(prefix("yield", function() {
  6287. var prev = state.tokens.prev;
  6288. if (state.inES6(true) && !state.funct["(generator)"]) {
  6289. if (!("(catch)" === state.funct["(name)"] && state.funct["(context)"]["(generator)"])) {
  6290. error("E046", state.tokens.curr, "yield");
  6291. }
  6292. } else if (!state.inES6()) {
  6293. warning("W104", state.tokens.curr, "yield", "6");
  6294. }
  6295. state.funct["(generator)"] = "yielded";
  6296. var delegatingYield = false;
  6297. if (state.tokens.next.value === "*") {
  6298. delegatingYield = true;
  6299. advance("*");
  6300. }
  6301. if (this.line === startLine(state.tokens.next) || !state.inMoz()) {
  6302. if (delegatingYield ||
  6303. (state.tokens.next.id !== ";" && !state.option.asi &&
  6304. !state.tokens.next.reach && state.tokens.next.nud)) {
  6305. nobreaknonadjacent(state.tokens.curr, state.tokens.next);
  6306. this.first = expression(10);
  6307. if (this.first.type === "(punctuator)" && this.first.value === "=" &&
  6308. !this.first.paren && !state.option.boss) {
  6309. warningAt("W093", this.first.line, this.first.character);
  6310. }
  6311. }
  6312. if (state.inMoz() && state.tokens.next.id !== ")" &&
  6313. (prev.lbp > 30 || (!prev.assign && !isEndOfExpr()) || prev.id === "yield")) {
  6314. error("E050", this);
  6315. }
  6316. } else if (!state.option.asi) {
  6317. nolinebreak(this); // always warn (Line breaking error)
  6318. }
  6319. return this;
  6320. })));
  6321. stmt("throw", function() {
  6322. nolinebreak(this);
  6323. this.first = expression(20);
  6324. reachable(this);
  6325. return this;
  6326. }).exps = true;
  6327. stmt("import", function() {
  6328. if (!state.inES6()) {
  6329. warning("W119", state.tokens.curr, "import", "6");
  6330. }
  6331. if (state.tokens.next.type === "(string)") {
  6332. advance("(string)");
  6333. return this;
  6334. }
  6335. if (state.tokens.next.identifier) {
  6336. this.name = identifier();
  6337. state.funct["(scope)"].addlabel(this.name, {
  6338. type: "const",
  6339. token: state.tokens.curr });
  6340. if (state.tokens.next.value === ",") {
  6341. advance(",");
  6342. } else {
  6343. advance("from");
  6344. advance("(string)");
  6345. return this;
  6346. }
  6347. }
  6348. if (state.tokens.next.id === "*") {
  6349. advance("*");
  6350. advance("as");
  6351. if (state.tokens.next.identifier) {
  6352. this.name = identifier();
  6353. state.funct["(scope)"].addlabel(this.name, {
  6354. type: "const",
  6355. token: state.tokens.curr });
  6356. }
  6357. } else {
  6358. advance("{");
  6359. for (;;) {
  6360. if (state.tokens.next.value === "}") {
  6361. advance("}");
  6362. break;
  6363. }
  6364. var importName;
  6365. if (state.tokens.next.type === "default") {
  6366. importName = "default";
  6367. advance("default");
  6368. } else {
  6369. importName = identifier();
  6370. }
  6371. if (state.tokens.next.value === "as") {
  6372. advance("as");
  6373. importName = identifier();
  6374. }
  6375. state.funct["(scope)"].addlabel(importName, {
  6376. type: "const",
  6377. token: state.tokens.curr });
  6378. if (state.tokens.next.value === ",") {
  6379. advance(",");
  6380. } else if (state.tokens.next.value === "}") {
  6381. advance("}");
  6382. break;
  6383. } else {
  6384. error("E024", state.tokens.next, state.tokens.next.value);
  6385. break;
  6386. }
  6387. }
  6388. }
  6389. advance("from");
  6390. advance("(string)");
  6391. return this;
  6392. }).exps = true;
  6393. stmt("export", function() {
  6394. var ok = true;
  6395. var token;
  6396. var identifier;
  6397. if (!state.inES6()) {
  6398. warning("W119", state.tokens.curr, "export", "6");
  6399. ok = false;
  6400. }
  6401. if (!state.funct["(scope)"].block.isGlobal()) {
  6402. error("E053", state.tokens.curr);
  6403. ok = false;
  6404. }
  6405. if (state.tokens.next.value === "*") {
  6406. advance("*");
  6407. advance("from");
  6408. advance("(string)");
  6409. return this;
  6410. }
  6411. if (state.tokens.next.type === "default") {
  6412. state.nameStack.set(state.tokens.next);
  6413. advance("default");
  6414. var exportType = state.tokens.next.id;
  6415. if (exportType === "function" || exportType === "class") {
  6416. this.block = true;
  6417. }
  6418. token = peek();
  6419. expression(10);
  6420. identifier = token.value;
  6421. if (this.block) {
  6422. state.funct["(scope)"].addlabel(identifier, {
  6423. type: exportType,
  6424. token: token });
  6425. state.funct["(scope)"].setExported(identifier, token);
  6426. }
  6427. return this;
  6428. }
  6429. if (state.tokens.next.value === "{") {
  6430. advance("{");
  6431. var exportedTokens = [];
  6432. for (;;) {
  6433. if (!state.tokens.next.identifier) {
  6434. error("E030", state.tokens.next, state.tokens.next.value);
  6435. }
  6436. advance();
  6437. exportedTokens.push(state.tokens.curr);
  6438. if (state.tokens.next.value === "as") {
  6439. advance("as");
  6440. if (!state.tokens.next.identifier) {
  6441. error("E030", state.tokens.next, state.tokens.next.value);
  6442. }
  6443. advance();
  6444. }
  6445. if (state.tokens.next.value === ",") {
  6446. advance(",");
  6447. } else if (state.tokens.next.value === "}") {
  6448. advance("}");
  6449. break;
  6450. } else {
  6451. error("E024", state.tokens.next, state.tokens.next.value);
  6452. break;
  6453. }
  6454. }
  6455. if (state.tokens.next.value === "from") {
  6456. advance("from");
  6457. advance("(string)");
  6458. } else if (ok) {
  6459. exportedTokens.forEach(function(token) {
  6460. state.funct["(scope)"].setExported(token.value, token);
  6461. });
  6462. }
  6463. return this;
  6464. }
  6465. if (state.tokens.next.id === "var") {
  6466. advance("var");
  6467. state.tokens.curr.fud({ inexport:true });
  6468. } else if (state.tokens.next.id === "let") {
  6469. advance("let");
  6470. state.tokens.curr.fud({ inexport:true });
  6471. } else if (state.tokens.next.id === "const") {
  6472. advance("const");
  6473. state.tokens.curr.fud({ inexport:true });
  6474. } else if (state.tokens.next.id === "function") {
  6475. this.block = true;
  6476. advance("function");
  6477. state.syntax["function"].fud({ inexport:true });
  6478. } else if (state.tokens.next.id === "class") {
  6479. this.block = true;
  6480. advance("class");
  6481. var classNameToken = state.tokens.next;
  6482. state.syntax["class"].fud();
  6483. state.funct["(scope)"].setExported(classNameToken.value, classNameToken);
  6484. } else {
  6485. error("E024", state.tokens.next, state.tokens.next.value);
  6486. }
  6487. return this;
  6488. }).exps = true;
  6489. FutureReservedWord("abstract");
  6490. FutureReservedWord("boolean");
  6491. FutureReservedWord("byte");
  6492. FutureReservedWord("char");
  6493. FutureReservedWord("class", { es5: true, nud: classdef });
  6494. FutureReservedWord("double");
  6495. FutureReservedWord("enum", { es5: true });
  6496. FutureReservedWord("export", { es5: true });
  6497. FutureReservedWord("extends", { es5: true });
  6498. FutureReservedWord("final");
  6499. FutureReservedWord("float");
  6500. FutureReservedWord("goto");
  6501. FutureReservedWord("implements", { es5: true, strictOnly: true });
  6502. FutureReservedWord("import", { es5: true });
  6503. FutureReservedWord("int");
  6504. FutureReservedWord("interface", { es5: true, strictOnly: true });
  6505. FutureReservedWord("long");
  6506. FutureReservedWord("native");
  6507. FutureReservedWord("package", { es5: true, strictOnly: true });
  6508. FutureReservedWord("private", { es5: true, strictOnly: true });
  6509. FutureReservedWord("protected", { es5: true, strictOnly: true });
  6510. FutureReservedWord("public", { es5: true, strictOnly: true });
  6511. FutureReservedWord("short");
  6512. FutureReservedWord("static", { es5: true, strictOnly: true });
  6513. FutureReservedWord("super", { es5: true });
  6514. FutureReservedWord("synchronized");
  6515. FutureReservedWord("transient");
  6516. FutureReservedWord("volatile");
  6517. var lookupBlockType = function() {
  6518. var pn, pn1, prev;
  6519. var i = -1;
  6520. var bracketStack = 0;
  6521. var ret = {};
  6522. if (checkPunctuators(state.tokens.curr, ["[", "{"])) {
  6523. bracketStack += 1;
  6524. }
  6525. do {
  6526. prev = i === -1 ? state.tokens.curr : pn;
  6527. pn = i === -1 ? state.tokens.next : peek(i);
  6528. pn1 = peek(i + 1);
  6529. i = i + 1;
  6530. if (checkPunctuators(pn, ["[", "{"])) {
  6531. bracketStack += 1;
  6532. } else if (checkPunctuators(pn, ["]", "}"])) {
  6533. bracketStack -= 1;
  6534. }
  6535. if (bracketStack === 1 && pn.identifier && pn.value === "for" &&
  6536. !checkPunctuator(prev, ".")) {
  6537. ret.isCompArray = true;
  6538. ret.notJson = true;
  6539. break;
  6540. }
  6541. if (bracketStack === 0 && checkPunctuators(pn, ["}", "]"])) {
  6542. if (pn1.value === "=") {
  6543. ret.isDestAssign = true;
  6544. ret.notJson = true;
  6545. break;
  6546. } else if (pn1.value === ".") {
  6547. ret.notJson = true;
  6548. break;
  6549. }
  6550. }
  6551. if (checkPunctuator(pn, ";")) {
  6552. ret.isBlock = true;
  6553. ret.notJson = true;
  6554. }
  6555. } while (bracketStack > 0 && pn.id !== "(end)");
  6556. return ret;
  6557. };
  6558. function saveProperty(props, name, tkn, isClass, isStatic) {
  6559. var msg = ["key", "class method", "static class method"];
  6560. msg = msg[(isClass || false) + (isStatic || false)];
  6561. if (tkn.identifier) {
  6562. name = tkn.value;
  6563. }
  6564. if (props[name] && name !== "__proto__") {
  6565. warning("W075", state.tokens.next, msg, name);
  6566. } else {
  6567. props[name] = Object.create(null);
  6568. }
  6569. props[name].basic = true;
  6570. props[name].basictkn = tkn;
  6571. }
  6572. function saveAccessor(accessorType, props, name, tkn, isClass, isStatic) {
  6573. var flagName = accessorType === "get" ? "getterToken" : "setterToken";
  6574. var msg = "";
  6575. if (isClass) {
  6576. if (isStatic) {
  6577. msg += "static ";
  6578. }
  6579. msg += accessorType + "ter method";
  6580. } else {
  6581. msg = "key";
  6582. }
  6583. state.tokens.curr.accessorType = accessorType;
  6584. state.nameStack.set(tkn);
  6585. if (props[name]) {
  6586. if ((props[name].basic || props[name][flagName]) && name !== "__proto__") {
  6587. warning("W075", state.tokens.next, msg, name);
  6588. }
  6589. } else {
  6590. props[name] = Object.create(null);
  6591. }
  6592. props[name][flagName] = tkn;
  6593. }
  6594. function computedPropertyName() {
  6595. advance("[");
  6596. if (!state.inES6()) {
  6597. warning("W119", state.tokens.curr, "computed property names", "6");
  6598. }
  6599. var value = expression(10);
  6600. advance("]");
  6601. return value;
  6602. }
  6603. function checkPunctuators(token, values) {
  6604. if (token.type === "(punctuator)") {
  6605. return _.contains(values, token.value);
  6606. }
  6607. return false;
  6608. }
  6609. function checkPunctuator(token, value) {
  6610. return token.type === "(punctuator)" && token.value === value;
  6611. }
  6612. function destructuringAssignOrJsonValue() {
  6613. var block = lookupBlockType();
  6614. if (block.notJson) {
  6615. if (!state.inES6() && block.isDestAssign) {
  6616. warning("W104", state.tokens.curr, "destructuring assignment", "6");
  6617. }
  6618. statements();
  6619. } else {
  6620. state.option.laxbreak = true;
  6621. state.jsonMode = true;
  6622. jsonValue();
  6623. }
  6624. }
  6625. var arrayComprehension = function() {
  6626. var CompArray = function() {
  6627. this.mode = "use";
  6628. this.variables = [];
  6629. };
  6630. var _carrays = [];
  6631. var _current;
  6632. function declare(v) {
  6633. var l = _current.variables.filter(function(elt) {
  6634. if (elt.value === v) {
  6635. elt.undef = false;
  6636. return v;
  6637. }
  6638. }).length;
  6639. return l !== 0;
  6640. }
  6641. function use(v) {
  6642. var l = _current.variables.filter(function(elt) {
  6643. if (elt.value === v && !elt.undef) {
  6644. if (elt.unused === true) {
  6645. elt.unused = false;
  6646. }
  6647. return v;
  6648. }
  6649. }).length;
  6650. return (l === 0);
  6651. }
  6652. return { stack: function() {
  6653. _current = new CompArray();
  6654. _carrays.push(_current);
  6655. },
  6656. unstack: function() {
  6657. _current.variables.filter(function(v) {
  6658. if (v.unused)
  6659. warning("W098", v.token, v.raw_text || v.value);
  6660. if (v.undef)
  6661. state.funct["(scope)"].block.use(v.value, v.token);
  6662. });
  6663. _carrays.splice(-1, 1);
  6664. _current = _carrays[_carrays.length - 1];
  6665. },
  6666. setState: function(s) {
  6667. if (_.contains(["use", "define", "generate", "filter"], s))
  6668. _current.mode = s;
  6669. },
  6670. check: function(v) {
  6671. if (!_current) {
  6672. return;
  6673. }
  6674. if (_current && _current.mode === "use") {
  6675. if (use(v)) {
  6676. _current.variables.push({
  6677. funct: state.funct,
  6678. token: state.tokens.curr,
  6679. value: v,
  6680. undef: true,
  6681. unused: false
  6682. });
  6683. }
  6684. return true;
  6685. } else if (_current && _current.mode === "define") {
  6686. if (!declare(v)) {
  6687. _current.variables.push({
  6688. funct: state.funct,
  6689. token: state.tokens.curr,
  6690. value: v,
  6691. undef: false,
  6692. unused: true
  6693. });
  6694. }
  6695. return true;
  6696. } else if (_current && _current.mode === "generate") {
  6697. state.funct["(scope)"].block.use(v, state.tokens.curr);
  6698. return true;
  6699. } else if (_current && _current.mode === "filter") {
  6700. if (use(v)) {
  6701. state.funct["(scope)"].block.use(v, state.tokens.curr);
  6702. }
  6703. return true;
  6704. }
  6705. return false;
  6706. }
  6707. };
  6708. };
  6709. function jsonValue() {
  6710. function jsonObject() {
  6711. var o = {}, t = state.tokens.next;
  6712. advance("{");
  6713. if (state.tokens.next.id !== "}") {
  6714. for (;;) {
  6715. if (state.tokens.next.id === "(end)") {
  6716. error("E026", state.tokens.next, t.line);
  6717. } else if (state.tokens.next.id === "}") {
  6718. warning("W094", state.tokens.curr);
  6719. break;
  6720. } else if (state.tokens.next.id === ",") {
  6721. error("E028", state.tokens.next);
  6722. } else if (state.tokens.next.id !== "(string)") {
  6723. warning("W095", state.tokens.next, state.tokens.next.value);
  6724. }
  6725. if (o[state.tokens.next.value] === true) {
  6726. warning("W075", state.tokens.next, "key", state.tokens.next.value);
  6727. } else if ((state.tokens.next.value === "__proto__" &&
  6728. !state.option.proto) || (state.tokens.next.value === "__iterator__" &&
  6729. !state.option.iterator)) {
  6730. warning("W096", state.tokens.next, state.tokens.next.value);
  6731. } else {
  6732. o[state.tokens.next.value] = true;
  6733. }
  6734. advance();
  6735. advance(":");
  6736. jsonValue();
  6737. if (state.tokens.next.id !== ",") {
  6738. break;
  6739. }
  6740. advance(",");
  6741. }
  6742. }
  6743. advance("}");
  6744. }
  6745. function jsonArray() {
  6746. var t = state.tokens.next;
  6747. advance("[");
  6748. if (state.tokens.next.id !== "]") {
  6749. for (;;) {
  6750. if (state.tokens.next.id === "(end)") {
  6751. error("E027", state.tokens.next, t.line);
  6752. } else if (state.tokens.next.id === "]") {
  6753. warning("W094", state.tokens.curr);
  6754. break;
  6755. } else if (state.tokens.next.id === ",") {
  6756. error("E028", state.tokens.next);
  6757. }
  6758. jsonValue();
  6759. if (state.tokens.next.id !== ",") {
  6760. break;
  6761. }
  6762. advance(",");
  6763. }
  6764. }
  6765. advance("]");
  6766. }
  6767. switch (state.tokens.next.id) {
  6768. case "{":
  6769. jsonObject();
  6770. break;
  6771. case "[":
  6772. jsonArray();
  6773. break;
  6774. case "true":
  6775. case "false":
  6776. case "null":
  6777. case "(number)":
  6778. case "(string)":
  6779. advance();
  6780. break;
  6781. case "-":
  6782. advance("-");
  6783. advance("(number)");
  6784. break;
  6785. default:
  6786. error("E003", state.tokens.next);
  6787. }
  6788. }
  6789. var escapeRegex = function(str) {
  6790. return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
  6791. };
  6792. var itself = function(s, o, g) {
  6793. var i, k, x, reIgnoreStr, reIgnore;
  6794. var optionKeys;
  6795. var newOptionObj = {};
  6796. var newIgnoredObj = {};
  6797. o = _.clone(o);
  6798. state.reset();
  6799. if (o && o.scope) {
  6800. JSHINT.scope = o.scope;
  6801. } else {
  6802. JSHINT.errors = [];
  6803. JSHINT.undefs = [];
  6804. JSHINT.internals = [];
  6805. JSHINT.blacklist = {};
  6806. JSHINT.scope = "(main)";
  6807. }
  6808. predefined = Object.create(null);
  6809. combine(predefined, vars.ecmaIdentifiers[3]);
  6810. combine(predefined, vars.reservedVars);
  6811. combine(predefined, g || {});
  6812. declared = Object.create(null);
  6813. var exported = Object.create(null); // Variables that live outside the current file
  6814. function each(obj, cb) {
  6815. if (!obj)
  6816. return;
  6817. if (!Array.isArray(obj) && typeof obj === "object")
  6818. obj = Object.keys(obj);
  6819. obj.forEach(cb);
  6820. }
  6821. if (o) {
  6822. each(o.predef || null, function(item) {
  6823. var slice, prop;
  6824. if (item[0] === "-") {
  6825. slice = item.slice(1);
  6826. JSHINT.blacklist[slice] = slice;
  6827. delete predefined[slice];
  6828. } else {
  6829. prop = Object.getOwnPropertyDescriptor(o.predef, item);
  6830. predefined[item] = prop ? prop.value : false;
  6831. }
  6832. });
  6833. each(o.exported || null, function(item) {
  6834. exported[item] = true;
  6835. });
  6836. delete o.predef;
  6837. delete o.exported;
  6838. optionKeys = Object.keys(o);
  6839. for (x = 0; x < optionKeys.length; x++) {
  6840. if (/^-W\d{3}$/g.test(optionKeys[x])) {
  6841. newIgnoredObj[optionKeys[x].slice(1)] = true;
  6842. } else {
  6843. var optionKey = optionKeys[x];
  6844. newOptionObj[optionKey] = o[optionKey];
  6845. if ((optionKey === "esversion" && o[optionKey] === 5) ||
  6846. (optionKey === "es5" && o[optionKey])) {
  6847. warning("I003");
  6848. }
  6849. if (optionKeys[x] === "newcap" && o[optionKey] === false)
  6850. newOptionObj["(explicitNewcap)"] = true;
  6851. }
  6852. }
  6853. }
  6854. state.option = newOptionObj;
  6855. state.ignored = newIgnoredObj;
  6856. state.option.indent = state.option.indent || 4;
  6857. state.option.maxerr = state.option.maxerr || 50;
  6858. indent = 1;
  6859. var scopeManagerInst = scopeManager(state, predefined, exported, declared);
  6860. scopeManagerInst.on("warning", function(ev) {
  6861. warning.apply(null, [ ev.code, ev.token].concat(ev.data));
  6862. });
  6863. scopeManagerInst.on("error", function(ev) {
  6864. error.apply(null, [ ev.code, ev.token ].concat(ev.data));
  6865. });
  6866. state.funct = functor("(global)", null, {
  6867. "(global)" : true,
  6868. "(scope)" : scopeManagerInst,
  6869. "(comparray)" : arrayComprehension(),
  6870. "(metrics)" : createMetrics(state.tokens.next)
  6871. });
  6872. functions = [state.funct];
  6873. urls = [];
  6874. stack = null;
  6875. member = {};
  6876. membersOnly = null;
  6877. inblock = false;
  6878. lookahead = [];
  6879. if (!isString(s) && !Array.isArray(s)) {
  6880. errorAt("E004", 0);
  6881. return false;
  6882. }
  6883. api = {
  6884. get isJSON() {
  6885. return state.jsonMode;
  6886. },
  6887. getOption: function(name) {
  6888. return state.option[name] || null;
  6889. },
  6890. getCache: function(name) {
  6891. return state.cache[name];
  6892. },
  6893. setCache: function(name, value) {
  6894. state.cache[name] = value;
  6895. },
  6896. warn: function(code, data) {
  6897. warningAt.apply(null, [ code, data.line, data.char ].concat(data.data));
  6898. },
  6899. on: function(names, listener) {
  6900. names.split(" ").forEach(function(name) {
  6901. emitter.on(name, listener);
  6902. }.bind(this));
  6903. }
  6904. };
  6905. emitter.removeAllListeners();
  6906. (extraModules || []).forEach(function(func) {
  6907. func(api);
  6908. });
  6909. state.tokens.prev = state.tokens.curr = state.tokens.next = state.syntax["(begin)"];
  6910. if (o && o.ignoreDelimiters) {
  6911. if (!Array.isArray(o.ignoreDelimiters)) {
  6912. o.ignoreDelimiters = [o.ignoreDelimiters];
  6913. }
  6914. o.ignoreDelimiters.forEach(function(delimiterPair) {
  6915. if (!delimiterPair.start || !delimiterPair.end)
  6916. return;
  6917. reIgnoreStr = escapeRegex(delimiterPair.start) +
  6918. "[\\s\\S]*?" +
  6919. escapeRegex(delimiterPair.end);
  6920. reIgnore = new RegExp(reIgnoreStr, "ig");
  6921. s = s.replace(reIgnore, function(match) {
  6922. return match.replace(/./g, " ");
  6923. });
  6924. });
  6925. }
  6926. lex = new Lexer(s);
  6927. lex.on("warning", function(ev) {
  6928. warningAt.apply(null, [ ev.code, ev.line, ev.character].concat(ev.data));
  6929. });
  6930. lex.on("error", function(ev) {
  6931. errorAt.apply(null, [ ev.code, ev.line, ev.character ].concat(ev.data));
  6932. });
  6933. lex.on("fatal", function(ev) {
  6934. quit("E041", ev.line, ev.from);
  6935. });
  6936. lex.on("Identifier", function(ev) {
  6937. emitter.emit("Identifier", ev);
  6938. });
  6939. lex.on("String", function(ev) {
  6940. emitter.emit("String", ev);
  6941. });
  6942. lex.on("Number", function(ev) {
  6943. emitter.emit("Number", ev);
  6944. });
  6945. lex.start();
  6946. for (var name in o) {
  6947. if (_.has(o, name)) {
  6948. checkOption(name, state.tokens.curr);
  6949. }
  6950. }
  6951. assume();
  6952. combine(predefined, g || {});
  6953. comma.first = true;
  6954. try {
  6955. advance();
  6956. switch (state.tokens.next.id) {
  6957. case "{":
  6958. case "[":
  6959. destructuringAssignOrJsonValue();
  6960. break;
  6961. default:
  6962. directives();
  6963. if (state.directive["use strict"]) {
  6964. if (state.option.strict !== "global") {
  6965. warning("W097", state.tokens.prev);
  6966. }
  6967. }
  6968. statements();
  6969. }
  6970. if (state.tokens.next.id !== "(end)") {
  6971. quit("E041", state.tokens.curr.line);
  6972. }
  6973. state.funct["(scope)"].unstack();
  6974. } catch (err) {
  6975. if (err && err.name === "JSHintError") {
  6976. var nt = state.tokens.next || {};
  6977. JSHINT.errors.push({
  6978. scope : "(main)",
  6979. raw : err.raw,
  6980. code : err.code,
  6981. reason : err.message,
  6982. line : err.line || nt.line,
  6983. character : err.character || nt.from
  6984. }, null);
  6985. } else {
  6986. throw err;
  6987. }
  6988. }
  6989. if (JSHINT.scope === "(main)") {
  6990. o = o || {};
  6991. for (i = 0; i < JSHINT.internals.length; i += 1) {
  6992. k = JSHINT.internals[i];
  6993. o.scope = k.elem;
  6994. itself(k.value, o, g);
  6995. }
  6996. }
  6997. return JSHINT.errors.length === 0;
  6998. };
  6999. itself.addModule = function(func) {
  7000. extraModules.push(func);
  7001. };
  7002. itself.addModule(style.register);
  7003. itself.data = function() {
  7004. var data = {
  7005. functions: [],
  7006. options: state.option
  7007. };
  7008. var fu, f, i, j, n, globals;
  7009. if (itself.errors.length) {
  7010. data.errors = itself.errors;
  7011. }
  7012. if (state.jsonMode) {
  7013. data.json = true;
  7014. }
  7015. var impliedGlobals = state.funct["(scope)"].getImpliedGlobals();
  7016. if (impliedGlobals.length > 0) {
  7017. data.implieds = impliedGlobals;
  7018. }
  7019. if (urls.length > 0) {
  7020. data.urls = urls;
  7021. }
  7022. globals = state.funct["(scope)"].getUsedOrDefinedGlobals();
  7023. if (globals.length > 0) {
  7024. data.globals = globals;
  7025. }
  7026. for (i = 1; i < functions.length; i += 1) {
  7027. f = functions[i];
  7028. fu = {};
  7029. for (j = 0; j < functionicity.length; j += 1) {
  7030. fu[functionicity[j]] = [];
  7031. }
  7032. for (j = 0; j < functionicity.length; j += 1) {
  7033. if (fu[functionicity[j]].length === 0) {
  7034. delete fu[functionicity[j]];
  7035. }
  7036. }
  7037. fu.name = f["(name)"];
  7038. fu.param = f["(params)"];
  7039. fu.line = f["(line)"];
  7040. fu.character = f["(character)"];
  7041. fu.last = f["(last)"];
  7042. fu.lastcharacter = f["(lastcharacter)"];
  7043. fu.metrics = {
  7044. complexity: f["(metrics)"].ComplexityCount,
  7045. parameters: f["(metrics)"].arity,
  7046. statements: f["(metrics)"].statementCount
  7047. };
  7048. data.functions.push(fu);
  7049. }
  7050. var unuseds = state.funct["(scope)"].getUnuseds();
  7051. if (unuseds.length > 0) {
  7052. data.unused = unuseds;
  7053. }
  7054. for (n in member) {
  7055. if (typeof member[n] === "number") {
  7056. data.member = member;
  7057. break;
  7058. }
  7059. }
  7060. return data;
  7061. };
  7062. itself.jshint = itself;
  7063. return itself;
  7064. }());
  7065. if (typeof exports === "object" && exports) {
  7066. exports.JSHINT = JSHINT;
  7067. }
  7068. },{"../lodash":"/node_modules/jshint/lodash.js","./lex.js":"/node_modules/jshint/src/lex.js","./messages.js":"/node_modules/jshint/src/messages.js","./options.js":"/node_modules/jshint/src/options.js","./reg.js":"/node_modules/jshint/src/reg.js","./scope-manager.js":"/node_modules/jshint/src/scope-manager.js","./state.js":"/node_modules/jshint/src/state.js","./style.js":"/node_modules/jshint/src/style.js","./vars.js":"/node_modules/jshint/src/vars.js","events":"/node_modules/browserify/node_modules/events/events.js"}],"/node_modules/jshint/src/lex.js":[function(_dereq_,module,exports){
  7069. "use strict";
  7070. var _ = _dereq_("../lodash");
  7071. var events = _dereq_("events");
  7072. var reg = _dereq_("./reg.js");
  7073. var state = _dereq_("./state.js").state;
  7074. var unicodeData = _dereq_("../data/ascii-identifier-data.js");
  7075. var asciiIdentifierStartTable = unicodeData.asciiIdentifierStartTable;
  7076. var asciiIdentifierPartTable = unicodeData.asciiIdentifierPartTable;
  7077. var Token = {
  7078. Identifier: 1,
  7079. Punctuator: 2,
  7080. NumericLiteral: 3,
  7081. StringLiteral: 4,
  7082. Comment: 5,
  7083. Keyword: 6,
  7084. NullLiteral: 7,
  7085. BooleanLiteral: 8,
  7086. RegExp: 9,
  7087. TemplateHead: 10,
  7088. TemplateMiddle: 11,
  7089. TemplateTail: 12,
  7090. NoSubstTemplate: 13
  7091. };
  7092. var Context = {
  7093. Block: 1,
  7094. Template: 2
  7095. };
  7096. function asyncTrigger() {
  7097. var _checks = [];
  7098. return {
  7099. push: function(fn) {
  7100. _checks.push(fn);
  7101. },
  7102. check: function() {
  7103. for (var check = 0; check < _checks.length; ++check) {
  7104. _checks[check]();
  7105. }
  7106. _checks.splice(0, _checks.length);
  7107. }
  7108. };
  7109. }
  7110. function Lexer(source) {
  7111. var lines = source;
  7112. if (typeof lines === "string") {
  7113. lines = lines
  7114. .replace(/\r\n/g, "\n")
  7115. .replace(/\r/g, "\n")
  7116. .split("\n");
  7117. }
  7118. if (lines[0] && lines[0].substr(0, 2) === "#!") {
  7119. if (lines[0].indexOf("node") !== -1) {
  7120. state.option.node = true;
  7121. }
  7122. lines[0] = "";
  7123. }
  7124. this.emitter = new events.EventEmitter();
  7125. this.source = source;
  7126. this.setLines(lines);
  7127. this.prereg = true;
  7128. this.line = 0;
  7129. this.char = 1;
  7130. this.from = 1;
  7131. this.input = "";
  7132. this.inComment = false;
  7133. this.context = [];
  7134. this.templateStarts = [];
  7135. for (var i = 0; i < state.option.indent; i += 1) {
  7136. state.tab += " ";
  7137. }
  7138. this.ignoreLinterErrors = false;
  7139. }
  7140. Lexer.prototype = {
  7141. _lines: [],
  7142. inContext: function(ctxType) {
  7143. return this.context.length > 0 && this.context[this.context.length - 1].type === ctxType;
  7144. },
  7145. pushContext: function(ctxType) {
  7146. this.context.push({ type: ctxType });
  7147. },
  7148. popContext: function() {
  7149. return this.context.pop();
  7150. },
  7151. isContext: function(context) {
  7152. return this.context.length > 0 && this.context[this.context.length - 1] === context;
  7153. },
  7154. currentContext: function() {
  7155. return this.context.length > 0 && this.context[this.context.length - 1];
  7156. },
  7157. getLines: function() {
  7158. this._lines = state.lines;
  7159. return this._lines;
  7160. },
  7161. setLines: function(val) {
  7162. this._lines = val;
  7163. state.lines = this._lines;
  7164. },
  7165. peek: function(i) {
  7166. return this.input.charAt(i || 0);
  7167. },
  7168. skip: function(i) {
  7169. i = i || 1;
  7170. this.char += i;
  7171. this.input = this.input.slice(i);
  7172. },
  7173. on: function(names, listener) {
  7174. names.split(" ").forEach(function(name) {
  7175. this.emitter.on(name, listener);
  7176. }.bind(this));
  7177. },
  7178. trigger: function() {
  7179. this.emitter.emit.apply(this.emitter, Array.prototype.slice.call(arguments));
  7180. },
  7181. triggerAsync: function(type, args, checks, fn) {
  7182. checks.push(function() {
  7183. if (fn()) {
  7184. this.trigger(type, args);
  7185. }
  7186. }.bind(this));
  7187. },
  7188. scanPunctuator: function() {
  7189. var ch1 = this.peek();
  7190. var ch2, ch3, ch4;
  7191. switch (ch1) {
  7192. case ".":
  7193. if ((/^[0-9]$/).test(this.peek(1))) {
  7194. return null;
  7195. }
  7196. if (this.peek(1) === "." && this.peek(2) === ".") {
  7197. return {
  7198. type: Token.Punctuator,
  7199. value: "..."
  7200. };
  7201. }
  7202. case "(":
  7203. case ")":
  7204. case ";":
  7205. case ",":
  7206. case "[":
  7207. case "]":
  7208. case ":":
  7209. case "~":
  7210. case "?":
  7211. return {
  7212. type: Token.Punctuator,
  7213. value: ch1
  7214. };
  7215. case "{":
  7216. this.pushContext(Context.Block);
  7217. return {
  7218. type: Token.Punctuator,
  7219. value: ch1
  7220. };
  7221. case "}":
  7222. if (this.inContext(Context.Block)) {
  7223. this.popContext();
  7224. }
  7225. return {
  7226. type: Token.Punctuator,
  7227. value: ch1
  7228. };
  7229. case "#":
  7230. return {
  7231. type: Token.Punctuator,
  7232. value: ch1
  7233. };
  7234. case "":
  7235. return null;
  7236. }
  7237. ch2 = this.peek(1);
  7238. ch3 = this.peek(2);
  7239. ch4 = this.peek(3);
  7240. if (ch1 === ">" && ch2 === ">" && ch3 === ">" && ch4 === "=") {
  7241. return {
  7242. type: Token.Punctuator,
  7243. value: ">>>="
  7244. };
  7245. }
  7246. if (ch1 === "=" && ch2 === "=" && ch3 === "=") {
  7247. return {
  7248. type: Token.Punctuator,
  7249. value: "==="
  7250. };
  7251. }
  7252. if (ch1 === "!" && ch2 === "=" && ch3 === "=") {
  7253. return {
  7254. type: Token.Punctuator,
  7255. value: "!=="
  7256. };
  7257. }
  7258. if (ch1 === ">" && ch2 === ">" && ch3 === ">") {
  7259. return {
  7260. type: Token.Punctuator,
  7261. value: ">>>"
  7262. };
  7263. }
  7264. if (ch1 === "<" && ch2 === "<" && ch3 === "=") {
  7265. return {
  7266. type: Token.Punctuator,
  7267. value: "<<="
  7268. };
  7269. }
  7270. if (ch1 === ">" && ch2 === ">" && ch3 === "=") {
  7271. return {
  7272. type: Token.Punctuator,
  7273. value: ">>="
  7274. };
  7275. }
  7276. if (ch1 === "=" && ch2 === ">") {
  7277. return {
  7278. type: Token.Punctuator,
  7279. value: ch1 + ch2
  7280. };
  7281. }
  7282. if (ch1 === ch2 && ("+-<>&|".indexOf(ch1) >= 0)) {
  7283. return {
  7284. type: Token.Punctuator,
  7285. value: ch1 + ch2
  7286. };
  7287. }
  7288. if ("<>=!+-*%&|^".indexOf(ch1) >= 0) {
  7289. if (ch2 === "=") {
  7290. return {
  7291. type: Token.Punctuator,
  7292. value: ch1 + ch2
  7293. };
  7294. }
  7295. return {
  7296. type: Token.Punctuator,
  7297. value: ch1
  7298. };
  7299. }
  7300. if (ch1 === "/") {
  7301. if (ch2 === "=") {
  7302. return {
  7303. type: Token.Punctuator,
  7304. value: "/="
  7305. };
  7306. }
  7307. return {
  7308. type: Token.Punctuator,
  7309. value: "/"
  7310. };
  7311. }
  7312. return null;
  7313. },
  7314. scanComments: function() {
  7315. var ch1 = this.peek();
  7316. var ch2 = this.peek(1);
  7317. var rest = this.input.substr(2);
  7318. var startLine = this.line;
  7319. var startChar = this.char;
  7320. var self = this;
  7321. function commentToken(label, body, opt) {
  7322. var special = ["jshint", "jslint", "members", "member", "globals", "global", "exported"];
  7323. var isSpecial = false;
  7324. var value = label + body;
  7325. var commentType = "plain";
  7326. opt = opt || {};
  7327. if (opt.isMultiline) {
  7328. value += "*/";
  7329. }
  7330. body = body.replace(/\n/g, " ");
  7331. if (label === "/*" && reg.fallsThrough.test(body)) {
  7332. isSpecial = true;
  7333. commentType = "falls through";
  7334. }
  7335. special.forEach(function(str) {
  7336. if (isSpecial) {
  7337. return;
  7338. }
  7339. if (label === "//" && str !== "jshint") {
  7340. return;
  7341. }
  7342. if (body.charAt(str.length) === " " && body.substr(0, str.length) === str) {
  7343. isSpecial = true;
  7344. label = label + str;
  7345. body = body.substr(str.length);
  7346. }
  7347. if (!isSpecial && body.charAt(0) === " " && body.charAt(str.length + 1) === " " &&
  7348. body.substr(1, str.length) === str) {
  7349. isSpecial = true;
  7350. label = label + " " + str;
  7351. body = body.substr(str.length + 1);
  7352. }
  7353. if (!isSpecial) {
  7354. return;
  7355. }
  7356. switch (str) {
  7357. case "member":
  7358. commentType = "members";
  7359. break;
  7360. case "global":
  7361. commentType = "globals";
  7362. break;
  7363. default:
  7364. var options = body.split(":").map(function(v) {
  7365. return v.replace(/^\s+/, "").replace(/\s+$/, "");
  7366. });
  7367. if (options.length === 2) {
  7368. switch (options[0]) {
  7369. case "ignore":
  7370. switch (options[1]) {
  7371. case "start":
  7372. self.ignoringLinterErrors = true;
  7373. isSpecial = false;
  7374. break;
  7375. case "end":
  7376. self.ignoringLinterErrors = false;
  7377. isSpecial = false;
  7378. break;
  7379. }
  7380. }
  7381. }
  7382. commentType = str;
  7383. }
  7384. });
  7385. return {
  7386. type: Token.Comment,
  7387. commentType: commentType,
  7388. value: value,
  7389. body: body,
  7390. isSpecial: isSpecial,
  7391. isMultiline: opt.isMultiline || false,
  7392. isMalformed: opt.isMalformed || false
  7393. };
  7394. }
  7395. if (ch1 === "*" && ch2 === "/") {
  7396. this.trigger("error", {
  7397. code: "E018",
  7398. line: startLine,
  7399. character: startChar
  7400. });
  7401. this.skip(2);
  7402. return null;
  7403. }
  7404. if (ch1 !== "/" || (ch2 !== "*" && ch2 !== "/")) {
  7405. return null;
  7406. }
  7407. if (ch2 === "/") {
  7408. this.skip(this.input.length); // Skip to the EOL.
  7409. return commentToken("//", rest);
  7410. }
  7411. var body = "";
  7412. if (ch2 === "*") {
  7413. this.inComment = true;
  7414. this.skip(2);
  7415. while (this.peek() !== "*" || this.peek(1) !== "/") {
  7416. if (this.peek() === "") { // End of Line
  7417. body += "\n";
  7418. if (!this.nextLine()) {
  7419. this.trigger("error", {
  7420. code: "E017",
  7421. line: startLine,
  7422. character: startChar
  7423. });
  7424. this.inComment = false;
  7425. return commentToken("/*", body, {
  7426. isMultiline: true,
  7427. isMalformed: true
  7428. });
  7429. }
  7430. } else {
  7431. body += this.peek();
  7432. this.skip();
  7433. }
  7434. }
  7435. this.skip(2);
  7436. this.inComment = false;
  7437. return commentToken("/*", body, { isMultiline: true });
  7438. }
  7439. },
  7440. scanKeyword: function() {
  7441. var result = /^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input);
  7442. var keywords = [
  7443. "if", "in", "do", "var", "for", "new",
  7444. "try", "let", "this", "else", "case",
  7445. "void", "with", "enum", "while", "break",
  7446. "catch", "throw", "const", "yield", "class",
  7447. "super", "return", "typeof", "delete",
  7448. "switch", "export", "import", "default",
  7449. "finally", "extends", "function", "continue",
  7450. "debugger", "instanceof"
  7451. ];
  7452. if (result && keywords.indexOf(result[0]) >= 0) {
  7453. return {
  7454. type: Token.Keyword,
  7455. value: result[0]
  7456. };
  7457. }
  7458. return null;
  7459. },
  7460. scanIdentifier: function() {
  7461. var id = "";
  7462. var index = 0;
  7463. var type, char;
  7464. function isNonAsciiIdentifierStart(code) {
  7465. return code > 256;
  7466. }
  7467. function isNonAsciiIdentifierPart(code) {
  7468. return code > 256;
  7469. }
  7470. function isHexDigit(str) {
  7471. return (/^[0-9a-fA-F]$/).test(str);
  7472. }
  7473. var readUnicodeEscapeSequence = function() {
  7474. index += 1;
  7475. if (this.peek(index) !== "u") {
  7476. return null;
  7477. }
  7478. var ch1 = this.peek(index + 1);
  7479. var ch2 = this.peek(index + 2);
  7480. var ch3 = this.peek(index + 3);
  7481. var ch4 = this.peek(index + 4);
  7482. var code;
  7483. if (isHexDigit(ch1) && isHexDigit(ch2) && isHexDigit(ch3) && isHexDigit(ch4)) {
  7484. code = parseInt(ch1 + ch2 + ch3 + ch4, 16);
  7485. if (asciiIdentifierPartTable[code] || isNonAsciiIdentifierPart(code)) {
  7486. index += 5;
  7487. return "\\u" + ch1 + ch2 + ch3 + ch4;
  7488. }
  7489. return null;
  7490. }
  7491. return null;
  7492. }.bind(this);
  7493. var getIdentifierStart = function() {
  7494. var chr = this.peek(index);
  7495. var code = chr.charCodeAt(0);
  7496. if (code === 92) {
  7497. return readUnicodeEscapeSequence();
  7498. }
  7499. if (code < 128) {
  7500. if (asciiIdentifierStartTable[code]) {
  7501. index += 1;
  7502. return chr;
  7503. }
  7504. return null;
  7505. }
  7506. if (isNonAsciiIdentifierStart(code)) {
  7507. index += 1;
  7508. return chr;
  7509. }
  7510. return null;
  7511. }.bind(this);
  7512. var getIdentifierPart = function() {
  7513. var chr = this.peek(index);
  7514. var code = chr.charCodeAt(0);
  7515. if (code === 92) {
  7516. return readUnicodeEscapeSequence();
  7517. }
  7518. if (code < 128) {
  7519. if (asciiIdentifierPartTable[code]) {
  7520. index += 1;
  7521. return chr;
  7522. }
  7523. return null;
  7524. }
  7525. if (isNonAsciiIdentifierPart(code)) {
  7526. index += 1;
  7527. return chr;
  7528. }
  7529. return null;
  7530. }.bind(this);
  7531. function removeEscapeSequences(id) {
  7532. return id.replace(/\\u([0-9a-fA-F]{4})/g, function(m0, codepoint) {
  7533. return String.fromCharCode(parseInt(codepoint, 16));
  7534. });
  7535. }
  7536. char = getIdentifierStart();
  7537. if (char === null) {
  7538. return null;
  7539. }
  7540. id = char;
  7541. for (;;) {
  7542. char = getIdentifierPart();
  7543. if (char === null) {
  7544. break;
  7545. }
  7546. id += char;
  7547. }
  7548. switch (id) {
  7549. case "true":
  7550. case "false":
  7551. type = Token.BooleanLiteral;
  7552. break;
  7553. case "null":
  7554. type = Token.NullLiteral;
  7555. break;
  7556. default:
  7557. type = Token.Identifier;
  7558. }
  7559. return {
  7560. type: type,
  7561. value: removeEscapeSequences(id),
  7562. text: id,
  7563. tokenLength: id.length
  7564. };
  7565. },
  7566. scanNumericLiteral: function() {
  7567. var index = 0;
  7568. var value = "";
  7569. var length = this.input.length;
  7570. var char = this.peek(index);
  7571. var bad;
  7572. var isAllowedDigit = isDecimalDigit;
  7573. var base = 10;
  7574. var isLegacy = false;
  7575. function isDecimalDigit(str) {
  7576. return (/^[0-9]$/).test(str);
  7577. }
  7578. function isOctalDigit(str) {
  7579. return (/^[0-7]$/).test(str);
  7580. }
  7581. function isBinaryDigit(str) {
  7582. return (/^[01]$/).test(str);
  7583. }
  7584. function isHexDigit(str) {
  7585. return (/^[0-9a-fA-F]$/).test(str);
  7586. }
  7587. function isIdentifierStart(ch) {
  7588. return (ch === "$") || (ch === "_") || (ch === "\\") ||
  7589. (ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z");
  7590. }
  7591. if (char !== "." && !isDecimalDigit(char)) {
  7592. return null;
  7593. }
  7594. if (char !== ".") {
  7595. value = this.peek(index);
  7596. index += 1;
  7597. char = this.peek(index);
  7598. if (value === "0") {
  7599. if (char === "x" || char === "X") {
  7600. isAllowedDigit = isHexDigit;
  7601. base = 16;
  7602. index += 1;
  7603. value += char;
  7604. }
  7605. if (char === "o" || char === "O") {
  7606. isAllowedDigit = isOctalDigit;
  7607. base = 8;
  7608. if (!state.inES6(true)) {
  7609. this.trigger("warning", {
  7610. code: "W119",
  7611. line: this.line,
  7612. character: this.char,
  7613. data: [ "Octal integer literal", "6" ]
  7614. });
  7615. }
  7616. index += 1;
  7617. value += char;
  7618. }
  7619. if (char === "b" || char === "B") {
  7620. isAllowedDigit = isBinaryDigit;
  7621. base = 2;
  7622. if (!state.inES6(true)) {
  7623. this.trigger("warning", {
  7624. code: "W119",
  7625. line: this.line,
  7626. character: this.char,
  7627. data: [ "Binary integer literal", "6" ]
  7628. });
  7629. }
  7630. index += 1;
  7631. value += char;
  7632. }
  7633. if (isOctalDigit(char)) {
  7634. isAllowedDigit = isOctalDigit;
  7635. base = 8;
  7636. isLegacy = true;
  7637. bad = false;
  7638. index += 1;
  7639. value += char;
  7640. }
  7641. if (!isOctalDigit(char) && isDecimalDigit(char)) {
  7642. index += 1;
  7643. value += char;
  7644. }
  7645. }
  7646. while (index < length) {
  7647. char = this.peek(index);
  7648. if (isLegacy && isDecimalDigit(char)) {
  7649. bad = true;
  7650. } else if (!isAllowedDigit(char)) {
  7651. break;
  7652. }
  7653. value += char;
  7654. index += 1;
  7655. }
  7656. if (isAllowedDigit !== isDecimalDigit) {
  7657. if (!isLegacy && value.length <= 2) { // 0x
  7658. return {
  7659. type: Token.NumericLiteral,
  7660. value: value,
  7661. isMalformed: true
  7662. };
  7663. }
  7664. if (index < length) {
  7665. char = this.peek(index);
  7666. if (isIdentifierStart(char)) {
  7667. return null;
  7668. }
  7669. }
  7670. return {
  7671. type: Token.NumericLiteral,
  7672. value: value,
  7673. base: base,
  7674. isLegacy: isLegacy,
  7675. isMalformed: false
  7676. };
  7677. }
  7678. }
  7679. if (char === ".") {
  7680. value += char;
  7681. index += 1;
  7682. while (index < length) {
  7683. char = this.peek(index);
  7684. if (!isDecimalDigit(char)) {
  7685. break;
  7686. }
  7687. value += char;
  7688. index += 1;
  7689. }
  7690. }
  7691. if (char === "e" || char === "E") {
  7692. value += char;
  7693. index += 1;
  7694. char = this.peek(index);
  7695. if (char === "+" || char === "-") {
  7696. value += this.peek(index);
  7697. index += 1;
  7698. }
  7699. char = this.peek(index);
  7700. if (isDecimalDigit(char)) {
  7701. value += char;
  7702. index += 1;
  7703. while (index < length) {
  7704. char = this.peek(index);
  7705. if (!isDecimalDigit(char)) {
  7706. break;
  7707. }
  7708. value += char;
  7709. index += 1;
  7710. }
  7711. } else {
  7712. return null;
  7713. }
  7714. }
  7715. if (index < length) {
  7716. char = this.peek(index);
  7717. if (isIdentifierStart(char)) {
  7718. return null;
  7719. }
  7720. }
  7721. return {
  7722. type: Token.NumericLiteral,
  7723. value: value,
  7724. base: base,
  7725. isMalformed: !isFinite(value)
  7726. };
  7727. },
  7728. scanEscapeSequence: function(checks) {
  7729. var allowNewLine = false;
  7730. var jump = 1;
  7731. this.skip();
  7732. var char = this.peek();
  7733. switch (char) {
  7734. case "'":
  7735. this.triggerAsync("warning", {
  7736. code: "W114",
  7737. line: this.line,
  7738. character: this.char,
  7739. data: [ "\\'" ]
  7740. }, checks, function() {return state.jsonMode; });
  7741. break;
  7742. case "b":
  7743. char = "\\b";
  7744. break;
  7745. case "f":
  7746. char = "\\f";
  7747. break;
  7748. case "n":
  7749. char = "\\n";
  7750. break;
  7751. case "r":
  7752. char = "\\r";
  7753. break;
  7754. case "t":
  7755. char = "\\t";
  7756. break;
  7757. case "0":
  7758. char = "\\0";
  7759. var n = parseInt(this.peek(1), 10);
  7760. this.triggerAsync("warning", {
  7761. code: "W115",
  7762. line: this.line,
  7763. character: this.char
  7764. }, checks,
  7765. function() { return n >= 0 && n <= 7 && state.isStrict(); });
  7766. break;
  7767. case "u":
  7768. var hexCode = this.input.substr(1, 4);
  7769. var code = parseInt(hexCode, 16);
  7770. if (isNaN(code)) {
  7771. this.trigger("warning", {
  7772. code: "W052",
  7773. line: this.line,
  7774. character: this.char,
  7775. data: [ "u" + hexCode ]
  7776. });
  7777. }
  7778. char = String.fromCharCode(code);
  7779. jump = 5;
  7780. break;
  7781. case "v":
  7782. this.triggerAsync("warning", {
  7783. code: "W114",
  7784. line: this.line,
  7785. character: this.char,
  7786. data: [ "\\v" ]
  7787. }, checks, function() { return state.jsonMode; });
  7788. char = "\v";
  7789. break;
  7790. case "x":
  7791. var x = parseInt(this.input.substr(1, 2), 16);
  7792. this.triggerAsync("warning", {
  7793. code: "W114",
  7794. line: this.line,
  7795. character: this.char,
  7796. data: [ "\\x-" ]
  7797. }, checks, function() { return state.jsonMode; });
  7798. char = String.fromCharCode(x);
  7799. jump = 3;
  7800. break;
  7801. case "\\":
  7802. char = "\\\\";
  7803. break;
  7804. case "\"":
  7805. char = "\\\"";
  7806. break;
  7807. case "/":
  7808. break;
  7809. case "":
  7810. allowNewLine = true;
  7811. char = "";
  7812. break;
  7813. }
  7814. return { char: char, jump: jump, allowNewLine: allowNewLine };
  7815. },
  7816. scanTemplateLiteral: function(checks) {
  7817. var tokenType;
  7818. var value = "";
  7819. var ch;
  7820. var startLine = this.line;
  7821. var startChar = this.char;
  7822. var depth = this.templateStarts.length;
  7823. if (!state.inES6(true)) {
  7824. return null;
  7825. } else if (this.peek() === "`") {
  7826. tokenType = Token.TemplateHead;
  7827. this.templateStarts.push({ line: this.line, char: this.char });
  7828. depth = this.templateStarts.length;
  7829. this.skip(1);
  7830. this.pushContext(Context.Template);
  7831. } else if (this.inContext(Context.Template) && this.peek() === "}") {
  7832. tokenType = Token.TemplateMiddle;
  7833. } else {
  7834. return null;
  7835. }
  7836. while (this.peek() !== "`") {
  7837. while ((ch = this.peek()) === "") {
  7838. value += "\n";
  7839. if (!this.nextLine()) {
  7840. var startPos = this.templateStarts.pop();
  7841. this.trigger("error", {
  7842. code: "E052",
  7843. line: startPos.line,
  7844. character: startPos.char
  7845. });
  7846. return {
  7847. type: tokenType,
  7848. value: value,
  7849. startLine: startLine,
  7850. startChar: startChar,
  7851. isUnclosed: true,
  7852. depth: depth,
  7853. context: this.popContext()
  7854. };
  7855. }
  7856. }
  7857. if (ch === '$' && this.peek(1) === '{') {
  7858. value += '${';
  7859. this.skip(2);
  7860. return {
  7861. type: tokenType,
  7862. value: value,
  7863. startLine: startLine,
  7864. startChar: startChar,
  7865. isUnclosed: false,
  7866. depth: depth,
  7867. context: this.currentContext()
  7868. };
  7869. } else if (ch === '\\') {
  7870. var escape = this.scanEscapeSequence(checks);
  7871. value += escape.char;
  7872. this.skip(escape.jump);
  7873. } else if (ch !== '`') {
  7874. value += ch;
  7875. this.skip(1);
  7876. }
  7877. }
  7878. tokenType = tokenType === Token.TemplateHead ? Token.NoSubstTemplate : Token.TemplateTail;
  7879. this.skip(1);
  7880. this.templateStarts.pop();
  7881. return {
  7882. type: tokenType,
  7883. value: value,
  7884. startLine: startLine,
  7885. startChar: startChar,
  7886. isUnclosed: false,
  7887. depth: depth,
  7888. context: this.popContext()
  7889. };
  7890. },
  7891. scanStringLiteral: function(checks) {
  7892. var quote = this.peek();
  7893. if (quote !== "\"" && quote !== "'") {
  7894. return null;
  7895. }
  7896. this.triggerAsync("warning", {
  7897. code: "W108",
  7898. line: this.line,
  7899. character: this.char // +1?
  7900. }, checks, function() { return state.jsonMode && quote !== "\""; });
  7901. var value = "";
  7902. var startLine = this.line;
  7903. var startChar = this.char;
  7904. var allowNewLine = false;
  7905. this.skip();
  7906. while (this.peek() !== quote) {
  7907. if (this.peek() === "") { // End Of Line
  7908. if (!allowNewLine) {
  7909. this.trigger("warning", {
  7910. code: "W112",
  7911. line: this.line,
  7912. character: this.char
  7913. });
  7914. } else {
  7915. allowNewLine = false;
  7916. this.triggerAsync("warning", {
  7917. code: "W043",
  7918. line: this.line,
  7919. character: this.char
  7920. }, checks, function() { return !state.option.multistr; });
  7921. this.triggerAsync("warning", {
  7922. code: "W042",
  7923. line: this.line,
  7924. character: this.char
  7925. }, checks, function() { return state.jsonMode && state.option.multistr; });
  7926. }
  7927. if (!this.nextLine()) {
  7928. this.trigger("error", {
  7929. code: "E029",
  7930. line: startLine,
  7931. character: startChar
  7932. });
  7933. return {
  7934. type: Token.StringLiteral,
  7935. value: value,
  7936. startLine: startLine,
  7937. startChar: startChar,
  7938. isUnclosed: true,
  7939. quote: quote
  7940. };
  7941. }
  7942. } else { // Any character other than End Of Line
  7943. allowNewLine = false;
  7944. var char = this.peek();
  7945. var jump = 1; // A length of a jump, after we're done
  7946. if (char < " ") {
  7947. this.trigger("warning", {
  7948. code: "W113",
  7949. line: this.line,
  7950. character: this.char,
  7951. data: [ "<non-printable>" ]
  7952. });
  7953. }
  7954. if (char === "\\") {
  7955. var parsed = this.scanEscapeSequence(checks);
  7956. char = parsed.char;
  7957. jump = parsed.jump;
  7958. allowNewLine = parsed.allowNewLine;
  7959. }
  7960. value += char;
  7961. this.skip(jump);
  7962. }
  7963. }
  7964. this.skip();
  7965. return {
  7966. type: Token.StringLiteral,
  7967. value: value,
  7968. startLine: startLine,
  7969. startChar: startChar,
  7970. isUnclosed: false,
  7971. quote: quote
  7972. };
  7973. },
  7974. scanRegExp: function() {
  7975. var index = 0;
  7976. var length = this.input.length;
  7977. var char = this.peek();
  7978. var value = char;
  7979. var body = "";
  7980. var flags = [];
  7981. var malformed = false;
  7982. var isCharSet = false;
  7983. var terminated;
  7984. var scanUnexpectedChars = function() {
  7985. if (char < " ") {
  7986. malformed = true;
  7987. this.trigger("warning", {
  7988. code: "W048",
  7989. line: this.line,
  7990. character: this.char
  7991. });
  7992. }
  7993. if (char === "<") {
  7994. malformed = true;
  7995. this.trigger("warning", {
  7996. code: "W049",
  7997. line: this.line,
  7998. character: this.char,
  7999. data: [ char ]
  8000. });
  8001. }
  8002. }.bind(this);
  8003. if (!this.prereg || char !== "/") {
  8004. return null;
  8005. }
  8006. index += 1;
  8007. terminated = false;
  8008. while (index < length) {
  8009. char = this.peek(index);
  8010. value += char;
  8011. body += char;
  8012. if (isCharSet) {
  8013. if (char === "]") {
  8014. if (this.peek(index - 1) !== "\\" || this.peek(index - 2) === "\\") {
  8015. isCharSet = false;
  8016. }
  8017. }
  8018. if (char === "\\") {
  8019. index += 1;
  8020. char = this.peek(index);
  8021. body += char;
  8022. value += char;
  8023. scanUnexpectedChars();
  8024. }
  8025. index += 1;
  8026. continue;
  8027. }
  8028. if (char === "\\") {
  8029. index += 1;
  8030. char = this.peek(index);
  8031. body += char;
  8032. value += char;
  8033. scanUnexpectedChars();
  8034. if (char === "/") {
  8035. index += 1;
  8036. continue;
  8037. }
  8038. if (char === "[") {
  8039. index += 1;
  8040. continue;
  8041. }
  8042. }
  8043. if (char === "[") {
  8044. isCharSet = true;
  8045. index += 1;
  8046. continue;
  8047. }
  8048. if (char === "/") {
  8049. body = body.substr(0, body.length - 1);
  8050. terminated = true;
  8051. index += 1;
  8052. break;
  8053. }
  8054. index += 1;
  8055. }
  8056. if (!terminated) {
  8057. this.trigger("error", {
  8058. code: "E015",
  8059. line: this.line,
  8060. character: this.from
  8061. });
  8062. return void this.trigger("fatal", {
  8063. line: this.line,
  8064. from: this.from
  8065. });
  8066. }
  8067. while (index < length) {
  8068. char = this.peek(index);
  8069. if (!/[gim]/.test(char)) {
  8070. break;
  8071. }
  8072. flags.push(char);
  8073. value += char;
  8074. index += 1;
  8075. }
  8076. try {
  8077. new RegExp(body, flags.join(""));
  8078. } catch (err) {
  8079. malformed = true;
  8080. this.trigger("error", {
  8081. code: "E016",
  8082. line: this.line,
  8083. character: this.char,
  8084. data: [ err.message ] // Platform dependent!
  8085. });
  8086. }
  8087. return {
  8088. type: Token.RegExp,
  8089. value: value,
  8090. flags: flags,
  8091. isMalformed: malformed
  8092. };
  8093. },
  8094. scanNonBreakingSpaces: function() {
  8095. return state.option.nonbsp ?
  8096. this.input.search(/(\u00A0)/) : -1;
  8097. },
  8098. scanUnsafeChars: function() {
  8099. return this.input.search(reg.unsafeChars);
  8100. },
  8101. next: function(checks) {
  8102. this.from = this.char;
  8103. var start;
  8104. if (/\s/.test(this.peek())) {
  8105. start = this.char;
  8106. while (/\s/.test(this.peek())) {
  8107. this.from += 1;
  8108. this.skip();
  8109. }
  8110. }
  8111. var match = this.scanComments() ||
  8112. this.scanStringLiteral(checks) ||
  8113. this.scanTemplateLiteral(checks);
  8114. if (match) {
  8115. return match;
  8116. }
  8117. match =
  8118. this.scanRegExp() ||
  8119. this.scanPunctuator() ||
  8120. this.scanKeyword() ||
  8121. this.scanIdentifier() ||
  8122. this.scanNumericLiteral();
  8123. if (match) {
  8124. this.skip(match.tokenLength || match.value.length);
  8125. return match;
  8126. }
  8127. return null;
  8128. },
  8129. nextLine: function() {
  8130. var char;
  8131. if (this.line >= this.getLines().length) {
  8132. return false;
  8133. }
  8134. this.input = this.getLines()[this.line];
  8135. this.line += 1;
  8136. this.char = 1;
  8137. this.from = 1;
  8138. var inputTrimmed = this.input.trim();
  8139. var startsWith = function() {
  8140. return _.some(arguments, function(prefix) {
  8141. return inputTrimmed.indexOf(prefix) === 0;
  8142. });
  8143. };
  8144. var endsWith = function() {
  8145. return _.some(arguments, function(suffix) {
  8146. return inputTrimmed.indexOf(suffix, inputTrimmed.length - suffix.length) !== -1;
  8147. });
  8148. };
  8149. if (this.ignoringLinterErrors === true) {
  8150. if (!startsWith("/*", "//") && !(this.inComment && endsWith("*/"))) {
  8151. this.input = "";
  8152. }
  8153. }
  8154. char = this.scanNonBreakingSpaces();
  8155. if (char >= 0) {
  8156. this.trigger("warning", { code: "W125", line: this.line, character: char + 1 });
  8157. }
  8158. this.input = this.input.replace(/\t/g, state.tab);
  8159. char = this.scanUnsafeChars();
  8160. if (char >= 0) {
  8161. this.trigger("warning", { code: "W100", line: this.line, character: char });
  8162. }
  8163. if (!this.ignoringLinterErrors && state.option.maxlen &&
  8164. state.option.maxlen < this.input.length) {
  8165. var inComment = this.inComment ||
  8166. startsWith.call(inputTrimmed, "//") ||
  8167. startsWith.call(inputTrimmed, "/*");
  8168. var shouldTriggerError = !inComment || !reg.maxlenException.test(inputTrimmed);
  8169. if (shouldTriggerError) {
  8170. this.trigger("warning", { code: "W101", line: this.line, character: this.input.length });
  8171. }
  8172. }
  8173. return true;
  8174. },
  8175. start: function() {
  8176. this.nextLine();
  8177. },
  8178. token: function() {
  8179. var checks = asyncTrigger();
  8180. var token;
  8181. function isReserved(token, isProperty) {
  8182. if (!token.reserved) {
  8183. return false;
  8184. }
  8185. var meta = token.meta;
  8186. if (meta && meta.isFutureReservedWord && state.inES5()) {
  8187. if (!meta.es5) {
  8188. return false;
  8189. }
  8190. if (meta.strictOnly) {
  8191. if (!state.option.strict && !state.isStrict()) {
  8192. return false;
  8193. }
  8194. }
  8195. if (isProperty) {
  8196. return false;
  8197. }
  8198. }
  8199. return true;
  8200. }
  8201. var create = function(type, value, isProperty, token) {
  8202. var obj;
  8203. if (type !== "(endline)" && type !== "(end)") {
  8204. this.prereg = false;
  8205. }
  8206. if (type === "(punctuator)") {
  8207. switch (value) {
  8208. case ".":
  8209. case ")":
  8210. case "~":
  8211. case "#":
  8212. case "]":
  8213. case "++":
  8214. case "--":
  8215. this.prereg = false;
  8216. break;
  8217. default:
  8218. this.prereg = true;
  8219. }
  8220. obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
  8221. }
  8222. if (type === "(identifier)") {
  8223. if (value === "return" || value === "case" || value === "typeof") {
  8224. this.prereg = true;
  8225. }
  8226. if (_.has(state.syntax, value)) {
  8227. obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
  8228. if (!isReserved(obj, isProperty && type === "(identifier)")) {
  8229. obj = null;
  8230. }
  8231. }
  8232. }
  8233. if (!obj) {
  8234. obj = Object.create(state.syntax[type]);
  8235. }
  8236. obj.identifier = (type === "(identifier)");
  8237. obj.type = obj.type || type;
  8238. obj.value = value;
  8239. obj.line = this.line;
  8240. obj.character = this.char;
  8241. obj.from = this.from;
  8242. if (obj.identifier && token) obj.raw_text = token.text || token.value;
  8243. if (token && token.startLine && token.startLine !== this.line) {
  8244. obj.startLine = token.startLine;
  8245. }
  8246. if (token && token.context) {
  8247. obj.context = token.context;
  8248. }
  8249. if (token && token.depth) {
  8250. obj.depth = token.depth;
  8251. }
  8252. if (token && token.isUnclosed) {
  8253. obj.isUnclosed = token.isUnclosed;
  8254. }
  8255. if (isProperty && obj.identifier) {
  8256. obj.isProperty = isProperty;
  8257. }
  8258. obj.check = checks.check;
  8259. return obj;
  8260. }.bind(this);
  8261. for (;;) {
  8262. if (!this.input.length) {
  8263. if (this.nextLine()) {
  8264. return create("(endline)", "");
  8265. }
  8266. if (this.exhausted) {
  8267. return null;
  8268. }
  8269. this.exhausted = true;
  8270. return create("(end)", "");
  8271. }
  8272. token = this.next(checks);
  8273. if (!token) {
  8274. if (this.input.length) {
  8275. this.trigger("error", {
  8276. code: "E024",
  8277. line: this.line,
  8278. character: this.char,
  8279. data: [ this.peek() ]
  8280. });
  8281. this.input = "";
  8282. }
  8283. continue;
  8284. }
  8285. switch (token.type) {
  8286. case Token.StringLiteral:
  8287. this.triggerAsync("String", {
  8288. line: this.line,
  8289. char: this.char,
  8290. from: this.from,
  8291. startLine: token.startLine,
  8292. startChar: token.startChar,
  8293. value: token.value,
  8294. quote: token.quote
  8295. }, checks, function() { return true; });
  8296. return create("(string)", token.value, null, token);
  8297. case Token.TemplateHead:
  8298. this.trigger("TemplateHead", {
  8299. line: this.line,
  8300. char: this.char,
  8301. from: this.from,
  8302. startLine: token.startLine,
  8303. startChar: token.startChar,
  8304. value: token.value
  8305. });
  8306. return create("(template)", token.value, null, token);
  8307. case Token.TemplateMiddle:
  8308. this.trigger("TemplateMiddle", {
  8309. line: this.line,
  8310. char: this.char,
  8311. from: this.from,
  8312. startLine: token.startLine,
  8313. startChar: token.startChar,
  8314. value: token.value
  8315. });
  8316. return create("(template middle)", token.value, null, token);
  8317. case Token.TemplateTail:
  8318. this.trigger("TemplateTail", {
  8319. line: this.line,
  8320. char: this.char,
  8321. from: this.from,
  8322. startLine: token.startLine,
  8323. startChar: token.startChar,
  8324. value: token.value
  8325. });
  8326. return create("(template tail)", token.value, null, token);
  8327. case Token.NoSubstTemplate:
  8328. this.trigger("NoSubstTemplate", {
  8329. line: this.line,
  8330. char: this.char,
  8331. from: this.from,
  8332. startLine: token.startLine,
  8333. startChar: token.startChar,
  8334. value: token.value
  8335. });
  8336. return create("(no subst template)", token.value, null, token);
  8337. case Token.Identifier:
  8338. this.triggerAsync("Identifier", {
  8339. line: this.line,
  8340. char: this.char,
  8341. from: this.form,
  8342. name: token.value,
  8343. raw_name: token.text,
  8344. isProperty: state.tokens.curr.id === "."
  8345. }, checks, function() { return true; });
  8346. case Token.Keyword:
  8347. case Token.NullLiteral:
  8348. case Token.BooleanLiteral:
  8349. return create("(identifier)", token.value, state.tokens.curr.id === ".", token);
  8350. case Token.NumericLiteral:
  8351. if (token.isMalformed) {
  8352. this.trigger("warning", {
  8353. code: "W045",
  8354. line: this.line,
  8355. character: this.char,
  8356. data: [ token.value ]
  8357. });
  8358. }
  8359. this.triggerAsync("warning", {
  8360. code: "W114",
  8361. line: this.line,
  8362. character: this.char,
  8363. data: [ "0x-" ]
  8364. }, checks, function() { return token.base === 16 && state.jsonMode; });
  8365. this.triggerAsync("warning", {
  8366. code: "W115",
  8367. line: this.line,
  8368. character: this.char
  8369. }, checks, function() {
  8370. return state.isStrict() && token.base === 8 && token.isLegacy;
  8371. });
  8372. this.trigger("Number", {
  8373. line: this.line,
  8374. char: this.char,
  8375. from: this.from,
  8376. value: token.value,
  8377. base: token.base,
  8378. isMalformed: token.malformed
  8379. });
  8380. return create("(number)", token.value);
  8381. case Token.RegExp:
  8382. return create("(regexp)", token.value);
  8383. case Token.Comment:
  8384. state.tokens.curr.comment = true;
  8385. if (token.isSpecial) {
  8386. return {
  8387. id: '(comment)',
  8388. value: token.value,
  8389. body: token.body,
  8390. type: token.commentType,
  8391. isSpecial: token.isSpecial,
  8392. line: this.line,
  8393. character: this.char,
  8394. from: this.from
  8395. };
  8396. }
  8397. break;
  8398. case "":
  8399. break;
  8400. default:
  8401. return create("(punctuator)", token.value);
  8402. }
  8403. }
  8404. }
  8405. };
  8406. exports.Lexer = Lexer;
  8407. exports.Context = Context;
  8408. },{"../data/ascii-identifier-data.js":"/node_modules/jshint/data/ascii-identifier-data.js","../lodash":"/node_modules/jshint/lodash.js","./reg.js":"/node_modules/jshint/src/reg.js","./state.js":"/node_modules/jshint/src/state.js","events":"/node_modules/browserify/node_modules/events/events.js"}],"/node_modules/jshint/src/messages.js":[function(_dereq_,module,exports){
  8409. "use strict";
  8410. var _ = _dereq_("../lodash");
  8411. var errors = {
  8412. E001: "Bad option: '{a}'.",
  8413. E002: "Bad option value.",
  8414. E003: "Expected a JSON value.",
  8415. E004: "Input is neither a string nor an array of strings.",
  8416. E005: "Input is empty.",
  8417. E006: "Unexpected early end of program.",
  8418. E007: "Missing \"use strict\" statement.",
  8419. E008: "Strict violation.",
  8420. E009: "Option 'validthis' can't be used in a global scope.",
  8421. E010: "'with' is not allowed in strict mode.",
  8422. E011: "'{a}' has already been declared.",
  8423. E012: "const '{a}' is initialized to 'undefined'.",
  8424. E013: "Attempting to override '{a}' which is a constant.",
  8425. E014: "A regular expression literal can be confused with '/='.",
  8426. E015: "Unclosed regular expression.",
  8427. E016: "Invalid regular expression.",
  8428. E017: "Unclosed comment.",
  8429. E018: "Unbegun comment.",
  8430. E019: "Unmatched '{a}'.",
  8431. E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
  8432. E021: "Expected '{a}' and instead saw '{b}'.",
  8433. E022: "Line breaking error '{a}'.",
  8434. E023: "Missing '{a}'.",
  8435. E024: "Unexpected '{a}'.",
  8436. E025: "Missing ':' on a case clause.",
  8437. E026: "Missing '}' to match '{' from line {a}.",
  8438. E027: "Missing ']' to match '[' from line {a}.",
  8439. E028: "Illegal comma.",
  8440. E029: "Unclosed string.",
  8441. E030: "Expected an identifier and instead saw '{a}'.",
  8442. E031: "Bad assignment.", // FIXME: Rephrase
  8443. E032: "Expected a small integer or 'false' and instead saw '{a}'.",
  8444. E033: "Expected an operator and instead saw '{a}'.",
  8445. E034: "get/set are ES5 features.",
  8446. E035: "Missing property name.",
  8447. E036: "Expected to see a statement and instead saw a block.",
  8448. E037: null,
  8449. E038: null,
  8450. E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.",
  8451. E040: "Each value should have its own case label.",
  8452. E041: "Unrecoverable syntax error.",
  8453. E042: "Stopping.",
  8454. E043: "Too many errors.",
  8455. E044: null,
  8456. E045: "Invalid for each loop.",
  8457. E046: "A yield statement shall be within a generator function (with syntax: `function*`)",
  8458. E047: null,
  8459. E048: "{a} declaration not directly within block.",
  8460. E049: "A {a} cannot be named '{b}'.",
  8461. E050: "Mozilla requires the yield expression to be parenthesized here.",
  8462. E051: null,
  8463. E052: "Unclosed template literal.",
  8464. E053: "Export declaration must be in global scope.",
  8465. E054: "Class properties must be methods. Expected '(' but instead saw '{a}'.",
  8466. E055: "The '{a}' option cannot be set after any executable code.",
  8467. E056: "'{a}' was used before it was declared, which is illegal for '{b}' variables.",
  8468. E057: "Invalid meta property: '{a}.{b}'.",
  8469. E058: "Missing semicolon."
  8470. };
  8471. var warnings = {
  8472. W001: "'hasOwnProperty' is a really bad name.",
  8473. W002: "Value of '{a}' may be overwritten in IE 8 and earlier.",
  8474. W003: "'{a}' was used before it was defined.",
  8475. W004: "'{a}' is already defined.",
  8476. W005: "A dot following a number can be confused with a decimal point.",
  8477. W006: "Confusing minuses.",
  8478. W007: "Confusing plusses.",
  8479. W008: "A leading decimal point can be confused with a dot: '{a}'.",
  8480. W009: "The array literal notation [] is preferable.",
  8481. W010: "The object literal notation {} is preferable.",
  8482. W011: null,
  8483. W012: null,
  8484. W013: null,
  8485. W014: "Bad line breaking before '{a}'.",
  8486. W015: null,
  8487. W016: "Unexpected use of '{a}'.",
  8488. W017: "Bad operand.",
  8489. W018: "Confusing use of '{a}'.",
  8490. W019: "Use the isNaN function to compare with NaN.",
  8491. W020: "Read only.",
  8492. W021: "Reassignment of '{a}', which is is a {b}. " +
  8493. "Use 'var' or 'let' to declare bindings that may change.",
  8494. W022: "Do not assign to the exception parameter.",
  8495. W023: "Expected an identifier in an assignment and instead saw a function invocation.",
  8496. W024: "Expected an identifier and instead saw '{a}' (a reserved word).",
  8497. W025: "Missing name in function declaration.",
  8498. W026: "Inner functions should be listed at the top of the outer function.",
  8499. W027: "Unreachable '{a}' after '{b}'.",
  8500. W028: "Label '{a}' on {b} statement.",
  8501. W030: "Expected an assignment or function call and instead saw an expression.",
  8502. W031: "Do not use 'new' for side effects.",
  8503. W032: "Unnecessary semicolon.",
  8504. W033: "Missing semicolon.",
  8505. W034: "Unnecessary directive \"{a}\".",
  8506. W035: "Empty block.",
  8507. W036: "Unexpected /*member '{a}'.",
  8508. W037: "'{a}' is a statement label.",
  8509. W038: "'{a}' used out of scope.",
  8510. W039: "'{a}' is not allowed.",
  8511. W040: "Possible strict violation.",
  8512. W041: "Use '{a}' to compare with '{b}'.",
  8513. W042: "Avoid EOL escaping.",
  8514. W043: "Bad escaping of EOL. Use option multistr if needed.",
  8515. W044: "Bad or unnecessary escaping.", /* TODO(caitp): remove W044 */
  8516. W045: "Bad number '{a}'.",
  8517. W046: "Don't use extra leading zeros '{a}'.",
  8518. W047: "A trailing decimal point can be confused with a dot: '{a}'.",
  8519. W048: "Unexpected control character in regular expression.",
  8520. W049: "Unexpected escaped character '{a}' in regular expression.",
  8521. W050: "JavaScript URL.",
  8522. W051: "Variables should not be deleted.",
  8523. W052: "Unexpected '{a}'.",
  8524. W053: "Do not use {a} as a constructor.",
  8525. W054: "The Function constructor is a form of eval.",
  8526. W055: "A constructor name should start with an uppercase letter.",
  8527. W056: "Bad constructor.",
  8528. W057: "Weird construction. Is 'new' necessary?",
  8529. W058: "Missing '()' invoking a constructor.",
  8530. W059: "Avoid arguments.{a}.",
  8531. W060: "document.write can be a form of eval.",
  8532. W061: "eval can be harmful.",
  8533. W062: "Wrap an immediate function invocation in parens " +
  8534. "to assist the reader in understanding that the expression " +
  8535. "is the result of a function, and not the function itself.",
  8536. W063: "Math is not a function.",
  8537. W064: "Missing 'new' prefix when invoking a constructor.",
  8538. W065: "Missing radix parameter.",
  8539. W066: "Implied eval. Consider passing a function instead of a string.",
  8540. W067: "Bad invocation.",
  8541. W068: "Wrapping non-IIFE function literals in parens is unnecessary.",
  8542. W069: "['{a}'] is better written in dot notation.",
  8543. W070: "Extra comma. (it breaks older versions of IE)",
  8544. W071: "This function has too many statements. ({a})",
  8545. W072: "This function has too many parameters. ({a})",
  8546. W073: "Blocks are nested too deeply. ({a})",
  8547. W074: "This function's cyclomatic complexity is too high. ({a})",
  8548. W075: "Duplicate {a} '{b}'.",
  8549. W076: "Unexpected parameter '{a}' in get {b} function.",
  8550. W077: "Expected a single parameter in set {a} function.",
  8551. W078: "Setter is defined without getter.",
  8552. W079: "Redefinition of '{a}'.",
  8553. W080: "It's not necessary to initialize '{a}' to 'undefined'.",
  8554. W081: null,
  8555. W082: "Function declarations should not be placed in blocks. " +
  8556. "Use a function expression or move the statement to the top of " +
  8557. "the outer function.",
  8558. W083: "Don't make functions within a loop.",
  8559. W084: "Assignment in conditional expression",
  8560. W085: "Don't use 'with'.",
  8561. W086: "Expected a 'break' statement before '{a}'.",
  8562. W087: "Forgotten 'debugger' statement?",
  8563. W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.",
  8564. W089: "The body of a for in should be wrapped in an if statement to filter " +
  8565. "unwanted properties from the prototype.",
  8566. W090: "'{a}' is not a statement label.",
  8567. W091: null,
  8568. W093: "Did you mean to return a conditional instead of an assignment?",
  8569. W094: "Unexpected comma.",
  8570. W095: "Expected a string and instead saw {a}.",
  8571. W096: "The '{a}' key may produce unexpected results.",
  8572. W097: "Use the function form of \"use strict\".",
  8573. W098: "'{a}' is defined but never used.",
  8574. W099: null,
  8575. W100: "This character may get silently deleted by one or more browsers.",
  8576. W101: "Line is too long.",
  8577. W102: null,
  8578. W103: "The '{a}' property is deprecated.",
  8579. W104: "'{a}' is available in ES{b} (use 'esversion: {b}') or Mozilla JS extensions (use moz).",
  8580. W105: "Unexpected {a} in '{b}'.",
  8581. W106: "Identifier '{a}' is not in camel case.",
  8582. W107: "Script URL.",
  8583. W108: "Strings must use doublequote.",
  8584. W109: "Strings must use singlequote.",
  8585. W110: "Mixed double and single quotes.",
  8586. W112: "Unclosed string.",
  8587. W113: "Control character in string: {a}.",
  8588. W114: "Avoid {a}.",
  8589. W115: "Octal literals are not allowed in strict mode.",
  8590. W116: "Expected '{a}' and instead saw '{b}'.",
  8591. W117: "'{a}' is not defined.",
  8592. W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).",
  8593. W119: "'{a}' is only available in ES{b} (use 'esversion: {b}').",
  8594. W120: "You might be leaking a variable ({a}) here.",
  8595. W121: "Extending prototype of native object: '{a}'.",
  8596. W122: "Invalid typeof value '{a}'",
  8597. W123: "'{a}' is already defined in outer scope.",
  8598. W124: "A generator function shall contain a yield statement.",
  8599. W125: "This line contains non-breaking spaces: http://jshint.com/doc/options/#nonbsp",
  8600. W126: "Unnecessary grouping operator.",
  8601. W127: "Unexpected use of a comma operator.",
  8602. W128: "Empty array elements require elision=true.",
  8603. W129: "'{a}' is defined in a future version of JavaScript. Use a " +
  8604. "different variable name to avoid migration issues.",
  8605. W130: "Invalid element after rest element.",
  8606. W131: "Invalid parameter after rest parameter.",
  8607. W132: "`var` declarations are forbidden. Use `let` or `const` instead.",
  8608. W133: "Invalid for-{a} loop left-hand-side: {b}.",
  8609. W134: "The '{a}' option is only available when linting ECMAScript {b} code.",
  8610. W135: "{a} may not be supported by non-browser environments.",
  8611. W136: "'{a}' must be in function scope.",
  8612. W137: "Empty destructuring.",
  8613. W138: "Regular parameters should not come after default parameters."
  8614. };
  8615. var info = {
  8616. I001: "Comma warnings can be turned off with 'laxcomma'.",
  8617. I002: null,
  8618. I003: "ES5 option is now set per default"
  8619. };
  8620. exports.errors = {};
  8621. exports.warnings = {};
  8622. exports.info = {};
  8623. _.each(errors, function(desc, code) {
  8624. exports.errors[code] = { code: code, desc: desc };
  8625. });
  8626. _.each(warnings, function(desc, code) {
  8627. exports.warnings[code] = { code: code, desc: desc };
  8628. });
  8629. _.each(info, function(desc, code) {
  8630. exports.info[code] = { code: code, desc: desc };
  8631. });
  8632. },{"../lodash":"/node_modules/jshint/lodash.js"}],"/node_modules/jshint/src/name-stack.js":[function(_dereq_,module,exports){
  8633. "use strict";
  8634. function NameStack() {
  8635. this._stack = [];
  8636. }
  8637. Object.defineProperty(NameStack.prototype, "length", {
  8638. get: function() {
  8639. return this._stack.length;
  8640. }
  8641. });
  8642. NameStack.prototype.push = function() {
  8643. this._stack.push(null);
  8644. };
  8645. NameStack.prototype.pop = function() {
  8646. this._stack.pop();
  8647. };
  8648. NameStack.prototype.set = function(token) {
  8649. this._stack[this.length - 1] = token;
  8650. };
  8651. NameStack.prototype.infer = function() {
  8652. var nameToken = this._stack[this.length - 1];
  8653. var prefix = "";
  8654. var type;
  8655. if (!nameToken || nameToken.type === "class") {
  8656. nameToken = this._stack[this.length - 2];
  8657. }
  8658. if (!nameToken) {
  8659. return "(empty)";
  8660. }
  8661. type = nameToken.type;
  8662. if (type !== "(string)" && type !== "(number)" && type !== "(identifier)" && type !== "default") {
  8663. return "(expression)";
  8664. }
  8665. if (nameToken.accessorType) {
  8666. prefix = nameToken.accessorType + " ";
  8667. }
  8668. return prefix + nameToken.value;
  8669. };
  8670. module.exports = NameStack;
  8671. },{}],"/node_modules/jshint/src/options.js":[function(_dereq_,module,exports){
  8672. "use strict";
  8673. exports.bool = {
  8674. enforcing: {
  8675. bitwise : true,
  8676. freeze : true,
  8677. camelcase : true,
  8678. curly : true,
  8679. eqeqeq : true,
  8680. futurehostile: true,
  8681. notypeof : true,
  8682. es3 : true,
  8683. es5 : true,
  8684. forin : true,
  8685. funcscope : true,
  8686. immed : true,
  8687. iterator : true,
  8688. newcap : true,
  8689. noarg : true,
  8690. nocomma : true,
  8691. noempty : true,
  8692. nonbsp : true,
  8693. nonew : true,
  8694. undef : true,
  8695. singleGroups: false,
  8696. varstmt: false,
  8697. enforceall : false
  8698. },
  8699. relaxing: {
  8700. asi : true,
  8701. multistr : true,
  8702. debug : true,
  8703. boss : true,
  8704. evil : true,
  8705. globalstrict: true,
  8706. plusplus : true,
  8707. proto : true,
  8708. scripturl : true,
  8709. sub : true,
  8710. supernew : true,
  8711. laxbreak : true,
  8712. laxcomma : true,
  8713. validthis : true,
  8714. withstmt : true,
  8715. moz : true,
  8716. noyield : true,
  8717. eqnull : true,
  8718. lastsemic : true,
  8719. loopfunc : true,
  8720. expr : true,
  8721. esnext : true,
  8722. elision : true,
  8723. },
  8724. environments: {
  8725. mootools : true,
  8726. couch : true,
  8727. jasmine : true,
  8728. jquery : true,
  8729. node : true,
  8730. qunit : true,
  8731. rhino : true,
  8732. shelljs : true,
  8733. prototypejs : true,
  8734. yui : true,
  8735. mocha : true,
  8736. module : true,
  8737. wsh : true,
  8738. worker : true,
  8739. nonstandard : true,
  8740. browser : true,
  8741. browserify : true,
  8742. devel : true,
  8743. dojo : true,
  8744. typed : true,
  8745. phantom : true
  8746. },
  8747. obsolete: {
  8748. onecase : true, // if one case switch statements should be allowed
  8749. regexp : true, // if the . should not be allowed in regexp literals
  8750. regexdash : true // if unescaped first/last dash (-) inside brackets
  8751. }
  8752. };
  8753. exports.val = {
  8754. maxlen : false,
  8755. indent : false,
  8756. maxerr : false,
  8757. predef : false,
  8758. globals : false,
  8759. quotmark : false,
  8760. scope : false,
  8761. maxstatements: false,
  8762. maxdepth : false,
  8763. maxparams : false,
  8764. maxcomplexity: false,
  8765. shadow : false,
  8766. strict : true,
  8767. unused : true,
  8768. latedef : false,
  8769. ignore : false, // start/end ignoring lines of code, bypassing the lexer
  8770. ignoreDelimiters: false, // array of start/end delimiters used to ignore
  8771. esversion: 5
  8772. };
  8773. exports.inverted = {
  8774. bitwise : true,
  8775. forin : true,
  8776. newcap : true,
  8777. plusplus: true,
  8778. regexp : true,
  8779. undef : true,
  8780. eqeqeq : true,
  8781. strict : true
  8782. };
  8783. exports.validNames = Object.keys(exports.val)
  8784. .concat(Object.keys(exports.bool.relaxing))
  8785. .concat(Object.keys(exports.bool.enforcing))
  8786. .concat(Object.keys(exports.bool.obsolete))
  8787. .concat(Object.keys(exports.bool.environments));
  8788. exports.renamed = {
  8789. eqeq : "eqeqeq",
  8790. windows: "wsh",
  8791. sloppy : "strict"
  8792. };
  8793. exports.removed = {
  8794. nomen: true,
  8795. onevar: true,
  8796. passfail: true,
  8797. white: true,
  8798. gcl: true,
  8799. smarttabs: true,
  8800. trailing: true
  8801. };
  8802. exports.noenforceall = {
  8803. varstmt: true,
  8804. strict: true
  8805. };
  8806. },{}],"/node_modules/jshint/src/reg.js":[function(_dereq_,module,exports){
  8807. "use strict";
  8808. exports.unsafeString =
  8809. /@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i;
  8810. exports.unsafeChars =
  8811. /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
  8812. exports.needEsc =
  8813. /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
  8814. exports.needEscGlobal =
  8815. /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
  8816. exports.starSlash = /\*\//;
  8817. exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
  8818. exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
  8819. exports.fallsThrough = /^\s*falls?\sthrough\s*$/;
  8820. exports.maxlenException = /^(?:(?:\/\/|\/\*|\*) ?)?[^ ]+$/;
  8821. },{}],"/node_modules/jshint/src/scope-manager.js":[function(_dereq_,module,exports){
  8822. "use strict";
  8823. var _ = _dereq_("../lodash");
  8824. var events = _dereq_("events");
  8825. var marker = {};
  8826. var scopeManager = function(state, predefined, exported, declared) {
  8827. var _current;
  8828. var _scopeStack = [];
  8829. function _newScope(type) {
  8830. _current = {
  8831. "(labels)": Object.create(null),
  8832. "(usages)": Object.create(null),
  8833. "(breakLabels)": Object.create(null),
  8834. "(parent)": _current,
  8835. "(type)": type,
  8836. "(params)": (type === "functionparams" || type === "catchparams") ? [] : null
  8837. };
  8838. _scopeStack.push(_current);
  8839. }
  8840. _newScope("global");
  8841. _current["(predefined)"] = predefined;
  8842. var _currentFunctBody = _current; // this is the block after the params = function
  8843. var usedPredefinedAndGlobals = Object.create(null);
  8844. var impliedGlobals = Object.create(null);
  8845. var unuseds = [];
  8846. var emitter = new events.EventEmitter();
  8847. function warning(code, token) {
  8848. emitter.emit("warning", {
  8849. code: code,
  8850. token: token,
  8851. data: _.slice(arguments, 2)
  8852. });
  8853. }
  8854. function error(code, token) {
  8855. emitter.emit("warning", {
  8856. code: code,
  8857. token: token,
  8858. data: _.slice(arguments, 2)
  8859. });
  8860. }
  8861. function _setupUsages(labelName) {
  8862. if (!_current["(usages)"][labelName]) {
  8863. _current["(usages)"][labelName] = {
  8864. "(modified)": [],
  8865. "(reassigned)": [],
  8866. "(tokens)": []
  8867. };
  8868. }
  8869. }
  8870. var _getUnusedOption = function(unused_opt) {
  8871. if (unused_opt === undefined) {
  8872. unused_opt = state.option.unused;
  8873. }
  8874. if (unused_opt === true) {
  8875. unused_opt = "last-param";
  8876. }
  8877. return unused_opt;
  8878. };
  8879. var _warnUnused = function(name, tkn, type, unused_opt) {
  8880. var line = tkn.line;
  8881. var chr = tkn.from;
  8882. var raw_name = tkn.raw_text || name;
  8883. unused_opt = _getUnusedOption(unused_opt);
  8884. var warnable_types = {
  8885. "vars": ["var"],
  8886. "last-param": ["var", "param"],
  8887. "strict": ["var", "param", "last-param"]
  8888. };
  8889. if (unused_opt) {
  8890. if (warnable_types[unused_opt] && warnable_types[unused_opt].indexOf(type) !== -1) {
  8891. warning("W098", { line: line, from: chr }, raw_name);
  8892. }
  8893. }
  8894. if (unused_opt || type === "var") {
  8895. unuseds.push({
  8896. name: name,
  8897. line: line,
  8898. character: chr
  8899. });
  8900. }
  8901. };
  8902. function _checkForUnused() {
  8903. if (_current["(type)"] === "functionparams") {
  8904. _checkParams();
  8905. return;
  8906. }
  8907. var curentLabels = _current["(labels)"];
  8908. for (var labelName in curentLabels) {
  8909. if (curentLabels[labelName]) {
  8910. if (curentLabels[labelName]["(type)"] !== "exception" &&
  8911. curentLabels[labelName]["(unused)"]) {
  8912. _warnUnused(labelName, curentLabels[labelName]["(token)"], "var");
  8913. }
  8914. }
  8915. }
  8916. }
  8917. function _checkParams() {
  8918. var params = _current["(params)"];
  8919. if (!params) {
  8920. return;
  8921. }
  8922. var param = params.pop();
  8923. var unused_opt;
  8924. while (param) {
  8925. var label = _current["(labels)"][param];
  8926. unused_opt = _getUnusedOption(state.funct["(unusedOption)"]);
  8927. if (param === "undefined")
  8928. return;
  8929. if (label["(unused)"]) {
  8930. _warnUnused(param, label["(token)"], "param", state.funct["(unusedOption)"]);
  8931. } else if (unused_opt === "last-param") {
  8932. return;
  8933. }
  8934. param = params.pop();
  8935. }
  8936. }
  8937. function _getLabel(labelName) {
  8938. for (var i = _scopeStack.length - 1 ; i >= 0; --i) {
  8939. var scopeLabels = _scopeStack[i]["(labels)"];
  8940. if (scopeLabels[labelName]) {
  8941. return scopeLabels;
  8942. }
  8943. }
  8944. }
  8945. function usedSoFarInCurrentFunction(labelName) {
  8946. for (var i = _scopeStack.length - 1; i >= 0; i--) {
  8947. var current = _scopeStack[i];
  8948. if (current["(usages)"][labelName]) {
  8949. return current["(usages)"][labelName];
  8950. }
  8951. if (current === _currentFunctBody) {
  8952. break;
  8953. }
  8954. }
  8955. return false;
  8956. }
  8957. function _checkOuterShadow(labelName, token) {
  8958. if (state.option.shadow !== "outer") {
  8959. return;
  8960. }
  8961. var isGlobal = _currentFunctBody["(type)"] === "global",
  8962. isNewFunction = _current["(type)"] === "functionparams";
  8963. var outsideCurrentFunction = !isGlobal;
  8964. for (var i = 0; i < _scopeStack.length; i++) {
  8965. var stackItem = _scopeStack[i];
  8966. if (!isNewFunction && _scopeStack[i + 1] === _currentFunctBody) {
  8967. outsideCurrentFunction = false;
  8968. }
  8969. if (outsideCurrentFunction && stackItem["(labels)"][labelName]) {
  8970. warning("W123", token, labelName);
  8971. }
  8972. if (stackItem["(breakLabels)"][labelName]) {
  8973. warning("W123", token, labelName);
  8974. }
  8975. }
  8976. }
  8977. function _latedefWarning(type, labelName, token) {
  8978. if (state.option.latedef) {
  8979. if ((state.option.latedef === true && type === "function") ||
  8980. type !== "function") {
  8981. warning("W003", token, labelName);
  8982. }
  8983. }
  8984. }
  8985. var scopeManagerInst = {
  8986. on: function(names, listener) {
  8987. names.split(" ").forEach(function(name) {
  8988. emitter.on(name, listener);
  8989. });
  8990. },
  8991. isPredefined: function(labelName) {
  8992. return !this.has(labelName) && _.has(_scopeStack[0]["(predefined)"], labelName);
  8993. },
  8994. stack: function(type) {
  8995. var previousScope = _current;
  8996. _newScope(type);
  8997. if (!type && previousScope["(type)"] === "functionparams") {
  8998. _current["(isFuncBody)"] = true;
  8999. _current["(context)"] = _currentFunctBody;
  9000. _currentFunctBody = _current;
  9001. }
  9002. },
  9003. unstack: function() {
  9004. var subScope = _scopeStack.length > 1 ? _scopeStack[_scopeStack.length - 2] : null;
  9005. var isUnstackingFunctionBody = _current === _currentFunctBody,
  9006. isUnstackingFunctionParams = _current["(type)"] === "functionparams",
  9007. isUnstackingFunctionOuter = _current["(type)"] === "functionouter";
  9008. var i, j;
  9009. var currentUsages = _current["(usages)"];
  9010. var currentLabels = _current["(labels)"];
  9011. var usedLabelNameList = Object.keys(currentUsages);
  9012. if (currentUsages.__proto__ && usedLabelNameList.indexOf("__proto__") === -1) {
  9013. usedLabelNameList.push("__proto__");
  9014. }
  9015. for (i = 0; i < usedLabelNameList.length; i++) {
  9016. var usedLabelName = usedLabelNameList[i];
  9017. var usage = currentUsages[usedLabelName];
  9018. var usedLabel = currentLabels[usedLabelName];
  9019. if (usedLabel) {
  9020. var usedLabelType = usedLabel["(type)"];
  9021. if (usedLabel["(useOutsideOfScope)"] && !state.option.funcscope) {
  9022. var usedTokens = usage["(tokens)"];
  9023. if (usedTokens) {
  9024. for (j = 0; j < usedTokens.length; j++) {
  9025. if (usedLabel["(function)"] === usedTokens[j]["(function)"]) {
  9026. error("W038", usedTokens[j], usedLabelName);
  9027. }
  9028. }
  9029. }
  9030. }
  9031. _current["(labels)"][usedLabelName]["(unused)"] = false;
  9032. if (usedLabelType === "const" && usage["(modified)"]) {
  9033. for (j = 0; j < usage["(modified)"].length; j++) {
  9034. error("E013", usage["(modified)"][j], usedLabelName);
  9035. }
  9036. }
  9037. if ((usedLabelType === "function" || usedLabelType === "class") &&
  9038. usage["(reassigned)"]) {
  9039. for (j = 0; j < usage["(reassigned)"].length; j++) {
  9040. error("W021", usage["(reassigned)"][j], usedLabelName, usedLabelType);
  9041. }
  9042. }
  9043. continue;
  9044. }
  9045. if (isUnstackingFunctionOuter) {
  9046. state.funct["(isCapturing)"] = true;
  9047. }
  9048. if (subScope) {
  9049. if (!subScope["(usages)"][usedLabelName]) {
  9050. subScope["(usages)"][usedLabelName] = usage;
  9051. if (isUnstackingFunctionBody) {
  9052. subScope["(usages)"][usedLabelName]["(onlyUsedSubFunction)"] = true;
  9053. }
  9054. } else {
  9055. var subScopeUsage = subScope["(usages)"][usedLabelName];
  9056. subScopeUsage["(modified)"] = subScopeUsage["(modified)"].concat(usage["(modified)"]);
  9057. subScopeUsage["(tokens)"] = subScopeUsage["(tokens)"].concat(usage["(tokens)"]);
  9058. subScopeUsage["(reassigned)"] =
  9059. subScopeUsage["(reassigned)"].concat(usage["(reassigned)"]);
  9060. subScopeUsage["(onlyUsedSubFunction)"] = false;
  9061. }
  9062. } else {
  9063. if (typeof _current["(predefined)"][usedLabelName] === "boolean") {
  9064. delete declared[usedLabelName];
  9065. usedPredefinedAndGlobals[usedLabelName] = marker;
  9066. if (_current["(predefined)"][usedLabelName] === false && usage["(reassigned)"]) {
  9067. for (j = 0; j < usage["(reassigned)"].length; j++) {
  9068. warning("W020", usage["(reassigned)"][j]);
  9069. }
  9070. }
  9071. }
  9072. else {
  9073. if (usage["(tokens)"]) {
  9074. for (j = 0; j < usage["(tokens)"].length; j++) {
  9075. var undefinedToken = usage["(tokens)"][j];
  9076. if (!undefinedToken.forgiveUndef) {
  9077. if (state.option.undef && !undefinedToken.ignoreUndef) {
  9078. warning("W117", undefinedToken, usedLabelName);
  9079. }
  9080. if (impliedGlobals[usedLabelName]) {
  9081. impliedGlobals[usedLabelName].line.push(undefinedToken.line);
  9082. } else {
  9083. impliedGlobals[usedLabelName] = {
  9084. name: usedLabelName,
  9085. line: [undefinedToken.line]
  9086. };
  9087. }
  9088. }
  9089. }
  9090. }
  9091. }
  9092. }
  9093. }
  9094. if (!subScope) {
  9095. Object.keys(declared)
  9096. .forEach(function(labelNotUsed) {
  9097. _warnUnused(labelNotUsed, declared[labelNotUsed], "var");
  9098. });
  9099. }
  9100. if (subScope && !isUnstackingFunctionBody &&
  9101. !isUnstackingFunctionParams && !isUnstackingFunctionOuter) {
  9102. var labelNames = Object.keys(currentLabels);
  9103. for (i = 0; i < labelNames.length; i++) {
  9104. var defLabelName = labelNames[i];
  9105. if (!currentLabels[defLabelName]["(blockscoped)"] &&
  9106. currentLabels[defLabelName]["(type)"] !== "exception" &&
  9107. !this.funct.has(defLabelName, { excludeCurrent: true })) {
  9108. subScope["(labels)"][defLabelName] = currentLabels[defLabelName];
  9109. if (_currentFunctBody["(type)"] !== "global") {
  9110. subScope["(labels)"][defLabelName]["(useOutsideOfScope)"] = true;
  9111. }
  9112. delete currentLabels[defLabelName];
  9113. }
  9114. }
  9115. }
  9116. _checkForUnused();
  9117. _scopeStack.pop();
  9118. if (isUnstackingFunctionBody) {
  9119. _currentFunctBody = _scopeStack[_.findLastIndex(_scopeStack, function(scope) {
  9120. return scope["(isFuncBody)"] || scope["(type)"] === "global";
  9121. })];
  9122. }
  9123. _current = subScope;
  9124. },
  9125. addParam: function(labelName, token, type) {
  9126. type = type || "param";
  9127. if (type === "exception") {
  9128. var previouslyDefinedLabelType = this.funct.labeltype(labelName);
  9129. if (previouslyDefinedLabelType && previouslyDefinedLabelType !== "exception") {
  9130. if (!state.option.node) {
  9131. warning("W002", state.tokens.next, labelName);
  9132. }
  9133. }
  9134. }
  9135. if (_.has(_current["(labels)"], labelName)) {
  9136. _current["(labels)"][labelName].duplicated = true;
  9137. } else {
  9138. _checkOuterShadow(labelName, token, type);
  9139. _current["(labels)"][labelName] = {
  9140. "(type)" : type,
  9141. "(token)": token,
  9142. "(unused)": true };
  9143. _current["(params)"].push(labelName);
  9144. }
  9145. if (_.has(_current["(usages)"], labelName)) {
  9146. var usage = _current["(usages)"][labelName];
  9147. if (usage["(onlyUsedSubFunction)"]) {
  9148. _latedefWarning(type, labelName, token);
  9149. } else {
  9150. warning("E056", token, labelName, type);
  9151. }
  9152. }
  9153. },
  9154. validateParams: function() {
  9155. if (_currentFunctBody["(type)"] === "global") {
  9156. return;
  9157. }
  9158. var isStrict = state.isStrict();
  9159. var currentFunctParamScope = _currentFunctBody["(parent)"];
  9160. if (!currentFunctParamScope["(params)"]) {
  9161. return;
  9162. }
  9163. currentFunctParamScope["(params)"].forEach(function(labelName) {
  9164. var label = currentFunctParamScope["(labels)"][labelName];
  9165. if (label && label.duplicated) {
  9166. if (isStrict) {
  9167. warning("E011", label["(token)"], labelName);
  9168. } else if (state.option.shadow !== true) {
  9169. warning("W004", label["(token)"], labelName);
  9170. }
  9171. }
  9172. });
  9173. },
  9174. getUsedOrDefinedGlobals: function() {
  9175. var list = Object.keys(usedPredefinedAndGlobals);
  9176. if (usedPredefinedAndGlobals.__proto__ === marker &&
  9177. list.indexOf("__proto__") === -1) {
  9178. list.push("__proto__");
  9179. }
  9180. return list;
  9181. },
  9182. getImpliedGlobals: function() {
  9183. var values = _.values(impliedGlobals);
  9184. var hasProto = false;
  9185. if (impliedGlobals.__proto__) {
  9186. hasProto = values.some(function(value) {
  9187. return value.name === "__proto__";
  9188. });
  9189. if (!hasProto) {
  9190. values.push(impliedGlobals.__proto__);
  9191. }
  9192. }
  9193. return values;
  9194. },
  9195. getUnuseds: function() {
  9196. return unuseds;
  9197. },
  9198. has: function(labelName) {
  9199. return Boolean(_getLabel(labelName));
  9200. },
  9201. labeltype: function(labelName) {
  9202. var scopeLabels = _getLabel(labelName);
  9203. if (scopeLabels) {
  9204. return scopeLabels[labelName]["(type)"];
  9205. }
  9206. return null;
  9207. },
  9208. addExported: function(labelName) {
  9209. var globalLabels = _scopeStack[0]["(labels)"];
  9210. if (_.has(declared, labelName)) {
  9211. delete declared[labelName];
  9212. } else if (_.has(globalLabels, labelName)) {
  9213. globalLabels[labelName]["(unused)"] = false;
  9214. } else {
  9215. for (var i = 1; i < _scopeStack.length; i++) {
  9216. var scope = _scopeStack[i];
  9217. if (!scope["(type)"]) {
  9218. if (_.has(scope["(labels)"], labelName) &&
  9219. !scope["(labels)"][labelName]["(blockscoped)"]) {
  9220. scope["(labels)"][labelName]["(unused)"] = false;
  9221. return;
  9222. }
  9223. } else {
  9224. break;
  9225. }
  9226. }
  9227. exported[labelName] = true;
  9228. }
  9229. },
  9230. setExported: function(labelName, token) {
  9231. this.block.use(labelName, token);
  9232. },
  9233. addlabel: function(labelName, opts) {
  9234. var type = opts.type;
  9235. var token = opts.token;
  9236. var isblockscoped = type === "let" || type === "const" || type === "class";
  9237. var isexported = (isblockscoped ? _current : _currentFunctBody)["(type)"] === "global" &&
  9238. _.has(exported, labelName);
  9239. _checkOuterShadow(labelName, token, type);
  9240. if (isblockscoped) {
  9241. var declaredInCurrentScope = _current["(labels)"][labelName];
  9242. if (!declaredInCurrentScope && _current === _currentFunctBody &&
  9243. _current["(type)"] !== "global") {
  9244. declaredInCurrentScope = !!_currentFunctBody["(parent)"]["(labels)"][labelName];
  9245. }
  9246. if (!declaredInCurrentScope && _current["(usages)"][labelName]) {
  9247. var usage = _current["(usages)"][labelName];
  9248. if (usage["(onlyUsedSubFunction)"]) {
  9249. _latedefWarning(type, labelName, token);
  9250. } else {
  9251. warning("E056", token, labelName, type);
  9252. }
  9253. }
  9254. if (declaredInCurrentScope) {
  9255. warning("E011", token, labelName);
  9256. }
  9257. else if (state.option.shadow === "outer") {
  9258. if (scopeManagerInst.funct.has(labelName)) {
  9259. warning("W004", token, labelName);
  9260. }
  9261. }
  9262. scopeManagerInst.block.add(labelName, type, token, !isexported);
  9263. } else {
  9264. var declaredInCurrentFunctionScope = scopeManagerInst.funct.has(labelName);
  9265. if (!declaredInCurrentFunctionScope && usedSoFarInCurrentFunction(labelName)) {
  9266. _latedefWarning(type, labelName, token);
  9267. }
  9268. if (scopeManagerInst.funct.has(labelName, { onlyBlockscoped: true })) {
  9269. warning("E011", token, labelName);
  9270. } else if (state.option.shadow !== true) {
  9271. if (declaredInCurrentFunctionScope && labelName !== "__proto__") {
  9272. if (_currentFunctBody["(type)"] !== "global") {
  9273. warning("W004", token, labelName);
  9274. }
  9275. }
  9276. }
  9277. scopeManagerInst.funct.add(labelName, type, token, !isexported);
  9278. if (_currentFunctBody["(type)"] === "global") {
  9279. usedPredefinedAndGlobals[labelName] = marker;
  9280. }
  9281. }
  9282. },
  9283. funct: {
  9284. labeltype: function(labelName, options) {
  9285. var onlyBlockscoped = options && options.onlyBlockscoped;
  9286. var excludeParams = options && options.excludeParams;
  9287. var currentScopeIndex = _scopeStack.length - (options && options.excludeCurrent ? 2 : 1);
  9288. for (var i = currentScopeIndex; i >= 0; i--) {
  9289. var current = _scopeStack[i];
  9290. if (current["(labels)"][labelName] &&
  9291. (!onlyBlockscoped || current["(labels)"][labelName]["(blockscoped)"])) {
  9292. return current["(labels)"][labelName]["(type)"];
  9293. }
  9294. var scopeCheck = excludeParams ? _scopeStack[ i - 1 ] : current;
  9295. if (scopeCheck && scopeCheck["(type)"] === "functionparams") {
  9296. return null;
  9297. }
  9298. }
  9299. return null;
  9300. },
  9301. hasBreakLabel: function(labelName) {
  9302. for (var i = _scopeStack.length - 1; i >= 0; i--) {
  9303. var current = _scopeStack[i];
  9304. if (current["(breakLabels)"][labelName]) {
  9305. return true;
  9306. }
  9307. if (current["(type)"] === "functionparams") {
  9308. return false;
  9309. }
  9310. }
  9311. return false;
  9312. },
  9313. has: function(labelName, options) {
  9314. return Boolean(this.labeltype(labelName, options));
  9315. },
  9316. add: function(labelName, type, tok, unused) {
  9317. _current["(labels)"][labelName] = {
  9318. "(type)" : type,
  9319. "(token)": tok,
  9320. "(blockscoped)": false,
  9321. "(function)": _currentFunctBody,
  9322. "(unused)": unused };
  9323. }
  9324. },
  9325. block: {
  9326. isGlobal: function() {
  9327. return _current["(type)"] === "global";
  9328. },
  9329. use: function(labelName, token) {
  9330. var paramScope = _currentFunctBody["(parent)"];
  9331. if (paramScope && paramScope["(labels)"][labelName] &&
  9332. paramScope["(labels)"][labelName]["(type)"] === "param") {
  9333. if (!scopeManagerInst.funct.has(labelName,
  9334. { excludeParams: true, onlyBlockscoped: true })) {
  9335. paramScope["(labels)"][labelName]["(unused)"] = false;
  9336. }
  9337. }
  9338. if (token && (state.ignored.W117 || state.option.undef === false)) {
  9339. token.ignoreUndef = true;
  9340. }
  9341. _setupUsages(labelName);
  9342. if (token) {
  9343. token["(function)"] = _currentFunctBody;
  9344. _current["(usages)"][labelName]["(tokens)"].push(token);
  9345. }
  9346. },
  9347. reassign: function(labelName, token) {
  9348. this.modify(labelName, token);
  9349. _current["(usages)"][labelName]["(reassigned)"].push(token);
  9350. },
  9351. modify: function(labelName, token) {
  9352. _setupUsages(labelName);
  9353. _current["(usages)"][labelName]["(modified)"].push(token);
  9354. },
  9355. add: function(labelName, type, tok, unused) {
  9356. _current["(labels)"][labelName] = {
  9357. "(type)" : type,
  9358. "(token)": tok,
  9359. "(blockscoped)": true,
  9360. "(unused)": unused };
  9361. },
  9362. addBreakLabel: function(labelName, opts) {
  9363. var token = opts.token;
  9364. if (scopeManagerInst.funct.hasBreakLabel(labelName)) {
  9365. warning("E011", token, labelName);
  9366. }
  9367. else if (state.option.shadow === "outer") {
  9368. if (scopeManagerInst.funct.has(labelName)) {
  9369. warning("W004", token, labelName);
  9370. } else {
  9371. _checkOuterShadow(labelName, token);
  9372. }
  9373. }
  9374. _current["(breakLabels)"][labelName] = token;
  9375. }
  9376. }
  9377. };
  9378. return scopeManagerInst;
  9379. };
  9380. module.exports = scopeManager;
  9381. },{"../lodash":"/node_modules/jshint/lodash.js","events":"/node_modules/browserify/node_modules/events/events.js"}],"/node_modules/jshint/src/state.js":[function(_dereq_,module,exports){
  9382. "use strict";
  9383. var NameStack = _dereq_("./name-stack.js");
  9384. var state = {
  9385. syntax: {},
  9386. isStrict: function() {
  9387. return this.directive["use strict"] || this.inClassBody ||
  9388. this.option.module || this.option.strict === "implied";
  9389. },
  9390. inMoz: function() {
  9391. return this.option.moz;
  9392. },
  9393. inES6: function() {
  9394. return this.option.moz || this.option.esversion >= 6;
  9395. },
  9396. inES5: function(strict) {
  9397. if (strict) {
  9398. return (!this.option.esversion || this.option.esversion === 5) && !this.option.moz;
  9399. }
  9400. return !this.option.esversion || this.option.esversion >= 5 || this.option.moz;
  9401. },
  9402. reset: function() {
  9403. this.tokens = {
  9404. prev: null,
  9405. next: null,
  9406. curr: null
  9407. };
  9408. this.option = {};
  9409. this.funct = null;
  9410. this.ignored = {};
  9411. this.directive = {};
  9412. this.jsonMode = false;
  9413. this.jsonWarnings = [];
  9414. this.lines = [];
  9415. this.tab = "";
  9416. this.cache = {}; // Node.JS doesn't have Map. Sniff.
  9417. this.ignoredLines = {};
  9418. this.forinifcheckneeded = false;
  9419. this.nameStack = new NameStack();
  9420. this.inClassBody = false;
  9421. }
  9422. };
  9423. exports.state = state;
  9424. },{"./name-stack.js":"/node_modules/jshint/src/name-stack.js"}],"/node_modules/jshint/src/style.js":[function(_dereq_,module,exports){
  9425. "use strict";
  9426. exports.register = function(linter) {
  9427. linter.on("Identifier", function style_scanProto(data) {
  9428. if (linter.getOption("proto")) {
  9429. return;
  9430. }
  9431. if (data.name === "__proto__") {
  9432. linter.warn("W103", {
  9433. line: data.line,
  9434. char: data.char,
  9435. data: [ data.name, "6" ]
  9436. });
  9437. }
  9438. });
  9439. linter.on("Identifier", function style_scanIterator(data) {
  9440. if (linter.getOption("iterator")) {
  9441. return;
  9442. }
  9443. if (data.name === "__iterator__") {
  9444. linter.warn("W103", {
  9445. line: data.line,
  9446. char: data.char,
  9447. data: [ data.name ]
  9448. });
  9449. }
  9450. });
  9451. linter.on("Identifier", function style_scanCamelCase(data) {
  9452. if (!linter.getOption("camelcase")) {
  9453. return;
  9454. }
  9455. if (data.name.replace(/^_+|_+$/g, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) {
  9456. linter.warn("W106", {
  9457. line: data.line,
  9458. char: data.from,
  9459. data: [ data.name ]
  9460. });
  9461. }
  9462. });
  9463. linter.on("String", function style_scanQuotes(data) {
  9464. var quotmark = linter.getOption("quotmark");
  9465. var code;
  9466. if (!quotmark) {
  9467. return;
  9468. }
  9469. if (quotmark === "single" && data.quote !== "'") {
  9470. code = "W109";
  9471. }
  9472. if (quotmark === "double" && data.quote !== "\"") {
  9473. code = "W108";
  9474. }
  9475. if (quotmark === true) {
  9476. if (!linter.getCache("quotmark")) {
  9477. linter.setCache("quotmark", data.quote);
  9478. }
  9479. if (linter.getCache("quotmark") !== data.quote) {
  9480. code = "W110";
  9481. }
  9482. }
  9483. if (code) {
  9484. linter.warn(code, {
  9485. line: data.line,
  9486. char: data.char,
  9487. });
  9488. }
  9489. });
  9490. linter.on("Number", function style_scanNumbers(data) {
  9491. if (data.value.charAt(0) === ".") {
  9492. linter.warn("W008", {
  9493. line: data.line,
  9494. char: data.char,
  9495. data: [ data.value ]
  9496. });
  9497. }
  9498. if (data.value.substr(data.value.length - 1) === ".") {
  9499. linter.warn("W047", {
  9500. line: data.line,
  9501. char: data.char,
  9502. data: [ data.value ]
  9503. });
  9504. }
  9505. if (/^00+/.test(data.value)) {
  9506. linter.warn("W046", {
  9507. line: data.line,
  9508. char: data.char,
  9509. data: [ data.value ]
  9510. });
  9511. }
  9512. });
  9513. linter.on("String", function style_scanJavaScriptURLs(data) {
  9514. var re = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
  9515. if (linter.getOption("scripturl")) {
  9516. return;
  9517. }
  9518. if (re.test(data.value)) {
  9519. linter.warn("W107", {
  9520. line: data.line,
  9521. char: data.char
  9522. });
  9523. }
  9524. });
  9525. };
  9526. },{}],"/node_modules/jshint/src/vars.js":[function(_dereq_,module,exports){
  9527. "use strict";
  9528. exports.reservedVars = {
  9529. arguments : false,
  9530. NaN : false
  9531. };
  9532. exports.ecmaIdentifiers = {
  9533. 3: {
  9534. Array : false,
  9535. Boolean : false,
  9536. Date : false,
  9537. decodeURI : false,
  9538. decodeURIComponent : false,
  9539. encodeURI : false,
  9540. encodeURIComponent : false,
  9541. Error : false,
  9542. "eval" : false,
  9543. EvalError : false,
  9544. Function : false,
  9545. hasOwnProperty : false,
  9546. isFinite : false,
  9547. isNaN : false,
  9548. Math : false,
  9549. Number : false,
  9550. Object : false,
  9551. parseInt : false,
  9552. parseFloat : false,
  9553. RangeError : false,
  9554. ReferenceError : false,
  9555. RegExp : false,
  9556. String : false,
  9557. SyntaxError : false,
  9558. TypeError : false,
  9559. URIError : false
  9560. },
  9561. 5: {
  9562. JSON : false
  9563. },
  9564. 6: {
  9565. Map : false,
  9566. Promise : false,
  9567. Proxy : false,
  9568. Reflect : false,
  9569. Set : false,
  9570. Symbol : false,
  9571. WeakMap : false,
  9572. WeakSet : false
  9573. }
  9574. };
  9575. exports.browser = {
  9576. Audio : false,
  9577. Blob : false,
  9578. addEventListener : false,
  9579. applicationCache : false,
  9580. atob : false,
  9581. blur : false,
  9582. btoa : false,
  9583. cancelAnimationFrame : false,
  9584. CanvasGradient : false,
  9585. CanvasPattern : false,
  9586. CanvasRenderingContext2D: false,
  9587. CSS : false,
  9588. clearInterval : false,
  9589. clearTimeout : false,
  9590. close : false,
  9591. closed : false,
  9592. Comment : false,
  9593. CustomEvent : false,
  9594. DOMParser : false,
  9595. defaultStatus : false,
  9596. Document : false,
  9597. document : false,
  9598. DocumentFragment : false,
  9599. Element : false,
  9600. ElementTimeControl : false,
  9601. Event : false,
  9602. event : false,
  9603. fetch : false,
  9604. FileReader : false,
  9605. FormData : false,
  9606. focus : false,
  9607. frames : false,
  9608. getComputedStyle : false,
  9609. HTMLElement : false,
  9610. HTMLAnchorElement : false,
  9611. HTMLBaseElement : false,
  9612. HTMLBlockquoteElement: false,
  9613. HTMLBodyElement : false,
  9614. HTMLBRElement : false,
  9615. HTMLButtonElement : false,
  9616. HTMLCanvasElement : false,
  9617. HTMLCollection : false,
  9618. HTMLDirectoryElement : false,
  9619. HTMLDivElement : false,
  9620. HTMLDListElement : false,
  9621. HTMLFieldSetElement : false,
  9622. HTMLFontElement : false,
  9623. HTMLFormElement : false,
  9624. HTMLFrameElement : false,
  9625. HTMLFrameSetElement : false,
  9626. HTMLHeadElement : false,
  9627. HTMLHeadingElement : false,
  9628. HTMLHRElement : false,
  9629. HTMLHtmlElement : false,
  9630. HTMLIFrameElement : false,
  9631. HTMLImageElement : false,
  9632. HTMLInputElement : false,
  9633. HTMLIsIndexElement : false,
  9634. HTMLLabelElement : false,
  9635. HTMLLayerElement : false,
  9636. HTMLLegendElement : false,
  9637. HTMLLIElement : false,
  9638. HTMLLinkElement : false,
  9639. HTMLMapElement : false,
  9640. HTMLMenuElement : false,
  9641. HTMLMetaElement : false,
  9642. HTMLModElement : false,
  9643. HTMLObjectElement : false,
  9644. HTMLOListElement : false,
  9645. HTMLOptGroupElement : false,
  9646. HTMLOptionElement : false,
  9647. HTMLParagraphElement : false,
  9648. HTMLParamElement : false,
  9649. HTMLPreElement : false,
  9650. HTMLQuoteElement : false,
  9651. HTMLScriptElement : false,
  9652. HTMLSelectElement : false,
  9653. HTMLStyleElement : false,
  9654. HTMLTableCaptionElement: false,
  9655. HTMLTableCellElement : false,
  9656. HTMLTableColElement : false,
  9657. HTMLTableElement : false,
  9658. HTMLTableRowElement : false,
  9659. HTMLTableSectionElement: false,
  9660. HTMLTemplateElement : false,
  9661. HTMLTextAreaElement : false,
  9662. HTMLTitleElement : false,
  9663. HTMLUListElement : false,
  9664. HTMLVideoElement : false,
  9665. history : false,
  9666. Image : false,
  9667. Intl : false,
  9668. length : false,
  9669. localStorage : false,
  9670. location : false,
  9671. matchMedia : false,
  9672. MessageChannel : false,
  9673. MessageEvent : false,
  9674. MessagePort : false,
  9675. MouseEvent : false,
  9676. moveBy : false,
  9677. moveTo : false,
  9678. MutationObserver : false,
  9679. name : false,
  9680. Node : false,
  9681. NodeFilter : false,
  9682. NodeList : false,
  9683. Notification : false,
  9684. navigator : false,
  9685. onbeforeunload : true,
  9686. onblur : true,
  9687. onerror : true,
  9688. onfocus : true,
  9689. onload : true,
  9690. onresize : true,
  9691. onunload : true,
  9692. open : false,
  9693. openDatabase : false,
  9694. opener : false,
  9695. Option : false,
  9696. parent : false,
  9697. performance : false,
  9698. print : false,
  9699. Range : false,
  9700. requestAnimationFrame : false,
  9701. removeEventListener : false,
  9702. resizeBy : false,
  9703. resizeTo : false,
  9704. screen : false,
  9705. scroll : false,
  9706. scrollBy : false,
  9707. scrollTo : false,
  9708. sessionStorage : false,
  9709. setInterval : false,
  9710. setTimeout : false,
  9711. SharedWorker : false,
  9712. status : false,
  9713. SVGAElement : false,
  9714. SVGAltGlyphDefElement: false,
  9715. SVGAltGlyphElement : false,
  9716. SVGAltGlyphItemElement: false,
  9717. SVGAngle : false,
  9718. SVGAnimateColorElement: false,
  9719. SVGAnimateElement : false,
  9720. SVGAnimateMotionElement: false,
  9721. SVGAnimateTransformElement: false,
  9722. SVGAnimatedAngle : false,
  9723. SVGAnimatedBoolean : false,
  9724. SVGAnimatedEnumeration: false,
  9725. SVGAnimatedInteger : false,
  9726. SVGAnimatedLength : false,
  9727. SVGAnimatedLengthList: false,
  9728. SVGAnimatedNumber : false,
  9729. SVGAnimatedNumberList: false,
  9730. SVGAnimatedPathData : false,
  9731. SVGAnimatedPoints : false,
  9732. SVGAnimatedPreserveAspectRatio: false,
  9733. SVGAnimatedRect : false,
  9734. SVGAnimatedString : false,
  9735. SVGAnimatedTransformList: false,
  9736. SVGAnimationElement : false,
  9737. SVGCSSRule : false,
  9738. SVGCircleElement : false,
  9739. SVGClipPathElement : false,
  9740. SVGColor : false,
  9741. SVGColorProfileElement: false,
  9742. SVGColorProfileRule : false,
  9743. SVGComponentTransferFunctionElement: false,
  9744. SVGCursorElement : false,
  9745. SVGDefsElement : false,
  9746. SVGDescElement : false,
  9747. SVGDocument : false,
  9748. SVGElement : false,
  9749. SVGElementInstance : false,
  9750. SVGElementInstanceList: false,
  9751. SVGEllipseElement : false,
  9752. SVGExternalResourcesRequired: false,
  9753. SVGFEBlendElement : false,
  9754. SVGFEColorMatrixElement: false,
  9755. SVGFEComponentTransferElement: false,
  9756. SVGFECompositeElement: false,
  9757. SVGFEConvolveMatrixElement: false,
  9758. SVGFEDiffuseLightingElement: false,
  9759. SVGFEDisplacementMapElement: false,
  9760. SVGFEDistantLightElement: false,
  9761. SVGFEFloodElement : false,
  9762. SVGFEFuncAElement : false,
  9763. SVGFEFuncBElement : false,
  9764. SVGFEFuncGElement : false,
  9765. SVGFEFuncRElement : false,
  9766. SVGFEGaussianBlurElement: false,
  9767. SVGFEImageElement : false,
  9768. SVGFEMergeElement : false,
  9769. SVGFEMergeNodeElement: false,
  9770. SVGFEMorphologyElement: false,
  9771. SVGFEOffsetElement : false,
  9772. SVGFEPointLightElement: false,
  9773. SVGFESpecularLightingElement: false,
  9774. SVGFESpotLightElement: false,
  9775. SVGFETileElement : false,
  9776. SVGFETurbulenceElement: false,
  9777. SVGFilterElement : false,
  9778. SVGFilterPrimitiveStandardAttributes: false,
  9779. SVGFitToViewBox : false,
  9780. SVGFontElement : false,
  9781. SVGFontFaceElement : false,
  9782. SVGFontFaceFormatElement: false,
  9783. SVGFontFaceNameElement: false,
  9784. SVGFontFaceSrcElement: false,
  9785. SVGFontFaceUriElement: false,
  9786. SVGForeignObjectElement: false,
  9787. SVGGElement : false,
  9788. SVGGlyphElement : false,
  9789. SVGGlyphRefElement : false,
  9790. SVGGradientElement : false,
  9791. SVGHKernElement : false,
  9792. SVGICCColor : false,
  9793. SVGImageElement : false,
  9794. SVGLangSpace : false,
  9795. SVGLength : false,
  9796. SVGLengthList : false,
  9797. SVGLineElement : false,
  9798. SVGLinearGradientElement: false,
  9799. SVGLocatable : false,
  9800. SVGMPathElement : false,
  9801. SVGMarkerElement : false,
  9802. SVGMaskElement : false,
  9803. SVGMatrix : false,
  9804. SVGMetadataElement : false,
  9805. SVGMissingGlyphElement: false,
  9806. SVGNumber : false,
  9807. SVGNumberList : false,
  9808. SVGPaint : false,
  9809. SVGPathElement : false,
  9810. SVGPathSeg : false,
  9811. SVGPathSegArcAbs : false,
  9812. SVGPathSegArcRel : false,
  9813. SVGPathSegClosePath : false,
  9814. SVGPathSegCurvetoCubicAbs: false,
  9815. SVGPathSegCurvetoCubicRel: false,
  9816. SVGPathSegCurvetoCubicSmoothAbs: false,
  9817. SVGPathSegCurvetoCubicSmoothRel: false,
  9818. SVGPathSegCurvetoQuadraticAbs: false,
  9819. SVGPathSegCurvetoQuadraticRel: false,
  9820. SVGPathSegCurvetoQuadraticSmoothAbs: false,
  9821. SVGPathSegCurvetoQuadraticSmoothRel: false,
  9822. SVGPathSegLinetoAbs : false,
  9823. SVGPathSegLinetoHorizontalAbs: false,
  9824. SVGPathSegLinetoHorizontalRel: false,
  9825. SVGPathSegLinetoRel : false,
  9826. SVGPathSegLinetoVerticalAbs: false,
  9827. SVGPathSegLinetoVerticalRel: false,
  9828. SVGPathSegList : false,
  9829. SVGPathSegMovetoAbs : false,
  9830. SVGPathSegMovetoRel : false,
  9831. SVGPatternElement : false,
  9832. SVGPoint : false,
  9833. SVGPointList : false,
  9834. SVGPolygonElement : false,
  9835. SVGPolylineElement : false,
  9836. SVGPreserveAspectRatio: false,
  9837. SVGRadialGradientElement: false,
  9838. SVGRect : false,
  9839. SVGRectElement : false,
  9840. SVGRenderingIntent : false,
  9841. SVGSVGElement : false,
  9842. SVGScriptElement : false,
  9843. SVGSetElement : false,
  9844. SVGStopElement : false,
  9845. SVGStringList : false,
  9846. SVGStylable : false,
  9847. SVGStyleElement : false,
  9848. SVGSwitchElement : false,
  9849. SVGSymbolElement : false,
  9850. SVGTRefElement : false,
  9851. SVGTSpanElement : false,
  9852. SVGTests : false,
  9853. SVGTextContentElement: false,
  9854. SVGTextElement : false,
  9855. SVGTextPathElement : false,
  9856. SVGTextPositioningElement: false,
  9857. SVGTitleElement : false,
  9858. SVGTransform : false,
  9859. SVGTransformList : false,
  9860. SVGTransformable : false,
  9861. SVGURIReference : false,
  9862. SVGUnitTypes : false,
  9863. SVGUseElement : false,
  9864. SVGVKernElement : false,
  9865. SVGViewElement : false,
  9866. SVGViewSpec : false,
  9867. SVGZoomAndPan : false,
  9868. Text : false,
  9869. TextDecoder : false,
  9870. TextEncoder : false,
  9871. TimeEvent : false,
  9872. top : false,
  9873. URL : false,
  9874. WebGLActiveInfo : false,
  9875. WebGLBuffer : false,
  9876. WebGLContextEvent : false,
  9877. WebGLFramebuffer : false,
  9878. WebGLProgram : false,
  9879. WebGLRenderbuffer : false,
  9880. WebGLRenderingContext: false,
  9881. WebGLShader : false,
  9882. WebGLShaderPrecisionFormat: false,
  9883. WebGLTexture : false,
  9884. WebGLUniformLocation : false,
  9885. WebSocket : false,
  9886. window : false,
  9887. Window : false,
  9888. Worker : false,
  9889. XDomainRequest : false,
  9890. XMLHttpRequest : false,
  9891. XMLSerializer : false,
  9892. XPathEvaluator : false,
  9893. XPathException : false,
  9894. XPathExpression : false,
  9895. XPathNamespace : false,
  9896. XPathNSResolver : false,
  9897. XPathResult : false
  9898. };
  9899. exports.devel = {
  9900. alert : false,
  9901. confirm: false,
  9902. console: false,
  9903. Debug : false,
  9904. opera : false,
  9905. prompt : false
  9906. };
  9907. exports.worker = {
  9908. importScripts : true,
  9909. postMessage : true,
  9910. self : true,
  9911. FileReaderSync : true
  9912. };
  9913. exports.nonstandard = {
  9914. escape : false,
  9915. unescape: false
  9916. };
  9917. exports.couch = {
  9918. "require" : false,
  9919. respond : false,
  9920. getRow : false,
  9921. emit : false,
  9922. send : false,
  9923. start : false,
  9924. sum : false,
  9925. log : false,
  9926. exports : false,
  9927. module : false,
  9928. provides : false
  9929. };
  9930. exports.node = {
  9931. __filename : false,
  9932. __dirname : false,
  9933. GLOBAL : false,
  9934. global : false,
  9935. module : false,
  9936. require : false,
  9937. Buffer : true,
  9938. console : true,
  9939. exports : true,
  9940. process : true,
  9941. setTimeout : true,
  9942. clearTimeout : true,
  9943. setInterval : true,
  9944. clearInterval : true,
  9945. setImmediate : true, // v0.9.1+
  9946. clearImmediate: true // v0.9.1+
  9947. };
  9948. exports.browserify = {
  9949. __filename : false,
  9950. __dirname : false,
  9951. global : false,
  9952. module : false,
  9953. require : false,
  9954. Buffer : true,
  9955. exports : true,
  9956. process : true
  9957. };
  9958. exports.phantom = {
  9959. phantom : true,
  9960. require : true,
  9961. WebPage : true,
  9962. console : true, // in examples, but undocumented
  9963. exports : true // v1.7+
  9964. };
  9965. exports.qunit = {
  9966. asyncTest : false,
  9967. deepEqual : false,
  9968. equal : false,
  9969. expect : false,
  9970. module : false,
  9971. notDeepEqual : false,
  9972. notEqual : false,
  9973. notPropEqual : false,
  9974. notStrictEqual : false,
  9975. ok : false,
  9976. propEqual : false,
  9977. QUnit : false,
  9978. raises : false,
  9979. start : false,
  9980. stop : false,
  9981. strictEqual : false,
  9982. test : false,
  9983. "throws" : false
  9984. };
  9985. exports.rhino = {
  9986. defineClass : false,
  9987. deserialize : false,
  9988. gc : false,
  9989. help : false,
  9990. importClass : false,
  9991. importPackage: false,
  9992. "java" : false,
  9993. load : false,
  9994. loadClass : false,
  9995. Packages : false,
  9996. print : false,
  9997. quit : false,
  9998. readFile : false,
  9999. readUrl : false,
  10000. runCommand : false,
  10001. seal : false,
  10002. serialize : false,
  10003. spawn : false,
  10004. sync : false,
  10005. toint32 : false,
  10006. version : false
  10007. };
  10008. exports.shelljs = {
  10009. target : false,
  10010. echo : false,
  10011. exit : false,
  10012. cd : false,
  10013. pwd : false,
  10014. ls : false,
  10015. find : false,
  10016. cp : false,
  10017. rm : false,
  10018. mv : false,
  10019. mkdir : false,
  10020. test : false,
  10021. cat : false,
  10022. sed : false,
  10023. grep : false,
  10024. which : false,
  10025. dirs : false,
  10026. pushd : false,
  10027. popd : false,
  10028. env : false,
  10029. exec : false,
  10030. chmod : false,
  10031. config : false,
  10032. error : false,
  10033. tempdir : false
  10034. };
  10035. exports.typed = {
  10036. ArrayBuffer : false,
  10037. ArrayBufferView : false,
  10038. DataView : false,
  10039. Float32Array : false,
  10040. Float64Array : false,
  10041. Int16Array : false,
  10042. Int32Array : false,
  10043. Int8Array : false,
  10044. Uint16Array : false,
  10045. Uint32Array : false,
  10046. Uint8Array : false,
  10047. Uint8ClampedArray : false
  10048. };
  10049. exports.wsh = {
  10050. ActiveXObject : true,
  10051. Enumerator : true,
  10052. GetObject : true,
  10053. ScriptEngine : true,
  10054. ScriptEngineBuildVersion : true,
  10055. ScriptEngineMajorVersion : true,
  10056. ScriptEngineMinorVersion : true,
  10057. VBArray : true,
  10058. WSH : true,
  10059. WScript : true,
  10060. XDomainRequest : true
  10061. };
  10062. exports.dojo = {
  10063. dojo : false,
  10064. dijit : false,
  10065. dojox : false,
  10066. define : false,
  10067. "require": false
  10068. };
  10069. exports.jquery = {
  10070. "$" : false,
  10071. jQuery : false
  10072. };
  10073. exports.mootools = {
  10074. "$" : false,
  10075. "$$" : false,
  10076. Asset : false,
  10077. Browser : false,
  10078. Chain : false,
  10079. Class : false,
  10080. Color : false,
  10081. Cookie : false,
  10082. Core : false,
  10083. Document : false,
  10084. DomReady : false,
  10085. DOMEvent : false,
  10086. DOMReady : false,
  10087. Drag : false,
  10088. Element : false,
  10089. Elements : false,
  10090. Event : false,
  10091. Events : false,
  10092. Fx : false,
  10093. Group : false,
  10094. Hash : false,
  10095. HtmlTable : false,
  10096. IFrame : false,
  10097. IframeShim : false,
  10098. InputValidator: false,
  10099. instanceOf : false,
  10100. Keyboard : false,
  10101. Locale : false,
  10102. Mask : false,
  10103. MooTools : false,
  10104. Native : false,
  10105. Options : false,
  10106. OverText : false,
  10107. Request : false,
  10108. Scroller : false,
  10109. Slick : false,
  10110. Slider : false,
  10111. Sortables : false,
  10112. Spinner : false,
  10113. Swiff : false,
  10114. Tips : false,
  10115. Type : false,
  10116. typeOf : false,
  10117. URI : false,
  10118. Window : false
  10119. };
  10120. exports.prototypejs = {
  10121. "$" : false,
  10122. "$$" : false,
  10123. "$A" : false,
  10124. "$F" : false,
  10125. "$H" : false,
  10126. "$R" : false,
  10127. "$break" : false,
  10128. "$continue" : false,
  10129. "$w" : false,
  10130. Abstract : false,
  10131. Ajax : false,
  10132. Class : false,
  10133. Enumerable : false,
  10134. Element : false,
  10135. Event : false,
  10136. Field : false,
  10137. Form : false,
  10138. Hash : false,
  10139. Insertion : false,
  10140. ObjectRange : false,
  10141. PeriodicalExecuter: false,
  10142. Position : false,
  10143. Prototype : false,
  10144. Selector : false,
  10145. Template : false,
  10146. Toggle : false,
  10147. Try : false,
  10148. Autocompleter : false,
  10149. Builder : false,
  10150. Control : false,
  10151. Draggable : false,
  10152. Draggables : false,
  10153. Droppables : false,
  10154. Effect : false,
  10155. Sortable : false,
  10156. SortableObserver : false,
  10157. Sound : false,
  10158. Scriptaculous : false
  10159. };
  10160. exports.yui = {
  10161. YUI : false,
  10162. Y : false,
  10163. YUI_config: false
  10164. };
  10165. exports.mocha = {
  10166. mocha : false,
  10167. describe : false,
  10168. xdescribe : false,
  10169. it : false,
  10170. xit : false,
  10171. context : false,
  10172. xcontext : false,
  10173. before : false,
  10174. after : false,
  10175. beforeEach : false,
  10176. afterEach : false,
  10177. suite : false,
  10178. test : false,
  10179. setup : false,
  10180. teardown : false,
  10181. suiteSetup : false,
  10182. suiteTeardown : false
  10183. };
  10184. exports.jasmine = {
  10185. jasmine : false,
  10186. describe : false,
  10187. xdescribe : false,
  10188. it : false,
  10189. xit : false,
  10190. beforeEach : false,
  10191. afterEach : false,
  10192. setFixtures : false,
  10193. loadFixtures: false,
  10194. spyOn : false,
  10195. expect : false,
  10196. runs : false,
  10197. waitsFor : false,
  10198. waits : false,
  10199. beforeAll : false,
  10200. afterAll : false,
  10201. fail : false,
  10202. fdescribe : false,
  10203. fit : false,
  10204. pending : false
  10205. };
  10206. },{}]},{},["/node_modules/jshint/src/jshint.js"]);
  10207. });
  10208. ace.define("ace/mode/javascript_worker",[], function(require, exports, module) {
  10209. "use strict";
  10210. var oop = require("../lib/oop");
  10211. var Mirror = require("../worker/mirror").Mirror;
  10212. var lint = require("./javascript/jshint").JSHINT;
  10213. function startRegex(arr) {
  10214. return RegExp("^(" + arr.join("|") + ")");
  10215. }
  10216. var disabledWarningsRe = startRegex([
  10217. "Bad for in variable '(.+)'.",
  10218. 'Missing "use strict"'
  10219. ]);
  10220. var errorsRe = startRegex([
  10221. "Unexpected",
  10222. "Expected ",
  10223. "Confusing (plus|minus)",
  10224. "\\{a\\} unterminated regular expression",
  10225. "Unclosed ",
  10226. "Unmatched ",
  10227. "Unbegun comment",
  10228. "Bad invocation",
  10229. "Missing space after",
  10230. "Missing operator at"
  10231. ]);
  10232. var infoRe = startRegex([
  10233. "Expected an assignment",
  10234. "Bad escapement of EOL",
  10235. "Unexpected comma",
  10236. "Unexpected space",
  10237. "Missing radix parameter.",
  10238. "A leading decimal point can",
  10239. "\\['{a}'\\] is better written in dot notation.",
  10240. "'{a}' used out of scope"
  10241. ]);
  10242. var JavaScriptWorker = exports.JavaScriptWorker = function(sender) {
  10243. Mirror.call(this, sender);
  10244. this.setTimeout(500);
  10245. this.setOptions();
  10246. };
  10247. oop.inherits(JavaScriptWorker, Mirror);
  10248. (function() {
  10249. this.setOptions = function(options) {
  10250. this.options = options || {
  10251. esnext: true,
  10252. moz: true,
  10253. devel: true,
  10254. browser: true,
  10255. node: true,
  10256. laxcomma: true,
  10257. laxbreak: true,
  10258. lastsemic: true,
  10259. onevar: false,
  10260. passfail: false,
  10261. maxerr: 100,
  10262. expr: true,
  10263. multistr: true,
  10264. globalstrict: true
  10265. };
  10266. this.doc.getValue() && this.deferredUpdate.schedule(100);
  10267. };
  10268. this.changeOptions = function(newOptions) {
  10269. oop.mixin(this.options, newOptions);
  10270. this.doc.getValue() && this.deferredUpdate.schedule(100);
  10271. };
  10272. this.isValidJS = function(str) {
  10273. try {
  10274. eval("throw 0;" + str);
  10275. } catch(e) {
  10276. if (e === 0)
  10277. return true;
  10278. }
  10279. return false;
  10280. };
  10281. this.onUpdate = function() {
  10282. var value = this.doc.getValue();
  10283. value = value.replace(/^#!.*\n/, "\n");
  10284. if (!value)
  10285. return this.sender.emit("annotate", []);
  10286. var errors = [];
  10287. var maxErrorLevel = this.isValidJS(value) ? "warning" : "error";
  10288. lint(value, this.options, this.options.globals);
  10289. var results = lint.errors;
  10290. var errorAdded = false;
  10291. for (var i = 0; i < results.length; i++) {
  10292. var error = results[i];
  10293. if (!error)
  10294. continue;
  10295. var raw = error.raw;
  10296. var type = "warning";
  10297. if (raw == "Missing semicolon.") {
  10298. var str = error.evidence.substr(error.character);
  10299. str = str.charAt(str.search(/\S/));
  10300. if (maxErrorLevel == "error" && str && /[\w\d{(['"]/.test(str)) {
  10301. error.reason = 'Missing ";" before statement';
  10302. type = "error";
  10303. } else {
  10304. type = "info";
  10305. }
  10306. }
  10307. else if (disabledWarningsRe.test(raw)) {
  10308. continue;
  10309. }
  10310. else if (infoRe.test(raw)) {
  10311. type = "info";
  10312. }
  10313. else if (errorsRe.test(raw)) {
  10314. errorAdded = true;
  10315. type = maxErrorLevel;
  10316. }
  10317. else if (raw == "'{a}' is not defined.") {
  10318. type = "warning";
  10319. }
  10320. else if (raw == "'{a}' is defined but never used.") {
  10321. type = "info";
  10322. }
  10323. errors.push({
  10324. row: error.line-1,
  10325. column: error.character-1,
  10326. text: error.reason,
  10327. type: type,
  10328. raw: raw
  10329. });
  10330. if (errorAdded) {
  10331. }
  10332. }
  10333. this.sender.emit("annotate", errors);
  10334. };
  10335. }).call(JavaScriptWorker.prototype);
  10336. });
  10337. ace.define("ace/lib/es5-shim",[], function(require, exports, module) {
  10338. function Empty() {}
  10339. if (!Function.prototype.bind) {
  10340. Function.prototype.bind = function bind(that) { // .length is 1
  10341. var target = this;
  10342. if (typeof target != "function") {
  10343. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  10344. }
  10345. var args = slice.call(arguments, 1); // for normal call
  10346. var bound = function () {
  10347. if (this instanceof bound) {
  10348. var result = target.apply(
  10349. this,
  10350. args.concat(slice.call(arguments))
  10351. );
  10352. if (Object(result) === result) {
  10353. return result;
  10354. }
  10355. return this;
  10356. } else {
  10357. return target.apply(
  10358. that,
  10359. args.concat(slice.call(arguments))
  10360. );
  10361. }
  10362. };
  10363. if(target.prototype) {
  10364. Empty.prototype = target.prototype;
  10365. bound.prototype = new Empty();
  10366. Empty.prototype = null;
  10367. }
  10368. return bound;
  10369. };
  10370. }
  10371. var call = Function.prototype.call;
  10372. var prototypeOfArray = Array.prototype;
  10373. var prototypeOfObject = Object.prototype;
  10374. var slice = prototypeOfArray.slice;
  10375. var _toString = call.bind(prototypeOfObject.toString);
  10376. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  10377. var defineGetter;
  10378. var defineSetter;
  10379. var lookupGetter;
  10380. var lookupSetter;
  10381. var supportsAccessors;
  10382. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  10383. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  10384. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  10385. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  10386. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  10387. }
  10388. if ([1,2].splice(0).length != 2) {
  10389. if(function() { // test IE < 9 to splice bug - see issue #138
  10390. function makeArray(l) {
  10391. var a = new Array(l+2);
  10392. a[0] = a[1] = 0;
  10393. return a;
  10394. }
  10395. var array = [], lengthBefore;
  10396. array.splice.apply(array, makeArray(20));
  10397. array.splice.apply(array, makeArray(26));
  10398. lengthBefore = array.length; //46
  10399. array.splice(5, 0, "XXX"); // add one element
  10400. lengthBefore + 1 == array.length
  10401. if (lengthBefore + 1 == array.length) {
  10402. return true;// has right splice implementation without bugs
  10403. }
  10404. }()) {//IE 6/7
  10405. var array_splice = Array.prototype.splice;
  10406. Array.prototype.splice = function(start, deleteCount) {
  10407. if (!arguments.length) {
  10408. return [];
  10409. } else {
  10410. return array_splice.apply(this, [
  10411. start === void 0 ? 0 : start,
  10412. deleteCount === void 0 ? (this.length - start) : deleteCount
  10413. ].concat(slice.call(arguments, 2)))
  10414. }
  10415. };
  10416. } else {//IE8
  10417. Array.prototype.splice = function(pos, removeCount){
  10418. var length = this.length;
  10419. if (pos > 0) {
  10420. if (pos > length)
  10421. pos = length;
  10422. } else if (pos == void 0) {
  10423. pos = 0;
  10424. } else if (pos < 0) {
  10425. pos = Math.max(length + pos, 0);
  10426. }
  10427. if (!(pos+removeCount < length))
  10428. removeCount = length - pos;
  10429. var removed = this.slice(pos, pos+removeCount);
  10430. var insert = slice.call(arguments, 2);
  10431. var add = insert.length;
  10432. if (pos === length) {
  10433. if (add) {
  10434. this.push.apply(this, insert);
  10435. }
  10436. } else {
  10437. var remove = Math.min(removeCount, length - pos);
  10438. var tailOldPos = pos + remove;
  10439. var tailNewPos = tailOldPos + add - remove;
  10440. var tailCount = length - tailOldPos;
  10441. var lengthAfterRemove = length - remove;
  10442. if (tailNewPos < tailOldPos) { // case A
  10443. for (var i = 0; i < tailCount; ++i) {
  10444. this[tailNewPos+i] = this[tailOldPos+i];
  10445. }
  10446. } else if (tailNewPos > tailOldPos) { // case B
  10447. for (i = tailCount; i--; ) {
  10448. this[tailNewPos+i] = this[tailOldPos+i];
  10449. }
  10450. } // else, add == remove (nothing to do)
  10451. if (add && pos === lengthAfterRemove) {
  10452. this.length = lengthAfterRemove; // truncate array
  10453. this.push.apply(this, insert);
  10454. } else {
  10455. this.length = lengthAfterRemove + add; // reserves space
  10456. for (i = 0; i < add; ++i) {
  10457. this[pos+i] = insert[i];
  10458. }
  10459. }
  10460. }
  10461. return removed;
  10462. };
  10463. }
  10464. }
  10465. if (!Array.isArray) {
  10466. Array.isArray = function isArray(obj) {
  10467. return _toString(obj) == "[object Array]";
  10468. };
  10469. }
  10470. var boxedString = Object("a"),
  10471. splitString = boxedString[0] != "a" || !(0 in boxedString);
  10472. if (!Array.prototype.forEach) {
  10473. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  10474. var object = toObject(this),
  10475. self = splitString && _toString(this) == "[object String]" ?
  10476. this.split("") :
  10477. object,
  10478. thisp = arguments[1],
  10479. i = -1,
  10480. length = self.length >>> 0;
  10481. if (_toString(fun) != "[object Function]") {
  10482. throw new TypeError(); // TODO message
  10483. }
  10484. while (++i < length) {
  10485. if (i in self) {
  10486. fun.call(thisp, self[i], i, object);
  10487. }
  10488. }
  10489. };
  10490. }
  10491. if (!Array.prototype.map) {
  10492. Array.prototype.map = function map(fun /*, thisp*/) {
  10493. var object = toObject(this),
  10494. self = splitString && _toString(this) == "[object String]" ?
  10495. this.split("") :
  10496. object,
  10497. length = self.length >>> 0,
  10498. result = Array(length),
  10499. thisp = arguments[1];
  10500. if (_toString(fun) != "[object Function]") {
  10501. throw new TypeError(fun + " is not a function");
  10502. }
  10503. for (var i = 0; i < length; i++) {
  10504. if (i in self)
  10505. result[i] = fun.call(thisp, self[i], i, object);
  10506. }
  10507. return result;
  10508. };
  10509. }
  10510. if (!Array.prototype.filter) {
  10511. Array.prototype.filter = function filter(fun /*, thisp */) {
  10512. var object = toObject(this),
  10513. self = splitString && _toString(this) == "[object String]" ?
  10514. this.split("") :
  10515. object,
  10516. length = self.length >>> 0,
  10517. result = [],
  10518. value,
  10519. thisp = arguments[1];
  10520. if (_toString(fun) != "[object Function]") {
  10521. throw new TypeError(fun + " is not a function");
  10522. }
  10523. for (var i = 0; i < length; i++) {
  10524. if (i in self) {
  10525. value = self[i];
  10526. if (fun.call(thisp, value, i, object)) {
  10527. result.push(value);
  10528. }
  10529. }
  10530. }
  10531. return result;
  10532. };
  10533. }
  10534. if (!Array.prototype.every) {
  10535. Array.prototype.every = function every(fun /*, thisp */) {
  10536. var object = toObject(this),
  10537. self = splitString && _toString(this) == "[object String]" ?
  10538. this.split("") :
  10539. object,
  10540. length = self.length >>> 0,
  10541. thisp = arguments[1];
  10542. if (_toString(fun) != "[object Function]") {
  10543. throw new TypeError(fun + " is not a function");
  10544. }
  10545. for (var i = 0; i < length; i++) {
  10546. if (i in self && !fun.call(thisp, self[i], i, object)) {
  10547. return false;
  10548. }
  10549. }
  10550. return true;
  10551. };
  10552. }
  10553. if (!Array.prototype.some) {
  10554. Array.prototype.some = function some(fun /*, thisp */) {
  10555. var object = toObject(this),
  10556. self = splitString && _toString(this) == "[object String]" ?
  10557. this.split("") :
  10558. object,
  10559. length = self.length >>> 0,
  10560. thisp = arguments[1];
  10561. if (_toString(fun) != "[object Function]") {
  10562. throw new TypeError(fun + " is not a function");
  10563. }
  10564. for (var i = 0; i < length; i++) {
  10565. if (i in self && fun.call(thisp, self[i], i, object)) {
  10566. return true;
  10567. }
  10568. }
  10569. return false;
  10570. };
  10571. }
  10572. if (!Array.prototype.reduce) {
  10573. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  10574. var object = toObject(this),
  10575. self = splitString && _toString(this) == "[object String]" ?
  10576. this.split("") :
  10577. object,
  10578. length = self.length >>> 0;
  10579. if (_toString(fun) != "[object Function]") {
  10580. throw new TypeError(fun + " is not a function");
  10581. }
  10582. if (!length && arguments.length == 1) {
  10583. throw new TypeError("reduce of empty array with no initial value");
  10584. }
  10585. var i = 0;
  10586. var result;
  10587. if (arguments.length >= 2) {
  10588. result = arguments[1];
  10589. } else {
  10590. do {
  10591. if (i in self) {
  10592. result = self[i++];
  10593. break;
  10594. }
  10595. if (++i >= length) {
  10596. throw new TypeError("reduce of empty array with no initial value");
  10597. }
  10598. } while (true);
  10599. }
  10600. for (; i < length; i++) {
  10601. if (i in self) {
  10602. result = fun.call(void 0, result, self[i], i, object);
  10603. }
  10604. }
  10605. return result;
  10606. };
  10607. }
  10608. if (!Array.prototype.reduceRight) {
  10609. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  10610. var object = toObject(this),
  10611. self = splitString && _toString(this) == "[object String]" ?
  10612. this.split("") :
  10613. object,
  10614. length = self.length >>> 0;
  10615. if (_toString(fun) != "[object Function]") {
  10616. throw new TypeError(fun + " is not a function");
  10617. }
  10618. if (!length && arguments.length == 1) {
  10619. throw new TypeError("reduceRight of empty array with no initial value");
  10620. }
  10621. var result, i = length - 1;
  10622. if (arguments.length >= 2) {
  10623. result = arguments[1];
  10624. } else {
  10625. do {
  10626. if (i in self) {
  10627. result = self[i--];
  10628. break;
  10629. }
  10630. if (--i < 0) {
  10631. throw new TypeError("reduceRight of empty array with no initial value");
  10632. }
  10633. } while (true);
  10634. }
  10635. do {
  10636. if (i in this) {
  10637. result = fun.call(void 0, result, self[i], i, object);
  10638. }
  10639. } while (i--);
  10640. return result;
  10641. };
  10642. }
  10643. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  10644. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  10645. var self = splitString && _toString(this) == "[object String]" ?
  10646. this.split("") :
  10647. toObject(this),
  10648. length = self.length >>> 0;
  10649. if (!length) {
  10650. return -1;
  10651. }
  10652. var i = 0;
  10653. if (arguments.length > 1) {
  10654. i = toInteger(arguments[1]);
  10655. }
  10656. i = i >= 0 ? i : Math.max(0, length + i);
  10657. for (; i < length; i++) {
  10658. if (i in self && self[i] === sought) {
  10659. return i;
  10660. }
  10661. }
  10662. return -1;
  10663. };
  10664. }
  10665. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  10666. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  10667. var self = splitString && _toString(this) == "[object String]" ?
  10668. this.split("") :
  10669. toObject(this),
  10670. length = self.length >>> 0;
  10671. if (!length) {
  10672. return -1;
  10673. }
  10674. var i = length - 1;
  10675. if (arguments.length > 1) {
  10676. i = Math.min(i, toInteger(arguments[1]));
  10677. }
  10678. i = i >= 0 ? i : length - Math.abs(i);
  10679. for (; i >= 0; i--) {
  10680. if (i in self && sought === self[i]) {
  10681. return i;
  10682. }
  10683. }
  10684. return -1;
  10685. };
  10686. }
  10687. if (!Object.getPrototypeOf) {
  10688. Object.getPrototypeOf = function getPrototypeOf(object) {
  10689. return object.__proto__ || (
  10690. object.constructor ?
  10691. object.constructor.prototype :
  10692. prototypeOfObject
  10693. );
  10694. };
  10695. }
  10696. if (!Object.getOwnPropertyDescriptor) {
  10697. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  10698. "non-object: ";
  10699. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  10700. if ((typeof object != "object" && typeof object != "function") || object === null)
  10701. throw new TypeError(ERR_NON_OBJECT + object);
  10702. if (!owns(object, property))
  10703. return;
  10704. var descriptor, getter, setter;
  10705. descriptor = { enumerable: true, configurable: true };
  10706. if (supportsAccessors) {
  10707. var prototype = object.__proto__;
  10708. object.__proto__ = prototypeOfObject;
  10709. var getter = lookupGetter(object, property);
  10710. var setter = lookupSetter(object, property);
  10711. object.__proto__ = prototype;
  10712. if (getter || setter) {
  10713. if (getter) descriptor.get = getter;
  10714. if (setter) descriptor.set = setter;
  10715. return descriptor;
  10716. }
  10717. }
  10718. descriptor.value = object[property];
  10719. return descriptor;
  10720. };
  10721. }
  10722. if (!Object.getOwnPropertyNames) {
  10723. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  10724. return Object.keys(object);
  10725. };
  10726. }
  10727. if (!Object.create) {
  10728. var createEmpty;
  10729. if (Object.prototype.__proto__ === null) {
  10730. createEmpty = function () {
  10731. return { "__proto__": null };
  10732. };
  10733. } else {
  10734. createEmpty = function () {
  10735. var empty = {};
  10736. for (var i in empty)
  10737. empty[i] = null;
  10738. empty.constructor =
  10739. empty.hasOwnProperty =
  10740. empty.propertyIsEnumerable =
  10741. empty.isPrototypeOf =
  10742. empty.toLocaleString =
  10743. empty.toString =
  10744. empty.valueOf =
  10745. empty.__proto__ = null;
  10746. return empty;
  10747. }
  10748. }
  10749. Object.create = function create(prototype, properties) {
  10750. var object;
  10751. if (prototype === null) {
  10752. object = createEmpty();
  10753. } else {
  10754. if (typeof prototype != "object")
  10755. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  10756. var Type = function () {};
  10757. Type.prototype = prototype;
  10758. object = new Type();
  10759. object.__proto__ = prototype;
  10760. }
  10761. if (properties !== void 0)
  10762. Object.defineProperties(object, properties);
  10763. return object;
  10764. };
  10765. }
  10766. function doesDefinePropertyWork(object) {
  10767. try {
  10768. Object.defineProperty(object, "sentinel", {});
  10769. return "sentinel" in object;
  10770. } catch (exception) {
  10771. }
  10772. }
  10773. if (Object.defineProperty) {
  10774. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  10775. var definePropertyWorksOnDom = typeof document == "undefined" ||
  10776. doesDefinePropertyWork(document.createElement("div"));
  10777. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  10778. var definePropertyFallback = Object.defineProperty;
  10779. }
  10780. }
  10781. if (!Object.defineProperty || definePropertyFallback) {
  10782. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  10783. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  10784. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  10785. "on this javascript engine";
  10786. Object.defineProperty = function defineProperty(object, property, descriptor) {
  10787. if ((typeof object != "object" && typeof object != "function") || object === null)
  10788. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  10789. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  10790. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  10791. if (definePropertyFallback) {
  10792. try {
  10793. return definePropertyFallback.call(Object, object, property, descriptor);
  10794. } catch (exception) {
  10795. }
  10796. }
  10797. if (owns(descriptor, "value")) {
  10798. if (supportsAccessors && (lookupGetter(object, property) ||
  10799. lookupSetter(object, property)))
  10800. {
  10801. var prototype = object.__proto__;
  10802. object.__proto__ = prototypeOfObject;
  10803. delete object[property];
  10804. object[property] = descriptor.value;
  10805. object.__proto__ = prototype;
  10806. } else {
  10807. object[property] = descriptor.value;
  10808. }
  10809. } else {
  10810. if (!supportsAccessors)
  10811. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  10812. if (owns(descriptor, "get"))
  10813. defineGetter(object, property, descriptor.get);
  10814. if (owns(descriptor, "set"))
  10815. defineSetter(object, property, descriptor.set);
  10816. }
  10817. return object;
  10818. };
  10819. }
  10820. if (!Object.defineProperties) {
  10821. Object.defineProperties = function defineProperties(object, properties) {
  10822. for (var property in properties) {
  10823. if (owns(properties, property))
  10824. Object.defineProperty(object, property, properties[property]);
  10825. }
  10826. return object;
  10827. };
  10828. }
  10829. if (!Object.seal) {
  10830. Object.seal = function seal(object) {
  10831. return object;
  10832. };
  10833. }
  10834. if (!Object.freeze) {
  10835. Object.freeze = function freeze(object) {
  10836. return object;
  10837. };
  10838. }
  10839. try {
  10840. Object.freeze(function () {});
  10841. } catch (exception) {
  10842. Object.freeze = (function freeze(freezeObject) {
  10843. return function freeze(object) {
  10844. if (typeof object == "function") {
  10845. return object;
  10846. } else {
  10847. return freezeObject(object);
  10848. }
  10849. };
  10850. })(Object.freeze);
  10851. }
  10852. if (!Object.preventExtensions) {
  10853. Object.preventExtensions = function preventExtensions(object) {
  10854. return object;
  10855. };
  10856. }
  10857. if (!Object.isSealed) {
  10858. Object.isSealed = function isSealed(object) {
  10859. return false;
  10860. };
  10861. }
  10862. if (!Object.isFrozen) {
  10863. Object.isFrozen = function isFrozen(object) {
  10864. return false;
  10865. };
  10866. }
  10867. if (!Object.isExtensible) {
  10868. Object.isExtensible = function isExtensible(object) {
  10869. if (Object(object) === object) {
  10870. throw new TypeError(); // TODO message
  10871. }
  10872. var name = '';
  10873. while (owns(object, name)) {
  10874. name += '?';
  10875. }
  10876. object[name] = true;
  10877. var returnValue = owns(object, name);
  10878. delete object[name];
  10879. return returnValue;
  10880. };
  10881. }
  10882. if (!Object.keys) {
  10883. var hasDontEnumBug = true,
  10884. dontEnums = [
  10885. "toString",
  10886. "toLocaleString",
  10887. "valueOf",
  10888. "hasOwnProperty",
  10889. "isPrototypeOf",
  10890. "propertyIsEnumerable",
  10891. "constructor"
  10892. ],
  10893. dontEnumsLength = dontEnums.length;
  10894. for (var key in {"toString": null}) {
  10895. hasDontEnumBug = false;
  10896. }
  10897. Object.keys = function keys(object) {
  10898. if (
  10899. (typeof object != "object" && typeof object != "function") ||
  10900. object === null
  10901. ) {
  10902. throw new TypeError("Object.keys called on a non-object");
  10903. }
  10904. var keys = [];
  10905. for (var name in object) {
  10906. if (owns(object, name)) {
  10907. keys.push(name);
  10908. }
  10909. }
  10910. if (hasDontEnumBug) {
  10911. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  10912. var dontEnum = dontEnums[i];
  10913. if (owns(object, dontEnum)) {
  10914. keys.push(dontEnum);
  10915. }
  10916. }
  10917. }
  10918. return keys;
  10919. };
  10920. }
  10921. if (!Date.now) {
  10922. Date.now = function now() {
  10923. return new Date().getTime();
  10924. };
  10925. }
  10926. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  10927. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  10928. "\u2029\uFEFF";
  10929. if (!String.prototype.trim || ws.trim()) {
  10930. ws = "[" + ws + "]";
  10931. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  10932. trimEndRegexp = new RegExp(ws + ws + "*$");
  10933. String.prototype.trim = function trim() {
  10934. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  10935. };
  10936. }
  10937. function toInteger(n) {
  10938. n = +n;
  10939. if (n !== n) { // isNaN
  10940. n = 0;
  10941. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  10942. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  10943. }
  10944. return n;
  10945. }
  10946. function isPrimitive(input) {
  10947. var type = typeof input;
  10948. return (
  10949. input === null ||
  10950. type === "undefined" ||
  10951. type === "boolean" ||
  10952. type === "number" ||
  10953. type === "string"
  10954. );
  10955. }
  10956. function toPrimitive(input) {
  10957. var val, valueOf, toString;
  10958. if (isPrimitive(input)) {
  10959. return input;
  10960. }
  10961. valueOf = input.valueOf;
  10962. if (typeof valueOf === "function") {
  10963. val = valueOf.call(input);
  10964. if (isPrimitive(val)) {
  10965. return val;
  10966. }
  10967. }
  10968. toString = input.toString;
  10969. if (typeof toString === "function") {
  10970. val = toString.call(input);
  10971. if (isPrimitive(val)) {
  10972. return val;
  10973. }
  10974. }
  10975. throw new TypeError();
  10976. }
  10977. var toObject = function (o) {
  10978. if (o == null) { // this matches both null and undefined
  10979. throw new TypeError("can't convert "+o+" to object");
  10980. }
  10981. return Object(o);
  10982. };
  10983. });