worker-javascript.js 337 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528
  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.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",["require","exports","module"], 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",["require","exports","module"], 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",["require","exports","module"], 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",["require","exports","module"], 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. callback && this.addEventListener(eventName, function newCallback() {
  534. _self.removeEventListener(eventName, newCallback);
  535. callback.apply(null, arguments);
  536. });
  537. };
  538. EventEmitter.setDefaultHandler = function(eventName, callback) {
  539. var handlers = this._defaultHandlers
  540. if (!handlers)
  541. handlers = this._defaultHandlers = {_disabled_: {}};
  542. if (handlers[eventName]) {
  543. var old = handlers[eventName];
  544. var disabled = handlers._disabled_[eventName];
  545. if (!disabled)
  546. handlers._disabled_[eventName] = disabled = [];
  547. disabled.push(old);
  548. var i = disabled.indexOf(callback);
  549. if (i != -1)
  550. disabled.splice(i, 1);
  551. }
  552. handlers[eventName] = callback;
  553. };
  554. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  555. var handlers = this._defaultHandlers
  556. if (!handlers)
  557. return;
  558. var disabled = handlers._disabled_[eventName];
  559. if (handlers[eventName] == callback) {
  560. var old = handlers[eventName];
  561. if (disabled)
  562. this.setDefaultHandler(eventName, disabled.pop());
  563. } else if (disabled) {
  564. var i = disabled.indexOf(callback);
  565. if (i != -1)
  566. disabled.splice(i, 1);
  567. }
  568. };
  569. EventEmitter.on =
  570. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  571. this._eventRegistry = this._eventRegistry || {};
  572. var listeners = this._eventRegistry[eventName];
  573. if (!listeners)
  574. listeners = this._eventRegistry[eventName] = [];
  575. if (listeners.indexOf(callback) == -1)
  576. listeners[capturing ? "unshift" : "push"](callback);
  577. return callback;
  578. };
  579. EventEmitter.off =
  580. EventEmitter.removeListener =
  581. EventEmitter.removeEventListener = function(eventName, callback) {
  582. this._eventRegistry = this._eventRegistry || {};
  583. var listeners = this._eventRegistry[eventName];
  584. if (!listeners)
  585. return;
  586. var index = listeners.indexOf(callback);
  587. if (index !== -1)
  588. listeners.splice(index, 1);
  589. };
  590. EventEmitter.removeAllListeners = function(eventName) {
  591. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  592. };
  593. exports.EventEmitter = EventEmitter;
  594. });
  595. ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  596. "use strict";
  597. var oop = require("./lib/oop");
  598. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  599. var Anchor = exports.Anchor = function(doc, row, column) {
  600. this.$onChange = this.onChange.bind(this);
  601. this.attach(doc);
  602. if (typeof column == "undefined")
  603. this.setPosition(row.row, row.column);
  604. else
  605. this.setPosition(row, column);
  606. };
  607. (function() {
  608. oop.implement(this, EventEmitter);
  609. this.getPosition = function() {
  610. return this.$clipPositionToDocument(this.row, this.column);
  611. };
  612. this.getDocument = function() {
  613. return this.document;
  614. };
  615. this.$insertRight = false;
  616. this.onChange = function(delta) {
  617. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  618. return;
  619. if (delta.start.row > this.row)
  620. return;
  621. var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
  622. this.setPosition(point.row, point.column, true);
  623. };
  624. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  625. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  626. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  627. }
  628. function $getTransformedPoint(delta, point, moveIfEqual) {
  629. var deltaIsInsert = delta.action == "insert";
  630. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  631. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  632. var deltaStart = delta.start;
  633. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  634. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  635. return {
  636. row: point.row,
  637. column: point.column
  638. };
  639. }
  640. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  641. return {
  642. row: point.row + deltaRowShift,
  643. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  644. };
  645. }
  646. return {
  647. row: deltaStart.row,
  648. column: deltaStart.column
  649. };
  650. }
  651. this.setPosition = function(row, column, noClip) {
  652. var pos;
  653. if (noClip) {
  654. pos = {
  655. row: row,
  656. column: column
  657. };
  658. } else {
  659. pos = this.$clipPositionToDocument(row, column);
  660. }
  661. if (this.row == pos.row && this.column == pos.column)
  662. return;
  663. var old = {
  664. row: this.row,
  665. column: this.column
  666. };
  667. this.row = pos.row;
  668. this.column = pos.column;
  669. this._signal("change", {
  670. old: old,
  671. value: pos
  672. });
  673. };
  674. this.detach = function() {
  675. this.document.removeEventListener("change", this.$onChange);
  676. };
  677. this.attach = function(doc) {
  678. this.document = doc || this.document;
  679. this.document.on("change", this.$onChange);
  680. };
  681. this.$clipPositionToDocument = function(row, column) {
  682. var pos = {};
  683. if (row >= this.document.getLength()) {
  684. pos.row = Math.max(0, this.document.getLength() - 1);
  685. pos.column = this.document.getLine(pos.row).length;
  686. }
  687. else if (row < 0) {
  688. pos.row = 0;
  689. pos.column = 0;
  690. }
  691. else {
  692. pos.row = row;
  693. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  694. }
  695. if (column < 0)
  696. pos.column = 0;
  697. return pos;
  698. };
  699. }).call(Anchor.prototype);
  700. });
  701. ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
  702. "use strict";
  703. var oop = require("./lib/oop");
  704. var applyDelta = require("./apply_delta").applyDelta;
  705. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  706. var Range = require("./range").Range;
  707. var Anchor = require("./anchor").Anchor;
  708. var Document = function(textOrLines) {
  709. this.$lines = [""];
  710. if (textOrLines.length === 0) {
  711. this.$lines = [""];
  712. } else if (Array.isArray(textOrLines)) {
  713. this.insertMergedLines({row: 0, column: 0}, textOrLines);
  714. } else {
  715. this.insert({row: 0, column:0}, textOrLines);
  716. }
  717. };
  718. (function() {
  719. oop.implement(this, EventEmitter);
  720. this.setValue = function(text) {
  721. var len = this.getLength() - 1;
  722. this.remove(new Range(0, 0, len, this.getLine(len).length));
  723. this.insert({row: 0, column: 0}, text);
  724. };
  725. this.getValue = function() {
  726. return this.getAllLines().join(this.getNewLineCharacter());
  727. };
  728. this.createAnchor = function(row, column) {
  729. return new Anchor(this, row, column);
  730. };
  731. if ("aaa".split(/a/).length === 0) {
  732. this.$split = function(text) {
  733. return text.replace(/\r\n|\r/g, "\n").split("\n");
  734. };
  735. } else {
  736. this.$split = function(text) {
  737. return text.split(/\r\n|\r|\n/);
  738. };
  739. }
  740. this.$detectNewLine = function(text) {
  741. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  742. this.$autoNewLine = match ? match[1] : "\n";
  743. this._signal("changeNewLineMode");
  744. };
  745. this.getNewLineCharacter = function() {
  746. switch (this.$newLineMode) {
  747. case "windows":
  748. return "\r\n";
  749. case "unix":
  750. return "\n";
  751. default:
  752. return this.$autoNewLine || "\n";
  753. }
  754. };
  755. this.$autoNewLine = "";
  756. this.$newLineMode = "auto";
  757. this.setNewLineMode = function(newLineMode) {
  758. if (this.$newLineMode === newLineMode)
  759. return;
  760. this.$newLineMode = newLineMode;
  761. this._signal("changeNewLineMode");
  762. };
  763. this.getNewLineMode = function() {
  764. return this.$newLineMode;
  765. };
  766. this.isNewLine = function(text) {
  767. return (text == "\r\n" || text == "\r" || text == "\n");
  768. };
  769. this.getLine = function(row) {
  770. return this.$lines[row] || "";
  771. };
  772. this.getLines = function(firstRow, lastRow) {
  773. return this.$lines.slice(firstRow, lastRow + 1);
  774. };
  775. this.getAllLines = function() {
  776. return this.getLines(0, this.getLength());
  777. };
  778. this.getLength = function() {
  779. return this.$lines.length;
  780. };
  781. this.getTextRange = function(range) {
  782. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  783. };
  784. this.getLinesForRange = function(range) {
  785. var lines;
  786. if (range.start.row === range.end.row) {
  787. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  788. } else {
  789. lines = this.getLines(range.start.row, range.end.row);
  790. lines[0] = (lines[0] || "").substring(range.start.column);
  791. var l = lines.length - 1;
  792. if (range.end.row - range.start.row == l)
  793. lines[l] = lines[l].substring(0, range.end.column);
  794. }
  795. return lines;
  796. };
  797. this.insertLines = function(row, lines) {
  798. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  799. return this.insertFullLines(row, lines);
  800. };
  801. this.removeLines = function(firstRow, lastRow) {
  802. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  803. return this.removeFullLines(firstRow, lastRow);
  804. };
  805. this.insertNewLine = function(position) {
  806. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
  807. return this.insertMergedLines(position, ["", ""]);
  808. };
  809. this.insert = function(position, text) {
  810. if (this.getLength() <= 1)
  811. this.$detectNewLine(text);
  812. return this.insertMergedLines(position, this.$split(text));
  813. };
  814. this.insertInLine = function(position, text) {
  815. var start = this.clippedPos(position.row, position.column);
  816. var end = this.pos(position.row, position.column + text.length);
  817. this.applyDelta({
  818. start: start,
  819. end: end,
  820. action: "insert",
  821. lines: [text]
  822. }, true);
  823. return this.clonePos(end);
  824. };
  825. this.clippedPos = function(row, column) {
  826. var length = this.getLength();
  827. if (row === undefined) {
  828. row = length;
  829. } else if (row < 0) {
  830. row = 0;
  831. } else if (row >= length) {
  832. row = length - 1;
  833. column = undefined;
  834. }
  835. var line = this.getLine(row);
  836. if (column == undefined)
  837. column = line.length;
  838. column = Math.min(Math.max(column, 0), line.length);
  839. return {row: row, column: column};
  840. };
  841. this.clonePos = function(pos) {
  842. return {row: pos.row, column: pos.column};
  843. };
  844. this.pos = function(row, column) {
  845. return {row: row, column: column};
  846. };
  847. this.$clipPosition = function(position) {
  848. var length = this.getLength();
  849. if (position.row >= length) {
  850. position.row = Math.max(0, length - 1);
  851. position.column = this.getLine(length - 1).length;
  852. } else {
  853. position.row = Math.max(0, position.row);
  854. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  855. }
  856. return position;
  857. };
  858. this.insertFullLines = function(row, lines) {
  859. row = Math.min(Math.max(row, 0), this.getLength());
  860. var column = 0;
  861. if (row < this.getLength()) {
  862. lines = lines.concat([""]);
  863. column = 0;
  864. } else {
  865. lines = [""].concat(lines);
  866. row--;
  867. column = this.$lines[row].length;
  868. }
  869. this.insertMergedLines({row: row, column: column}, lines);
  870. };
  871. this.insertMergedLines = function(position, lines) {
  872. var start = this.clippedPos(position.row, position.column);
  873. var end = {
  874. row: start.row + lines.length - 1,
  875. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  876. };
  877. this.applyDelta({
  878. start: start,
  879. end: end,
  880. action: "insert",
  881. lines: lines
  882. });
  883. return this.clonePos(end);
  884. };
  885. this.remove = function(range) {
  886. var start = this.clippedPos(range.start.row, range.start.column);
  887. var end = this.clippedPos(range.end.row, range.end.column);
  888. this.applyDelta({
  889. start: start,
  890. end: end,
  891. action: "remove",
  892. lines: this.getLinesForRange({start: start, end: end})
  893. });
  894. return this.clonePos(start);
  895. };
  896. this.removeInLine = function(row, startColumn, endColumn) {
  897. var start = this.clippedPos(row, startColumn);
  898. var end = this.clippedPos(row, endColumn);
  899. this.applyDelta({
  900. start: start,
  901. end: end,
  902. action: "remove",
  903. lines: this.getLinesForRange({start: start, end: end})
  904. }, true);
  905. return this.clonePos(start);
  906. };
  907. this.removeFullLines = function(firstRow, lastRow) {
  908. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  909. lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
  910. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  911. var deleteLastNewLine = lastRow < this.getLength() - 1;
  912. var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
  913. var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
  914. var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
  915. var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
  916. var range = new Range(startRow, startCol, endRow, endCol);
  917. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  918. this.applyDelta({
  919. start: range.start,
  920. end: range.end,
  921. action: "remove",
  922. lines: this.getLinesForRange(range)
  923. });
  924. return deletedLines;
  925. };
  926. this.removeNewLine = function(row) {
  927. if (row < this.getLength() - 1 && row >= 0) {
  928. this.applyDelta({
  929. start: this.pos(row, this.getLine(row).length),
  930. end: this.pos(row + 1, 0),
  931. action: "remove",
  932. lines: ["", ""]
  933. });
  934. }
  935. };
  936. this.replace = function(range, text) {
  937. if (!(range instanceof Range))
  938. range = Range.fromPoints(range.start, range.end);
  939. if (text.length === 0 && range.isEmpty())
  940. return range.start;
  941. if (text == this.getTextRange(range))
  942. return range.end;
  943. this.remove(range);
  944. var end;
  945. if (text) {
  946. end = this.insert(range.start, text);
  947. }
  948. else {
  949. end = range.start;
  950. }
  951. return end;
  952. };
  953. this.applyDeltas = function(deltas) {
  954. for (var i=0; i<deltas.length; i++) {
  955. this.applyDelta(deltas[i]);
  956. }
  957. };
  958. this.revertDeltas = function(deltas) {
  959. for (var i=deltas.length-1; i>=0; i--) {
  960. this.revertDelta(deltas[i]);
  961. }
  962. };
  963. this.applyDelta = function(delta, doNotValidate) {
  964. var isInsert = delta.action == "insert";
  965. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  966. : !Range.comparePoints(delta.start, delta.end)) {
  967. return;
  968. }
  969. if (isInsert && delta.lines.length > 20000)
  970. this.$splitAndapplyLargeDelta(delta, 20000);
  971. applyDelta(this.$lines, delta, doNotValidate);
  972. this._signal("change", delta);
  973. };
  974. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  975. var lines = delta.lines;
  976. var l = lines.length;
  977. var row = delta.start.row;
  978. var column = delta.start.column;
  979. var from = 0, to = 0;
  980. do {
  981. from = to;
  982. to += MAX - 1;
  983. var chunk = lines.slice(from, to);
  984. if (to > l) {
  985. delta.lines = chunk;
  986. delta.start.row = row + from;
  987. delta.start.column = column;
  988. break;
  989. }
  990. chunk.push("");
  991. this.applyDelta({
  992. start: this.pos(row + from, column),
  993. end: this.pos(row + to, column = 0),
  994. action: delta.action,
  995. lines: chunk
  996. }, true);
  997. } while(true);
  998. };
  999. this.revertDelta = function(delta) {
  1000. this.applyDelta({
  1001. start: this.clonePos(delta.start),
  1002. end: this.clonePos(delta.end),
  1003. action: (delta.action == "insert" ? "remove" : "insert"),
  1004. lines: delta.lines.slice()
  1005. });
  1006. };
  1007. this.indexToPosition = function(index, startRow) {
  1008. var lines = this.$lines || this.getAllLines();
  1009. var newlineLength = this.getNewLineCharacter().length;
  1010. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1011. index -= lines[i].length + newlineLength;
  1012. if (index < 0)
  1013. return {row: i, column: index + lines[i].length + newlineLength};
  1014. }
  1015. return {row: l-1, column: lines[l-1].length};
  1016. };
  1017. this.positionToIndex = function(pos, startRow) {
  1018. var lines = this.$lines || this.getAllLines();
  1019. var newlineLength = this.getNewLineCharacter().length;
  1020. var index = 0;
  1021. var row = Math.min(pos.row, lines.length);
  1022. for (var i = startRow || 0; i < row; ++i)
  1023. index += lines[i].length + newlineLength;
  1024. return index + pos.column;
  1025. };
  1026. }).call(Document.prototype);
  1027. exports.Document = Document;
  1028. });
  1029. ace.define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  1030. "use strict";
  1031. exports.last = function(a) {
  1032. return a[a.length - 1];
  1033. };
  1034. exports.stringReverse = function(string) {
  1035. return string.split("").reverse().join("");
  1036. };
  1037. exports.stringRepeat = function (string, count) {
  1038. var result = '';
  1039. while (count > 0) {
  1040. if (count & 1)
  1041. result += string;
  1042. if (count >>= 1)
  1043. string += string;
  1044. }
  1045. return result;
  1046. };
  1047. var trimBeginRegexp = /^\s\s*/;
  1048. var trimEndRegexp = /\s\s*$/;
  1049. exports.stringTrimLeft = function (string) {
  1050. return string.replace(trimBeginRegexp, '');
  1051. };
  1052. exports.stringTrimRight = function (string) {
  1053. return string.replace(trimEndRegexp, '');
  1054. };
  1055. exports.copyObject = function(obj) {
  1056. var copy = {};
  1057. for (var key in obj) {
  1058. copy[key] = obj[key];
  1059. }
  1060. return copy;
  1061. };
  1062. exports.copyArray = function(array){
  1063. var copy = [];
  1064. for (var i=0, l=array.length; i<l; i++) {
  1065. if (array[i] && typeof array[i] == "object")
  1066. copy[i] = this.copyObject(array[i]);
  1067. else
  1068. copy[i] = array[i];
  1069. }
  1070. return copy;
  1071. };
  1072. exports.deepCopy = function deepCopy(obj) {
  1073. if (typeof obj !== "object" || !obj)
  1074. return obj;
  1075. var copy;
  1076. if (Array.isArray(obj)) {
  1077. copy = [];
  1078. for (var key = 0; key < obj.length; key++) {
  1079. copy[key] = deepCopy(obj[key]);
  1080. }
  1081. return copy;
  1082. }
  1083. if (Object.prototype.toString.call(obj) !== "[object Object]")
  1084. return obj;
  1085. copy = {};
  1086. for (var key in obj)
  1087. copy[key] = deepCopy(obj[key]);
  1088. return copy;
  1089. };
  1090. exports.arrayToMap = function(arr) {
  1091. var map = {};
  1092. for (var i=0; i<arr.length; i++) {
  1093. map[arr[i]] = 1;
  1094. }
  1095. return map;
  1096. };
  1097. exports.createMap = function(props) {
  1098. var map = Object.create(null);
  1099. for (var i in props) {
  1100. map[i] = props[i];
  1101. }
  1102. return map;
  1103. };
  1104. exports.arrayRemove = function(array, value) {
  1105. for (var i = 0; i <= array.length; i++) {
  1106. if (value === array[i]) {
  1107. array.splice(i, 1);
  1108. }
  1109. }
  1110. };
  1111. exports.escapeRegExp = function(str) {
  1112. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1113. };
  1114. exports.escapeHTML = function(str) {
  1115. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1116. };
  1117. exports.getMatchOffsets = function(string, regExp) {
  1118. var matches = [];
  1119. string.replace(regExp, function(str) {
  1120. matches.push({
  1121. offset: arguments[arguments.length-2],
  1122. length: str.length
  1123. });
  1124. });
  1125. return matches;
  1126. };
  1127. exports.deferredCall = function(fcn) {
  1128. var timer = null;
  1129. var callback = function() {
  1130. timer = null;
  1131. fcn();
  1132. };
  1133. var deferred = function(timeout) {
  1134. deferred.cancel();
  1135. timer = setTimeout(callback, timeout || 0);
  1136. return deferred;
  1137. };
  1138. deferred.schedule = deferred;
  1139. deferred.call = function() {
  1140. this.cancel();
  1141. fcn();
  1142. return deferred;
  1143. };
  1144. deferred.cancel = function() {
  1145. clearTimeout(timer);
  1146. timer = null;
  1147. return deferred;
  1148. };
  1149. deferred.isPending = function() {
  1150. return timer;
  1151. };
  1152. return deferred;
  1153. };
  1154. exports.delayedCall = function(fcn, defaultTimeout) {
  1155. var timer = null;
  1156. var callback = function() {
  1157. timer = null;
  1158. fcn();
  1159. };
  1160. var _self = function(timeout) {
  1161. if (timer == null)
  1162. timer = setTimeout(callback, timeout || defaultTimeout);
  1163. };
  1164. _self.delay = function(timeout) {
  1165. timer && clearTimeout(timer);
  1166. timer = setTimeout(callback, timeout || defaultTimeout);
  1167. };
  1168. _self.schedule = _self;
  1169. _self.call = function() {
  1170. this.cancel();
  1171. fcn();
  1172. };
  1173. _self.cancel = function() {
  1174. timer && clearTimeout(timer);
  1175. timer = null;
  1176. };
  1177. _self.isPending = function() {
  1178. return timer;
  1179. };
  1180. return _self;
  1181. };
  1182. });
  1183. ace.define("ace/worker/mirror",["require","exports","module","ace/range","ace/document","ace/lib/lang"], function(require, exports, module) {
  1184. "use strict";
  1185. var Range = require("../range").Range;
  1186. var Document = require("../document").Document;
  1187. var lang = require("../lib/lang");
  1188. var Mirror = exports.Mirror = function(sender) {
  1189. this.sender = sender;
  1190. var doc = this.doc = new Document("");
  1191. var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  1192. var _self = this;
  1193. sender.on("change", function(e) {
  1194. var data = e.data;
  1195. if (data[0].start) {
  1196. doc.applyDeltas(data);
  1197. } else {
  1198. for (var i = 0; i < data.length; i += 2) {
  1199. if (Array.isArray(data[i+1])) {
  1200. var d = {action: "insert", start: data[i], lines: data[i+1]};
  1201. } else {
  1202. var d = {action: "remove", start: data[i], end: data[i+1]};
  1203. }
  1204. doc.applyDelta(d, true);
  1205. }
  1206. }
  1207. if (_self.$timeout)
  1208. return deferredUpdate.schedule(_self.$timeout);
  1209. _self.onUpdate();
  1210. });
  1211. };
  1212. (function() {
  1213. this.$timeout = 500;
  1214. this.setTimeout = function(timeout) {
  1215. this.$timeout = timeout;
  1216. };
  1217. this.setValue = function(value) {
  1218. this.doc.setValue(value);
  1219. this.deferredUpdate.schedule(this.$timeout);
  1220. };
  1221. this.getValue = function(callbackId) {
  1222. this.sender.callback(this.doc.getValue(), callbackId);
  1223. };
  1224. this.onUpdate = function() {
  1225. };
  1226. this.isPending = function() {
  1227. return this.deferredUpdate.isPending();
  1228. };
  1229. }).call(Mirror.prototype);
  1230. });
  1231. ace.define("ace/mode/javascript/jshint",["require","exports","module"], function(require, exports, module) {
  1232. module.exports = (function outer (modules, cache, entry) {
  1233. var previousRequire = typeof require == "function" && require;
  1234. function newRequire(name, jumped){
  1235. if(!cache[name]) {
  1236. if(!modules[name]) {
  1237. var currentRequire = typeof require == "function" && require;
  1238. if (!jumped && currentRequire) return currentRequire(name, true);
  1239. if (previousRequire) return previousRequire(name, true);
  1240. var err = new Error('Cannot find module \'' + name + '\'');
  1241. err.code = 'MODULE_NOT_FOUND';
  1242. throw err;
  1243. }
  1244. var m = cache[name] = {exports:{}};
  1245. modules[name][0].call(m.exports, function(x){
  1246. var id = modules[name][1][x];
  1247. return newRequire(id ? id : x);
  1248. },m,m.exports,outer,modules,cache,entry);
  1249. }
  1250. return cache[name].exports;
  1251. }
  1252. for(var i=0;i<entry.length;i++) newRequire(entry[i]);
  1253. return newRequire(entry[0]);
  1254. })
  1255. ({"/node_modules/browserify/node_modules/events/events.js":[function(_dereq_,module,exports){
  1256. function EventEmitter() {
  1257. this._events = this._events || {};
  1258. this._maxListeners = this._maxListeners || undefined;
  1259. }
  1260. module.exports = EventEmitter;
  1261. EventEmitter.EventEmitter = EventEmitter;
  1262. EventEmitter.prototype._events = undefined;
  1263. EventEmitter.prototype._maxListeners = undefined;
  1264. EventEmitter.defaultMaxListeners = 10;
  1265. EventEmitter.prototype.setMaxListeners = function(n) {
  1266. if (!isNumber(n) || n < 0 || isNaN(n))
  1267. throw TypeError('n must be a positive number');
  1268. this._maxListeners = n;
  1269. return this;
  1270. };
  1271. EventEmitter.prototype.emit = function(type) {
  1272. var er, handler, len, args, i, listeners;
  1273. if (!this._events)
  1274. this._events = {};
  1275. if (type === 'error') {
  1276. if (!this._events.error ||
  1277. (isObject(this._events.error) && !this._events.error.length)) {
  1278. er = arguments[1];
  1279. if (er instanceof Error) {
  1280. throw er; // Unhandled 'error' event
  1281. }
  1282. throw TypeError('Uncaught, unspecified "error" event.');
  1283. }
  1284. }
  1285. handler = this._events[type];
  1286. if (isUndefined(handler))
  1287. return false;
  1288. if (isFunction(handler)) {
  1289. switch (arguments.length) {
  1290. case 1:
  1291. handler.call(this);
  1292. break;
  1293. case 2:
  1294. handler.call(this, arguments[1]);
  1295. break;
  1296. case 3:
  1297. handler.call(this, arguments[1], arguments[2]);
  1298. break;
  1299. default:
  1300. len = arguments.length;
  1301. args = new Array(len - 1);
  1302. for (i = 1; i < len; i++)
  1303. args[i - 1] = arguments[i];
  1304. handler.apply(this, args);
  1305. }
  1306. } else if (isObject(handler)) {
  1307. len = arguments.length;
  1308. args = new Array(len - 1);
  1309. for (i = 1; i < len; i++)
  1310. args[i - 1] = arguments[i];
  1311. listeners = handler.slice();
  1312. len = listeners.length;
  1313. for (i = 0; i < len; i++)
  1314. listeners[i].apply(this, args);
  1315. }
  1316. return true;
  1317. };
  1318. EventEmitter.prototype.addListener = function(type, listener) {
  1319. var m;
  1320. if (!isFunction(listener))
  1321. throw TypeError('listener must be a function');
  1322. if (!this._events)
  1323. this._events = {};
  1324. if (this._events.newListener)
  1325. this.emit('newListener', type,
  1326. isFunction(listener.listener) ?
  1327. listener.listener : listener);
  1328. if (!this._events[type])
  1329. this._events[type] = listener;
  1330. else if (isObject(this._events[type]))
  1331. this._events[type].push(listener);
  1332. else
  1333. this._events[type] = [this._events[type], listener];
  1334. if (isObject(this._events[type]) && !this._events[type].warned) {
  1335. var m;
  1336. if (!isUndefined(this._maxListeners)) {
  1337. m = this._maxListeners;
  1338. } else {
  1339. m = EventEmitter.defaultMaxListeners;
  1340. }
  1341. if (m && m > 0 && this._events[type].length > m) {
  1342. this._events[type].warned = true;
  1343. console.error('(node) warning: possible EventEmitter memory ' +
  1344. 'leak detected. %d listeners added. ' +
  1345. 'Use emitter.setMaxListeners() to increase limit.',
  1346. this._events[type].length);
  1347. if (typeof console.trace === 'function') {
  1348. console.trace();
  1349. }
  1350. }
  1351. }
  1352. return this;
  1353. };
  1354. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  1355. EventEmitter.prototype.once = function(type, listener) {
  1356. if (!isFunction(listener))
  1357. throw TypeError('listener must be a function');
  1358. var fired = false;
  1359. function g() {
  1360. this.removeListener(type, g);
  1361. if (!fired) {
  1362. fired = true;
  1363. listener.apply(this, arguments);
  1364. }
  1365. }
  1366. g.listener = listener;
  1367. this.on(type, g);
  1368. return this;
  1369. };
  1370. EventEmitter.prototype.removeListener = function(type, listener) {
  1371. var list, position, length, i;
  1372. if (!isFunction(listener))
  1373. throw TypeError('listener must be a function');
  1374. if (!this._events || !this._events[type])
  1375. return this;
  1376. list = this._events[type];
  1377. length = list.length;
  1378. position = -1;
  1379. if (list === listener ||
  1380. (isFunction(list.listener) && list.listener === listener)) {
  1381. delete this._events[type];
  1382. if (this._events.removeListener)
  1383. this.emit('removeListener', type, listener);
  1384. } else if (isObject(list)) {
  1385. for (i = length; i-- > 0;) {
  1386. if (list[i] === listener ||
  1387. (list[i].listener && list[i].listener === listener)) {
  1388. position = i;
  1389. break;
  1390. }
  1391. }
  1392. if (position < 0)
  1393. return this;
  1394. if (list.length === 1) {
  1395. list.length = 0;
  1396. delete this._events[type];
  1397. } else {
  1398. list.splice(position, 1);
  1399. }
  1400. if (this._events.removeListener)
  1401. this.emit('removeListener', type, listener);
  1402. }
  1403. return this;
  1404. };
  1405. EventEmitter.prototype.removeAllListeners = function(type) {
  1406. var key, listeners;
  1407. if (!this._events)
  1408. return this;
  1409. if (!this._events.removeListener) {
  1410. if (arguments.length === 0)
  1411. this._events = {};
  1412. else if (this._events[type])
  1413. delete this._events[type];
  1414. return this;
  1415. }
  1416. if (arguments.length === 0) {
  1417. for (key in this._events) {
  1418. if (key === 'removeListener') continue;
  1419. this.removeAllListeners(key);
  1420. }
  1421. this.removeAllListeners('removeListener');
  1422. this._events = {};
  1423. return this;
  1424. }
  1425. listeners = this._events[type];
  1426. if (isFunction(listeners)) {
  1427. this.removeListener(type, listeners);
  1428. } else {
  1429. while (listeners.length)
  1430. this.removeListener(type, listeners[listeners.length - 1]);
  1431. }
  1432. delete this._events[type];
  1433. return this;
  1434. };
  1435. EventEmitter.prototype.listeners = function(type) {
  1436. var ret;
  1437. if (!this._events || !this._events[type])
  1438. ret = [];
  1439. else if (isFunction(this._events[type]))
  1440. ret = [this._events[type]];
  1441. else
  1442. ret = this._events[type].slice();
  1443. return ret;
  1444. };
  1445. EventEmitter.listenerCount = function(emitter, type) {
  1446. var ret;
  1447. if (!emitter._events || !emitter._events[type])
  1448. ret = 0;
  1449. else if (isFunction(emitter._events[type]))
  1450. ret = 1;
  1451. else
  1452. ret = emitter._events[type].length;
  1453. return ret;
  1454. };
  1455. function isFunction(arg) {
  1456. return typeof arg === 'function';
  1457. }
  1458. function isNumber(arg) {
  1459. return typeof arg === 'number';
  1460. }
  1461. function isObject(arg) {
  1462. return typeof arg === 'object' && arg !== null;
  1463. }
  1464. function isUndefined(arg) {
  1465. return arg === void 0;
  1466. }
  1467. },{}],"/node_modules/jshint/data/ascii-identifier-data.js":[function(_dereq_,module,exports){
  1468. var identifierStartTable = [];
  1469. for (var i = 0; i < 128; i++) {
  1470. identifierStartTable[i] =
  1471. i === 36 || // $
  1472. i >= 65 && i <= 90 || // A-Z
  1473. i === 95 || // _
  1474. i >= 97 && i <= 122; // a-z
  1475. }
  1476. var identifierPartTable = [];
  1477. for (var i = 0; i < 128; i++) {
  1478. identifierPartTable[i] =
  1479. identifierStartTable[i] || // $, _, A-Z, a-z
  1480. i >= 48 && i <= 57; // 0-9
  1481. }
  1482. module.exports = {
  1483. asciiIdentifierStartTable: identifierStartTable,
  1484. asciiIdentifierPartTable: identifierPartTable
  1485. };
  1486. },{}],"/node_modules/jshint/lodash.js":[function(_dereq_,module,exports){
  1487. (function (global){
  1488. ;(function() {
  1489. var undefined;
  1490. var VERSION = '3.7.0';
  1491. var FUNC_ERROR_TEXT = 'Expected a function';
  1492. var argsTag = '[object Arguments]',
  1493. arrayTag = '[object Array]',
  1494. boolTag = '[object Boolean]',
  1495. dateTag = '[object Date]',
  1496. errorTag = '[object Error]',
  1497. funcTag = '[object Function]',
  1498. mapTag = '[object Map]',
  1499. numberTag = '[object Number]',
  1500. objectTag = '[object Object]',
  1501. regexpTag = '[object RegExp]',
  1502. setTag = '[object Set]',
  1503. stringTag = '[object String]',
  1504. weakMapTag = '[object WeakMap]';
  1505. var arrayBufferTag = '[object ArrayBuffer]',
  1506. float32Tag = '[object Float32Array]',
  1507. float64Tag = '[object Float64Array]',
  1508. int8Tag = '[object Int8Array]',
  1509. int16Tag = '[object Int16Array]',
  1510. int32Tag = '[object Int32Array]',
  1511. uint8Tag = '[object Uint8Array]',
  1512. uint8ClampedTag = '[object Uint8ClampedArray]',
  1513. uint16Tag = '[object Uint16Array]',
  1514. uint32Tag = '[object Uint32Array]';
  1515. var reIsDeepProp = /\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,
  1516. reIsPlainProp = /^\w*$/,
  1517. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  1518. var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
  1519. reHasRegExpChars = RegExp(reRegExpChars.source);
  1520. var reEscapeChar = /\\(\\)?/g;
  1521. var reFlags = /\w*$/;
  1522. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1523. var typedArrayTags = {};
  1524. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1525. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1526. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1527. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1528. typedArrayTags[uint32Tag] = true;
  1529. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1530. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1531. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  1532. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  1533. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  1534. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  1535. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  1536. var cloneableTags = {};
  1537. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  1538. cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
  1539. cloneableTags[dateTag] = cloneableTags[float32Tag] =
  1540. cloneableTags[float64Tag] = cloneableTags[int8Tag] =
  1541. cloneableTags[int16Tag] = cloneableTags[int32Tag] =
  1542. cloneableTags[numberTag] = cloneableTags[objectTag] =
  1543. cloneableTags[regexpTag] = cloneableTags[stringTag] =
  1544. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  1545. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  1546. cloneableTags[errorTag] = cloneableTags[funcTag] =
  1547. cloneableTags[mapTag] = cloneableTags[setTag] =
  1548. cloneableTags[weakMapTag] = false;
  1549. var objectTypes = {
  1550. 'function': true,
  1551. 'object': true
  1552. };
  1553. var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
  1554. var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
  1555. var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;
  1556. var freeSelf = objectTypes[typeof self] && self && self.Object && self;
  1557. var freeWindow = objectTypes[typeof window] && window && window.Object && window;
  1558. var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
  1559. var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
  1560. function baseFindIndex(array, predicate, fromRight) {
  1561. var length = array.length,
  1562. index = fromRight ? length : -1;
  1563. while ((fromRight ? index-- : ++index < length)) {
  1564. if (predicate(array[index], index, array)) {
  1565. return index;
  1566. }
  1567. }
  1568. return -1;
  1569. }
  1570. function baseIndexOf(array, value, fromIndex) {
  1571. if (value !== value) {
  1572. return indexOfNaN(array, fromIndex);
  1573. }
  1574. var index = fromIndex - 1,
  1575. length = array.length;
  1576. while (++index < length) {
  1577. if (array[index] === value) {
  1578. return index;
  1579. }
  1580. }
  1581. return -1;
  1582. }
  1583. function baseIsFunction(value) {
  1584. return typeof value == 'function' || false;
  1585. }
  1586. function baseToString(value) {
  1587. if (typeof value == 'string') {
  1588. return value;
  1589. }
  1590. return value == null ? '' : (value + '');
  1591. }
  1592. function indexOfNaN(array, fromIndex, fromRight) {
  1593. var length = array.length,
  1594. index = fromIndex + (fromRight ? 0 : -1);
  1595. while ((fromRight ? index-- : ++index < length)) {
  1596. var other = array[index];
  1597. if (other !== other) {
  1598. return index;
  1599. }
  1600. }
  1601. return -1;
  1602. }
  1603. function isObjectLike(value) {
  1604. return !!value && typeof value == 'object';
  1605. }
  1606. var arrayProto = Array.prototype,
  1607. objectProto = Object.prototype;
  1608. var fnToString = Function.prototype.toString;
  1609. var hasOwnProperty = objectProto.hasOwnProperty;
  1610. var objToString = objectProto.toString;
  1611. var reIsNative = RegExp('^' +
  1612. escapeRegExp(objToString)
  1613. .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1614. );
  1615. var ArrayBuffer = isNative(ArrayBuffer = root.ArrayBuffer) && ArrayBuffer,
  1616. bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
  1617. floor = Math.floor,
  1618. getOwnPropertySymbols = isNative(getOwnPropertySymbols = Object.getOwnPropertySymbols) && getOwnPropertySymbols,
  1619. getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
  1620. push = arrayProto.push,
  1621. preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions,
  1622. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  1623. Uint8Array = isNative(Uint8Array = root.Uint8Array) && Uint8Array;
  1624. var Float64Array = (function() {
  1625. try {
  1626. var func = isNative(func = root.Float64Array) && func,
  1627. result = new func(new ArrayBuffer(10), 0, 1) && func;
  1628. } catch(e) {}
  1629. return result;
  1630. }());
  1631. var nativeAssign = (function() {
  1632. var object = { '1': 0 },
  1633. func = preventExtensions && isNative(func = Object.assign) && func;
  1634. try { func(preventExtensions(object), 'xo'); } catch(e) {}
  1635. return !object[1] && func;
  1636. }());
  1637. var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray,
  1638. nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys,
  1639. nativeMax = Math.max,
  1640. nativeMin = Math.min;
  1641. var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;
  1642. var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
  1643. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  1644. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  1645. var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
  1646. var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
  1647. function lodash() {
  1648. }
  1649. var support = lodash.support = {};
  1650. (function(x) {
  1651. var Ctor = function() { this.x = x; },
  1652. object = { '0': x, 'length': x },
  1653. props = [];
  1654. Ctor.prototype = { 'valueOf': x, 'y': x };
  1655. for (var key in new Ctor) { props.push(key); }
  1656. support.funcDecomp = /\bthis\b/.test(function() { return this; });
  1657. support.funcNames = typeof Function.name == 'string';
  1658. try {
  1659. support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
  1660. } catch(e) {
  1661. support.nonEnumArgs = true;
  1662. }
  1663. }(1, 0));
  1664. function arrayCopy(source, array) {
  1665. var index = -1,
  1666. length = source.length;
  1667. array || (array = Array(length));
  1668. while (++index < length) {
  1669. array[index] = source[index];
  1670. }
  1671. return array;
  1672. }
  1673. function arrayEach(array, iteratee) {
  1674. var index = -1,
  1675. length = array.length;
  1676. while (++index < length) {
  1677. if (iteratee(array[index], index, array) === false) {
  1678. break;
  1679. }
  1680. }
  1681. return array;
  1682. }
  1683. function arrayFilter(array, predicate) {
  1684. var index = -1,
  1685. length = array.length,
  1686. resIndex = -1,
  1687. result = [];
  1688. while (++index < length) {
  1689. var value = array[index];
  1690. if (predicate(value, index, array)) {
  1691. result[++resIndex] = value;
  1692. }
  1693. }
  1694. return result;
  1695. }
  1696. function arrayMap(array, iteratee) {
  1697. var index = -1,
  1698. length = array.length,
  1699. result = Array(length);
  1700. while (++index < length) {
  1701. result[index] = iteratee(array[index], index, array);
  1702. }
  1703. return result;
  1704. }
  1705. function arrayMax(array) {
  1706. var index = -1,
  1707. length = array.length,
  1708. result = NEGATIVE_INFINITY;
  1709. while (++index < length) {
  1710. var value = array[index];
  1711. if (value > result) {
  1712. result = value;
  1713. }
  1714. }
  1715. return result;
  1716. }
  1717. function arraySome(array, predicate) {
  1718. var index = -1,
  1719. length = array.length;
  1720. while (++index < length) {
  1721. if (predicate(array[index], index, array)) {
  1722. return true;
  1723. }
  1724. }
  1725. return false;
  1726. }
  1727. function assignWith(object, source, customizer) {
  1728. var props = keys(source);
  1729. push.apply(props, getSymbols(source));
  1730. var index = -1,
  1731. length = props.length;
  1732. while (++index < length) {
  1733. var key = props[index],
  1734. value = object[key],
  1735. result = customizer(value, source[key], key, object, source);
  1736. if ((result === result ? (result !== value) : (value === value)) ||
  1737. (value === undefined && !(key in object))) {
  1738. object[key] = result;
  1739. }
  1740. }
  1741. return object;
  1742. }
  1743. var baseAssign = nativeAssign || function(object, source) {
  1744. return source == null
  1745. ? object
  1746. : baseCopy(source, getSymbols(source), baseCopy(source, keys(source), object));
  1747. };
  1748. function baseCopy(source, props, object) {
  1749. object || (object = {});
  1750. var index = -1,
  1751. length = props.length;
  1752. while (++index < length) {
  1753. var key = props[index];
  1754. object[key] = source[key];
  1755. }
  1756. return object;
  1757. }
  1758. function baseCallback(func, thisArg, argCount) {
  1759. var type = typeof func;
  1760. if (type == 'function') {
  1761. return thisArg === undefined
  1762. ? func
  1763. : bindCallback(func, thisArg, argCount);
  1764. }
  1765. if (func == null) {
  1766. return identity;
  1767. }
  1768. if (type == 'object') {
  1769. return baseMatches(func);
  1770. }
  1771. return thisArg === undefined
  1772. ? property(func)
  1773. : baseMatchesProperty(func, thisArg);
  1774. }
  1775. function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
  1776. var result;
  1777. if (customizer) {
  1778. result = object ? customizer(value, key, object) : customizer(value);
  1779. }
  1780. if (result !== undefined) {
  1781. return result;
  1782. }
  1783. if (!isObject(value)) {
  1784. return value;
  1785. }
  1786. var isArr = isArray(value);
  1787. if (isArr) {
  1788. result = initCloneArray(value);
  1789. if (!isDeep) {
  1790. return arrayCopy(value, result);
  1791. }
  1792. } else {
  1793. var tag = objToString.call(value),
  1794. isFunc = tag == funcTag;
  1795. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  1796. result = initCloneObject(isFunc ? {} : value);
  1797. if (!isDeep) {
  1798. return baseAssign(result, value);
  1799. }
  1800. } else {
  1801. return cloneableTags[tag]
  1802. ? initCloneByTag(value, tag, isDeep)
  1803. : (object ? value : {});
  1804. }
  1805. }
  1806. stackA || (stackA = []);
  1807. stackB || (stackB = []);
  1808. var length = stackA.length;
  1809. while (length--) {
  1810. if (stackA[length] == value) {
  1811. return stackB[length];
  1812. }
  1813. }
  1814. stackA.push(value);
  1815. stackB.push(result);
  1816. (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
  1817. result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
  1818. });
  1819. return result;
  1820. }
  1821. var baseEach = createBaseEach(baseForOwn);
  1822. function baseFilter(collection, predicate) {
  1823. var result = [];
  1824. baseEach(collection, function(value, index, collection) {
  1825. if (predicate(value, index, collection)) {
  1826. result.push(value);
  1827. }
  1828. });
  1829. return result;
  1830. }
  1831. var baseFor = createBaseFor();
  1832. function baseForIn(object, iteratee) {
  1833. return baseFor(object, iteratee, keysIn);
  1834. }
  1835. function baseForOwn(object, iteratee) {
  1836. return baseFor(object, iteratee, keys);
  1837. }
  1838. function baseGet(object, path, pathKey) {
  1839. if (object == null) {
  1840. return;
  1841. }
  1842. if (pathKey !== undefined && pathKey in toObject(object)) {
  1843. path = [pathKey];
  1844. }
  1845. var index = -1,
  1846. length = path.length;
  1847. while (object != null && ++index < length) {
  1848. var result = object = object[path[index]];
  1849. }
  1850. return result;
  1851. }
  1852. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  1853. if (value === other) {
  1854. return value !== 0 || (1 / value == 1 / other);
  1855. }
  1856. var valType = typeof value,
  1857. othType = typeof other;
  1858. if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
  1859. value == null || other == null) {
  1860. return value !== value && other !== other;
  1861. }
  1862. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  1863. }
  1864. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  1865. var objIsArr = isArray(object),
  1866. othIsArr = isArray(other),
  1867. objTag = arrayTag,
  1868. othTag = arrayTag;
  1869. if (!objIsArr) {
  1870. objTag = objToString.call(object);
  1871. if (objTag == argsTag) {
  1872. objTag = objectTag;
  1873. } else if (objTag != objectTag) {
  1874. objIsArr = isTypedArray(object);
  1875. }
  1876. }
  1877. if (!othIsArr) {
  1878. othTag = objToString.call(other);
  1879. if (othTag == argsTag) {
  1880. othTag = objectTag;
  1881. } else if (othTag != objectTag) {
  1882. othIsArr = isTypedArray(other);
  1883. }
  1884. }
  1885. var objIsObj = objTag == objectTag,
  1886. othIsObj = othTag == objectTag,
  1887. isSameTag = objTag == othTag;
  1888. if (isSameTag && !(objIsArr || objIsObj)) {
  1889. return equalByTag(object, other, objTag);
  1890. }
  1891. if (!isLoose) {
  1892. var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  1893. othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  1894. if (valWrapped || othWrapped) {
  1895. return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  1896. }
  1897. }
  1898. if (!isSameTag) {
  1899. return false;
  1900. }
  1901. stackA || (stackA = []);
  1902. stackB || (stackB = []);
  1903. var length = stackA.length;
  1904. while (length--) {
  1905. if (stackA[length] == object) {
  1906. return stackB[length] == other;
  1907. }
  1908. }
  1909. stackA.push(object);
  1910. stackB.push(other);
  1911. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  1912. stackA.pop();
  1913. stackB.pop();
  1914. return result;
  1915. }
  1916. function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
  1917. var index = -1,
  1918. length = props.length,
  1919. noCustomizer = !customizer;
  1920. while (++index < length) {
  1921. if ((noCustomizer && strictCompareFlags[index])
  1922. ? values[index] !== object[props[index]]
  1923. : !(props[index] in object)
  1924. ) {
  1925. return false;
  1926. }
  1927. }
  1928. index = -1;
  1929. while (++index < length) {
  1930. var key = props[index],
  1931. objValue = object[key],
  1932. srcValue = values[index];
  1933. if (noCustomizer && strictCompareFlags[index]) {
  1934. var result = objValue !== undefined || (key in object);
  1935. } else {
  1936. result = customizer ? customizer(objValue, srcValue, key) : undefined;
  1937. if (result === undefined) {
  1938. result = baseIsEqual(srcValue, objValue, customizer, true);
  1939. }
  1940. }
  1941. if (!result) {
  1942. return false;
  1943. }
  1944. }
  1945. return true;
  1946. }
  1947. function baseMatches(source) {
  1948. var props = keys(source),
  1949. length = props.length;
  1950. if (!length) {
  1951. return constant(true);
  1952. }
  1953. if (length == 1) {
  1954. var key = props[0],
  1955. value = source[key];
  1956. if (isStrictComparable(value)) {
  1957. return function(object) {
  1958. if (object == null) {
  1959. return false;
  1960. }
  1961. return object[key] === value && (value !== undefined || (key in toObject(object)));
  1962. };
  1963. }
  1964. }
  1965. var values = Array(length),
  1966. strictCompareFlags = Array(length);
  1967. while (length--) {
  1968. value = source[props[length]];
  1969. values[length] = value;
  1970. strictCompareFlags[length] = isStrictComparable(value);
  1971. }
  1972. return function(object) {
  1973. return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
  1974. };
  1975. }
  1976. function baseMatchesProperty(path, value) {
  1977. var isArr = isArray(path),
  1978. isCommon = isKey(path) && isStrictComparable(value),
  1979. pathKey = (path + '');
  1980. path = toPath(path);
  1981. return function(object) {
  1982. if (object == null) {
  1983. return false;
  1984. }
  1985. var key = pathKey;
  1986. object = toObject(object);
  1987. if ((isArr || !isCommon) && !(key in object)) {
  1988. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  1989. if (object == null) {
  1990. return false;
  1991. }
  1992. key = last(path);
  1993. object = toObject(object);
  1994. }
  1995. return object[key] === value
  1996. ? (value !== undefined || (key in object))
  1997. : baseIsEqual(value, object[key], null, true);
  1998. };
  1999. }
  2000. function baseMerge(object, source, customizer, stackA, stackB) {
  2001. if (!isObject(object)) {
  2002. return object;
  2003. }
  2004. var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
  2005. if (!isSrcArr) {
  2006. var props = keys(source);
  2007. push.apply(props, getSymbols(source));
  2008. }
  2009. arrayEach(props || source, function(srcValue, key) {
  2010. if (props) {
  2011. key = srcValue;
  2012. srcValue = source[key];
  2013. }
  2014. if (isObjectLike(srcValue)) {
  2015. stackA || (stackA = []);
  2016. stackB || (stackB = []);
  2017. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  2018. }
  2019. else {
  2020. var value = object[key],
  2021. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  2022. isCommon = result === undefined;
  2023. if (isCommon) {
  2024. result = srcValue;
  2025. }
  2026. if ((isSrcArr || result !== undefined) &&
  2027. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  2028. object[key] = result;
  2029. }
  2030. }
  2031. });
  2032. return object;
  2033. }
  2034. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  2035. var length = stackA.length,
  2036. srcValue = source[key];
  2037. while (length--) {
  2038. if (stackA[length] == srcValue) {
  2039. object[key] = stackB[length];
  2040. return;
  2041. }
  2042. }
  2043. var value = object[key],
  2044. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  2045. isCommon = result === undefined;
  2046. if (isCommon) {
  2047. result = srcValue;
  2048. if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
  2049. result = isArray(value)
  2050. ? value
  2051. : (getLength(value) ? arrayCopy(value) : []);
  2052. }
  2053. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  2054. result = isArguments(value)
  2055. ? toPlainObject(value)
  2056. : (isPlainObject(value) ? value : {});
  2057. }
  2058. else {
  2059. isCommon = false;
  2060. }
  2061. }
  2062. stackA.push(srcValue);
  2063. stackB.push(result);
  2064. if (isCommon) {
  2065. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  2066. } else if (result === result ? (result !== value) : (value === value)) {
  2067. object[key] = result;
  2068. }
  2069. }
  2070. function baseProperty(key) {
  2071. return function(object) {
  2072. return object == null ? undefined : object[key];
  2073. };
  2074. }
  2075. function basePropertyDeep(path) {
  2076. var pathKey = (path + '');
  2077. path = toPath(path);
  2078. return function(object) {
  2079. return baseGet(object, path, pathKey);
  2080. };
  2081. }
  2082. function baseSlice(array, start, end) {
  2083. var index = -1,
  2084. length = array.length;
  2085. start = start == null ? 0 : (+start || 0);
  2086. if (start < 0) {
  2087. start = -start > length ? 0 : (length + start);
  2088. }
  2089. end = (end === undefined || end > length) ? length : (+end || 0);
  2090. if (end < 0) {
  2091. end += length;
  2092. }
  2093. length = start > end ? 0 : ((end - start) >>> 0);
  2094. start >>>= 0;
  2095. var result = Array(length);
  2096. while (++index < length) {
  2097. result[index] = array[index + start];
  2098. }
  2099. return result;
  2100. }
  2101. function baseSome(collection, predicate) {
  2102. var result;
  2103. baseEach(collection, function(value, index, collection) {
  2104. result = predicate(value, index, collection);
  2105. return !result;
  2106. });
  2107. return !!result;
  2108. }
  2109. function baseValues(object, props) {
  2110. var index = -1,
  2111. length = props.length,
  2112. result = Array(length);
  2113. while (++index < length) {
  2114. result[index] = object[props[index]];
  2115. }
  2116. return result;
  2117. }
  2118. function binaryIndex(array, value, retHighest) {
  2119. var low = 0,
  2120. high = array ? array.length : low;
  2121. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  2122. while (low < high) {
  2123. var mid = (low + high) >>> 1,
  2124. computed = array[mid];
  2125. if (retHighest ? (computed <= value) : (computed < value)) {
  2126. low = mid + 1;
  2127. } else {
  2128. high = mid;
  2129. }
  2130. }
  2131. return high;
  2132. }
  2133. return binaryIndexBy(array, value, identity, retHighest);
  2134. }
  2135. function binaryIndexBy(array, value, iteratee, retHighest) {
  2136. value = iteratee(value);
  2137. var low = 0,
  2138. high = array ? array.length : 0,
  2139. valIsNaN = value !== value,
  2140. valIsUndef = value === undefined;
  2141. while (low < high) {
  2142. var mid = floor((low + high) / 2),
  2143. computed = iteratee(array[mid]),
  2144. isReflexive = computed === computed;
  2145. if (valIsNaN) {
  2146. var setLow = isReflexive || retHighest;
  2147. } else if (valIsUndef) {
  2148. setLow = isReflexive && (retHighest || computed !== undefined);
  2149. } else {
  2150. setLow = retHighest ? (computed <= value) : (computed < value);
  2151. }
  2152. if (setLow) {
  2153. low = mid + 1;
  2154. } else {
  2155. high = mid;
  2156. }
  2157. }
  2158. return nativeMin(high, MAX_ARRAY_INDEX);
  2159. }
  2160. function bindCallback(func, thisArg, argCount) {
  2161. if (typeof func != 'function') {
  2162. return identity;
  2163. }
  2164. if (thisArg === undefined) {
  2165. return func;
  2166. }
  2167. switch (argCount) {
  2168. case 1: return function(value) {
  2169. return func.call(thisArg, value);
  2170. };
  2171. case 3: return function(value, index, collection) {
  2172. return func.call(thisArg, value, index, collection);
  2173. };
  2174. case 4: return function(accumulator, value, index, collection) {
  2175. return func.call(thisArg, accumulator, value, index, collection);
  2176. };
  2177. case 5: return function(value, other, key, object, source) {
  2178. return func.call(thisArg, value, other, key, object, source);
  2179. };
  2180. }
  2181. return function() {
  2182. return func.apply(thisArg, arguments);
  2183. };
  2184. }
  2185. function bufferClone(buffer) {
  2186. return bufferSlice.call(buffer, 0);
  2187. }
  2188. if (!bufferSlice) {
  2189. bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
  2190. var byteLength = buffer.byteLength,
  2191. floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
  2192. offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
  2193. result = new ArrayBuffer(byteLength);
  2194. if (floatLength) {
  2195. var view = new Float64Array(result, 0, floatLength);
  2196. view.set(new Float64Array(buffer, 0, floatLength));
  2197. }
  2198. if (byteLength != offset) {
  2199. view = new Uint8Array(result, offset);
  2200. view.set(new Uint8Array(buffer, offset));
  2201. }
  2202. return result;
  2203. };
  2204. }
  2205. function createAssigner(assigner) {
  2206. return restParam(function(object, sources) {
  2207. var index = -1,
  2208. length = object == null ? 0 : sources.length,
  2209. customizer = length > 2 && sources[length - 2],
  2210. guard = length > 2 && sources[2],
  2211. thisArg = length > 1 && sources[length - 1];
  2212. if (typeof customizer == 'function') {
  2213. customizer = bindCallback(customizer, thisArg, 5);
  2214. length -= 2;
  2215. } else {
  2216. customizer = typeof thisArg == 'function' ? thisArg : null;
  2217. length -= (customizer ? 1 : 0);
  2218. }
  2219. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  2220. customizer = length < 3 ? null : customizer;
  2221. length = 1;
  2222. }
  2223. while (++index < length) {
  2224. var source = sources[index];
  2225. if (source) {
  2226. assigner(object, source, customizer);
  2227. }
  2228. }
  2229. return object;
  2230. });
  2231. }
  2232. function createBaseEach(eachFunc, fromRight) {
  2233. return function(collection, iteratee) {
  2234. var length = collection ? getLength(collection) : 0;
  2235. if (!isLength(length)) {
  2236. return eachFunc(collection, iteratee);
  2237. }
  2238. var index = fromRight ? length : -1,
  2239. iterable = toObject(collection);
  2240. while ((fromRight ? index-- : ++index < length)) {
  2241. if (iteratee(iterable[index], index, iterable) === false) {
  2242. break;
  2243. }
  2244. }
  2245. return collection;
  2246. };
  2247. }
  2248. function createBaseFor(fromRight) {
  2249. return function(object, iteratee, keysFunc) {
  2250. var iterable = toObject(object),
  2251. props = keysFunc(object),
  2252. length = props.length,
  2253. index = fromRight ? length : -1;
  2254. while ((fromRight ? index-- : ++index < length)) {
  2255. var key = props[index];
  2256. if (iteratee(iterable[key], key, iterable) === false) {
  2257. break;
  2258. }
  2259. }
  2260. return object;
  2261. };
  2262. }
  2263. function createFindIndex(fromRight) {
  2264. return function(array, predicate, thisArg) {
  2265. if (!(array && array.length)) {
  2266. return -1;
  2267. }
  2268. predicate = getCallback(predicate, thisArg, 3);
  2269. return baseFindIndex(array, predicate, fromRight);
  2270. };
  2271. }
  2272. function createForEach(arrayFunc, eachFunc) {
  2273. return function(collection, iteratee, thisArg) {
  2274. return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
  2275. ? arrayFunc(collection, iteratee)
  2276. : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
  2277. };
  2278. }
  2279. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  2280. var index = -1,
  2281. arrLength = array.length,
  2282. othLength = other.length,
  2283. result = true;
  2284. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  2285. return false;
  2286. }
  2287. while (result && ++index < arrLength) {
  2288. var arrValue = array[index],
  2289. othValue = other[index];
  2290. result = undefined;
  2291. if (customizer) {
  2292. result = isLoose
  2293. ? customizer(othValue, arrValue, index)
  2294. : customizer(arrValue, othValue, index);
  2295. }
  2296. if (result === undefined) {
  2297. if (isLoose) {
  2298. var othIndex = othLength;
  2299. while (othIndex--) {
  2300. othValue = other[othIndex];
  2301. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  2302. if (result) {
  2303. break;
  2304. }
  2305. }
  2306. } else {
  2307. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  2308. }
  2309. }
  2310. }
  2311. return !!result;
  2312. }
  2313. function equalByTag(object, other, tag) {
  2314. switch (tag) {
  2315. case boolTag:
  2316. case dateTag:
  2317. return +object == +other;
  2318. case errorTag:
  2319. return object.name == other.name && object.message == other.message;
  2320. case numberTag:
  2321. return (object != +object)
  2322. ? other != +other
  2323. : (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
  2324. case regexpTag:
  2325. case stringTag:
  2326. return object == (other + '');
  2327. }
  2328. return false;
  2329. }
  2330. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  2331. var objProps = keys(object),
  2332. objLength = objProps.length,
  2333. othProps = keys(other),
  2334. othLength = othProps.length;
  2335. if (objLength != othLength && !isLoose) {
  2336. return false;
  2337. }
  2338. var skipCtor = isLoose,
  2339. index = -1;
  2340. while (++index < objLength) {
  2341. var key = objProps[index],
  2342. result = isLoose ? key in other : hasOwnProperty.call(other, key);
  2343. if (result) {
  2344. var objValue = object[key],
  2345. othValue = other[key];
  2346. result = undefined;
  2347. if (customizer) {
  2348. result = isLoose
  2349. ? customizer(othValue, objValue, key)
  2350. : customizer(objValue, othValue, key);
  2351. }
  2352. if (result === undefined) {
  2353. result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
  2354. }
  2355. }
  2356. if (!result) {
  2357. return false;
  2358. }
  2359. skipCtor || (skipCtor = key == 'constructor');
  2360. }
  2361. if (!skipCtor) {
  2362. var objCtor = object.constructor,
  2363. othCtor = other.constructor;
  2364. if (objCtor != othCtor &&
  2365. ('constructor' in object && 'constructor' in other) &&
  2366. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  2367. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  2368. return false;
  2369. }
  2370. }
  2371. return true;
  2372. }
  2373. function getCallback(func, thisArg, argCount) {
  2374. var result = lodash.callback || callback;
  2375. result = result === callback ? baseCallback : result;
  2376. return argCount ? result(func, thisArg, argCount) : result;
  2377. }
  2378. function getIndexOf(collection, target, fromIndex) {
  2379. var result = lodash.indexOf || indexOf;
  2380. result = result === indexOf ? baseIndexOf : result;
  2381. return collection ? result(collection, target, fromIndex) : result;
  2382. }
  2383. var getLength = baseProperty('length');
  2384. var getSymbols = !getOwnPropertySymbols ? constant([]) : function(object) {
  2385. return getOwnPropertySymbols(toObject(object));
  2386. };
  2387. function initCloneArray(array) {
  2388. var length = array.length,
  2389. result = new array.constructor(length);
  2390. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  2391. result.index = array.index;
  2392. result.input = array.input;
  2393. }
  2394. return result;
  2395. }
  2396. function initCloneObject(object) {
  2397. var Ctor = object.constructor;
  2398. if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
  2399. Ctor = Object;
  2400. }
  2401. return new Ctor;
  2402. }
  2403. function initCloneByTag(object, tag, isDeep) {
  2404. var Ctor = object.constructor;
  2405. switch (tag) {
  2406. case arrayBufferTag:
  2407. return bufferClone(object);
  2408. case boolTag:
  2409. case dateTag:
  2410. return new Ctor(+object);
  2411. case float32Tag: case float64Tag:
  2412. case int8Tag: case int16Tag: case int32Tag:
  2413. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  2414. var buffer = object.buffer;
  2415. return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
  2416. case numberTag:
  2417. case stringTag:
  2418. return new Ctor(object);
  2419. case regexpTag:
  2420. var result = new Ctor(object.source, reFlags.exec(object));
  2421. result.lastIndex = object.lastIndex;
  2422. }
  2423. return result;
  2424. }
  2425. function isIndex(value, length) {
  2426. value = +value;
  2427. length = length == null ? MAX_SAFE_INTEGER : length;
  2428. return value > -1 && value % 1 == 0 && value < length;
  2429. }
  2430. function isIterateeCall(value, index, object) {
  2431. if (!isObject(object)) {
  2432. return false;
  2433. }
  2434. var type = typeof index;
  2435. if (type == 'number') {
  2436. var length = getLength(object),
  2437. prereq = isLength(length) && isIndex(index, length);
  2438. } else {
  2439. prereq = type == 'string' && index in object;
  2440. }
  2441. if (prereq) {
  2442. var other = object[index];
  2443. return value === value ? (value === other) : (other !== other);
  2444. }
  2445. return false;
  2446. }
  2447. function isKey(value, object) {
  2448. var type = typeof value;
  2449. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  2450. return true;
  2451. }
  2452. if (isArray(value)) {
  2453. return false;
  2454. }
  2455. var result = !reIsDeepProp.test(value);
  2456. return result || (object != null && value in toObject(object));
  2457. }
  2458. function isLength(value) {
  2459. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  2460. }
  2461. function isStrictComparable(value) {
  2462. return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
  2463. }
  2464. function shimIsPlainObject(value) {
  2465. var Ctor,
  2466. support = lodash.support;
  2467. if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||
  2468. (!hasOwnProperty.call(value, 'constructor') &&
  2469. (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  2470. return false;
  2471. }
  2472. var result;
  2473. baseForIn(value, function(subValue, key) {
  2474. result = key;
  2475. });
  2476. return result === undefined || hasOwnProperty.call(value, result);
  2477. }
  2478. function shimKeys(object) {
  2479. var props = keysIn(object),
  2480. propsLength = props.length,
  2481. length = propsLength && object.length,
  2482. support = lodash.support;
  2483. var allowIndexes = length && isLength(length) &&
  2484. (isArray(object) || (support.nonEnumArgs && isArguments(object)));
  2485. var index = -1,
  2486. result = [];
  2487. while (++index < propsLength) {
  2488. var key = props[index];
  2489. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  2490. result.push(key);
  2491. }
  2492. }
  2493. return result;
  2494. }
  2495. function toObject(value) {
  2496. return isObject(value) ? value : Object(value);
  2497. }
  2498. function toPath(value) {
  2499. if (isArray(value)) {
  2500. return value;
  2501. }
  2502. var result = [];
  2503. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  2504. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  2505. });
  2506. return result;
  2507. }
  2508. var findLastIndex = createFindIndex(true);
  2509. function indexOf(array, value, fromIndex) {
  2510. var length = array ? array.length : 0;
  2511. if (!length) {
  2512. return -1;
  2513. }
  2514. if (typeof fromIndex == 'number') {
  2515. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
  2516. } else if (fromIndex) {
  2517. var index = binaryIndex(array, value),
  2518. other = array[index];
  2519. if (value === value ? (value === other) : (other !== other)) {
  2520. return index;
  2521. }
  2522. return -1;
  2523. }
  2524. return baseIndexOf(array, value, fromIndex || 0);
  2525. }
  2526. function last(array) {
  2527. var length = array ? array.length : 0;
  2528. return length ? array[length - 1] : undefined;
  2529. }
  2530. function slice(array, start, end) {
  2531. var length = array ? array.length : 0;
  2532. if (!length) {
  2533. return [];
  2534. }
  2535. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  2536. start = 0;
  2537. end = length;
  2538. }
  2539. return baseSlice(array, start, end);
  2540. }
  2541. function unzip(array) {
  2542. var index = -1,
  2543. length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0,
  2544. result = Array(length);
  2545. while (++index < length) {
  2546. result[index] = arrayMap(array, baseProperty(index));
  2547. }
  2548. return result;
  2549. }
  2550. var zip = restParam(unzip);
  2551. var forEach = createForEach(arrayEach, baseEach);
  2552. function includes(collection, target, fromIndex, guard) {
  2553. var length = collection ? getLength(collection) : 0;
  2554. if (!isLength(length)) {
  2555. collection = values(collection);
  2556. length = collection.length;
  2557. }
  2558. if (!length) {
  2559. return false;
  2560. }
  2561. if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
  2562. fromIndex = 0;
  2563. } else {
  2564. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
  2565. }
  2566. return (typeof collection == 'string' || !isArray(collection) && isString(collection))
  2567. ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
  2568. : (getIndexOf(collection, target, fromIndex) > -1);
  2569. }
  2570. function reject(collection, predicate, thisArg) {
  2571. var func = isArray(collection) ? arrayFilter : baseFilter;
  2572. predicate = getCallback(predicate, thisArg, 3);
  2573. return func(collection, function(value, index, collection) {
  2574. return !predicate(value, index, collection);
  2575. });
  2576. }
  2577. function some(collection, predicate, thisArg) {
  2578. var func = isArray(collection) ? arraySome : baseSome;
  2579. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  2580. predicate = null;
  2581. }
  2582. if (typeof predicate != 'function' || thisArg !== undefined) {
  2583. predicate = getCallback(predicate, thisArg, 3);
  2584. }
  2585. return func(collection, predicate);
  2586. }
  2587. function restParam(func, start) {
  2588. if (typeof func != 'function') {
  2589. throw new TypeError(FUNC_ERROR_TEXT);
  2590. }
  2591. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  2592. return function() {
  2593. var args = arguments,
  2594. index = -1,
  2595. length = nativeMax(args.length - start, 0),
  2596. rest = Array(length);
  2597. while (++index < length) {
  2598. rest[index] = args[start + index];
  2599. }
  2600. switch (start) {
  2601. case 0: return func.call(this, rest);
  2602. case 1: return func.call(this, args[0], rest);
  2603. case 2: return func.call(this, args[0], args[1], rest);
  2604. }
  2605. var otherArgs = Array(start + 1);
  2606. index = -1;
  2607. while (++index < start) {
  2608. otherArgs[index] = args[index];
  2609. }
  2610. otherArgs[start] = rest;
  2611. return func.apply(this, otherArgs);
  2612. };
  2613. }
  2614. function clone(value, isDeep, customizer, thisArg) {
  2615. if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
  2616. isDeep = false;
  2617. }
  2618. else if (typeof isDeep == 'function') {
  2619. thisArg = customizer;
  2620. customizer = isDeep;
  2621. isDeep = false;
  2622. }
  2623. customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
  2624. return baseClone(value, isDeep, customizer);
  2625. }
  2626. function isArguments(value) {
  2627. var length = isObjectLike(value) ? value.length : undefined;
  2628. return isLength(length) && objToString.call(value) == argsTag;
  2629. }
  2630. var isArray = nativeIsArray || function(value) {
  2631. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  2632. };
  2633. function isEmpty(value) {
  2634. if (value == null) {
  2635. return true;
  2636. }
  2637. var length = getLength(value);
  2638. if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
  2639. (isObjectLike(value) && isFunction(value.splice)))) {
  2640. return !length;
  2641. }
  2642. return !keys(value).length;
  2643. }
  2644. var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
  2645. return objToString.call(value) == funcTag;
  2646. };
  2647. function isObject(value) {
  2648. var type = typeof value;
  2649. return type == 'function' || (!!value && type == 'object');
  2650. }
  2651. function isNative(value) {
  2652. if (value == null) {
  2653. return false;
  2654. }
  2655. if (objToString.call(value) == funcTag) {
  2656. return reIsNative.test(fnToString.call(value));
  2657. }
  2658. return isObjectLike(value) && reIsHostCtor.test(value);
  2659. }
  2660. function isNumber(value) {
  2661. return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
  2662. }
  2663. var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
  2664. if (!(value && objToString.call(value) == objectTag)) {
  2665. return false;
  2666. }
  2667. var valueOf = value.valueOf,
  2668. objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
  2669. return objProto
  2670. ? (value == objProto || getPrototypeOf(value) == objProto)
  2671. : shimIsPlainObject(value);
  2672. };
  2673. function isString(value) {
  2674. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  2675. }
  2676. function isTypedArray(value) {
  2677. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  2678. }
  2679. function toPlainObject(value) {
  2680. return baseCopy(value, keysIn(value));
  2681. }
  2682. var assign = createAssigner(function(object, source, customizer) {
  2683. return customizer
  2684. ? assignWith(object, source, customizer)
  2685. : baseAssign(object, source);
  2686. });
  2687. function has(object, path) {
  2688. if (object == null) {
  2689. return false;
  2690. }
  2691. var result = hasOwnProperty.call(object, path);
  2692. if (!result && !isKey(path)) {
  2693. path = toPath(path);
  2694. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  2695. path = last(path);
  2696. result = object != null && hasOwnProperty.call(object, path);
  2697. }
  2698. return result;
  2699. }
  2700. var keys = !nativeKeys ? shimKeys : function(object) {
  2701. if (object) {
  2702. var Ctor = object.constructor,
  2703. length = object.length;
  2704. }
  2705. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  2706. (typeof object != 'function' && isLength(length))) {
  2707. return shimKeys(object);
  2708. }
  2709. return isObject(object) ? nativeKeys(object) : [];
  2710. };
  2711. function keysIn(object) {
  2712. if (object == null) {
  2713. return [];
  2714. }
  2715. if (!isObject(object)) {
  2716. object = Object(object);
  2717. }
  2718. var length = object.length;
  2719. length = (length && isLength(length) &&
  2720. (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
  2721. var Ctor = object.constructor,
  2722. index = -1,
  2723. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  2724. result = Array(length),
  2725. skipIndexes = length > 0;
  2726. while (++index < length) {
  2727. result[index] = (index + '');
  2728. }
  2729. for (var key in object) {
  2730. if (!(skipIndexes && isIndex(key, length)) &&
  2731. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  2732. result.push(key);
  2733. }
  2734. }
  2735. return result;
  2736. }
  2737. var merge = createAssigner(baseMerge);
  2738. function values(object) {
  2739. return baseValues(object, keys(object));
  2740. }
  2741. function escapeRegExp(string) {
  2742. string = baseToString(string);
  2743. return (string && reHasRegExpChars.test(string))
  2744. ? string.replace(reRegExpChars, '\\$&')
  2745. : string;
  2746. }
  2747. function callback(func, thisArg, guard) {
  2748. if (guard && isIterateeCall(func, thisArg, guard)) {
  2749. thisArg = null;
  2750. }
  2751. return baseCallback(func, thisArg);
  2752. }
  2753. function constant(value) {
  2754. return function() {
  2755. return value;
  2756. };
  2757. }
  2758. function identity(value) {
  2759. return value;
  2760. }
  2761. function property(path) {
  2762. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  2763. }
  2764. lodash.assign = assign;
  2765. lodash.callback = callback;
  2766. lodash.constant = constant;
  2767. lodash.forEach = forEach;
  2768. lodash.keys = keys;
  2769. lodash.keysIn = keysIn;
  2770. lodash.merge = merge;
  2771. lodash.property = property;
  2772. lodash.reject = reject;
  2773. lodash.restParam = restParam;
  2774. lodash.slice = slice;
  2775. lodash.toPlainObject = toPlainObject;
  2776. lodash.unzip = unzip;
  2777. lodash.values = values;
  2778. lodash.zip = zip;
  2779. lodash.each = forEach;
  2780. lodash.extend = assign;
  2781. lodash.iteratee = callback;
  2782. lodash.clone = clone;
  2783. lodash.escapeRegExp = escapeRegExp;
  2784. lodash.findLastIndex = findLastIndex;
  2785. lodash.has = has;
  2786. lodash.identity = identity;
  2787. lodash.includes = includes;
  2788. lodash.indexOf = indexOf;
  2789. lodash.isArguments = isArguments;
  2790. lodash.isArray = isArray;
  2791. lodash.isEmpty = isEmpty;
  2792. lodash.isFunction = isFunction;
  2793. lodash.isNative = isNative;
  2794. lodash.isNumber = isNumber;
  2795. lodash.isObject = isObject;
  2796. lodash.isPlainObject = isPlainObject;
  2797. lodash.isString = isString;
  2798. lodash.isTypedArray = isTypedArray;
  2799. lodash.last = last;
  2800. lodash.some = some;
  2801. lodash.any = some;
  2802. lodash.contains = includes;
  2803. lodash.include = includes;
  2804. lodash.VERSION = VERSION;
  2805. if (freeExports && freeModule) {
  2806. if (moduleExports) {
  2807. (freeModule.exports = lodash)._ = lodash;
  2808. }
  2809. else {
  2810. freeExports._ = lodash;
  2811. }
  2812. }
  2813. else {
  2814. root._ = lodash;
  2815. }
  2816. }.call(this));
  2817. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2818. },{}],"/node_modules/jshint/src/jshint.js":[function(_dereq_,module,exports){
  2819. var _ = _dereq_("../lodash");
  2820. var events = _dereq_("events");
  2821. var vars = _dereq_("./vars.js");
  2822. var messages = _dereq_("./messages.js");
  2823. var Lexer = _dereq_("./lex.js").Lexer;
  2824. var reg = _dereq_("./reg.js");
  2825. var state = _dereq_("./state.js").state;
  2826. var style = _dereq_("./style.js");
  2827. var options = _dereq_("./options.js");
  2828. var scopeManager = _dereq_("./scope-manager.js");
  2829. var JSHINT = (function() {
  2830. "use strict";
  2831. var api, // Extension API
  2832. bang = {
  2833. "<" : true,
  2834. "<=" : true,
  2835. "==" : true,
  2836. "===": true,
  2837. "!==": true,
  2838. "!=" : true,
  2839. ">" : true,
  2840. ">=" : true,
  2841. "+" : true,
  2842. "-" : true,
  2843. "*" : true,
  2844. "/" : true,
  2845. "%" : true
  2846. },
  2847. declared, // Globals that were declared using /*global ... */ syntax.
  2848. functionicity = [
  2849. "closure", "exception", "global", "label",
  2850. "outer", "unused", "var"
  2851. ],
  2852. functions, // All of the functions
  2853. inblock,
  2854. indent,
  2855. lookahead,
  2856. lex,
  2857. member,
  2858. membersOnly,
  2859. predefined, // Global variables defined by option
  2860. stack,
  2861. urls,
  2862. extraModules = [],
  2863. emitter = new events.EventEmitter();
  2864. function checkOption(name, t) {
  2865. name = name.trim();
  2866. if (/^[+-]W\d{3}$/g.test(name)) {
  2867. return true;
  2868. }
  2869. if (options.validNames.indexOf(name) === -1) {
  2870. if (t.type !== "jslint" && !_.has(options.removed, name)) {
  2871. error("E001", t, name);
  2872. return false;
  2873. }
  2874. }
  2875. return true;
  2876. }
  2877. function isString(obj) {
  2878. return Object.prototype.toString.call(obj) === "[object String]";
  2879. }
  2880. function isIdentifier(tkn, value) {
  2881. if (!tkn)
  2882. return false;
  2883. if (!tkn.identifier || tkn.value !== value)
  2884. return false;
  2885. return true;
  2886. }
  2887. function isReserved(token) {
  2888. if (!token.reserved) {
  2889. return false;
  2890. }
  2891. var meta = token.meta;
  2892. if (meta && meta.isFutureReservedWord && state.inES5()) {
  2893. if (!meta.es5) {
  2894. return false;
  2895. }
  2896. if (meta.strictOnly) {
  2897. if (!state.option.strict && !state.isStrict()) {
  2898. return false;
  2899. }
  2900. }
  2901. if (token.isProperty) {
  2902. return false;
  2903. }
  2904. }
  2905. return true;
  2906. }
  2907. function supplant(str, data) {
  2908. return str.replace(/\{([^{}]*)\}/g, function(a, b) {
  2909. var r = data[b];
  2910. return typeof r === "string" || typeof r === "number" ? r : a;
  2911. });
  2912. }
  2913. function combine(dest, src) {
  2914. Object.keys(src).forEach(function(name) {
  2915. if (_.has(JSHINT.blacklist, name)) return;
  2916. dest[name] = src[name];
  2917. });
  2918. }
  2919. function processenforceall() {
  2920. if (state.option.enforceall) {
  2921. for (var enforceopt in options.bool.enforcing) {
  2922. if (state.option[enforceopt] === undefined &&
  2923. !options.noenforceall[enforceopt]) {
  2924. state.option[enforceopt] = true;
  2925. }
  2926. }
  2927. for (var relaxopt in options.bool.relaxing) {
  2928. if (state.option[relaxopt] === undefined) {
  2929. state.option[relaxopt] = false;
  2930. }
  2931. }
  2932. }
  2933. }
  2934. function assume() {
  2935. processenforceall();
  2936. if (!state.option.esversion && !state.option.moz) {
  2937. if (state.option.es3) {
  2938. state.option.esversion = 3;
  2939. } else if (state.option.esnext) {
  2940. state.option.esversion = 6;
  2941. } else {
  2942. state.option.esversion = 5;
  2943. }
  2944. }
  2945. if (state.inES5()) {
  2946. combine(predefined, vars.ecmaIdentifiers[5]);
  2947. }
  2948. if (state.inES6()) {
  2949. combine(predefined, vars.ecmaIdentifiers[6]);
  2950. }
  2951. if (state.option.module) {
  2952. if (state.option.strict === true) {
  2953. state.option.strict = "global";
  2954. }
  2955. if (!state.inES6()) {
  2956. warning("W134", state.tokens.next, "module", 6);
  2957. }
  2958. }
  2959. if (state.option.couch) {
  2960. combine(predefined, vars.couch);
  2961. }
  2962. if (state.option.qunit) {
  2963. combine(predefined, vars.qunit);
  2964. }
  2965. if (state.option.rhino) {
  2966. combine(predefined, vars.rhino);
  2967. }
  2968. if (state.option.shelljs) {
  2969. combine(predefined, vars.shelljs);
  2970. combine(predefined, vars.node);
  2971. }
  2972. if (state.option.typed) {
  2973. combine(predefined, vars.typed);
  2974. }
  2975. if (state.option.phantom) {
  2976. combine(predefined, vars.phantom);
  2977. if (state.option.strict === true) {
  2978. state.option.strict = "global";
  2979. }
  2980. }
  2981. if (state.option.prototypejs) {
  2982. combine(predefined, vars.prototypejs);
  2983. }
  2984. if (state.option.node) {
  2985. combine(predefined, vars.node);
  2986. combine(predefined, vars.typed);
  2987. if (state.option.strict === true) {
  2988. state.option.strict = "global";
  2989. }
  2990. }
  2991. if (state.option.devel) {
  2992. combine(predefined, vars.devel);
  2993. }
  2994. if (state.option.dojo) {
  2995. combine(predefined, vars.dojo);
  2996. }
  2997. if (state.option.browser) {
  2998. combine(predefined, vars.browser);
  2999. combine(predefined, vars.typed);
  3000. }
  3001. if (state.option.browserify) {
  3002. combine(predefined, vars.browser);
  3003. combine(predefined, vars.typed);
  3004. combine(predefined, vars.browserify);
  3005. if (state.option.strict === true) {
  3006. state.option.strict = "global";
  3007. }
  3008. }
  3009. if (state.option.nonstandard) {
  3010. combine(predefined, vars.nonstandard);
  3011. }
  3012. if (state.option.jasmine) {
  3013. combine(predefined, vars.jasmine);
  3014. }
  3015. if (state.option.jquery) {
  3016. combine(predefined, vars.jquery);
  3017. }
  3018. if (state.option.mootools) {
  3019. combine(predefined, vars.mootools);
  3020. }
  3021. if (state.option.worker) {
  3022. combine(predefined, vars.worker);
  3023. }
  3024. if (state.option.wsh) {
  3025. combine(predefined, vars.wsh);
  3026. }
  3027. if (state.option.globalstrict && state.option.strict !== false) {
  3028. state.option.strict = "global";
  3029. }
  3030. if (state.option.yui) {
  3031. combine(predefined, vars.yui);
  3032. }
  3033. if (state.option.mocha) {
  3034. combine(predefined, vars.mocha);
  3035. }
  3036. }
  3037. function quit(code, line, chr) {
  3038. var percentage = Math.floor((line / state.lines.length) * 100);
  3039. var message = messages.errors[code].desc;
  3040. throw {
  3041. name: "JSHintError",
  3042. line: line,
  3043. character: chr,
  3044. message: message + " (" + percentage + "% scanned).",
  3045. raw: message,
  3046. code: code
  3047. };
  3048. }
  3049. function removeIgnoredMessages() {
  3050. var ignored = state.ignoredLines;
  3051. if (_.isEmpty(ignored)) return;
  3052. JSHINT.errors = _.reject(JSHINT.errors, function(err) { return ignored[err.line] });
  3053. }
  3054. function warning(code, t, a, b, c, d) {
  3055. var ch, l, w, msg;
  3056. if (/^W\d{3}$/.test(code)) {
  3057. if (state.ignored[code])
  3058. return;
  3059. msg = messages.warnings[code];
  3060. } else if (/E\d{3}/.test(code)) {
  3061. msg = messages.errors[code];
  3062. } else if (/I\d{3}/.test(code)) {
  3063. msg = messages.info[code];
  3064. }
  3065. t = t || state.tokens.next || {};
  3066. if (t.id === "(end)") { // `~
  3067. t = state.tokens.curr;
  3068. }
  3069. l = t.line || 0;
  3070. ch = t.from || 0;
  3071. w = {
  3072. id: "(error)",
  3073. raw: msg.desc,
  3074. code: msg.code,
  3075. evidence: state.lines[l - 1] || "",
  3076. line: l,
  3077. character: ch,
  3078. scope: JSHINT.scope,
  3079. a: a,
  3080. b: b,
  3081. c: c,
  3082. d: d
  3083. };
  3084. w.reason = supplant(msg.desc, w);
  3085. JSHINT.errors.push(w);
  3086. removeIgnoredMessages();
  3087. if (JSHINT.errors.length >= state.option.maxerr)
  3088. quit("E043", l, ch);
  3089. return w;
  3090. }
  3091. function warningAt(m, l, ch, a, b, c, d) {
  3092. return warning(m, {
  3093. line: l,
  3094. from: ch
  3095. }, a, b, c, d);
  3096. }
  3097. function error(m, t, a, b, c, d) {
  3098. warning(m, t, a, b, c, d);
  3099. }
  3100. function errorAt(m, l, ch, a, b, c, d) {
  3101. return error(m, {
  3102. line: l,
  3103. from: ch
  3104. }, a, b, c, d);
  3105. }
  3106. function addInternalSrc(elem, src) {
  3107. var i;
  3108. i = {
  3109. id: "(internal)",
  3110. elem: elem,
  3111. value: src
  3112. };
  3113. JSHINT.internals.push(i);
  3114. return i;
  3115. }
  3116. function doOption() {
  3117. var nt = state.tokens.next;
  3118. var body = nt.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g) || [];
  3119. var predef = {};
  3120. if (nt.type === "globals") {
  3121. body.forEach(function(g, idx) {
  3122. g = g.split(":");
  3123. var key = (g[0] || "").trim();
  3124. var val = (g[1] || "").trim();
  3125. if (key === "-" || !key.length) {
  3126. if (idx > 0 && idx === body.length - 1) {
  3127. return;
  3128. }
  3129. error("E002", nt);
  3130. return;
  3131. }
  3132. if (key.charAt(0) === "-") {
  3133. key = key.slice(1);
  3134. val = false;
  3135. JSHINT.blacklist[key] = key;
  3136. delete predefined[key];
  3137. } else {
  3138. predef[key] = (val === "true");
  3139. }
  3140. });
  3141. combine(predefined, predef);
  3142. for (var key in predef) {
  3143. if (_.has(predef, key)) {
  3144. declared[key] = nt;
  3145. }
  3146. }
  3147. }
  3148. if (nt.type === "exported") {
  3149. body.forEach(function(e, idx) {
  3150. if (!e.length) {
  3151. if (idx > 0 && idx === body.length - 1) {
  3152. return;
  3153. }
  3154. error("E002", nt);
  3155. return;
  3156. }
  3157. state.funct["(scope)"].addExported(e);
  3158. });
  3159. }
  3160. if (nt.type === "members") {
  3161. membersOnly = membersOnly || {};
  3162. body.forEach(function(m) {
  3163. var ch1 = m.charAt(0);
  3164. var ch2 = m.charAt(m.length - 1);
  3165. if (ch1 === ch2 && (ch1 === "\"" || ch1 === "'")) {
  3166. m = m
  3167. .substr(1, m.length - 2)
  3168. .replace("\\\"", "\"");
  3169. }
  3170. membersOnly[m] = false;
  3171. });
  3172. }
  3173. var numvals = [
  3174. "maxstatements",
  3175. "maxparams",
  3176. "maxdepth",
  3177. "maxcomplexity",
  3178. "maxerr",
  3179. "maxlen",
  3180. "indent"
  3181. ];
  3182. if (nt.type === "jshint" || nt.type === "jslint") {
  3183. body.forEach(function(g) {
  3184. g = g.split(":");
  3185. var key = (g[0] || "").trim();
  3186. var val = (g[1] || "").trim();
  3187. if (!checkOption(key, nt)) {
  3188. return;
  3189. }
  3190. if (numvals.indexOf(key) >= 0) {
  3191. if (val !== "false") {
  3192. val = +val;
  3193. if (typeof val !== "number" || !isFinite(val) || val <= 0 || Math.floor(val) !== val) {
  3194. error("E032", nt, g[1].trim());
  3195. return;
  3196. }
  3197. state.option[key] = val;
  3198. } else {
  3199. state.option[key] = key === "indent" ? 4 : false;
  3200. }
  3201. return;
  3202. }
  3203. if (key === "validthis") {
  3204. if (state.funct["(global)"])
  3205. return void error("E009");
  3206. if (val !== "true" && val !== "false")
  3207. return void error("E002", nt);
  3208. state.option.validthis = (val === "true");
  3209. return;
  3210. }
  3211. if (key === "quotmark") {
  3212. switch (val) {
  3213. case "true":
  3214. case "false":
  3215. state.option.quotmark = (val === "true");
  3216. break;
  3217. case "double":
  3218. case "single":
  3219. state.option.quotmark = val;
  3220. break;
  3221. default:
  3222. error("E002", nt);
  3223. }
  3224. return;
  3225. }
  3226. if (key === "shadow") {
  3227. switch (val) {
  3228. case "true":
  3229. state.option.shadow = true;
  3230. break;
  3231. case "outer":
  3232. state.option.shadow = "outer";
  3233. break;
  3234. case "false":
  3235. case "inner":
  3236. state.option.shadow = "inner";
  3237. break;
  3238. default:
  3239. error("E002", nt);
  3240. }
  3241. return;
  3242. }
  3243. if (key === "unused") {
  3244. switch (val) {
  3245. case "true":
  3246. state.option.unused = true;
  3247. break;
  3248. case "false":
  3249. state.option.unused = false;
  3250. break;
  3251. case "vars":
  3252. case "strict":
  3253. state.option.unused = val;
  3254. break;
  3255. default:
  3256. error("E002", nt);
  3257. }
  3258. return;
  3259. }
  3260. if (key === "latedef") {
  3261. switch (val) {
  3262. case "true":
  3263. state.option.latedef = true;
  3264. break;
  3265. case "false":
  3266. state.option.latedef = false;
  3267. break;
  3268. case "nofunc":
  3269. state.option.latedef = "nofunc";
  3270. break;
  3271. default:
  3272. error("E002", nt);
  3273. }
  3274. return;
  3275. }
  3276. if (key === "ignore") {
  3277. switch (val) {
  3278. case "line":
  3279. state.ignoredLines[nt.line] = true;
  3280. removeIgnoredMessages();
  3281. break;
  3282. default:
  3283. error("E002", nt);
  3284. }
  3285. return;
  3286. }
  3287. if (key === "strict") {
  3288. switch (val) {
  3289. case "true":
  3290. state.option.strict = true;
  3291. break;
  3292. case "false":
  3293. state.option.strict = false;
  3294. break;
  3295. case "func":
  3296. case "global":
  3297. case "implied":
  3298. state.option.strict = val;
  3299. break;
  3300. default:
  3301. error("E002", nt);
  3302. }
  3303. return;
  3304. }
  3305. if (key === "module") {
  3306. if (!hasParsedCode(state.funct)) {
  3307. error("E055", state.tokens.next, "module");
  3308. }
  3309. }
  3310. var esversions = {
  3311. es3 : 3,
  3312. es5 : 5,
  3313. esnext: 6
  3314. };
  3315. if (_.has(esversions, key)) {
  3316. switch (val) {
  3317. case "true":
  3318. state.option.moz = false;
  3319. state.option.esversion = esversions[key];
  3320. break;
  3321. case "false":
  3322. if (!state.option.moz) {
  3323. state.option.esversion = 5;
  3324. }
  3325. break;
  3326. default:
  3327. error("E002", nt);
  3328. }
  3329. return;
  3330. }
  3331. if (key === "esversion") {
  3332. switch (val) {
  3333. case "5":
  3334. if (state.inES5(true)) {
  3335. warning("I003");
  3336. }
  3337. case "3":
  3338. case "6":
  3339. state.option.moz = false;
  3340. state.option.esversion = +val;
  3341. break;
  3342. case "2015":
  3343. state.option.moz = false;
  3344. state.option.esversion = 6;
  3345. break;
  3346. default:
  3347. error("E002", nt);
  3348. }
  3349. if (!hasParsedCode(state.funct)) {
  3350. error("E055", state.tokens.next, "esversion");
  3351. }
  3352. return;
  3353. }
  3354. var match = /^([+-])(W\d{3})$/g.exec(key);
  3355. if (match) {
  3356. state.ignored[match[2]] = (match[1] === "-");
  3357. return;
  3358. }
  3359. var tn;
  3360. if (val === "true" || val === "false") {
  3361. if (nt.type === "jslint") {
  3362. tn = options.renamed[key] || key;
  3363. state.option[tn] = (val === "true");
  3364. if (options.inverted[tn] !== undefined) {
  3365. state.option[tn] = !state.option[tn];
  3366. }
  3367. } else {
  3368. state.option[key] = (val === "true");
  3369. }
  3370. if (key === "newcap") {
  3371. state.option["(explicitNewcap)"] = true;
  3372. }
  3373. return;
  3374. }
  3375. error("E002", nt);
  3376. });
  3377. assume();
  3378. }
  3379. }
  3380. function peek(p) {
  3381. var i = p || 0, j = lookahead.length, t;
  3382. if (i < j) {
  3383. return lookahead[i];
  3384. }
  3385. while (j <= i) {
  3386. t = lookahead[j];
  3387. if (!t) {
  3388. t = lookahead[j] = lex.token();
  3389. }
  3390. j += 1;
  3391. }
  3392. if (!t && state.tokens.next.id === "(end)") {
  3393. return state.tokens.next;
  3394. }
  3395. return t;
  3396. }
  3397. function peekIgnoreEOL() {
  3398. var i = 0;
  3399. var t;
  3400. do {
  3401. t = peek(i++);
  3402. } while (t.id === "(endline)");
  3403. return t;
  3404. }
  3405. function advance(id, t) {
  3406. switch (state.tokens.curr.id) {
  3407. case "(number)":
  3408. if (state.tokens.next.id === ".") {
  3409. warning("W005", state.tokens.curr);
  3410. }
  3411. break;
  3412. case "-":
  3413. if (state.tokens.next.id === "-" || state.tokens.next.id === "--") {
  3414. warning("W006");
  3415. }
  3416. break;
  3417. case "+":
  3418. if (state.tokens.next.id === "+" || state.tokens.next.id === "++") {
  3419. warning("W007");
  3420. }
  3421. break;
  3422. }
  3423. if (id && state.tokens.next.id !== id) {
  3424. if (t) {
  3425. if (state.tokens.next.id === "(end)") {
  3426. error("E019", t, t.id);
  3427. } else {
  3428. error("E020", state.tokens.next, id, t.id, t.line, state.tokens.next.value);
  3429. }
  3430. } else if (state.tokens.next.type !== "(identifier)" || state.tokens.next.value !== id) {
  3431. warning("W116", state.tokens.next, id, state.tokens.next.value);
  3432. }
  3433. }
  3434. state.tokens.prev = state.tokens.curr;
  3435. state.tokens.curr = state.tokens.next;
  3436. for (;;) {
  3437. state.tokens.next = lookahead.shift() || lex.token();
  3438. if (!state.tokens.next) { // No more tokens left, give up
  3439. quit("E041", state.tokens.curr.line);
  3440. }
  3441. if (state.tokens.next.id === "(end)" || state.tokens.next.id === "(error)") {
  3442. return;
  3443. }
  3444. if (state.tokens.next.check) {
  3445. state.tokens.next.check();
  3446. }
  3447. if (state.tokens.next.isSpecial) {
  3448. if (state.tokens.next.type === "falls through") {
  3449. state.tokens.curr.caseFallsThrough = true;
  3450. } else {
  3451. doOption();
  3452. }
  3453. } else {
  3454. if (state.tokens.next.id !== "(endline)") {
  3455. break;
  3456. }
  3457. }
  3458. }
  3459. }
  3460. function isInfix(token) {
  3461. return token.infix || (!token.identifier && !token.template && !!token.led);
  3462. }
  3463. function isEndOfExpr() {
  3464. var curr = state.tokens.curr;
  3465. var next = state.tokens.next;
  3466. if (next.id === ";" || next.id === "}" || next.id === ":") {
  3467. return true;
  3468. }
  3469. if (isInfix(next) === isInfix(curr) || (curr.id === "yield" && state.inMoz())) {
  3470. return curr.line !== startLine(next);
  3471. }
  3472. return false;
  3473. }
  3474. function isBeginOfExpr(prev) {
  3475. return !prev.left && prev.arity !== "unary";
  3476. }
  3477. function expression(rbp, initial) {
  3478. var left, isArray = false, isObject = false, isLetExpr = false;
  3479. state.nameStack.push();
  3480. if (!initial && state.tokens.next.value === "let" && peek(0).value === "(") {
  3481. if (!state.inMoz()) {
  3482. warning("W118", state.tokens.next, "let expressions");
  3483. }
  3484. isLetExpr = true;
  3485. state.funct["(scope)"].stack();
  3486. advance("let");
  3487. advance("(");
  3488. state.tokens.prev.fud();
  3489. advance(")");
  3490. }
  3491. if (state.tokens.next.id === "(end)")
  3492. error("E006", state.tokens.curr);
  3493. var isDangerous =
  3494. state.option.asi &&
  3495. state.tokens.prev.line !== startLine(state.tokens.curr) &&
  3496. _.contains(["]", ")"], state.tokens.prev.id) &&
  3497. _.contains(["[", "("], state.tokens.curr.id);
  3498. if (isDangerous)
  3499. warning("W014", state.tokens.curr, state.tokens.curr.id);
  3500. advance();
  3501. if (initial) {
  3502. state.funct["(verb)"] = state.tokens.curr.value;
  3503. state.tokens.curr.beginsStmt = true;
  3504. }
  3505. if (initial === true && state.tokens.curr.fud) {
  3506. left = state.tokens.curr.fud();
  3507. } else {
  3508. if (state.tokens.curr.nud) {
  3509. left = state.tokens.curr.nud();
  3510. } else {
  3511. error("E030", state.tokens.curr, state.tokens.curr.id);
  3512. }
  3513. while ((rbp < state.tokens.next.lbp || state.tokens.next.type === "(template)") &&
  3514. !isEndOfExpr()) {
  3515. isArray = state.tokens.curr.value === "Array";
  3516. isObject = state.tokens.curr.value === "Object";
  3517. if (left && (left.value || (left.first && left.first.value))) {
  3518. if (left.value !== "new" ||
  3519. (left.first && left.first.value && left.first.value === ".")) {
  3520. isArray = false;
  3521. if (left.value !== state.tokens.curr.value) {
  3522. isObject = false;
  3523. }
  3524. }
  3525. }
  3526. advance();
  3527. if (isArray && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
  3528. warning("W009", state.tokens.curr);
  3529. }
  3530. if (isObject && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
  3531. warning("W010", state.tokens.curr);
  3532. }
  3533. if (left && state.tokens.curr.led) {
  3534. left = state.tokens.curr.led(left);
  3535. } else {
  3536. error("E033", state.tokens.curr, state.tokens.curr.id);
  3537. }
  3538. }
  3539. }
  3540. if (isLetExpr) {
  3541. state.funct["(scope)"].unstack();
  3542. }
  3543. state.nameStack.pop();
  3544. return left;
  3545. }
  3546. function startLine(token) {
  3547. return token.startLine || token.line;
  3548. }
  3549. function nobreaknonadjacent(left, right) {
  3550. left = left || state.tokens.curr;
  3551. right = right || state.tokens.next;
  3552. if (!state.option.laxbreak && left.line !== startLine(right)) {
  3553. warning("W014", right, right.value);
  3554. }
  3555. }
  3556. function nolinebreak(t) {
  3557. t = t || state.tokens.curr;
  3558. if (t.line !== startLine(state.tokens.next)) {
  3559. warning("E022", t, t.value);
  3560. }
  3561. }
  3562. function nobreakcomma(left, right) {
  3563. if (left.line !== startLine(right)) {
  3564. if (!state.option.laxcomma) {
  3565. if (comma.first) {
  3566. warning("I001");
  3567. comma.first = false;
  3568. }
  3569. warning("W014", left, right.value);
  3570. }
  3571. }
  3572. }
  3573. function comma(opts) {
  3574. opts = opts || {};
  3575. if (!opts.peek) {
  3576. nobreakcomma(state.tokens.curr, state.tokens.next);
  3577. advance(",");
  3578. } else {
  3579. nobreakcomma(state.tokens.prev, state.tokens.curr);
  3580. }
  3581. if (state.tokens.next.identifier && !(opts.property && state.inES5())) {
  3582. switch (state.tokens.next.value) {
  3583. case "break":
  3584. case "case":
  3585. case "catch":
  3586. case "continue":
  3587. case "default":
  3588. case "do":
  3589. case "else":
  3590. case "finally":
  3591. case "for":
  3592. case "if":
  3593. case "in":
  3594. case "instanceof":
  3595. case "return":
  3596. case "switch":
  3597. case "throw":
  3598. case "try":
  3599. case "var":
  3600. case "let":
  3601. case "while":
  3602. case "with":
  3603. error("E024", state.tokens.next, state.tokens.next.value);
  3604. return false;
  3605. }
  3606. }
  3607. if (state.tokens.next.type === "(punctuator)") {
  3608. switch (state.tokens.next.value) {
  3609. case "}":
  3610. case "]":
  3611. case ",":
  3612. if (opts.allowTrailing) {
  3613. return true;
  3614. }
  3615. case ")":
  3616. error("E024", state.tokens.next, state.tokens.next.value);
  3617. return false;
  3618. }
  3619. }
  3620. return true;
  3621. }
  3622. function symbol(s, p) {
  3623. var x = state.syntax[s];
  3624. if (!x || typeof x !== "object") {
  3625. state.syntax[s] = x = {
  3626. id: s,
  3627. lbp: p,
  3628. value: s
  3629. };
  3630. }
  3631. return x;
  3632. }
  3633. function delim(s) {
  3634. var x = symbol(s, 0);
  3635. x.delim = true;
  3636. return x;
  3637. }
  3638. function stmt(s, f) {
  3639. var x = delim(s);
  3640. x.identifier = x.reserved = true;
  3641. x.fud = f;
  3642. return x;
  3643. }
  3644. function blockstmt(s, f) {
  3645. var x = stmt(s, f);
  3646. x.block = true;
  3647. return x;
  3648. }
  3649. function reserveName(x) {
  3650. var c = x.id.charAt(0);
  3651. if ((c >= "a" && c <= "z") || (c >= "A" && c <= "Z")) {
  3652. x.identifier = x.reserved = true;
  3653. }
  3654. return x;
  3655. }
  3656. function prefix(s, f) {
  3657. var x = symbol(s, 150);
  3658. reserveName(x);
  3659. x.nud = (typeof f === "function") ? f : function() {
  3660. this.arity = "unary";
  3661. this.right = expression(150);
  3662. if (this.id === "++" || this.id === "--") {
  3663. if (state.option.plusplus) {
  3664. warning("W016", this, this.id);
  3665. } else if (this.right && (!this.right.identifier || isReserved(this.right)) &&
  3666. this.right.id !== "." && this.right.id !== "[") {
  3667. warning("W017", this);
  3668. }
  3669. if (this.right && this.right.isMetaProperty) {
  3670. error("E031", this);
  3671. } else if (this.right && this.right.identifier) {
  3672. state.funct["(scope)"].block.modify(this.right.value, this);
  3673. }
  3674. }
  3675. return this;
  3676. };
  3677. return x;
  3678. }
  3679. function type(s, f) {
  3680. var x = delim(s);
  3681. x.type = s;
  3682. x.nud = f;
  3683. return x;
  3684. }
  3685. function reserve(name, func) {
  3686. var x = type(name, func);
  3687. x.identifier = true;
  3688. x.reserved = true;
  3689. return x;
  3690. }
  3691. function FutureReservedWord(name, meta) {
  3692. var x = type(name, (meta && meta.nud) || function() {
  3693. return this;
  3694. });
  3695. meta = meta || {};
  3696. meta.isFutureReservedWord = true;
  3697. x.value = name;
  3698. x.identifier = true;
  3699. x.reserved = true;
  3700. x.meta = meta;
  3701. return x;
  3702. }
  3703. function reservevar(s, v) {
  3704. return reserve(s, function() {
  3705. if (typeof v === "function") {
  3706. v(this);
  3707. }
  3708. return this;
  3709. });
  3710. }
  3711. function infix(s, f, p, w) {
  3712. var x = symbol(s, p);
  3713. reserveName(x);
  3714. x.infix = true;
  3715. x.led = function(left) {
  3716. if (!w) {
  3717. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  3718. }
  3719. if ((s === "in" || s === "instanceof") && left.id === "!") {
  3720. warning("W018", left, "!");
  3721. }
  3722. if (typeof f === "function") {
  3723. return f(left, this);
  3724. } else {
  3725. this.left = left;
  3726. this.right = expression(p);
  3727. return this;
  3728. }
  3729. };
  3730. return x;
  3731. }
  3732. function application(s) {
  3733. var x = symbol(s, 42);
  3734. x.led = function(left) {
  3735. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  3736. this.left = left;
  3737. this.right = doFunction({ type: "arrow", loneArg: left });
  3738. return this;
  3739. };
  3740. return x;
  3741. }
  3742. function relation(s, f) {
  3743. var x = symbol(s, 100);
  3744. x.led = function(left) {
  3745. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  3746. this.left = left;
  3747. var right = this.right = expression(100);
  3748. if (isIdentifier(left, "NaN") || isIdentifier(right, "NaN")) {
  3749. warning("W019", this);
  3750. } else if (f) {
  3751. f.apply(this, [left, right]);
  3752. }
  3753. if (!left || !right) {
  3754. quit("E041", state.tokens.curr.line);
  3755. }
  3756. if (left.id === "!") {
  3757. warning("W018", left, "!");
  3758. }
  3759. if (right.id === "!") {
  3760. warning("W018", right, "!");
  3761. }
  3762. return this;
  3763. };
  3764. return x;
  3765. }
  3766. function isPoorRelation(node) {
  3767. return node &&
  3768. ((node.type === "(number)" && +node.value === 0) ||
  3769. (node.type === "(string)" && node.value === "") ||
  3770. (node.type === "null" && !state.option.eqnull) ||
  3771. node.type === "true" ||
  3772. node.type === "false" ||
  3773. node.type === "undefined");
  3774. }
  3775. var typeofValues = {};
  3776. typeofValues.legacy = [
  3777. "xml",
  3778. "unknown"
  3779. ];
  3780. typeofValues.es3 = [
  3781. "undefined", "boolean", "number", "string", "function", "object",
  3782. ];
  3783. typeofValues.es3 = typeofValues.es3.concat(typeofValues.legacy);
  3784. typeofValues.es6 = typeofValues.es3.concat("symbol");
  3785. function isTypoTypeof(left, right, state) {
  3786. var values;
  3787. if (state.option.notypeof)
  3788. return false;
  3789. if (!left || !right)
  3790. return false;
  3791. values = state.inES6() ? typeofValues.es6 : typeofValues.es3;
  3792. if (right.type === "(identifier)" && right.value === "typeof" && left.type === "(string)")
  3793. return !_.contains(values, left.value);
  3794. return false;
  3795. }
  3796. function isGlobalEval(left, state) {
  3797. var isGlobal = false;
  3798. if (left.type === "this" && state.funct["(context)"] === null) {
  3799. isGlobal = true;
  3800. }
  3801. else if (left.type === "(identifier)") {
  3802. if (state.option.node && left.value === "global") {
  3803. isGlobal = true;
  3804. }
  3805. else if (state.option.browser && (left.value === "window" || left.value === "document")) {
  3806. isGlobal = true;
  3807. }
  3808. }
  3809. return isGlobal;
  3810. }
  3811. function findNativePrototype(left) {
  3812. var natives = [
  3813. "Array", "ArrayBuffer", "Boolean", "Collator", "DataView", "Date",
  3814. "DateTimeFormat", "Error", "EvalError", "Float32Array", "Float64Array",
  3815. "Function", "Infinity", "Intl", "Int16Array", "Int32Array", "Int8Array",
  3816. "Iterator", "Number", "NumberFormat", "Object", "RangeError",
  3817. "ReferenceError", "RegExp", "StopIteration", "String", "SyntaxError",
  3818. "TypeError", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray",
  3819. "URIError"
  3820. ];
  3821. function walkPrototype(obj) {
  3822. if (typeof obj !== "object") return;
  3823. return obj.right === "prototype" ? obj : walkPrototype(obj.left);
  3824. }
  3825. function walkNative(obj) {
  3826. while (!obj.identifier && typeof obj.left === "object")
  3827. obj = obj.left;
  3828. if (obj.identifier && natives.indexOf(obj.value) >= 0)
  3829. return obj.value;
  3830. }
  3831. var prototype = walkPrototype(left);
  3832. if (prototype) return walkNative(prototype);
  3833. }
  3834. function checkLeftSideAssign(left, assignToken, options) {
  3835. var allowDestructuring = options && options.allowDestructuring;
  3836. assignToken = assignToken || left;
  3837. if (state.option.freeze) {
  3838. var nativeObject = findNativePrototype(left);
  3839. if (nativeObject)
  3840. warning("W121", left, nativeObject);
  3841. }
  3842. if (left.identifier && !left.isMetaProperty) {
  3843. state.funct["(scope)"].block.reassign(left.value, left);
  3844. }
  3845. if (left.id === ".") {
  3846. if (!left.left || left.left.value === "arguments" && !state.isStrict()) {
  3847. warning("E031", assignToken);
  3848. }
  3849. state.nameStack.set(state.tokens.prev);
  3850. return true;
  3851. } else if (left.id === "{" || left.id === "[") {
  3852. if (allowDestructuring && state.tokens.curr.left.destructAssign) {
  3853. state.tokens.curr.left.destructAssign.forEach(function(t) {
  3854. if (t.id) {
  3855. state.funct["(scope)"].block.modify(t.id, t.token);
  3856. }
  3857. });
  3858. } else {
  3859. if (left.id === "{" || !left.left) {
  3860. warning("E031", assignToken);
  3861. } else if (left.left.value === "arguments" && !state.isStrict()) {
  3862. warning("E031", assignToken);
  3863. }
  3864. }
  3865. if (left.id === "[") {
  3866. state.nameStack.set(left.right);
  3867. }
  3868. return true;
  3869. } else if (left.isMetaProperty) {
  3870. error("E031", assignToken);
  3871. return true;
  3872. } else if (left.identifier && !isReserved(left)) {
  3873. if (state.funct["(scope)"].labeltype(left.value) === "exception") {
  3874. warning("W022", left);
  3875. }
  3876. state.nameStack.set(left);
  3877. return true;
  3878. }
  3879. if (left === state.syntax["function"]) {
  3880. warning("W023", state.tokens.curr);
  3881. }
  3882. return false;
  3883. }
  3884. function assignop(s, f, p) {
  3885. var x = infix(s, typeof f === "function" ? f : function(left, that) {
  3886. that.left = left;
  3887. if (left && checkLeftSideAssign(left, that, { allowDestructuring: true })) {
  3888. that.right = expression(10);
  3889. return that;
  3890. }
  3891. error("E031", that);
  3892. }, p);
  3893. x.exps = true;
  3894. x.assign = true;
  3895. return x;
  3896. }
  3897. function bitwise(s, f, p) {
  3898. var x = symbol(s, p);
  3899. reserveName(x);
  3900. x.led = (typeof f === "function") ? f : function(left) {
  3901. if (state.option.bitwise) {
  3902. warning("W016", this, this.id);
  3903. }
  3904. this.left = left;
  3905. this.right = expression(p);
  3906. return this;
  3907. };
  3908. return x;
  3909. }
  3910. function bitwiseassignop(s) {
  3911. return assignop(s, function(left, that) {
  3912. if (state.option.bitwise) {
  3913. warning("W016", that, that.id);
  3914. }
  3915. if (left && checkLeftSideAssign(left, that)) {
  3916. that.right = expression(10);
  3917. return that;
  3918. }
  3919. error("E031", that);
  3920. }, 20);
  3921. }
  3922. function suffix(s) {
  3923. var x = symbol(s, 150);
  3924. x.led = function(left) {
  3925. if (state.option.plusplus) {
  3926. warning("W016", this, this.id);
  3927. } else if ((!left.identifier || isReserved(left)) && left.id !== "." && left.id !== "[") {
  3928. warning("W017", this);
  3929. }
  3930. if (left.isMetaProperty) {
  3931. error("E031", this);
  3932. } else if (left && left.identifier) {
  3933. state.funct["(scope)"].block.modify(left.value, left);
  3934. }
  3935. this.left = left;
  3936. return this;
  3937. };
  3938. return x;
  3939. }
  3940. function optionalidentifier(fnparam, prop, preserve) {
  3941. if (!state.tokens.next.identifier) {
  3942. return;
  3943. }
  3944. if (!preserve) {
  3945. advance();
  3946. }
  3947. var curr = state.tokens.curr;
  3948. var val = state.tokens.curr.value;
  3949. if (!isReserved(curr)) {
  3950. return val;
  3951. }
  3952. if (prop) {
  3953. if (state.inES5()) {
  3954. return val;
  3955. }
  3956. }
  3957. if (fnparam && val === "undefined") {
  3958. return val;
  3959. }
  3960. warning("W024", state.tokens.curr, state.tokens.curr.id);
  3961. return val;
  3962. }
  3963. function identifier(fnparam, prop) {
  3964. var i = optionalidentifier(fnparam, prop, false);
  3965. if (i) {
  3966. return i;
  3967. }
  3968. if (state.tokens.next.value === "...") {
  3969. if (!state.inES6(true)) {
  3970. warning("W119", state.tokens.next, "spread/rest operator", "6");
  3971. }
  3972. advance();
  3973. if (checkPunctuator(state.tokens.next, "...")) {
  3974. warning("E024", state.tokens.next, "...");
  3975. while (checkPunctuator(state.tokens.next, "...")) {
  3976. advance();
  3977. }
  3978. }
  3979. if (!state.tokens.next.identifier) {
  3980. warning("E024", state.tokens.curr, "...");
  3981. return;
  3982. }
  3983. return identifier(fnparam, prop);
  3984. } else {
  3985. error("E030", state.tokens.next, state.tokens.next.value);
  3986. if (state.tokens.next.id !== ";") {
  3987. advance();
  3988. }
  3989. }
  3990. }
  3991. function reachable(controlToken) {
  3992. var i = 0, t;
  3993. if (state.tokens.next.id !== ";" || controlToken.inBracelessBlock) {
  3994. return;
  3995. }
  3996. for (;;) {
  3997. do {
  3998. t = peek(i);
  3999. i += 1;
  4000. } while (t.id !== "(end)" && t.id === "(comment)");
  4001. if (t.reach) {
  4002. return;
  4003. }
  4004. if (t.id !== "(endline)") {
  4005. if (t.id === "function") {
  4006. if (state.option.latedef === true) {
  4007. warning("W026", t);
  4008. }
  4009. break;
  4010. }
  4011. warning("W027", t, t.value, controlToken.value);
  4012. break;
  4013. }
  4014. }
  4015. }
  4016. function parseFinalSemicolon() {
  4017. if (state.tokens.next.id !== ";") {
  4018. if (state.tokens.next.isUnclosed) return advance();
  4019. var sameLine = startLine(state.tokens.next) === state.tokens.curr.line &&
  4020. state.tokens.next.id !== "(end)";
  4021. var blockEnd = checkPunctuator(state.tokens.next, "}");
  4022. if (sameLine && !blockEnd) {
  4023. errorAt("E058", state.tokens.curr.line, state.tokens.curr.character);
  4024. } else if (!state.option.asi) {
  4025. if ((blockEnd && !state.option.lastsemic) || !sameLine) {
  4026. warningAt("W033", state.tokens.curr.line, state.tokens.curr.character);
  4027. }
  4028. }
  4029. } else {
  4030. advance(";");
  4031. }
  4032. }
  4033. function statement() {
  4034. var i = indent, r, t = state.tokens.next, hasOwnScope = false;
  4035. if (t.id === ";") {
  4036. advance(";");
  4037. return;
  4038. }
  4039. var res = isReserved(t);
  4040. if (res && t.meta && t.meta.isFutureReservedWord && peek().id === ":") {
  4041. warning("W024", t, t.id);
  4042. res = false;
  4043. }
  4044. if (t.identifier && !res && peek().id === ":") {
  4045. advance();
  4046. advance(":");
  4047. hasOwnScope = true;
  4048. state.funct["(scope)"].stack();
  4049. state.funct["(scope)"].block.addBreakLabel(t.value, { token: state.tokens.curr });
  4050. if (!state.tokens.next.labelled && state.tokens.next.value !== "{") {
  4051. warning("W028", state.tokens.next, t.value, state.tokens.next.value);
  4052. }
  4053. state.tokens.next.label = t.value;
  4054. t = state.tokens.next;
  4055. }
  4056. if (t.id === "{") {
  4057. var iscase = (state.funct["(verb)"] === "case" && state.tokens.curr.value === ":");
  4058. block(true, true, false, false, iscase);
  4059. return;
  4060. }
  4061. r = expression(0, true);
  4062. if (r && !(r.identifier && r.value === "function") &&
  4063. !(r.type === "(punctuator)" && r.left &&
  4064. r.left.identifier && r.left.value === "function")) {
  4065. if (!state.isStrict() &&
  4066. state.option.strict === "global") {
  4067. warning("E007");
  4068. }
  4069. }
  4070. if (!t.block) {
  4071. if (!state.option.expr && (!r || !r.exps)) {
  4072. warning("W030", state.tokens.curr);
  4073. } else if (state.option.nonew && r && r.left && r.id === "(" && r.left.id === "new") {
  4074. warning("W031", t);
  4075. }
  4076. parseFinalSemicolon();
  4077. }
  4078. indent = i;
  4079. if (hasOwnScope) {
  4080. state.funct["(scope)"].unstack();
  4081. }
  4082. return r;
  4083. }
  4084. function statements() {
  4085. var a = [], p;
  4086. while (!state.tokens.next.reach && state.tokens.next.id !== "(end)") {
  4087. if (state.tokens.next.id === ";") {
  4088. p = peek();
  4089. if (!p || (p.id !== "(" && p.id !== "[")) {
  4090. warning("W032");
  4091. }
  4092. advance(";");
  4093. } else {
  4094. a.push(statement());
  4095. }
  4096. }
  4097. return a;
  4098. }
  4099. function directives() {
  4100. var i, p, pn;
  4101. while (state.tokens.next.id === "(string)") {
  4102. p = peek(0);
  4103. if (p.id === "(endline)") {
  4104. i = 1;
  4105. do {
  4106. pn = peek(i++);
  4107. } while (pn.id === "(endline)");
  4108. if (pn.id === ";") {
  4109. p = pn;
  4110. } else if (pn.value === "[" || pn.value === ".") {
  4111. break;
  4112. } else if (!state.option.asi || pn.value === "(") {
  4113. warning("W033", state.tokens.next);
  4114. }
  4115. } else if (p.id === "." || p.id === "[") {
  4116. break;
  4117. } else if (p.id !== ";") {
  4118. warning("W033", p);
  4119. }
  4120. advance();
  4121. var directive = state.tokens.curr.value;
  4122. if (state.directive[directive] ||
  4123. (directive === "use strict" && state.option.strict === "implied")) {
  4124. warning("W034", state.tokens.curr, directive);
  4125. }
  4126. state.directive[directive] = true;
  4127. if (p.id === ";") {
  4128. advance(";");
  4129. }
  4130. }
  4131. if (state.isStrict()) {
  4132. if (!state.option["(explicitNewcap)"]) {
  4133. state.option.newcap = true;
  4134. }
  4135. state.option.undef = true;
  4136. }
  4137. }
  4138. function block(ordinary, stmt, isfunc, isfatarrow, iscase) {
  4139. var a,
  4140. b = inblock,
  4141. old_indent = indent,
  4142. m,
  4143. t,
  4144. line,
  4145. d;
  4146. inblock = ordinary;
  4147. t = state.tokens.next;
  4148. var metrics = state.funct["(metrics)"];
  4149. metrics.nestedBlockDepth += 1;
  4150. metrics.verifyMaxNestedBlockDepthPerFunction();
  4151. if (state.tokens.next.id === "{") {
  4152. advance("{");
  4153. state.funct["(scope)"].stack();
  4154. line = state.tokens.curr.line;
  4155. if (state.tokens.next.id !== "}") {
  4156. indent += state.option.indent;
  4157. while (!ordinary && state.tokens.next.from > indent) {
  4158. indent += state.option.indent;
  4159. }
  4160. if (isfunc) {
  4161. m = {};
  4162. for (d in state.directive) {
  4163. if (_.has(state.directive, d)) {
  4164. m[d] = state.directive[d];
  4165. }
  4166. }
  4167. directives();
  4168. if (state.option.strict && state.funct["(context)"]["(global)"]) {
  4169. if (!m["use strict"] && !state.isStrict()) {
  4170. warning("E007");
  4171. }
  4172. }
  4173. }
  4174. a = statements();
  4175. metrics.statementCount += a.length;
  4176. indent -= state.option.indent;
  4177. }
  4178. advance("}", t);
  4179. if (isfunc) {
  4180. state.funct["(scope)"].validateParams();
  4181. if (m) {
  4182. state.directive = m;
  4183. }
  4184. }
  4185. state.funct["(scope)"].unstack();
  4186. indent = old_indent;
  4187. } else if (!ordinary) {
  4188. if (isfunc) {
  4189. state.funct["(scope)"].stack();
  4190. m = {};
  4191. if (stmt && !isfatarrow && !state.inMoz()) {
  4192. error("W118", state.tokens.curr, "function closure expressions");
  4193. }
  4194. if (!stmt) {
  4195. for (d in state.directive) {
  4196. if (_.has(state.directive, d)) {
  4197. m[d] = state.directive[d];
  4198. }
  4199. }
  4200. }
  4201. expression(10);
  4202. if (state.option.strict && state.funct["(context)"]["(global)"]) {
  4203. if (!m["use strict"] && !state.isStrict()) {
  4204. warning("E007");
  4205. }
  4206. }
  4207. state.funct["(scope)"].unstack();
  4208. } else {
  4209. error("E021", state.tokens.next, "{", state.tokens.next.value);
  4210. }
  4211. } else {
  4212. state.funct["(noblockscopedvar)"] = state.tokens.next.id !== "for";
  4213. state.funct["(scope)"].stack();
  4214. if (!stmt || state.option.curly) {
  4215. warning("W116", state.tokens.next, "{", state.tokens.next.value);
  4216. }
  4217. state.tokens.next.inBracelessBlock = true;
  4218. indent += state.option.indent;
  4219. a = [statement()];
  4220. indent -= state.option.indent;
  4221. state.funct["(scope)"].unstack();
  4222. delete state.funct["(noblockscopedvar)"];
  4223. }
  4224. switch (state.funct["(verb)"]) {
  4225. case "break":
  4226. case "continue":
  4227. case "return":
  4228. case "throw":
  4229. if (iscase) {
  4230. break;
  4231. }
  4232. default:
  4233. state.funct["(verb)"] = null;
  4234. }
  4235. inblock = b;
  4236. if (ordinary && state.option.noempty && (!a || a.length === 0)) {
  4237. warning("W035", state.tokens.prev);
  4238. }
  4239. metrics.nestedBlockDepth -= 1;
  4240. return a;
  4241. }
  4242. function countMember(m) {
  4243. if (membersOnly && typeof membersOnly[m] !== "boolean") {
  4244. warning("W036", state.tokens.curr, m);
  4245. }
  4246. if (typeof member[m] === "number") {
  4247. member[m] += 1;
  4248. } else {
  4249. member[m] = 1;
  4250. }
  4251. }
  4252. type("(number)", function() {
  4253. return this;
  4254. });
  4255. type("(string)", function() {
  4256. return this;
  4257. });
  4258. state.syntax["(identifier)"] = {
  4259. type: "(identifier)",
  4260. lbp: 0,
  4261. identifier: true,
  4262. nud: function() {
  4263. var v = this.value;
  4264. if (state.tokens.next.id === "=>") {
  4265. return this;
  4266. }
  4267. if (!state.funct["(comparray)"].check(v)) {
  4268. state.funct["(scope)"].block.use(v, state.tokens.curr);
  4269. }
  4270. return this;
  4271. },
  4272. led: function() {
  4273. error("E033", state.tokens.next, state.tokens.next.value);
  4274. }
  4275. };
  4276. var baseTemplateSyntax = {
  4277. lbp: 0,
  4278. identifier: false,
  4279. template: true,
  4280. };
  4281. state.syntax["(template)"] = _.extend({
  4282. type: "(template)",
  4283. nud: doTemplateLiteral,
  4284. led: doTemplateLiteral,
  4285. noSubst: false
  4286. }, baseTemplateSyntax);
  4287. state.syntax["(template middle)"] = _.extend({
  4288. type: "(template middle)",
  4289. middle: true,
  4290. noSubst: false
  4291. }, baseTemplateSyntax);
  4292. state.syntax["(template tail)"] = _.extend({
  4293. type: "(template tail)",
  4294. tail: true,
  4295. noSubst: false
  4296. }, baseTemplateSyntax);
  4297. state.syntax["(no subst template)"] = _.extend({
  4298. type: "(template)",
  4299. nud: doTemplateLiteral,
  4300. led: doTemplateLiteral,
  4301. noSubst: true,
  4302. tail: true // mark as tail, since it's always the last component
  4303. }, baseTemplateSyntax);
  4304. type("(regexp)", function() {
  4305. return this;
  4306. });
  4307. delim("(endline)");
  4308. delim("(begin)");
  4309. delim("(end)").reach = true;
  4310. delim("(error)").reach = true;
  4311. delim("}").reach = true;
  4312. delim(")");
  4313. delim("]");
  4314. delim("\"").reach = true;
  4315. delim("'").reach = true;
  4316. delim(";");
  4317. delim(":").reach = true;
  4318. delim("#");
  4319. reserve("else");
  4320. reserve("case").reach = true;
  4321. reserve("catch");
  4322. reserve("default").reach = true;
  4323. reserve("finally");
  4324. reservevar("arguments", function(x) {
  4325. if (state.isStrict() && state.funct["(global)"]) {
  4326. warning("E008", x);
  4327. }
  4328. });
  4329. reservevar("eval");
  4330. reservevar("false");
  4331. reservevar("Infinity");
  4332. reservevar("null");
  4333. reservevar("this", function(x) {
  4334. if (state.isStrict() && !isMethod() &&
  4335. !state.option.validthis && ((state.funct["(statement)"] &&
  4336. state.funct["(name)"].charAt(0) > "Z") || state.funct["(global)"])) {
  4337. warning("W040", x);
  4338. }
  4339. });
  4340. reservevar("true");
  4341. reservevar("undefined");
  4342. assignop("=", "assign", 20);
  4343. assignop("+=", "assignadd", 20);
  4344. assignop("-=", "assignsub", 20);
  4345. assignop("*=", "assignmult", 20);
  4346. assignop("/=", "assigndiv", 20).nud = function() {
  4347. error("E014");
  4348. };
  4349. assignop("%=", "assignmod", 20);
  4350. bitwiseassignop("&=");
  4351. bitwiseassignop("|=");
  4352. bitwiseassignop("^=");
  4353. bitwiseassignop("<<=");
  4354. bitwiseassignop(">>=");
  4355. bitwiseassignop(">>>=");
  4356. infix(",", function(left, that) {
  4357. var expr;
  4358. that.exprs = [left];
  4359. if (state.option.nocomma) {
  4360. warning("W127");
  4361. }
  4362. if (!comma({ peek: true })) {
  4363. return that;
  4364. }
  4365. while (true) {
  4366. if (!(expr = expression(10))) {
  4367. break;
  4368. }
  4369. that.exprs.push(expr);
  4370. if (state.tokens.next.value !== "," || !comma()) {
  4371. break;
  4372. }
  4373. }
  4374. return that;
  4375. }, 10, true);
  4376. infix("?", function(left, that) {
  4377. increaseComplexityCount();
  4378. that.left = left;
  4379. that.right = expression(10);
  4380. advance(":");
  4381. that["else"] = expression(10);
  4382. return that;
  4383. }, 30);
  4384. var orPrecendence = 40;
  4385. infix("||", function(left, that) {
  4386. increaseComplexityCount();
  4387. that.left = left;
  4388. that.right = expression(orPrecendence);
  4389. return that;
  4390. }, orPrecendence);
  4391. infix("&&", "and", 50);
  4392. bitwise("|", "bitor", 70);
  4393. bitwise("^", "bitxor", 80);
  4394. bitwise("&", "bitand", 90);
  4395. relation("==", function(left, right) {
  4396. var eqnull = state.option.eqnull &&
  4397. ((left && left.value) === "null" || (right && right.value) === "null");
  4398. switch (true) {
  4399. case !eqnull && state.option.eqeqeq:
  4400. this.from = this.character;
  4401. warning("W116", this, "===", "==");
  4402. break;
  4403. case isPoorRelation(left):
  4404. warning("W041", this, "===", left.value);
  4405. break;
  4406. case isPoorRelation(right):
  4407. warning("W041", this, "===", right.value);
  4408. break;
  4409. case isTypoTypeof(right, left, state):
  4410. warning("W122", this, right.value);
  4411. break;
  4412. case isTypoTypeof(left, right, state):
  4413. warning("W122", this, left.value);
  4414. break;
  4415. }
  4416. return this;
  4417. });
  4418. relation("===", function(left, right) {
  4419. if (isTypoTypeof(right, left, state)) {
  4420. warning("W122", this, right.value);
  4421. } else if (isTypoTypeof(left, right, state)) {
  4422. warning("W122", this, left.value);
  4423. }
  4424. return this;
  4425. });
  4426. relation("!=", function(left, right) {
  4427. var eqnull = state.option.eqnull &&
  4428. ((left && left.value) === "null" || (right && right.value) === "null");
  4429. if (!eqnull && state.option.eqeqeq) {
  4430. this.from = this.character;
  4431. warning("W116", this, "!==", "!=");
  4432. } else if (isPoorRelation(left)) {
  4433. warning("W041", this, "!==", left.value);
  4434. } else if (isPoorRelation(right)) {
  4435. warning("W041", this, "!==", right.value);
  4436. } else if (isTypoTypeof(right, left, state)) {
  4437. warning("W122", this, right.value);
  4438. } else if (isTypoTypeof(left, right, state)) {
  4439. warning("W122", this, left.value);
  4440. }
  4441. return this;
  4442. });
  4443. relation("!==", function(left, right) {
  4444. if (isTypoTypeof(right, left, state)) {
  4445. warning("W122", this, right.value);
  4446. } else if (isTypoTypeof(left, right, state)) {
  4447. warning("W122", this, left.value);
  4448. }
  4449. return this;
  4450. });
  4451. relation("<");
  4452. relation(">");
  4453. relation("<=");
  4454. relation(">=");
  4455. bitwise("<<", "shiftleft", 120);
  4456. bitwise(">>", "shiftright", 120);
  4457. bitwise(">>>", "shiftrightunsigned", 120);
  4458. infix("in", "in", 120);
  4459. infix("instanceof", "instanceof", 120);
  4460. infix("+", function(left, that) {
  4461. var right;
  4462. that.left = left;
  4463. that.right = right = expression(130);
  4464. if (left && right && left.id === "(string)" && right.id === "(string)") {
  4465. left.value += right.value;
  4466. left.character = right.character;
  4467. if (!state.option.scripturl && reg.javascriptURL.test(left.value)) {
  4468. warning("W050", left);
  4469. }
  4470. return left;
  4471. }
  4472. return that;
  4473. }, 130);
  4474. prefix("+", "num");
  4475. prefix("+++", function() {
  4476. warning("W007");
  4477. this.arity = "unary";
  4478. this.right = expression(150);
  4479. return this;
  4480. });
  4481. infix("+++", function(left) {
  4482. warning("W007");
  4483. this.left = left;
  4484. this.right = expression(130);
  4485. return this;
  4486. }, 130);
  4487. infix("-", "sub", 130);
  4488. prefix("-", "neg");
  4489. prefix("---", function() {
  4490. warning("W006");
  4491. this.arity = "unary";
  4492. this.right = expression(150);
  4493. return this;
  4494. });
  4495. infix("---", function(left) {
  4496. warning("W006");
  4497. this.left = left;
  4498. this.right = expression(130);
  4499. return this;
  4500. }, 130);
  4501. infix("*", "mult", 140);
  4502. infix("/", "div", 140);
  4503. infix("%", "mod", 140);
  4504. suffix("++");
  4505. prefix("++", "preinc");
  4506. state.syntax["++"].exps = true;
  4507. suffix("--");
  4508. prefix("--", "predec");
  4509. state.syntax["--"].exps = true;
  4510. prefix("delete", function() {
  4511. var p = expression(10);
  4512. if (!p) {
  4513. return this;
  4514. }
  4515. if (p.id !== "." && p.id !== "[") {
  4516. warning("W051");
  4517. }
  4518. this.first = p;
  4519. if (p.identifier && !state.isStrict()) {
  4520. p.forgiveUndef = true;
  4521. }
  4522. return this;
  4523. }).exps = true;
  4524. prefix("~", function() {
  4525. if (state.option.bitwise) {
  4526. warning("W016", this, "~");
  4527. }
  4528. this.arity = "unary";
  4529. this.right = expression(150);
  4530. return this;
  4531. });
  4532. prefix("...", function() {
  4533. if (!state.inES6(true)) {
  4534. warning("W119", this, "spread/rest operator", "6");
  4535. }
  4536. if (!state.tokens.next.identifier &&
  4537. state.tokens.next.type !== "(string)" &&
  4538. !checkPunctuators(state.tokens.next, ["[", "("])) {
  4539. error("E030", state.tokens.next, state.tokens.next.value);
  4540. }
  4541. expression(150);
  4542. return this;
  4543. });
  4544. prefix("!", function() {
  4545. this.arity = "unary";
  4546. this.right = expression(150);
  4547. if (!this.right) { // '!' followed by nothing? Give up.
  4548. quit("E041", this.line || 0);
  4549. }
  4550. if (bang[this.right.id] === true) {
  4551. warning("W018", this, "!");
  4552. }
  4553. return this;
  4554. });
  4555. prefix("typeof", (function() {
  4556. var p = expression(150);
  4557. this.first = this.right = p;
  4558. if (!p) { // 'typeof' followed by nothing? Give up.
  4559. quit("E041", this.line || 0, this.character || 0);
  4560. }
  4561. if (p.identifier) {
  4562. p.forgiveUndef = true;
  4563. }
  4564. return this;
  4565. }));
  4566. prefix("new", function() {
  4567. var mp = metaProperty("target", function() {
  4568. if (!state.inES6(true)) {
  4569. warning("W119", state.tokens.prev, "new.target", "6");
  4570. }
  4571. var inFunction, c = state.funct;
  4572. while (c) {
  4573. inFunction = !c["(global)"];
  4574. if (!c["(arrow)"]) { break; }
  4575. c = c["(context)"];
  4576. }
  4577. if (!inFunction) {
  4578. warning("W136", state.tokens.prev, "new.target");
  4579. }
  4580. });
  4581. if (mp) { return mp; }
  4582. var c = expression(155), i;
  4583. if (c && c.id !== "function") {
  4584. if (c.identifier) {
  4585. c["new"] = true;
  4586. switch (c.value) {
  4587. case "Number":
  4588. case "String":
  4589. case "Boolean":
  4590. case "Math":
  4591. case "JSON":
  4592. warning("W053", state.tokens.prev, c.value);
  4593. break;
  4594. case "Symbol":
  4595. if (state.inES6()) {
  4596. warning("W053", state.tokens.prev, c.value);
  4597. }
  4598. break;
  4599. case "Function":
  4600. if (!state.option.evil) {
  4601. warning("W054");
  4602. }
  4603. break;
  4604. case "Date":
  4605. case "RegExp":
  4606. case "this":
  4607. break;
  4608. default:
  4609. if (c.id !== "function") {
  4610. i = c.value.substr(0, 1);
  4611. if (state.option.newcap && (i < "A" || i > "Z") &&
  4612. !state.funct["(scope)"].isPredefined(c.value)) {
  4613. warning("W055", state.tokens.curr);
  4614. }
  4615. }
  4616. }
  4617. } else {
  4618. if (c.id !== "." && c.id !== "[" && c.id !== "(") {
  4619. warning("W056", state.tokens.curr);
  4620. }
  4621. }
  4622. } else {
  4623. if (!state.option.supernew)
  4624. warning("W057", this);
  4625. }
  4626. if (state.tokens.next.id !== "(" && !state.option.supernew) {
  4627. warning("W058", state.tokens.curr, state.tokens.curr.value);
  4628. }
  4629. this.first = this.right = c;
  4630. return this;
  4631. });
  4632. state.syntax["new"].exps = true;
  4633. prefix("void").exps = true;
  4634. infix(".", function(left, that) {
  4635. var m = identifier(false, true);
  4636. if (typeof m === "string") {
  4637. countMember(m);
  4638. }
  4639. that.left = left;
  4640. that.right = m;
  4641. if (m && m === "hasOwnProperty" && state.tokens.next.value === "=") {
  4642. warning("W001");
  4643. }
  4644. if (left && left.value === "arguments" && (m === "callee" || m === "caller")) {
  4645. if (state.option.noarg)
  4646. warning("W059", left, m);
  4647. else if (state.isStrict())
  4648. error("E008");
  4649. } else if (!state.option.evil && left && left.value === "document" &&
  4650. (m === "write" || m === "writeln")) {
  4651. warning("W060", left);
  4652. }
  4653. if (!state.option.evil && (m === "eval" || m === "execScript")) {
  4654. if (isGlobalEval(left, state)) {
  4655. warning("W061");
  4656. }
  4657. }
  4658. return that;
  4659. }, 160, true);
  4660. infix("(", function(left, that) {
  4661. if (state.option.immed && left && !left.immed && left.id === "function") {
  4662. warning("W062");
  4663. }
  4664. var n = 0;
  4665. var p = [];
  4666. if (left) {
  4667. if (left.type === "(identifier)") {
  4668. if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
  4669. if ("Array Number String Boolean Date Object Error Symbol".indexOf(left.value) === -1) {
  4670. if (left.value === "Math") {
  4671. warning("W063", left);
  4672. } else if (state.option.newcap) {
  4673. warning("W064", left);
  4674. }
  4675. }
  4676. }
  4677. }
  4678. }
  4679. if (state.tokens.next.id !== ")") {
  4680. for (;;) {
  4681. p[p.length] = expression(10);
  4682. n += 1;
  4683. if (state.tokens.next.id !== ",") {
  4684. break;
  4685. }
  4686. comma();
  4687. }
  4688. }
  4689. advance(")");
  4690. if (typeof left === "object") {
  4691. if (!state.inES5() && left.value === "parseInt" && n === 1) {
  4692. warning("W065", state.tokens.curr);
  4693. }
  4694. if (!state.option.evil) {
  4695. if (left.value === "eval" || left.value === "Function" ||
  4696. left.value === "execScript") {
  4697. warning("W061", left);
  4698. if (p[0] && [0].id === "(string)") {
  4699. addInternalSrc(left, p[0].value);
  4700. }
  4701. } else if (p[0] && p[0].id === "(string)" &&
  4702. (left.value === "setTimeout" ||
  4703. left.value === "setInterval")) {
  4704. warning("W066", left);
  4705. addInternalSrc(left, p[0].value);
  4706. } else if (p[0] && p[0].id === "(string)" &&
  4707. left.value === "." &&
  4708. left.left.value === "window" &&
  4709. (left.right === "setTimeout" ||
  4710. left.right === "setInterval")) {
  4711. warning("W066", left);
  4712. addInternalSrc(left, p[0].value);
  4713. }
  4714. }
  4715. if (!left.identifier && left.id !== "." && left.id !== "[" && left.id !== "=>" &&
  4716. left.id !== "(" && left.id !== "&&" && left.id !== "||" && left.id !== "?" &&
  4717. !(state.inES6() && left["(name)"])) {
  4718. warning("W067", that);
  4719. }
  4720. }
  4721. that.left = left;
  4722. return that;
  4723. }, 155, true).exps = true;
  4724. prefix("(", function() {
  4725. var pn = state.tokens.next, pn1, i = -1;
  4726. var ret, triggerFnExpr, first, last;
  4727. var parens = 1;
  4728. var opening = state.tokens.curr;
  4729. var preceeding = state.tokens.prev;
  4730. var isNecessary = !state.option.singleGroups;
  4731. do {
  4732. if (pn.value === "(") {
  4733. parens += 1;
  4734. } else if (pn.value === ")") {
  4735. parens -= 1;
  4736. }
  4737. i += 1;
  4738. pn1 = pn;
  4739. pn = peek(i);
  4740. } while (!(parens === 0 && pn1.value === ")") && pn.value !== ";" && pn.type !== "(end)");
  4741. if (state.tokens.next.id === "function") {
  4742. triggerFnExpr = state.tokens.next.immed = true;
  4743. }
  4744. if (pn.value === "=>") {
  4745. return doFunction({ type: "arrow", parsedOpening: true });
  4746. }
  4747. var exprs = [];
  4748. if (state.tokens.next.id !== ")") {
  4749. for (;;) {
  4750. exprs.push(expression(10));
  4751. if (state.tokens.next.id !== ",") {
  4752. break;
  4753. }
  4754. if (state.option.nocomma) {
  4755. warning("W127");
  4756. }
  4757. comma();
  4758. }
  4759. }
  4760. advance(")", this);
  4761. if (state.option.immed && exprs[0] && exprs[0].id === "function") {
  4762. if (state.tokens.next.id !== "(" &&
  4763. state.tokens.next.id !== "." && state.tokens.next.id !== "[") {
  4764. warning("W068", this);
  4765. }
  4766. }
  4767. if (!exprs.length) {
  4768. return;
  4769. }
  4770. if (exprs.length > 1) {
  4771. ret = Object.create(state.syntax[","]);
  4772. ret.exprs = exprs;
  4773. first = exprs[0];
  4774. last = exprs[exprs.length - 1];
  4775. if (!isNecessary) {
  4776. isNecessary = preceeding.assign || preceeding.delim;
  4777. }
  4778. } else {
  4779. ret = first = last = exprs[0];
  4780. if (!isNecessary) {
  4781. isNecessary =
  4782. (opening.beginsStmt && (ret.id === "{" || triggerFnExpr || isFunctor(ret))) ||
  4783. (triggerFnExpr &&
  4784. (!isEndOfExpr() || state.tokens.prev.id !== "}")) ||
  4785. (isFunctor(ret) && !isEndOfExpr()) ||
  4786. (ret.id === "{" && preceeding.id === "=>") ||
  4787. (ret.type === "(number)" &&
  4788. checkPunctuator(pn, ".") && /^\d+$/.test(ret.value));
  4789. }
  4790. }
  4791. if (ret) {
  4792. if (!isNecessary && (first.left || first.right || ret.exprs)) {
  4793. isNecessary =
  4794. (!isBeginOfExpr(preceeding) && first.lbp <= preceeding.lbp) ||
  4795. (!isEndOfExpr() && last.lbp < state.tokens.next.lbp);
  4796. }
  4797. if (!isNecessary) {
  4798. warning("W126", opening);
  4799. }
  4800. ret.paren = true;
  4801. }
  4802. return ret;
  4803. });
  4804. application("=>");
  4805. infix("[", function(left, that) {
  4806. var e = expression(10), s;
  4807. if (e && e.type === "(string)") {
  4808. if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) {
  4809. if (isGlobalEval(left, state)) {
  4810. warning("W061");
  4811. }
  4812. }
  4813. countMember(e.value);
  4814. if (!state.option.sub && reg.identifier.test(e.value)) {
  4815. s = state.syntax[e.value];
  4816. if (!s || !isReserved(s)) {
  4817. warning("W069", state.tokens.prev, e.value);
  4818. }
  4819. }
  4820. }
  4821. advance("]", that);
  4822. if (e && e.value === "hasOwnProperty" && state.tokens.next.value === "=") {
  4823. warning("W001");
  4824. }
  4825. that.left = left;
  4826. that.right = e;
  4827. return that;
  4828. }, 160, true);
  4829. function comprehensiveArrayExpression() {
  4830. var res = {};
  4831. res.exps = true;
  4832. state.funct["(comparray)"].stack();
  4833. var reversed = false;
  4834. if (state.tokens.next.value !== "for") {
  4835. reversed = true;
  4836. if (!state.inMoz()) {
  4837. warning("W116", state.tokens.next, "for", state.tokens.next.value);
  4838. }
  4839. state.funct["(comparray)"].setState("use");
  4840. res.right = expression(10);
  4841. }
  4842. advance("for");
  4843. if (state.tokens.next.value === "each") {
  4844. advance("each");
  4845. if (!state.inMoz()) {
  4846. warning("W118", state.tokens.curr, "for each");
  4847. }
  4848. }
  4849. advance("(");
  4850. state.funct["(comparray)"].setState("define");
  4851. res.left = expression(130);
  4852. if (_.contains(["in", "of"], state.tokens.next.value)) {
  4853. advance();
  4854. } else {
  4855. error("E045", state.tokens.curr);
  4856. }
  4857. state.funct["(comparray)"].setState("generate");
  4858. expression(10);
  4859. advance(")");
  4860. if (state.tokens.next.value === "if") {
  4861. advance("if");
  4862. advance("(");
  4863. state.funct["(comparray)"].setState("filter");
  4864. res.filter = expression(10);
  4865. advance(")");
  4866. }
  4867. if (!reversed) {
  4868. state.funct["(comparray)"].setState("use");
  4869. res.right = expression(10);
  4870. }
  4871. advance("]");
  4872. state.funct["(comparray)"].unstack();
  4873. return res;
  4874. }
  4875. prefix("[", function() {
  4876. var blocktype = lookupBlockType();
  4877. if (blocktype.isCompArray) {
  4878. if (!state.option.esnext && !state.inMoz()) {
  4879. warning("W118", state.tokens.curr, "array comprehension");
  4880. }
  4881. return comprehensiveArrayExpression();
  4882. } else if (blocktype.isDestAssign) {
  4883. this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
  4884. return this;
  4885. }
  4886. var b = state.tokens.curr.line !== startLine(state.tokens.next);
  4887. this.first = [];
  4888. if (b) {
  4889. indent += state.option.indent;
  4890. if (state.tokens.next.from === indent + state.option.indent) {
  4891. indent += state.option.indent;
  4892. }
  4893. }
  4894. while (state.tokens.next.id !== "(end)") {
  4895. while (state.tokens.next.id === ",") {
  4896. if (!state.option.elision) {
  4897. if (!state.inES5()) {
  4898. warning("W070");
  4899. } else {
  4900. warning("W128");
  4901. do {
  4902. advance(",");
  4903. } while (state.tokens.next.id === ",");
  4904. continue;
  4905. }
  4906. }
  4907. advance(",");
  4908. }
  4909. if (state.tokens.next.id === "]") {
  4910. break;
  4911. }
  4912. this.first.push(expression(10));
  4913. if (state.tokens.next.id === ",") {
  4914. comma({ allowTrailing: true });
  4915. if (state.tokens.next.id === "]" && !state.inES5()) {
  4916. warning("W070", state.tokens.curr);
  4917. break;
  4918. }
  4919. } else {
  4920. break;
  4921. }
  4922. }
  4923. if (b) {
  4924. indent -= state.option.indent;
  4925. }
  4926. advance("]", this);
  4927. return this;
  4928. });
  4929. function isMethod() {
  4930. return state.funct["(statement)"] && state.funct["(statement)"].type === "class" ||
  4931. state.funct["(context)"] && state.funct["(context)"]["(verb)"] === "class";
  4932. }
  4933. function isPropertyName(token) {
  4934. return token.identifier || token.id === "(string)" || token.id === "(number)";
  4935. }
  4936. function propertyName(preserveOrToken) {
  4937. var id;
  4938. var preserve = true;
  4939. if (typeof preserveOrToken === "object") {
  4940. id = preserveOrToken;
  4941. } else {
  4942. preserve = preserveOrToken;
  4943. id = optionalidentifier(false, true, preserve);
  4944. }
  4945. if (!id) {
  4946. if (state.tokens.next.id === "(string)") {
  4947. id = state.tokens.next.value;
  4948. if (!preserve) {
  4949. advance();
  4950. }
  4951. } else if (state.tokens.next.id === "(number)") {
  4952. id = state.tokens.next.value.toString();
  4953. if (!preserve) {
  4954. advance();
  4955. }
  4956. }
  4957. } else if (typeof id === "object") {
  4958. if (id.id === "(string)" || id.id === "(identifier)") id = id.value;
  4959. else if (id.id === "(number)") id = id.value.toString();
  4960. }
  4961. if (id === "hasOwnProperty") {
  4962. warning("W001");
  4963. }
  4964. return id;
  4965. }
  4966. function functionparams(options) {
  4967. var next;
  4968. var paramsIds = [];
  4969. var ident;
  4970. var tokens = [];
  4971. var t;
  4972. var pastDefault = false;
  4973. var pastRest = false;
  4974. var arity = 0;
  4975. var loneArg = options && options.loneArg;
  4976. if (loneArg && loneArg.identifier === true) {
  4977. state.funct["(scope)"].addParam(loneArg.value, loneArg);
  4978. return { arity: 1, params: [ loneArg.value ] };
  4979. }
  4980. next = state.tokens.next;
  4981. if (!options || !options.parsedOpening) {
  4982. advance("(");
  4983. }
  4984. if (state.tokens.next.id === ")") {
  4985. advance(")");
  4986. return;
  4987. }
  4988. function addParam(addParamArgs) {
  4989. state.funct["(scope)"].addParam.apply(state.funct["(scope)"], addParamArgs);
  4990. }
  4991. for (;;) {
  4992. arity++;
  4993. var currentParams = [];
  4994. if (_.contains(["{", "["], state.tokens.next.id)) {
  4995. tokens = destructuringPattern();
  4996. for (t in tokens) {
  4997. t = tokens[t];
  4998. if (t.id) {
  4999. paramsIds.push(t.id);
  5000. currentParams.push([t.id, t.token]);
  5001. }
  5002. }
  5003. } else {
  5004. if (checkPunctuator(state.tokens.next, "...")) pastRest = true;
  5005. ident = identifier(true);
  5006. if (ident) {
  5007. paramsIds.push(ident);
  5008. currentParams.push([ident, state.tokens.curr]);
  5009. } else {
  5010. while (!checkPunctuators(state.tokens.next, [",", ")"])) advance();
  5011. }
  5012. }
  5013. if (pastDefault) {
  5014. if (state.tokens.next.id !== "=") {
  5015. error("W138", state.tokens.current);
  5016. }
  5017. }
  5018. if (state.tokens.next.id === "=") {
  5019. if (!state.inES6()) {
  5020. warning("W119", state.tokens.next, "default parameters", "6");
  5021. }
  5022. advance("=");
  5023. pastDefault = true;
  5024. expression(10);
  5025. }
  5026. currentParams.forEach(addParam);
  5027. if (state.tokens.next.id === ",") {
  5028. if (pastRest) {
  5029. warning("W131", state.tokens.next);
  5030. }
  5031. comma();
  5032. } else {
  5033. advance(")", next);
  5034. return { arity: arity, params: paramsIds };
  5035. }
  5036. }
  5037. }
  5038. function functor(name, token, overwrites) {
  5039. var funct = {
  5040. "(name)" : name,
  5041. "(breakage)" : 0,
  5042. "(loopage)" : 0,
  5043. "(tokens)" : {},
  5044. "(properties)": {},
  5045. "(catch)" : false,
  5046. "(global)" : false,
  5047. "(line)" : null,
  5048. "(character)" : null,
  5049. "(metrics)" : null,
  5050. "(statement)" : null,
  5051. "(context)" : null,
  5052. "(scope)" : null,
  5053. "(comparray)" : null,
  5054. "(generator)" : null,
  5055. "(arrow)" : null,
  5056. "(params)" : null
  5057. };
  5058. if (token) {
  5059. _.extend(funct, {
  5060. "(line)" : token.line,
  5061. "(character)": token.character,
  5062. "(metrics)" : createMetrics(token)
  5063. });
  5064. }
  5065. _.extend(funct, overwrites);
  5066. if (funct["(context)"]) {
  5067. funct["(scope)"] = funct["(context)"]["(scope)"];
  5068. funct["(comparray)"] = funct["(context)"]["(comparray)"];
  5069. }
  5070. return funct;
  5071. }
  5072. function isFunctor(token) {
  5073. return "(scope)" in token;
  5074. }
  5075. function hasParsedCode(funct) {
  5076. return funct["(global)"] && !funct["(verb)"];
  5077. }
  5078. function doTemplateLiteral(left) {
  5079. var ctx = this.context;
  5080. var noSubst = this.noSubst;
  5081. var depth = this.depth;
  5082. if (!noSubst) {
  5083. while (!end()) {
  5084. if (!state.tokens.next.template || state.tokens.next.depth > depth) {
  5085. expression(0); // should probably have different rbp?
  5086. } else {
  5087. advance();
  5088. }
  5089. }
  5090. }
  5091. return {
  5092. id: "(template)",
  5093. type: "(template)",
  5094. tag: left
  5095. };
  5096. function end() {
  5097. if (state.tokens.curr.template && state.tokens.curr.tail &&
  5098. state.tokens.curr.context === ctx) return true;
  5099. var complete = (state.tokens.next.template && state.tokens.next.tail &&
  5100. state.tokens.next.context === ctx);
  5101. if (complete) advance();
  5102. return complete || state.tokens.next.isUnclosed;
  5103. }
  5104. }
  5105. function doFunction(options) {
  5106. var f, token, name, statement, classExprBinding, isGenerator, isArrow, ignoreLoopFunc;
  5107. var oldOption = state.option;
  5108. var oldIgnored = state.ignored;
  5109. if (options) {
  5110. name = options.name;
  5111. statement = options.statement;
  5112. classExprBinding = options.classExprBinding;
  5113. isGenerator = options.type === "generator";
  5114. isArrow = options.type === "arrow";
  5115. ignoreLoopFunc = options.ignoreLoopFunc;
  5116. }
  5117. state.option = Object.create(state.option);
  5118. state.ignored = Object.create(state.ignored);
  5119. state.funct = functor(name || state.nameStack.infer(), state.tokens.next, {
  5120. "(statement)": statement,
  5121. "(context)": state.funct,
  5122. "(arrow)": isArrow,
  5123. "(generator)": isGenerator
  5124. });
  5125. f = state.funct;
  5126. token = state.tokens.curr;
  5127. token.funct = state.funct;
  5128. functions.push(state.funct);
  5129. state.funct["(scope)"].stack("functionouter");
  5130. var internallyAccessibleName = name || classExprBinding;
  5131. if (internallyAccessibleName) {
  5132. state.funct["(scope)"].block.add(internallyAccessibleName,
  5133. classExprBinding ? "class" : "function", state.tokens.curr, false);
  5134. }
  5135. state.funct["(scope)"].stack("functionparams");
  5136. var paramsInfo = functionparams(options);
  5137. if (paramsInfo) {
  5138. state.funct["(params)"] = paramsInfo.params;
  5139. state.funct["(metrics)"].arity = paramsInfo.arity;
  5140. state.funct["(metrics)"].verifyMaxParametersPerFunction();
  5141. } else {
  5142. state.funct["(metrics)"].arity = 0;
  5143. }
  5144. if (isArrow) {
  5145. if (!state.inES6(true)) {
  5146. warning("W119", state.tokens.curr, "arrow function syntax (=>)", "6");
  5147. }
  5148. if (!options.loneArg) {
  5149. advance("=>");
  5150. }
  5151. }
  5152. block(false, true, true, isArrow);
  5153. if (!state.option.noyield && isGenerator &&
  5154. state.funct["(generator)"] !== "yielded") {
  5155. warning("W124", state.tokens.curr);
  5156. }
  5157. state.funct["(metrics)"].verifyMaxStatementsPerFunction();
  5158. state.funct["(metrics)"].verifyMaxComplexityPerFunction();
  5159. state.funct["(unusedOption)"] = state.option.unused;
  5160. state.option = oldOption;
  5161. state.ignored = oldIgnored;
  5162. state.funct["(last)"] = state.tokens.curr.line;
  5163. state.funct["(lastcharacter)"] = state.tokens.curr.character;
  5164. state.funct["(scope)"].unstack(); // also does usage and label checks
  5165. state.funct["(scope)"].unstack();
  5166. state.funct = state.funct["(context)"];
  5167. if (!ignoreLoopFunc && !state.option.loopfunc && state.funct["(loopage)"]) {
  5168. if (f["(isCapturing)"]) {
  5169. warning("W083", token);
  5170. }
  5171. }
  5172. return f;
  5173. }
  5174. function createMetrics(functionStartToken) {
  5175. return {
  5176. statementCount: 0,
  5177. nestedBlockDepth: -1,
  5178. ComplexityCount: 1,
  5179. arity: 0,
  5180. verifyMaxStatementsPerFunction: function() {
  5181. if (state.option.maxstatements &&
  5182. this.statementCount > state.option.maxstatements) {
  5183. warning("W071", functionStartToken, this.statementCount);
  5184. }
  5185. },
  5186. verifyMaxParametersPerFunction: function() {
  5187. if (_.isNumber(state.option.maxparams) &&
  5188. this.arity > state.option.maxparams) {
  5189. warning("W072", functionStartToken, this.arity);
  5190. }
  5191. },
  5192. verifyMaxNestedBlockDepthPerFunction: function() {
  5193. if (state.option.maxdepth &&
  5194. this.nestedBlockDepth > 0 &&
  5195. this.nestedBlockDepth === state.option.maxdepth + 1) {
  5196. warning("W073", null, this.nestedBlockDepth);
  5197. }
  5198. },
  5199. verifyMaxComplexityPerFunction: function() {
  5200. var max = state.option.maxcomplexity;
  5201. var cc = this.ComplexityCount;
  5202. if (max && cc > max) {
  5203. warning("W074", functionStartToken, cc);
  5204. }
  5205. }
  5206. };
  5207. }
  5208. function increaseComplexityCount() {
  5209. state.funct["(metrics)"].ComplexityCount += 1;
  5210. }
  5211. function checkCondAssignment(expr) {
  5212. var id, paren;
  5213. if (expr) {
  5214. id = expr.id;
  5215. paren = expr.paren;
  5216. if (id === "," && (expr = expr.exprs[expr.exprs.length - 1])) {
  5217. id = expr.id;
  5218. paren = paren || expr.paren;
  5219. }
  5220. }
  5221. switch (id) {
  5222. case "=":
  5223. case "+=":
  5224. case "-=":
  5225. case "*=":
  5226. case "%=":
  5227. case "&=":
  5228. case "|=":
  5229. case "^=":
  5230. case "/=":
  5231. if (!paren && !state.option.boss) {
  5232. warning("W084");
  5233. }
  5234. }
  5235. }
  5236. function checkProperties(props) {
  5237. if (state.inES5()) {
  5238. for (var name in props) {
  5239. if (props[name] && props[name].setterToken && !props[name].getterToken) {
  5240. warning("W078", props[name].setterToken);
  5241. }
  5242. }
  5243. }
  5244. }
  5245. function metaProperty(name, c) {
  5246. if (checkPunctuator(state.tokens.next, ".")) {
  5247. var left = state.tokens.curr.id;
  5248. advance(".");
  5249. var id = identifier();
  5250. state.tokens.curr.isMetaProperty = true;
  5251. if (name !== id) {
  5252. error("E057", state.tokens.prev, left, id);
  5253. } else {
  5254. c();
  5255. }
  5256. return state.tokens.curr;
  5257. }
  5258. }
  5259. (function(x) {
  5260. x.nud = function() {
  5261. var b, f, i, p, t, isGeneratorMethod = false, nextVal;
  5262. var props = Object.create(null); // All properties, including accessors
  5263. b = state.tokens.curr.line !== startLine(state.tokens.next);
  5264. if (b) {
  5265. indent += state.option.indent;
  5266. if (state.tokens.next.from === indent + state.option.indent) {
  5267. indent += state.option.indent;
  5268. }
  5269. }
  5270. var blocktype = lookupBlockType();
  5271. if (blocktype.isDestAssign) {
  5272. this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
  5273. return this;
  5274. }
  5275. for (;;) {
  5276. if (state.tokens.next.id === "}") {
  5277. break;
  5278. }
  5279. nextVal = state.tokens.next.value;
  5280. if (state.tokens.next.identifier &&
  5281. (peekIgnoreEOL().id === "," || peekIgnoreEOL().id === "}")) {
  5282. if (!state.inES6()) {
  5283. warning("W104", state.tokens.next, "object short notation", "6");
  5284. }
  5285. i = propertyName(true);
  5286. saveProperty(props, i, state.tokens.next);
  5287. expression(10);
  5288. } else if (peek().id !== ":" && (nextVal === "get" || nextVal === "set")) {
  5289. advance(nextVal);
  5290. if (!state.inES5()) {
  5291. error("E034");
  5292. }
  5293. i = propertyName();
  5294. if (!i && !state.inES6()) {
  5295. error("E035");
  5296. }
  5297. if (i) {
  5298. saveAccessor(nextVal, props, i, state.tokens.curr);
  5299. }
  5300. t = state.tokens.next;
  5301. f = doFunction();
  5302. p = f["(params)"];
  5303. if (nextVal === "get" && i && p) {
  5304. warning("W076", t, p[0], i);
  5305. } else if (nextVal === "set" && i && (!p || p.length !== 1)) {
  5306. warning("W077", t, i);
  5307. }
  5308. } else {
  5309. if (state.tokens.next.value === "*" && state.tokens.next.type === "(punctuator)") {
  5310. if (!state.inES6()) {
  5311. warning("W104", state.tokens.next, "generator functions", "6");
  5312. }
  5313. advance("*");
  5314. isGeneratorMethod = true;
  5315. } else {
  5316. isGeneratorMethod = false;
  5317. }
  5318. if (state.tokens.next.id === "[") {
  5319. i = computedPropertyName();
  5320. state.nameStack.set(i);
  5321. } else {
  5322. state.nameStack.set(state.tokens.next);
  5323. i = propertyName();
  5324. saveProperty(props, i, state.tokens.next);
  5325. if (typeof i !== "string") {
  5326. break;
  5327. }
  5328. }
  5329. if (state.tokens.next.value === "(") {
  5330. if (!state.inES6()) {
  5331. warning("W104", state.tokens.curr, "concise methods", "6");
  5332. }
  5333. doFunction({ type: isGeneratorMethod ? "generator" : null });
  5334. } else {
  5335. advance(":");
  5336. expression(10);
  5337. }
  5338. }
  5339. countMember(i);
  5340. if (state.tokens.next.id === ",") {
  5341. comma({ allowTrailing: true, property: true });
  5342. if (state.tokens.next.id === ",") {
  5343. warning("W070", state.tokens.curr);
  5344. } else if (state.tokens.next.id === "}" && !state.inES5()) {
  5345. warning("W070", state.tokens.curr);
  5346. }
  5347. } else {
  5348. break;
  5349. }
  5350. }
  5351. if (b) {
  5352. indent -= state.option.indent;
  5353. }
  5354. advance("}", this);
  5355. checkProperties(props);
  5356. return this;
  5357. };
  5358. x.fud = function() {
  5359. error("E036", state.tokens.curr);
  5360. };
  5361. }(delim("{")));
  5362. function destructuringPattern(options) {
  5363. var isAssignment = options && options.assignment;
  5364. if (!state.inES6()) {
  5365. warning("W104", state.tokens.curr,
  5366. isAssignment ? "destructuring assignment" : "destructuring binding", "6");
  5367. }
  5368. return destructuringPatternRecursive(options);
  5369. }
  5370. function destructuringPatternRecursive(options) {
  5371. var ids;
  5372. var identifiers = [];
  5373. var openingParsed = options && options.openingParsed;
  5374. var isAssignment = options && options.assignment;
  5375. var recursiveOptions = isAssignment ? { assignment: isAssignment } : null;
  5376. var firstToken = openingParsed ? state.tokens.curr : state.tokens.next;
  5377. var nextInnerDE = function() {
  5378. var ident;
  5379. if (checkPunctuators(state.tokens.next, ["[", "{"])) {
  5380. ids = destructuringPatternRecursive(recursiveOptions);
  5381. for (var id in ids) {
  5382. id = ids[id];
  5383. identifiers.push({ id: id.id, token: id.token });
  5384. }
  5385. } else if (checkPunctuator(state.tokens.next, ",")) {
  5386. identifiers.push({ id: null, token: state.tokens.curr });
  5387. } else if (checkPunctuator(state.tokens.next, "(")) {
  5388. advance("(");
  5389. nextInnerDE();
  5390. advance(")");
  5391. } else {
  5392. var is_rest = checkPunctuator(state.tokens.next, "...");
  5393. if (isAssignment) {
  5394. var identifierToken = is_rest ? peek(0) : state.tokens.next;
  5395. if (!identifierToken.identifier) {
  5396. warning("E030", identifierToken, identifierToken.value);
  5397. }
  5398. var assignTarget = expression(155);
  5399. if (assignTarget) {
  5400. checkLeftSideAssign(assignTarget);
  5401. if (assignTarget.identifier) {
  5402. ident = assignTarget.value;
  5403. }
  5404. }
  5405. } else {
  5406. ident = identifier();
  5407. }
  5408. if (ident) {
  5409. identifiers.push({ id: ident, token: state.tokens.curr });
  5410. }
  5411. return is_rest;
  5412. }
  5413. return false;
  5414. };
  5415. var assignmentProperty = function() {
  5416. var id;
  5417. if (checkPunctuator(state.tokens.next, "[")) {
  5418. advance("[");
  5419. expression(10);
  5420. advance("]");
  5421. advance(":");
  5422. nextInnerDE();
  5423. } else if (state.tokens.next.id === "(string)" ||
  5424. state.tokens.next.id === "(number)") {
  5425. advance();
  5426. advance(":");
  5427. nextInnerDE();
  5428. } else {
  5429. id = identifier();
  5430. if (checkPunctuator(state.tokens.next, ":")) {
  5431. advance(":");
  5432. nextInnerDE();
  5433. } else if (id) {
  5434. if (isAssignment) {
  5435. checkLeftSideAssign(state.tokens.curr);
  5436. }
  5437. identifiers.push({ id: id, token: state.tokens.curr });
  5438. }
  5439. }
  5440. };
  5441. if (checkPunctuator(firstToken, "[")) {
  5442. if (!openingParsed) {
  5443. advance("[");
  5444. }
  5445. if (checkPunctuator(state.tokens.next, "]")) {
  5446. warning("W137", state.tokens.curr);
  5447. }
  5448. var element_after_rest = false;
  5449. while (!checkPunctuator(state.tokens.next, "]")) {
  5450. if (nextInnerDE() && !element_after_rest &&
  5451. checkPunctuator(state.tokens.next, ",")) {
  5452. warning("W130", state.tokens.next);
  5453. element_after_rest = true;
  5454. }
  5455. if (checkPunctuator(state.tokens.next, "=")) {
  5456. if (checkPunctuator(state.tokens.prev, "...")) {
  5457. advance("]");
  5458. } else {
  5459. advance("=");
  5460. }
  5461. if (state.tokens.next.id === "undefined") {
  5462. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5463. }
  5464. expression(10);
  5465. }
  5466. if (!checkPunctuator(state.tokens.next, "]")) {
  5467. advance(",");
  5468. }
  5469. }
  5470. advance("]");
  5471. } else if (checkPunctuator(firstToken, "{")) {
  5472. if (!openingParsed) {
  5473. advance("{");
  5474. }
  5475. if (checkPunctuator(state.tokens.next, "}")) {
  5476. warning("W137", state.tokens.curr);
  5477. }
  5478. while (!checkPunctuator(state.tokens.next, "}")) {
  5479. assignmentProperty();
  5480. if (checkPunctuator(state.tokens.next, "=")) {
  5481. advance("=");
  5482. if (state.tokens.next.id === "undefined") {
  5483. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5484. }
  5485. expression(10);
  5486. }
  5487. if (!checkPunctuator(state.tokens.next, "}")) {
  5488. advance(",");
  5489. if (checkPunctuator(state.tokens.next, "}")) {
  5490. break;
  5491. }
  5492. }
  5493. }
  5494. advance("}");
  5495. }
  5496. return identifiers;
  5497. }
  5498. function destructuringPatternMatch(tokens, value) {
  5499. var first = value.first;
  5500. if (!first)
  5501. return;
  5502. _.zip(tokens, Array.isArray(first) ? first : [ first ]).forEach(function(val) {
  5503. var token = val[0];
  5504. var value = val[1];
  5505. if (token && value)
  5506. token.first = value;
  5507. else if (token && token.first && !value)
  5508. warning("W080", token.first, token.first.value);
  5509. });
  5510. }
  5511. function blockVariableStatement(type, statement, context) {
  5512. var prefix = context && context.prefix;
  5513. var inexport = context && context.inexport;
  5514. var isLet = type === "let";
  5515. var isConst = type === "const";
  5516. var tokens, lone, value, letblock;
  5517. if (!state.inES6()) {
  5518. warning("W104", state.tokens.curr, type, "6");
  5519. }
  5520. if (isLet && state.tokens.next.value === "(") {
  5521. if (!state.inMoz()) {
  5522. warning("W118", state.tokens.next, "let block");
  5523. }
  5524. advance("(");
  5525. state.funct["(scope)"].stack();
  5526. letblock = true;
  5527. } else if (state.funct["(noblockscopedvar)"]) {
  5528. error("E048", state.tokens.curr, isConst ? "Const" : "Let");
  5529. }
  5530. statement.first = [];
  5531. for (;;) {
  5532. var names = [];
  5533. if (_.contains(["{", "["], state.tokens.next.value)) {
  5534. tokens = destructuringPattern();
  5535. lone = false;
  5536. } else {
  5537. tokens = [ { id: identifier(), token: state.tokens.curr } ];
  5538. lone = true;
  5539. }
  5540. if (!prefix && isConst && state.tokens.next.id !== "=") {
  5541. warning("E012", state.tokens.curr, state.tokens.curr.value);
  5542. }
  5543. for (var t in tokens) {
  5544. if (tokens.hasOwnProperty(t)) {
  5545. t = tokens[t];
  5546. if (state.funct["(scope)"].block.isGlobal()) {
  5547. if (predefined[t.id] === false) {
  5548. warning("W079", t.token, t.id);
  5549. }
  5550. }
  5551. if (t.id && !state.funct["(noblockscopedvar)"]) {
  5552. state.funct["(scope)"].addlabel(t.id, {
  5553. type: type,
  5554. token: t.token });
  5555. names.push(t.token);
  5556. if (lone && inexport) {
  5557. state.funct["(scope)"].setExported(t.token.value, t.token);
  5558. }
  5559. }
  5560. }
  5561. }
  5562. if (state.tokens.next.id === "=") {
  5563. advance("=");
  5564. if (!prefix && state.tokens.next.id === "undefined") {
  5565. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5566. }
  5567. if (!prefix && peek(0).id === "=" && state.tokens.next.identifier) {
  5568. warning("W120", state.tokens.next, state.tokens.next.value);
  5569. }
  5570. value = expression(prefix ? 120 : 10);
  5571. if (lone) {
  5572. tokens[0].first = value;
  5573. } else {
  5574. destructuringPatternMatch(names, value);
  5575. }
  5576. }
  5577. statement.first = statement.first.concat(names);
  5578. if (state.tokens.next.id !== ",") {
  5579. break;
  5580. }
  5581. comma();
  5582. }
  5583. if (letblock) {
  5584. advance(")");
  5585. block(true, true);
  5586. statement.block = true;
  5587. state.funct["(scope)"].unstack();
  5588. }
  5589. return statement;
  5590. }
  5591. var conststatement = stmt("const", function(context) {
  5592. return blockVariableStatement("const", this, context);
  5593. });
  5594. conststatement.exps = true;
  5595. var letstatement = stmt("let", function(context) {
  5596. return blockVariableStatement("let", this, context);
  5597. });
  5598. letstatement.exps = true;
  5599. var varstatement = stmt("var", function(context) {
  5600. var prefix = context && context.prefix;
  5601. var inexport = context && context.inexport;
  5602. var tokens, lone, value;
  5603. var implied = context && context.implied;
  5604. var report = !(context && context.ignore);
  5605. this.first = [];
  5606. for (;;) {
  5607. var names = [];
  5608. if (_.contains(["{", "["], state.tokens.next.value)) {
  5609. tokens = destructuringPattern();
  5610. lone = false;
  5611. } else {
  5612. tokens = [ { id: identifier(), token: state.tokens.curr } ];
  5613. lone = true;
  5614. }
  5615. if (!(prefix && implied) && report && state.option.varstmt) {
  5616. warning("W132", this);
  5617. }
  5618. this.first = this.first.concat(names);
  5619. for (var t in tokens) {
  5620. if (tokens.hasOwnProperty(t)) {
  5621. t = tokens[t];
  5622. if (!implied && state.funct["(global)"]) {
  5623. if (predefined[t.id] === false) {
  5624. warning("W079", t.token, t.id);
  5625. } else if (state.option.futurehostile === false) {
  5626. if ((!state.inES5() && vars.ecmaIdentifiers[5][t.id] === false) ||
  5627. (!state.inES6() && vars.ecmaIdentifiers[6][t.id] === false)) {
  5628. warning("W129", t.token, t.id);
  5629. }
  5630. }
  5631. }
  5632. if (t.id) {
  5633. if (implied === "for") {
  5634. if (!state.funct["(scope)"].has(t.id)) {
  5635. if (report) warning("W088", t.token, t.id);
  5636. }
  5637. state.funct["(scope)"].block.use(t.id, t.token);
  5638. } else {
  5639. state.funct["(scope)"].addlabel(t.id, {
  5640. type: "var",
  5641. token: t.token });
  5642. if (lone && inexport) {
  5643. state.funct["(scope)"].setExported(t.id, t.token);
  5644. }
  5645. }
  5646. names.push(t.token);
  5647. }
  5648. }
  5649. }
  5650. if (state.tokens.next.id === "=") {
  5651. state.nameStack.set(state.tokens.curr);
  5652. advance("=");
  5653. if (!prefix && report && !state.funct["(loopage)"] &&
  5654. state.tokens.next.id === "undefined") {
  5655. warning("W080", state.tokens.prev, state.tokens.prev.value);
  5656. }
  5657. if (peek(0).id === "=" && state.tokens.next.identifier) {
  5658. if (!prefix && report &&
  5659. !state.funct["(params)"] ||
  5660. state.funct["(params)"].indexOf(state.tokens.next.value) === -1) {
  5661. warning("W120", state.tokens.next, state.tokens.next.value);
  5662. }
  5663. }
  5664. value = expression(prefix ? 120 : 10);
  5665. if (lone) {
  5666. tokens[0].first = value;
  5667. } else {
  5668. destructuringPatternMatch(names, value);
  5669. }
  5670. }
  5671. if (state.tokens.next.id !== ",") {
  5672. break;
  5673. }
  5674. comma();
  5675. }
  5676. return this;
  5677. });
  5678. varstatement.exps = true;
  5679. blockstmt("class", function() {
  5680. return classdef.call(this, true);
  5681. });
  5682. function classdef(isStatement) {
  5683. if (!state.inES6()) {
  5684. warning("W104", state.tokens.curr, "class", "6");
  5685. }
  5686. if (isStatement) {
  5687. this.name = identifier();
  5688. state.funct["(scope)"].addlabel(this.name, {
  5689. type: "class",
  5690. token: state.tokens.curr });
  5691. } else if (state.tokens.next.identifier && state.tokens.next.value !== "extends") {
  5692. this.name = identifier();
  5693. this.namedExpr = true;
  5694. } else {
  5695. this.name = state.nameStack.infer();
  5696. }
  5697. classtail(this);
  5698. return this;
  5699. }
  5700. function classtail(c) {
  5701. var wasInClassBody = state.inClassBody;
  5702. if (state.tokens.next.value === "extends") {
  5703. advance("extends");
  5704. c.heritage = expression(10);
  5705. }
  5706. state.inClassBody = true;
  5707. advance("{");
  5708. c.body = classbody(c);
  5709. advance("}");
  5710. state.inClassBody = wasInClassBody;
  5711. }
  5712. function classbody(c) {
  5713. var name;
  5714. var isStatic;
  5715. var isGenerator;
  5716. var getset;
  5717. var props = Object.create(null);
  5718. var staticProps = Object.create(null);
  5719. var computed;
  5720. for (var i = 0; state.tokens.next.id !== "}"; ++i) {
  5721. name = state.tokens.next;
  5722. isStatic = false;
  5723. isGenerator = false;
  5724. getset = null;
  5725. if (name.id === ";") {
  5726. warning("W032");
  5727. advance(";");
  5728. continue;
  5729. }
  5730. if (name.id === "*") {
  5731. isGenerator = true;
  5732. advance("*");
  5733. name = state.tokens.next;
  5734. }
  5735. if (name.id === "[") {
  5736. name = computedPropertyName();
  5737. computed = true;
  5738. } else if (isPropertyName(name)) {
  5739. advance();
  5740. computed = false;
  5741. if (name.identifier && name.value === "static") {
  5742. if (checkPunctuator(state.tokens.next, "*")) {
  5743. isGenerator = true;
  5744. advance("*");
  5745. }
  5746. if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
  5747. computed = state.tokens.next.id === "[";
  5748. isStatic = true;
  5749. name = state.tokens.next;
  5750. if (state.tokens.next.id === "[") {
  5751. name = computedPropertyName();
  5752. } else advance();
  5753. }
  5754. }
  5755. if (name.identifier && (name.value === "get" || name.value === "set")) {
  5756. if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
  5757. computed = state.tokens.next.id === "[";
  5758. getset = name;
  5759. name = state.tokens.next;
  5760. if (state.tokens.next.id === "[") {
  5761. name = computedPropertyName();
  5762. } else advance();
  5763. }
  5764. }
  5765. } else {
  5766. warning("W052", state.tokens.next, state.tokens.next.value || state.tokens.next.type);
  5767. advance();
  5768. continue;
  5769. }
  5770. if (!checkPunctuator(state.tokens.next, "(")) {
  5771. error("E054", state.tokens.next, state.tokens.next.value);
  5772. while (state.tokens.next.id !== "}" &&
  5773. !checkPunctuator(state.tokens.next, "(")) {
  5774. advance();
  5775. }
  5776. if (state.tokens.next.value !== "(") {
  5777. doFunction({ statement: c });
  5778. }
  5779. }
  5780. if (!computed) {
  5781. if (getset) {
  5782. saveAccessor(
  5783. getset.value, isStatic ? staticProps : props, name.value, name, true, isStatic);
  5784. } else {
  5785. if (name.value === "constructor") {
  5786. state.nameStack.set(c);
  5787. } else {
  5788. state.nameStack.set(name);
  5789. }
  5790. saveProperty(isStatic ? staticProps : props, name.value, name, true, isStatic);
  5791. }
  5792. }
  5793. if (getset && name.value === "constructor") {
  5794. var propDesc = getset.value === "get" ? "class getter method" : "class setter method";
  5795. error("E049", name, propDesc, "constructor");
  5796. } else if (name.value === "prototype") {
  5797. error("E049", name, "class method", "prototype");
  5798. }
  5799. propertyName(name);
  5800. doFunction({
  5801. statement: c,
  5802. type: isGenerator ? "generator" : null,
  5803. classExprBinding: c.namedExpr ? c.name : null
  5804. });
  5805. }
  5806. checkProperties(props);
  5807. }
  5808. blockstmt("function", function(context) {
  5809. var inexport = context && context.inexport;
  5810. var generator = false;
  5811. if (state.tokens.next.value === "*") {
  5812. advance("*");
  5813. if (state.inES6({ strict: true })) {
  5814. generator = true;
  5815. } else {
  5816. warning("W119", state.tokens.curr, "function*", "6");
  5817. }
  5818. }
  5819. if (inblock) {
  5820. warning("W082", state.tokens.curr);
  5821. }
  5822. var i = optionalidentifier();
  5823. state.funct["(scope)"].addlabel(i, {
  5824. type: "function",
  5825. token: state.tokens.curr });
  5826. if (i === undefined) {
  5827. warning("W025");
  5828. } else if (inexport) {
  5829. state.funct["(scope)"].setExported(i, state.tokens.prev);
  5830. }
  5831. doFunction({
  5832. name: i,
  5833. statement: this,
  5834. type: generator ? "generator" : null,
  5835. ignoreLoopFunc: inblock // a declaration may already have warned
  5836. });
  5837. if (state.tokens.next.id === "(" && state.tokens.next.line === state.tokens.curr.line) {
  5838. error("E039");
  5839. }
  5840. return this;
  5841. });
  5842. prefix("function", function() {
  5843. var generator = false;
  5844. if (state.tokens.next.value === "*") {
  5845. if (!state.inES6()) {
  5846. warning("W119", state.tokens.curr, "function*", "6");
  5847. }
  5848. advance("*");
  5849. generator = true;
  5850. }
  5851. var i = optionalidentifier();
  5852. doFunction({ name: i, type: generator ? "generator" : null });
  5853. return this;
  5854. });
  5855. blockstmt("if", function() {
  5856. var t = state.tokens.next;
  5857. increaseComplexityCount();
  5858. state.condition = true;
  5859. advance("(");
  5860. var expr = expression(0);
  5861. checkCondAssignment(expr);
  5862. var forinifcheck = null;
  5863. if (state.option.forin && state.forinifcheckneeded) {
  5864. state.forinifcheckneeded = false; // We only need to analyze the first if inside the loop
  5865. forinifcheck = state.forinifchecks[state.forinifchecks.length - 1];
  5866. if (expr.type === "(punctuator)" && expr.value === "!") {
  5867. forinifcheck.type = "(negative)";
  5868. } else {
  5869. forinifcheck.type = "(positive)";
  5870. }
  5871. }
  5872. advance(")", t);
  5873. state.condition = false;
  5874. var s = block(true, true);
  5875. if (forinifcheck && forinifcheck.type === "(negative)") {
  5876. if (s && s[0] && s[0].type === "(identifier)" && s[0].value === "continue") {
  5877. forinifcheck.type = "(negative-with-continue)";
  5878. }
  5879. }
  5880. if (state.tokens.next.id === "else") {
  5881. advance("else");
  5882. if (state.tokens.next.id === "if" || state.tokens.next.id === "switch") {
  5883. statement();
  5884. } else {
  5885. block(true, true);
  5886. }
  5887. }
  5888. return this;
  5889. });
  5890. blockstmt("try", function() {
  5891. var b;
  5892. function doCatch() {
  5893. advance("catch");
  5894. advance("(");
  5895. state.funct["(scope)"].stack("catchparams");
  5896. if (checkPunctuators(state.tokens.next, ["[", "{"])) {
  5897. var tokens = destructuringPattern();
  5898. _.each(tokens, function(token) {
  5899. if (token.id) {
  5900. state.funct["(scope)"].addParam(token.id, token, "exception");
  5901. }
  5902. });
  5903. } else if (state.tokens.next.type !== "(identifier)") {
  5904. warning("E030", state.tokens.next, state.tokens.next.value);
  5905. } else {
  5906. state.funct["(scope)"].addParam(identifier(), state.tokens.curr, "exception");
  5907. }
  5908. if (state.tokens.next.value === "if") {
  5909. if (!state.inMoz()) {
  5910. warning("W118", state.tokens.curr, "catch filter");
  5911. }
  5912. advance("if");
  5913. expression(0);
  5914. }
  5915. advance(")");
  5916. block(false);
  5917. state.funct["(scope)"].unstack();
  5918. }
  5919. block(true);
  5920. while (state.tokens.next.id === "catch") {
  5921. increaseComplexityCount();
  5922. if (b && (!state.inMoz())) {
  5923. warning("W118", state.tokens.next, "multiple catch blocks");
  5924. }
  5925. doCatch();
  5926. b = true;
  5927. }
  5928. if (state.tokens.next.id === "finally") {
  5929. advance("finally");
  5930. block(true);
  5931. return;
  5932. }
  5933. if (!b) {
  5934. error("E021", state.tokens.next, "catch", state.tokens.next.value);
  5935. }
  5936. return this;
  5937. });
  5938. blockstmt("while", function() {
  5939. var t = state.tokens.next;
  5940. state.funct["(breakage)"] += 1;
  5941. state.funct["(loopage)"] += 1;
  5942. increaseComplexityCount();
  5943. advance("(");
  5944. checkCondAssignment(expression(0));
  5945. advance(")", t);
  5946. block(true, true);
  5947. state.funct["(breakage)"] -= 1;
  5948. state.funct["(loopage)"] -= 1;
  5949. return this;
  5950. }).labelled = true;
  5951. blockstmt("with", function() {
  5952. var t = state.tokens.next;
  5953. if (state.isStrict()) {
  5954. error("E010", state.tokens.curr);
  5955. } else if (!state.option.withstmt) {
  5956. warning("W085", state.tokens.curr);
  5957. }
  5958. advance("(");
  5959. expression(0);
  5960. advance(")", t);
  5961. block(true, true);
  5962. return this;
  5963. });
  5964. blockstmt("switch", function() {
  5965. var t = state.tokens.next;
  5966. var g = false;
  5967. var noindent = false;
  5968. state.funct["(breakage)"] += 1;
  5969. advance("(");
  5970. checkCondAssignment(expression(0));
  5971. advance(")", t);
  5972. t = state.tokens.next;
  5973. advance("{");
  5974. if (state.tokens.next.from === indent)
  5975. noindent = true;
  5976. if (!noindent)
  5977. indent += state.option.indent;
  5978. this.cases = [];
  5979. for (;;) {
  5980. switch (state.tokens.next.id) {
  5981. case "case":
  5982. switch (state.funct["(verb)"]) {
  5983. case "yield":
  5984. case "break":
  5985. case "case":
  5986. case "continue":
  5987. case "return":
  5988. case "switch":
  5989. case "throw":
  5990. break;
  5991. default:
  5992. if (!state.tokens.curr.caseFallsThrough) {
  5993. warning("W086", state.tokens.curr, "case");
  5994. }
  5995. }
  5996. advance("case");
  5997. this.cases.push(expression(0));
  5998. increaseComplexityCount();
  5999. g = true;
  6000. advance(":");
  6001. state.funct["(verb)"] = "case";
  6002. break;
  6003. case "default":
  6004. switch (state.funct["(verb)"]) {
  6005. case "yield":
  6006. case "break":
  6007. case "continue":
  6008. case "return":
  6009. case "throw":
  6010. break;
  6011. default:
  6012. if (this.cases.length) {
  6013. if (!state.tokens.curr.caseFallsThrough) {
  6014. warning("W086", state.tokens.curr, "default");
  6015. }
  6016. }
  6017. }
  6018. advance("default");
  6019. g = true;
  6020. advance(":");
  6021. break;
  6022. case "}":
  6023. if (!noindent)
  6024. indent -= state.option.indent;
  6025. advance("}", t);
  6026. state.funct["(breakage)"] -= 1;
  6027. state.funct["(verb)"] = undefined;
  6028. return;
  6029. case "(end)":
  6030. error("E023", state.tokens.next, "}");
  6031. return;
  6032. default:
  6033. indent += state.option.indent;
  6034. if (g) {
  6035. switch (state.tokens.curr.id) {
  6036. case ",":
  6037. error("E040");
  6038. return;
  6039. case ":":
  6040. g = false;
  6041. statements();
  6042. break;
  6043. default:
  6044. error("E025", state.tokens.curr);
  6045. return;
  6046. }
  6047. } else {
  6048. if (state.tokens.curr.id === ":") {
  6049. advance(":");
  6050. error("E024", state.tokens.curr, ":");
  6051. statements();
  6052. } else {
  6053. error("E021", state.tokens.next, "case", state.tokens.next.value);
  6054. return;
  6055. }
  6056. }
  6057. indent -= state.option.indent;
  6058. }
  6059. }
  6060. return this;
  6061. }).labelled = true;
  6062. stmt("debugger", function() {
  6063. if (!state.option.debug) {
  6064. warning("W087", this);
  6065. }
  6066. return this;
  6067. }).exps = true;
  6068. (function() {
  6069. var x = stmt("do", function() {
  6070. state.funct["(breakage)"] += 1;
  6071. state.funct["(loopage)"] += 1;
  6072. increaseComplexityCount();
  6073. this.first = block(true, true);
  6074. advance("while");
  6075. var t = state.tokens.next;
  6076. advance("(");
  6077. checkCondAssignment(expression(0));
  6078. advance(")", t);
  6079. state.funct["(breakage)"] -= 1;
  6080. state.funct["(loopage)"] -= 1;
  6081. return this;
  6082. });
  6083. x.labelled = true;
  6084. x.exps = true;
  6085. }());
  6086. blockstmt("for", function() {
  6087. var s, t = state.tokens.next;
  6088. var letscope = false;
  6089. var foreachtok = null;
  6090. if (t.value === "each") {
  6091. foreachtok = t;
  6092. advance("each");
  6093. if (!state.inMoz()) {
  6094. warning("W118", state.tokens.curr, "for each");
  6095. }
  6096. }
  6097. increaseComplexityCount();
  6098. advance("(");
  6099. var nextop; // contains the token of the "in" or "of" operator
  6100. var i = 0;
  6101. var inof = ["in", "of"];
  6102. var level = 0; // BindingPattern "level" --- level 0 === no BindingPattern
  6103. var comma; // First comma punctuator at level 0
  6104. var initializer; // First initializer at level 0
  6105. if (checkPunctuators(state.tokens.next, ["{", "["])) ++level;
  6106. do {
  6107. nextop = peek(i);
  6108. ++i;
  6109. if (checkPunctuators(nextop, ["{", "["])) ++level;
  6110. else if (checkPunctuators(nextop, ["}", "]"])) --level;
  6111. if (level < 0) break;
  6112. if (level === 0) {
  6113. if (!comma && checkPunctuator(nextop, ",")) comma = nextop;
  6114. else if (!initializer && checkPunctuator(nextop, "=")) initializer = nextop;
  6115. }
  6116. } while (level > 0 || !_.contains(inof, nextop.value) && nextop.value !== ";" &&
  6117. nextop.type !== "(end)"); // Is this a JSCS bug? This looks really weird.
  6118. if (_.contains(inof, nextop.value)) {
  6119. if (!state.inES6() && nextop.value === "of") {
  6120. warning("W104", nextop, "for of", "6");
  6121. }
  6122. var ok = !(initializer || comma);
  6123. if (initializer) {
  6124. error("W133", comma, nextop.value, "initializer is forbidden");
  6125. }
  6126. if (comma) {
  6127. error("W133", comma, nextop.value, "more than one ForBinding");
  6128. }
  6129. if (state.tokens.next.id === "var") {
  6130. advance("var");
  6131. state.tokens.curr.fud({ prefix: true });
  6132. } else if (state.tokens.next.id === "let" || state.tokens.next.id === "const") {
  6133. advance(state.tokens.next.id);
  6134. letscope = true;
  6135. state.funct["(scope)"].stack();
  6136. state.tokens.curr.fud({ prefix: true });
  6137. } else {
  6138. Object.create(varstatement).fud({ prefix: true, implied: "for", ignore: !ok });
  6139. }
  6140. advance(nextop.value);
  6141. expression(20);
  6142. advance(")", t);
  6143. if (nextop.value === "in" && state.option.forin) {
  6144. state.forinifcheckneeded = true;
  6145. if (state.forinifchecks === undefined) {
  6146. state.forinifchecks = [];
  6147. }
  6148. state.forinifchecks.push({
  6149. type: "(none)"
  6150. });
  6151. }
  6152. state.funct["(breakage)"] += 1;
  6153. state.funct["(loopage)"] += 1;
  6154. s = block(true, true);
  6155. if (nextop.value === "in" && state.option.forin) {
  6156. if (state.forinifchecks && state.forinifchecks.length > 0) {
  6157. var check = state.forinifchecks.pop();
  6158. if (// No if statement or not the first statement in loop body
  6159. s && s.length > 0 && (typeof s[0] !== "object" || s[0].value !== "if") ||
  6160. check.type === "(positive)" && s.length > 1 ||
  6161. check.type === "(negative)") {
  6162. warning("W089", this);
  6163. }
  6164. }
  6165. state.forinifcheckneeded = false;
  6166. }
  6167. state.funct["(breakage)"] -= 1;
  6168. state.funct["(loopage)"] -= 1;
  6169. } else {
  6170. if (foreachtok) {
  6171. error("E045", foreachtok);
  6172. }
  6173. if (state.tokens.next.id !== ";") {
  6174. if (state.tokens.next.id === "var") {
  6175. advance("var");
  6176. state.tokens.curr.fud();
  6177. } else if (state.tokens.next.id === "let") {
  6178. advance("let");
  6179. letscope = true;
  6180. state.funct["(scope)"].stack();
  6181. state.tokens.curr.fud();
  6182. } else {
  6183. for (;;) {
  6184. expression(0, "for");
  6185. if (state.tokens.next.id !== ",") {
  6186. break;
  6187. }
  6188. comma();
  6189. }
  6190. }
  6191. }
  6192. nolinebreak(state.tokens.curr);
  6193. advance(";");
  6194. state.funct["(loopage)"] += 1;
  6195. if (state.tokens.next.id !== ";") {
  6196. checkCondAssignment(expression(0));
  6197. }
  6198. nolinebreak(state.tokens.curr);
  6199. advance(";");
  6200. if (state.tokens.next.id === ";") {
  6201. error("E021", state.tokens.next, ")", ";");
  6202. }
  6203. if (state.tokens.next.id !== ")") {
  6204. for (;;) {
  6205. expression(0, "for");
  6206. if (state.tokens.next.id !== ",") {
  6207. break;
  6208. }
  6209. comma();
  6210. }
  6211. }
  6212. advance(")", t);
  6213. state.funct["(breakage)"] += 1;
  6214. block(true, true);
  6215. state.funct["(breakage)"] -= 1;
  6216. state.funct["(loopage)"] -= 1;
  6217. }
  6218. if (letscope) {
  6219. state.funct["(scope)"].unstack();
  6220. }
  6221. return this;
  6222. }).labelled = true;
  6223. stmt("break", function() {
  6224. var v = state.tokens.next.value;
  6225. if (!state.option.asi)
  6226. nolinebreak(this);
  6227. if (state.tokens.next.id !== ";" && !state.tokens.next.reach &&
  6228. state.tokens.curr.line === startLine(state.tokens.next)) {
  6229. if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
  6230. warning("W090", state.tokens.next, v);
  6231. }
  6232. this.first = state.tokens.next;
  6233. advance();
  6234. } else {
  6235. if (state.funct["(breakage)"] === 0)
  6236. warning("W052", state.tokens.next, this.value);
  6237. }
  6238. reachable(this);
  6239. return this;
  6240. }).exps = true;
  6241. stmt("continue", function() {
  6242. var v = state.tokens.next.value;
  6243. if (state.funct["(breakage)"] === 0)
  6244. warning("W052", state.tokens.next, this.value);
  6245. if (!state.funct["(loopage)"])
  6246. warning("W052", state.tokens.next, this.value);
  6247. if (!state.option.asi)
  6248. nolinebreak(this);
  6249. if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
  6250. if (state.tokens.curr.line === startLine(state.tokens.next)) {
  6251. if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
  6252. warning("W090", state.tokens.next, v);
  6253. }
  6254. this.first = state.tokens.next;
  6255. advance();
  6256. }
  6257. }
  6258. reachable(this);
  6259. return this;
  6260. }).exps = true;
  6261. stmt("return", function() {
  6262. if (this.line === startLine(state.tokens.next)) {
  6263. if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
  6264. this.first = expression(0);
  6265. if (this.first &&
  6266. this.first.type === "(punctuator)" && this.first.value === "=" &&
  6267. !this.first.paren && !state.option.boss) {
  6268. warningAt("W093", this.first.line, this.first.character);
  6269. }
  6270. }
  6271. } else {
  6272. if (state.tokens.next.type === "(punctuator)" &&
  6273. ["[", "{", "+", "-"].indexOf(state.tokens.next.value) > -1) {
  6274. nolinebreak(this); // always warn (Line breaking error)
  6275. }
  6276. }
  6277. reachable(this);
  6278. return this;
  6279. }).exps = true;
  6280. (function(x) {
  6281. x.exps = true;
  6282. x.lbp = 25;
  6283. }(prefix("yield", function() {
  6284. var prev = state.tokens.prev;
  6285. if (state.inES6(true) && !state.funct["(generator)"]) {
  6286. if (!("(catch)" === state.funct["(name)"] && state.funct["(context)"]["(generator)"])) {
  6287. error("E046", state.tokens.curr, "yield");
  6288. }
  6289. } else if (!state.inES6()) {
  6290. warning("W104", state.tokens.curr, "yield", "6");
  6291. }
  6292. state.funct["(generator)"] = "yielded";
  6293. var delegatingYield = false;
  6294. if (state.tokens.next.value === "*") {
  6295. delegatingYield = true;
  6296. advance("*");
  6297. }
  6298. if (this.line === startLine(state.tokens.next) || !state.inMoz()) {
  6299. if (delegatingYield ||
  6300. (state.tokens.next.id !== ";" && !state.option.asi &&
  6301. !state.tokens.next.reach && state.tokens.next.nud)) {
  6302. nobreaknonadjacent(state.tokens.curr, state.tokens.next);
  6303. this.first = expression(10);
  6304. if (this.first.type === "(punctuator)" && this.first.value === "=" &&
  6305. !this.first.paren && !state.option.boss) {
  6306. warningAt("W093", this.first.line, this.first.character);
  6307. }
  6308. }
  6309. if (state.inMoz() && state.tokens.next.id !== ")" &&
  6310. (prev.lbp > 30 || (!prev.assign && !isEndOfExpr()) || prev.id === "yield")) {
  6311. error("E050", this);
  6312. }
  6313. } else if (!state.option.asi) {
  6314. nolinebreak(this); // always warn (Line breaking error)
  6315. }
  6316. return this;
  6317. })));
  6318. stmt("throw", function() {
  6319. nolinebreak(this);
  6320. this.first = expression(20);
  6321. reachable(this);
  6322. return this;
  6323. }).exps = true;
  6324. stmt("import", function() {
  6325. if (!state.inES6()) {
  6326. warning("W119", state.tokens.curr, "import", "6");
  6327. }
  6328. if (state.tokens.next.type === "(string)") {
  6329. advance("(string)");
  6330. return this;
  6331. }
  6332. if (state.tokens.next.identifier) {
  6333. this.name = identifier();
  6334. state.funct["(scope)"].addlabel(this.name, {
  6335. type: "const",
  6336. token: state.tokens.curr });
  6337. if (state.tokens.next.value === ",") {
  6338. advance(",");
  6339. } else {
  6340. advance("from");
  6341. advance("(string)");
  6342. return this;
  6343. }
  6344. }
  6345. if (state.tokens.next.id === "*") {
  6346. advance("*");
  6347. advance("as");
  6348. if (state.tokens.next.identifier) {
  6349. this.name = identifier();
  6350. state.funct["(scope)"].addlabel(this.name, {
  6351. type: "const",
  6352. token: state.tokens.curr });
  6353. }
  6354. } else {
  6355. advance("{");
  6356. for (;;) {
  6357. if (state.tokens.next.value === "}") {
  6358. advance("}");
  6359. break;
  6360. }
  6361. var importName;
  6362. if (state.tokens.next.type === "default") {
  6363. importName = "default";
  6364. advance("default");
  6365. } else {
  6366. importName = identifier();
  6367. }
  6368. if (state.tokens.next.value === "as") {
  6369. advance("as");
  6370. importName = identifier();
  6371. }
  6372. state.funct["(scope)"].addlabel(importName, {
  6373. type: "const",
  6374. token: state.tokens.curr });
  6375. if (state.tokens.next.value === ",") {
  6376. advance(",");
  6377. } else if (state.tokens.next.value === "}") {
  6378. advance("}");
  6379. break;
  6380. } else {
  6381. error("E024", state.tokens.next, state.tokens.next.value);
  6382. break;
  6383. }
  6384. }
  6385. }
  6386. advance("from");
  6387. advance("(string)");
  6388. return this;
  6389. }).exps = true;
  6390. stmt("export", function() {
  6391. var ok = true;
  6392. var token;
  6393. var identifier;
  6394. if (!state.inES6()) {
  6395. warning("W119", state.tokens.curr, "export", "6");
  6396. ok = false;
  6397. }
  6398. if (!state.funct["(scope)"].block.isGlobal()) {
  6399. error("E053", state.tokens.curr);
  6400. ok = false;
  6401. }
  6402. if (state.tokens.next.value === "*") {
  6403. advance("*");
  6404. advance("from");
  6405. advance("(string)");
  6406. return this;
  6407. }
  6408. if (state.tokens.next.type === "default") {
  6409. state.nameStack.set(state.tokens.next);
  6410. advance("default");
  6411. var exportType = state.tokens.next.id;
  6412. if (exportType === "function" || exportType === "class") {
  6413. this.block = true;
  6414. }
  6415. token = peek();
  6416. expression(10);
  6417. identifier = token.value;
  6418. if (this.block) {
  6419. state.funct["(scope)"].addlabel(identifier, {
  6420. type: exportType,
  6421. token: token });
  6422. state.funct["(scope)"].setExported(identifier, token);
  6423. }
  6424. return this;
  6425. }
  6426. if (state.tokens.next.value === "{") {
  6427. advance("{");
  6428. var exportedTokens = [];
  6429. for (;;) {
  6430. if (!state.tokens.next.identifier) {
  6431. error("E030", state.tokens.next, state.tokens.next.value);
  6432. }
  6433. advance();
  6434. exportedTokens.push(state.tokens.curr);
  6435. if (state.tokens.next.value === "as") {
  6436. advance("as");
  6437. if (!state.tokens.next.identifier) {
  6438. error("E030", state.tokens.next, state.tokens.next.value);
  6439. }
  6440. advance();
  6441. }
  6442. if (state.tokens.next.value === ",") {
  6443. advance(",");
  6444. } else if (state.tokens.next.value === "}") {
  6445. advance("}");
  6446. break;
  6447. } else {
  6448. error("E024", state.tokens.next, state.tokens.next.value);
  6449. break;
  6450. }
  6451. }
  6452. if (state.tokens.next.value === "from") {
  6453. advance("from");
  6454. advance("(string)");
  6455. } else if (ok) {
  6456. exportedTokens.forEach(function(token) {
  6457. state.funct["(scope)"].setExported(token.value, token);
  6458. });
  6459. }
  6460. return this;
  6461. }
  6462. if (state.tokens.next.id === "var") {
  6463. advance("var");
  6464. state.tokens.curr.fud({ inexport:true });
  6465. } else if (state.tokens.next.id === "let") {
  6466. advance("let");
  6467. state.tokens.curr.fud({ inexport:true });
  6468. } else if (state.tokens.next.id === "const") {
  6469. advance("const");
  6470. state.tokens.curr.fud({ inexport:true });
  6471. } else if (state.tokens.next.id === "function") {
  6472. this.block = true;
  6473. advance("function");
  6474. state.syntax["function"].fud({ inexport:true });
  6475. } else if (state.tokens.next.id === "class") {
  6476. this.block = true;
  6477. advance("class");
  6478. var classNameToken = state.tokens.next;
  6479. state.syntax["class"].fud();
  6480. state.funct["(scope)"].setExported(classNameToken.value, classNameToken);
  6481. } else {
  6482. error("E024", state.tokens.next, state.tokens.next.value);
  6483. }
  6484. return this;
  6485. }).exps = true;
  6486. FutureReservedWord("abstract");
  6487. FutureReservedWord("boolean");
  6488. FutureReservedWord("byte");
  6489. FutureReservedWord("char");
  6490. FutureReservedWord("class", { es5: true, nud: classdef });
  6491. FutureReservedWord("double");
  6492. FutureReservedWord("enum", { es5: true });
  6493. FutureReservedWord("export", { es5: true });
  6494. FutureReservedWord("extends", { es5: true });
  6495. FutureReservedWord("final");
  6496. FutureReservedWord("float");
  6497. FutureReservedWord("goto");
  6498. FutureReservedWord("implements", { es5: true, strictOnly: true });
  6499. FutureReservedWord("import", { es5: true });
  6500. FutureReservedWord("int");
  6501. FutureReservedWord("interface", { es5: true, strictOnly: true });
  6502. FutureReservedWord("long");
  6503. FutureReservedWord("native");
  6504. FutureReservedWord("package", { es5: true, strictOnly: true });
  6505. FutureReservedWord("private", { es5: true, strictOnly: true });
  6506. FutureReservedWord("protected", { es5: true, strictOnly: true });
  6507. FutureReservedWord("public", { es5: true, strictOnly: true });
  6508. FutureReservedWord("short");
  6509. FutureReservedWord("static", { es5: true, strictOnly: true });
  6510. FutureReservedWord("super", { es5: true });
  6511. FutureReservedWord("synchronized");
  6512. FutureReservedWord("transient");
  6513. FutureReservedWord("volatile");
  6514. var lookupBlockType = function() {
  6515. var pn, pn1, prev;
  6516. var i = -1;
  6517. var bracketStack = 0;
  6518. var ret = {};
  6519. if (checkPunctuators(state.tokens.curr, ["[", "{"])) {
  6520. bracketStack += 1;
  6521. }
  6522. do {
  6523. prev = i === -1 ? state.tokens.curr : pn;
  6524. pn = i === -1 ? state.tokens.next : peek(i);
  6525. pn1 = peek(i + 1);
  6526. i = i + 1;
  6527. if (checkPunctuators(pn, ["[", "{"])) {
  6528. bracketStack += 1;
  6529. } else if (checkPunctuators(pn, ["]", "}"])) {
  6530. bracketStack -= 1;
  6531. }
  6532. if (bracketStack === 1 && pn.identifier && pn.value === "for" &&
  6533. !checkPunctuator(prev, ".")) {
  6534. ret.isCompArray = true;
  6535. ret.notJson = true;
  6536. break;
  6537. }
  6538. if (bracketStack === 0 && checkPunctuators(pn, ["}", "]"])) {
  6539. if (pn1.value === "=") {
  6540. ret.isDestAssign = true;
  6541. ret.notJson = true;
  6542. break;
  6543. } else if (pn1.value === ".") {
  6544. ret.notJson = true;
  6545. break;
  6546. }
  6547. }
  6548. if (checkPunctuator(pn, ";")) {
  6549. ret.isBlock = true;
  6550. ret.notJson = true;
  6551. }
  6552. } while (bracketStack > 0 && pn.id !== "(end)");
  6553. return ret;
  6554. };
  6555. function saveProperty(props, name, tkn, isClass, isStatic) {
  6556. var msg = ["key", "class method", "static class method"];
  6557. msg = msg[(isClass || false) + (isStatic || false)];
  6558. if (tkn.identifier) {
  6559. name = tkn.value;
  6560. }
  6561. if (props[name] && name !== "__proto__") {
  6562. warning("W075", state.tokens.next, msg, name);
  6563. } else {
  6564. props[name] = Object.create(null);
  6565. }
  6566. props[name].basic = true;
  6567. props[name].basictkn = tkn;
  6568. }
  6569. function saveAccessor(accessorType, props, name, tkn, isClass, isStatic) {
  6570. var flagName = accessorType === "get" ? "getterToken" : "setterToken";
  6571. var msg = "";
  6572. if (isClass) {
  6573. if (isStatic) {
  6574. msg += "static ";
  6575. }
  6576. msg += accessorType + "ter method";
  6577. } else {
  6578. msg = "key";
  6579. }
  6580. state.tokens.curr.accessorType = accessorType;
  6581. state.nameStack.set(tkn);
  6582. if (props[name]) {
  6583. if ((props[name].basic || props[name][flagName]) && name !== "__proto__") {
  6584. warning("W075", state.tokens.next, msg, name);
  6585. }
  6586. } else {
  6587. props[name] = Object.create(null);
  6588. }
  6589. props[name][flagName] = tkn;
  6590. }
  6591. function computedPropertyName() {
  6592. advance("[");
  6593. if (!state.inES6()) {
  6594. warning("W119", state.tokens.curr, "computed property names", "6");
  6595. }
  6596. var value = expression(10);
  6597. advance("]");
  6598. return value;
  6599. }
  6600. function checkPunctuators(token, values) {
  6601. if (token.type === "(punctuator)") {
  6602. return _.contains(values, token.value);
  6603. }
  6604. return false;
  6605. }
  6606. function checkPunctuator(token, value) {
  6607. return token.type === "(punctuator)" && token.value === value;
  6608. }
  6609. function destructuringAssignOrJsonValue() {
  6610. var block = lookupBlockType();
  6611. if (block.notJson) {
  6612. if (!state.inES6() && block.isDestAssign) {
  6613. warning("W104", state.tokens.curr, "destructuring assignment", "6");
  6614. }
  6615. statements();
  6616. } else {
  6617. state.option.laxbreak = true;
  6618. state.jsonMode = true;
  6619. jsonValue();
  6620. }
  6621. }
  6622. var arrayComprehension = function() {
  6623. var CompArray = function() {
  6624. this.mode = "use";
  6625. this.variables = [];
  6626. };
  6627. var _carrays = [];
  6628. var _current;
  6629. function declare(v) {
  6630. var l = _current.variables.filter(function(elt) {
  6631. if (elt.value === v) {
  6632. elt.undef = false;
  6633. return v;
  6634. }
  6635. }).length;
  6636. return l !== 0;
  6637. }
  6638. function use(v) {
  6639. var l = _current.variables.filter(function(elt) {
  6640. if (elt.value === v && !elt.undef) {
  6641. if (elt.unused === true) {
  6642. elt.unused = false;
  6643. }
  6644. return v;
  6645. }
  6646. }).length;
  6647. return (l === 0);
  6648. }
  6649. return { stack: function() {
  6650. _current = new CompArray();
  6651. _carrays.push(_current);
  6652. },
  6653. unstack: function() {
  6654. _current.variables.filter(function(v) {
  6655. if (v.unused)
  6656. warning("W098", v.token, v.raw_text || v.value);
  6657. if (v.undef)
  6658. state.funct["(scope)"].block.use(v.value, v.token);
  6659. });
  6660. _carrays.splice(-1, 1);
  6661. _current = _carrays[_carrays.length - 1];
  6662. },
  6663. setState: function(s) {
  6664. if (_.contains(["use", "define", "generate", "filter"], s))
  6665. _current.mode = s;
  6666. },
  6667. check: function(v) {
  6668. if (!_current) {
  6669. return;
  6670. }
  6671. if (_current && _current.mode === "use") {
  6672. if (use(v)) {
  6673. _current.variables.push({
  6674. funct: state.funct,
  6675. token: state.tokens.curr,
  6676. value: v,
  6677. undef: true,
  6678. unused: false
  6679. });
  6680. }
  6681. return true;
  6682. } else if (_current && _current.mode === "define") {
  6683. if (!declare(v)) {
  6684. _current.variables.push({
  6685. funct: state.funct,
  6686. token: state.tokens.curr,
  6687. value: v,
  6688. undef: false,
  6689. unused: true
  6690. });
  6691. }
  6692. return true;
  6693. } else if (_current && _current.mode === "generate") {
  6694. state.funct["(scope)"].block.use(v, state.tokens.curr);
  6695. return true;
  6696. } else if (_current && _current.mode === "filter") {
  6697. if (use(v)) {
  6698. state.funct["(scope)"].block.use(v, state.tokens.curr);
  6699. }
  6700. return true;
  6701. }
  6702. return false;
  6703. }
  6704. };
  6705. };
  6706. function jsonValue() {
  6707. function jsonObject() {
  6708. var o = {}, t = state.tokens.next;
  6709. advance("{");
  6710. if (state.tokens.next.id !== "}") {
  6711. for (;;) {
  6712. if (state.tokens.next.id === "(end)") {
  6713. error("E026", state.tokens.next, t.line);
  6714. } else if (state.tokens.next.id === "}") {
  6715. warning("W094", state.tokens.curr);
  6716. break;
  6717. } else if (state.tokens.next.id === ",") {
  6718. error("E028", state.tokens.next);
  6719. } else if (state.tokens.next.id !== "(string)") {
  6720. warning("W095", state.tokens.next, state.tokens.next.value);
  6721. }
  6722. if (o[state.tokens.next.value] === true) {
  6723. warning("W075", state.tokens.next, "key", state.tokens.next.value);
  6724. } else if ((state.tokens.next.value === "__proto__" &&
  6725. !state.option.proto) || (state.tokens.next.value === "__iterator__" &&
  6726. !state.option.iterator)) {
  6727. warning("W096", state.tokens.next, state.tokens.next.value);
  6728. } else {
  6729. o[state.tokens.next.value] = true;
  6730. }
  6731. advance();
  6732. advance(":");
  6733. jsonValue();
  6734. if (state.tokens.next.id !== ",") {
  6735. break;
  6736. }
  6737. advance(",");
  6738. }
  6739. }
  6740. advance("}");
  6741. }
  6742. function jsonArray() {
  6743. var t = state.tokens.next;
  6744. advance("[");
  6745. if (state.tokens.next.id !== "]") {
  6746. for (;;) {
  6747. if (state.tokens.next.id === "(end)") {
  6748. error("E027", state.tokens.next, t.line);
  6749. } else if (state.tokens.next.id === "]") {
  6750. warning("W094", state.tokens.curr);
  6751. break;
  6752. } else if (state.tokens.next.id === ",") {
  6753. error("E028", state.tokens.next);
  6754. }
  6755. jsonValue();
  6756. if (state.tokens.next.id !== ",") {
  6757. break;
  6758. }
  6759. advance(",");
  6760. }
  6761. }
  6762. advance("]");
  6763. }
  6764. switch (state.tokens.next.id) {
  6765. case "{":
  6766. jsonObject();
  6767. break;
  6768. case "[":
  6769. jsonArray();
  6770. break;
  6771. case "true":
  6772. case "false":
  6773. case "null":
  6774. case "(number)":
  6775. case "(string)":
  6776. advance();
  6777. break;
  6778. case "-":
  6779. advance("-");
  6780. advance("(number)");
  6781. break;
  6782. default:
  6783. error("E003", state.tokens.next);
  6784. }
  6785. }
  6786. var escapeRegex = function(str) {
  6787. return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
  6788. };
  6789. var itself = function(s, o, g) {
  6790. var i, k, x, reIgnoreStr, reIgnore;
  6791. var optionKeys;
  6792. var newOptionObj = {};
  6793. var newIgnoredObj = {};
  6794. o = _.clone(o);
  6795. state.reset();
  6796. if (o && o.scope) {
  6797. JSHINT.scope = o.scope;
  6798. } else {
  6799. JSHINT.errors = [];
  6800. JSHINT.undefs = [];
  6801. JSHINT.internals = [];
  6802. JSHINT.blacklist = {};
  6803. JSHINT.scope = "(main)";
  6804. }
  6805. predefined = Object.create(null);
  6806. combine(predefined, vars.ecmaIdentifiers[3]);
  6807. combine(predefined, vars.reservedVars);
  6808. combine(predefined, g || {});
  6809. declared = Object.create(null);
  6810. var exported = Object.create(null); // Variables that live outside the current file
  6811. function each(obj, cb) {
  6812. if (!obj)
  6813. return;
  6814. if (!Array.isArray(obj) && typeof obj === "object")
  6815. obj = Object.keys(obj);
  6816. obj.forEach(cb);
  6817. }
  6818. if (o) {
  6819. each(o.predef || null, function(item) {
  6820. var slice, prop;
  6821. if (item[0] === "-") {
  6822. slice = item.slice(1);
  6823. JSHINT.blacklist[slice] = slice;
  6824. delete predefined[slice];
  6825. } else {
  6826. prop = Object.getOwnPropertyDescriptor(o.predef, item);
  6827. predefined[item] = prop ? prop.value : false;
  6828. }
  6829. });
  6830. each(o.exported || null, function(item) {
  6831. exported[item] = true;
  6832. });
  6833. delete o.predef;
  6834. delete o.exported;
  6835. optionKeys = Object.keys(o);
  6836. for (x = 0; x < optionKeys.length; x++) {
  6837. if (/^-W\d{3}$/g.test(optionKeys[x])) {
  6838. newIgnoredObj[optionKeys[x].slice(1)] = true;
  6839. } else {
  6840. var optionKey = optionKeys[x];
  6841. newOptionObj[optionKey] = o[optionKey];
  6842. if ((optionKey === "esversion" && o[optionKey] === 5) ||
  6843. (optionKey === "es5" && o[optionKey])) {
  6844. warning("I003");
  6845. }
  6846. if (optionKeys[x] === "newcap" && o[optionKey] === false)
  6847. newOptionObj["(explicitNewcap)"] = true;
  6848. }
  6849. }
  6850. }
  6851. state.option = newOptionObj;
  6852. state.ignored = newIgnoredObj;
  6853. state.option.indent = state.option.indent || 4;
  6854. state.option.maxerr = state.option.maxerr || 50;
  6855. indent = 1;
  6856. var scopeManagerInst = scopeManager(state, predefined, exported, declared);
  6857. scopeManagerInst.on("warning", function(ev) {
  6858. warning.apply(null, [ ev.code, ev.token].concat(ev.data));
  6859. });
  6860. scopeManagerInst.on("error", function(ev) {
  6861. error.apply(null, [ ev.code, ev.token ].concat(ev.data));
  6862. });
  6863. state.funct = functor("(global)", null, {
  6864. "(global)" : true,
  6865. "(scope)" : scopeManagerInst,
  6866. "(comparray)" : arrayComprehension(),
  6867. "(metrics)" : createMetrics(state.tokens.next)
  6868. });
  6869. functions = [state.funct];
  6870. urls = [];
  6871. stack = null;
  6872. member = {};
  6873. membersOnly = null;
  6874. inblock = false;
  6875. lookahead = [];
  6876. if (!isString(s) && !Array.isArray(s)) {
  6877. errorAt("E004", 0);
  6878. return false;
  6879. }
  6880. api = {
  6881. get isJSON() {
  6882. return state.jsonMode;
  6883. },
  6884. getOption: function(name) {
  6885. return state.option[name] || null;
  6886. },
  6887. getCache: function(name) {
  6888. return state.cache[name];
  6889. },
  6890. setCache: function(name, value) {
  6891. state.cache[name] = value;
  6892. },
  6893. warn: function(code, data) {
  6894. warningAt.apply(null, [ code, data.line, data.char ].concat(data.data));
  6895. },
  6896. on: function(names, listener) {
  6897. names.split(" ").forEach(function(name) {
  6898. emitter.on(name, listener);
  6899. }.bind(this));
  6900. }
  6901. };
  6902. emitter.removeAllListeners();
  6903. (extraModules || []).forEach(function(func) {
  6904. func(api);
  6905. });
  6906. state.tokens.prev = state.tokens.curr = state.tokens.next = state.syntax["(begin)"];
  6907. if (o && o.ignoreDelimiters) {
  6908. if (!Array.isArray(o.ignoreDelimiters)) {
  6909. o.ignoreDelimiters = [o.ignoreDelimiters];
  6910. }
  6911. o.ignoreDelimiters.forEach(function(delimiterPair) {
  6912. if (!delimiterPair.start || !delimiterPair.end)
  6913. return;
  6914. reIgnoreStr = escapeRegex(delimiterPair.start) +
  6915. "[\\s\\S]*?" +
  6916. escapeRegex(delimiterPair.end);
  6917. reIgnore = new RegExp(reIgnoreStr, "ig");
  6918. s = s.replace(reIgnore, function(match) {
  6919. return match.replace(/./g, " ");
  6920. });
  6921. });
  6922. }
  6923. lex = new Lexer(s);
  6924. lex.on("warning", function(ev) {
  6925. warningAt.apply(null, [ ev.code, ev.line, ev.character].concat(ev.data));
  6926. });
  6927. lex.on("error", function(ev) {
  6928. errorAt.apply(null, [ ev.code, ev.line, ev.character ].concat(ev.data));
  6929. });
  6930. lex.on("fatal", function(ev) {
  6931. quit("E041", ev.line, ev.from);
  6932. });
  6933. lex.on("Identifier", function(ev) {
  6934. emitter.emit("Identifier", ev);
  6935. });
  6936. lex.on("String", function(ev) {
  6937. emitter.emit("String", ev);
  6938. });
  6939. lex.on("Number", function(ev) {
  6940. emitter.emit("Number", ev);
  6941. });
  6942. lex.start();
  6943. for (var name in o) {
  6944. if (_.has(o, name)) {
  6945. checkOption(name, state.tokens.curr);
  6946. }
  6947. }
  6948. assume();
  6949. combine(predefined, g || {});
  6950. comma.first = true;
  6951. try {
  6952. advance();
  6953. switch (state.tokens.next.id) {
  6954. case "{":
  6955. case "[":
  6956. destructuringAssignOrJsonValue();
  6957. break;
  6958. default:
  6959. directives();
  6960. if (state.directive["use strict"]) {
  6961. if (state.option.strict !== "global") {
  6962. warning("W097", state.tokens.prev);
  6963. }
  6964. }
  6965. statements();
  6966. }
  6967. if (state.tokens.next.id !== "(end)") {
  6968. quit("E041", state.tokens.curr.line);
  6969. }
  6970. state.funct["(scope)"].unstack();
  6971. } catch (err) {
  6972. if (err && err.name === "JSHintError") {
  6973. var nt = state.tokens.next || {};
  6974. JSHINT.errors.push({
  6975. scope : "(main)",
  6976. raw : err.raw,
  6977. code : err.code,
  6978. reason : err.message,
  6979. line : err.line || nt.line,
  6980. character : err.character || nt.from
  6981. }, null);
  6982. } else {
  6983. throw err;
  6984. }
  6985. }
  6986. if (JSHINT.scope === "(main)") {
  6987. o = o || {};
  6988. for (i = 0; i < JSHINT.internals.length; i += 1) {
  6989. k = JSHINT.internals[i];
  6990. o.scope = k.elem;
  6991. itself(k.value, o, g);
  6992. }
  6993. }
  6994. return JSHINT.errors.length === 0;
  6995. };
  6996. itself.addModule = function(func) {
  6997. extraModules.push(func);
  6998. };
  6999. itself.addModule(style.register);
  7000. itself.data = function() {
  7001. var data = {
  7002. functions: [],
  7003. options: state.option
  7004. };
  7005. var fu, f, i, j, n, globals;
  7006. if (itself.errors.length) {
  7007. data.errors = itself.errors;
  7008. }
  7009. if (state.jsonMode) {
  7010. data.json = true;
  7011. }
  7012. var impliedGlobals = state.funct["(scope)"].getImpliedGlobals();
  7013. if (impliedGlobals.length > 0) {
  7014. data.implieds = impliedGlobals;
  7015. }
  7016. if (urls.length > 0) {
  7017. data.urls = urls;
  7018. }
  7019. globals = state.funct["(scope)"].getUsedOrDefinedGlobals();
  7020. if (globals.length > 0) {
  7021. data.globals = globals;
  7022. }
  7023. for (i = 1; i < functions.length; i += 1) {
  7024. f = functions[i];
  7025. fu = {};
  7026. for (j = 0; j < functionicity.length; j += 1) {
  7027. fu[functionicity[j]] = [];
  7028. }
  7029. for (j = 0; j < functionicity.length; j += 1) {
  7030. if (fu[functionicity[j]].length === 0) {
  7031. delete fu[functionicity[j]];
  7032. }
  7033. }
  7034. fu.name = f["(name)"];
  7035. fu.param = f["(params)"];
  7036. fu.line = f["(line)"];
  7037. fu.character = f["(character)"];
  7038. fu.last = f["(last)"];
  7039. fu.lastcharacter = f["(lastcharacter)"];
  7040. fu.metrics = {
  7041. complexity: f["(metrics)"].ComplexityCount,
  7042. parameters: f["(metrics)"].arity,
  7043. statements: f["(metrics)"].statementCount
  7044. };
  7045. data.functions.push(fu);
  7046. }
  7047. var unuseds = state.funct["(scope)"].getUnuseds();
  7048. if (unuseds.length > 0) {
  7049. data.unused = unuseds;
  7050. }
  7051. for (n in member) {
  7052. if (typeof member[n] === "number") {
  7053. data.member = member;
  7054. break;
  7055. }
  7056. }
  7057. return data;
  7058. };
  7059. itself.jshint = itself;
  7060. return itself;
  7061. }());
  7062. if (typeof exports === "object" && exports) {
  7063. exports.JSHINT = JSHINT;
  7064. }
  7065. },{"../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){
  7066. "use strict";
  7067. var _ = _dereq_("../lodash");
  7068. var events = _dereq_("events");
  7069. var reg = _dereq_("./reg.js");
  7070. var state = _dereq_("./state.js").state;
  7071. var unicodeData = _dereq_("../data/ascii-identifier-data.js");
  7072. var asciiIdentifierStartTable = unicodeData.asciiIdentifierStartTable;
  7073. var asciiIdentifierPartTable = unicodeData.asciiIdentifierPartTable;
  7074. var Token = {
  7075. Identifier: 1,
  7076. Punctuator: 2,
  7077. NumericLiteral: 3,
  7078. StringLiteral: 4,
  7079. Comment: 5,
  7080. Keyword: 6,
  7081. NullLiteral: 7,
  7082. BooleanLiteral: 8,
  7083. RegExp: 9,
  7084. TemplateHead: 10,
  7085. TemplateMiddle: 11,
  7086. TemplateTail: 12,
  7087. NoSubstTemplate: 13
  7088. };
  7089. var Context = {
  7090. Block: 1,
  7091. Template: 2
  7092. };
  7093. function asyncTrigger() {
  7094. var _checks = [];
  7095. return {
  7096. push: function(fn) {
  7097. _checks.push(fn);
  7098. },
  7099. check: function() {
  7100. for (var check = 0; check < _checks.length; ++check) {
  7101. _checks[check]();
  7102. }
  7103. _checks.splice(0, _checks.length);
  7104. }
  7105. };
  7106. }
  7107. function Lexer(source) {
  7108. var lines = source;
  7109. if (typeof lines === "string") {
  7110. lines = lines
  7111. .replace(/\r\n/g, "\n")
  7112. .replace(/\r/g, "\n")
  7113. .split("\n");
  7114. }
  7115. if (lines[0] && lines[0].substr(0, 2) === "#!") {
  7116. if (lines[0].indexOf("node") !== -1) {
  7117. state.option.node = true;
  7118. }
  7119. lines[0] = "";
  7120. }
  7121. this.emitter = new events.EventEmitter();
  7122. this.source = source;
  7123. this.setLines(lines);
  7124. this.prereg = true;
  7125. this.line = 0;
  7126. this.char = 1;
  7127. this.from = 1;
  7128. this.input = "";
  7129. this.inComment = false;
  7130. this.context = [];
  7131. this.templateStarts = [];
  7132. for (var i = 0; i < state.option.indent; i += 1) {
  7133. state.tab += " ";
  7134. }
  7135. this.ignoreLinterErrors = false;
  7136. }
  7137. Lexer.prototype = {
  7138. _lines: [],
  7139. inContext: function(ctxType) {
  7140. return this.context.length > 0 && this.context[this.context.length - 1].type === ctxType;
  7141. },
  7142. pushContext: function(ctxType) {
  7143. this.context.push({ type: ctxType });
  7144. },
  7145. popContext: function() {
  7146. return this.context.pop();
  7147. },
  7148. isContext: function(context) {
  7149. return this.context.length > 0 && this.context[this.context.length - 1] === context;
  7150. },
  7151. currentContext: function() {
  7152. return this.context.length > 0 && this.context[this.context.length - 1];
  7153. },
  7154. getLines: function() {
  7155. this._lines = state.lines;
  7156. return this._lines;
  7157. },
  7158. setLines: function(val) {
  7159. this._lines = val;
  7160. state.lines = this._lines;
  7161. },
  7162. peek: function(i) {
  7163. return this.input.charAt(i || 0);
  7164. },
  7165. skip: function(i) {
  7166. i = i || 1;
  7167. this.char += i;
  7168. this.input = this.input.slice(i);
  7169. },
  7170. on: function(names, listener) {
  7171. names.split(" ").forEach(function(name) {
  7172. this.emitter.on(name, listener);
  7173. }.bind(this));
  7174. },
  7175. trigger: function() {
  7176. this.emitter.emit.apply(this.emitter, Array.prototype.slice.call(arguments));
  7177. },
  7178. triggerAsync: function(type, args, checks, fn) {
  7179. checks.push(function() {
  7180. if (fn()) {
  7181. this.trigger(type, args);
  7182. }
  7183. }.bind(this));
  7184. },
  7185. scanPunctuator: function() {
  7186. var ch1 = this.peek();
  7187. var ch2, ch3, ch4;
  7188. switch (ch1) {
  7189. case ".":
  7190. if ((/^[0-9]$/).test(this.peek(1))) {
  7191. return null;
  7192. }
  7193. if (this.peek(1) === "." && this.peek(2) === ".") {
  7194. return {
  7195. type: Token.Punctuator,
  7196. value: "..."
  7197. };
  7198. }
  7199. case "(":
  7200. case ")":
  7201. case ";":
  7202. case ",":
  7203. case "[":
  7204. case "]":
  7205. case ":":
  7206. case "~":
  7207. case "?":
  7208. return {
  7209. type: Token.Punctuator,
  7210. value: ch1
  7211. };
  7212. case "{":
  7213. this.pushContext(Context.Block);
  7214. return {
  7215. type: Token.Punctuator,
  7216. value: ch1
  7217. };
  7218. case "}":
  7219. if (this.inContext(Context.Block)) {
  7220. this.popContext();
  7221. }
  7222. return {
  7223. type: Token.Punctuator,
  7224. value: ch1
  7225. };
  7226. case "#":
  7227. return {
  7228. type: Token.Punctuator,
  7229. value: ch1
  7230. };
  7231. case "":
  7232. return null;
  7233. }
  7234. ch2 = this.peek(1);
  7235. ch3 = this.peek(2);
  7236. ch4 = this.peek(3);
  7237. if (ch1 === ">" && ch2 === ">" && ch3 === ">" && ch4 === "=") {
  7238. return {
  7239. type: Token.Punctuator,
  7240. value: ">>>="
  7241. };
  7242. }
  7243. if (ch1 === "=" && ch2 === "=" && ch3 === "=") {
  7244. return {
  7245. type: Token.Punctuator,
  7246. value: "==="
  7247. };
  7248. }
  7249. if (ch1 === "!" && ch2 === "=" && ch3 === "=") {
  7250. return {
  7251. type: Token.Punctuator,
  7252. value: "!=="
  7253. };
  7254. }
  7255. if (ch1 === ">" && ch2 === ">" && ch3 === ">") {
  7256. return {
  7257. type: Token.Punctuator,
  7258. value: ">>>"
  7259. };
  7260. }
  7261. if (ch1 === "<" && ch2 === "<" && ch3 === "=") {
  7262. return {
  7263. type: Token.Punctuator,
  7264. value: "<<="
  7265. };
  7266. }
  7267. if (ch1 === ">" && ch2 === ">" && ch3 === "=") {
  7268. return {
  7269. type: Token.Punctuator,
  7270. value: ">>="
  7271. };
  7272. }
  7273. if (ch1 === "=" && ch2 === ">") {
  7274. return {
  7275. type: Token.Punctuator,
  7276. value: ch1 + ch2
  7277. };
  7278. }
  7279. if (ch1 === ch2 && ("+-<>&|".indexOf(ch1) >= 0)) {
  7280. return {
  7281. type: Token.Punctuator,
  7282. value: ch1 + ch2
  7283. };
  7284. }
  7285. if ("<>=!+-*%&|^".indexOf(ch1) >= 0) {
  7286. if (ch2 === "=") {
  7287. return {
  7288. type: Token.Punctuator,
  7289. value: ch1 + ch2
  7290. };
  7291. }
  7292. return {
  7293. type: Token.Punctuator,
  7294. value: ch1
  7295. };
  7296. }
  7297. if (ch1 === "/") {
  7298. if (ch2 === "=") {
  7299. return {
  7300. type: Token.Punctuator,
  7301. value: "/="
  7302. };
  7303. }
  7304. return {
  7305. type: Token.Punctuator,
  7306. value: "/"
  7307. };
  7308. }
  7309. return null;
  7310. },
  7311. scanComments: function() {
  7312. var ch1 = this.peek();
  7313. var ch2 = this.peek(1);
  7314. var rest = this.input.substr(2);
  7315. var startLine = this.line;
  7316. var startChar = this.char;
  7317. var self = this;
  7318. function commentToken(label, body, opt) {
  7319. var special = ["jshint", "jslint", "members", "member", "globals", "global", "exported"];
  7320. var isSpecial = false;
  7321. var value = label + body;
  7322. var commentType = "plain";
  7323. opt = opt || {};
  7324. if (opt.isMultiline) {
  7325. value += "*/";
  7326. }
  7327. body = body.replace(/\n/g, " ");
  7328. if (label === "/*" && reg.fallsThrough.test(body)) {
  7329. isSpecial = true;
  7330. commentType = "falls through";
  7331. }
  7332. special.forEach(function(str) {
  7333. if (isSpecial) {
  7334. return;
  7335. }
  7336. if (label === "//" && str !== "jshint") {
  7337. return;
  7338. }
  7339. if (body.charAt(str.length) === " " && body.substr(0, str.length) === str) {
  7340. isSpecial = true;
  7341. label = label + str;
  7342. body = body.substr(str.length);
  7343. }
  7344. if (!isSpecial && body.charAt(0) === " " && body.charAt(str.length + 1) === " " &&
  7345. body.substr(1, str.length) === str) {
  7346. isSpecial = true;
  7347. label = label + " " + str;
  7348. body = body.substr(str.length + 1);
  7349. }
  7350. if (!isSpecial) {
  7351. return;
  7352. }
  7353. switch (str) {
  7354. case "member":
  7355. commentType = "members";
  7356. break;
  7357. case "global":
  7358. commentType = "globals";
  7359. break;
  7360. default:
  7361. var options = body.split(":").map(function(v) {
  7362. return v.replace(/^\s+/, "").replace(/\s+$/, "");
  7363. });
  7364. if (options.length === 2) {
  7365. switch (options[0]) {
  7366. case "ignore":
  7367. switch (options[1]) {
  7368. case "start":
  7369. self.ignoringLinterErrors = true;
  7370. isSpecial = false;
  7371. break;
  7372. case "end":
  7373. self.ignoringLinterErrors = false;
  7374. isSpecial = false;
  7375. break;
  7376. }
  7377. }
  7378. }
  7379. commentType = str;
  7380. }
  7381. });
  7382. return {
  7383. type: Token.Comment,
  7384. commentType: commentType,
  7385. value: value,
  7386. body: body,
  7387. isSpecial: isSpecial,
  7388. isMultiline: opt.isMultiline || false,
  7389. isMalformed: opt.isMalformed || false
  7390. };
  7391. }
  7392. if (ch1 === "*" && ch2 === "/") {
  7393. this.trigger("error", {
  7394. code: "E018",
  7395. line: startLine,
  7396. character: startChar
  7397. });
  7398. this.skip(2);
  7399. return null;
  7400. }
  7401. if (ch1 !== "/" || (ch2 !== "*" && ch2 !== "/")) {
  7402. return null;
  7403. }
  7404. if (ch2 === "/") {
  7405. this.skip(this.input.length); // Skip to the EOL.
  7406. return commentToken("//", rest);
  7407. }
  7408. var body = "";
  7409. if (ch2 === "*") {
  7410. this.inComment = true;
  7411. this.skip(2);
  7412. while (this.peek() !== "*" || this.peek(1) !== "/") {
  7413. if (this.peek() === "") { // End of Line
  7414. body += "\n";
  7415. if (!this.nextLine()) {
  7416. this.trigger("error", {
  7417. code: "E017",
  7418. line: startLine,
  7419. character: startChar
  7420. });
  7421. this.inComment = false;
  7422. return commentToken("/*", body, {
  7423. isMultiline: true,
  7424. isMalformed: true
  7425. });
  7426. }
  7427. } else {
  7428. body += this.peek();
  7429. this.skip();
  7430. }
  7431. }
  7432. this.skip(2);
  7433. this.inComment = false;
  7434. return commentToken("/*", body, { isMultiline: true });
  7435. }
  7436. },
  7437. scanKeyword: function() {
  7438. var result = /^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input);
  7439. var keywords = [
  7440. "if", "in", "do", "var", "for", "new",
  7441. "try", "let", "this", "else", "case",
  7442. "void", "with", "enum", "while", "break",
  7443. "catch", "throw", "const", "yield", "class",
  7444. "super", "return", "typeof", "delete",
  7445. "switch", "export", "import", "default",
  7446. "finally", "extends", "function", "continue",
  7447. "debugger", "instanceof"
  7448. ];
  7449. if (result && keywords.indexOf(result[0]) >= 0) {
  7450. return {
  7451. type: Token.Keyword,
  7452. value: result[0]
  7453. };
  7454. }
  7455. return null;
  7456. },
  7457. scanIdentifier: function() {
  7458. var id = "";
  7459. var index = 0;
  7460. var type, char;
  7461. function isNonAsciiIdentifierStart(code) {
  7462. return code > 256;
  7463. }
  7464. function isNonAsciiIdentifierPart(code) {
  7465. return code > 256;
  7466. }
  7467. function isHexDigit(str) {
  7468. return (/^[0-9a-fA-F]$/).test(str);
  7469. }
  7470. var readUnicodeEscapeSequence = function() {
  7471. index += 1;
  7472. if (this.peek(index) !== "u") {
  7473. return null;
  7474. }
  7475. var ch1 = this.peek(index + 1);
  7476. var ch2 = this.peek(index + 2);
  7477. var ch3 = this.peek(index + 3);
  7478. var ch4 = this.peek(index + 4);
  7479. var code;
  7480. if (isHexDigit(ch1) && isHexDigit(ch2) && isHexDigit(ch3) && isHexDigit(ch4)) {
  7481. code = parseInt(ch1 + ch2 + ch3 + ch4, 16);
  7482. if (asciiIdentifierPartTable[code] || isNonAsciiIdentifierPart(code)) {
  7483. index += 5;
  7484. return "\\u" + ch1 + ch2 + ch3 + ch4;
  7485. }
  7486. return null;
  7487. }
  7488. return null;
  7489. }.bind(this);
  7490. var getIdentifierStart = function() {
  7491. var chr = this.peek(index);
  7492. var code = chr.charCodeAt(0);
  7493. if (code === 92) {
  7494. return readUnicodeEscapeSequence();
  7495. }
  7496. if (code < 128) {
  7497. if (asciiIdentifierStartTable[code]) {
  7498. index += 1;
  7499. return chr;
  7500. }
  7501. return null;
  7502. }
  7503. if (isNonAsciiIdentifierStart(code)) {
  7504. index += 1;
  7505. return chr;
  7506. }
  7507. return null;
  7508. }.bind(this);
  7509. var getIdentifierPart = function() {
  7510. var chr = this.peek(index);
  7511. var code = chr.charCodeAt(0);
  7512. if (code === 92) {
  7513. return readUnicodeEscapeSequence();
  7514. }
  7515. if (code < 128) {
  7516. if (asciiIdentifierPartTable[code]) {
  7517. index += 1;
  7518. return chr;
  7519. }
  7520. return null;
  7521. }
  7522. if (isNonAsciiIdentifierPart(code)) {
  7523. index += 1;
  7524. return chr;
  7525. }
  7526. return null;
  7527. }.bind(this);
  7528. function removeEscapeSequences(id) {
  7529. return id.replace(/\\u([0-9a-fA-F]{4})/g, function(m0, codepoint) {
  7530. return String.fromCharCode(parseInt(codepoint, 16));
  7531. });
  7532. }
  7533. char = getIdentifierStart();
  7534. if (char === null) {
  7535. return null;
  7536. }
  7537. id = char;
  7538. for (;;) {
  7539. char = getIdentifierPart();
  7540. if (char === null) {
  7541. break;
  7542. }
  7543. id += char;
  7544. }
  7545. switch (id) {
  7546. case "true":
  7547. case "false":
  7548. type = Token.BooleanLiteral;
  7549. break;
  7550. case "null":
  7551. type = Token.NullLiteral;
  7552. break;
  7553. default:
  7554. type = Token.Identifier;
  7555. }
  7556. return {
  7557. type: type,
  7558. value: removeEscapeSequences(id),
  7559. text: id,
  7560. tokenLength: id.length
  7561. };
  7562. },
  7563. scanNumericLiteral: function() {
  7564. var index = 0;
  7565. var value = "";
  7566. var length = this.input.length;
  7567. var char = this.peek(index);
  7568. var bad;
  7569. var isAllowedDigit = isDecimalDigit;
  7570. var base = 10;
  7571. var isLegacy = false;
  7572. function isDecimalDigit(str) {
  7573. return (/^[0-9]$/).test(str);
  7574. }
  7575. function isOctalDigit(str) {
  7576. return (/^[0-7]$/).test(str);
  7577. }
  7578. function isBinaryDigit(str) {
  7579. return (/^[01]$/).test(str);
  7580. }
  7581. function isHexDigit(str) {
  7582. return (/^[0-9a-fA-F]$/).test(str);
  7583. }
  7584. function isIdentifierStart(ch) {
  7585. return (ch === "$") || (ch === "_") || (ch === "\\") ||
  7586. (ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z");
  7587. }
  7588. if (char !== "." && !isDecimalDigit(char)) {
  7589. return null;
  7590. }
  7591. if (char !== ".") {
  7592. value = this.peek(index);
  7593. index += 1;
  7594. char = this.peek(index);
  7595. if (value === "0") {
  7596. if (char === "x" || char === "X") {
  7597. isAllowedDigit = isHexDigit;
  7598. base = 16;
  7599. index += 1;
  7600. value += char;
  7601. }
  7602. if (char === "o" || char === "O") {
  7603. isAllowedDigit = isOctalDigit;
  7604. base = 8;
  7605. if (!state.inES6(true)) {
  7606. this.trigger("warning", {
  7607. code: "W119",
  7608. line: this.line,
  7609. character: this.char,
  7610. data: [ "Octal integer literal", "6" ]
  7611. });
  7612. }
  7613. index += 1;
  7614. value += char;
  7615. }
  7616. if (char === "b" || char === "B") {
  7617. isAllowedDigit = isBinaryDigit;
  7618. base = 2;
  7619. if (!state.inES6(true)) {
  7620. this.trigger("warning", {
  7621. code: "W119",
  7622. line: this.line,
  7623. character: this.char,
  7624. data: [ "Binary integer literal", "6" ]
  7625. });
  7626. }
  7627. index += 1;
  7628. value += char;
  7629. }
  7630. if (isOctalDigit(char)) {
  7631. isAllowedDigit = isOctalDigit;
  7632. base = 8;
  7633. isLegacy = true;
  7634. bad = false;
  7635. index += 1;
  7636. value += char;
  7637. }
  7638. if (!isOctalDigit(char) && isDecimalDigit(char)) {
  7639. index += 1;
  7640. value += char;
  7641. }
  7642. }
  7643. while (index < length) {
  7644. char = this.peek(index);
  7645. if (isLegacy && isDecimalDigit(char)) {
  7646. bad = true;
  7647. } else if (!isAllowedDigit(char)) {
  7648. break;
  7649. }
  7650. value += char;
  7651. index += 1;
  7652. }
  7653. if (isAllowedDigit !== isDecimalDigit) {
  7654. if (!isLegacy && value.length <= 2) { // 0x
  7655. return {
  7656. type: Token.NumericLiteral,
  7657. value: value,
  7658. isMalformed: true
  7659. };
  7660. }
  7661. if (index < length) {
  7662. char = this.peek(index);
  7663. if (isIdentifierStart(char)) {
  7664. return null;
  7665. }
  7666. }
  7667. return {
  7668. type: Token.NumericLiteral,
  7669. value: value,
  7670. base: base,
  7671. isLegacy: isLegacy,
  7672. isMalformed: false
  7673. };
  7674. }
  7675. }
  7676. if (char === ".") {
  7677. value += char;
  7678. index += 1;
  7679. while (index < length) {
  7680. char = this.peek(index);
  7681. if (!isDecimalDigit(char)) {
  7682. break;
  7683. }
  7684. value += char;
  7685. index += 1;
  7686. }
  7687. }
  7688. if (char === "e" || char === "E") {
  7689. value += char;
  7690. index += 1;
  7691. char = this.peek(index);
  7692. if (char === "+" || char === "-") {
  7693. value += this.peek(index);
  7694. index += 1;
  7695. }
  7696. char = this.peek(index);
  7697. if (isDecimalDigit(char)) {
  7698. value += char;
  7699. index += 1;
  7700. while (index < length) {
  7701. char = this.peek(index);
  7702. if (!isDecimalDigit(char)) {
  7703. break;
  7704. }
  7705. value += char;
  7706. index += 1;
  7707. }
  7708. } else {
  7709. return null;
  7710. }
  7711. }
  7712. if (index < length) {
  7713. char = this.peek(index);
  7714. if (isIdentifierStart(char)) {
  7715. return null;
  7716. }
  7717. }
  7718. return {
  7719. type: Token.NumericLiteral,
  7720. value: value,
  7721. base: base,
  7722. isMalformed: !isFinite(value)
  7723. };
  7724. },
  7725. scanEscapeSequence: function(checks) {
  7726. var allowNewLine = false;
  7727. var jump = 1;
  7728. this.skip();
  7729. var char = this.peek();
  7730. switch (char) {
  7731. case "'":
  7732. this.triggerAsync("warning", {
  7733. code: "W114",
  7734. line: this.line,
  7735. character: this.char,
  7736. data: [ "\\'" ]
  7737. }, checks, function() {return state.jsonMode; });
  7738. break;
  7739. case "b":
  7740. char = "\\b";
  7741. break;
  7742. case "f":
  7743. char = "\\f";
  7744. break;
  7745. case "n":
  7746. char = "\\n";
  7747. break;
  7748. case "r":
  7749. char = "\\r";
  7750. break;
  7751. case "t":
  7752. char = "\\t";
  7753. break;
  7754. case "0":
  7755. char = "\\0";
  7756. var n = parseInt(this.peek(1), 10);
  7757. this.triggerAsync("warning", {
  7758. code: "W115",
  7759. line: this.line,
  7760. character: this.char
  7761. }, checks,
  7762. function() { return n >= 0 && n <= 7 && state.isStrict(); });
  7763. break;
  7764. case "u":
  7765. var hexCode = this.input.substr(1, 4);
  7766. var code = parseInt(hexCode, 16);
  7767. if (isNaN(code)) {
  7768. this.trigger("warning", {
  7769. code: "W052",
  7770. line: this.line,
  7771. character: this.char,
  7772. data: [ "u" + hexCode ]
  7773. });
  7774. }
  7775. char = String.fromCharCode(code);
  7776. jump = 5;
  7777. break;
  7778. case "v":
  7779. this.triggerAsync("warning", {
  7780. code: "W114",
  7781. line: this.line,
  7782. character: this.char,
  7783. data: [ "\\v" ]
  7784. }, checks, function() { return state.jsonMode; });
  7785. char = "\v";
  7786. break;
  7787. case "x":
  7788. var x = parseInt(this.input.substr(1, 2), 16);
  7789. this.triggerAsync("warning", {
  7790. code: "W114",
  7791. line: this.line,
  7792. character: this.char,
  7793. data: [ "\\x-" ]
  7794. }, checks, function() { return state.jsonMode; });
  7795. char = String.fromCharCode(x);
  7796. jump = 3;
  7797. break;
  7798. case "\\":
  7799. char = "\\\\";
  7800. break;
  7801. case "\"":
  7802. char = "\\\"";
  7803. break;
  7804. case "/":
  7805. break;
  7806. case "":
  7807. allowNewLine = true;
  7808. char = "";
  7809. break;
  7810. }
  7811. return { char: char, jump: jump, allowNewLine: allowNewLine };
  7812. },
  7813. scanTemplateLiteral: function(checks) {
  7814. var tokenType;
  7815. var value = "";
  7816. var ch;
  7817. var startLine = this.line;
  7818. var startChar = this.char;
  7819. var depth = this.templateStarts.length;
  7820. if (!state.inES6(true)) {
  7821. return null;
  7822. } else if (this.peek() === "`") {
  7823. tokenType = Token.TemplateHead;
  7824. this.templateStarts.push({ line: this.line, char: this.char });
  7825. depth = this.templateStarts.length;
  7826. this.skip(1);
  7827. this.pushContext(Context.Template);
  7828. } else if (this.inContext(Context.Template) && this.peek() === "}") {
  7829. tokenType = Token.TemplateMiddle;
  7830. } else {
  7831. return null;
  7832. }
  7833. while (this.peek() !== "`") {
  7834. while ((ch = this.peek()) === "") {
  7835. value += "\n";
  7836. if (!this.nextLine()) {
  7837. var startPos = this.templateStarts.pop();
  7838. this.trigger("error", {
  7839. code: "E052",
  7840. line: startPos.line,
  7841. character: startPos.char
  7842. });
  7843. return {
  7844. type: tokenType,
  7845. value: value,
  7846. startLine: startLine,
  7847. startChar: startChar,
  7848. isUnclosed: true,
  7849. depth: depth,
  7850. context: this.popContext()
  7851. };
  7852. }
  7853. }
  7854. if (ch === '$' && this.peek(1) === '{') {
  7855. value += '${';
  7856. this.skip(2);
  7857. return {
  7858. type: tokenType,
  7859. value: value,
  7860. startLine: startLine,
  7861. startChar: startChar,
  7862. isUnclosed: false,
  7863. depth: depth,
  7864. context: this.currentContext()
  7865. };
  7866. } else if (ch === '\\') {
  7867. var escape = this.scanEscapeSequence(checks);
  7868. value += escape.char;
  7869. this.skip(escape.jump);
  7870. } else if (ch !== '`') {
  7871. value += ch;
  7872. this.skip(1);
  7873. }
  7874. }
  7875. tokenType = tokenType === Token.TemplateHead ? Token.NoSubstTemplate : Token.TemplateTail;
  7876. this.skip(1);
  7877. this.templateStarts.pop();
  7878. return {
  7879. type: tokenType,
  7880. value: value,
  7881. startLine: startLine,
  7882. startChar: startChar,
  7883. isUnclosed: false,
  7884. depth: depth,
  7885. context: this.popContext()
  7886. };
  7887. },
  7888. scanStringLiteral: function(checks) {
  7889. var quote = this.peek();
  7890. if (quote !== "\"" && quote !== "'") {
  7891. return null;
  7892. }
  7893. this.triggerAsync("warning", {
  7894. code: "W108",
  7895. line: this.line,
  7896. character: this.char // +1?
  7897. }, checks, function() { return state.jsonMode && quote !== "\""; });
  7898. var value = "";
  7899. var startLine = this.line;
  7900. var startChar = this.char;
  7901. var allowNewLine = false;
  7902. this.skip();
  7903. while (this.peek() !== quote) {
  7904. if (this.peek() === "") { // End Of Line
  7905. if (!allowNewLine) {
  7906. this.trigger("warning", {
  7907. code: "W112",
  7908. line: this.line,
  7909. character: this.char
  7910. });
  7911. } else {
  7912. allowNewLine = false;
  7913. this.triggerAsync("warning", {
  7914. code: "W043",
  7915. line: this.line,
  7916. character: this.char
  7917. }, checks, function() { return !state.option.multistr; });
  7918. this.triggerAsync("warning", {
  7919. code: "W042",
  7920. line: this.line,
  7921. character: this.char
  7922. }, checks, function() { return state.jsonMode && state.option.multistr; });
  7923. }
  7924. if (!this.nextLine()) {
  7925. this.trigger("error", {
  7926. code: "E029",
  7927. line: startLine,
  7928. character: startChar
  7929. });
  7930. return {
  7931. type: Token.StringLiteral,
  7932. value: value,
  7933. startLine: startLine,
  7934. startChar: startChar,
  7935. isUnclosed: true,
  7936. quote: quote
  7937. };
  7938. }
  7939. } else { // Any character other than End Of Line
  7940. allowNewLine = false;
  7941. var char = this.peek();
  7942. var jump = 1; // A length of a jump, after we're done
  7943. if (char < " ") {
  7944. this.trigger("warning", {
  7945. code: "W113",
  7946. line: this.line,
  7947. character: this.char,
  7948. data: [ "<non-printable>" ]
  7949. });
  7950. }
  7951. if (char === "\\") {
  7952. var parsed = this.scanEscapeSequence(checks);
  7953. char = parsed.char;
  7954. jump = parsed.jump;
  7955. allowNewLine = parsed.allowNewLine;
  7956. }
  7957. value += char;
  7958. this.skip(jump);
  7959. }
  7960. }
  7961. this.skip();
  7962. return {
  7963. type: Token.StringLiteral,
  7964. value: value,
  7965. startLine: startLine,
  7966. startChar: startChar,
  7967. isUnclosed: false,
  7968. quote: quote
  7969. };
  7970. },
  7971. scanRegExp: function() {
  7972. var index = 0;
  7973. var length = this.input.length;
  7974. var char = this.peek();
  7975. var value = char;
  7976. var body = "";
  7977. var flags = [];
  7978. var malformed = false;
  7979. var isCharSet = false;
  7980. var terminated;
  7981. var scanUnexpectedChars = function() {
  7982. if (char < " ") {
  7983. malformed = true;
  7984. this.trigger("warning", {
  7985. code: "W048",
  7986. line: this.line,
  7987. character: this.char
  7988. });
  7989. }
  7990. if (char === "<") {
  7991. malformed = true;
  7992. this.trigger("warning", {
  7993. code: "W049",
  7994. line: this.line,
  7995. character: this.char,
  7996. data: [ char ]
  7997. });
  7998. }
  7999. }.bind(this);
  8000. if (!this.prereg || char !== "/") {
  8001. return null;
  8002. }
  8003. index += 1;
  8004. terminated = false;
  8005. while (index < length) {
  8006. char = this.peek(index);
  8007. value += char;
  8008. body += char;
  8009. if (isCharSet) {
  8010. if (char === "]") {
  8011. if (this.peek(index - 1) !== "\\" || this.peek(index - 2) === "\\") {
  8012. isCharSet = false;
  8013. }
  8014. }
  8015. if (char === "\\") {
  8016. index += 1;
  8017. char = this.peek(index);
  8018. body += char;
  8019. value += char;
  8020. scanUnexpectedChars();
  8021. }
  8022. index += 1;
  8023. continue;
  8024. }
  8025. if (char === "\\") {
  8026. index += 1;
  8027. char = this.peek(index);
  8028. body += char;
  8029. value += char;
  8030. scanUnexpectedChars();
  8031. if (char === "/") {
  8032. index += 1;
  8033. continue;
  8034. }
  8035. if (char === "[") {
  8036. index += 1;
  8037. continue;
  8038. }
  8039. }
  8040. if (char === "[") {
  8041. isCharSet = true;
  8042. index += 1;
  8043. continue;
  8044. }
  8045. if (char === "/") {
  8046. body = body.substr(0, body.length - 1);
  8047. terminated = true;
  8048. index += 1;
  8049. break;
  8050. }
  8051. index += 1;
  8052. }
  8053. if (!terminated) {
  8054. this.trigger("error", {
  8055. code: "E015",
  8056. line: this.line,
  8057. character: this.from
  8058. });
  8059. return void this.trigger("fatal", {
  8060. line: this.line,
  8061. from: this.from
  8062. });
  8063. }
  8064. while (index < length) {
  8065. char = this.peek(index);
  8066. if (!/[gim]/.test(char)) {
  8067. break;
  8068. }
  8069. flags.push(char);
  8070. value += char;
  8071. index += 1;
  8072. }
  8073. try {
  8074. new RegExp(body, flags.join(""));
  8075. } catch (err) {
  8076. malformed = true;
  8077. this.trigger("error", {
  8078. code: "E016",
  8079. line: this.line,
  8080. character: this.char,
  8081. data: [ err.message ] // Platform dependent!
  8082. });
  8083. }
  8084. return {
  8085. type: Token.RegExp,
  8086. value: value,
  8087. flags: flags,
  8088. isMalformed: malformed
  8089. };
  8090. },
  8091. scanNonBreakingSpaces: function() {
  8092. return state.option.nonbsp ?
  8093. this.input.search(/(\u00A0)/) : -1;
  8094. },
  8095. scanUnsafeChars: function() {
  8096. return this.input.search(reg.unsafeChars);
  8097. },
  8098. next: function(checks) {
  8099. this.from = this.char;
  8100. var start;
  8101. if (/\s/.test(this.peek())) {
  8102. start = this.char;
  8103. while (/\s/.test(this.peek())) {
  8104. this.from += 1;
  8105. this.skip();
  8106. }
  8107. }
  8108. var match = this.scanComments() ||
  8109. this.scanStringLiteral(checks) ||
  8110. this.scanTemplateLiteral(checks);
  8111. if (match) {
  8112. return match;
  8113. }
  8114. match =
  8115. this.scanRegExp() ||
  8116. this.scanPunctuator() ||
  8117. this.scanKeyword() ||
  8118. this.scanIdentifier() ||
  8119. this.scanNumericLiteral();
  8120. if (match) {
  8121. this.skip(match.tokenLength || match.value.length);
  8122. return match;
  8123. }
  8124. return null;
  8125. },
  8126. nextLine: function() {
  8127. var char;
  8128. if (this.line >= this.getLines().length) {
  8129. return false;
  8130. }
  8131. this.input = this.getLines()[this.line];
  8132. this.line += 1;
  8133. this.char = 1;
  8134. this.from = 1;
  8135. var inputTrimmed = this.input.trim();
  8136. var startsWith = function() {
  8137. return _.some(arguments, function(prefix) {
  8138. return inputTrimmed.indexOf(prefix) === 0;
  8139. });
  8140. };
  8141. var endsWith = function() {
  8142. return _.some(arguments, function(suffix) {
  8143. return inputTrimmed.indexOf(suffix, inputTrimmed.length - suffix.length) !== -1;
  8144. });
  8145. };
  8146. if (this.ignoringLinterErrors === true) {
  8147. if (!startsWith("/*", "//") && !(this.inComment && endsWith("*/"))) {
  8148. this.input = "";
  8149. }
  8150. }
  8151. char = this.scanNonBreakingSpaces();
  8152. if (char >= 0) {
  8153. this.trigger("warning", { code: "W125", line: this.line, character: char + 1 });
  8154. }
  8155. this.input = this.input.replace(/\t/g, state.tab);
  8156. char = this.scanUnsafeChars();
  8157. if (char >= 0) {
  8158. this.trigger("warning", { code: "W100", line: this.line, character: char });
  8159. }
  8160. if (!this.ignoringLinterErrors && state.option.maxlen &&
  8161. state.option.maxlen < this.input.length) {
  8162. var inComment = this.inComment ||
  8163. startsWith.call(inputTrimmed, "//") ||
  8164. startsWith.call(inputTrimmed, "/*");
  8165. var shouldTriggerError = !inComment || !reg.maxlenException.test(inputTrimmed);
  8166. if (shouldTriggerError) {
  8167. this.trigger("warning", { code: "W101", line: this.line, character: this.input.length });
  8168. }
  8169. }
  8170. return true;
  8171. },
  8172. start: function() {
  8173. this.nextLine();
  8174. },
  8175. token: function() {
  8176. var checks = asyncTrigger();
  8177. var token;
  8178. function isReserved(token, isProperty) {
  8179. if (!token.reserved) {
  8180. return false;
  8181. }
  8182. var meta = token.meta;
  8183. if (meta && meta.isFutureReservedWord && state.inES5()) {
  8184. if (!meta.es5) {
  8185. return false;
  8186. }
  8187. if (meta.strictOnly) {
  8188. if (!state.option.strict && !state.isStrict()) {
  8189. return false;
  8190. }
  8191. }
  8192. if (isProperty) {
  8193. return false;
  8194. }
  8195. }
  8196. return true;
  8197. }
  8198. var create = function(type, value, isProperty, token) {
  8199. var obj;
  8200. if (type !== "(endline)" && type !== "(end)") {
  8201. this.prereg = false;
  8202. }
  8203. if (type === "(punctuator)") {
  8204. switch (value) {
  8205. case ".":
  8206. case ")":
  8207. case "~":
  8208. case "#":
  8209. case "]":
  8210. case "++":
  8211. case "--":
  8212. this.prereg = false;
  8213. break;
  8214. default:
  8215. this.prereg = true;
  8216. }
  8217. obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
  8218. }
  8219. if (type === "(identifier)") {
  8220. if (value === "return" || value === "case" || value === "typeof") {
  8221. this.prereg = true;
  8222. }
  8223. if (_.has(state.syntax, value)) {
  8224. obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
  8225. if (!isReserved(obj, isProperty && type === "(identifier)")) {
  8226. obj = null;
  8227. }
  8228. }
  8229. }
  8230. if (!obj) {
  8231. obj = Object.create(state.syntax[type]);
  8232. }
  8233. obj.identifier = (type === "(identifier)");
  8234. obj.type = obj.type || type;
  8235. obj.value = value;
  8236. obj.line = this.line;
  8237. obj.character = this.char;
  8238. obj.from = this.from;
  8239. if (obj.identifier && token) obj.raw_text = token.text || token.value;
  8240. if (token && token.startLine && token.startLine !== this.line) {
  8241. obj.startLine = token.startLine;
  8242. }
  8243. if (token && token.context) {
  8244. obj.context = token.context;
  8245. }
  8246. if (token && token.depth) {
  8247. obj.depth = token.depth;
  8248. }
  8249. if (token && token.isUnclosed) {
  8250. obj.isUnclosed = token.isUnclosed;
  8251. }
  8252. if (isProperty && obj.identifier) {
  8253. obj.isProperty = isProperty;
  8254. }
  8255. obj.check = checks.check;
  8256. return obj;
  8257. }.bind(this);
  8258. for (;;) {
  8259. if (!this.input.length) {
  8260. if (this.nextLine()) {
  8261. return create("(endline)", "");
  8262. }
  8263. if (this.exhausted) {
  8264. return null;
  8265. }
  8266. this.exhausted = true;
  8267. return create("(end)", "");
  8268. }
  8269. token = this.next(checks);
  8270. if (!token) {
  8271. if (this.input.length) {
  8272. this.trigger("error", {
  8273. code: "E024",
  8274. line: this.line,
  8275. character: this.char,
  8276. data: [ this.peek() ]
  8277. });
  8278. this.input = "";
  8279. }
  8280. continue;
  8281. }
  8282. switch (token.type) {
  8283. case Token.StringLiteral:
  8284. this.triggerAsync("String", {
  8285. line: this.line,
  8286. char: this.char,
  8287. from: this.from,
  8288. startLine: token.startLine,
  8289. startChar: token.startChar,
  8290. value: token.value,
  8291. quote: token.quote
  8292. }, checks, function() { return true; });
  8293. return create("(string)", token.value, null, token);
  8294. case Token.TemplateHead:
  8295. this.trigger("TemplateHead", {
  8296. line: this.line,
  8297. char: this.char,
  8298. from: this.from,
  8299. startLine: token.startLine,
  8300. startChar: token.startChar,
  8301. value: token.value
  8302. });
  8303. return create("(template)", token.value, null, token);
  8304. case Token.TemplateMiddle:
  8305. this.trigger("TemplateMiddle", {
  8306. line: this.line,
  8307. char: this.char,
  8308. from: this.from,
  8309. startLine: token.startLine,
  8310. startChar: token.startChar,
  8311. value: token.value
  8312. });
  8313. return create("(template middle)", token.value, null, token);
  8314. case Token.TemplateTail:
  8315. this.trigger("TemplateTail", {
  8316. line: this.line,
  8317. char: this.char,
  8318. from: this.from,
  8319. startLine: token.startLine,
  8320. startChar: token.startChar,
  8321. value: token.value
  8322. });
  8323. return create("(template tail)", token.value, null, token);
  8324. case Token.NoSubstTemplate:
  8325. this.trigger("NoSubstTemplate", {
  8326. line: this.line,
  8327. char: this.char,
  8328. from: this.from,
  8329. startLine: token.startLine,
  8330. startChar: token.startChar,
  8331. value: token.value
  8332. });
  8333. return create("(no subst template)", token.value, null, token);
  8334. case Token.Identifier:
  8335. this.triggerAsync("Identifier", {
  8336. line: this.line,
  8337. char: this.char,
  8338. from: this.form,
  8339. name: token.value,
  8340. raw_name: token.text,
  8341. isProperty: state.tokens.curr.id === "."
  8342. }, checks, function() { return true; });
  8343. case Token.Keyword:
  8344. case Token.NullLiteral:
  8345. case Token.BooleanLiteral:
  8346. return create("(identifier)", token.value, state.tokens.curr.id === ".", token);
  8347. case Token.NumericLiteral:
  8348. if (token.isMalformed) {
  8349. this.trigger("warning", {
  8350. code: "W045",
  8351. line: this.line,
  8352. character: this.char,
  8353. data: [ token.value ]
  8354. });
  8355. }
  8356. this.triggerAsync("warning", {
  8357. code: "W114",
  8358. line: this.line,
  8359. character: this.char,
  8360. data: [ "0x-" ]
  8361. }, checks, function() { return token.base === 16 && state.jsonMode; });
  8362. this.triggerAsync("warning", {
  8363. code: "W115",
  8364. line: this.line,
  8365. character: this.char
  8366. }, checks, function() {
  8367. return state.isStrict() && token.base === 8 && token.isLegacy;
  8368. });
  8369. this.trigger("Number", {
  8370. line: this.line,
  8371. char: this.char,
  8372. from: this.from,
  8373. value: token.value,
  8374. base: token.base,
  8375. isMalformed: token.malformed
  8376. });
  8377. return create("(number)", token.value);
  8378. case Token.RegExp:
  8379. return create("(regexp)", token.value);
  8380. case Token.Comment:
  8381. state.tokens.curr.comment = true;
  8382. if (token.isSpecial) {
  8383. return {
  8384. id: '(comment)',
  8385. value: token.value,
  8386. body: token.body,
  8387. type: token.commentType,
  8388. isSpecial: token.isSpecial,
  8389. line: this.line,
  8390. character: this.char,
  8391. from: this.from
  8392. };
  8393. }
  8394. break;
  8395. case "":
  8396. break;
  8397. default:
  8398. return create("(punctuator)", token.value);
  8399. }
  8400. }
  8401. }
  8402. };
  8403. exports.Lexer = Lexer;
  8404. exports.Context = Context;
  8405. },{"../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){
  8406. "use strict";
  8407. var _ = _dereq_("../lodash");
  8408. var errors = {
  8409. E001: "Bad option: '{a}'.",
  8410. E002: "Bad option value.",
  8411. E003: "Expected a JSON value.",
  8412. E004: "Input is neither a string nor an array of strings.",
  8413. E005: "Input is empty.",
  8414. E006: "Unexpected early end of program.",
  8415. E007: "Missing \"use strict\" statement.",
  8416. E008: "Strict violation.",
  8417. E009: "Option 'validthis' can't be used in a global scope.",
  8418. E010: "'with' is not allowed in strict mode.",
  8419. E011: "'{a}' has already been declared.",
  8420. E012: "const '{a}' is initialized to 'undefined'.",
  8421. E013: "Attempting to override '{a}' which is a constant.",
  8422. E014: "A regular expression literal can be confused with '/='.",
  8423. E015: "Unclosed regular expression.",
  8424. E016: "Invalid regular expression.",
  8425. E017: "Unclosed comment.",
  8426. E018: "Unbegun comment.",
  8427. E019: "Unmatched '{a}'.",
  8428. E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
  8429. E021: "Expected '{a}' and instead saw '{b}'.",
  8430. E022: "Line breaking error '{a}'.",
  8431. E023: "Missing '{a}'.",
  8432. E024: "Unexpected '{a}'.",
  8433. E025: "Missing ':' on a case clause.",
  8434. E026: "Missing '}' to match '{' from line {a}.",
  8435. E027: "Missing ']' to match '[' from line {a}.",
  8436. E028: "Illegal comma.",
  8437. E029: "Unclosed string.",
  8438. E030: "Expected an identifier and instead saw '{a}'.",
  8439. E031: "Bad assignment.", // FIXME: Rephrase
  8440. E032: "Expected a small integer or 'false' and instead saw '{a}'.",
  8441. E033: "Expected an operator and instead saw '{a}'.",
  8442. E034: "get/set are ES5 features.",
  8443. E035: "Missing property name.",
  8444. E036: "Expected to see a statement and instead saw a block.",
  8445. E037: null,
  8446. E038: null,
  8447. E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.",
  8448. E040: "Each value should have its own case label.",
  8449. E041: "Unrecoverable syntax error.",
  8450. E042: "Stopping.",
  8451. E043: "Too many errors.",
  8452. E044: null,
  8453. E045: "Invalid for each loop.",
  8454. E046: "A yield statement shall be within a generator function (with syntax: `function*`)",
  8455. E047: null,
  8456. E048: "{a} declaration not directly within block.",
  8457. E049: "A {a} cannot be named '{b}'.",
  8458. E050: "Mozilla requires the yield expression to be parenthesized here.",
  8459. E051: null,
  8460. E052: "Unclosed template literal.",
  8461. E053: "Export declaration must be in global scope.",
  8462. E054: "Class properties must be methods. Expected '(' but instead saw '{a}'.",
  8463. E055: "The '{a}' option cannot be set after any executable code.",
  8464. E056: "'{a}' was used before it was declared, which is illegal for '{b}' variables.",
  8465. E057: "Invalid meta property: '{a}.{b}'.",
  8466. E058: "Missing semicolon."
  8467. };
  8468. var warnings = {
  8469. W001: "'hasOwnProperty' is a really bad name.",
  8470. W002: "Value of '{a}' may be overwritten in IE 8 and earlier.",
  8471. W003: "'{a}' was used before it was defined.",
  8472. W004: "'{a}' is already defined.",
  8473. W005: "A dot following a number can be confused with a decimal point.",
  8474. W006: "Confusing minuses.",
  8475. W007: "Confusing plusses.",
  8476. W008: "A leading decimal point can be confused with a dot: '{a}'.",
  8477. W009: "The array literal notation [] is preferable.",
  8478. W010: "The object literal notation {} is preferable.",
  8479. W011: null,
  8480. W012: null,
  8481. W013: null,
  8482. W014: "Bad line breaking before '{a}'.",
  8483. W015: null,
  8484. W016: "Unexpected use of '{a}'.",
  8485. W017: "Bad operand.",
  8486. W018: "Confusing use of '{a}'.",
  8487. W019: "Use the isNaN function to compare with NaN.",
  8488. W020: "Read only.",
  8489. W021: "Reassignment of '{a}', which is is a {b}. " +
  8490. "Use 'var' or 'let' to declare bindings that may change.",
  8491. W022: "Do not assign to the exception parameter.",
  8492. W023: "Expected an identifier in an assignment and instead saw a function invocation.",
  8493. W024: "Expected an identifier and instead saw '{a}' (a reserved word).",
  8494. W025: "Missing name in function declaration.",
  8495. W026: "Inner functions should be listed at the top of the outer function.",
  8496. W027: "Unreachable '{a}' after '{b}'.",
  8497. W028: "Label '{a}' on {b} statement.",
  8498. W030: "Expected an assignment or function call and instead saw an expression.",
  8499. W031: "Do not use 'new' for side effects.",
  8500. W032: "Unnecessary semicolon.",
  8501. W033: "Missing semicolon.",
  8502. W034: "Unnecessary directive \"{a}\".",
  8503. W035: "Empty block.",
  8504. W036: "Unexpected /*member '{a}'.",
  8505. W037: "'{a}' is a statement label.",
  8506. W038: "'{a}' used out of scope.",
  8507. W039: "'{a}' is not allowed.",
  8508. W040: "Possible strict violation.",
  8509. W041: "Use '{a}' to compare with '{b}'.",
  8510. W042: "Avoid EOL escaping.",
  8511. W043: "Bad escaping of EOL. Use option multistr if needed.",
  8512. W044: "Bad or unnecessary escaping.", /* TODO(caitp): remove W044 */
  8513. W045: "Bad number '{a}'.",
  8514. W046: "Don't use extra leading zeros '{a}'.",
  8515. W047: "A trailing decimal point can be confused with a dot: '{a}'.",
  8516. W048: "Unexpected control character in regular expression.",
  8517. W049: "Unexpected escaped character '{a}' in regular expression.",
  8518. W050: "JavaScript URL.",
  8519. W051: "Variables should not be deleted.",
  8520. W052: "Unexpected '{a}'.",
  8521. W053: "Do not use {a} as a constructor.",
  8522. W054: "The Function constructor is a form of eval.",
  8523. W055: "A constructor name should start with an uppercase letter.",
  8524. W056: "Bad constructor.",
  8525. W057: "Weird construction. Is 'new' necessary?",
  8526. W058: "Missing '()' invoking a constructor.",
  8527. W059: "Avoid arguments.{a}.",
  8528. W060: "document.write can be a form of eval.",
  8529. W061: "eval can be harmful.",
  8530. W062: "Wrap an immediate function invocation in parens " +
  8531. "to assist the reader in understanding that the expression " +
  8532. "is the result of a function, and not the function itself.",
  8533. W063: "Math is not a function.",
  8534. W064: "Missing 'new' prefix when invoking a constructor.",
  8535. W065: "Missing radix parameter.",
  8536. W066: "Implied eval. Consider passing a function instead of a string.",
  8537. W067: "Bad invocation.",
  8538. W068: "Wrapping non-IIFE function literals in parens is unnecessary.",
  8539. W069: "['{a}'] is better written in dot notation.",
  8540. W070: "Extra comma. (it breaks older versions of IE)",
  8541. W071: "This function has too many statements. ({a})",
  8542. W072: "This function has too many parameters. ({a})",
  8543. W073: "Blocks are nested too deeply. ({a})",
  8544. W074: "This function's cyclomatic complexity is too high. ({a})",
  8545. W075: "Duplicate {a} '{b}'.",
  8546. W076: "Unexpected parameter '{a}' in get {b} function.",
  8547. W077: "Expected a single parameter in set {a} function.",
  8548. W078: "Setter is defined without getter.",
  8549. W079: "Redefinition of '{a}'.",
  8550. W080: "It's not necessary to initialize '{a}' to 'undefined'.",
  8551. W081: null,
  8552. W082: "Function declarations should not be placed in blocks. " +
  8553. "Use a function expression or move the statement to the top of " +
  8554. "the outer function.",
  8555. W083: "Don't make functions within a loop.",
  8556. W084: "Assignment in conditional expression",
  8557. W085: "Don't use 'with'.",
  8558. W086: "Expected a 'break' statement before '{a}'.",
  8559. W087: "Forgotten 'debugger' statement?",
  8560. W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.",
  8561. W089: "The body of a for in should be wrapped in an if statement to filter " +
  8562. "unwanted properties from the prototype.",
  8563. W090: "'{a}' is not a statement label.",
  8564. W091: null,
  8565. W093: "Did you mean to return a conditional instead of an assignment?",
  8566. W094: "Unexpected comma.",
  8567. W095: "Expected a string and instead saw {a}.",
  8568. W096: "The '{a}' key may produce unexpected results.",
  8569. W097: "Use the function form of \"use strict\".",
  8570. W098: "'{a}' is defined but never used.",
  8571. W099: null,
  8572. W100: "This character may get silently deleted by one or more browsers.",
  8573. W101: "Line is too long.",
  8574. W102: null,
  8575. W103: "The '{a}' property is deprecated.",
  8576. W104: "'{a}' is available in ES{b} (use 'esversion: {b}') or Mozilla JS extensions (use moz).",
  8577. W105: "Unexpected {a} in '{b}'.",
  8578. W106: "Identifier '{a}' is not in camel case.",
  8579. W107: "Script URL.",
  8580. W108: "Strings must use doublequote.",
  8581. W109: "Strings must use singlequote.",
  8582. W110: "Mixed double and single quotes.",
  8583. W112: "Unclosed string.",
  8584. W113: "Control character in string: {a}.",
  8585. W114: "Avoid {a}.",
  8586. W115: "Octal literals are not allowed in strict mode.",
  8587. W116: "Expected '{a}' and instead saw '{b}'.",
  8588. W117: "'{a}' is not defined.",
  8589. W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).",
  8590. W119: "'{a}' is only available in ES{b} (use 'esversion: {b}').",
  8591. W120: "You might be leaking a variable ({a}) here.",
  8592. W121: "Extending prototype of native object: '{a}'.",
  8593. W122: "Invalid typeof value '{a}'",
  8594. W123: "'{a}' is already defined in outer scope.",
  8595. W124: "A generator function shall contain a yield statement.",
  8596. W125: "This line contains non-breaking spaces: http://jshint.com/doc/options/#nonbsp",
  8597. W126: "Unnecessary grouping operator.",
  8598. W127: "Unexpected use of a comma operator.",
  8599. W128: "Empty array elements require elision=true.",
  8600. W129: "'{a}' is defined in a future version of JavaScript. Use a " +
  8601. "different variable name to avoid migration issues.",
  8602. W130: "Invalid element after rest element.",
  8603. W131: "Invalid parameter after rest parameter.",
  8604. W132: "`var` declarations are forbidden. Use `let` or `const` instead.",
  8605. W133: "Invalid for-{a} loop left-hand-side: {b}.",
  8606. W134: "The '{a}' option is only available when linting ECMAScript {b} code.",
  8607. W135: "{a} may not be supported by non-browser environments.",
  8608. W136: "'{a}' must be in function scope.",
  8609. W137: "Empty destructuring.",
  8610. W138: "Regular parameters should not come after default parameters."
  8611. };
  8612. var info = {
  8613. I001: "Comma warnings can be turned off with 'laxcomma'.",
  8614. I002: null,
  8615. I003: "ES5 option is now set per default"
  8616. };
  8617. exports.errors = {};
  8618. exports.warnings = {};
  8619. exports.info = {};
  8620. _.each(errors, function(desc, code) {
  8621. exports.errors[code] = { code: code, desc: desc };
  8622. });
  8623. _.each(warnings, function(desc, code) {
  8624. exports.warnings[code] = { code: code, desc: desc };
  8625. });
  8626. _.each(info, function(desc, code) {
  8627. exports.info[code] = { code: code, desc: desc };
  8628. });
  8629. },{"../lodash":"/node_modules/jshint/lodash.js"}],"/node_modules/jshint/src/name-stack.js":[function(_dereq_,module,exports){
  8630. "use strict";
  8631. function NameStack() {
  8632. this._stack = [];
  8633. }
  8634. Object.defineProperty(NameStack.prototype, "length", {
  8635. get: function() {
  8636. return this._stack.length;
  8637. }
  8638. });
  8639. NameStack.prototype.push = function() {
  8640. this._stack.push(null);
  8641. };
  8642. NameStack.prototype.pop = function() {
  8643. this._stack.pop();
  8644. };
  8645. NameStack.prototype.set = function(token) {
  8646. this._stack[this.length - 1] = token;
  8647. };
  8648. NameStack.prototype.infer = function() {
  8649. var nameToken = this._stack[this.length - 1];
  8650. var prefix = "";
  8651. var type;
  8652. if (!nameToken || nameToken.type === "class") {
  8653. nameToken = this._stack[this.length - 2];
  8654. }
  8655. if (!nameToken) {
  8656. return "(empty)";
  8657. }
  8658. type = nameToken.type;
  8659. if (type !== "(string)" && type !== "(number)" && type !== "(identifier)" && type !== "default") {
  8660. return "(expression)";
  8661. }
  8662. if (nameToken.accessorType) {
  8663. prefix = nameToken.accessorType + " ";
  8664. }
  8665. return prefix + nameToken.value;
  8666. };
  8667. module.exports = NameStack;
  8668. },{}],"/node_modules/jshint/src/options.js":[function(_dereq_,module,exports){
  8669. "use strict";
  8670. exports.bool = {
  8671. enforcing: {
  8672. bitwise : true,
  8673. freeze : true,
  8674. camelcase : true,
  8675. curly : true,
  8676. eqeqeq : true,
  8677. futurehostile: true,
  8678. notypeof : true,
  8679. es3 : true,
  8680. es5 : true,
  8681. forin : true,
  8682. funcscope : true,
  8683. immed : true,
  8684. iterator : true,
  8685. newcap : true,
  8686. noarg : true,
  8687. nocomma : true,
  8688. noempty : true,
  8689. nonbsp : true,
  8690. nonew : true,
  8691. undef : true,
  8692. singleGroups: false,
  8693. varstmt: false,
  8694. enforceall : false
  8695. },
  8696. relaxing: {
  8697. asi : true,
  8698. multistr : true,
  8699. debug : true,
  8700. boss : true,
  8701. evil : true,
  8702. globalstrict: true,
  8703. plusplus : true,
  8704. proto : true,
  8705. scripturl : true,
  8706. sub : true,
  8707. supernew : true,
  8708. laxbreak : true,
  8709. laxcomma : true,
  8710. validthis : true,
  8711. withstmt : true,
  8712. moz : true,
  8713. noyield : true,
  8714. eqnull : true,
  8715. lastsemic : true,
  8716. loopfunc : true,
  8717. expr : true,
  8718. esnext : true,
  8719. elision : true,
  8720. },
  8721. environments: {
  8722. mootools : true,
  8723. couch : true,
  8724. jasmine : true,
  8725. jquery : true,
  8726. node : true,
  8727. qunit : true,
  8728. rhino : true,
  8729. shelljs : true,
  8730. prototypejs : true,
  8731. yui : true,
  8732. mocha : true,
  8733. module : true,
  8734. wsh : true,
  8735. worker : true,
  8736. nonstandard : true,
  8737. browser : true,
  8738. browserify : true,
  8739. devel : true,
  8740. dojo : true,
  8741. typed : true,
  8742. phantom : true
  8743. },
  8744. obsolete: {
  8745. onecase : true, // if one case switch statements should be allowed
  8746. regexp : true, // if the . should not be allowed in regexp literals
  8747. regexdash : true // if unescaped first/last dash (-) inside brackets
  8748. }
  8749. };
  8750. exports.val = {
  8751. maxlen : false,
  8752. indent : false,
  8753. maxerr : false,
  8754. predef : false,
  8755. globals : false,
  8756. quotmark : false,
  8757. scope : false,
  8758. maxstatements: false,
  8759. maxdepth : false,
  8760. maxparams : false,
  8761. maxcomplexity: false,
  8762. shadow : false,
  8763. strict : true,
  8764. unused : true,
  8765. latedef : false,
  8766. ignore : false, // start/end ignoring lines of code, bypassing the lexer
  8767. ignoreDelimiters: false, // array of start/end delimiters used to ignore
  8768. esversion: 5
  8769. };
  8770. exports.inverted = {
  8771. bitwise : true,
  8772. forin : true,
  8773. newcap : true,
  8774. plusplus: true,
  8775. regexp : true,
  8776. undef : true,
  8777. eqeqeq : true,
  8778. strict : true
  8779. };
  8780. exports.validNames = Object.keys(exports.val)
  8781. .concat(Object.keys(exports.bool.relaxing))
  8782. .concat(Object.keys(exports.bool.enforcing))
  8783. .concat(Object.keys(exports.bool.obsolete))
  8784. .concat(Object.keys(exports.bool.environments));
  8785. exports.renamed = {
  8786. eqeq : "eqeqeq",
  8787. windows: "wsh",
  8788. sloppy : "strict"
  8789. };
  8790. exports.removed = {
  8791. nomen: true,
  8792. onevar: true,
  8793. passfail: true,
  8794. white: true,
  8795. gcl: true,
  8796. smarttabs: true,
  8797. trailing: true
  8798. };
  8799. exports.noenforceall = {
  8800. varstmt: true,
  8801. strict: true
  8802. };
  8803. },{}],"/node_modules/jshint/src/reg.js":[function(_dereq_,module,exports){
  8804. "use strict";
  8805. exports.unsafeString =
  8806. /@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i;
  8807. exports.unsafeChars =
  8808. /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
  8809. exports.needEsc =
  8810. /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
  8811. exports.needEscGlobal =
  8812. /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
  8813. exports.starSlash = /\*\//;
  8814. exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
  8815. exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
  8816. exports.fallsThrough = /^\s*falls?\sthrough\s*$/;
  8817. exports.maxlenException = /^(?:(?:\/\/|\/\*|\*) ?)?[^ ]+$/;
  8818. },{}],"/node_modules/jshint/src/scope-manager.js":[function(_dereq_,module,exports){
  8819. "use strict";
  8820. var _ = _dereq_("../lodash");
  8821. var events = _dereq_("events");
  8822. var marker = {};
  8823. var scopeManager = function(state, predefined, exported, declared) {
  8824. var _current;
  8825. var _scopeStack = [];
  8826. function _newScope(type) {
  8827. _current = {
  8828. "(labels)": Object.create(null),
  8829. "(usages)": Object.create(null),
  8830. "(breakLabels)": Object.create(null),
  8831. "(parent)": _current,
  8832. "(type)": type,
  8833. "(params)": (type === "functionparams" || type === "catchparams") ? [] : null
  8834. };
  8835. _scopeStack.push(_current);
  8836. }
  8837. _newScope("global");
  8838. _current["(predefined)"] = predefined;
  8839. var _currentFunctBody = _current; // this is the block after the params = function
  8840. var usedPredefinedAndGlobals = Object.create(null);
  8841. var impliedGlobals = Object.create(null);
  8842. var unuseds = [];
  8843. var emitter = new events.EventEmitter();
  8844. function warning(code, token) {
  8845. emitter.emit("warning", {
  8846. code: code,
  8847. token: token,
  8848. data: _.slice(arguments, 2)
  8849. });
  8850. }
  8851. function error(code, token) {
  8852. emitter.emit("warning", {
  8853. code: code,
  8854. token: token,
  8855. data: _.slice(arguments, 2)
  8856. });
  8857. }
  8858. function _setupUsages(labelName) {
  8859. if (!_current["(usages)"][labelName]) {
  8860. _current["(usages)"][labelName] = {
  8861. "(modified)": [],
  8862. "(reassigned)": [],
  8863. "(tokens)": []
  8864. };
  8865. }
  8866. }
  8867. var _getUnusedOption = function(unused_opt) {
  8868. if (unused_opt === undefined) {
  8869. unused_opt = state.option.unused;
  8870. }
  8871. if (unused_opt === true) {
  8872. unused_opt = "last-param";
  8873. }
  8874. return unused_opt;
  8875. };
  8876. var _warnUnused = function(name, tkn, type, unused_opt) {
  8877. var line = tkn.line;
  8878. var chr = tkn.from;
  8879. var raw_name = tkn.raw_text || name;
  8880. unused_opt = _getUnusedOption(unused_opt);
  8881. var warnable_types = {
  8882. "vars": ["var"],
  8883. "last-param": ["var", "param"],
  8884. "strict": ["var", "param", "last-param"]
  8885. };
  8886. if (unused_opt) {
  8887. if (warnable_types[unused_opt] && warnable_types[unused_opt].indexOf(type) !== -1) {
  8888. warning("W098", { line: line, from: chr }, raw_name);
  8889. }
  8890. }
  8891. if (unused_opt || type === "var") {
  8892. unuseds.push({
  8893. name: name,
  8894. line: line,
  8895. character: chr
  8896. });
  8897. }
  8898. };
  8899. function _checkForUnused() {
  8900. if (_current["(type)"] === "functionparams") {
  8901. _checkParams();
  8902. return;
  8903. }
  8904. var curentLabels = _current["(labels)"];
  8905. for (var labelName in curentLabels) {
  8906. if (curentLabels[labelName]) {
  8907. if (curentLabels[labelName]["(type)"] !== "exception" &&
  8908. curentLabels[labelName]["(unused)"]) {
  8909. _warnUnused(labelName, curentLabels[labelName]["(token)"], "var");
  8910. }
  8911. }
  8912. }
  8913. }
  8914. function _checkParams() {
  8915. var params = _current["(params)"];
  8916. if (!params) {
  8917. return;
  8918. }
  8919. var param = params.pop();
  8920. var unused_opt;
  8921. while (param) {
  8922. var label = _current["(labels)"][param];
  8923. unused_opt = _getUnusedOption(state.funct["(unusedOption)"]);
  8924. if (param === "undefined")
  8925. return;
  8926. if (label["(unused)"]) {
  8927. _warnUnused(param, label["(token)"], "param", state.funct["(unusedOption)"]);
  8928. } else if (unused_opt === "last-param") {
  8929. return;
  8930. }
  8931. param = params.pop();
  8932. }
  8933. }
  8934. function _getLabel(labelName) {
  8935. for (var i = _scopeStack.length - 1 ; i >= 0; --i) {
  8936. var scopeLabels = _scopeStack[i]["(labels)"];
  8937. if (scopeLabels[labelName]) {
  8938. return scopeLabels;
  8939. }
  8940. }
  8941. }
  8942. function usedSoFarInCurrentFunction(labelName) {
  8943. for (var i = _scopeStack.length - 1; i >= 0; i--) {
  8944. var current = _scopeStack[i];
  8945. if (current["(usages)"][labelName]) {
  8946. return current["(usages)"][labelName];
  8947. }
  8948. if (current === _currentFunctBody) {
  8949. break;
  8950. }
  8951. }
  8952. return false;
  8953. }
  8954. function _checkOuterShadow(labelName, token) {
  8955. if (state.option.shadow !== "outer") {
  8956. return;
  8957. }
  8958. var isGlobal = _currentFunctBody["(type)"] === "global",
  8959. isNewFunction = _current["(type)"] === "functionparams";
  8960. var outsideCurrentFunction = !isGlobal;
  8961. for (var i = 0; i < _scopeStack.length; i++) {
  8962. var stackItem = _scopeStack[i];
  8963. if (!isNewFunction && _scopeStack[i + 1] === _currentFunctBody) {
  8964. outsideCurrentFunction = false;
  8965. }
  8966. if (outsideCurrentFunction && stackItem["(labels)"][labelName]) {
  8967. warning("W123", token, labelName);
  8968. }
  8969. if (stackItem["(breakLabels)"][labelName]) {
  8970. warning("W123", token, labelName);
  8971. }
  8972. }
  8973. }
  8974. function _latedefWarning(type, labelName, token) {
  8975. if (state.option.latedef) {
  8976. if ((state.option.latedef === true && type === "function") ||
  8977. type !== "function") {
  8978. warning("W003", token, labelName);
  8979. }
  8980. }
  8981. }
  8982. var scopeManagerInst = {
  8983. on: function(names, listener) {
  8984. names.split(" ").forEach(function(name) {
  8985. emitter.on(name, listener);
  8986. });
  8987. },
  8988. isPredefined: function(labelName) {
  8989. return !this.has(labelName) && _.has(_scopeStack[0]["(predefined)"], labelName);
  8990. },
  8991. stack: function(type) {
  8992. var previousScope = _current;
  8993. _newScope(type);
  8994. if (!type && previousScope["(type)"] === "functionparams") {
  8995. _current["(isFuncBody)"] = true;
  8996. _current["(context)"] = _currentFunctBody;
  8997. _currentFunctBody = _current;
  8998. }
  8999. },
  9000. unstack: function() {
  9001. var subScope = _scopeStack.length > 1 ? _scopeStack[_scopeStack.length - 2] : null;
  9002. var isUnstackingFunctionBody = _current === _currentFunctBody,
  9003. isUnstackingFunctionParams = _current["(type)"] === "functionparams",
  9004. isUnstackingFunctionOuter = _current["(type)"] === "functionouter";
  9005. var i, j;
  9006. var currentUsages = _current["(usages)"];
  9007. var currentLabels = _current["(labels)"];
  9008. var usedLabelNameList = Object.keys(currentUsages);
  9009. if (currentUsages.__proto__ && usedLabelNameList.indexOf("__proto__") === -1) {
  9010. usedLabelNameList.push("__proto__");
  9011. }
  9012. for (i = 0; i < usedLabelNameList.length; i++) {
  9013. var usedLabelName = usedLabelNameList[i];
  9014. var usage = currentUsages[usedLabelName];
  9015. var usedLabel = currentLabels[usedLabelName];
  9016. if (usedLabel) {
  9017. var usedLabelType = usedLabel["(type)"];
  9018. if (usedLabel["(useOutsideOfScope)"] && !state.option.funcscope) {
  9019. var usedTokens = usage["(tokens)"];
  9020. if (usedTokens) {
  9021. for (j = 0; j < usedTokens.length; j++) {
  9022. if (usedLabel["(function)"] === usedTokens[j]["(function)"]) {
  9023. error("W038", usedTokens[j], usedLabelName);
  9024. }
  9025. }
  9026. }
  9027. }
  9028. _current["(labels)"][usedLabelName]["(unused)"] = false;
  9029. if (usedLabelType === "const" && usage["(modified)"]) {
  9030. for (j = 0; j < usage["(modified)"].length; j++) {
  9031. error("E013", usage["(modified)"][j], usedLabelName);
  9032. }
  9033. }
  9034. if ((usedLabelType === "function" || usedLabelType === "class") &&
  9035. usage["(reassigned)"]) {
  9036. for (j = 0; j < usage["(reassigned)"].length; j++) {
  9037. error("W021", usage["(reassigned)"][j], usedLabelName, usedLabelType);
  9038. }
  9039. }
  9040. continue;
  9041. }
  9042. if (isUnstackingFunctionOuter) {
  9043. state.funct["(isCapturing)"] = true;
  9044. }
  9045. if (subScope) {
  9046. if (!subScope["(usages)"][usedLabelName]) {
  9047. subScope["(usages)"][usedLabelName] = usage;
  9048. if (isUnstackingFunctionBody) {
  9049. subScope["(usages)"][usedLabelName]["(onlyUsedSubFunction)"] = true;
  9050. }
  9051. } else {
  9052. var subScopeUsage = subScope["(usages)"][usedLabelName];
  9053. subScopeUsage["(modified)"] = subScopeUsage["(modified)"].concat(usage["(modified)"]);
  9054. subScopeUsage["(tokens)"] = subScopeUsage["(tokens)"].concat(usage["(tokens)"]);
  9055. subScopeUsage["(reassigned)"] =
  9056. subScopeUsage["(reassigned)"].concat(usage["(reassigned)"]);
  9057. subScopeUsage["(onlyUsedSubFunction)"] = false;
  9058. }
  9059. } else {
  9060. if (typeof _current["(predefined)"][usedLabelName] === "boolean") {
  9061. delete declared[usedLabelName];
  9062. usedPredefinedAndGlobals[usedLabelName] = marker;
  9063. if (_current["(predefined)"][usedLabelName] === false && usage["(reassigned)"]) {
  9064. for (j = 0; j < usage["(reassigned)"].length; j++) {
  9065. warning("W020", usage["(reassigned)"][j]);
  9066. }
  9067. }
  9068. }
  9069. else {
  9070. if (usage["(tokens)"]) {
  9071. for (j = 0; j < usage["(tokens)"].length; j++) {
  9072. var undefinedToken = usage["(tokens)"][j];
  9073. if (!undefinedToken.forgiveUndef) {
  9074. if (state.option.undef && !undefinedToken.ignoreUndef) {
  9075. warning("W117", undefinedToken, usedLabelName);
  9076. }
  9077. if (impliedGlobals[usedLabelName]) {
  9078. impliedGlobals[usedLabelName].line.push(undefinedToken.line);
  9079. } else {
  9080. impliedGlobals[usedLabelName] = {
  9081. name: usedLabelName,
  9082. line: [undefinedToken.line]
  9083. };
  9084. }
  9085. }
  9086. }
  9087. }
  9088. }
  9089. }
  9090. }
  9091. if (!subScope) {
  9092. Object.keys(declared)
  9093. .forEach(function(labelNotUsed) {
  9094. _warnUnused(labelNotUsed, declared[labelNotUsed], "var");
  9095. });
  9096. }
  9097. if (subScope && !isUnstackingFunctionBody &&
  9098. !isUnstackingFunctionParams && !isUnstackingFunctionOuter) {
  9099. var labelNames = Object.keys(currentLabels);
  9100. for (i = 0; i < labelNames.length; i++) {
  9101. var defLabelName = labelNames[i];
  9102. if (!currentLabels[defLabelName]["(blockscoped)"] &&
  9103. currentLabels[defLabelName]["(type)"] !== "exception" &&
  9104. !this.funct.has(defLabelName, { excludeCurrent: true })) {
  9105. subScope["(labels)"][defLabelName] = currentLabels[defLabelName];
  9106. if (_currentFunctBody["(type)"] !== "global") {
  9107. subScope["(labels)"][defLabelName]["(useOutsideOfScope)"] = true;
  9108. }
  9109. delete currentLabels[defLabelName];
  9110. }
  9111. }
  9112. }
  9113. _checkForUnused();
  9114. _scopeStack.pop();
  9115. if (isUnstackingFunctionBody) {
  9116. _currentFunctBody = _scopeStack[_.findLastIndex(_scopeStack, function(scope) {
  9117. return scope["(isFuncBody)"] || scope["(type)"] === "global";
  9118. })];
  9119. }
  9120. _current = subScope;
  9121. },
  9122. addParam: function(labelName, token, type) {
  9123. type = type || "param";
  9124. if (type === "exception") {
  9125. var previouslyDefinedLabelType = this.funct.labeltype(labelName);
  9126. if (previouslyDefinedLabelType && previouslyDefinedLabelType !== "exception") {
  9127. if (!state.option.node) {
  9128. warning("W002", state.tokens.next, labelName);
  9129. }
  9130. }
  9131. }
  9132. if (_.has(_current["(labels)"], labelName)) {
  9133. _current["(labels)"][labelName].duplicated = true;
  9134. } else {
  9135. _checkOuterShadow(labelName, token, type);
  9136. _current["(labels)"][labelName] = {
  9137. "(type)" : type,
  9138. "(token)": token,
  9139. "(unused)": true };
  9140. _current["(params)"].push(labelName);
  9141. }
  9142. if (_.has(_current["(usages)"], labelName)) {
  9143. var usage = _current["(usages)"][labelName];
  9144. if (usage["(onlyUsedSubFunction)"]) {
  9145. _latedefWarning(type, labelName, token);
  9146. } else {
  9147. warning("E056", token, labelName, type);
  9148. }
  9149. }
  9150. },
  9151. validateParams: function() {
  9152. if (_currentFunctBody["(type)"] === "global") {
  9153. return;
  9154. }
  9155. var isStrict = state.isStrict();
  9156. var currentFunctParamScope = _currentFunctBody["(parent)"];
  9157. if (!currentFunctParamScope["(params)"]) {
  9158. return;
  9159. }
  9160. currentFunctParamScope["(params)"].forEach(function(labelName) {
  9161. var label = currentFunctParamScope["(labels)"][labelName];
  9162. if (label && label.duplicated) {
  9163. if (isStrict) {
  9164. warning("E011", label["(token)"], labelName);
  9165. } else if (state.option.shadow !== true) {
  9166. warning("W004", label["(token)"], labelName);
  9167. }
  9168. }
  9169. });
  9170. },
  9171. getUsedOrDefinedGlobals: function() {
  9172. var list = Object.keys(usedPredefinedAndGlobals);
  9173. if (usedPredefinedAndGlobals.__proto__ === marker &&
  9174. list.indexOf("__proto__") === -1) {
  9175. list.push("__proto__");
  9176. }
  9177. return list;
  9178. },
  9179. getImpliedGlobals: function() {
  9180. var values = _.values(impliedGlobals);
  9181. var hasProto = false;
  9182. if (impliedGlobals.__proto__) {
  9183. hasProto = values.some(function(value) {
  9184. return value.name === "__proto__";
  9185. });
  9186. if (!hasProto) {
  9187. values.push(impliedGlobals.__proto__);
  9188. }
  9189. }
  9190. return values;
  9191. },
  9192. getUnuseds: function() {
  9193. return unuseds;
  9194. },
  9195. has: function(labelName) {
  9196. return Boolean(_getLabel(labelName));
  9197. },
  9198. labeltype: function(labelName) {
  9199. var scopeLabels = _getLabel(labelName);
  9200. if (scopeLabels) {
  9201. return scopeLabels[labelName]["(type)"];
  9202. }
  9203. return null;
  9204. },
  9205. addExported: function(labelName) {
  9206. var globalLabels = _scopeStack[0]["(labels)"];
  9207. if (_.has(declared, labelName)) {
  9208. delete declared[labelName];
  9209. } else if (_.has(globalLabels, labelName)) {
  9210. globalLabels[labelName]["(unused)"] = false;
  9211. } else {
  9212. for (var i = 1; i < _scopeStack.length; i++) {
  9213. var scope = _scopeStack[i];
  9214. if (!scope["(type)"]) {
  9215. if (_.has(scope["(labels)"], labelName) &&
  9216. !scope["(labels)"][labelName]["(blockscoped)"]) {
  9217. scope["(labels)"][labelName]["(unused)"] = false;
  9218. return;
  9219. }
  9220. } else {
  9221. break;
  9222. }
  9223. }
  9224. exported[labelName] = true;
  9225. }
  9226. },
  9227. setExported: function(labelName, token) {
  9228. this.block.use(labelName, token);
  9229. },
  9230. addlabel: function(labelName, opts) {
  9231. var type = opts.type;
  9232. var token = opts.token;
  9233. var isblockscoped = type === "let" || type === "const" || type === "class";
  9234. var isexported = (isblockscoped ? _current : _currentFunctBody)["(type)"] === "global" &&
  9235. _.has(exported, labelName);
  9236. _checkOuterShadow(labelName, token, type);
  9237. if (isblockscoped) {
  9238. var declaredInCurrentScope = _current["(labels)"][labelName];
  9239. if (!declaredInCurrentScope && _current === _currentFunctBody &&
  9240. _current["(type)"] !== "global") {
  9241. declaredInCurrentScope = !!_currentFunctBody["(parent)"]["(labels)"][labelName];
  9242. }
  9243. if (!declaredInCurrentScope && _current["(usages)"][labelName]) {
  9244. var usage = _current["(usages)"][labelName];
  9245. if (usage["(onlyUsedSubFunction)"]) {
  9246. _latedefWarning(type, labelName, token);
  9247. } else {
  9248. warning("E056", token, labelName, type);
  9249. }
  9250. }
  9251. if (declaredInCurrentScope) {
  9252. warning("E011", token, labelName);
  9253. }
  9254. else if (state.option.shadow === "outer") {
  9255. if (scopeManagerInst.funct.has(labelName)) {
  9256. warning("W004", token, labelName);
  9257. }
  9258. }
  9259. scopeManagerInst.block.add(labelName, type, token, !isexported);
  9260. } else {
  9261. var declaredInCurrentFunctionScope = scopeManagerInst.funct.has(labelName);
  9262. if (!declaredInCurrentFunctionScope && usedSoFarInCurrentFunction(labelName)) {
  9263. _latedefWarning(type, labelName, token);
  9264. }
  9265. if (scopeManagerInst.funct.has(labelName, { onlyBlockscoped: true })) {
  9266. warning("E011", token, labelName);
  9267. } else if (state.option.shadow !== true) {
  9268. if (declaredInCurrentFunctionScope && labelName !== "__proto__") {
  9269. if (_currentFunctBody["(type)"] !== "global") {
  9270. warning("W004", token, labelName);
  9271. }
  9272. }
  9273. }
  9274. scopeManagerInst.funct.add(labelName, type, token, !isexported);
  9275. if (_currentFunctBody["(type)"] === "global") {
  9276. usedPredefinedAndGlobals[labelName] = marker;
  9277. }
  9278. }
  9279. },
  9280. funct: {
  9281. labeltype: function(labelName, options) {
  9282. var onlyBlockscoped = options && options.onlyBlockscoped;
  9283. var excludeParams = options && options.excludeParams;
  9284. var currentScopeIndex = _scopeStack.length - (options && options.excludeCurrent ? 2 : 1);
  9285. for (var i = currentScopeIndex; i >= 0; i--) {
  9286. var current = _scopeStack[i];
  9287. if (current["(labels)"][labelName] &&
  9288. (!onlyBlockscoped || current["(labels)"][labelName]["(blockscoped)"])) {
  9289. return current["(labels)"][labelName]["(type)"];
  9290. }
  9291. var scopeCheck = excludeParams ? _scopeStack[ i - 1 ] : current;
  9292. if (scopeCheck && scopeCheck["(type)"] === "functionparams") {
  9293. return null;
  9294. }
  9295. }
  9296. return null;
  9297. },
  9298. hasBreakLabel: function(labelName) {
  9299. for (var i = _scopeStack.length - 1; i >= 0; i--) {
  9300. var current = _scopeStack[i];
  9301. if (current["(breakLabels)"][labelName]) {
  9302. return true;
  9303. }
  9304. if (current["(type)"] === "functionparams") {
  9305. return false;
  9306. }
  9307. }
  9308. return false;
  9309. },
  9310. has: function(labelName, options) {
  9311. return Boolean(this.labeltype(labelName, options));
  9312. },
  9313. add: function(labelName, type, tok, unused) {
  9314. _current["(labels)"][labelName] = {
  9315. "(type)" : type,
  9316. "(token)": tok,
  9317. "(blockscoped)": false,
  9318. "(function)": _currentFunctBody,
  9319. "(unused)": unused };
  9320. }
  9321. },
  9322. block: {
  9323. isGlobal: function() {
  9324. return _current["(type)"] === "global";
  9325. },
  9326. use: function(labelName, token) {
  9327. var paramScope = _currentFunctBody["(parent)"];
  9328. if (paramScope && paramScope["(labels)"][labelName] &&
  9329. paramScope["(labels)"][labelName]["(type)"] === "param") {
  9330. if (!scopeManagerInst.funct.has(labelName,
  9331. { excludeParams: true, onlyBlockscoped: true })) {
  9332. paramScope["(labels)"][labelName]["(unused)"] = false;
  9333. }
  9334. }
  9335. if (token && (state.ignored.W117 || state.option.undef === false)) {
  9336. token.ignoreUndef = true;
  9337. }
  9338. _setupUsages(labelName);
  9339. if (token) {
  9340. token["(function)"] = _currentFunctBody;
  9341. _current["(usages)"][labelName]["(tokens)"].push(token);
  9342. }
  9343. },
  9344. reassign: function(labelName, token) {
  9345. this.modify(labelName, token);
  9346. _current["(usages)"][labelName]["(reassigned)"].push(token);
  9347. },
  9348. modify: function(labelName, token) {
  9349. _setupUsages(labelName);
  9350. _current["(usages)"][labelName]["(modified)"].push(token);
  9351. },
  9352. add: function(labelName, type, tok, unused) {
  9353. _current["(labels)"][labelName] = {
  9354. "(type)" : type,
  9355. "(token)": tok,
  9356. "(blockscoped)": true,
  9357. "(unused)": unused };
  9358. },
  9359. addBreakLabel: function(labelName, opts) {
  9360. var token = opts.token;
  9361. if (scopeManagerInst.funct.hasBreakLabel(labelName)) {
  9362. warning("E011", token, labelName);
  9363. }
  9364. else if (state.option.shadow === "outer") {
  9365. if (scopeManagerInst.funct.has(labelName)) {
  9366. warning("W004", token, labelName);
  9367. } else {
  9368. _checkOuterShadow(labelName, token);
  9369. }
  9370. }
  9371. _current["(breakLabels)"][labelName] = token;
  9372. }
  9373. }
  9374. };
  9375. return scopeManagerInst;
  9376. };
  9377. module.exports = scopeManager;
  9378. },{"../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){
  9379. "use strict";
  9380. var NameStack = _dereq_("./name-stack.js");
  9381. var state = {
  9382. syntax: {},
  9383. isStrict: function() {
  9384. return this.directive["use strict"] || this.inClassBody ||
  9385. this.option.module || this.option.strict === "implied";
  9386. },
  9387. inMoz: function() {
  9388. return this.option.moz;
  9389. },
  9390. inES6: function() {
  9391. return this.option.moz || this.option.esversion >= 6;
  9392. },
  9393. inES5: function(strict) {
  9394. if (strict) {
  9395. return (!this.option.esversion || this.option.esversion === 5) && !this.option.moz;
  9396. }
  9397. return !this.option.esversion || this.option.esversion >= 5 || this.option.moz;
  9398. },
  9399. reset: function() {
  9400. this.tokens = {
  9401. prev: null,
  9402. next: null,
  9403. curr: null
  9404. };
  9405. this.option = {};
  9406. this.funct = null;
  9407. this.ignored = {};
  9408. this.directive = {};
  9409. this.jsonMode = false;
  9410. this.jsonWarnings = [];
  9411. this.lines = [];
  9412. this.tab = "";
  9413. this.cache = {}; // Node.JS doesn't have Map. Sniff.
  9414. this.ignoredLines = {};
  9415. this.forinifcheckneeded = false;
  9416. this.nameStack = new NameStack();
  9417. this.inClassBody = false;
  9418. }
  9419. };
  9420. exports.state = state;
  9421. },{"./name-stack.js":"/node_modules/jshint/src/name-stack.js"}],"/node_modules/jshint/src/style.js":[function(_dereq_,module,exports){
  9422. "use strict";
  9423. exports.register = function(linter) {
  9424. linter.on("Identifier", function style_scanProto(data) {
  9425. if (linter.getOption("proto")) {
  9426. return;
  9427. }
  9428. if (data.name === "__proto__") {
  9429. linter.warn("W103", {
  9430. line: data.line,
  9431. char: data.char,
  9432. data: [ data.name, "6" ]
  9433. });
  9434. }
  9435. });
  9436. linter.on("Identifier", function style_scanIterator(data) {
  9437. if (linter.getOption("iterator")) {
  9438. return;
  9439. }
  9440. if (data.name === "__iterator__") {
  9441. linter.warn("W103", {
  9442. line: data.line,
  9443. char: data.char,
  9444. data: [ data.name ]
  9445. });
  9446. }
  9447. });
  9448. linter.on("Identifier", function style_scanCamelCase(data) {
  9449. if (!linter.getOption("camelcase")) {
  9450. return;
  9451. }
  9452. if (data.name.replace(/^_+|_+$/g, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) {
  9453. linter.warn("W106", {
  9454. line: data.line,
  9455. char: data.from,
  9456. data: [ data.name ]
  9457. });
  9458. }
  9459. });
  9460. linter.on("String", function style_scanQuotes(data) {
  9461. var quotmark = linter.getOption("quotmark");
  9462. var code;
  9463. if (!quotmark) {
  9464. return;
  9465. }
  9466. if (quotmark === "single" && data.quote !== "'") {
  9467. code = "W109";
  9468. }
  9469. if (quotmark === "double" && data.quote !== "\"") {
  9470. code = "W108";
  9471. }
  9472. if (quotmark === true) {
  9473. if (!linter.getCache("quotmark")) {
  9474. linter.setCache("quotmark", data.quote);
  9475. }
  9476. if (linter.getCache("quotmark") !== data.quote) {
  9477. code = "W110";
  9478. }
  9479. }
  9480. if (code) {
  9481. linter.warn(code, {
  9482. line: data.line,
  9483. char: data.char,
  9484. });
  9485. }
  9486. });
  9487. linter.on("Number", function style_scanNumbers(data) {
  9488. if (data.value.charAt(0) === ".") {
  9489. linter.warn("W008", {
  9490. line: data.line,
  9491. char: data.char,
  9492. data: [ data.value ]
  9493. });
  9494. }
  9495. if (data.value.substr(data.value.length - 1) === ".") {
  9496. linter.warn("W047", {
  9497. line: data.line,
  9498. char: data.char,
  9499. data: [ data.value ]
  9500. });
  9501. }
  9502. if (/^00+/.test(data.value)) {
  9503. linter.warn("W046", {
  9504. line: data.line,
  9505. char: data.char,
  9506. data: [ data.value ]
  9507. });
  9508. }
  9509. });
  9510. linter.on("String", function style_scanJavaScriptURLs(data) {
  9511. var re = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
  9512. if (linter.getOption("scripturl")) {
  9513. return;
  9514. }
  9515. if (re.test(data.value)) {
  9516. linter.warn("W107", {
  9517. line: data.line,
  9518. char: data.char
  9519. });
  9520. }
  9521. });
  9522. };
  9523. },{}],"/node_modules/jshint/src/vars.js":[function(_dereq_,module,exports){
  9524. "use strict";
  9525. exports.reservedVars = {
  9526. arguments : false,
  9527. NaN : false
  9528. };
  9529. exports.ecmaIdentifiers = {
  9530. 3: {
  9531. Array : false,
  9532. Boolean : false,
  9533. Date : false,
  9534. decodeURI : false,
  9535. decodeURIComponent : false,
  9536. encodeURI : false,
  9537. encodeURIComponent : false,
  9538. Error : false,
  9539. "eval" : false,
  9540. EvalError : false,
  9541. Function : false,
  9542. hasOwnProperty : false,
  9543. isFinite : false,
  9544. isNaN : false,
  9545. Math : false,
  9546. Number : false,
  9547. Object : false,
  9548. parseInt : false,
  9549. parseFloat : false,
  9550. RangeError : false,
  9551. ReferenceError : false,
  9552. RegExp : false,
  9553. String : false,
  9554. SyntaxError : false,
  9555. TypeError : false,
  9556. URIError : false
  9557. },
  9558. 5: {
  9559. JSON : false
  9560. },
  9561. 6: {
  9562. Map : false,
  9563. Promise : false,
  9564. Proxy : false,
  9565. Reflect : false,
  9566. Set : false,
  9567. Symbol : false,
  9568. WeakMap : false,
  9569. WeakSet : false
  9570. }
  9571. };
  9572. exports.browser = {
  9573. Audio : false,
  9574. Blob : false,
  9575. addEventListener : false,
  9576. applicationCache : false,
  9577. atob : false,
  9578. blur : false,
  9579. btoa : false,
  9580. cancelAnimationFrame : false,
  9581. CanvasGradient : false,
  9582. CanvasPattern : false,
  9583. CanvasRenderingContext2D: false,
  9584. CSS : false,
  9585. clearInterval : false,
  9586. clearTimeout : false,
  9587. close : false,
  9588. closed : false,
  9589. Comment : false,
  9590. CustomEvent : false,
  9591. DOMParser : false,
  9592. defaultStatus : false,
  9593. Document : false,
  9594. document : false,
  9595. DocumentFragment : false,
  9596. Element : false,
  9597. ElementTimeControl : false,
  9598. Event : false,
  9599. event : false,
  9600. fetch : false,
  9601. FileReader : false,
  9602. FormData : false,
  9603. focus : false,
  9604. frames : false,
  9605. getComputedStyle : false,
  9606. HTMLElement : false,
  9607. HTMLAnchorElement : false,
  9608. HTMLBaseElement : false,
  9609. HTMLBlockquoteElement: false,
  9610. HTMLBodyElement : false,
  9611. HTMLBRElement : false,
  9612. HTMLButtonElement : false,
  9613. HTMLCanvasElement : false,
  9614. HTMLCollection : false,
  9615. HTMLDirectoryElement : false,
  9616. HTMLDivElement : false,
  9617. HTMLDListElement : false,
  9618. HTMLFieldSetElement : false,
  9619. HTMLFontElement : false,
  9620. HTMLFormElement : false,
  9621. HTMLFrameElement : false,
  9622. HTMLFrameSetElement : false,
  9623. HTMLHeadElement : false,
  9624. HTMLHeadingElement : false,
  9625. HTMLHRElement : false,
  9626. HTMLHtmlElement : false,
  9627. HTMLIFrameElement : false,
  9628. HTMLImageElement : false,
  9629. HTMLInputElement : false,
  9630. HTMLIsIndexElement : false,
  9631. HTMLLabelElement : false,
  9632. HTMLLayerElement : false,
  9633. HTMLLegendElement : false,
  9634. HTMLLIElement : false,
  9635. HTMLLinkElement : false,
  9636. HTMLMapElement : false,
  9637. HTMLMenuElement : false,
  9638. HTMLMetaElement : false,
  9639. HTMLModElement : false,
  9640. HTMLObjectElement : false,
  9641. HTMLOListElement : false,
  9642. HTMLOptGroupElement : false,
  9643. HTMLOptionElement : false,
  9644. HTMLParagraphElement : false,
  9645. HTMLParamElement : false,
  9646. HTMLPreElement : false,
  9647. HTMLQuoteElement : false,
  9648. HTMLScriptElement : false,
  9649. HTMLSelectElement : false,
  9650. HTMLStyleElement : false,
  9651. HTMLTableCaptionElement: false,
  9652. HTMLTableCellElement : false,
  9653. HTMLTableColElement : false,
  9654. HTMLTableElement : false,
  9655. HTMLTableRowElement : false,
  9656. HTMLTableSectionElement: false,
  9657. HTMLTemplateElement : false,
  9658. HTMLTextAreaElement : false,
  9659. HTMLTitleElement : false,
  9660. HTMLUListElement : false,
  9661. HTMLVideoElement : false,
  9662. history : false,
  9663. Image : false,
  9664. Intl : false,
  9665. length : false,
  9666. localStorage : false,
  9667. location : false,
  9668. matchMedia : false,
  9669. MessageChannel : false,
  9670. MessageEvent : false,
  9671. MessagePort : false,
  9672. MouseEvent : false,
  9673. moveBy : false,
  9674. moveTo : false,
  9675. MutationObserver : false,
  9676. name : false,
  9677. Node : false,
  9678. NodeFilter : false,
  9679. NodeList : false,
  9680. Notification : false,
  9681. navigator : false,
  9682. onbeforeunload : true,
  9683. onblur : true,
  9684. onerror : true,
  9685. onfocus : true,
  9686. onload : true,
  9687. onresize : true,
  9688. onunload : true,
  9689. open : false,
  9690. openDatabase : false,
  9691. opener : false,
  9692. Option : false,
  9693. parent : false,
  9694. performance : false,
  9695. print : false,
  9696. Range : false,
  9697. requestAnimationFrame : false,
  9698. removeEventListener : false,
  9699. resizeBy : false,
  9700. resizeTo : false,
  9701. screen : false,
  9702. scroll : false,
  9703. scrollBy : false,
  9704. scrollTo : false,
  9705. sessionStorage : false,
  9706. setInterval : false,
  9707. setTimeout : false,
  9708. SharedWorker : false,
  9709. status : false,
  9710. SVGAElement : false,
  9711. SVGAltGlyphDefElement: false,
  9712. SVGAltGlyphElement : false,
  9713. SVGAltGlyphItemElement: false,
  9714. SVGAngle : false,
  9715. SVGAnimateColorElement: false,
  9716. SVGAnimateElement : false,
  9717. SVGAnimateMotionElement: false,
  9718. SVGAnimateTransformElement: false,
  9719. SVGAnimatedAngle : false,
  9720. SVGAnimatedBoolean : false,
  9721. SVGAnimatedEnumeration: false,
  9722. SVGAnimatedInteger : false,
  9723. SVGAnimatedLength : false,
  9724. SVGAnimatedLengthList: false,
  9725. SVGAnimatedNumber : false,
  9726. SVGAnimatedNumberList: false,
  9727. SVGAnimatedPathData : false,
  9728. SVGAnimatedPoints : false,
  9729. SVGAnimatedPreserveAspectRatio: false,
  9730. SVGAnimatedRect : false,
  9731. SVGAnimatedString : false,
  9732. SVGAnimatedTransformList: false,
  9733. SVGAnimationElement : false,
  9734. SVGCSSRule : false,
  9735. SVGCircleElement : false,
  9736. SVGClipPathElement : false,
  9737. SVGColor : false,
  9738. SVGColorProfileElement: false,
  9739. SVGColorProfileRule : false,
  9740. SVGComponentTransferFunctionElement: false,
  9741. SVGCursorElement : false,
  9742. SVGDefsElement : false,
  9743. SVGDescElement : false,
  9744. SVGDocument : false,
  9745. SVGElement : false,
  9746. SVGElementInstance : false,
  9747. SVGElementInstanceList: false,
  9748. SVGEllipseElement : false,
  9749. SVGExternalResourcesRequired: false,
  9750. SVGFEBlendElement : false,
  9751. SVGFEColorMatrixElement: false,
  9752. SVGFEComponentTransferElement: false,
  9753. SVGFECompositeElement: false,
  9754. SVGFEConvolveMatrixElement: false,
  9755. SVGFEDiffuseLightingElement: false,
  9756. SVGFEDisplacementMapElement: false,
  9757. SVGFEDistantLightElement: false,
  9758. SVGFEFloodElement : false,
  9759. SVGFEFuncAElement : false,
  9760. SVGFEFuncBElement : false,
  9761. SVGFEFuncGElement : false,
  9762. SVGFEFuncRElement : false,
  9763. SVGFEGaussianBlurElement: false,
  9764. SVGFEImageElement : false,
  9765. SVGFEMergeElement : false,
  9766. SVGFEMergeNodeElement: false,
  9767. SVGFEMorphologyElement: false,
  9768. SVGFEOffsetElement : false,
  9769. SVGFEPointLightElement: false,
  9770. SVGFESpecularLightingElement: false,
  9771. SVGFESpotLightElement: false,
  9772. SVGFETileElement : false,
  9773. SVGFETurbulenceElement: false,
  9774. SVGFilterElement : false,
  9775. SVGFilterPrimitiveStandardAttributes: false,
  9776. SVGFitToViewBox : false,
  9777. SVGFontElement : false,
  9778. SVGFontFaceElement : false,
  9779. SVGFontFaceFormatElement: false,
  9780. SVGFontFaceNameElement: false,
  9781. SVGFontFaceSrcElement: false,
  9782. SVGFontFaceUriElement: false,
  9783. SVGForeignObjectElement: false,
  9784. SVGGElement : false,
  9785. SVGGlyphElement : false,
  9786. SVGGlyphRefElement : false,
  9787. SVGGradientElement : false,
  9788. SVGHKernElement : false,
  9789. SVGICCColor : false,
  9790. SVGImageElement : false,
  9791. SVGLangSpace : false,
  9792. SVGLength : false,
  9793. SVGLengthList : false,
  9794. SVGLineElement : false,
  9795. SVGLinearGradientElement: false,
  9796. SVGLocatable : false,
  9797. SVGMPathElement : false,
  9798. SVGMarkerElement : false,
  9799. SVGMaskElement : false,
  9800. SVGMatrix : false,
  9801. SVGMetadataElement : false,
  9802. SVGMissingGlyphElement: false,
  9803. SVGNumber : false,
  9804. SVGNumberList : false,
  9805. SVGPaint : false,
  9806. SVGPathElement : false,
  9807. SVGPathSeg : false,
  9808. SVGPathSegArcAbs : false,
  9809. SVGPathSegArcRel : false,
  9810. SVGPathSegClosePath : false,
  9811. SVGPathSegCurvetoCubicAbs: false,
  9812. SVGPathSegCurvetoCubicRel: false,
  9813. SVGPathSegCurvetoCubicSmoothAbs: false,
  9814. SVGPathSegCurvetoCubicSmoothRel: false,
  9815. SVGPathSegCurvetoQuadraticAbs: false,
  9816. SVGPathSegCurvetoQuadraticRel: false,
  9817. SVGPathSegCurvetoQuadraticSmoothAbs: false,
  9818. SVGPathSegCurvetoQuadraticSmoothRel: false,
  9819. SVGPathSegLinetoAbs : false,
  9820. SVGPathSegLinetoHorizontalAbs: false,
  9821. SVGPathSegLinetoHorizontalRel: false,
  9822. SVGPathSegLinetoRel : false,
  9823. SVGPathSegLinetoVerticalAbs: false,
  9824. SVGPathSegLinetoVerticalRel: false,
  9825. SVGPathSegList : false,
  9826. SVGPathSegMovetoAbs : false,
  9827. SVGPathSegMovetoRel : false,
  9828. SVGPatternElement : false,
  9829. SVGPoint : false,
  9830. SVGPointList : false,
  9831. SVGPolygonElement : false,
  9832. SVGPolylineElement : false,
  9833. SVGPreserveAspectRatio: false,
  9834. SVGRadialGradientElement: false,
  9835. SVGRect : false,
  9836. SVGRectElement : false,
  9837. SVGRenderingIntent : false,
  9838. SVGSVGElement : false,
  9839. SVGScriptElement : false,
  9840. SVGSetElement : false,
  9841. SVGStopElement : false,
  9842. SVGStringList : false,
  9843. SVGStylable : false,
  9844. SVGStyleElement : false,
  9845. SVGSwitchElement : false,
  9846. SVGSymbolElement : false,
  9847. SVGTRefElement : false,
  9848. SVGTSpanElement : false,
  9849. SVGTests : false,
  9850. SVGTextContentElement: false,
  9851. SVGTextElement : false,
  9852. SVGTextPathElement : false,
  9853. SVGTextPositioningElement: false,
  9854. SVGTitleElement : false,
  9855. SVGTransform : false,
  9856. SVGTransformList : false,
  9857. SVGTransformable : false,
  9858. SVGURIReference : false,
  9859. SVGUnitTypes : false,
  9860. SVGUseElement : false,
  9861. SVGVKernElement : false,
  9862. SVGViewElement : false,
  9863. SVGViewSpec : false,
  9864. SVGZoomAndPan : false,
  9865. Text : false,
  9866. TextDecoder : false,
  9867. TextEncoder : false,
  9868. TimeEvent : false,
  9869. top : false,
  9870. URL : false,
  9871. WebGLActiveInfo : false,
  9872. WebGLBuffer : false,
  9873. WebGLContextEvent : false,
  9874. WebGLFramebuffer : false,
  9875. WebGLProgram : false,
  9876. WebGLRenderbuffer : false,
  9877. WebGLRenderingContext: false,
  9878. WebGLShader : false,
  9879. WebGLShaderPrecisionFormat: false,
  9880. WebGLTexture : false,
  9881. WebGLUniformLocation : false,
  9882. WebSocket : false,
  9883. window : false,
  9884. Window : false,
  9885. Worker : false,
  9886. XDomainRequest : false,
  9887. XMLHttpRequest : false,
  9888. XMLSerializer : false,
  9889. XPathEvaluator : false,
  9890. XPathException : false,
  9891. XPathExpression : false,
  9892. XPathNamespace : false,
  9893. XPathNSResolver : false,
  9894. XPathResult : false
  9895. };
  9896. exports.devel = {
  9897. alert : false,
  9898. confirm: false,
  9899. console: false,
  9900. Debug : false,
  9901. opera : false,
  9902. prompt : false
  9903. };
  9904. exports.worker = {
  9905. importScripts : true,
  9906. postMessage : true,
  9907. self : true,
  9908. FileReaderSync : true
  9909. };
  9910. exports.nonstandard = {
  9911. escape : false,
  9912. unescape: false
  9913. };
  9914. exports.couch = {
  9915. "require" : false,
  9916. respond : false,
  9917. getRow : false,
  9918. emit : false,
  9919. send : false,
  9920. start : false,
  9921. sum : false,
  9922. log : false,
  9923. exports : false,
  9924. module : false,
  9925. provides : false
  9926. };
  9927. exports.node = {
  9928. __filename : false,
  9929. __dirname : false,
  9930. GLOBAL : false,
  9931. global : false,
  9932. module : false,
  9933. require : false,
  9934. Buffer : true,
  9935. console : true,
  9936. exports : true,
  9937. process : true,
  9938. setTimeout : true,
  9939. clearTimeout : true,
  9940. setInterval : true,
  9941. clearInterval : true,
  9942. setImmediate : true, // v0.9.1+
  9943. clearImmediate: true // v0.9.1+
  9944. };
  9945. exports.browserify = {
  9946. __filename : false,
  9947. __dirname : false,
  9948. global : false,
  9949. module : false,
  9950. require : false,
  9951. Buffer : true,
  9952. exports : true,
  9953. process : true
  9954. };
  9955. exports.phantom = {
  9956. phantom : true,
  9957. require : true,
  9958. WebPage : true,
  9959. console : true, // in examples, but undocumented
  9960. exports : true // v1.7+
  9961. };
  9962. exports.qunit = {
  9963. asyncTest : false,
  9964. deepEqual : false,
  9965. equal : false,
  9966. expect : false,
  9967. module : false,
  9968. notDeepEqual : false,
  9969. notEqual : false,
  9970. notPropEqual : false,
  9971. notStrictEqual : false,
  9972. ok : false,
  9973. propEqual : false,
  9974. QUnit : false,
  9975. raises : false,
  9976. start : false,
  9977. stop : false,
  9978. strictEqual : false,
  9979. test : false,
  9980. "throws" : false
  9981. };
  9982. exports.rhino = {
  9983. defineClass : false,
  9984. deserialize : false,
  9985. gc : false,
  9986. help : false,
  9987. importClass : false,
  9988. importPackage: false,
  9989. "java" : false,
  9990. load : false,
  9991. loadClass : false,
  9992. Packages : false,
  9993. print : false,
  9994. quit : false,
  9995. readFile : false,
  9996. readUrl : false,
  9997. runCommand : false,
  9998. seal : false,
  9999. serialize : false,
  10000. spawn : false,
  10001. sync : false,
  10002. toint32 : false,
  10003. version : false
  10004. };
  10005. exports.shelljs = {
  10006. target : false,
  10007. echo : false,
  10008. exit : false,
  10009. cd : false,
  10010. pwd : false,
  10011. ls : false,
  10012. find : false,
  10013. cp : false,
  10014. rm : false,
  10015. mv : false,
  10016. mkdir : false,
  10017. test : false,
  10018. cat : false,
  10019. sed : false,
  10020. grep : false,
  10021. which : false,
  10022. dirs : false,
  10023. pushd : false,
  10024. popd : false,
  10025. env : false,
  10026. exec : false,
  10027. chmod : false,
  10028. config : false,
  10029. error : false,
  10030. tempdir : false
  10031. };
  10032. exports.typed = {
  10033. ArrayBuffer : false,
  10034. ArrayBufferView : false,
  10035. DataView : false,
  10036. Float32Array : false,
  10037. Float64Array : false,
  10038. Int16Array : false,
  10039. Int32Array : false,
  10040. Int8Array : false,
  10041. Uint16Array : false,
  10042. Uint32Array : false,
  10043. Uint8Array : false,
  10044. Uint8ClampedArray : false
  10045. };
  10046. exports.wsh = {
  10047. ActiveXObject : true,
  10048. Enumerator : true,
  10049. GetObject : true,
  10050. ScriptEngine : true,
  10051. ScriptEngineBuildVersion : true,
  10052. ScriptEngineMajorVersion : true,
  10053. ScriptEngineMinorVersion : true,
  10054. VBArray : true,
  10055. WSH : true,
  10056. WScript : true,
  10057. XDomainRequest : true
  10058. };
  10059. exports.dojo = {
  10060. dojo : false,
  10061. dijit : false,
  10062. dojox : false,
  10063. define : false,
  10064. "require": false
  10065. };
  10066. exports.jquery = {
  10067. "$" : false,
  10068. jQuery : false
  10069. };
  10070. exports.mootools = {
  10071. "$" : false,
  10072. "$$" : false,
  10073. Asset : false,
  10074. Browser : false,
  10075. Chain : false,
  10076. Class : false,
  10077. Color : false,
  10078. Cookie : false,
  10079. Core : false,
  10080. Document : false,
  10081. DomReady : false,
  10082. DOMEvent : false,
  10083. DOMReady : false,
  10084. Drag : false,
  10085. Element : false,
  10086. Elements : false,
  10087. Event : false,
  10088. Events : false,
  10089. Fx : false,
  10090. Group : false,
  10091. Hash : false,
  10092. HtmlTable : false,
  10093. IFrame : false,
  10094. IframeShim : false,
  10095. InputValidator: false,
  10096. instanceOf : false,
  10097. Keyboard : false,
  10098. Locale : false,
  10099. Mask : false,
  10100. MooTools : false,
  10101. Native : false,
  10102. Options : false,
  10103. OverText : false,
  10104. Request : false,
  10105. Scroller : false,
  10106. Slick : false,
  10107. Slider : false,
  10108. Sortables : false,
  10109. Spinner : false,
  10110. Swiff : false,
  10111. Tips : false,
  10112. Type : false,
  10113. typeOf : false,
  10114. URI : false,
  10115. Window : false
  10116. };
  10117. exports.prototypejs = {
  10118. "$" : false,
  10119. "$$" : false,
  10120. "$A" : false,
  10121. "$F" : false,
  10122. "$H" : false,
  10123. "$R" : false,
  10124. "$break" : false,
  10125. "$continue" : false,
  10126. "$w" : false,
  10127. Abstract : false,
  10128. Ajax : false,
  10129. Class : false,
  10130. Enumerable : false,
  10131. Element : false,
  10132. Event : false,
  10133. Field : false,
  10134. Form : false,
  10135. Hash : false,
  10136. Insertion : false,
  10137. ObjectRange : false,
  10138. PeriodicalExecuter: false,
  10139. Position : false,
  10140. Prototype : false,
  10141. Selector : false,
  10142. Template : false,
  10143. Toggle : false,
  10144. Try : false,
  10145. Autocompleter : false,
  10146. Builder : false,
  10147. Control : false,
  10148. Draggable : false,
  10149. Draggables : false,
  10150. Droppables : false,
  10151. Effect : false,
  10152. Sortable : false,
  10153. SortableObserver : false,
  10154. Sound : false,
  10155. Scriptaculous : false
  10156. };
  10157. exports.yui = {
  10158. YUI : false,
  10159. Y : false,
  10160. YUI_config: false
  10161. };
  10162. exports.mocha = {
  10163. mocha : false,
  10164. describe : false,
  10165. xdescribe : false,
  10166. it : false,
  10167. xit : false,
  10168. context : false,
  10169. xcontext : false,
  10170. before : false,
  10171. after : false,
  10172. beforeEach : false,
  10173. afterEach : false,
  10174. suite : false,
  10175. test : false,
  10176. setup : false,
  10177. teardown : false,
  10178. suiteSetup : false,
  10179. suiteTeardown : false
  10180. };
  10181. exports.jasmine = {
  10182. jasmine : false,
  10183. describe : false,
  10184. xdescribe : false,
  10185. it : false,
  10186. xit : false,
  10187. beforeEach : false,
  10188. afterEach : false,
  10189. setFixtures : false,
  10190. loadFixtures: false,
  10191. spyOn : false,
  10192. expect : false,
  10193. runs : false,
  10194. waitsFor : false,
  10195. waits : false,
  10196. beforeAll : false,
  10197. afterAll : false,
  10198. fail : false,
  10199. fdescribe : false,
  10200. fit : false,
  10201. pending : false
  10202. };
  10203. },{}]},{},["/node_modules/jshint/src/jshint.js"]);
  10204. });
  10205. ace.define("ace/mode/javascript_worker",["require","exports","module","ace/lib/oop","ace/worker/mirror","ace/mode/javascript/jshint"], function(require, exports, module) {
  10206. "use strict";
  10207. var oop = require("../lib/oop");
  10208. var Mirror = require("../worker/mirror").Mirror;
  10209. var lint = require("./javascript/jshint").JSHINT;
  10210. function startRegex(arr) {
  10211. return RegExp("^(" + arr.join("|") + ")");
  10212. }
  10213. var disabledWarningsRe = startRegex([
  10214. "Bad for in variable '(.+)'.",
  10215. 'Missing "use strict"'
  10216. ]);
  10217. var errorsRe = startRegex([
  10218. "Unexpected",
  10219. "Expected ",
  10220. "Confusing (plus|minus)",
  10221. "\\{a\\} unterminated regular expression",
  10222. "Unclosed ",
  10223. "Unmatched ",
  10224. "Unbegun comment",
  10225. "Bad invocation",
  10226. "Missing space after",
  10227. "Missing operator at"
  10228. ]);
  10229. var infoRe = startRegex([
  10230. "Expected an assignment",
  10231. "Bad escapement of EOL",
  10232. "Unexpected comma",
  10233. "Unexpected space",
  10234. "Missing radix parameter.",
  10235. "A leading decimal point can",
  10236. "\\['{a}'\\] is better written in dot notation.",
  10237. "'{a}' used out of scope"
  10238. ]);
  10239. var JavaScriptWorker = exports.JavaScriptWorker = function(sender) {
  10240. Mirror.call(this, sender);
  10241. this.setTimeout(500);
  10242. this.setOptions();
  10243. };
  10244. oop.inherits(JavaScriptWorker, Mirror);
  10245. (function() {
  10246. this.setOptions = function(options) {
  10247. this.options = options || {
  10248. esnext: true,
  10249. moz: true,
  10250. devel: true,
  10251. browser: true,
  10252. node: true,
  10253. laxcomma: true,
  10254. laxbreak: true,
  10255. lastsemic: true,
  10256. onevar: false,
  10257. passfail: false,
  10258. maxerr: 100,
  10259. expr: true,
  10260. multistr: true,
  10261. globalstrict: true
  10262. };
  10263. this.doc.getValue() && this.deferredUpdate.schedule(100);
  10264. };
  10265. this.changeOptions = function(newOptions) {
  10266. oop.mixin(this.options, newOptions);
  10267. this.doc.getValue() && this.deferredUpdate.schedule(100);
  10268. };
  10269. this.isValidJS = function(str) {
  10270. try {
  10271. eval("throw 0;" + str);
  10272. } catch(e) {
  10273. if (e === 0)
  10274. return true;
  10275. }
  10276. return false
  10277. };
  10278. this.onUpdate = function() {
  10279. var value = this.doc.getValue();
  10280. value = value.replace(/^#!.*\n/, "\n");
  10281. if (!value)
  10282. return this.sender.emit("annotate", []);
  10283. var errors = [];
  10284. var maxErrorLevel = this.isValidJS(value) ? "warning" : "error";
  10285. lint(value, this.options, this.options.globals);
  10286. var results = lint.errors;
  10287. var errorAdded = false
  10288. for (var i = 0; i < results.length; i++) {
  10289. var error = results[i];
  10290. if (!error)
  10291. continue;
  10292. var raw = error.raw;
  10293. var type = "warning";
  10294. if (raw == "Missing semicolon.") {
  10295. var str = error.evidence.substr(error.character);
  10296. str = str.charAt(str.search(/\S/));
  10297. if (maxErrorLevel == "error" && str && /[\w\d{(['"]/.test(str)) {
  10298. error.reason = 'Missing ";" before statement';
  10299. type = "error";
  10300. } else {
  10301. type = "info";
  10302. }
  10303. }
  10304. else if (disabledWarningsRe.test(raw)) {
  10305. continue;
  10306. }
  10307. else if (infoRe.test(raw)) {
  10308. type = "info"
  10309. }
  10310. else if (errorsRe.test(raw)) {
  10311. errorAdded = true;
  10312. type = maxErrorLevel;
  10313. }
  10314. else if (raw == "'{a}' is not defined.") {
  10315. type = "warning";
  10316. }
  10317. else if (raw == "'{a}' is defined but never used.") {
  10318. type = "info";
  10319. }
  10320. errors.push({
  10321. row: error.line-1,
  10322. column: error.character-1,
  10323. text: error.reason,
  10324. type: type,
  10325. raw: raw
  10326. });
  10327. if (errorAdded) {
  10328. }
  10329. }
  10330. this.sender.emit("annotate", errors);
  10331. };
  10332. }).call(JavaScriptWorker.prototype);
  10333. });
  10334. ace.define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
  10335. function Empty() {}
  10336. if (!Function.prototype.bind) {
  10337. Function.prototype.bind = function bind(that) { // .length is 1
  10338. var target = this;
  10339. if (typeof target != "function") {
  10340. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  10341. }
  10342. var args = slice.call(arguments, 1); // for normal call
  10343. var bound = function () {
  10344. if (this instanceof bound) {
  10345. var result = target.apply(
  10346. this,
  10347. args.concat(slice.call(arguments))
  10348. );
  10349. if (Object(result) === result) {
  10350. return result;
  10351. }
  10352. return this;
  10353. } else {
  10354. return target.apply(
  10355. that,
  10356. args.concat(slice.call(arguments))
  10357. );
  10358. }
  10359. };
  10360. if(target.prototype) {
  10361. Empty.prototype = target.prototype;
  10362. bound.prototype = new Empty();
  10363. Empty.prototype = null;
  10364. }
  10365. return bound;
  10366. };
  10367. }
  10368. var call = Function.prototype.call;
  10369. var prototypeOfArray = Array.prototype;
  10370. var prototypeOfObject = Object.prototype;
  10371. var slice = prototypeOfArray.slice;
  10372. var _toString = call.bind(prototypeOfObject.toString);
  10373. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  10374. var defineGetter;
  10375. var defineSetter;
  10376. var lookupGetter;
  10377. var lookupSetter;
  10378. var supportsAccessors;
  10379. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  10380. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  10381. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  10382. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  10383. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  10384. }
  10385. if ([1,2].splice(0).length != 2) {
  10386. if(function() { // test IE < 9 to splice bug - see issue #138
  10387. function makeArray(l) {
  10388. var a = new Array(l+2);
  10389. a[0] = a[1] = 0;
  10390. return a;
  10391. }
  10392. var array = [], lengthBefore;
  10393. array.splice.apply(array, makeArray(20));
  10394. array.splice.apply(array, makeArray(26));
  10395. lengthBefore = array.length; //46
  10396. array.splice(5, 0, "XXX"); // add one element
  10397. lengthBefore + 1 == array.length
  10398. if (lengthBefore + 1 == array.length) {
  10399. return true;// has right splice implementation without bugs
  10400. }
  10401. }()) {//IE 6/7
  10402. var array_splice = Array.prototype.splice;
  10403. Array.prototype.splice = function(start, deleteCount) {
  10404. if (!arguments.length) {
  10405. return [];
  10406. } else {
  10407. return array_splice.apply(this, [
  10408. start === void 0 ? 0 : start,
  10409. deleteCount === void 0 ? (this.length - start) : deleteCount
  10410. ].concat(slice.call(arguments, 2)))
  10411. }
  10412. };
  10413. } else {//IE8
  10414. Array.prototype.splice = function(pos, removeCount){
  10415. var length = this.length;
  10416. if (pos > 0) {
  10417. if (pos > length)
  10418. pos = length;
  10419. } else if (pos == void 0) {
  10420. pos = 0;
  10421. } else if (pos < 0) {
  10422. pos = Math.max(length + pos, 0);
  10423. }
  10424. if (!(pos+removeCount < length))
  10425. removeCount = length - pos;
  10426. var removed = this.slice(pos, pos+removeCount);
  10427. var insert = slice.call(arguments, 2);
  10428. var add = insert.length;
  10429. if (pos === length) {
  10430. if (add) {
  10431. this.push.apply(this, insert);
  10432. }
  10433. } else {
  10434. var remove = Math.min(removeCount, length - pos);
  10435. var tailOldPos = pos + remove;
  10436. var tailNewPos = tailOldPos + add - remove;
  10437. var tailCount = length - tailOldPos;
  10438. var lengthAfterRemove = length - remove;
  10439. if (tailNewPos < tailOldPos) { // case A
  10440. for (var i = 0; i < tailCount; ++i) {
  10441. this[tailNewPos+i] = this[tailOldPos+i];
  10442. }
  10443. } else if (tailNewPos > tailOldPos) { // case B
  10444. for (i = tailCount; i--; ) {
  10445. this[tailNewPos+i] = this[tailOldPos+i];
  10446. }
  10447. } // else, add == remove (nothing to do)
  10448. if (add && pos === lengthAfterRemove) {
  10449. this.length = lengthAfterRemove; // truncate array
  10450. this.push.apply(this, insert);
  10451. } else {
  10452. this.length = lengthAfterRemove + add; // reserves space
  10453. for (i = 0; i < add; ++i) {
  10454. this[pos+i] = insert[i];
  10455. }
  10456. }
  10457. }
  10458. return removed;
  10459. };
  10460. }
  10461. }
  10462. if (!Array.isArray) {
  10463. Array.isArray = function isArray(obj) {
  10464. return _toString(obj) == "[object Array]";
  10465. };
  10466. }
  10467. var boxedString = Object("a"),
  10468. splitString = boxedString[0] != "a" || !(0 in boxedString);
  10469. if (!Array.prototype.forEach) {
  10470. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  10471. var object = toObject(this),
  10472. self = splitString && _toString(this) == "[object String]" ?
  10473. this.split("") :
  10474. object,
  10475. thisp = arguments[1],
  10476. i = -1,
  10477. length = self.length >>> 0;
  10478. if (_toString(fun) != "[object Function]") {
  10479. throw new TypeError(); // TODO message
  10480. }
  10481. while (++i < length) {
  10482. if (i in self) {
  10483. fun.call(thisp, self[i], i, object);
  10484. }
  10485. }
  10486. };
  10487. }
  10488. if (!Array.prototype.map) {
  10489. Array.prototype.map = function map(fun /*, thisp*/) {
  10490. var object = toObject(this),
  10491. self = splitString && _toString(this) == "[object String]" ?
  10492. this.split("") :
  10493. object,
  10494. length = self.length >>> 0,
  10495. result = Array(length),
  10496. thisp = arguments[1];
  10497. if (_toString(fun) != "[object Function]") {
  10498. throw new TypeError(fun + " is not a function");
  10499. }
  10500. for (var i = 0; i < length; i++) {
  10501. if (i in self)
  10502. result[i] = fun.call(thisp, self[i], i, object);
  10503. }
  10504. return result;
  10505. };
  10506. }
  10507. if (!Array.prototype.filter) {
  10508. Array.prototype.filter = function filter(fun /*, thisp */) {
  10509. var object = toObject(this),
  10510. self = splitString && _toString(this) == "[object String]" ?
  10511. this.split("") :
  10512. object,
  10513. length = self.length >>> 0,
  10514. result = [],
  10515. value,
  10516. thisp = arguments[1];
  10517. if (_toString(fun) != "[object Function]") {
  10518. throw new TypeError(fun + " is not a function");
  10519. }
  10520. for (var i = 0; i < length; i++) {
  10521. if (i in self) {
  10522. value = self[i];
  10523. if (fun.call(thisp, value, i, object)) {
  10524. result.push(value);
  10525. }
  10526. }
  10527. }
  10528. return result;
  10529. };
  10530. }
  10531. if (!Array.prototype.every) {
  10532. Array.prototype.every = function every(fun /*, thisp */) {
  10533. var object = toObject(this),
  10534. self = splitString && _toString(this) == "[object String]" ?
  10535. this.split("") :
  10536. object,
  10537. length = self.length >>> 0,
  10538. thisp = arguments[1];
  10539. if (_toString(fun) != "[object Function]") {
  10540. throw new TypeError(fun + " is not a function");
  10541. }
  10542. for (var i = 0; i < length; i++) {
  10543. if (i in self && !fun.call(thisp, self[i], i, object)) {
  10544. return false;
  10545. }
  10546. }
  10547. return true;
  10548. };
  10549. }
  10550. if (!Array.prototype.some) {
  10551. Array.prototype.some = function some(fun /*, thisp */) {
  10552. var object = toObject(this),
  10553. self = splitString && _toString(this) == "[object String]" ?
  10554. this.split("") :
  10555. object,
  10556. length = self.length >>> 0,
  10557. thisp = arguments[1];
  10558. if (_toString(fun) != "[object Function]") {
  10559. throw new TypeError(fun + " is not a function");
  10560. }
  10561. for (var i = 0; i < length; i++) {
  10562. if (i in self && fun.call(thisp, self[i], i, object)) {
  10563. return true;
  10564. }
  10565. }
  10566. return false;
  10567. };
  10568. }
  10569. if (!Array.prototype.reduce) {
  10570. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  10571. var object = toObject(this),
  10572. self = splitString && _toString(this) == "[object String]" ?
  10573. this.split("") :
  10574. object,
  10575. length = self.length >>> 0;
  10576. if (_toString(fun) != "[object Function]") {
  10577. throw new TypeError(fun + " is not a function");
  10578. }
  10579. if (!length && arguments.length == 1) {
  10580. throw new TypeError("reduce of empty array with no initial value");
  10581. }
  10582. var i = 0;
  10583. var result;
  10584. if (arguments.length >= 2) {
  10585. result = arguments[1];
  10586. } else {
  10587. do {
  10588. if (i in self) {
  10589. result = self[i++];
  10590. break;
  10591. }
  10592. if (++i >= length) {
  10593. throw new TypeError("reduce of empty array with no initial value");
  10594. }
  10595. } while (true);
  10596. }
  10597. for (; i < length; i++) {
  10598. if (i in self) {
  10599. result = fun.call(void 0, result, self[i], i, object);
  10600. }
  10601. }
  10602. return result;
  10603. };
  10604. }
  10605. if (!Array.prototype.reduceRight) {
  10606. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  10607. var object = toObject(this),
  10608. self = splitString && _toString(this) == "[object String]" ?
  10609. this.split("") :
  10610. object,
  10611. length = self.length >>> 0;
  10612. if (_toString(fun) != "[object Function]") {
  10613. throw new TypeError(fun + " is not a function");
  10614. }
  10615. if (!length && arguments.length == 1) {
  10616. throw new TypeError("reduceRight of empty array with no initial value");
  10617. }
  10618. var result, i = length - 1;
  10619. if (arguments.length >= 2) {
  10620. result = arguments[1];
  10621. } else {
  10622. do {
  10623. if (i in self) {
  10624. result = self[i--];
  10625. break;
  10626. }
  10627. if (--i < 0) {
  10628. throw new TypeError("reduceRight of empty array with no initial value");
  10629. }
  10630. } while (true);
  10631. }
  10632. do {
  10633. if (i in this) {
  10634. result = fun.call(void 0, result, self[i], i, object);
  10635. }
  10636. } while (i--);
  10637. return result;
  10638. };
  10639. }
  10640. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  10641. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  10642. var self = splitString && _toString(this) == "[object String]" ?
  10643. this.split("") :
  10644. toObject(this),
  10645. length = self.length >>> 0;
  10646. if (!length) {
  10647. return -1;
  10648. }
  10649. var i = 0;
  10650. if (arguments.length > 1) {
  10651. i = toInteger(arguments[1]);
  10652. }
  10653. i = i >= 0 ? i : Math.max(0, length + i);
  10654. for (; i < length; i++) {
  10655. if (i in self && self[i] === sought) {
  10656. return i;
  10657. }
  10658. }
  10659. return -1;
  10660. };
  10661. }
  10662. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  10663. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  10664. var self = splitString && _toString(this) == "[object String]" ?
  10665. this.split("") :
  10666. toObject(this),
  10667. length = self.length >>> 0;
  10668. if (!length) {
  10669. return -1;
  10670. }
  10671. var i = length - 1;
  10672. if (arguments.length > 1) {
  10673. i = Math.min(i, toInteger(arguments[1]));
  10674. }
  10675. i = i >= 0 ? i : length - Math.abs(i);
  10676. for (; i >= 0; i--) {
  10677. if (i in self && sought === self[i]) {
  10678. return i;
  10679. }
  10680. }
  10681. return -1;
  10682. };
  10683. }
  10684. if (!Object.getPrototypeOf) {
  10685. Object.getPrototypeOf = function getPrototypeOf(object) {
  10686. return object.__proto__ || (
  10687. object.constructor ?
  10688. object.constructor.prototype :
  10689. prototypeOfObject
  10690. );
  10691. };
  10692. }
  10693. if (!Object.getOwnPropertyDescriptor) {
  10694. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  10695. "non-object: ";
  10696. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  10697. if ((typeof object != "object" && typeof object != "function") || object === null)
  10698. throw new TypeError(ERR_NON_OBJECT + object);
  10699. if (!owns(object, property))
  10700. return;
  10701. var descriptor, getter, setter;
  10702. descriptor = { enumerable: true, configurable: true };
  10703. if (supportsAccessors) {
  10704. var prototype = object.__proto__;
  10705. object.__proto__ = prototypeOfObject;
  10706. var getter = lookupGetter(object, property);
  10707. var setter = lookupSetter(object, property);
  10708. object.__proto__ = prototype;
  10709. if (getter || setter) {
  10710. if (getter) descriptor.get = getter;
  10711. if (setter) descriptor.set = setter;
  10712. return descriptor;
  10713. }
  10714. }
  10715. descriptor.value = object[property];
  10716. return descriptor;
  10717. };
  10718. }
  10719. if (!Object.getOwnPropertyNames) {
  10720. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  10721. return Object.keys(object);
  10722. };
  10723. }
  10724. if (!Object.create) {
  10725. var createEmpty;
  10726. if (Object.prototype.__proto__ === null) {
  10727. createEmpty = function () {
  10728. return { "__proto__": null };
  10729. };
  10730. } else {
  10731. createEmpty = function () {
  10732. var empty = {};
  10733. for (var i in empty)
  10734. empty[i] = null;
  10735. empty.constructor =
  10736. empty.hasOwnProperty =
  10737. empty.propertyIsEnumerable =
  10738. empty.isPrototypeOf =
  10739. empty.toLocaleString =
  10740. empty.toString =
  10741. empty.valueOf =
  10742. empty.__proto__ = null;
  10743. return empty;
  10744. }
  10745. }
  10746. Object.create = function create(prototype, properties) {
  10747. var object;
  10748. if (prototype === null) {
  10749. object = createEmpty();
  10750. } else {
  10751. if (typeof prototype != "object")
  10752. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  10753. var Type = function () {};
  10754. Type.prototype = prototype;
  10755. object = new Type();
  10756. object.__proto__ = prototype;
  10757. }
  10758. if (properties !== void 0)
  10759. Object.defineProperties(object, properties);
  10760. return object;
  10761. };
  10762. }
  10763. function doesDefinePropertyWork(object) {
  10764. try {
  10765. Object.defineProperty(object, "sentinel", {});
  10766. return "sentinel" in object;
  10767. } catch (exception) {
  10768. }
  10769. }
  10770. if (Object.defineProperty) {
  10771. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  10772. var definePropertyWorksOnDom = typeof document == "undefined" ||
  10773. doesDefinePropertyWork(document.createElement("div"));
  10774. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  10775. var definePropertyFallback = Object.defineProperty;
  10776. }
  10777. }
  10778. if (!Object.defineProperty || definePropertyFallback) {
  10779. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  10780. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  10781. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  10782. "on this javascript engine";
  10783. Object.defineProperty = function defineProperty(object, property, descriptor) {
  10784. if ((typeof object != "object" && typeof object != "function") || object === null)
  10785. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  10786. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  10787. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  10788. if (definePropertyFallback) {
  10789. try {
  10790. return definePropertyFallback.call(Object, object, property, descriptor);
  10791. } catch (exception) {
  10792. }
  10793. }
  10794. if (owns(descriptor, "value")) {
  10795. if (supportsAccessors && (lookupGetter(object, property) ||
  10796. lookupSetter(object, property)))
  10797. {
  10798. var prototype = object.__proto__;
  10799. object.__proto__ = prototypeOfObject;
  10800. delete object[property];
  10801. object[property] = descriptor.value;
  10802. object.__proto__ = prototype;
  10803. } else {
  10804. object[property] = descriptor.value;
  10805. }
  10806. } else {
  10807. if (!supportsAccessors)
  10808. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  10809. if (owns(descriptor, "get"))
  10810. defineGetter(object, property, descriptor.get);
  10811. if (owns(descriptor, "set"))
  10812. defineSetter(object, property, descriptor.set);
  10813. }
  10814. return object;
  10815. };
  10816. }
  10817. if (!Object.defineProperties) {
  10818. Object.defineProperties = function defineProperties(object, properties) {
  10819. for (var property in properties) {
  10820. if (owns(properties, property))
  10821. Object.defineProperty(object, property, properties[property]);
  10822. }
  10823. return object;
  10824. };
  10825. }
  10826. if (!Object.seal) {
  10827. Object.seal = function seal(object) {
  10828. return object;
  10829. };
  10830. }
  10831. if (!Object.freeze) {
  10832. Object.freeze = function freeze(object) {
  10833. return object;
  10834. };
  10835. }
  10836. try {
  10837. Object.freeze(function () {});
  10838. } catch (exception) {
  10839. Object.freeze = (function freeze(freezeObject) {
  10840. return function freeze(object) {
  10841. if (typeof object == "function") {
  10842. return object;
  10843. } else {
  10844. return freezeObject(object);
  10845. }
  10846. };
  10847. })(Object.freeze);
  10848. }
  10849. if (!Object.preventExtensions) {
  10850. Object.preventExtensions = function preventExtensions(object) {
  10851. return object;
  10852. };
  10853. }
  10854. if (!Object.isSealed) {
  10855. Object.isSealed = function isSealed(object) {
  10856. return false;
  10857. };
  10858. }
  10859. if (!Object.isFrozen) {
  10860. Object.isFrozen = function isFrozen(object) {
  10861. return false;
  10862. };
  10863. }
  10864. if (!Object.isExtensible) {
  10865. Object.isExtensible = function isExtensible(object) {
  10866. if (Object(object) === object) {
  10867. throw new TypeError(); // TODO message
  10868. }
  10869. var name = '';
  10870. while (owns(object, name)) {
  10871. name += '?';
  10872. }
  10873. object[name] = true;
  10874. var returnValue = owns(object, name);
  10875. delete object[name];
  10876. return returnValue;
  10877. };
  10878. }
  10879. if (!Object.keys) {
  10880. var hasDontEnumBug = true,
  10881. dontEnums = [
  10882. "toString",
  10883. "toLocaleString",
  10884. "valueOf",
  10885. "hasOwnProperty",
  10886. "isPrototypeOf",
  10887. "propertyIsEnumerable",
  10888. "constructor"
  10889. ],
  10890. dontEnumsLength = dontEnums.length;
  10891. for (var key in {"toString": null}) {
  10892. hasDontEnumBug = false;
  10893. }
  10894. Object.keys = function keys(object) {
  10895. if (
  10896. (typeof object != "object" && typeof object != "function") ||
  10897. object === null
  10898. ) {
  10899. throw new TypeError("Object.keys called on a non-object");
  10900. }
  10901. var keys = [];
  10902. for (var name in object) {
  10903. if (owns(object, name)) {
  10904. keys.push(name);
  10905. }
  10906. }
  10907. if (hasDontEnumBug) {
  10908. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  10909. var dontEnum = dontEnums[i];
  10910. if (owns(object, dontEnum)) {
  10911. keys.push(dontEnum);
  10912. }
  10913. }
  10914. }
  10915. return keys;
  10916. };
  10917. }
  10918. if (!Date.now) {
  10919. Date.now = function now() {
  10920. return new Date().getTime();
  10921. };
  10922. }
  10923. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  10924. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  10925. "\u2029\uFEFF";
  10926. if (!String.prototype.trim || ws.trim()) {
  10927. ws = "[" + ws + "]";
  10928. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  10929. trimEndRegexp = new RegExp(ws + ws + "*$");
  10930. String.prototype.trim = function trim() {
  10931. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  10932. };
  10933. }
  10934. function toInteger(n) {
  10935. n = +n;
  10936. if (n !== n) { // isNaN
  10937. n = 0;
  10938. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  10939. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  10940. }
  10941. return n;
  10942. }
  10943. function isPrimitive(input) {
  10944. var type = typeof input;
  10945. return (
  10946. input === null ||
  10947. type === "undefined" ||
  10948. type === "boolean" ||
  10949. type === "number" ||
  10950. type === "string"
  10951. );
  10952. }
  10953. function toPrimitive(input) {
  10954. var val, valueOf, toString;
  10955. if (isPrimitive(input)) {
  10956. return input;
  10957. }
  10958. valueOf = input.valueOf;
  10959. if (typeof valueOf === "function") {
  10960. val = valueOf.call(input);
  10961. if (isPrimitive(val)) {
  10962. return val;
  10963. }
  10964. }
  10965. toString = input.toString;
  10966. if (typeof toString === "function") {
  10967. val = toString.call(input);
  10968. if (isPrimitive(val)) {
  10969. return val;
  10970. }
  10971. }
  10972. throw new TypeError();
  10973. }
  10974. var toObject = function (o) {
  10975. if (o == null) { // this matches both null and undefined
  10976. throw new TypeError("can't convert "+o+" to object");
  10977. }
  10978. return Object(o);
  10979. };
  10980. });